作者 钟来

对接plc

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