Commit 595b0e44 zshaohui

1.增加中控,抛送小车信息

1 个父辈 0b3f6abe
...@@ -37,6 +37,7 @@ import com.neotel.smfcore.core.system.util.TaskService; ...@@ -37,6 +37,7 @@ import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType; import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi; import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.factory_c.common.util.DisableBarcodeUtil; import com.neotel.smfcore.custom.luxsan.factory_c.common.util.DisableBarcodeUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.service.KafkaService;
import com.neotel.smfcore.custom.siemens.SiemensApi; import com.neotel.smfcore.custom.siemens.SiemensApi;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -88,6 +89,9 @@ public class StoragePosController { ...@@ -88,6 +89,9 @@ public class StoragePosController {
@Autowired @Autowired
private IBarcodeManager barcodeManager; private IBarcodeManager barcodeManager;
@Autowired
private KafkaService kafkaService;
@ApiOperation("查询库位") @ApiOperation("查询库位")
@GetMapping @GetMapping
...@@ -265,6 +269,12 @@ public class StoragePosController { ...@@ -265,6 +269,12 @@ public class StoragePosController {
log.info("启用禁用库位:库位号[" + pos.getId() + "][" + pos.getPosName() + "]=" + enabledDto.isEnabled()); log.info("启用禁用库位:库位号[" + pos.getId() + "][" + pos.getPosName() + "]=" + enabledDto.isEnabled());
DeviceMessageUtil.addEnabledPosMessage(pos,SecurityUtils.getCurrentUsername()); DeviceMessageUtil.addEnabledPosMessage(pos,SecurityUtils.getCurrentUsername());
if (!pos.isEnabled()){
kafkaService.sendPosChange(pos.getPosName(),"2");
} else {
kafkaService.sendPosChange(pos.getPosName(),"3");
}
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
......
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.config; package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.config;
import java.util.ArrayList;
import java.util.List;
public class StorageNameConfig { public class StorageNameConfig {
//原材料仓货架 //半成品仓货架
public static final String semiFinishedTower = "semi-finished-tower"; public static final String semiFinishedTower = "semi-finished-tower";
static List<String> agvMachineIdList = new ArrayList<>();
public static List<String> getAgvMachineIdList(){
if (agvMachineIdList != null && !agvMachineIdList.isEmpty()){
return agvMachineIdList;
}
agvMachineIdList.add(semiFinishedCtu5040);
agvMachineIdList.add(semiFinishedCtu5041);
agvMachineIdList.add(semiFinishedCtu5070);
return agvMachineIdList;
}
public static final String semiFinishedCtu5040 = "semi-finished-ctu-5040";//半成品第1台CTU
public static final String semiFinishedCtu5041 = "semi-finished-ctu-5040";//半成品第1台CTU
public static final String semiFinishedCtu5070 = "semi-finished-ctu-5040";//半成品第1台CTU
} }
...@@ -7,7 +7,10 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode; ...@@ -7,7 +7,10 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode;
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.device.util.EquipmentCache;
import com.neotel.smfcore.core.equipment.bean.EquipMsg;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean; import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; 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.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
...@@ -16,6 +19,7 @@ import com.neotel.smfcore.core.system.util.EquipStatusUtil; ...@@ -16,6 +19,7 @@ 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.Heartbeat;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.MachineParameter; 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.MachineParameterData;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.MachineStatus;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.config.KafkaConfig; 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 com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.config.StorageNameConfig;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -106,7 +110,7 @@ public class KafkaService { ...@@ -106,7 +110,7 @@ public class KafkaService {
} }
} }
Query query = new Query(Criteria.where("storageId").in(storageIdList)); Query query = new Query(Criteria.where("storageId").in(storageIdList));
query.fields().include("barcode","posName"); query.fields().include("barcode","posName","enabled");
List<Map<String,String>> dataList = new ArrayList<>(); List<Map<String,String>> dataList = new ArrayList<>();
...@@ -122,6 +126,18 @@ public class KafkaService { ...@@ -122,6 +126,18 @@ public class KafkaService {
dataList.add(dataMap); dataList.add(dataMap);
} }
for (StoragePos pos : storagePosList) {
Map<String,String> dataMap = new HashMap<>();
dataMap.put("Storage",pos.getPosName());
dataMap.put("Status",3+"");
if (!pos.isEnabled()){
dataMap.put("Status",2+"");
}
dataList.add(dataMap);
}
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
paramMap.put("MachineID",StorageNameConfig.semiFinishedTower); paramMap.put("MachineID",StorageNameConfig.semiFinishedTower);
paramMap.put("data",dataList); paramMap.put("data",dataList);
...@@ -132,7 +148,7 @@ public class KafkaService { ...@@ -132,7 +148,7 @@ public class KafkaService {
} }
//status为1时入库 status为0 为出库 //status为1时入库 status为0 为出库 2; 禁用 3: 启用
public void sendPosChange(String posName,String status){ public void sendPosChange(String posName,String status){
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
paramMap.put("MachineID",StorageNameConfig.semiFinishedTower); paramMap.put("MachineID",StorageNameConfig.semiFinishedTower);
...@@ -141,6 +157,9 @@ public class KafkaService { ...@@ -141,6 +157,9 @@ public class KafkaService {
Map<String,String> dataMap = new HashMap<>(); Map<String,String> dataMap = new HashMap<>();
dataMap.put("Storage",posName); dataMap.put("Storage",posName);
dataMap.put("Status",status); dataMap.put("Status",status);
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
dataMap.put("OccurrenceTime",dateStr);
dataList.add(dataMap); dataList.add(dataMap);
paramMap.put("data",dataList); paramMap.put("data",dataList);
...@@ -151,21 +170,130 @@ public class KafkaService { ...@@ -151,21 +170,130 @@ public class KafkaService {
log.info("半成品仓抛送货架变动结果为:" + JSON.toJSONString(future)); log.info("半成品仓抛送货架变动结果为:" + JSON.toJSONString(future));
} }
/**
* 抛送小车心跳
*/
//@Scheduled(fixedRate = 1000 * 10) @Scheduled(fixedRate = 1000 * 5)
public void sendHeartbeat() { public void sendAgvHeart() {
List<String> agvMachineIdList = StorageNameConfig.getAgvMachineIdList();
for (String agvMachineId : agvMachineIdList) {
EquipStatusBean statusBean = EquipStatusUtil.getStatusBean(agvMachineId);
if (statusBean != null) {
if (!statusBean.timeOut()) {
int status = statusBean.getStatus();
if (status != 0) {
Heartbeat heartbeat = new Heartbeat(); Heartbeat heartbeat = new Heartbeat();
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"); String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
heartbeat.setOccurrenceTime(dateStr); heartbeat.setOccurrenceTime(dateStr);
heartbeat.setMachineID(StorageNameConfig.semiFinishedTower); heartbeat.setMachineID(agvMachineId);
heartbeat.setTopicType(KafkaConfig.HEARTBEAT_TOPIC); heartbeat.setTopicType(KafkaConfig.HEARTBEAT_TOPIC);
String statusStr = JSON.toJSONString(heartbeat); String statusStr = JSON.toJSONString(heartbeat);
log.info("出料口主题为:" + KafkaConfig.HEARTBEAT_TOPIC + "内容为:" + statusStr); log.info("半成品仓抛送AGV小车心跳信息:" + KafkaConfig.HEARTBEAT_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.HEARTBEAT_TOPIC, statusStr); ListenableFuture future = kafkaTemplate.send(KafkaConfig.HEARTBEAT_TOPIC, statusStr);
log.info("出料口返回结果为:" + JSON.toJSONString(future)); //log.info("半成品仓抛送AGV小车信息结束为:" + JSON.toJSONString(future));
}
}
}
}
}
/**
* 抛送小车状态
*/
@Scheduled(fixedRate = 1000 * 10)
public void sendAgvStatus(){
List<String> agvMachineIdList = StorageNameConfig.getAgvMachineIdList();
for (String agvMachineId : agvMachineIdList) {
List<EquipMsg> equipMsgList = new ArrayList<>();
String currentStatus = "1"; //正常
EquipStatusBean statusBean = EquipStatusUtil.getStatusBean(agvMachineId);
if (statusBean == null){
currentStatus = "5";
} else {
if (statusBean.timeOut()){
currentStatus = "5";
} else {
int status = statusBean.getStatus();
if (4 == status || 2 == status){
currentStatus = "3";
}
if (13 == status || 1 == status){
currentStatus = "1";
}
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(agvMachineId);
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(agvMachineId+"抛送Agv状态主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
log.info(agvMachineId+"抛送Agv状态返回结果为:" + 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(agvMachineId);
machineStatus.setTopicType(KafkaConfig.MACHINESTATUS_TOPIC);
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+"抛送设备状态返回结果为:" + JSON.toJSONString(future));
}
}
}
@Scheduled(fixedRate = 1000 * 10)
public void sendAgvMachineStatus() {
List<String> agvMachineIdList = StorageNameConfig.getAgvMachineIdList();
for (String agvMachineId : agvMachineIdList) {
EquipStatusBean statusBean = EquipStatusUtil.getStatusBean(agvMachineId);
if (statusBean != null) {
String elec = statusBean.getFromData("elec");
String loc = statusBean.getFromData("loc");
MachineParameter machineParameter = new MachineParameter();
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
machineParameter.setOccurrenceTime(dateStr);
machineParameter.setMachineID(agvMachineId);
machineParameter.setContentType("F");
machineParameter.setMachineType("原材货架");
machineParameter.setSupplierID("NEOTEL");
machineParameter.setProgramName("");
machineParameter.setProgramVersion("");
machineParameter.setSerialNumber("");
machineParameter.setResult("");
machineParameter.setEmpNo("");
machineParameter.setClientIP("");
List<MachineParameterData> dataList = new ArrayList<>();
dataList.add(new MachineParameterData("elec", elec));
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返回结果为:" + JSON.toJSONString(future));
}
}
}
public int getTodayInOutCount(List<String> storageIdList, int type) { public int getTodayInOutCount(List<String> storageIdList, int type) {
Query q = new Query(); Query q = new Query();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!