Commit 9cab9d63 zshaohui

1. 所有空隔口信息给CTU

2. CTU生成出库任务接口
1 个父辈 263ce831
...@@ -508,6 +508,9 @@ public class StoragePosController { ...@@ -508,6 +508,9 @@ public class StoragePosController {
if (subCodeList != null && !subCodeList.isEmpty()){ if (subCodeList != null && !subCodeList.isEmpty()){
barcodeDto.setNeedExpand(true); barcodeDto.setNeedExpand(true);
barcodeDto.setSubCodeList(new ArrayList<>()); barcodeDto.setSubCodeList(new ArrayList<>());
barcodeDto.setReelAmount(subCodeList.size());
} else {
barcodeDto.setReelAmount(0);
} }
} }
} }
......
...@@ -83,6 +83,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> { ...@@ -83,6 +83,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
List<StoragePos> findNotEmptyPosNameByStorageId(String storageId); List<StoragePos> findNotEmptyPosNameByStorageId(String storageId);
List<StoragePos> findNotEmptyBarcodeByStorageId(String storageId);
StoragePos findOneEmptyPosNameByStorageId(String storageId,String posName); StoragePos findOneEmptyPosNameByStorageId(String storageId,String posName);
List<StoragePos> findEmptyByStorageId(String storageId); List<StoragePos> findEmptyByStorageId(String storageId);
......
...@@ -455,6 +455,17 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -455,6 +455,17 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return storagePosDao.findByQuery(query); return storagePosDao.findByQuery(query);
} }
public List<StoragePos> findNotEmptyBarcodeByStorageId(String storageId) {
Criteria c = Criteria.where("barcode").exists(true)
.and("enabled").is(true);//可用;
if(!Strings.isNullOrEmpty(storageId)){
c = c.and("storageId").is(storageId);
}
Query query = new Query(c);
query.fields().include("barcode.posName","barcode.barcode","barcode.status","barcode.subCodeList.posName","barcode.partNumber").exclude("id");
return storagePosDao.findByQuery(query);
}
@Override @Override
public StoragePos findOneEmptyPosNameByStorageId(String storageId,String posName) { public StoragePos findOneEmptyPosNameByStorageId(String storageId,String posName) {
Criteria c = Criteria.where("barcode").exists(false) Criteria c = Criteria.where("barcode").exists(false)
......
...@@ -361,6 +361,10 @@ public class CDeviceController { ...@@ -361,6 +361,10 @@ public class CDeviceController {
cacheMap.remove(materialStr); cacheMap.remove(materialStr);
dataCache.updateCache(CacheNameUtil.CHCHE_RETURN_TOWER, cacheMap); dataCache.updateCache(CacheNameUtil.CHCHE_RETURN_TOWER, cacheMap);
} }
//清空入料线体缓存
RawInLineUtil.clearInLineStacker(materialStr);
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
......
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller; package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.alibaba.fastjson.JSONObject;
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.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
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.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.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.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.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.CtuTask; import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.CtuTask;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.TaskCurrentLoc; import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.TaskCurrentLoc;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil; import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -21,6 +26,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -21,6 +26,8 @@ import io.swagger.annotations.ApiOperation;
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;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
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;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -44,6 +51,9 @@ public class CtuDeviceController { ...@@ -44,6 +51,9 @@ public class CtuDeviceController {
@Autowired @Autowired
private CodeResolve codeResolve; private CodeResolve codeResolve;
@Autowired
private IStoragePosManager storagePosManager;
@ApiOperation("原材料CTU获取线体到架子的入库任务(入满箱或出库后回库)") @ApiOperation("原材料CTU获取线体到架子的入库任务(入满箱或出库后回库)")
@RequestMapping("/lineToShelfTasks") @RequestMapping("/lineToShelfTasks")
...@@ -340,4 +350,189 @@ public class CtuDeviceController { ...@@ -340,4 +350,189 @@ public class CtuDeviceController {
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
@ApiOperation("获取所有在库的料箱信息")
@RequestMapping("/getInStoreBarcode")
@AnonymousAccess
public ResultBean getInStoreBarcode() {
String storageId = "";
for (Storage storage : dataCache.getAllStorage().values()) {
if (!storage.isVirtual()) {
storageId = storage.getId();
}
}
//查找所有库位信息
//log.info("开始时间:"+System.currentTimeMillis());
List<StoragePos> storagePosList = storagePosManager.findNotEmptyBarcodeByStorageId(storageId);
if (storagePosList == null || storagePosList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "未找到可用料箱");
}
//log.info("结束时间:"+System.currentTimeMillis());
List<Map<String,Object>> resultList = new ArrayList<>();
//循环判断是否可用
List<DataLog> allTasks = taskService.getAllTasks();
Map<String, String> binCodeCacheMap = BinCacheUtil.binCodeCacheMap("", "");
//Map<String, String> binCodeCacheMap = new HashMap<>();
for (StoragePos pos : storagePosList) {
Barcode barcode = pos.getBarcode();
if (barcode != null){
if (barcode.getStatus() != BARCODE_STATUS.IN_STORE){
continue;
}
int count = 0;
//判断是否可用
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList == null || subCodeList.isEmpty()){
if ("C07".equals(barcode.getPartNumber())){
count = 6;
} else if ("C13".equals(barcode.getPartNumber()) || "C15".equals(barcode.getPartNumber())){
count = 3;
}
} else {
Map<String, List<Barcode>> posNameMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName));
if ("C07".equals(barcode.getPartNumber())){
count = 6 - posNameMap.keySet().size();
} else if ("C13".equals(barcode.getPartNumber()) || "C15".equals(barcode.getPartNumber())){
count = 3 - posNameMap.keySet().size();
}
}
if (count == 0){
continue;
}
//判断是否有任务
boolean hasTask = false;
for (DataLog dataLog : allTasks) {
if (!dataLog.isCancel() && !dataLog.isFinished()){
if (barcode.getBarcode().equals(dataLog.getBarcode())){
hasTask = true;
break;
}
}
}
if (hasTask){
continue;
}
String size = "";
String boxStr = barcode.getBarcode();
if (boxStr.startsWith("C07")){
size = "7";
} else if (boxStr.startsWith("C13")){
size = "13";
}else if (boxStr.startsWith("C15")){
size = "15";
}
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("box",boxStr);
resultMap.put("size",size);
String binCode = boxStr+"-01";
String warehouseCode = StringUtils.isNotEmpty(binCodeCacheMap.get(binCode)) ? binCodeCacheMap.get(binCode) : "";
resultMap.put("warehouseCode",warehouseCode);
resultMap.put("remainNum",count);
resultList.add(resultMap);
}
}
if (resultList == null || resultList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "未找到可用料箱");
}
resultList.sort((o1, o2) -> o2.get("remainNum").toString().compareTo(o1.get("remainNum").toString()));
return ResultBean.newOkResult(resultList);
}
@ApiOperation("CTU通知生成出库任务")
@RequestMapping("/boxCheckOut")
@AnonymousAccess
public ResultBean boxCheckOut(@RequestBody List<String> boxList){
if (boxList == null || boxList.isEmpty()){
return ResultBean.newErrorResult(-1,"","传入的料箱号不能为空");
}
String boxListStr = JSONObject.toJSONString(boxList);
log.info("CTU生成出库任务,料箱号为:"+boxListStr);
List<Map<String,String>> resultList = new ArrayList<>();
List<DataLog> allTasks = taskService.getAllTasks();
List<StoragePos> storagePosList = storagePosManager.findByQuery(new Query(Criteria.where("barcode.barcode").in(boxList)));
if (storagePosList == null || storagePosList.isEmpty()){
return ResultBean.newErrorResult(-1,"",boxList+"未在库位中找到料箱");
}
for (StoragePos pos : storagePosList) {
Barcode barcode = pos.getBarcode();
if (barcode != null) {
if (barcode.getStatus() != BARCODE_STATUS.IN_STORE) {
log.info(barcode.getBarcode() + "料箱不在库,跳过");
continue;
}
//判断有没有出库任务
boolean reelHasOutTask = false;
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
for (Barcode subCode : subCodeList) {
if (subCode.isOut()) {
reelHasOutTask = true;
break;
}
}
}
if (reelHasOutTask) {
log.info(barcode.getBarcode() + "料箱中有要出库的物料,跳过");
continue;
}
//判断有没有任务
boolean boxHasTask = false;
for (DataLog task : allTasks) {
if (!task.isFinished() && !task.isCancel()) {
if (barcode.getBarcode().equals(task.getBarcode())) {
boxHasTask = true;
break;
}
}
}
if (boxHasTask) {
log.info(barcode.getBarcode() + "料箱有正在执行的任务,跳过");
continue;
}
//生成出库任务
String storageId = pos.getStorageId();
Storage storage = dataCache.getStorageById(storageId);
if (storage.isVirtual()){
log.info(barcode.getBarcode() + "料箱在虚拟仓中,跳过");
continue;
}
DataLog dataLog = new DataLog(storage, barcode, pos);
dataLog.setLoc(TaskCurrentLoc.In_FeedingInlet);
dataLog.setType(OP.CHECKOUT);
dataLog.setCallEmptyBox(true);
dataLog.setOperator("CTU呼叫到入料机构");
taskService.addTaskToExecute(dataLog);
Map<String,String> resultMap = new HashMap<>();
resultMap.put("box",barcode.getBarcode());
resultMap.put("posName",pos.getPosName());
resultList.add(resultMap);
}
}
if (resultList == null || resultList.isEmpty()){
return ResultBean.newErrorResult(-1,"",boxList+"未找到符合条件的下架任务");
}
return ResultBean.newOkResult(resultList);
}
} }
package com.neotel.smfcore.custom.luxsan.factory_c.third; package com.neotel.smfcore.custom.luxsan.factory_c.third;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
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.custom.luxsan.factory_c.third.bean.MaterialLoc; import com.neotel.smfcore.custom.luxsan.factory_c.third.bean.MaterialLoc;
import com.neotel.smfcore.custom.luxsan.factory_c.third.util.MaterialLocUtil; import com.neotel.smfcore.custom.luxsan.factory_c.third.util.MaterialLocUtil;
...@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
@Slf4j @Slf4j
...@@ -67,7 +69,13 @@ public class MaterialRestController { ...@@ -67,7 +69,13 @@ public class MaterialRestController {
public ResultBean manualBindStack(@RequestBody Map<String, String> paramMap) { public ResultBean manualBindStack(@RequestBody Map<String, String> paramMap) {
String stackerCode = paramMap.get("stackerCode"); String stackerCode = paramMap.get("stackerCode");
String destination = paramMap.get("destination"); String destination = paramMap.get("destination");
log.info("手动绑定料串["+stackerCode+"]目的地:" + stackerCode); stackerCode = stackerCode.toUpperCase(Locale.ROOT);
if (StringUtils.isNotEmpty(stackerCode)){
if (!stackerCode.startsWith("B")){
return ResultBean.newErrorResult(-1,"",stackerCode+"格式不正确");
}
}
log.info("手动绑定料串["+stackerCode+"]目的地:" + destination);
MaterialLocUtil.updateStackerLoc(stackerCode,"", destination); MaterialLocUtil.updateStackerLoc(stackerCode,"", destination);
return ResultBean.newOkResult("绑定成功"); return ResultBean.newOkResult("绑定成功");
} }
......
package com.neotel.smfcore.custom.luxsan.factory_c.third; package com.neotel.smfcore.custom.luxsan.factory_c.third;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.MaterialUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.third.util.RawInLineUtil; import com.neotel.smfcore.custom.luxsan.factory_c.third.util.RawInLineUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -26,8 +27,14 @@ public class RawInLineController { ...@@ -26,8 +27,14 @@ public class RawInLineController {
String materialStr = paramMap.get("materialStr"); String materialStr = paramMap.get("materialStr");
String loc = paramMap.get("loc"); String loc = paramMap.get("loc");
log.info("入库流水线,获取满料串:" + materialStr + "目的地为:" + loc); log.info("入库流水线,获取满料串:" + materialStr + "目的地为:" + loc);
String destination = RawInLineUtil.getNextDestination(materialStr, loc);
//判断料串有没有绑定,没有绑定,返回noDestination
String destination = "noDestination";
if (!MaterialUtil.bindInfo(materialStr)){
} else {
destination = RawInLineUtil.getNextDestination(materialStr, loc);
}
Map<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
resultMap.put("destination", destination); resultMap.put("destination", destination);
resultMap.put("materialStr", materialStr); resultMap.put("materialStr", materialStr);
......
...@@ -89,45 +89,39 @@ public class RawInLineUtil { ...@@ -89,45 +89,39 @@ public class RawInLineUtil {
Map<String, RawInLineMaterialLoc> destinationMap = dataCache.getCache(CacheNameUtil.CHCHE_RAWIN_LINE_MATERIAL_DESTINATION); Map<String, RawInLineMaterialLoc> destinationMap = dataCache.getCache(CacheNameUtil.CHCHE_RAWIN_LINE_MATERIAL_DESTINATION);
if(loc.equals(forkLoc)){ if(loc.equals(forkLoc)){
int count = 0;
String nextLoc = ""; String nextLoc = "";
for (RawInLineMaterialLoc materialLoc : destinationMap.values()) { if ("13".equals(materialSize) || "15".equals(materialSize)){
if (rawInLine01.equals(materialLoc.getDestination())) { log.info("13或者15寸的料串,只放在1号工位:"+rawInLine01);
count++;
}
}
if(count >= 3){
//1号已经3个, 分2号
nextLoc = rawInLine02;
}else{
nextLoc = rawInLine01; nextLoc = rawInLine01;
} else {
nextLoc = rawInLine02;
} }
updateDestinationMap(material,loc,nextLoc); updateDestinationMap(material,loc,nextLoc);
return nextLoc; return nextLoc;
}else{ }else{
if ("13".equals(materialSize) || "15".equals(materialSize)){ String nextLoc = loc;
log.info("13或者15寸的料串,只放在当前位置:"+loc); if (rawInLine02.equals(loc)) {
return loc; nextLoc = rawInLine03;
} else if (rawInLine03.equals(loc)) {
nextLoc = rawInLine04;
} else if (rawInLine04.equals(loc)) {
nextLoc = rawInLine05;
} else if (rawInLine05.equals(loc)) {
nextLoc = rawInLine06;
} }
int count = 0; int count = 0;
for (RawInLineMaterialLoc materialLoc : destinationMap.values()) { for (RawInLineMaterialLoc materialLoc : destinationMap.values()) {
if (loc.equals(materialLoc.getDestination())) { if (nextLoc.equals(materialLoc.getDestination())) {
count++; count++;
} }
} }
if(count >=3){
String nextLoc = loc; if(count < 6){
if (rawInLine02.equals(loc)) { if (!nextLoc.equals(loc)) {
nextLoc = rawInLine03; log.info("获取满料串:" + material + ",下一个位置[" + nextLoc + "]数量为:" + count + "小于6个,料串从当前位置["+loc+"]流走");
} else if (rawInLine03.equals(loc)) { updateDestinationMap(material, loc + "_to_" + nextLoc, nextLoc);
nextLoc = rawInLine04;
} else if (rawInLine04.equals(loc)) {
nextLoc = rawInLine05;
} else if (rawInLine05.equals(loc)) {
nextLoc = rawInLine06;
} }
log.info("获取满料串:"+material+",当前位置["+loc+"]数量为:"+count+"超过3个,分配到下一位置" + nextLoc);
updateDestinationMap(material,loc,nextLoc);
return nextLoc; return nextLoc;
}else{ }else{
updateDestinationMap(material,loc,""); updateDestinationMap(material,loc,"");
...@@ -136,4 +130,12 @@ public class RawInLineUtil { ...@@ -136,4 +130,12 @@ public class RawInLineUtil {
} }
} }
public static void clearInLineStacker(String materialStr) {
Map<String, RawInLineMaterialLoc> destinationMap = dataCache.getCache(CacheNameUtil.CHCHE_RAWIN_LINE_MATERIAL_DESTINATION);
if (destinationMap == null) {
destinationMap = new ConcurrentHashMap<>();
}
destinationMap.remove(materialStr);
dataCache.updateCache(CacheNameUtil.CHCHE_RAWIN_LINE_MATERIAL_DESTINATION,destinationMap);
}
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!