瀏覽代碼

平房仓 整合

gaodd 3 年之前
父節點
當前提交
e3dddb810c

+ 101 - 73
src/main/java/com/unissoft/interaction/algorithm/SquareAlg.java

@@ -12,15 +12,25 @@ import java.util.List;
12 12
  */
13 13
 public class SquareAlg {
14 14
 
15
+	/**
16
+	 * 定义常量  减速机传动比
17
+	 */
18
+	public static int basicData = 50;
15 19
 	
16
-	 public static String getAveragePosition(double houseWideOn, double houseWideUnder, double houseLengthLeft, double houseLengthRight,double houseHigh) {
20
+	//0.5米做安全隔墙
21
+	public static double boundaryValue = 0.5;
22
+	
23
+	//每隔2米打一个点
24
+	public static double spacingDistance = 2;
25
+	
26
+	public static String getAveragePosition(double houseWideOn, double houseWideUnder, double houseLengthLeft, double houseLengthRight,double houseHigh) {
17 27
 		 
18 28
 			StringBuffer sb = new StringBuffer();   
19 29
 			String str = "";
20 30
 			//AC 是设备到地面/粮面最高点的高
21 31
 			double AC = houseHigh;
22 32
 			/**
23
-			 * 设备安装的点为o 设备到左面的点为a上面的点为b 右面的点为c 下面的点为d
33
+			 * 设备安装的点为o 设备到左面的点为a 上面的点为b 右面的点为c 下面的点为d
24 34
 			 * oa ob oc od 根据设备可以获取得到 
25 35
 			 * 以o为起点每间隔两米打一个点
26 36
 			 * 		b
@@ -31,8 +41,8 @@ public class SquareAlg {
31 41
 			 * | 3 |	4	   |
32 42
 			 * |---------------|
33 43
 			 * 		d
34
-			 * 水平方向的 以bd为开始 向左即(2和4 区域的)是反方向的;(23区域)是正方向的
35
-			 * 垂直方向 以ac为开始 向上即(1和2区域的)是正方向;(3和4区域)是反方向的
44
+			 * 水平转动的方向 以bd为开始 向左即(1和4 区域的)是反方向的;(23区域)是正方向的
45
+			 * 垂直转动的方向 以ac为开始 向上即(1和2区域的)是正方向;(3和4区域)是反方向的
36 46
 			 * 
37 47
 			 */
38 48
 			double oa = houseLengthLeft;
@@ -41,36 +51,37 @@ public class SquareAlg {
41 51
 			double od = houseWideUnder;
42 52
 			/**
43 53
 			 * 第一块
44
-			 * 以o为起点 oa、ob方向每隔米打一个点 
54
+			 * 以o为起点 oa、ob方向每隔spacingDistance米打一个点 
45 55
 			 * +1是把起点o算上
46 56
 			 * 打出来的点 包括区域里的和x轴和y轴
47 57
 			 */
48
-			double x = 0;
49
-			double y = 0;
50
-			double AB = 0; //理想状态 打出来三角形的底边AB 实际是平面上点的斜边
58
+			double x = 0;//点的横坐标
59
+			double y = 0;//点的纵坐标
60
+			double AB = 0; //理想状态 垂直三角形的底边AB 实际是平面三角形的斜边
51 61
 		    double level_angle = 0;//水平转动的角度
52
-		    double BC = 0; //设备和粮面点之间的距离
53 62
 		    double vertical_angle = 0;//垂直转动角度
63
+		    double BC = 0; //设备和粮面点之间的距离
54 64
 		    
55 65
 		    int level_angle1 = 0;//水平转动的角度
56 66
 		    int vertical_angle1 = 0;//垂直转动角度
57
-			for (int i = 0; i < Math.floor(ob/2)+1 ; i++) {
58
-			  for(int j = 0; j < Math.floor(oa/2)+1 ; j++){
59
-				  x = -2*j;
60
-				  y = 2*i;
67
+			for (int i = 0; i < Math.floor(ob/spacingDistance)+1 ; i++) {//i和j表示点的个数
68
+			  for(int j = 0; j < Math.floor(oa/spacingDistance)+1 ; j++){
69
+				  x = -spacingDistance * j;
70
+				  y = spacingDistance * i;
61 71
 				  //System.out.println("("+x+","+y+")");
62 72
 				  AB = Math.sqrt(x*x+y*y);
63
-				  if(x == 0 && y>=0){
73
+				  if(x == 0 && y >= 0){
64 74
 					  level_angle = 0;
65
-				  }else if(y == 0 && x<0){ 
75
+				  }else if(y == 0 && x != 0){ 
66 76
 					  level_angle = -90;
67 77
 				  }else{
68 78
 					  level_angle = -Math.toDegrees(Math.atan((Math.abs(x))/y));
69 79
 				  }
70 80
 				  BC = Math.sqrt(AB*AB+AC*AC);
71 81
 				  vertical_angle = Math.toDegrees(Math.acos(AC/BC));
72
-				  level_angle1 = (int) Math.round(level_angle);
73
-				  vertical_angle1 = (int) Math.round(vertical_angle);
82
+				  
83
+				  level_angle1 =  (int) (Math.round(level_angle) * basicData);
84
+				  vertical_angle1 =  (int) (Math.round(vertical_angle) * basicData);
74 85
 				  
75 86
 				  str = vertical_angle1 + ","+level_angle1+";";
76 87
 				  sb.append(str);
@@ -85,10 +96,10 @@ public class SquareAlg {
85 96
 			 * 
86 97
 			 * 打出来的点 只有 x轴和区域的点
87 98
 			 */
88
-			for(int i = 0; i < Math.floor(ob/2)+1 ; i++){
89
-				for(int j = 1; j <= Math.floor(oc/2) ; j++){
90
-					  x = 2*j;
91
-					  y = 2*i;
99
+			for(int i = 0; i < Math.floor(ob/spacingDistance)+1 ; i++){
100
+				for(int j = 1; j <= Math.floor(oc/spacingDistance) ; j++){
101
+					  x = spacingDistance * j;
102
+					  y = spacingDistance * i;
92 103
 					  //System.out.println("("+x+","+y+")");
93 104
 					  AB = Math.sqrt(x*x+y*y);
94 105
 					  if(y == 0){
@@ -98,8 +109,9 @@ public class SquareAlg {
98 109
 					  }
99 110
 					  BC = Math.sqrt(AB*AB+AC*AC);
100 111
 					  vertical_angle = Math.toDegrees(Math.acos(AC/BC));
101
-					  level_angle1 = (int) Math.round(level_angle);
102
-					  vertical_angle1 = (int) Math.round(vertical_angle);
112
+					  
113
+					  level_angle1 = (int) Math.round(level_angle) * basicData;
114
+					  vertical_angle1 = (int) Math.round(vertical_angle) *basicData;
103 115
 					  str = vertical_angle1 + ","+level_angle1+";";
104 116
 					  sb.append(str);
105 117
 				}
@@ -113,10 +125,10 @@ public class SquareAlg {
113 125
 			 * 打出来的点 包括区域里的和y轴
114 126
 			 */
115 127
 			
116
-			for (int i = 1; i <= Math.floor(oa/2)+1 ; i++) {
117
-			  for(int j = 0; j < Math.floor(od/2) ; j++){
118
-				  x = -2*j;
119
-				  y = -2*i;
128
+			for (int i = 1; i < Math.floor(od/spacingDistance)+1 ; i++) {
129
+				  for(int j = 0; j < Math.floor(oa/spacingDistance)+1 ; j++){
130
+				  x = -spacingDistance * j;
131
+				  y = -spacingDistance * i;
120 132
 				  //System.out.println("("+x+","+y+")");
121 133
 				  AB = Math.sqrt(x*x+y*y);
122 134
 				  if(x == 0){
@@ -126,8 +138,8 @@ public class SquareAlg {
126 138
 				  }
127 139
 				  BC = Math.sqrt(AB*AB+AC*AC);
128 140
 				  vertical_angle = -Math.toDegrees(Math.acos(AC/BC));
129
-				  level_angle1 = (int) Math.round(level_angle);
130
-				  vertical_angle1 = (int) Math.round(vertical_angle);
141
+				  level_angle1 = (int) Math.round(level_angle) * basicData;
142
+				  vertical_angle1 = (int) Math.round(vertical_angle) * basicData;
131 143
 				  str = vertical_angle1 + ","+level_angle1+";";
132 144
 				  sb.append(str);
133 145
 			  }
@@ -139,40 +151,40 @@ public class SquareAlg {
139 151
 			 * 以o为起点 oc、od方向每隔两米打一个点 
140 152
 			 * 打出来的点 只有区域的点
141 153
 			 */
142
-			for(int i = 1; i <= Math.floor(oc/2) ; i++){
143
-				for(int j = 1; j <= Math.floor(od/2) ; j++){
144
-					  x = 2*i;
145
-					  y = -2*j;
154
+			for(int i = 1; i <= Math.floor(oc/spacingDistance) ; i++){
155
+				for(int j = 1; j <= Math.floor(od/spacingDistance) ; j++){
156
+					  x = spacingDistance * i;
157
+					  y = -spacingDistance * j;
146 158
 					 // System.out.println("("+x+","+y+")");
147 159
 					  AB = Math.sqrt(x*x+y*y);
148 160
 					  level_angle = -Math.toDegrees(Math.atan(x/(Math.abs(y))));
149 161
 					  BC = Math.sqrt(AB*AB+AC*AC);
150 162
 					  vertical_angle = -Math.toDegrees(Math.acos(AC/BC));
151
-					  level_angle1 = (int) Math.round(level_angle);
152
-					  vertical_angle1 = (int) Math.round(vertical_angle);
163
+					  level_angle1 = (int) Math.round(level_angle) * basicData;
164
+					  vertical_angle1 = (int) Math.round(vertical_angle) * basicData;
153 165
 					  str = vertical_angle1 + ","+level_angle1+";";
154 166
 					  sb.append(str);
155 167
 				}
156 168
 				
157 169
 			}
158
-			 //System.out.println(sb);
159
-		 return sb.toString();
170
+			String returnString = sb.substring(0, sb.length()-1);
171
+			//System.out.println(returnString);
172
+
173
+		 return returnString;
160 174
 		 
161 175
 	 }
162 176
 	 
163 177
 	 
164 178
 	   /**
165
-	     * 计算  粮面点到设备的垂直距离(有效点)
179
+	     * 计算  z的有效点
166 180
 	     *
167 181
 	     * @param rotationxy
168 182
 	     * @return
169 183
 	     */
170
-	    public static List<Double> zHeight(String rotationxy,double houseWideOn,double houseWideUnder,double houseLengthLeft,double houseLengthRight) {
184
+	    public static List<Double> zHeight(String rotationxy,double houseWideOn,double houseWideUnder,double houseLengthLeft,double houseLengthRight,double houseHight) {
171 185
 
172 186
 			List<Double> zList = new ArrayList<Double>();
173 187
 			
174
-			//返回的结果集
175
-			//String rotationxy ="";
176 188
 			//垂直角度
177 189
 			double verticalAngle = 0;
178 190
 			//水平角度
@@ -191,19 +203,19 @@ public class SquareAlg {
191 203
 	        double x = 0;
192 204
 	        //真实的点的纵坐标的距离
193 205
 	        double y = 0;
194
-	        //加0.5后的横纵坐标
206
+	        //加一个边界值后的横纵坐标
195 207
 	        double x1 = 0;
196 208
 	        double y1 = 0;
197 209
 	       //以粮面为基准面的高
198
-	        double zHigh = 0;
210
+	        //double zHigh = 0;
199 211
 	        
200 212
 	        double oa = houseLengthLeft; //x的左半轴(长)
201 213
     		double ob = houseWideOn; //y的上半轴(宽)
202 214
     		double oc = houseLengthRight; //x的右半轴(长)
203 215
     		double od = houseWideUnder; //y的下半轴(宽)
204 216
     		
205
-	        //基数 51
206
-	        BigDecimal baseNumber = new BigDecimal(51);
217
+	        //基数 
218
+	        BigDecimal baseNumber = new BigDecimal(basicData);
207 219
 	        
208 220
 			String[] split = rotationxy.split(";");
209 221
 	        for (int i = 0; i < split.length; i++) {
@@ -217,67 +229,75 @@ public class SquareAlg {
217 229
 	             * 去掉打在墙上的点(计算正式的点的坐标,横纵坐标只要有一个>(边-0.5)即为墙上的点)
218 230
 	             */
219 231
 	            
220
-	            String verticalAngleS = String.format("%.2f%n", Math.sin(Math.abs(verticalAngle)));
221
-	            double verticalSinc = new Double(verticalAngleS);
222
-	            //即 平面三角形的斜边
223
-	            A1B1 = realHypotenuse * verticalSinc; 
232
+	            //将垂直的角度转化为弧度
233
+	            double verticalAngleRadians = Math.toRadians(verticalAngle);
234
+	            //垂直角度的sin
235
+	            String verticalAngleS = String.format("%.2f%n", Math.sin(verticalAngleRadians));
236
+	            double sinVerticalAngle = new Double(verticalAngleS);
237
+	            //垂直角度的cos
238
+	            String verticalC = String.format("%.2f%n", Math.cos(Math.abs(verticalAngleRadians)));
239
+	            double cosVertical = new Double(verticalC);
224 240
 	            
225
-
226
-	            String levelSinStr = String.format("%.2f%n", Math.sin(Math.abs(levelAngle)));
227
-	            double levelSina = new Double(levelSinStr);
241
+	            //将水平的角度转化为弧度
242
+	            double levelAngleRadians = Math.toRadians(levelAngle);
243
+	            //水平角度的sin
244
+	            String levelSinStr = String.format("%.2f%n", Math.sin(Math.abs(levelAngleRadians)));
245
+	            double sinLevelAngle = new Double(levelSinStr);
246
+	            //水平角度的cos
247
+	            String levelCosStr = String.format("%.2f%n", Math.cos(Math.abs(levelAngleRadians)));
248
+	            double cosLevelAngle = new Double(levelCosStr);
228 249
 	            
229
-	            String levelCosStr = String.format("%.2f%n", Math.cos(Math.abs(levelAngle)));
230
-	            double levelCosa = new Double(levelCosStr);
250
+	            //平面三角形的斜边
251
+	            A1B1 = realHypotenuse * sinVerticalAngle;
231 252
 	            
232
-	            //横坐标的距离
233
-	            x = A1B1 * levelCosa;
234
-	            //纵坐标的距离
235
-	            y = A1B1 * levelSina;
253
+	            //横坐标的距离(只有长度)
254
+	            x = Math.abs(A1B1 * cosLevelAngle ) ;
255
+	            //纵坐标的距离(只有长度)
256
+	            y = Math.abs(A1B1 * sinLevelAngle ) ;
236 257
 	            
237 258
 	            //判断真实的坐标与长宽的距离
238 259
 	            //四面都减少0.5米做安全隔墙 只要不在这范围的都算打在墙上(真实的坐标的距离都加0.5小于实际的边即可)
239 260
 	            
261
+	    		//加0.5后的横纵坐标的距离
262
+	    		x1 = x + boundaryValue;
263
+	    		y1 = y + boundaryValue;
240 264
 	    		
241
-	    		//加0.5后的横纵坐标
242
-	    		x1 = x + 0.5;
243
-	    		y1 = y + 0.5;
244
-	    		
245
-	    		 String verticalC = String.format("%.2f%n", Math.cos(Math.abs(verticalAngle)));
246
-	             double verticalCosc = new Double(verticalC);
265
+	    		 
247 266
 	             //A1C 是粮面点到设备的垂直距离
248
-	             double A1C = realHypotenuse * verticalCosc; 
267
+	             double A1C = realHypotenuse * cosVertical; 
268
+	             double z = houseHight - A1C;
249 269
 	             
250 270
 	            if(levelAngle < 0 && verticalAngle>0 ){
251 271
 	            	//第一区域
252 272
 	            	if(x1<oa && y1<ob){
253
-	                     zList.add(A1C);
273
+	                     zList.add(z);
254 274
 	            	}
255 275
 	            }else if(levelAngle > 0 && verticalAngle>0){
256 276
 	            	//第二区域
257 277
 	            	if(x1<oc && y1<ob){
258
-	                    zList.add(A1C);
278
+	                    zList.add(z);
259 279
 	           	    }
260 280
 	            	
261 281
 	            }else if(levelAngle > 0 && verticalAngle<0){
262 282
 	            	//第三区域
263 283
 	            	if(x1<oa && y1<od){
264
-	                    zList.add(A1C);
284
+	                    zList.add(z);
265 285
 	           	    }
266 286
 	            	
267 287
 	            }else if(levelAngle < 0 && verticalAngle<0){
268 288
 	            	//第四区域
269 289
 	            	if(x1<oc && y1<od){
270
-	                    zList.add(A1C);
290
+	                    zList.add(z);
271 291
 	           	    }
272 292
 	            }else if(levelAngle == 0 || levelAngle == -90 || levelAngle == 90){
273
-	            	//
293
+	            	//坐标轴上的点
274 294
 	            	if(verticalAngle>0){
275 295
 	            		if(y1<ob){
276
-	            			zList.add(A1C);
296
+	            			zList.add(z);
277 297
 	            		}
278 298
 	            	}else if(verticalAngle<0){
279 299
 	            		if(y1<od){
280
-	            			zList.add(A1C);
300
+	            			zList.add(z);
281 301
 	            		}
282 302
 	            	}
283 303
 	            }
@@ -290,6 +310,14 @@ public class SquareAlg {
290 310
 	    
291 311
 	    
292 312
 	    /**
293
-	     * 去除打在墙上的点
313
+	     * 计算体积---------------todo
314
+	     *
315
+	     * @param zList 粮面高集合(z值的集合)
294 316
 	     */
317
+	    public static double calculateVolume(List<Double> zList,double houseWideOn,double houseWideUnder,double houseLengthLeft,double houseLengthRight,double houseHight) {
318
+	    	double v = 0; 
319
+	    	return v;
320
+	    }
321
+	    
322
+	    
295 323
 }

+ 28 - 1
src/main/java/com/unissoft/interaction/controller/DataController.java

@@ -1,10 +1,15 @@
1 1
 package com.unissoft.interaction.controller;
2 2
 
3 3
 import com.unissoft.interaction.entity.TeData;
4
+import com.unissoft.interaction.service.SquareService;
4 5
 import com.unissoft.interaction.service.TeDataService;
6
+import com.unissoft.systemManage.model.OrgInfo;
7
+import com.unissoft.systemManage.service.OrgInfoService;
5 8
 
6 9
 import java.util.Date;
7 10
 
11
+import javax.annotation.Resource;
12
+
8 13
 import org.slf4j.Logger;
9 14
 import org.slf4j.LoggerFactory;
10 15
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,11 +23,23 @@ public class DataController {
18 23
 
19 24
     private TeDataService teDataService;
20 25
 
26
+    private SquareService squareService;
27
+
21 28
     @Autowired
22 29
     public void setTeDataService(TeDataService teDataService) {
23 30
         this.teDataService = teDataService;
24 31
     }
32
+    
33
+    @Autowired
34
+    public void setSquareService(SquareService squareService) {
35
+        this.squareService = squareService;
36
+    }
37
+    
38
+    
25 39
 
40
+    @Resource
41
+    private OrgInfoService orgInfoService;
42
+    
26 43
     /**
27 44
      * 检测后数据
28 45
      *
@@ -37,7 +54,17 @@ public class DataController {
37 54
         if (inum < 0) {
38 55
             return "fail";
39 56
         }
40
-        teDataService.scanTask(teData);//进行下一次的打点
57
+        String houseId = teData.getTaskID().split(",")[0];	
58
+        //查询仓房信息 判断是平房仓还是圆筒仓
59
+        OrgInfo orgInfoHouse = orgInfoService.getById(Integer.parseInt(houseId));
60
+   	    String houseType = orgInfoHouse.getHouseType();
61
+        //20 筒仓  21 平房仓
62
+   	    if(houseType.equals("20")){
63
+   	        teDataService.scanTask(teData);//进行下一次的打点
64
+   	    }else if(houseType.equals("21")){
65
+   	    	squareService.scanTask(teData); //下一次打点
66
+   	    }
67
+        
41 68
         return "success";
42 69
     }
43 70
 

+ 10 - 9
src/main/java/com/unissoft/interaction/controller/SquareController.java

@@ -1,4 +1,4 @@
1
-package com.unissoft.interaction.controller;
1
+/*package com.unissoft.interaction.controller;
2 2
 
3 3
 import com.unissoft.interaction.entity.TeData;
4 4
 import com.unissoft.interaction.service.SquareService;
@@ -10,11 +10,11 @@ import org.slf4j.LoggerFactory;
10 10
 import org.springframework.beans.factory.annotation.Autowired;
11 11
 import org.springframework.web.bind.annotation.*;
12 12
 
13
-/**
13
+*//**
14 14
  * 平房仓
15 15
  * @author My Sunshine
16 16
  *
17
- */
17
+ *//*
18 18
 @RestController
19 19
 @RequestMapping(value = "/square")
20 20
 public class SquareController {
@@ -28,12 +28,12 @@ public class SquareController {
28 28
         this.squareService = squareService;
29 29
     }
30 30
 
31
-    /**
31
+    *//**
32 32
      * 检测后数据
33 33
      *
34 34
      * @param teData
35 35
      * @return
36
-     */
36
+     *//*
37 37
     @PostMapping("/equipmentTestingEnd")
38 38
     public String equipmentTesting(@RequestBody TeData teData) {
39 39
         logger.info("接收到的数据为{}", teData);
@@ -47,12 +47,12 @@ public class SquareController {
47 47
         return "success";
48 48
     }
49 49
 
50
-    /**
50
+    *//**
51 51
      * @param houseWideOn 仓房宽的上半部分
52 52
      * @param houseWideUnder 仓房宽的下半部分
53 53
      * houseLengthLeft 仓房长的左半部分
54 54
      * houseLengthRight 仓房长的右半部分
55
-     */
55
+     *//*
56 56
     @GetMapping("/scanning")
57 57
     public void scanning(@RequestParam(value = "houseWideOn", defaultValue = "35") double houseWideOn,
58 58
                          @RequestParam(value = "houseWideUnder ", defaultValue = "12") double houseWideUnder,
@@ -66,10 +66,11 @@ public class SquareController {
66 66
     }
67 67
     
68 68
     
69
-    /*@GetMapping("/scanningss")
69
+    @GetMapping("/scanningss")
70 70
     public void scanningss() {
71 71
         squareService.calculateVolume("2022030111");
72
-    }*/
72
+    }
73 73
     
74 74
     
75 75
 }
76
+*/

+ 2 - 2
src/main/java/com/unissoft/interaction/service/SquareService.java

@@ -26,12 +26,12 @@ public interface SquareService {
26 26
      * @param houseLengthLeft
27 27
      * @param houseLengthRight
28 28
      */
29
-	void scanSquareTask(double houseWideOn, double houseWideUnder, double houseLengthLeft, double houseLengthRight,double houseHigh);
29
+	void scanSquareTask(String cfId, double houseWideOn, double houseWideUnder, double houseLengthLeft, double houseLengthRight,double houseHigh);
30 30
 
31 31
 	int saveTeData(TeData teData);
32 32
 
33 33
 	void scanTask(TeData teData);
34 34
 
35
-	void calculateVolume(String taskID);
35
+	double calculateVolume(String taskID);
36 36
 
37 37
 }

+ 10 - 1
src/main/java/com/unissoft/interaction/service/TestTask.java

@@ -29,6 +29,9 @@ public class TestTask extends AbstractTask {
29 29
     @Resource
30 30
     private TeDataService teDataService;
31 31
     
32
+    @Resource
33
+    private SquareService squareService;
34
+    
32 35
     private Logger logger = LoggerFactory.getLogger(TestTask.class);
33 36
 
34 37
     @PostConstruct
@@ -64,7 +67,13 @@ public class TestTask extends AbstractTask {
64 67
                 		teDataService.scanTask(cfId,diameter,h);
65 68
                 	}
66 69
                 	if(houseType.equals("21")){
67
-                		//平房仓的打点算法
70
+                		//平房仓的打点算法--------------todo
71
+                		double houseWideOn = 0 ; 
72
+                		double houseWideUnder = 0;
73
+                		double houseLengthLeft = 0; 
74
+                		double houseLengthRight = 0;
75
+                		double houseHigh = 0;
76
+                		squareService.scanSquareTask(cfId,houseWideOn, houseWideUnder, houseLengthLeft, houseLengthRight, houseHigh);
68 77
                 	}
69 78
         		}
70 79
         	}else{//单个仓房

+ 101 - 53
src/main/java/com/unissoft/interaction/service/impl/SquareServiceImpl.java

@@ -2,7 +2,6 @@ package com.unissoft.interaction.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.unissoft.interaction.algorithm.SquareAlg;
5
-import com.unissoft.interaction.controller.DataController;
6 5
 import com.unissoft.interaction.entity.ReMsg;
7 6
 import com.unissoft.interaction.entity.STask;
8 7
 import com.unissoft.interaction.entity.TeData;
@@ -10,7 +9,11 @@ import com.unissoft.interaction.mapper.ReMsgMapper;
10 9
 import com.unissoft.interaction.mapper.STaskMapper;
11 10
 import com.unissoft.interaction.mapper.TeDataMapper;
12 11
 import com.unissoft.interaction.service.SquareService;
13
-import com.unissoft.interaction.service.TeDataService;
12
+import com.unissoft.parameter.mapper.HardwareParameterMapper;
13
+import com.unissoft.parameter.model.HardwareParameter;
14
+import com.unissoft.systemManage.mapper.OrgInfoMapper;
15
+import com.unissoft.systemManage.model.OrgInfo;
16
+
14 17
 import org.slf4j.Logger;
15 18
 import org.slf4j.LoggerFactory;
16 19
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,12 +21,12 @@ import org.springframework.scheduling.annotation.Async;
18 21
 import org.springframework.stereotype.Service;
19 22
 import org.springframework.web.client.RestTemplate;
20 23
 
21
-import java.beans.Transient;
22
-import java.util.ArrayList;
23 24
 import java.util.Collections;
24 25
 import java.util.Date;
25 26
 import java.util.List;
26 27
 
28
+import javax.annotation.Resource;
29
+
27 30
 @Service(value = "squareService")
28 31
 public class SquareServiceImpl implements SquareService {
29 32
 
@@ -31,15 +34,14 @@ public class SquareServiceImpl implements SquareService {
31 34
 
32 35
     static String base_url = "http://192.168.0.61:4017/";
33 36
     static boolean flag = true;
34
-    static double houseWideOn;
37
+    /*static double houseWideOn;
35 38
     static double houseWideUnder;
36 39
     static double houseLengthLeft;
37
-    static double houseLengthRight;
40
+    static double houseLengthRight;*/
38 41
     private STaskMapper sTaskMapper;
39 42
     private TeDataMapper teDataMapper;
40 43
     private ReMsgMapper reMsgMapper;
41
-
42
-
44
+    
43 45
     @Autowired
44 46
     public void setsTaskMapper(STaskMapper sTaskMapper) {
45 47
         this.sTaskMapper = sTaskMapper;
@@ -54,36 +56,53 @@ public class SquareServiceImpl implements SquareService {
54 56
     public void setReMsgMapper(ReMsgMapper reMsgMapper) {
55 57
         this.reMsgMapper = reMsgMapper;
56 58
     }
59
+    
60
+    @Resource
61
+    private HardwareParameterMapper hardwareParameterMapper;
62
+
63
+    @Resource
64
+    private OrgInfoMapper orgInfoMapper;
65
+    
66
+    @Resource
67
+    private TeDataServiceImpl teDataServiceImpl;
68
+    
69
+    
57 70
 
58 71
     /**
59
-     * todo
60
-     * http://local.wxlxit.com:61001/
61
-     * 1. equipmentTestingIsReady
62
-     * 2. equipmentTestingStart
63
-     * 3. equipmentTestingEnd
72
+     *第一次打点
64 73
      */
65 74
     @Override
66
-    public void scanSquareTask(double houseWideOn, double houseWideUnder, double houseLengthLeft, double houseLengthRight,double houseHigh) {
67
-        logger.info("scanTask {},{},{},{},{}",houseWideOn, houseWideUnder,houseLengthLeft,houseLengthRight,houseHigh);
68
-        STask task = new STask();
69
-        Date date = new Date();
70
-        task.setCtime(date);
71
-        task.setDepict("test");
72
-        sTaskMapper.insert(task);
73
-
74
-        TeData teData = new TeData();
75
-        teData.setEquipmentID("hljcbk1001");
76
-        teData.setTaskID("" + task.getId());
77
-        teData.setStime(date);
78
-
79
-        //todo 第一次待打点
80
-        String rotationxy = SquareAlg.getAveragePosition(houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight, houseHigh);
81
-        teData.setRotationxy(rotationxy);
82
-        logger.info("scanTask sTaskMapper teDataMapper {},{}",task,teData);
83
-
84
-        postHelper(teData);
85
-        flag = true;
75
+    public void scanSquareTask(String cfId,double houseWideOn, double houseWideUnder, double houseLengthLeft, double houseLengthRight,double houseHigh) {
76
+    	logger.info("scanSquareTask{} {},{},{},{},{}",cfId,houseWideOn, houseWideUnder,houseLengthLeft,houseLengthRight,houseHigh);
77
+
78
+    	//根据仓房id 获取设备编号
79
+  		QueryWrapper<HardwareParameter> queryWrapper = new QueryWrapper<>();
80
+        queryWrapper.eq("house_id", Integer.parseInt(cfId));
81
+        List<HardwareParameter> hardList = hardwareParameterMapper.selectList(queryWrapper);
82
+        if(hardList.size()>0){
83
+        	STask task = new STask();
84
+            Date date = new Date();
85
+            task.setCtime(date);
86
+            task.setDepict(cfId+"仓打点");
87
+            sTaskMapper.insert(task);
88
+            
89
+            TeData teData = new TeData();
90
+            teData.setEquipmentID(hardList.get(0).getDeviceCode());//设备id-----设备编码
91
+            teData.setTaskID(cfId+","+ task.getId());//拼接一个仓房id
92
+            teData.setStime(date);
93
+            
94
+            //第一次待打点
95
+            String rotationxy = SquareAlg.getAveragePosition(houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight, houseHigh);
96
+            teData.setRotationxy(rotationxy);
97
+            logger.info("第一次打点数据{}",teData);
86 98
 
99
+            //发送给硬件
100
+            postHelper(teData);
101
+            //第一次打点标识
102
+            flag = true;
103
+        }else{
104
+          	logger.info("该仓房没有硬件参数");
105
+        }
87 106
     }
88 107
     
89 108
     /**
@@ -99,33 +118,51 @@ public class SquareServiceImpl implements SquareService {
99 118
         }
100 119
         //只运行 发送一次。
101 120
         if (flag) {
102
-            //teData.getEquipmentID();
103
-            //teData.getTaskID();
104
-
105
-            //todo 第二次待打点
106
-
107
-            //计算以粮面为基准面的高
108
-            List<Double> list = SquareAlg.zHeight(teData.getRotationxy(),houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight);
109
-            double zHeight = Collections.min(list);
110
-            logger.info("以粮面为基准面的高zHeight {}",zHeight);
121
+            // 第二次待打点
122
+
123
+            //根据仓房id查询其信息
124
+        	String taskId = teData.getTaskID();
125
+        	String houseId = taskId.split(",")[0];//仓房id
126
+        	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));//--------------------待完
127
+        	
128
+        	double houseWideOn = 0;
129
+            double houseWideUnder = 0;
130
+            double houseLengthLeft = 0;
131
+            double houseLengthRight = 0;
132
+            double houseHight = 0;
133
+            
134
+            
135
+        	//计算以粮面为基准面的高
136
+            List<Double> zlist = SquareAlg.zHeight(teData.getRotationxy(),houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
137
+            double zHeight = Collections.max(zlist);//纵坐标的最大值
138
+            double secondH = houseHight - zHeight;//仓房的高-点的纵坐标
139
+            logger.info("以粮面为基准面的高secondH {}",secondH);
111 140
 
112 141
             //打点
113
-            String rotationxy = SquareAlg.getAveragePosition(houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight, zHeight);
142
+            String rotationxy = SquareAlg.getAveragePosition(houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight, secondH);
114 143
             teData.setRotationxy(rotationxy);
115 144
             teData.setStime(new Date());//第二次开始的时间
145
+            
146
+            //发送给硬件
116 147
             postHelper(teData);
117 148
 
149
+            //打点次数的标识
118 150
             flag = false;
119
-        } else { //打点两次完毕 计算体积
120
-            this.calculateVolume(teData.getTaskID());
151
+        } else { 
152
+        	//打点两次完毕 计算体积
153
+            double v = this.calculateVolume(teData.getTaskID());
154
+            //增加数据到数据查询表(即体积、重量)
155
+            //Te.addNBasicEdge(v,teData.getTaskID());
156
+            teDataServiceImpl.addNBasicEdge(v, teData.getTaskID());
157
+            //计算实际的点的坐标(用于三维展示)-------------todo
158
+            
121 159
         }
122 160
 
123 161
     }
124 162
 
125 163
     @Override
126 164
     public int saveTeData(TeData teData) {
127
-        int inum = teDataMapper.insert(teData);
128
-        return inum;
165
+        return teDataMapper.insert(teData);
129 166
     }
130 167
 
131 168
     public ReMsg postHelper(TeData teData) {
@@ -152,7 +189,7 @@ public class SquareServiceImpl implements SquareService {
152 189
     }
153 190
 
154 191
     @Override
155
-    public void calculateVolume(String taskID) {
192
+    public double calculateVolume(String taskID) {
156 193
     	
157 194
     	
158 195
     	//(第一次扫描点数总和+第二次扫描点数总和)*(仓房长*宽/(第一次扫描点数+第二次扫描点数))=体积
@@ -161,8 +198,8 @@ public class SquareServiceImpl implements SquareService {
161 198
         */
162 199
         
163 200
         // TODO Auto-generated method stub
164
-        List<Double> zList = new ArrayList<Double>();
165
-        String[] split = null;
201
+        //List<Double> zList = new ArrayList<Double>();
202
+        //String[] split = null;
166 203
         String str = "";
167 204
 
168 205
         QueryWrapper<TeData> queryWrapper = new QueryWrapper<>();
@@ -175,12 +212,23 @@ public class SquareServiceImpl implements SquareService {
175 212
         }
176 213
         //两次打点的值
177 214
         String xyStr = str.substring(0, str.length()-1);
178
-        //去除打在墙上的点 得到的集合是有效的点(粮面点到设备的垂直距离)
179
-        List<Double> list = SquareAlg.zHeight(xyStr,houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight);
180
-
181 215
         
216
+        //根据仓房id查询其信息
217
+    	String houseId = taskID.split(",")[0];//仓房id
218
+    	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));//--------------------待完
219
+    	
220
+    	double houseWideOn = 0;
221
+        double houseWideUnder = 0;
222
+        double houseLengthLeft = 0;
223
+        double houseLengthRight = 0;
224
+        double houseHight = 0;
182 225
         
183 226
         
227
+        //去除打在墙上的点 得到的集合是有效的点的纵坐标
228
+        List<Double> zList = SquareAlg.zHeight(xyStr,houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
229
+        //体积
230
+        double v =SquareAlg.calculateVolume(zList,houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
231
+        return v;
184 232
 
185 233
     }
186 234
 

+ 1 - 1
src/main/java/com/unissoft/interaction/service/impl/TeDataServiceImpl.java

@@ -177,7 +177,7 @@ public class TeDataServiceImpl implements TeDataService {
177 177
             //double zHeight = CylinderAlg.zHeight(teData.getRotationxy(), diameter, h);
178 178
             
179 179
     		List<Double> zList = CylinderAlg.getValidZ(teData.getRotationxy(), diameter, h);
180
-    		double z = Collections.min(zList);
180
+    		double z = Collections.max(zList);//纵坐标的最大值
181 181
     		//第二次打点的高
182 182
     		double secondH = h - z;//仓房的高-点的纵坐标
183 183
             logger.info("z {} ,diameter {},secondH {}",z,diameter,secondH);