|
|
|
@ -135,6 +135,7 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
Double tempValue = 0.0; |
|
|
|
|
map.put("controlElement", mv.getRelationField()); |
|
|
|
|
map.put("controlRemark", mv.getIoDesc()); |
|
|
|
|
map.put("nowTempRemark", mv.getIoRemark()); |
|
|
|
|
if (null != thermometerDataRes) { |
|
|
|
|
switch (mv.getRelationField()) { |
|
|
|
|
case "intemp": |
|
|
|
@ -276,15 +277,23 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
@Override |
|
|
|
|
public int controlDeviceStartAndStop(Integer deviceId, Integer runStatus, String controlBy, Integer controlMethod) { |
|
|
|
|
|
|
|
|
|
List<HashMap> data = new ArrayList<>(); |
|
|
|
|
String value = ""; |
|
|
|
|
if (runStatus == 1) { |
|
|
|
|
value = "启动"; |
|
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("Open", "1"); |
|
|
|
|
data.add(map); |
|
|
|
|
} else if (runStatus == 2) { |
|
|
|
|
value = "停止"; |
|
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("Close", "0"); |
|
|
|
|
data.add(map); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("设备id:{}", deviceId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PsdcDevice psdcDevice = psdcDeviceMapper.queryById(deviceId); |
|
|
|
|
if (psdcDevice == null) { |
|
|
|
|
psdcControlLogMapper.insert(new PsdcControlLog(deviceId, null, null, "设备启停", value, controlMethod, 3, "未找到该设备", controlBy)); |
|
|
|
@ -296,6 +305,16 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 发送MQTT指令
|
|
|
|
|
MyMQTTClient myMQTTClient = new MyMQTTClient(); |
|
|
|
|
// 封装控制策略Json
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("mid",MID); |
|
|
|
|
jsonObject.put("timestamp",sdf2.format(new Date())); |
|
|
|
|
jsonObject.put("deviceId",deviceId); |
|
|
|
|
jsonObject.put("data",data); |
|
|
|
|
MID = MID + 1; |
|
|
|
|
myMQTTClient.publish(jsonObject.toJSONString(), "/hwj1/dntd/request/action/command", 2, false); |
|
|
|
|
|
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),"设备启停",value,controlMethod,3,"手动控制,等待终端响应超时",controlBy));
|
|
|
|
|
// 发送成功
|
|
|
|
|
|
|
|
|
@ -322,33 +341,36 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(0); |
|
|
|
|
|
|
|
|
|
List<HashMap> ary = new ArrayList<>(); |
|
|
|
|
for (HashMap map : data) { |
|
|
|
|
// 模式策略下属各场景步骤控制指令下发执行日志
|
|
|
|
|
String controlKey = map.get("controlKey").toString(); |
|
|
|
|
String controlValue = map.get("controlValue").toString(); |
|
|
|
|
HashMap<String, Object> map2 = new HashMap<>(); |
|
|
|
|
map2.put(coverKey(controlKey), controlValue); |
|
|
|
|
ary.add(map2); |
|
|
|
|
if (controlValue.equals("1") || controlValue.equals("2")) { |
|
|
|
|
controlValue = coverStr("r", Integer.parseInt(controlValue)); |
|
|
|
|
} |
|
|
|
|
String controlContext = ControlKeyEnum.getControlContext(controlKey); |
|
|
|
|
|
|
|
|
|
// TODO 发送MQTT指令
|
|
|
|
|
MyMQTTClient myMQTTClient = new MyMQTTClient(); |
|
|
|
|
// 封装控制策略Json
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("mid",MID); |
|
|
|
|
jsonObject.put("timestamp",sdf2.format(new Date())); |
|
|
|
|
jsonObject.put("deviceId",deviceId); |
|
|
|
|
jsonObject.put("data",data); |
|
|
|
|
MID = MID + 1; |
|
|
|
|
myMQTTClient.publish(jsonObject.toJSONString(), "/hwj1/dntd/request/action/command", 2, false); |
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,2,"控制成功",controlBy));
|
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,3,"等待终端响应超时",controlBy));
|
|
|
|
|
// 发送成功
|
|
|
|
|
|
|
|
|
|
psdcControlLogMapper.insert(new PsdcControlLog(deviceId, psdcDevice.getDeviceName(), psdcDevice.getDeviceSn(), controlContext, controlValue, controlMethod, 2, "控制成功", controlBy)); |
|
|
|
|
atomicInteger.incrementAndGet(); |
|
|
|
|
} |
|
|
|
|
// TODO 发送MQTT指令
|
|
|
|
|
MyMQTTClient myMQTTClient = new MyMQTTClient(); |
|
|
|
|
// 封装控制策略Json
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("mid",MID); |
|
|
|
|
jsonObject.put("timestamp",sdf2.format(new Date())); |
|
|
|
|
jsonObject.put("deviceId",deviceId); |
|
|
|
|
jsonObject.put("data", ary); |
|
|
|
|
MID = MID + 1; |
|
|
|
|
myMQTTClient.publish(jsonObject.toJSONString(), "/hwj1/dntd/request/action/command", 2, false); |
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,2,"控制成功",controlBy));
|
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,3,"等待终端响应超时",controlBy));
|
|
|
|
|
// 发送成功
|
|
|
|
|
|
|
|
|
|
atomicInteger.incrementAndGet(); |
|
|
|
|
|
|
|
|
|
return atomicInteger.get(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -670,4 +692,5 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |