Commit 20f70078 zshaohui

1131 外仓功能提交

1 个父辈 6e7fda45
...@@ -47,6 +47,7 @@ public enum OP_STATUS { ...@@ -47,6 +47,7 @@ public enum OP_STATUS {
IN_ON_LINE, IN_ON_LINE,
IN_ON_AGV, IN_ON_AGV,
OUT_ON_LINE, OUT_ON_LINE,
OUT_ON_AGV OUT_ON_AGV,
ERROR
; ;
} }
...@@ -302,9 +302,9 @@ public class DataLog extends BasePo implements Serializable { ...@@ -302,9 +302,9 @@ public class DataLog extends BasePo implements Serializable {
*/ */
public boolean needRemoveFromCache(){ public boolean needRemoveFromCache(){
if(isFinished() || isCancel()){ if(isFinished() || isCancel()){
if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 5 * 60 * 1000){ //if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 5 * 60 * 1000){
return true; return true;
} //}
} }
return false; return false;
} }
......
package com.neotel.smfcore.custom.lizhen.bean; package com.neotel.smfcore.custom.lizhen.bean;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author sunke * @author sunke
* @date 2022/9/22 4:32 PM * @date 2022/9/22 4:32 PM
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class Station { public class Station {
/** /**
...@@ -19,10 +23,26 @@ public class Station { ...@@ -19,10 +23,26 @@ public class Station {
*/ */
private String currentRfid = ""; private String currentRfid = "";
/**
* 物料当前扫描数量
*/
private int reelCurrentNum = 0;
/**
* 物料总数量
*/
private int reelNum;
/**
* 料箱当前数量
*/
private int boxCurrentNum = 0;
/** /**
* 数量 * 料箱数量
*/ */
private int num; private int boxNum;
/** /**
* 宽 * 宽
...@@ -38,4 +58,7 @@ public class Station { ...@@ -38,4 +58,7 @@ public class Station {
* GR标签 * GR标签
*/ */
private String grLabel; private String grLabel;
private String lastScanBoxCode = "";
} }
package com.neotel.smfcore.custom.lizhen.rest; package com.neotel.smfcore.custom.lizhen.rest;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE; import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
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.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
...@@ -10,6 +11,7 @@ import com.neotel.smfcore.core.storage.enums.DeviceType; ...@@ -10,6 +11,7 @@ import com.neotel.smfcore.core.storage.enums.DeviceType;
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;
import com.neotel.smfcore.core.system.service.dao.IDataLogDao;
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.bean.Station; import com.neotel.smfcore.custom.lizhen.bean.Station;
...@@ -48,6 +50,9 @@ public class AgvBoxDeviceClientController { ...@@ -48,6 +50,9 @@ public class AgvBoxDeviceClientController {
@Autowired @Autowired
private IStoragePosManager storagePosManager; private IStoragePosManager storagePosManager;
@Autowired
private IDataLogDao dataLogDao;
/** /**
* 料箱锁定的目的地 * 料箱锁定的目的地
*/ */
...@@ -62,7 +67,7 @@ public class AgvBoxDeviceClientController { ...@@ -62,7 +67,7 @@ public class AgvBoxDeviceClientController {
@ResponseBody @ResponseBody
@AnonymousAccess @AnonymousAccess
public ResultBean stationInfo(HttpServletRequest request) { public ResultBean stationInfo(HttpServletRequest request) {
for (int i = 1; i < 5; i++) { for (int i = 1; i <= 5; i++) {
String stationName = "s" + i; String stationName = "s" + i;
String rfid = request.getParameter(stationName); String rfid = request.getParameter(stationName);
StationCacheUtil.updateCurrentRfid(stationName, rfid); StationCacheUtil.updateCurrentRfid(stationName, rfid);
...@@ -92,10 +97,10 @@ public class AgvBoxDeviceClientController { ...@@ -92,10 +97,10 @@ public class AgvBoxDeviceClientController {
* 根据料箱RFID获取工位信息 * 根据料箱RFID获取工位信息
*/ */
private String getStationByRfid(String rfid) { private String getStationByRfid(String rfid) {
String prefixRfid = rfid + "-"; //String prefixRfid = rfid + "-";
for (Station station : StationCacheUtil.getAllStations()) { for (Station station : StationCacheUtil.getAllStations()) {
String stationRfid = station.getCurrentRfid(); String stationRfid = station.getCurrentRfid();
if (stationRfid.startsWith(prefixRfid)) { if (stationRfid.startsWith(rfid)) {
return station.getName(); return station.getName();
} }
} }
...@@ -149,7 +154,7 @@ public class AgvBoxDeviceClientController { ...@@ -149,7 +154,7 @@ public class AgvBoxDeviceClientController {
DataLog opTask = null; DataLog opTask = null;
Collection<DataLog> tasks = taskService.getAllTasks(); Collection<DataLog> tasks = taskService.getAllTasks();
for (DataLog task : tasks) { for (DataLog task : tasks) {
if (!task.isFinished()) { if (!task.isFinished() && !task.isCancel()) {
Storage storage = dataCache.getStorageById(task.getStorageId()); Storage storage = dataCache.getStorageById(task.getStorageId());
if (storage.isStorage(DeviceType.AGV_BOX)) { if (storage.isStorage(DeviceType.AGV_BOX)) {
if (isSameBarcodeTask(rfid, task)) { if (isSameBarcodeTask(rfid, task)) {
...@@ -238,7 +243,9 @@ public class AgvBoxDeviceClientController { ...@@ -238,7 +243,9 @@ public class AgvBoxDeviceClientController {
List<DataLog> allTasks = taskService.getAllTasks(); List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog task : allTasks) { for (DataLog task : allTasks) {
if (rfid.startsWith(task.getBarcode())) { if (rfid.startsWith(task.getBarcode())) {
if (!task.isCancel()) {
opTask = task; opTask = task;
}
break; break;
} }
} }
...@@ -277,6 +284,8 @@ public class AgvBoxDeviceClientController { ...@@ -277,6 +284,8 @@ public class AgvBoxDeviceClientController {
if (OP_STATUS.OUT_ON_AGV.name().equals(statusStr)) { if (OP_STATUS.OUT_ON_AGV.name().equals(statusStr)) {
//从库位中取出,需要移到完成队列中,并且清理库存 //从库位中取出,需要移到完成队列中,并且清理库存
outFromPos(opTask); outFromPos(opTask);
//清理锁定库位
ReelLockPosUtil.removeReelLockPosInfo(rfid);
} }
taskService.updateFinishedTask(opTask); taskService.updateFinishedTask(opTask);
......
...@@ -4,10 +4,13 @@ import com.neotel.smfcore.common.bean.ResultBean; ...@@ -4,10 +4,13 @@ import com.neotel.smfcore.common.bean.ResultBean;
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.IStorageManager; import com.neotel.smfcore.core.storage.service.manager.IStorageManager;
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.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -16,7 +19,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,7 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
@RestController @RestController
public class TaskRestController{ @Slf4j
public class TaskRestController {
@Autowired @Autowired
private IDataLogManager dataLogManager; private IDataLogManager dataLogManager;
...@@ -25,12 +29,15 @@ public class TaskRestController{ ...@@ -25,12 +29,15 @@ public class TaskRestController{
private DataCache dataCache; private DataCache dataCache;
@Autowired @Autowired
private IStorageManager storageManager; private TaskService taskService;
@Autowired
private IStoragePosManager storagePosManager;
@RequestMapping("/putIn") @RequestMapping("/putIn")
@AnonymousAccess @AnonymousAccess
public ResultBean putIn(@RequestBody Map<String,String> paramMap){ public ResultBean putIn(@RequestBody Map<String, String> paramMap) {
String barcode = paramMap.get("barcode"); String barcode = paramMap.get("barcode");
String posName = paramMap.get("posName"); String posName = paramMap.get("posName");
String cid = paramMap.get("cid"); String cid = paramMap.get("cid");
...@@ -38,12 +45,36 @@ public class TaskRestController{ ...@@ -38,12 +45,36 @@ public class TaskRestController{
DataLog dataLog = new DataLog(); DataLog dataLog = new DataLog();
dataLog.setStorageId(storage.getId()); dataLog.setStorageId(storage.getId());
dataLog.setPosName(posName); dataLog.setPosName(posName);
dataLog.setPosId(storagePosManager.getByPosName(posName).getId());
dataLog.setCid(cid); dataLog.setCid(cid);
dataLog.setBarcode(barcode); dataLog.setBarcode(barcode);
dataLog.setPartNumber(barcode); dataLog.setPartNumber(barcode);
dataLog.setType(1); dataLog.setType(1);
dataLog.setStatus(OP_STATUS.WAIT.name()); dataLog.setStatus(OP_STATUS.WAIT.name());
dataLogManager.save(dataLog); taskService.addTaskToExecute(dataLog);
return ResultBean.newOkResult("");
}
@RequestMapping("/outIn")
@AnonymousAccess
public ResultBean outIn(@RequestBody Map<String, String> paramMap) {
String barcode = paramMap.get("barcode");
String posName = paramMap.get("posName");
String cid = paramMap.get("cid");
String name = paramMap.get("name");
Storage storage = dataCache.getStorage(cid);
DataLog dataLog = new DataLog();
dataLog.setStorageId(storage.getId());
dataLog.setPosName(posName);
dataLog.setPosId(storagePosManager.getByPosName(posName).getId());
dataLog.setCid(cid);
dataLog.setBarcode(barcode);
dataLog.setPartNumber(barcode);
dataLog.setType(2);
dataLog.setStatus(OP_STATUS.WAIT.name());
dataLog.setLoc(name);
log.info("工位信息--" + name);
taskService.addTaskToExecute(dataLog);
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
......
package com.neotel.smfcore.custom.lizhen.util; package com.neotel.smfcore.custom.lizhen.util;
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.custom.lizhen.bean.Station; import com.neotel.smfcore.custom.lizhen.bean.Station;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -22,6 +23,13 @@ public class StationCacheUtil { ...@@ -22,6 +23,13 @@ public class StationCacheUtil {
*/ */
private static Map<String, Station> stationMap = new ConcurrentHashMap<>(); private static Map<String, Station> stationMap = new ConcurrentHashMap<>();
public static void saveReelToBoxCode(Station station) {
int reelCurrentNum = station.getReelCurrentNum();
reelCurrentNum++;
station.setReelCurrentNum(reelCurrentNum);
StationCacheUtil.updateStation(station);
}
@PostConstruct @PostConstruct
public void init() { public void init() {
log.info("开始工位缓存信息"); log.info("开始工位缓存信息");
...@@ -31,13 +39,13 @@ public class StationCacheUtil { ...@@ -31,13 +39,13 @@ public class StationCacheUtil {
if(station == null){ if(station == null){
station = new Station(); station = new Station();
station.setName(stationName); station.setName(stationName);
}
stationMap.put(stationName,station); stationMap.put(stationName,station);
dataCache.updateCache(stationName, station); dataCache.updateCache(stationName, station);
} }
} }
}
private static synchronized void updateStation(Station station){ public static synchronized void updateStation(Station station){
stationMap.put(station.getName(),station); stationMap.put(station.getName(),station);
dataCache.updateCache(station.getName(), station); dataCache.updateCache(station.getName(), station);
} }
...@@ -59,6 +67,11 @@ public class StationCacheUtil { ...@@ -59,6 +67,11 @@ public class StationCacheUtil {
station.setCurrentRfid(rfid); station.setCurrentRfid(rfid);
updateStation(station); updateStation(station);
} }
} else {
station = new Station();
station.setName(stationName);
station.setCurrentRfid(rfid);
updateStation(station);
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!