Commit c4820231 zshaohui

1.kafka 心跳功能提交

2.迈征站位状态
1 个父辈 bcf8a25e
正在显示 30 个修改的文件 包含 592 行增加58 行删除
...@@ -241,6 +241,11 @@ ...@@ -241,6 +241,11 @@
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>3.1.1</version> <version>3.1.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
</dependencies> </dependencies>
......
...@@ -9,9 +9,14 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor ...@@ -9,9 +9,14 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
//@EnableAsync
//@EnableScheduling
@EnableKafka
@RestController @RestController
@SpringBootApplication @SpringBootApplication
public class SmfCoreApplication extends SpringBootServletInitializer { public class SmfCoreApplication extends SpringBootServletInitializer {
......
...@@ -78,7 +78,8 @@ public class MainTimer { ...@@ -78,7 +78,8 @@ public class MainTimer {
lastPreGenerateTaskTime = System.currentTimeMillis(); lastPreGenerateTaskTime = System.currentTimeMillis();
try { try {
log.info("生成缺料预警任务"); log.info("生成缺料预警任务");
PreWarningItemCache.runTimer(0); //PreWarningItemCache.runTimer(0);
PreWarningItemCache.runTimer(1);
//liteOrderCache.runTimer(0); //liteOrderCache.runTimer(0);
//设备状态判断 //设备状态判断
DevicesStatusUtil.runTimer(); DevicesStatusUtil.runTimer();
...@@ -95,7 +96,7 @@ public class MainTimer { ...@@ -95,7 +96,7 @@ public class MainTimer {
private void timerTaskLz() { private void timerTaskLz() {
try { try {
//log.info("人工叫料,每5s执行一次"); //log.info("人工叫料,每5s执行一次");
PreWarningItemCache.runTimer(1); //PreWarningItemCache.runTimer(1);
liteOrderCache.runTimer(1); liteOrderCache.runTimer(1);
liteOrderCache.runTimer(0); liteOrderCache.runTimer(0);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -2,18 +2,15 @@ package com.neotel.smfcore.core.barcode.bean; ...@@ -2,18 +2,15 @@ package com.neotel.smfcore.core.barcode.bean;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel; import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.util.ExpireDateUtil; import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/** /**
* *
......
...@@ -6,6 +6,7 @@ import com.neotel.smfcore.common.exception.ValidateException; ...@@ -6,6 +6,7 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.FileUtil; import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp; import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.dao.IBarcodeDao; import com.neotel.smfcore.core.barcode.service.dao.IBarcodeDao;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager; import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
...@@ -18,7 +19,6 @@ import org.springframework.data.mongodb.core.query.Criteria; ...@@ -18,7 +19,6 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
...@@ -108,16 +108,28 @@ public class BarcodeManagerImpl implements IBarcodeManager { ...@@ -108,16 +108,28 @@ public class BarcodeManagerImpl implements IBarcodeManager {
validateSave(resources); validateSave(resources);
Criteria c= Criteria.where("barcode").is(resources.getBarcode()); Criteria c= Criteria.where("barcode").is(resources.getBarcode());
String logName="新增条码:"; /*String logName="新增条码:";
if(resources.getId()!=null){ if(resources.getId()!=null){
logName="修改条码:"; logName="修改条码:";
c.and("id").ne(resources.getId()); c.and("id").ne(resources.getId());
} }*/
Query query=new Query(c); Query query=new Query(c);
//readID不能重复 //readID不能重复
Barcode data= barcodeDao.findOne(query);
if(data!=null){ List<Barcode> barcodeList = barcodeDao.findByQuery(query);
throw new ValidateException("smfcore.codeExist", "条码["+resources.getBarcode()+"]已存在"); String id = resources.getId();
if (StringUtils.isNotBlank(id)){
if (barcodeList != null && !barcodeList.isEmpty()){
for (Barcode barcode : barcodeList) {
if (!barcode.getId().equals(id)){
throw new ValidateException("smfcore.codeExist", "条码["+resources.getBarcode()+"]已存在");
}
}
}
} else {
if (barcodeList != null && !barcodeList.isEmpty()){
throw new ValidateException("smfcore.codeExist", "条码["+resources.getBarcode()+"]已存在");
}
} }
if(resources.getProvider()==null){ if(resources.getProvider()==null){
......
...@@ -161,6 +161,12 @@ public class ComponentManagerImpl implements IComponentManager { ...@@ -161,6 +161,12 @@ public class ComponentManagerImpl implements IComponentManager {
} }
//判断partNum是否重复 //判断partNum是否重复
Criteria c = Criteria.where("partNumber").is(resources.getPartNumber()); Criteria c = Criteria.where("partNumber").is(resources.getPartNumber());
String provider = resources.getProvider();
if (StringUtils.isNotBlank(provider)){
c.and("provider").is(provider);
}
String logName = "新增元器件"; String logName = "新增元器件";
if (resources.getId() != null) { if (resources.getId() != null) {
logName = "修改元器件"; logName = "修改元器件";
......
...@@ -430,12 +430,12 @@ public class LiteOrderCache { ...@@ -430,12 +430,12 @@ public class LiteOrderCache {
} }
List<DataLog> allTasksByCid = taskService.getAllTasksByCid(storage.getCid()); List<DataLog> allTasksByCid = taskService.getAllTasksByCid(storage.getCid());
for (DataLog task : allTasksByCid) { for (DataLog task : allTasksByCid) {
/*if (!task.isFinished() if (!task.isFinished()
&& !task.isCancel() && !task.isCancel()
&& !task.isToBox() && !task.isToBox()
&& task.isCheckOutTask() && task.isCheckOutTask()
&& StringUtils.isNotBlank(task.getSourceId()) && StringUtils.isNotBlank(task.getSourceId())
&& !task.isLabeled())*/ )
if (task.isCheckOutTask() && StringUtils.isNotBlank(task.getSourceId()) && (task.isExecuting() || task.isWait())){ if (task.isCheckOutTask() && StringUtils.isNotBlank(task.getSourceId()) && (task.isExecuting() || task.isWait())){
hasOutTask = true; hasOutTask = true;
break; break;
...@@ -496,7 +496,7 @@ public class LiteOrderCache { ...@@ -496,7 +496,7 @@ public class LiteOrderCache {
} }
//获取是否有出料口 //获取是否有出料口
String exportStr = StorageExportUtil.getExportByOrderNo(cacheOrder.getOrderNo(),true); String exportStr = StorageExportUtil.getExportByOrderNo(cacheOrder.getOrderNo(),true,cacheOrder.isMaiZheng());
if (StringUtils.isBlank(exportStr)) { if (StringUtils.isBlank(exportStr)) {
log.info(cacheOrder.getOrderNo() + "没有空闲的出料口"); log.info(cacheOrder.getOrderNo() + "没有空闲的出料口");
return "没有空闲的出料口"; return "没有空闲的出料口";
......
...@@ -156,6 +156,13 @@ public class LiteOrder extends BasePo implements Serializable { ...@@ -156,6 +156,13 @@ public class LiteOrder extends BasePo implements Serializable {
*/ */
private String export = ""; private String export = "";
/**
* 是否迈征
*/
private boolean maiZheng = false;
public void setClosed(boolean value){ public void setClosed(boolean value){
this.closed=value; this.closed=value;
if(value){ if(value){
......
...@@ -361,6 +361,61 @@ public class StoragePosController { ...@@ -361,6 +361,61 @@ public class StoragePosController {
} }
} }
@ApiOperation("库位使用情况")
@RequestMapping("/posUsageSituation")
@AnonymousAccess
public ResultBean posUsageSituation(@RequestParam("cid") String cid) {
Map<String, List<String>> resultMap = new HashMap<>();
Storage storage = dataCache.getStorage(cid);
List<StoragePos> storagePosList = storagePosManager.findByStorage(storage.getId());
if (storagePosList != null && !storagePosList.isEmpty()) {
List<String> disablePosList = new ArrayList<>();
List<String> hasReelPosList = new ArrayList<>();
List<String> noReelPosList = new ArrayList<>();
for (StoragePos storagePos : storagePosList) {
boolean enabled = storagePos.isEnabled();
Barcode barcode = storagePos.getBarcode();
if (!enabled){
disablePosList.add(storagePos.getPosName());
}
if(barcode != null){
hasReelPosList.add(storagePos.getPosName());
} else {
noReelPosList.add(storagePos.getPosName());
}
}
resultMap.put("disable",disablePosList);
resultMap.put("hasReel",hasReelPosList);
resultMap.put("noReel",noReelPosList);
}
return ResultBean.newOkResult(resultMap);
}
@ApiOperation("客户端启用禁用库位")
@RequestMapping("/enabled")
@AnonymousAccess
public ResultBean enabled(@RequestParam("cid") String cid, @RequestParam("posName") String posName) {
StoragePos storagePos = storagePosManager.getByPosName(posName);
if (storagePos != null && !storagePos.isEnabled()){
Barcode barcode = storagePos.getBarcode();
if (barcode != null){
taskService.addTaskToFinished(storagePos,barcode,"admin-enable");
}
storagePos.setEnabled(true);
storagePosManager.save(storagePos);
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
dataCache.reloadStorage(storage,storage.getCid());
}
return ResultBean.newOkResult("");
}
private Query getPosFindCriteria(StoragePosFindCriteria criteria){ private Query getPosFindCriteria(StoragePosFindCriteria criteria){
if (ObjectUtil.isNotEmpty(criteria.getStorageId()) && criteria.getStorageId().equals("0")) { if (ObjectUtil.isNotEmpty(criteria.getStorageId()) && criteria.getStorageId().equals("0")) {
criteria.setStorageId(null); criteria.setStorageId(null);
......
...@@ -68,4 +68,7 @@ public class StorageDto implements Serializable { ...@@ -68,4 +68,7 @@ public class StorageDto implements Serializable {
@ApiModelProperty("是否可以合并库位") @ApiModelProperty("是否可以合并库位")
private boolean mergePos=false; private boolean mergePos=false;
@ApiModelProperty("machineId")
private String machineId = "";
} }
...@@ -71,6 +71,10 @@ public class Storage extends BasePo implements Serializable { ...@@ -71,6 +71,10 @@ public class Storage extends BasePo implements Serializable {
*/ */
private boolean mergePos=false; private boolean mergePos=false;
/**
* machineId
*/
private String machineId = "";
// /** // /**
// * 是否是上下层的在线料仓 // * 是否是上下层的在线料仓
......
...@@ -517,7 +517,7 @@ public class LizhenApi extends DefaultSmfApiListener { ...@@ -517,7 +517,7 @@ public class LizhenApi extends DefaultSmfApiListener {
} }
} }
if (items != null && !items.isEmpty()) { if (items != null && !items.isEmpty()) {
return PreWarningItemCache.createAndExecuteLiteOrder(items,2); return PreWarningItemCache.createAndExecuteLiteOrder(items,2,false);
} }
} }
return null; return null;
......
...@@ -14,7 +14,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos; ...@@ -14,7 +14,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager; import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.util.ExpireDateUtil; import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import java.util.*; import java.util.*;
@RestController @RestController
......
...@@ -453,7 +453,7 @@ public class InnerBoxRestController { ...@@ -453,7 +453,7 @@ public class InnerBoxRestController {
log.info(dataLog.getBarcode() + "获取出料口信息为:" + dataLog.getExport()); log.info(dataLog.getBarcode() + "获取出料口信息为:" + dataLog.getExport());
resultMap.put("export", dataLog.getExport()); resultMap.put("export", dataLog.getExport());
} else { } else {
String export = StorageExportUtil.getExportByOrderNo("",false); String export = StorageExportUtil.getExportByOrderNo("",false,false);
log.info(dataLog.getBarcode() + "手动出库获取出料口信息为:" + export); log.info(dataLog.getBarcode() + "手动出库获取出料口信息为:" + export);
resultMap.put("export", export); resultMap.put("export", export);
} }
......
...@@ -3,9 +3,7 @@ package com.neotel.smfcore.custom.lizhen.innerBox.rest; ...@@ -3,9 +3,7 @@ package com.neotel.smfcore.custom.lizhen.innerBox.rest;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.*; import com.neotel.smfcore.common.utils.*;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.bean.CodeBean; import com.neotel.smfcore.core.barcode.bean.CodeBean;
...@@ -29,12 +27,11 @@ import com.neotel.smfcore.custom.lizhen.LizhenApi; ...@@ -29,12 +27,11 @@ import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.VirImportLog; import com.neotel.smfcore.custom.lizhen.innerBox.bean.VirImportLog;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType; import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IVirImportLogManager; import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IVirImportLogManager;
import com.neotel.smfcore.custom.lizhen.util.ExpireDateUtil; import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -44,7 +41,6 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -44,7 +41,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* 虚拟仓页面 * 虚拟仓页面
......
...@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.lizhen.innerBox.util; ...@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.lizhen.innerBox.util;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager; import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
...@@ -11,6 +12,8 @@ import com.neotel.smfcore.core.order.service.po.LiteOrderItem; ...@@ -11,6 +12,8 @@ import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem; import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem;
import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IPreWarningItemManager; import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IPreWarningItemManager;
import com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemCacheManager; import com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemCacheManager;
import com.neotel.smfcore.custom.lizhen.third.maicheng.bean.StationStatus;
import com.neotel.smfcore.custom.lizhen.third.maicheng.util.StationStatusCache;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -50,6 +53,8 @@ public class PreWarningItemCache { ...@@ -50,6 +53,8 @@ public class PreWarningItemCache {
private static IPreWarningItemManager preWarningItemManager; private static IPreWarningItemManager preWarningItemManager;
private static StationStatusCache stationStatusCache;
/** /**
* 添加到预警列表缓存中 * 添加到预警列表缓存中
*/ */
...@@ -75,6 +80,57 @@ public class PreWarningItemCache { ...@@ -75,6 +80,57 @@ public class PreWarningItemCache {
return; return;
} }
//优先生成迈征的信息
List<StationStatus> stationStatusList = stationStatusCache.getAllStationStatus();
if (stationStatusList != null && !stationStatusList.isEmpty()) {
for (StationStatus stationStatus : stationStatusList) {
List<PreWarningItem> lineItems = new ArrayList<>();
if (queueItemList != null && !queueItemList.isEmpty()) {
String line = stationStatus.getLINE(); //产线
String trackNumber = stationStatus.getTrackNumber(); //轨道号
String side = stationStatus.getSIDE(); //面别
log.info("开始生成迈征的工单信息,line为:"+line+",side为:"+side+",trackNumber为:"+trackNumber);
for (PreWarningItem item : queueItemList) {
//判断产线,面别,
if (StringUtils.isNotBlank(line)
&& StringUtils.isNotBlank(side)
&& StringUtils.isNotBlank(trackNumber)
) {
if (line.equals(item.getLine()) && side.equals(item.getSide())
&& StringUtils.isNotBlank(item.getStation()) && item.getStation().endsWith(trackNumber)) {
//再判断料号是否相同
for (StationStatus status : stationStatusList) {
String station = status.getSTATION();
String slot = status.getSLOT();
String partnumber = status.getPARTNUMBER();
if (StringUtils.isNotBlank(partnumber) && StringUtils.isNotBlank(slot) && StringUtils.isNotBlank(station)) {
if (station.equals(item.getStation())
&& slot.equals(item.getSlot())
&& partnumber.equals(item.getPartnumber())
&& line.equals(status.getLINE())
&& side.equals(status.getSIDE())
) {
log.info("开始添加迈征的工单明细,station为:"+station+",slot为:"+slot+",partnumber为:"+partnumber);
lineItems.add(item);
}
}
}
}
}
}
}
if (lineItems != null && !lineItems.isEmpty()) {
createAndExecuteLiteOrder(lineItems, priority, true);
}
}
}
Integer preGenerateTaskTimes = dataCache.getCache(Constants.CACHE_preGenerateTask_Times); Integer preGenerateTaskTimes = dataCache.getCache(Constants.CACHE_preGenerateTask_Times);
if (preGenerateTaskTimes == null || preGenerateTaskTimes == 0) { if (preGenerateTaskTimes == null || preGenerateTaskTimes == 0) {
preGenerateTaskTimes = 2; preGenerateTaskTimes = 2;
...@@ -84,23 +140,25 @@ public class PreWarningItemCache { ...@@ -84,23 +140,25 @@ public class PreWarningItemCache {
//最早的一条预警时间 //最早的一条预警时间
List<PreWarningItem> lineItems = new ArrayList<>(); List<PreWarningItem> lineItems = new ArrayList<>();
String firstItemLine = ""; String firstItemLine = "";
for (PreWarningItem preWarningItem : queueItemList) { if (queueItemList != null && !queueItemList.isEmpty()) {
String itemLine = preWarningItem.getLine(); for (PreWarningItem preWarningItem : queueItemList) {
if (Strings.isNotBlank(itemLine)) { String itemLine = preWarningItem.getLine();
if (firstItemLine.isEmpty()) { if (Strings.isNotBlank(itemLine)) {
firstItemLine = itemLine; if (firstItemLine.isEmpty()) {
if (System.currentTimeMillis() - preWarningItem.getReceiveDate().getTime() < 1 * 60 * 1000) { firstItemLine = itemLine;
return; if (System.currentTimeMillis() - preWarningItem.getReceiveDate().getTime() < 1 * 60 * 1000) {
return;
}
}
//同一个线别的生成一个工单
if (itemLine.equals(firstItemLine)) {
lineItems.add(preWarningItem);
} }
}
//同一个线别的生成一个工单
if (itemLine.equals(firstItemLine)) {
lineItems.add(preWarningItem);
} }
} }
} }
if (!lineItems.isEmpty()) { if (!lineItems.isEmpty()) {
createAndExecuteLiteOrder(lineItems, priority); createAndExecuteLiteOrder(lineItems, priority,false);
} }
} }
} }
...@@ -113,17 +171,17 @@ public class PreWarningItemCache { ...@@ -113,17 +171,17 @@ public class PreWarningItemCache {
* *
* @param lineItems * @param lineItems
*/ */
public static synchronized LiteOrder createAndExecuteLiteOrder(List<PreWarningItem> lineItems,int priority) { public static synchronized LiteOrder createAndExecuteLiteOrder(List<PreWarningItem> lineItems,int priority,boolean maiZheng) {
//1.得到优先级比较高的 //1.得到优先级比较高的
LiteOrder liteOrder = new LiteOrder(); LiteOrder liteOrder = new LiteOrder();
//List<PreWarningItem> itemsPri = new ArrayList<>(); //List<PreWarningItem> itemsPri = new ArrayList<>();
if (priority == 1){ /*if (priority == 1){
lineItems = lineItems.stream().filter(t -> 1 == t.getPriority()).collect(Collectors.toList()); lineItems = lineItems.stream().filter(t -> 1 == t.getPriority()).collect(Collectors.toList());
liteOrder.setPriority(1); liteOrder.setPriority(1);
} else if (priority == 2){ } else if (priority == 2){
lineItems = lineItems.stream().filter(t -> 1 != t.getPriority()).collect(Collectors.toList()); lineItems = lineItems.stream().filter(t -> 1 != t.getPriority()).collect(Collectors.toList());
liteOrder.setPriority(0); liteOrder.setPriority(0);
} }*/
//2 如果优先级不为空,则优先生成优先级高的工单 //2 如果优先级不为空,则优先生成优先级高的工单
List<LiteOrderItem> orderItems = new ArrayList<>(); List<LiteOrderItem> orderItems = new ArrayList<>();
if (lineItems != null && !lineItems.isEmpty()) { if (lineItems != null && !lineItems.isEmpty()) {
...@@ -152,6 +210,7 @@ public class PreWarningItemCache { ...@@ -152,6 +210,7 @@ public class PreWarningItemCache {
liteOrder.setOrderItems(orderItems); liteOrder.setOrderItems(orderItems);
liteOrder.setTotalTaskReelCount(orderItems.size()); liteOrder.setTotalTaskReelCount(orderItems.size());
liteOrder.setTaskReelCount(orderItems.size()); liteOrder.setTaskReelCount(orderItems.size());
liteOrder.setMaiZheng(maiZheng);
liteOrder = liteOrderManager.createWithItems(liteOrder); liteOrder = liteOrderManager.createWithItems(liteOrder);
log.info("生成工单信息为:"+liteOrder.getOrderNo()); log.info("生成工单信息为:"+liteOrder.getOrderNo());
liteOrderCache.addOrderToMap(liteOrder); liteOrderCache.addOrderToMap(liteOrder);
...@@ -178,11 +237,11 @@ public class PreWarningItemCache { ...@@ -178,11 +237,11 @@ public class PreWarningItemCache {
// 从newItems中移除数据库中已经存在相应工单的items // 从newItems中移除数据库中已经存在相应工单的items
if (!newItems.isEmpty()) { if (!newItems.isEmpty()) {
List<String> itemIds = newItems.stream().map(PreWarningItem::getItemId).collect(Collectors.toList()); List<String> itemIds = newItems.stream().map(PreWarningItem::getItemId).collect(Collectors.toList());
List<String> partNumbers = newItems.stream().map(PreWarningItem::getPartnumber).collect(Collectors.toList()); //List<String> partNumbers = newItems.stream().map(PreWarningItem::getPartnumber).collect(Collectors.toList());
Criteria c = new Criteria(); Criteria c = new Criteria();
c.and("pn").in(partNumbers); //c.and("pn").in(partNumbers);
c.and("warningItemId").in(itemIds); c.and("warningItemId").is(itemIds.get(0));
LiteOrderItem orderItem = liteOrderItemManager.findOne(new Query().addCriteria(c)); LiteOrderItem orderItem = liteOrderItemManager.findOne(new Query().addCriteria(c));
if (orderItem != null){ if (orderItem != null){
...@@ -255,6 +314,11 @@ public class PreWarningItemCache { ...@@ -255,6 +314,11 @@ public class PreWarningItemCache {
PreWarningItemCache.preWarningItemManager = preWarningItemManager; PreWarningItemCache.preWarningItemManager = preWarningItemManager;
} }
@Autowired
public void setStationStatusCache(StationStatusCache cache) {
PreWarningItemCache.stationStatusCache = cache;
}
private synchronized static String getSeq() { private synchronized static String getSeq() {
return "H" + preWarningItemCacheManager.getNextId(PreWarningItemCache.class.getName()); return "H" + preWarningItemCacheManager.getNextId(PreWarningItemCache.class.getName());
......
...@@ -49,6 +49,14 @@ public class StorageExportUtil { ...@@ -49,6 +49,14 @@ public class StorageExportUtil {
} }
} }
private static String maizhengExport = "";
@Value("${maizheng.export}")
void setMaizhengExport(String export){
if (StringUtils.isNotBlank(export)){
maizhengExport = export;
}
}
//出料口名称 //出料口名称
...@@ -80,10 +88,23 @@ public class StorageExportUtil { ...@@ -80,10 +88,23 @@ public class StorageExportUtil {
} }
//根据工单号,获取目的地信息 //根据工单号,获取目的地信息
public static synchronized String getExportByOrderNo(String orderNo,boolean hasSameOrder) { public static synchronized String getExportByOrderNo(String orderNo,boolean hasSameOrder,boolean maizheng) {
if (StringUtils.isBlank(orderNo)) { if (StringUtils.isBlank(orderNo)) {
return manualCheckoutExport; return manualCheckoutExport;
} }
//判断是否为迈征
if (maizheng){
log.info("迈征数据获取出料口信息工单号为:"+orderNo+"出料口信息为:"+maizhengExport);
if (StringUtils.isNotBlank(maizhengExport)){
StorageExport export = getExport(maizhengExport);
if (!export.isDisable() && StringUtils.isBlank(export.getHSerial())){
return maizhengExport;
}
}
return "";
}
String exportStr = ""; String exportStr = "";
//判断是否有相同工单 //判断是否有相同工单
for (Map.Entry<String, StorageExport> entry : exportMap.entrySet()) { for (Map.Entry<String, StorageExport> entry : exportMap.entrySet()) {
...@@ -117,6 +138,13 @@ public class StorageExportUtil { ...@@ -117,6 +138,13 @@ public class StorageExportUtil {
} }
} }
//迈征的排除
if (StringUtils.isNotBlank(maizhengExport)){
if (entry.getKey().startsWith(maizhengExport)){
continue;
}
}
if (entry.getKey().contains(StorageExportUtil.OUT_STATION)) { if (entry.getKey().contains(StorageExportUtil.OUT_STATION)) {
continue; continue;
} }
......
package com.neotel.smfcore.custom.lizhen.kafka.bean;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@ApiModel("心跳信息")
public class Heartbeat implements Serializable{
@JSONField(name = "OccurrenceTime")
@ApiModelProperty("发生时间")
//@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private String OccurrenceTime;
@JSONField(name = "MachineID")
@ApiModelProperty("机台唯一ID")
private String MachineID;
@JSONField(name = "TopicType")
@ApiModelProperty("消息类别")
private String TopicType;
}
package com.neotel.smfcore.custom.lizhen.kafka.bean;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class MachineStatus {
@ApiModelProperty("发生时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private Date OccurrenceTime;
@ApiModelProperty("消息类别")
private String TopicType;
@ApiModelProperty("机台唯一ID")
private String MachineID;
@ApiModelProperty("当前状态")
//1:运行;2:等待;3:故障;
//4:未生产;5:离线;…
private String CurrentStatus;
@ApiModelProperty("错误代码")
private String ErrorCode;
@ApiModelProperty("错误描述")
private String ErrorMsg;
@ApiModelProperty("客户端 IP")
private String ClientIP;
}
package com.neotel.smfcore.custom.lizhen.kafka.config;
public class KafkaConfig {
/**
* 设备状态主题
*/
public static final String MACHINESTATUS_TOPIC = "MachineStatus";
/**
* 心跳主题
*/
public static final String HEARTBEAT_TOPIC = "Heartbeat";
}
package com.neotel.smfcore.custom.lizhen.kafka.service;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.custom.lizhen.kafka.bean.Heartbeat;
import com.neotel.smfcore.custom.lizhen.kafka.config.KafkaConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.protocol.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import java.util.Collection;
import java.util.Date;
import java.util.concurrent.ExecutionException;
//@Async
@Service
@Slf4j
public class KafkaService {
@Autowired
private DataCache dataCache;
@Autowired
private KafkaTemplate kafkaTemplate;
/**
* 设备状态发送
*/
//@Scheduled(fixedRate = 1000 * 5)
public void setMachineStatus() {
Collection<Storage> storages = dataCache.getAllStorage().values();
for (Storage storage : storages) {
String cid = storage.getCid();
StatusBean statusBean = DevicesStatusUtil.getStatusBean(cid);
}
}
/**
* 心跳数据发送
*/
//@Scheduled(fixedRate = 1000 * 60 * 5)
//@Scheduled(fixedRate = 1000 * 5)
public void setHeartbeat() {
Collection<Storage> storages = dataCache.getAllStorage().values();
for (Storage storage : storages) {
String cid = storage.getCid();
StatusBean statusBean = DevicesStatusUtil.getStatusBean(cid);
if (statusBean != null) {
Heartbeat heartbeat = new Heartbeat();
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
heartbeat.setOccurrenceTime(dateStr);
heartbeat.setMachineID(cid);
heartbeat.setTopicType(KafkaConfig.HEARTBEAT_TOPIC);
String heartbeatStr = JSON.toJSONString(heartbeat);
log.info("主题为:" + KafkaConfig.HEARTBEAT_TOPIC + "内容为:" + heartbeatStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.HEARTBEAT_TOPIC, heartbeatStr);
log.info("返回结果为:" + JSON.toJSONString(future));
}
}
}
}
...@@ -7,7 +7,6 @@ import com.neotel.smfcore.common.utils.FileUtil; ...@@ -7,7 +7,6 @@ import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp; import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.rest.mapstruct.StoragePosMapper;
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.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager; import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
...@@ -17,7 +16,7 @@ import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto.BCChange; ...@@ -17,7 +16,7 @@ import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto.BCChange;
import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto.BCExpire; import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto.BCExpire;
import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto.BCInventory; import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto.BCInventory;
import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.query.BcQuery; import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.query.BcQuery;
import com.neotel.smfcore.custom.lizhen.util.ExpireDateUtil; import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
......
...@@ -14,7 +14,6 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; ...@@ -14,7 +14,6 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
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.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.enums.LITEORDER_STATUS; import com.neotel.smfcore.core.order.enums.LITEORDER_STATUS;
...@@ -33,14 +32,12 @@ import com.neotel.smfcore.core.storage.service.po.Storage; ...@@ -33,14 +32,12 @@ 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;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager; import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.VirImportLog; import com.neotel.smfcore.custom.lizhen.innerBox.bean.VirImportLog;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType; import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IVirImportLogManager; import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IVirImportLogManager;
import com.neotel.smfcore.custom.lizhen.report.bean.dto.ExpireDto; import com.neotel.smfcore.custom.lizhen.report.bean.dto.ExpireDto;
import com.neotel.smfcore.custom.lizhen.report.bean.query.ReportQueryCondition; import com.neotel.smfcore.custom.lizhen.report.bean.query.ReportQueryCondition;
import com.neotel.smfcore.custom.lizhen.report.merge.utils.FloorUtils; import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import com.neotel.smfcore.custom.lizhen.util.ExpireDateUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -56,7 +53,6 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -56,7 +53,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
......
package com.neotel.smfcore.custom.lizhen.report.outer; package com.neotel.smfcore.custom.lizhen.report.outer;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.base.IExcelDownLoad; import com.neotel.smfcore.common.base.IExcelDownLoad;
import com.neotel.smfcore.common.bean.PageData; import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.FileUtil; import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp; import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
...@@ -37,14 +34,13 @@ import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType; ...@@ -37,14 +34,13 @@ import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.report.bean.dto.ExpireDto; import com.neotel.smfcore.custom.lizhen.report.bean.dto.ExpireDto;
import com.neotel.smfcore.custom.lizhen.report.bean.dto.InventoryDto; import com.neotel.smfcore.custom.lizhen.report.bean.dto.InventoryDto;
import com.neotel.smfcore.custom.lizhen.report.bean.query.ReportQueryCondition; import com.neotel.smfcore.custom.lizhen.report.bean.query.ReportQueryCondition;
import com.neotel.smfcore.custom.lizhen.util.ExpireDateUtil; import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -53,7 +49,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -53,7 +49,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.ImageProducer;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
......
package com.neotel.smfcore.custom.lizhen.util; package com.neotel.smfcore.custom.lizhen.setting.util;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
......
package com.neotel.smfcore.custom.lizhen.third.maicheng.api;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.custom.lizhen.third.maicheng.bean.StationStatus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Component
public class MaiZhengApi {
@Value("${maizheng.stationStatusApi}")
private String stationStatusApi = "";
/**
* 获取站位状态接口
*
* @return
*/
public List<StationStatus> StationStatus() {
try {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("SessionID", "0");
paramMap.put("MesType", "Get");
Map<String, String> dataMap = new HashMap<>();
paramMap.put("Datas", Arrays.asList(dataMap));
log.info("获取站位状态接口入参为:" + JSONObject.toJSONString(paramMap) + "地址为:" + stationStatusApi);
String result = HttpHelper.postJson(stationStatusApi, paramMap);
log.info("获取站位状态接口返回为:" + result);
JSONObject resultJson = JSONObject.parseObject(result);
String dataStr = resultJson.getString("Datas");
return JSONObject.parseArray(dataStr, StationStatus.class);
} catch (Exception e) {
log.error("解析站位状态出错:"+e.getMessage());
e.printStackTrace();
}
return null;
}
}
package com.neotel.smfcore.custom.lizhen.third.maicheng.bean;
import lombok.Data;
@Data
public class MachineInfo {
private String 站位名称;
private String 状态;
}
package com.neotel.smfcore.custom.lizhen.third.maicheng.bean;
import lombok.Data;
/**
* 站位状态
*/
@Data
public class StationStatus {
//private String GUID;
// private String MACHINENAME;
private String LINE;
private String SIDE;
//private String NUM;
// private String MACHINENUMBER;
private String STATION;
//private String FEEDERTYPE;
private String SLOT;
//private String SUBSLOT;
private String PARTNUMBER;
//private String FEEDERNUMBER;
//private String STATUS;
//private String LEFTLENGTH;
// private String ENABLE;
//轨道号
private String trackNumber;
}
package com.neotel.smfcore.custom.lizhen.third.maicheng.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.custom.lizhen.third.maicheng.api.MaiZhengApi;
import com.neotel.smfcore.custom.lizhen.third.maicheng.bean.StationStatus;
import com.neotel.smfcore.custom.lizhen.third.maicheng.util.StationStatusCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/maiZheng")
public class MaiZhengController {
@Autowired
private StationStatusCache stationStatusCache;
@Autowired
private MaiZhengApi maiZhengApi;
@ApiOperation("修改站位状态信息")
@RequestMapping("/updateStationStatus")
@AnonymousAccess
public ResultBean updateStationStatus(@RequestBody Map<String,String> paramMap) {
log.info("修改站位状态信息:" + JSON.toJSONString(paramMap));
String dataStr = paramMap.get("Datas");
List<StationStatus> stationStatusList = JSONObject.parseArray(dataStr, StationStatus.class);
stationStatusCache.updateStatusList(stationStatusList);
return ResultBean.newOkResult("");
}
@ApiOperation("获取站位信息")
@RequestMapping("/getStationStatus")
@AnonymousAccess
public ResultBean getStationStatus(){
maiZhengApi.StationStatus();
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.lizhen.third.maicheng.util;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.lizhen.third.maicheng.api.MaiZhengApi;
import com.neotel.smfcore.custom.lizhen.third.maicheng.bean.StationStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class StationStatusCache {
@Autowired
private MaiZhengApi maiZhengApi;
@Autowired
private DataCache dataCache;
public static final String MAICHENG_STATIONSTATUS_CACHE = "MaiChengStationStatusCache";
private static List<StationStatus> stationStatusList = Lists.newCopyOnWriteArrayList();
@PostConstruct
public void init() {
try {
List<StationStatus> statusList = maiZhengApi.StationStatus();
if (statusList != null && !statusList.isEmpty()) {
updateStatusList(statusList);
} else {
List<StationStatus> statusCacheList = dataCache.getCache(MAICHENG_STATIONSTATUS_CACHE);
if (statusCacheList != null && !statusCacheList.isEmpty()) {
updateStatusList(statusCacheList);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void updateStatusList(List<StationStatus> statusList) {
stationStatusList.clear();
stationStatusList.addAll(statusList);
dataCache.updateCache(MAICHENG_STATIONSTATUS_CACHE, stationStatusList);
}
public List<StationStatus> getAllStationStatus() {
List<StationStatus> statusList = new ArrayList<>();
if (stationStatusList == null || stationStatusList.isEmpty()) {
stationStatusList = dataCache.getCache(MAICHENG_STATIONSTATUS_CACHE);
}
if (stationStatusList != null && !stationStatusList.isEmpty()) {
for (StationStatus status : stationStatusList) {
String station = status.getSTATION();
if (StringUtils.isNotBlank(station)) {
String trackNumber = station.substring(station.length() - 1);
status.setTrackNumber(trackNumber);
}
statusList.add(status);
}
}
if (statusList != null && !statusList.isEmpty()){
statusList = statusList.stream().distinct().collect(Collectors.toList());
}
return statusList;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!