|
@@ -2,12 +2,14 @@ package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
+import com.welampiot.dao.WaterImmersionDevInfoDao;
|
|
|
import com.welampiot.dto.AirSwitchInfoDTO;
|
|
|
import com.welampiot.dto.WaterImmersionDevInfoDTO;
|
|
|
import com.welampiot.dto.WaterImmersionDevInfoLogDTO;
|
|
|
import com.welampiot.service.AirSwitchInfoService;
|
|
|
import com.welampiot.service.WaterImmersionDevInfoService;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.utils.WebUtils;
|
|
|
import com.welampiot.vo.AirSwitchInfoReturnVO;
|
|
|
import com.welampiot.vo.WaterImmersionDevInfoLogVO;
|
|
|
import com.welampiot.vo.WaterImmersionDevInfoVO;
|
|
@@ -231,4 +233,60 @@ public class WaterImmersionController {
|
|
|
airSwitchInfoReturnVO1.setTotal(total);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,airSwitchInfoReturnVO1);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置报警延时时间
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/setAlarmTime", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> setAlarmTime(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ Integer delayTime = (Integer) toolUtils.getRequestContent(request,"delayTime",1);
|
|
|
+
|
|
|
+ WaterImmersionDevInfoDTO waterDTOById = waterImmersionDevInfoService.getWaterDTOById(id);
|
|
|
+ if (waterDTOById.getFactory() == 1 || waterDTOById.getFactory() == 2) return toolUtils.response(InterfaceResultEnum.DEVICE_NO_SUPPORT,version);
|
|
|
+ if (waterDTOById.getModel() == 1 && waterDTOById.getFactory() == 0){
|
|
|
+ String timeHex = Integer.toHexString(delayTime);
|
|
|
+ timeHex = "0000"+timeHex;
|
|
|
+ timeHex = timeHex.substring(timeHex.length()-4);
|
|
|
+ String address = Integer.toHexString(Integer.parseInt(waterDTOById.getAddress()));
|
|
|
+ address = "00"+address;
|
|
|
+ address = address.substring(address.length()-2);
|
|
|
+ String cmd = address + "060033" + timeHex;
|
|
|
+ cmd += toolUtils.getCRC(cmd.getBytes());
|
|
|
+ cmd = "0202"+cmd;
|
|
|
+ String sendTopic = "/WEGW2/TransIn/"+waterDTOById.getNum();
|
|
|
+ String backTopic = "/WEGW2/TransOut/"+waterDTOById.getNum();
|
|
|
+ String s = toolUtils.sendMqttCmd(sendTopic, toolUtils.hexString2Bytes(cmd), backTopic);
|
|
|
+ if (s == null || s.length() == 0) return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
|
+ WaterImmersionDevInfoDTO waterImmersionDevInfoDTO = new WaterImmersionDevInfoDTO();
|
|
|
+ waterImmersionDevInfoDTO.setId(id);
|
|
|
+ waterImmersionDevInfoDTO.setDelayTime(delayTime);
|
|
|
+ waterImmersionDevInfoService.updateDelayTimeByDto(waterImmersionDevInfoDTO);
|
|
|
+ } else if (waterDTOById.getModel() == 3 && waterDTOById.getFactory() == 0) {
|
|
|
+ String port = "00"+waterDTOById.getSerialPort();
|
|
|
+ port = port.substring(port.length()-2);
|
|
|
+ String timeHex = Integer.toHexString(delayTime);
|
|
|
+ timeHex = "0000"+timeHex;
|
|
|
+ timeHex = timeHex.substring(timeHex.length()-4);
|
|
|
+ String address = Integer.toHexString(Integer.parseInt(waterDTOById.getAddress()));
|
|
|
+ address = "00"+address;
|
|
|
+ address = address.substring(address.length()-2);
|
|
|
+ String cmd = address + "060033" + timeHex;
|
|
|
+ cmd += toolUtils.getCRC(cmd.getBytes());
|
|
|
+ cmd = "0202"+port+cmd;
|
|
|
+ String sendTopic = "/WEGW3/TransIn/"+waterDTOById.getNum();
|
|
|
+ String backTopic = "/WEGW3/TransOut/"+waterDTOById.getNum();
|
|
|
+ String s = toolUtils.sendMqttCmd(sendTopic, toolUtils.hexString2Bytes(cmd), backTopic);
|
|
|
+ if (s == null || s.length() == 0) return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
|
+ WaterImmersionDevInfoDTO waterImmersionDevInfoDTO = new WaterImmersionDevInfoDTO();
|
|
|
+ waterImmersionDevInfoDTO.setId(id);
|
|
|
+ waterImmersionDevInfoDTO.setDelayTime(delayTime);
|
|
|
+ waterImmersionDevInfoService.updateDelayTimeByDto(waterImmersionDevInfoDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|