Commit 98b64b8d zshaohui

1.未完成的需求单 不关闭

2.抛送agv信息到中控
1 个父辈 bbc5d2e7
......@@ -103,14 +103,14 @@ public class LiteOrderCache {
List<LiteOrder> unEndOutInfoList = liteOrderManager.findUnEndOrdersList();
long now = System.currentTimeMillis();
for (LiteOrder order : unEndOutInfoList) {
if (now - order.getCreateDate().getTime() > 30 * 24 * 60 * 60 * 1000) {
/* if (now - order.getCreateDate().getTime() > 30 * 24 * 60 * 60 * 1000) {
//7天前的需求单,关闭,并解绑
log.info("需求单 =[" + order.getOrderNo() + "]为30天前,关闭并解绑工单");
closeOrder(order.getOrderNo());
} else {
} else {*/
addOrderToMap(order);
}
//}
}
}
public void addOrderToMap(LiteOrder order ){
......
......@@ -111,6 +111,11 @@ public class OdnCheckOutNewController {
List<String> excludePosIdList = new ArrayList<>();
for (LiteOrderItem orderItem : liteOrder.getOrderItems()) {
String status = orderItem.getStatus();
if (!"New".equals(status)){
return ResultBean.newErrorResult(-1,"",odn+"的状态为:"+status+",不是New,不允许出库");
}
int targetNum = orderItem.getNeedNum() - orderItem.getTotalOutNum();
if (targetNum <= 0) {
continue;
......
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class LastStatusInfo {
private String machineId;
private String errorCode;
private String errorText;
private long lastSaveTime = 0l;
}
......@@ -6,17 +6,23 @@ public class KafkaConfig {
*/
public static final String MACHINESTATUS_TOPIC = "MachineStatus";
public static final String Agv_MachineStatus = "Agv-MachineStatus";
/**
* 心跳主题
*/
public static final String HEARTBEAT_TOPIC = "Heartbeat";
public static final String Agv_Heartbeat = "Agv-Heartbeat";
/**
* MachineParameter
*/
public static final String MACHINEPARAMETER_TOPIC = "MachineParameter";
public static final String Agv_MachineParameter = "Agv-MachineParameter";
public static final String SMARTWH_TOPIC = "SmartWH";
......
......@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.service;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP;
......@@ -16,10 +17,7 @@ import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.util.EquipStatusUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.Heartbeat;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.MachineParameter;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.MachineParameterData;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.MachineStatus;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.*;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.config.KafkaConfig;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.config.StorageNameConfig;
import lombok.extern.slf4j.Slf4j;
......@@ -32,6 +30,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import java.util.*;
import java.util.stream.Collectors;
//@Async
@Service
......@@ -50,6 +49,8 @@ public class KafkaService {
@Autowired
private IStoragePosManager storagePosManager;
Map<String, List<LastStatusInfo>> lastStatusInfoMap = Maps.newConcurrentMap();
@Scheduled(fixedRate = 1000 * 60 * 5)
public void setTowerDataMachineParamter() {
......@@ -175,7 +176,7 @@ public class KafkaService {
/**
* 抛送小车心跳
*/
//@Scheduled(fixedRate = 1000 * 5)
@Scheduled(fixedRate = 1000 * 5)
public void sendAgvHeart() {
List<String> agvMachineIdList = StorageNameConfig.getAgvMachineIdList();
for (String agvMachineId : agvMachineIdList) {
......@@ -188,10 +189,10 @@ public class KafkaService {
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
heartbeat.setOccurrenceTime(dateStr);
heartbeat.setMachineID(agvMachineId);
heartbeat.setTopicType(KafkaConfig.HEARTBEAT_TOPIC);
heartbeat.setTopicType(KafkaConfig.Agv_Heartbeat);
String statusStr = JSON.toJSONString(heartbeat);
log.info("半成品仓抛送AGV小车心跳信息:" + KafkaConfig.HEARTBEAT_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.HEARTBEAT_TOPIC, statusStr);
log.info("半成品仓抛送AGV小车心跳信息:" + KafkaConfig.Agv_Heartbeat + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.Agv_Heartbeat, statusStr);
//log.info("半成品仓抛送AGV小车信息结束为:" + JSON.toJSONString(future));
}
}
......@@ -202,7 +203,7 @@ public class KafkaService {
/**
* 抛送小车状态
*/
//@Scheduled(fixedRate = 1000 * 10)
@Scheduled(fixedRate = 1000 * 10)
public void sendAgvStatus(){
List<String> agvMachineIdList = StorageNameConfig.getAgvMachineIdList();
for (String agvMachineId : agvMachineIdList) {
......@@ -234,37 +235,40 @@ public class KafkaService {
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
machineStatus.setOccurrenceTime(dateStr);
machineStatus.setMachineID(agvMachineId);
machineStatus.setTopicType(KafkaConfig.MACHINESTATUS_TOPIC);
machineStatus.setCurrentStatus(currentStatus);
machineStatus.setTopicType(KafkaConfig.Agv_MachineStatus);
machineStatus.setCurrentStatus("3");
machineStatus.setErrorCode(equipMsg.getErrorCode());
machineStatus.setErrorMsg(equipMsg.getMsg());
machineStatus.setClientIP("");
String statusStr = JSON.toJSONString(machineStatus);
log.info(agvMachineId+"抛送Agv状态主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
log.info(agvMachineId+"抛送Agv状态返回结果为:" + JSON.toJSONString(future));
boolean hasSameStatus = hasSameStatus(machineStatus.getMachineID(), machineStatus.getErrorCode(), machineStatus.getErrorMsg());
if (!hasSameStatus) {
String statusStr = JSON.toJSONString(machineStatus);
log.info(agvMachineId + "抛送Agv状态主题为:" + KafkaConfig.Agv_MachineStatus + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.Agv_MachineStatus, statusStr);
log.info(agvMachineId + "抛送Agv状态返回结果为:" + JSON.toJSONString(future));
updateLastStatus(machineStatus.getMachineID(), machineStatus.getErrorCode(), machineStatus.getErrorMsg());
}
}
} else {
MachineStatus machineStatus = new MachineStatus();
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
machineStatus.setOccurrenceTime(dateStr);
machineStatus.setMachineID(agvMachineId);
machineStatus.setTopicType(KafkaConfig.MACHINESTATUS_TOPIC);
machineStatus.setTopicType(KafkaConfig.Agv_MachineStatus);
machineStatus.setCurrentStatus(currentStatus);
machineStatus.setErrorCode("");
machineStatus.setErrorMsg("");
machineStatus.setClientIP("");
String statusStr = JSON.toJSONString(machineStatus);
log.info(agvMachineId+"抛送设备状态主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
log.info(agvMachineId+"抛送设备状态主题为:" + KafkaConfig.Agv_MachineStatus + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.Agv_MachineStatus, statusStr);
log.info(agvMachineId+"抛送设备状态返回结果为:" + JSON.toJSONString(future));
}
}
}
//@Scheduled(fixedRate = 1000 * 10)
public void sendAgvMachineStatus() {
@Scheduled(fixedRate = 1000 * 10)
public void sendAgvMachineParameter() {
List<String> agvMachineIdList = StorageNameConfig.getAgvMachineIdList();
for (String agvMachineId : agvMachineIdList) {
EquipStatusBean statusBean = EquipStatusUtil.getStatusBean(agvMachineId);
......@@ -289,8 +293,8 @@ public class KafkaService {
dataList.add(new MachineParameterData("loc", loc));
machineParameter.setData(dataList);
String machineParameterStr = JSON.toJSONString(machineParameter);
log.info("推送小车电量和位置信息,MachineParameter主题为:" + KafkaConfig.MACHINEPARAMETER_TOPIC + "内容为:" + machineParameterStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINEPARAMETER_TOPIC, machineParameterStr);
log.info("推送小车电量和位置信息,MachineParameter主题为:" + KafkaConfig.Agv_MachineParameter + "内容为:" + machineParameterStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.Agv_MachineParameter, machineParameterStr);
log.info("推送小车电量和位置信息,MachineParameter返回结果为:" + JSON.toJSONString(future));
}
}
......@@ -318,4 +322,50 @@ public class KafkaService {
log.info("获取到开始时间为:" + startDate);
return startDate;
}
private void updateLastStatus(String machineId, String errorCode, String errorText) {
List<LastStatusInfo> lastStatusInfoList = lastStatusInfoMap.get(machineId);
if (lastStatusInfoList == null) {
lastStatusInfoList = new ArrayList<>();
}
boolean hasSameStatus = false;
for (LastStatusInfo lastStatusInfo : lastStatusInfoList) {
if (errorText.equals(lastStatusInfo.getErrorText())) {
//超过1个小时,重新统计
if (System.currentTimeMillis() - lastStatusInfo.getLastSaveTime() < 1000 * 60 * 10) {
hasSameStatus = true;
break;
}
}
}
if (!hasSameStatus) {
LastStatusInfo lastStatusInfo = new LastStatusInfo(machineId, errorCode, errorText, System.currentTimeMillis());
lastStatusInfoList.add(lastStatusInfo);
}
//清理超过半个小时的
lastStatusInfoList = lastStatusInfoList.stream()
.filter(lastStatusInfo -> System.currentTimeMillis()- lastStatusInfo.getLastSaveTime() < 1000 * 60 * 10)
.collect(Collectors.toList());
lastStatusInfoMap.put(machineId,lastStatusInfoList);
}
private boolean hasSameStatus(String machineId, String errorCode, String errorText) {
boolean hasSameStatus = false;
List<LastStatusInfo> lastStatusInfoList = lastStatusInfoMap.get(machineId);
if (lastStatusInfoList == null) {
lastStatusInfoList = new ArrayList<>();
}
for (LastStatusInfo lastStatusInfo : lastStatusInfoList) {
if (errorText.equals(lastStatusInfo.getErrorText())) {
//超过1个小时,重新统计
if (System.currentTimeMillis() - lastStatusInfo.getLastSaveTime() < 1000 * 60 * 10) {
log.info(machineId+"的报错信息和上一次相同,跳过");
hasSameStatus = true;
break;
}
}
}
return hasSameStatus;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!