| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | import com.qianwen.mdc.collect.service.IOTMqttReceiveService; |
| | | import com.qianwen.mdc.collect.service.WorkstationAppMappingService; |
| | | import com.qianwen.mdc.collect.service.WorkstationDatapointsService; |
| | | import com.qianwen.mdc.collect.service.feedback.WorkstationFeedbackService; |
| | | |
| | |
| | | |
| | | @Value("${mqtt.password:}") |
| | | private String mqttPassword; |
| | | |
| | | @Value("${mqtt.timeout:1000}") |
| | | private int timeout; |
| | | |
| | | @Autowired |
| | | private IOTMqttReceiveService recService; |
| | | @Autowired |
| | | private DeviceStateFixPointService stateFixPointService; |
| | | @Autowired |
| | | private WorkstationFeedbackService workstationFeedbackService; |
| | | @Autowired |
| | | private WorkstationAppMappingService workstationAppMappingService; |
| | | |
| | | @Autowired |
| | | private WorkstationDatapointsService dpService; |
| | |
| | | */ |
| | | public static final String FEEDBACK_TOPIC = "mdc/feedback"; |
| | | |
| | | /** |
| | | * 工位创建消息,mdc中新建工位时发送,本应用接收并处理 |
| | | */ |
| | | public static final String WOCKSTATION_CREATE_TOPIC = "mdc/workstation-create"; |
| | | |
| | | /** |
| | |
| | | DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory(); |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | | options.setServerURIs(new String[] { mqttHost});//"tcp://82.156.1.83:1884" |
| | | options.setConnectionTimeout(timeout); |
| | | |
| | | if(ObjectUtil.isNotEmpty(mqttUserName)) { |
| | | options.setUserName(mqttUserName); |
| | |
| | | }else if(WORKSTATION_DATAPOINT_CHANGED_TOPIC.equals(topic)) { |
| | | String payload = (String)message.getPayload(); |
| | | logger.info("工位appId映射变化消息={}",payload); |
| | | workstationAppMappingService.saveToCache(); |
| | | //workstationAppMappingService.saveToCache(); |
| | | //清除该工位的数据点缓存 |
| | | JSONObject payloadObj = JSONObject.parseObject(payload); |
| | | //payloadObj.getLong("workstationId"); |
| | | |
| | | dpService.datapointsCacheEvict(payloadObj.getString("appId")); |
| | | } else {//订阅了几个topic就会接收到几个,其他的不会进来 |
| | | logger.warn("topic={},msg={},无对应的处理器",topic,message.getPayload()); |