作者 钟来

对接plc

@@ -99,7 +99,7 @@ public class ControlDeviceConreoller extends BaseController { @@ -99,7 +99,7 @@ public class ControlDeviceConreoller extends BaseController {
99 String body = new String(bodyBytes, request.getCharacterEncoding()); 99 String body = new String(bodyBytes, request.getCharacterEncoding());
100 DeviceCommand deviceCommand = new DeviceCommand(); 100 DeviceCommand deviceCommand = new DeviceCommand();
101 deviceCommand.setDeviceId(deviceId); 101 deviceCommand.setDeviceId(deviceId);
102 - deviceCommand.setCommandType(CommandType.write); 102 + deviceCommand.setCommandType(CommandType.read);
103 deviceCommand.setData(GsonConstructor.get().fromJson(body,JsonObject.class)); 103 deviceCommand.setData(GsonConstructor.get().fromJson(body,JsonObject.class));
104 return rocketMqSendService.deviceControl(deviceCommand); 104 return rocketMqSendService.deviceControl(deviceCommand);
105 } 105 }
@@ -101,7 +101,10 @@ public class MNPLCProtocolParserFactoryImpl implements ProtocolParserFactory { @@ -101,7 +101,10 @@ public class MNPLCProtocolParserFactoryImpl implements ProtocolParserFactory {
101 number_name = keyArr[0]+"区"+keyArr[2]+"号"+iotProductPlcDevice.getName()+keyArr[2]; 101 number_name = keyArr[0]+"区"+keyArr[2]+"号"+iotProductPlcDevice.getName()+keyArr[2];
102 if("YEL".equals(identifier)) 102 if("YEL".equals(identifier))
103 { 103 {
104 - int type = jsonObject.get(key.replace("SENSOR","TYPE")).getAsInt(); 104 + String yuerlTypeKey = key.replace(data_identifier,"TYPE");
  105 + if (jsonObject.has(yuerlTypeKey))
  106 + {
  107 + int type = jsonObject.get(yuerlTypeKey).getAsInt();
105 if(type==0) 108 if(type==0)
106 { 109 {
107 continue; 110 continue;
@@ -127,6 +130,8 @@ public class MNPLCProtocolParserFactoryImpl implements ProtocolParserFactory { @@ -127,6 +130,8 @@ public class MNPLCProtocolParserFactoryImpl implements ProtocolParserFactory {
127 } 130 }
128 } 131 }
129 } 132 }
  133 +
  134 + }
130 } 135 }
131 136
132 if(StringUtils.isNotEmpty(number)) 137 if(StringUtils.isNotEmpty(number))
@@ -28,6 +28,7 @@ public class DeviceCommandListenServiceImpl implements DeviceCommandServiceFacto @@ -28,6 +28,7 @@ public class DeviceCommandListenServiceImpl implements DeviceCommandServiceFacto
28 private static final Logger log = LoggerFactory.getLogger(DeviceCommandListenServiceImpl.class); 28 private static final Logger log = LoggerFactory.getLogger(DeviceCommandListenServiceImpl.class);
29 @Override 29 @Override
30 public NoticeMessageDto read(String deviceId, JsonObject jsonObject) { 30 public NoticeMessageDto read(String deviceId, JsonObject jsonObject) {
  31 + log.info("不支持读功能");
31 return null; 32 return null;
32 } 33 }
33 34
@@ -40,7 +41,7 @@ public class DeviceCommandListenServiceImpl implements DeviceCommandServiceFacto @@ -40,7 +41,7 @@ public class DeviceCommandListenServiceImpl implements DeviceCommandServiceFacto
40 noticeMessageDto.setTopic(topic); 41 noticeMessageDto.setTopic(topic);
41 noticeMessageDto.setTopicconfig(topicModel); 42 noticeMessageDto.setTopicconfig(topicModel);
42 43
43 - //将jsonObject里面的两层键值比如:{"1":{"key","value","key1",1}}提取成一层放在commdjson里面如{"key":"value","key1":1} 44 + //将{"0":"a,b,c","1":"a,b,c"}变成{"A_SYS_0_"}
44 JsonObject commdjson = flattenJsonObject(jsonObject); 45 JsonObject commdjson = flattenJsonObject(jsonObject);
45 46
46 noticeMessageDto.setCommd(commdjson.toString().getBytes()); 47 noticeMessageDto.setCommd(commdjson.toString().getBytes());
@@ -36,7 +36,8 @@ @@ -36,7 +36,8 @@
36 * LEVEL:液位值 36 * LEVEL:液位值
37 * MODE:运行模式 37 * MODE:运行模式
38 * OTHER:现场扩展参数 38 * OTHER:现场扩展参数
39 -* 39 +* YWJC: 液位计自动控制
  40 +* CXCLEAN: 冲洗次数清零
40 41
41 格式示例:`A_TLJ_1_RUN` 42 格式示例:`A_TLJ_1_RUN`
42 43
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Controller; @@ -15,6 +15,7 @@ import org.springframework.stereotype.Controller;
15 import org.springframework.web.bind.annotation.PathVariable; 15 import org.springframework.web.bind.annotation.PathVariable;
16 import org.springframework.web.bind.annotation.RequestMapping; 16 import org.springframework.web.bind.annotation.RequestMapping;
17 import org.springframework.web.bind.annotation.RequestMethod; 17 import org.springframework.web.bind.annotation.RequestMethod;
  18 +import org.springframework.web.bind.annotation.ResponseBody;
18 19
19 import javax.servlet.http.HttpServletResponse; 20 import javax.servlet.http.HttpServletResponse;
20 import java.io.*; 21 import java.io.*;
@@ -29,6 +30,7 @@ public class LogController { @@ -29,6 +30,7 @@ public class LogController {
29 @Autowired 30 @Autowired
30 private DeviceCommandListenService deviceCommandListenService; 31 private DeviceCommandListenService deviceCommandListenService;
31 @ApiOperation("获取") 32 @ApiOperation("获取")
  33 + @ResponseBody
32 @RequestMapping(value = "getOperation_token",method = RequestMethod.GET) 34 @RequestMapping(value = "getOperation_token",method = RequestMethod.GET)
33 public String getOperation_token() 35 public String getOperation_token()
34 { 36 {
@@ -11,11 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -11,11 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Controller; 11 import org.springframework.stereotype.Controller;
12 import org.springframework.web.bind.annotation.RequestMapping; 12 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RequestMethod; 13 import org.springframework.web.bind.annotation.RequestMethod;
  14 +import org.springframework.web.bind.annotation.RestController;
14 15
15 import java.util.Map; 16 import java.util.Map;
16 17
17 @Api(tags = "系统运行接口") 18 @Api(tags = "系统运行接口")
18 -@Controller 19 +@RestController
19 @RequestMapping("/sys") 20 @RequestMapping("/sys")
20 public class SysConfigController { 21 public class SysConfigController {
21 22