Commit e5e54a0c zshaohui

1.出入库数据统计,7点到7点

2.状态为3时,errorCode为空问题
3.出料口增加心跳发送
1 个父辈 8ee5ccf5
...@@ -10,7 +10,6 @@ import com.neotel.smfcore.core.device.enums.BOX_STATUS; ...@@ -10,7 +10,6 @@ import com.neotel.smfcore.core.device.enums.BOX_STATUS;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage; import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager; import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil; import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
...@@ -84,9 +83,9 @@ public class KafkaService { ...@@ -84,9 +83,9 @@ public class KafkaService {
} }
String msg = statusBean.getMsg(); String msg = statusBean.getMsg();
String errorCode = statusBean.getErrorCode(); String errorCode = statusBean.getErrorCode();
String[] msgStr = msg.split("\r\n", -1); if (StringUtils.isNotBlank(msg) && StringUtils.isNotBlank(errorCode)) {
String[] errorCodeStr = errorCode.split("\r\n", -1); String[] msgStr = msg.split("\r\n");
String[] errorCodeStr = errorCode.split("\r\n");
for (int i = 0; i < errorCodeStr.length; i++) { for (int i = 0; i < errorCodeStr.length; i++) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("errorCode", errorCodeStr[i]); map.put("errorCode", errorCodeStr[i]);
...@@ -96,6 +95,7 @@ public class KafkaService { ...@@ -96,6 +95,7 @@ public class KafkaService {
} }
} }
} }
}
String currentStatus = "1"; String currentStatus = "1";
if (fault) { if (fault) {
...@@ -132,8 +132,13 @@ public class KafkaService { ...@@ -132,8 +132,13 @@ public class KafkaService {
log.info("返回结果为:" + JSON.toJSONString(future)); log.info("返回结果为:" + JSON.toJSONString(future));
} }
} else { } else {
if ("3".equals(currentStatus)){
status.setErrorCode("10100038");
status.setErrorMsg("设备未启动");
} else {
status.setErrorCode(""); status.setErrorCode("");
status.setErrorMsg(""); status.setErrorMsg("");
}
String statusStr = JSON.toJSONString(status); String statusStr = JSON.toJSONString(status);
log.info("主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr); log.info("主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr); ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
...@@ -166,8 +171,7 @@ public class KafkaService { ...@@ -166,8 +171,7 @@ public class KafkaService {
if (statusBean.timeOut()) { if (statusBean.timeOut()) {
normal = false; normal = false;
} else { } else {
int status = statusBean.getStatus(); if (!statusBean.isAvailable()) {
if (status == BOX_STATUS.EMERGENCY || status == BOX_STATUS.PROBLEM) {
normal = false; normal = false;
} }
} }
...@@ -233,6 +237,44 @@ public class KafkaService { ...@@ -233,6 +237,44 @@ public class KafkaService {
/** /**
* 发送出料口心跳
*/
@Scheduled(fixedRate = 1000 * 60 * 5)
public void setStorageHeartbeat() {
log.info("发送出料口心跳开始");
for (Map.Entry<String, StorageExport> exportEntry : StorageExportUtil.exportMap.entrySet()) {
if (exportEntry.getKey().contains(StorageExportUtil.OUT_STATION)) {
continue;
}
//默认是等待中2,禁用是故障3,有任务是运行1
String currentStatus = "2";
StorageExport export = exportEntry.getValue();
if (export.isDisable()) {
currentStatus = "3";
} else {
if (StringUtils.isNotBlank(export.getHSerial())) {
currentStatus = "1";
}
}
if (!"3".equals(currentStatus)) {
Heartbeat heartbeat = new Heartbeat();
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
heartbeat.setOccurrenceTime(dateStr);
heartbeat.setMachineID(StorageExportConfig.getMachineId(exportEntry.getKey()));
heartbeat.setTopicType(KafkaConfig.HEARTBEAT_TOPIC);
String statusStr = JSON.toJSONString(heartbeat);
log.info("出料口主题为:" + KafkaConfig.HEARTBEAT_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.HEARTBEAT_TOPIC, statusStr);
log.info("出料口返回结果为:" + JSON.toJSONString(future));
}
}
log.info("发送出料口心跳结束");
}
/**
* MachineParameter发送 * MachineParameter发送
*/ */
@Scheduled(fixedRate = 1000 * 60 * 5) @Scheduled(fixedRate = 1000 * 60 * 5)
...@@ -287,11 +329,9 @@ public class KafkaService { ...@@ -287,11 +329,9 @@ public class KafkaService {
public int getTodayInOutCount(List<String> storageIdList, int type) { public int getTodayInOutCount(List<String> storageIdList, int type) {
String todayStr = DateUtil.today();
DateTime today = DateUtil.parse(todayStr, "yyyy-MM-dd");
Query q = new Query(); Query q = new Query();
Criteria c = new Criteria(); Criteria c = new Criteria();
c.and("updateDate").gte(today); //时间大于今天 c.and("updateDate").gte(getDate()); //时间大于今天
c.and("status").in(OP_STATUS.END.name(), OP_STATUS.FINISHED.name()); // 任务是完成的 c.and("status").in(OP_STATUS.END.name(), OP_STATUS.FINISHED.name()); // 任务是完成的
c.and("storageId").in(storageIdList); c.and("storageId").in(storageIdList);
c.and("type").is(type); c.and("type").is(type);
...@@ -299,6 +339,25 @@ public class KafkaService { ...@@ -299,6 +339,25 @@ public class KafkaService {
} }
private Date getDate() {
//1.获取到当前时间
Date currentDate = new Date();
//2.获取到今天的开始时间
String currentDay = DateUtil.format(currentDate, "yyyy-MM-dd");
currentDay += " 07:00:00";
Date startDate = DateUtil.parse(currentDay, "yyyy-MM-dd HH:mm:ss");
//3.如果当前时间大于今天开始时间,则返回
if (currentDate.getTime() > startDate.getTime()) {
return startDate;
} else {
startDate = DateUtil.offsetDay(startDate, -1);
}
log.info("获取到开始时间为:"+startDate);
return startDate;
}
public List<String> getMachineIdList() { public List<String> getMachineIdList() {
//找出所有的machineId //找出所有的machineId
List<String> machineIdList = new ArrayList<>(); List<String> machineIdList = new ArrayList<>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!