Commit 0d8d5905 zshaohui

定时抛送设备状态

1 个父辈 7620eb50
......@@ -7,6 +7,7 @@ import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.device.util.EquipmentCache;
import com.neotel.smfcore.core.equipment.bean.EquipMsg;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
......@@ -15,6 +16,7 @@ import com.neotel.smfcore.core.system.util.EquipStatusUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.kafka.bean.Heartbeat;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.kafka.bean.MachineParameter;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.kafka.bean.MachineParameterData;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.kafka.bean.MachineStatus;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.kafka.config.KafkaConfig;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.kafka.config.StorageNameConfig;
import lombok.extern.slf4j.Slf4j;
......@@ -49,9 +51,71 @@ public class KafkaService {
/**
* 抛送入料机构,分拣机构的设备状态信息,每1分钟抛送一次
*/
//@Scheduled(fixedRate = 1000 * 60 * 1)
public void setRawMaterialInOutMachineStatus() {
//获取所有的设备
List<String> rawMaterialList = StorageNameConfig.getRawMaterialList();
for (String machineId : rawMaterialList) {
String currentStatus = "1"; //正常
List<EquipMsg> equipMsgList = new ArrayList<>();
EquipStatusBean statusBean = EquipStatusUtil.getStatusBean(machineId);
if (statusBean == null){
currentStatus = "5";
} else {
int status = statusBean.getStatus(); //状态
if (2 == status || 3 == status) {
currentStatus = "3"; //故障
}
if (0 == status) {
currentStatus = "5";
}
equipMsgList = statusBean.getMsgList();
}
if (equipMsgList != null && !equipMsgList.isEmpty()){
for (EquipMsg equipMsg : equipMsgList) {
MachineStatus machineStatus = new MachineStatus();
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
machineStatus.setOccurrenceTime(dateStr);
machineStatus.setMachineID(machineId);
machineStatus.setTopicType(KafkaConfig.MACHINESTATUS_TOPIC);
machineStatus.setCurrentStatus(currentStatus);
machineStatus.setErrorCode(equipMsg.getErrorCode());
machineStatus.setErrorMsg(equipMsg.getMsg());
machineStatus.setClientIP("");
String statusStr = JSON.toJSONString(machineStatus);
log.info(machineId+"抛送设备状态主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
log.info(machineId+"抛送设备状态返回结果为:" + JSON.toJSONString(future));
}
} else {
MachineStatus machineStatus = new MachineStatus();
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
machineStatus.setOccurrenceTime(dateStr);
machineStatus.setMachineID(machineId);
machineStatus.setTopicType(KafkaConfig.MACHINESTATUS_TOPIC);
machineStatus.setCurrentStatus(currentStatus);
machineStatus.setErrorCode("");
machineStatus.setErrorMsg("");
machineStatus.setClientIP("");
String statusStr = JSON.toJSONString(machineStatus);
log.info(machineId+"抛送设备状态主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
log.info(machineId+"抛送设备状态返回结果为:" + JSON.toJSONString(future));
}
}
}
/**
* 抛送入料机构,分拣机构的心跳,每10s抛送一次
*/
@Scheduled(fixedRate = 1000 * 10)
//@Scheduled(fixedRate = 1000 * 10)
public void setRawMaterialInOutHeartbeat() {
//获取所有的设备
List<String> rawMaterialList = StorageNameConfig.getRawMaterialList();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!