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;
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.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
......@@ -84,14 +83,15 @@ public class KafkaService {
}
String msg = statusBean.getMsg();
String errorCode = statusBean.getErrorCode();
String[] msgStr = msg.split("\r\n", -1);
String[] errorCodeStr = errorCode.split("\r\n", -1);
for (int i = 0; i < errorCodeStr.length; i++) {
Map<String, String> map = new HashMap<>();
map.put("errorCode", errorCodeStr[i]);
map.put("msg", msgStr[i]);
msgList.add(map);
if (StringUtils.isNotBlank(msg) && StringUtils.isNotBlank(errorCode)) {
String[] msgStr = msg.split("\r\n");
String[] errorCodeStr = errorCode.split("\r\n");
for (int i = 0; i < errorCodeStr.length; i++) {
Map<String, String> map = new HashMap<>();
map.put("errorCode", errorCodeStr[i]);
map.put("msg", msgStr[i]);
msgList.add(map);
}
}
}
}
......@@ -132,8 +132,13 @@ public class KafkaService {
log.info("返回结果为:" + JSON.toJSONString(future));
}
} else {
status.setErrorCode("");
status.setErrorMsg("");
if ("3".equals(currentStatus)){
status.setErrorCode("10100038");
status.setErrorMsg("设备未启动");
} else {
status.setErrorCode("");
status.setErrorMsg("");
}
String statusStr = JSON.toJSONString(status);
log.info("主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
......@@ -166,8 +171,7 @@ public class KafkaService {
if (statusBean.timeOut()) {
normal = false;
} else {
int status = statusBean.getStatus();
if (status == BOX_STATUS.EMERGENCY || status == BOX_STATUS.PROBLEM) {
if (!statusBean.isAvailable()) {
normal = false;
}
}
......@@ -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发送
*/
@Scheduled(fixedRate = 1000 * 60 * 5)
......@@ -287,11 +329,9 @@ public class KafkaService {
public int getTodayInOutCount(List<String> storageIdList, int type) {
String todayStr = DateUtil.today();
DateTime today = DateUtil.parse(todayStr, "yyyy-MM-dd");
Query q = new Query();
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("storageId").in(storageIdList);
c.and("type").is(type);
......@@ -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() {
//找出所有的machineId
List<String> machineIdList = new ArrayList<>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!