Bladeren bron

Merge branch 'master' of http://101.36.160.140:21044/numberPro/numberCloud

zlq 1 jaar geleden
bovenliggende
commit
006e6145fa

File diff suppressed because it is too large
+ 174 - 0
src/main/java/com/unissoft/interaction/algorithm/CylinderAlg.java


+ 162 - 8
src/main/java/com/unissoft/interaction/algorithm/SquareAlg.java

@@ -60,7 +60,7 @@ public class SquareAlg {
60 60
 			double AB = 0; //理想状态 垂直三角形的底边AB 实际是平面三角形的斜边
61 61
 		    double level_angle = 0;//水平转动的角度
62 62
 		    double vertical_angle = 0;//垂直转动角度
63
-		    double BC = 0; //设备和粮面点之间的距离
63
+		    double BC = 0; //设备和粮面点之间的距离(垂直三角形的斜边)
64 64
 		    
65 65
 		    int level_angle1 = 0;//水平转动的角度
66 66
 		    int vertical_angle1 = 0;//垂直转动角度
@@ -70,9 +70,9 @@ public class SquareAlg {
70 70
 				  y = spacingDistance * i;
71 71
 				  //System.out.println("("+x+","+y+")");
72 72
 				  AB = Math.sqrt(x*x+y*y);
73
-				  if(x == 0 && y >= 0){
73
+				  if(x == 0 && y >= 0){//y轴的正半轴以及原点
74 74
 					  level_angle = 0;
75
-				  }else if(y == 0 && x != 0){ 
75
+				  }else if(y == 0 && x != 0){//x轴的负半轴
76 76
 					  level_angle = -90;
77 77
 				  }else{
78 78
 					  level_angle = -Math.toDegrees(Math.atan((Math.abs(x))/y));
@@ -102,7 +102,7 @@ public class SquareAlg {
102 102
 					  y = spacingDistance * i;
103 103
 					  //System.out.println("("+x+","+y+")");
104 104
 					  AB = Math.sqrt(x*x+y*y);
105
-					  if(y == 0){
105
+					  if(y == 0){//x轴的正半轴
106 106
 						  level_angle = 90;
107 107
 					  }else{ 
108 108
 						  level_angle = Math.toDegrees(Math.atan(x/y));
@@ -131,7 +131,7 @@ public class SquareAlg {
131 131
 				  y = -spacingDistance * i;
132 132
 				  //System.out.println("("+x+","+y+")");
133 133
 				  AB = Math.sqrt(x*x+y*y);
134
-				  if(x == 0){
134
+				  if(x == 0){//y轴的负半轴
135 135
 					  level_angle = 0;
136 136
 				  }else{
137 137
 					  level_angle = Math.toDegrees(Math.atan((Math.abs(x))/y));
@@ -310,14 +310,168 @@ public class SquareAlg {
310 310
 	    
311 311
 	    
312 312
 	    /**
313
-	     * 计算体积---------------todo
313
+	     * 计算体积---------------
314 314
 	     *
315 315
 	     * @param zList 粮面高集合(z值的集合)
316 316
 	     */
317
-	    public static double calculateVolume(List<Double> zList,double houseWideOn,double houseWideUnder,double houseLengthLeft,double houseLengthRight,double houseHight) {
318
-	    	double v = 0; 
317
+	    public static double calculateVolume(List<Double> zList,double houseLength,double houseWide,double houseHight) {
318
+	    	
319
+	    	//17.1  18.3  19.2  18.3    20.1  16.4  19.8  16.7  19.0  18.9
320
+	        Double zMin = Collections.min(zList); //z的最小值
321
+
322
+	        double sum = 0;
323
+	        double zHeigh = 0;//每一个z与最低点的z差值
324
+	        for (int i = 0; i < zList.size(); i++) {
325
+	            //sum = zList.get(i)+sum;
326
+	            zHeigh = zList.get(i) - zMin;
327
+	            sum += zHeigh;
328
+	        }
329
+	        /** v 是总体积
330
+	         * v1 最上面的那一部分不规则的体积
331
+	         * v2 是长方体的体积
332
+	         * 
333
+	         */
334
+
335
+	        double v1 = houseLength * houseWide * (sum / zList.size());
336
+	        double v2 = houseLength * houseWide * houseHight;
337
+	        double sumV = v1 + v2;
338
+	        BigDecimal bdv = BigDecimal.valueOf(sumV);
339
+	        double v = bdv.setScale(2, RoundingMode.HALF_UP).doubleValue();
319 340
 	    	return v;
320 341
 	    }
321 342
 	    
322 343
 	    
344
+
345
+	    /**
346
+	     * 计算实际的点的坐标
347
+	     */
348
+	    public static String getCoordinates(String rotationxy, double houseWideOn,double houseWideUnder,double houseLengthLeft,double houseLengthRight, double high) {
349
+	    	
350
+	    	StringBuffer pointSb = new StringBuffer();
351
+	    	pointSb.append("[");
352
+	    	
353
+	    	String pointString = null;//所有的点
354
+	    	String xyz = null;//每个点的坐标
355
+
356
+	        double AC = high;
357
+	        //double B1C = 0;//设备和粮面点之间的距离
358
+	        double A1B1 = 0;//粮面的点到设备的水平距离
359
+	        double x = 0; //实际点的坐标的x轴
360
+	        double y = 0; //实际点的坐标的y轴
361
+	        double z = 0; //实际点的坐标的z轴
362
+	        //加一个边界值后的横纵坐标
363
+	        double x1 = 0;
364
+	        double y1 = 0;
365
+	        //给三维的坐标
366
+	        int x2 = 0;
367
+	        int y2 = 0;
368
+	        double verticalAngle = 0;//垂直角度
369
+	        double levelAngle = 0;//水平角度
370
+	        double realHypotenuse = 0;//返回的距离即设备和粮面间两点的距离
371
+	        
372
+	        double oa = houseLengthLeft; //x的左半轴(长)
373
+    		double ob = houseWideOn; //y的上半轴(宽)
374
+    		double oc = houseLengthRight; //x的右半轴(长)
375
+    		double od = houseWideUnder; //y的下半轴(宽)
376
+    		
377
+	        BigDecimal baseNumber = new BigDecimal(basicData);
378
+
379
+	        //  "18,7,17.88 ; 19,6,28.88 ; 17,4,39.88"  垂直角度,水平角度,返回距离 ;
380
+	        String[] split = rotationxy.split(";");
381
+	        for (int i = 0; i < split.length; i++) {
382
+	            //System.out.println("split[i]是:"+split[i]);
383
+	            String[] split1 = split[i].split(",");
384
+	            verticalAngle = new BigDecimal(split1[0]).divide(baseNumber, 0, RoundingMode.HALF_UP).doubleValue();
385
+	            levelAngle = new BigDecimal(split1[1]).divide(baseNumber, 0, RoundingMode.HALF_UP).doubleValue();
386
+	            realHypotenuse = new BigDecimal(split1[2]).divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP).doubleValue(); //单位转化为米
387
+
388
+	            //将垂直的角度转化为弧度
389
+	            double verticalAngleRadians = Math.toRadians(verticalAngle);
390
+	            //垂直角度的sin
391
+	            String verticalAngleS = String.format("%.2f%n", Math.sin(verticalAngleRadians));
392
+	            double sinVerticalAngle = new Double(verticalAngleS);
393
+	            //垂直角度的cos
394
+	            String verticalAngleC = String.format("%.2f%n", Math.cos(verticalAngleRadians));
395
+	            double cosVerticalAngle = new Double(verticalAngleC);
396
+	            
397
+	            //将水平的角度转化为弧度
398
+	            double levelAngleRadians = Math.toRadians(levelAngle);
399
+	            //水平角度的sin
400
+	            String sinLevel = String.format("%.2f%n", Math.sin(levelAngleRadians));
401
+	            double sinLeveld = new Double(sinLevel);
402
+	            //水平角度的cos
403
+	            String cosLevel = String.format("%.2f%n", Math.cos(levelAngleRadians));
404
+	            double cosLeveld = new Double(cosLevel);
405
+
406
+	            //竖直三角形的底边 即 平面三角形的斜边   
407
+	            A1B1 = realHypotenuse * sinVerticalAngle; 
408
+
409
+	            //横坐标的距离(只有长度)
410
+	            x = Math.abs(A1B1 * cosLeveld ) ;
411
+	            //纵坐标的距离(只有长度)
412
+	            y = Math.abs(A1B1 * sinLeveld ) ;
413
+	            
414
+	            //判断真实的坐标与长宽的距离
415
+	            //四面都减少0.5米做安全隔墙 只要不在这范围的都算打在墙上(真实的坐标的距离都加0.5小于实际的边即可)
416
+	            
417
+	    		//加0.5后的横纵坐标的距离
418
+	    		x1 = x + boundaryValue;
419
+	    		y1 = y + boundaryValue;
420
+	    		
421
+	    		 
422
+	             //A1C 是粮面点到设备的垂直距离
423
+	             double A1C = realHypotenuse * cosVerticalAngle; 
424
+	             z = high - A1C;
425
+	            
426
+	             /*
427
+	              *  给三维的坐标是 1234 模块都属于第一象限 则需要将原点移动至仓房的左下角
428
+	              *  
429
+	              *  坐标移动 横坐标向左移动oa的长度 则+oa(长度) 纵坐标向下移动od的长度 则+od(长度)
430
+	              */
431
+	             
432
+	                x2 = (int) Math.round(x1+oa);
433
+	                y2 = (int) Math.round(y1+od);
434
+	                z = (double) (Math.round(z*100)/100);
435
+            		xyz = "["+x2+","+y2+","+z+"]"+",";
436
+
437
+	             if(levelAngle < 0 && verticalAngle>0 ){
438
+		            	//第一区域
439
+		            	if(x1<oa && y1<ob){
440
+		            		pointSb.append(xyz);
441
+		            	}
442
+		            }else if(levelAngle > 0 && verticalAngle>0){
443
+		            	//第二区域
444
+		            	if(x1<oc && y1<ob){
445
+		            		pointSb.append(xyz);
446
+		           	    }
447
+		            	
448
+		            }else if(levelAngle > 0 && verticalAngle<0){
449
+		            	//第三区域
450
+		            	if(x1<oa && y1<od){
451
+		            		pointSb.append(xyz);
452
+		           	    }
453
+		            	
454
+		            }else if(levelAngle < 0 && verticalAngle<0){
455
+		            	//第四区域
456
+		            	if(x1<oc && y1<od){
457
+		            		pointSb.append(xyz);
458
+		           	    }
459
+		            }else if(levelAngle == 0 || levelAngle == -90 || levelAngle == 90){
460
+		            	//坐标轴上的点
461
+		            	if(verticalAngle>0){
462
+		            		if(y1<ob){
463
+		            			pointSb.append(xyz);
464
+		            		}
465
+		            	}else if(verticalAngle<0){
466
+		            		if(y1<od){
467
+		            			pointSb.append(xyz);
468
+		            		}
469
+		            	}
470
+		            }
471
+	        }
472
+	        pointString = pointSb.substring(0, pointSb.toString().length()-1).toString()+"]";
473
+	        return pointString;
474
+	    	
475
+	    }
476
+	    
323 477
 }

File diff suppressed because it is too large
+ 110 - 2
src/main/java/com/unissoft/interaction/controller/DataController.java


+ 6 - 0
src/main/java/com/unissoft/interaction/service/TeDataService.java

@@ -45,4 +45,10 @@ public interface TeDataService {
45 45
 
46 46
 	void scanTask(String cfId, Double diameter, Double h);
47 47
 
48
+	void tj(String taskID);
49
+
50
+	double calculateVolumeByOne(String taskID);
51
+
52
+	void calibration(String cfId, double diameter, double height);
53
+
48 54
 }

+ 16 - 4
src/main/java/com/unissoft/interaction/service/TestTask.java

@@ -68,12 +68,17 @@ public class TestTask extends AbstractTask {
68 68
                 		teDataService.scanTask(cfId,diameter,h);
69 69
                 	}
70 70
                 	if(houseType.equals("21")){
71
-                		//平房仓的打点算法--------------todo
72
-                		double houseWideOn = 0 ; 
71
+                		//平房仓的打点算法--------------
72
+                		/*double houseWideOn = 0 ; 
73 73
                 		double houseWideUnder = 0;
74 74
                 		double houseLengthLeft = 0; 
75 75
                 		double houseLengthRight = 0;
76
-                		double houseHigh = 0;
76
+                		double houseHigh = 0;*/
77
+                		double houseWideOn = orgInfoHouse.getHouseWideOn().doubleValue();
78
+                		double houseWideUnder = orgInfoHouse.getHouseWideUnder().doubleValue();
79
+                		double houseLengthLeft = orgInfoHouse.getHouseLengthLeft().doubleValue();
80
+                		double houseLengthRight = orgInfoHouse.getHouseLengthRight().doubleValue();
81
+                		double houseHigh = Double.valueOf(orgInfoHouse.getHigh());
77 82
                 		squareService.scanSquareTask(cfId,houseWideOn, houseWideUnder, houseLengthLeft, houseLengthRight, houseHigh);
78 83
                 	}
79 84
         		}
@@ -89,7 +94,14 @@ public class TestTask extends AbstractTask {
89 94
 	         		teDataService.scanTask(houseId,diameter,h);
90 95
 		         }
91 96
 		         if(houseType.equals("21")){
92
-		         		//平房仓的打点算法
97
+		         	//平房仓的打点算法
98
+		        	double houseWideOn = orgInfoHouse.getHouseWideOn().doubleValue();
99
+             		double houseWideUnder = orgInfoHouse.getHouseWideUnder().doubleValue();
100
+             		double houseLengthLeft = orgInfoHouse.getHouseLengthLeft().doubleValue();
101
+             		double houseLengthRight = orgInfoHouse.getHouseLengthRight().doubleValue();
102
+             		double houseHigh = Double.valueOf(orgInfoHouse.getHigh());
103
+             		squareService.scanSquareTask(houseId,houseWideOn, houseWideUnder, houseLengthLeft, houseLengthRight, houseHigh);
104
+             	
93 105
 		         }
94 106
         	}
95 107
         	logger.info("检测任务结束");

+ 95 - 8
src/main/java/com/unissoft/interaction/service/impl/SquareServiceImpl.java

@@ -1,5 +1,6 @@
1 1
 package com.unissoft.interaction.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONArray;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.unissoft.interaction.algorithm.SquareAlg;
5 6
 import com.unissoft.interaction.entity.ReMsg;
@@ -12,7 +13,9 @@ import com.unissoft.interaction.service.SquareService;
12 13
 import com.unissoft.parameter.mapper.HardwareParameterMapper;
13 14
 import com.unissoft.parameter.model.HardwareParameter;
14 15
 import com.unissoft.systemManage.mapper.OrgInfoMapper;
16
+import com.unissoft.systemManage.mapper.PointDataMapper;
15 17
 import com.unissoft.systemManage.model.OrgInfo;
18
+import com.unissoft.systemManage.model.PointData;
16 19
 
17 20
 import org.slf4j.Logger;
18 21
 import org.slf4j.LoggerFactory;
@@ -21,6 +24,7 @@ import org.springframework.scheduling.annotation.Async;
21 24
 import org.springframework.stereotype.Service;
22 25
 import org.springframework.web.client.RestTemplate;
23 26
 
27
+import java.util.ArrayList;
24 28
 import java.util.Collections;
25 29
 import java.util.Date;
26 30
 import java.util.List;
@@ -66,6 +70,9 @@ public class SquareServiceImpl implements SquareService {
66 70
     @Resource
67 71
     private TeDataServiceImpl teDataServiceImpl;
68 72
     
73
+    @Resource
74
+    private PointDataMapper pointDataMapper;
75
+    
69 76
     
70 77
 
71 78
     /**
@@ -135,16 +142,23 @@ public class SquareServiceImpl implements SquareService {
135 142
             if(hardList.size()>0){
136 143
             	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));//--------------------待完
137 144
             	
138
-            	double houseWideOn = 0;
145
+            	/*double houseWideOn = 0;
139 146
                 double houseWideUnder = 0;
140 147
                 double houseLengthLeft = 0;
141 148
                 double houseLengthRight = 0;
142
-                double houseHight = 0;
149
+                double houseHight = 0;*/
150
+            	
151
+            	double houseWideOn = orgInfoHouse.getHouseWideOn().doubleValue();
152
+         		double houseWideUnder = orgInfoHouse.getHouseWideUnder().doubleValue();
153
+         		double houseLengthLeft = orgInfoHouse.getHouseLengthLeft().doubleValue();
154
+         		double houseLengthRight = orgInfoHouse.getHouseLengthRight().doubleValue();
155
+         		double houseHight = Double.valueOf(orgInfoHouse.getHigh());
143 156
                 
144 157
                 
145 158
             	//计算以粮面为基准面的高
146
-                List<Double> zlist = SquareAlg.zHeight(teData.getRotationxy(),houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
147
-                double zHeight = Collections.max(zlist);//纵坐标的最大值
159
+                List<Double> zList = SquareAlg.zHeight(teData.getRotationxy(),houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
160
+                //double zHeight = Collections.max(zList);//纵坐标的最大值
161
+                double zHeight = Collections.min(zList);//纵坐标的最小值
148 162
                 double secondH = houseHight - zHeight;//仓房的高-点的纵坐标
149 163
                 logger.info("以粮面为基准面的高secondH {}",secondH);
150 164
 
@@ -170,6 +184,7 @@ public class SquareServiceImpl implements SquareService {
170 184
             //Te.addNBasicEdge(v,teData.getTaskID());
171 185
             teDataServiceImpl.addNBasicEdge(v, teData.getTaskID());
172 186
             //计算实际的点的坐标(用于三维展示)-------------todo
187
+            this.addPoint(teData.getTaskID());
173 188
             
174 189
         }
175 190
 
@@ -230,21 +245,93 @@ public class SquareServiceImpl implements SquareService {
230 245
         
231 246
         //根据仓房id查询其信息
232 247
     	String houseId = taskID.split(",")[0];//仓房id
233
-    	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));//--------------------待完
248
+    	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));//--------------------
234 249
     	
235
-    	double houseWideOn = 0;
250
+    	/*double houseWideOn = 0;
236 251
         double houseWideUnder = 0;
237 252
         double houseLengthLeft = 0;
238 253
         double houseLengthRight = 0;
239
-        double houseHight = 0;
254
+        double houseHight = 0;*/
255
+    	
256
+    	double houseWideOn = orgInfoHouse.getHouseWideOn().doubleValue();
257
+ 		double houseWideUnder = orgInfoHouse.getHouseWideUnder().doubleValue();
258
+ 		double houseLengthLeft = orgInfoHouse.getHouseLengthLeft().doubleValue();
259
+ 		double houseLengthRight = orgInfoHouse.getHouseLengthRight().doubleValue();
260
+ 		double houseLength = orgInfoHouse.getChang().doubleValue();
261
+ 		double houseWide = orgInfoHouse.getKuan().doubleValue();
262
+ 		double houseHight = Double.valueOf(orgInfoHouse.getHigh());
240 263
         
241 264
         
242 265
         //去除打在墙上的点 得到的集合是有效的点的纵坐标
243 266
         List<Double> zList = SquareAlg.zHeight(xyStr,houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
244 267
         //体积
245
-        double v =SquareAlg.calculateVolume(zList,houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
268
+        double v =SquareAlg.calculateVolume(zList,houseLength,houseWide,houseHight);
246 269
         return v;
247 270
 
248 271
     }
272
+    
273
+    
274
+    /**
275
+     * 实际打点的坐标
276
+     * @param taskId
277
+     */
278
+    public void addPoint(String taskId){
279
+    	PointData ponitData = new PointData();
280
+    	
281
+    	String houseId = taskId.split(",")[0];//仓房id
282
+        //获取仓房信息
283
+    	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
284
+		String high = orgInfoHouse.getHigh();//高
285
+		Double h = Double.parseDouble(high);
286
+		double houseWideOn = orgInfoHouse.getHouseWideOn().doubleValue();
287
+ 		double houseWideUnder = orgInfoHouse.getHouseWideUnder().doubleValue();
288
+ 		double houseLengthLeft = orgInfoHouse.getHouseLengthLeft().doubleValue();
289
+ 		double houseLengthRight = orgInfoHouse.getHouseLengthRight().doubleValue();
290
+ 		double length = orgInfoHouse.getChang().doubleValue();
291
+ 		double wide = orgInfoHouse.getKuan().doubleValue();
292
+    	//查询打点返回的数据
293
+    	StringBuffer sb = new StringBuffer();
294
+    	QueryWrapper<TeData> queryWrapper = new QueryWrapper<>();
295
+        List<TeData> teDataList = null;
296
+        queryWrapper.eq("taskID", taskId);
297
+        teDataList = teDataMapper.selectList(queryWrapper);
298
+        if(teDataList.size()>0){
299
+        	for (TeData teData : teDataList) {
300
+        		sb.append(teData.getRotationxy()+";");
301
+            	
302
+            }
303
+        	String rotationxy = sb.substring(0, sb.length()-1).toString();//发送的角度和返回的距离  150,50,90;200,-100,90;50,-50,90
304
+        	
305
+        	//计算实际的坐标
306
+        	String xyz = SquareAlg.getCoordinates(rotationxy,houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight , h);
307
+        	
308
+        	ponitData.setHouseId(orgInfoHouse.getId());
309
+        	ponitData.setCreateTime(new Date());
310
+        	ponitData.setLkHeight(high);//保存高
311
+    		ponitData.setPoints(xyz);//保存坐标
312
+    		ponitData.setLength(length+"");//仓房的长
313
+    		ponitData.setWide(wide+"");//仓房的宽
314
+    		
315
+    		//String jsonString = "[[1,2,3],[4,5,62.33],[1,5,2.3]]";
316
+    		JSONArray jsonArray=JSONArray.parseArray(xyz);
317
+    		List<Double> list = new ArrayList<>();
318
+    		
319
+    		for(int i=0;i<jsonArray.size();i++){
320
+    		    double z = Double.parseDouble(jsonArray.get(i).toString().split(",")[2].split("]")[0]);
321
+    		    list.add(z);
322
+    		    //System.out.println(z);
323
+    		}
324
+    		Double max = Collections.max(list);
325
+    		max = (double) (Math.round(max*100)/100);
326
+    	    Double min = Collections.min(list);
327
+    	    min = (double) (Math.round(min*100)/100);
328
+    	    Double minHeigth = (max+min)/2;
329
+    	    ponitData.setVerticalMaxHeigth(max+"");//垂直最大高度
330
+    	    ponitData.setVerticalMinHeigth(min+"");//垂直最小高度
331
+    	    ponitData.setMinHeigth(minHeigth+"");//----------------待确定
332
+    		pointDataMapper.insert(ponitData);
333
+        	
334
+        }
335
+    }
249 336
 
250 337
 }

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

@@ -101,7 +101,7 @@ public class TeDataServiceImpl implements TeDataService {
101 101
         teData.setStime(date);
102 102
 
103 103
         // 第一次待打点
104
-        String rotationxy = CylinderAlg.getAveragePosition(diameter, high);
104
+        String rotationxy = CylinderAlg.getAveragePosition1(diameter, high);
105 105
         teData.setRotationxy(rotationxy);
106 106
         //int inum = teDataMapper.insert(teData);
107 107
 
@@ -140,7 +140,7 @@ public class TeDataServiceImpl implements TeDataService {
140 140
             String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
141 141
 
142 142
             // 第一次待打点
143
-            String rotationxy = CylinderAlg.getAveragePosition(diameter, h);
143
+            String rotationxy = CylinderAlg.getAveragePosition1(diameter, h);
144 144
             teData.setRotationxy(rotationxy);
145 145
             logger.info("第一次打点的数据{}",teData);
146 146
             
@@ -191,16 +191,16 @@ public class TeDataServiceImpl implements TeDataService {
191 191
         		Double diameter = Double.parseDouble(radius)*2;//直径
192 192
         		Double h = Double.parseDouble(high);
193 193
         		
194
-                //double zHeight = CylinderAlg.zHeight(teData.getRotationxy(), diameter, h);
195
-                
196 194
         		List<Double> zList = CylinderAlg.getValidZ(teData.getRotationxy(), diameter, h);
197 195
         		double z = Collections.max(zList);//纵坐标的最大值
196
+        		double z1 = Collections.min(zList);//纵坐标的最小值
198 197
         		//第二次打点的高
199
-        		double secondH = h - z;//仓房的高-点的纵坐标
200
-                logger.info("z {} ,diameter {},secondH {}",z,diameter,secondH);
198
+        		//double secondH = h - z;//仓房的高-点的纵坐标
199
+        		double secondH = z;
200
+                logger.info("z {} ,z1 {},diameter {},secondH {}",z,z1,diameter,secondH);
201 201
 
202 202
                 //打点
203
-                String rotationxy = CylinderAlg.getAveragePosition(diameter, secondH);
203
+                String rotationxy = CylinderAlg.getAveragePosition1(diameter, secondH);
204 204
                 teData.setRotationxy(rotationxy);
205 205
                 teData.setStime(new Date());//第二次开始的时间
206 206
                 
@@ -217,7 +217,8 @@ public class TeDataServiceImpl implements TeDataService {
217 217
         } else { 
218 218
         	//打点两次完毕 计算体积
219 219
         	 logger.info("计算体积。。。。");
220
-            double v = this.calculateVolume(teData.getTaskID());
220
+            double v = this.calculateVolume(teData.getTaskID());//两次数据
221
+            //double v = this.calculateVolumeByOne(teData.getTaskID());//两次数据中的一条数据
221 222
             logger.info("计算体积是:{}",v);
222 223
             //增加数据到数据查询表(即体积、重量)
223 224
             this.addNBasicEdge(v,teData.getTaskID());
@@ -289,6 +290,42 @@ public class TeDataServiceImpl implements TeDataService {
289 290
         
290 291
     }
291 292
     
293
+    @Override
294
+    public double calculateVolumeByOne (String taskID){
295
+    	StringBuffer sb = new StringBuffer();
296
+    	Double v = new Double(0);
297
+    	QueryWrapper<TeData> queryWrapper = new QueryWrapper<>();
298
+
299
+        List<TeData> teDataList = null;
300
+        queryWrapper.eq("taskID", taskID);
301
+        teDataList = teDataMapper.selectList(queryWrapper);
302
+        
303
+        if(teDataList.size()>0){
304
+        	/*for (TeData teData : teDataList) {
305
+        		sb.append(teData.getRotationxy()+";");
306
+            }
307
+        	String rotationxy = sb.substring(0, sb.length()-1).toString();//发送的角度和返回的距离  150,50,90;200,-100,90;50,-50,90
308
+        	*/
309
+        	String rotationxy = teDataList.get(0).getRotationxy();
310
+        	//获取直径
311
+        	String houseId = taskID.split(",")[0];//仓房id
312
+        	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
313
+    		String radius = orgInfoHouse.getRadius();//仓房的半径
314
+    		Double diameter = Double.parseDouble(radius)*2;//直径
315
+    		String high = orgInfoHouse.getHigh();//高
316
+    		Double h = Double.parseDouble(high);
317
+    		
318
+    		//获取有效的z值
319
+        	List<Double> zList = CylinderAlg.getValidZ(rotationxy, diameter, h);
320
+            
321
+    		//计算体积
322
+            v = CylinderAlg.calculateVolume(zList, diameter, h1, h2); //体积
323
+        }
324
+        
325
+       return v;
326
+        
327
+    }
328
+    
292 329
     /**
293 330
      * 计算 质量  体积
294 331
      * @param lkVolume
@@ -411,7 +448,7 @@ public class TeDataServiceImpl implements TeDataService {
411 448
     	    min = (double) (Math.round(min*100)/100);
412 449
     	    Double minHeigth = (max+min)/2;
413 450
     	    ponitData.setVerticalMaxHeigth(max+"");//垂直最大高度
414
-    	    ponitData.setVerticalMinHeigth(min+"");//垂直最高度
451
+    	    ponitData.setVerticalMinHeigth(min+"");//垂直最高度
415 452
     	    ponitData.setMinHeigth(minHeigth+"");//----------------待确定
416 453
     		pointDataMapper.insert(ponitData);
417 454
         	
@@ -430,4 +467,53 @@ public class TeDataServiceImpl implements TeDataService {
430 467
     	
431 468
 	}
432 469
 
470
+	@Override
471
+	public void tj(String taskID) {
472
+		// TODO Auto-generated method stub
473
+		double v = this.calculateVolume(taskID);
474
+		
475
+		BigDecimal big_density = new BigDecimal(500); 
476
+	    BigDecimal big_lkVolume = new BigDecimal(v); //保留两位小数的体积
477
+	    BigDecimal quality = big_density.multiply(big_lkVolume).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_UP);
478
+		double m = Double.parseDouble(quality+"");//单位 吨
479
+		System.out.println("体积v:"+v+"-----"+"重量是:"+m);
480
+		
481
+	}
482
+
483
+	@Override
484
+	public void calibration(String cfId, double diameter, double height) {
485
+		// TODO Auto-generated method stub
486
+		//根据仓房id 获取设备编号
487
+				QueryWrapper<HardwareParameter> queryWrapper = new QueryWrapper<>();
488
+		        queryWrapper.eq("house_id", Integer.parseInt(cfId));
489
+		        List<HardwareParameter> hardList = hardwareParameterMapper.selectList(queryWrapper);
490
+		        StringBuffer sb = new StringBuffer();
491
+		        if(hardList.size()>0){
492
+		        	logger.info("圆筒{}仓打点前校准的直径和高: {},{}",cfId ,diameter,height);
493
+		            STask task = new STask();
494
+		            Date date = new Date();
495
+		            task.setCtime(date);
496
+		            task.setDepict(cfId+"仓是否校准");
497
+		            sTaskMapper.insert(task);
498
+
499
+		            TeData teData = new TeData();
500
+		            teData.setEquipmentID(hardList.get(0).getDeviceCode());//设备id
501
+		            teData.setTaskID(cfId+","+ task.getId());//拼接一个仓房id
502
+		            teData.setStime(date);
503
+		            //IP地址
504
+		            String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
505
+		            
506
+		            //打一个点判断是否校准 垂直角度90,水平不变
507
+		            int vertical = CylinderAlg.basicData*90;
508
+		            sb.append(vertical);
509
+		            sb.append(",");
510
+		            sb.append(0);
511
+		            teData.setRotationxy(sb.toString());
512
+		            //发送给硬件
513
+		            postHelper(teData,base_url);
514
+
515
+		        }
516
+	}
517
+
518
+
433 519
 }

+ 5 - 1
src/main/java/com/unissoft/systemManage/mapper/PointDataMapper.xml

@@ -13,11 +13,15 @@
13 13
         <result column="vertical_max_heigth" property="verticalMaxHeigth" />
14 14
         <result column="vertical_min_heigth" property="verticalMinHeigth" />
15 15
         <result column="create_time" property="createTime" />
16
+        
17
+        <result column="length" property="length" />
18
+        <result column="wide" property="wide" />
16 19
     </resultMap>
17 20
 
18 21
     <!-- 通用查询结果列 -->
19 22
     <sql id="Base_Column_List">
20
-        id, house_id, lk_height, radius, points, min_heigth, vertical_max_heigth, vertical_min_heigth, create_time
23
+        id, house_id, lk_height, radius, points, min_heigth, vertical_max_heigth, vertical_min_heigth, 
24
+        create_time,length,wide
21 25
     </sql>
22 26
 
23 27
 </mapper>

+ 18 - 0
src/main/java/com/unissoft/systemManage/model/OrgInfo.java

@@ -110,6 +110,24 @@ public class OrgInfo implements Serializable {
110 110
     private String radius;
111 111
     
112 112
     
113
+    
114
+    @ApiModelProperty(value = "平房仓中宽的上半部分")
115
+    @TableField("house_wide_on")
116
+    private BigDecimal houseWideOn;
117
+    
118
+    @ApiModelProperty(value = "平房仓中宽的下半部分")
119
+    @TableField("house_wide_under")
120
+    private BigDecimal houseWideUnder;
121
+    
122
+    @ApiModelProperty(value = "平房仓中长的左半部分")
123
+    @TableField("house_length_left")
124
+    private BigDecimal houseLengthLeft;
125
+    
126
+    @ApiModelProperty(value = "平房仓中长的右半部分")
127
+    @TableField("house_length_right")
128
+    private BigDecimal houseLengthRight;
129
+    
130
+    
113 131
     /**
114 132
      * 业务字段
115 133
      */

+ 11 - 0
src/main/java/com/unissoft/systemManage/model/PointData.java

@@ -66,6 +66,17 @@ public class PointData implements Serializable {
66 66
     @ApiModelProperty(value = "创建时间")
67 67
     @TableField("create_time")
68 68
     private Date createTime;
69
+    
70
+    @ApiModelProperty(value = "平房仓的长")
71
+    @JsonProperty("Length")
72
+    @TableField("length")
73
+    private String length;
74
+    
75
+    
76
+    @ApiModelProperty(value = "平房仓的宽")
77
+    @JsonProperty("Wide")
78
+    @TableField("wide")
79
+    private String wide;
69 80
 
70 81
 
71 82
 }

+ 6 - 1
src/main/resources/mapper/systemManage/OrgInfoMapper.xml

@@ -24,12 +24,17 @@
24 24
         <result column="house_type" property="houseType" />
25 25
         <result column="high" property="high" />
26 26
         <result column="radius" property="radius" />
27
+        
28
+        <result column="house_wide_on" property="houseWideOn" />
29
+        <result column="house_wide_under" property="houseWideUnder" />
30
+        <result column="house_length_left" property="houseLengthLeft" />
31
+        <result column="house_length_right" property="houseLengthRight" />
27 32
     </resultMap>
28 33
 
29 34
     <!-- 通用查询结果列 -->
30 35
     <sql id="Base_Column_List">
31 36
         id, org_name, store_type_name, store_type_code, org_state, parent_id, build_time, keeper, lxfs, cf_status, zlxgd, sjcr, chang, kuan, 
32
-        cntj, last_time, house_type, high, radius
37
+        cntj, last_time, house_type, high, radius,house_wide_on,house_wide_under,house_length_left,house_length_right
33 38
     </sql>
34 39
 
35 40
     <select id="getStorehouse" parameterType="java.lang.Integer" resultType="java.util.Map">