|
|
@@ -33,10 +33,7 @@ import org.springframework.web.client.RestTemplate;
|
|
33
|
33
|
|
|
34
|
34
|
import java.math.BigDecimal;
|
|
35
|
35
|
import java.math.RoundingMode;
|
|
36
|
|
-import java.util.ArrayList;
|
|
37
|
|
-import java.util.Collections;
|
|
38
|
|
-import java.util.Date;
|
|
39
|
|
-import java.util.List;
|
|
|
36
|
+import java.util.*;
|
|
40
|
37
|
|
|
41
|
38
|
import javax.annotation.Resource;
|
|
42
|
39
|
|
|
|
@@ -46,7 +43,8 @@ public class TeDataServiceImpl implements TeDataService {
|
|
46
|
43
|
private static final Logger logger = LoggerFactory.getLogger(TeDataServiceImpl.class);
|
|
47
|
44
|
|
|
48
|
45
|
//static String base_url = "http://192.168.0.61:4017/";
|
|
49
|
|
- static boolean flag = true;
|
|
|
46
|
+ private static HashMap<String, Object> flag=new HashMap<>() ;
|
|
|
47
|
+// static boolean flag = true;
|
|
50
|
48
|
static double h1 = 6; //h1 圆锥的高
|
|
51
|
49
|
static double h2 = 3; //h2 水平地面到圆锥尖的高
|
|
52
|
50
|
private STaskMapper sTaskMapper;
|
|
|
@@ -113,7 +111,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
113
|
111
|
|
|
114
|
112
|
postHelper(teData,base_url);
|
|
115
|
113
|
//equipmentTestingEnd
|
|
116
|
|
- flag = true;
|
|
|
114
|
+// flag = true;
|
|
117
|
115
|
|
|
118
|
116
|
}
|
|
119
|
117
|
|
|
|
@@ -126,7 +124,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
126
|
124
|
// TODO Auto-generated method stub
|
|
127
|
125
|
//根据仓房id 获取设备编号
|
|
128
|
126
|
QueryWrapper<HardwareParameter> queryWrapper = new QueryWrapper<>();
|
|
129
|
|
- queryWrapper.eq("house_id", Integer.parseInt(cfId));
|
|
|
127
|
+ queryWrapper.eq("house_id", Long.parseLong(cfId));
|
|
130
|
128
|
List<HardwareParameter> hardList = hardwareParameterMapper.selectList(queryWrapper);
|
|
131
|
129
|
if(hardList.size()>0){
|
|
132
|
130
|
logger.info("圆筒{}仓第一次打点的直径和高: {},{}",cfId ,diameter,h);
|
|
|
@@ -150,8 +148,8 @@ public class TeDataServiceImpl implements TeDataService {
|
|
150
|
148
|
|
|
151
|
149
|
//发送给硬件
|
|
152
|
150
|
postHelper(teData,base_url);
|
|
153
|
|
-
|
|
154
|
|
- flag = true;
|
|
|
151
|
+
|
|
|
152
|
+// flag = true;
|
|
155
|
153
|
|
|
156
|
154
|
}
|
|
157
|
155
|
}
|
|
|
@@ -170,7 +168,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
170
|
168
|
e.printStackTrace();
|
|
171
|
169
|
}
|
|
172
|
170
|
//只运行 发送一次。
|
|
173
|
|
- if (flag) {
|
|
|
171
|
+
|
|
174
|
172
|
|
|
175
|
173
|
// 第二次待打点
|
|
176
|
174
|
|
|
|
@@ -184,41 +182,41 @@ public class TeDataServiceImpl implements TeDataService {
|
|
184
|
182
|
|
|
185
|
183
|
//查询设备的ip和端口
|
|
186
|
184
|
QueryWrapper<HardwareParameter> queryWrapper = new QueryWrapper<>();
|
|
187
|
|
- queryWrapper.eq("house_id", Integer.parseInt(houseId));
|
|
|
185
|
+ queryWrapper.eq("house_id", Long.parseLong(houseId));
|
|
188
|
186
|
List<HardwareParameter> hardList = hardwareParameterMapper.selectList(queryWrapper);
|
|
189
|
|
-
|
|
190
|
|
- if(hardList.size()>0){
|
|
|
187
|
+ //判断是否已经进行过第二次打点,如果有设备信息,且设备flag中无此设备,即进行第二次打点;
|
|
|
188
|
+ if(hardList.size()>0&& !flag.containsKey(hardList.get(0).getIpAdress()) ){
|
|
191
|
189
|
|
|
192
|
|
- OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
|
|
193
|
|
- String high = orgInfoHouse.getHigh();//仓房的高
|
|
194
|
|
- String radius = orgInfoHouse.getRadius();//仓房的半径
|
|
195
|
|
- Double diameter = Double.parseDouble(radius)*2;//直径
|
|
196
|
|
- Double h = Double.parseDouble(high);
|
|
197
|
|
-
|
|
198
|
|
- List<Double> zList = CylinderAlg.getValidZ(teData.getRotationxy(), diameter, h);
|
|
199
|
|
- double z = Collections.max(zList);//纵坐标的最大值
|
|
200
|
|
- double z1 = Collections.min(zList);//纵坐标的最小值
|
|
201
|
|
- //第二次打点的高
|
|
202
|
|
- //double secondH = h - z;//仓房的高-点的纵坐标
|
|
203
|
|
- double secondH = z;
|
|
204
|
|
- logger.info("z {} ,z1 {},diameter {},secondH {}",z,z1,diameter,secondH);
|
|
205
|
|
-
|
|
206
|
|
- //打点
|
|
207
|
|
- String rotationxy = CylinderAlg.getAveragePosition1(diameter, secondH);
|
|
208
|
|
- teData.setRotationxy(rotationxy);
|
|
209
|
|
- teData.setStime(new Date());//第二次开始的时间
|
|
210
|
|
-
|
|
211
|
|
- //IP地址
|
|
212
|
|
- String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
|
|
213
|
|
-
|
|
214
|
|
- //发送给硬件打点数据
|
|
215
|
|
- postHelper(teData,base_url);
|
|
216
|
|
-
|
|
217
|
|
- flag = false;
|
|
218
|
|
- }
|
|
219
|
|
-
|
|
220
|
|
-
|
|
221
|
|
- } else {
|
|
|
190
|
+ OrgInfo orgInfoHouse = orgInfoMapper.selectById(Long.parseLong(houseId));
|
|
|
191
|
+ String high = orgInfoHouse.getHigh();//仓房的高
|
|
|
192
|
+ String radius = orgInfoHouse.getRadius();//仓房的半径
|
|
|
193
|
+ Double diameter = Double.parseDouble(radius)*2;//直径
|
|
|
194
|
+ Double h = Double.parseDouble(high);
|
|
|
195
|
+
|
|
|
196
|
+ List<Double> zList = CylinderAlg.getValidZ(teData.getRotationxy(), diameter, h);
|
|
|
197
|
+ double z = Collections.max(zList);//纵坐标的最大值
|
|
|
198
|
+ double z1 = Collections.min(zList);//纵坐标的最小值
|
|
|
199
|
+ //第二次打点的高
|
|
|
200
|
+ //double secondH = h - z;//仓房的高-点的纵坐标
|
|
|
201
|
+ double secondH = z;
|
|
|
202
|
+ logger.info("z {} ,z1 {},diameter {},secondH {}",z,z1,diameter,secondH);
|
|
|
203
|
+
|
|
|
204
|
+ //打点
|
|
|
205
|
+ String rotationxy = CylinderAlg.getAveragePosition1(diameter, secondH);
|
|
|
206
|
+ teData.setRotationxy(rotationxy);
|
|
|
207
|
+ teData.setStime(new Date());//第二次开始的时间
|
|
|
208
|
+
|
|
|
209
|
+ //IP地址
|
|
|
210
|
+ String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
|
|
|
211
|
+
|
|
|
212
|
+ //发送给硬件打点数据
|
|
|
213
|
+ postHelper(teData,base_url);
|
|
|
214
|
+ //已打点设备信息
|
|
|
215
|
+ flag.put(hardList.get(0).getIpAdress(),"");
|
|
|
216
|
+// flag = false;
|
|
|
217
|
+
|
|
|
218
|
+ } else {
|
|
|
219
|
+ flag.remove(hardList.get(0).getIpAdress());
|
|
222
|
220
|
//打点两次完毕 计算体积
|
|
223
|
221
|
logger.info("计算体积。。。。");
|
|
224
|
222
|
double v = this.calculateVolume(teData.getTaskID());//两次数据
|
|
|
@@ -277,7 +275,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
277
|
275
|
|
|
278
|
276
|
//获取直径
|
|
279
|
277
|
String houseId = taskID.split(",")[0];//仓房id
|
|
280
|
|
- OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
|
|
|
278
|
+ OrgInfo orgInfoHouse = orgInfoMapper.selectById(Long.parseLong(houseId));
|
|
281
|
279
|
String radius = orgInfoHouse.getRadius();//仓房的半径
|
|
282
|
280
|
Double diameter = Double.parseDouble(radius)*2;//直径
|
|
283
|
281
|
String high = orgInfoHouse.getHigh();//高
|
|
|
@@ -313,7 +311,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
313
|
311
|
String rotationxy = teDataList.get(0).getRotationxy();
|
|
314
|
312
|
//获取直径
|
|
315
|
313
|
String houseId = taskID.split(",")[0];//仓房id
|
|
316
|
|
- OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
|
|
|
314
|
+ OrgInfo orgInfoHouse = orgInfoMapper.selectById(Long.parseLong(houseId));
|
|
317
|
315
|
String radius = orgInfoHouse.getRadius();//仓房的半径
|
|
318
|
316
|
Double diameter = Double.parseDouble(radius)*2;//直径
|
|
319
|
317
|
String high = orgInfoHouse.getHigh();//高
|
|
|
@@ -366,7 +364,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
366
|
364
|
|
|
367
|
365
|
|
|
368
|
366
|
//获取仓房信息
|
|
369
|
|
- OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
|
|
|
367
|
+ OrgInfo orgInfoHouse = orgInfoMapper.selectById(Long.parseLong(houseId));
|
|
370
|
368
|
|
|
371
|
369
|
//获取其库名称
|
|
372
|
370
|
OrgInfo orgInfo = orgInfoMapper.selectById(orgInfoHouse.getParentId());
|
|
|
@@ -411,7 +409,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
411
|
409
|
|
|
412
|
410
|
String houseId = taskId.split(",")[0];//仓房id
|
|
413
|
411
|
//获取仓房信息
|
|
414
|
|
- OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
|
|
|
412
|
+ OrgInfo orgInfoHouse = orgInfoMapper.selectById(Long.parseLong(houseId));
|
|
415
|
413
|
String radius = orgInfoHouse.getRadius();//仓房的半径
|
|
416
|
414
|
Double diameter = Double.parseDouble(radius)*2;//直径
|
|
417
|
415
|
String high = orgInfoHouse.getHigh();//高
|
|
|
@@ -491,7 +489,7 @@ public class TeDataServiceImpl implements TeDataService {
|
|
491
|
489
|
// TODO Auto-generated method stub
|
|
492
|
490
|
//根据仓房id 获取设备编号
|
|
493
|
491
|
QueryWrapper<HardwareParameter> queryWrapper = new QueryWrapper<>();
|
|
494
|
|
- queryWrapper.eq("house_id", Integer.parseInt(cfId));
|
|
|
492
|
+ queryWrapper.eq("house_id", Long.parseLong(cfId));
|
|
495
|
493
|
List<HardwareParameter> hardList = hardwareParameterMapper.selectList(queryWrapper);
|
|
496
|
494
|
StringBuffer sb = new StringBuffer();
|
|
497
|
495
|
if(hardList.size()>0){
|