diff --git a/psdc-business/src/main/java/com/psdc/entity/vo/ModelVo.java b/psdc-business/src/main/java/com/psdc/entity/vo/ModelVo.java index 36b8a0f..2c12703 100644 --- a/psdc-business/src/main/java/com/psdc/entity/vo/ModelVo.java +++ b/psdc-business/src/main/java/com/psdc/entity/vo/ModelVo.java @@ -26,5 +26,6 @@ public class ModelVo implements Serializable,Cloneable{ private String ioDesc ; /** io类型【serve服务;event事件,attribute属性】 */ private String ioType ; - + /** io描述 */ + private String ioRemark ; } \ No newline at end of file diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java index bcc0830..d3fb266 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java @@ -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 data = new ArrayList<>(); String value = ""; if (runStatus == 1) { value = "启动"; + HashMap map = new HashMap<>(); + map.put("Open", "1"); + data.add(map); } else if (runStatus == 2) { value = "停止"; + HashMap 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 ary = new ArrayList<>(); for (HashMap map : data) { // 模式策略下属各场景步骤控制指令下发执行日志 String controlKey = map.get("controlKey").toString(); String controlValue = map.get("controlValue").toString(); + HashMap 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; } } + } \ No newline at end of file diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java index 2c881fc..b6d4082 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java @@ -409,7 +409,7 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { switch (value){ case "1": return "open"; - case "2": + case "0": return "close"; default: return "Start-End"; diff --git a/psdc-business/src/main/resources/mapper/business/PsdcModelMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcModelMapper.xml index 58148ed..84bd597 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcModelMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcModelMapper.xml @@ -7,6 +7,7 @@ + @@ -66,7 +67,7 @@ diff --git a/psdc-business/src/main/resources/mapper/business/PsdcStrategyMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcStrategyMapper.xml index 9ab1ac7..caa7651 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcStrategyMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcStrategyMapper.xml @@ -16,8 +16,8 @@ diff --git a/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml index 03c618e..d12f538 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml @@ -51,7 +51,7 @@ And date_format(pth.update_time,'%Y-%m-%d %H:%i:%S') <= date_format(#{endTime},'%Y-%m-%d %H:%i:%S') - GROUP BY PTH.update_time + GROUP BY pth.update_time ORDER BY pth.update_time