Commit 614d16c2 LN

不同类型料箱格口数量不一样

1 个父辈 bd210c83
......@@ -101,5 +101,5 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
StoragePos findBoxPNInStorages(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ) ;
StoragePos findEmptyBoxToPutIn(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ) ;
StoragePos findEmptyBoxToPutIn(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ,String boxType,int maxCount) ;
}
......@@ -929,11 +929,17 @@ public class StoragePosManagerImpl implements IStoragePosManager {
}
@Override
public StoragePos findEmptyBoxToPutIn(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ) {
public StoragePos findEmptyBoxToPutIn(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ,String boxType,int maxCount) {
String regex="^"+boxType+".*";
Pattern pattern = Pattern.compile(regex );
Criteria c = Criteria.where("id").nin(excludePosIds);
c = c.and("enabled").is(true);//可用
c.and("used").is(true);
c.and("barcode").exists(true);//已使用有料箱
c.and("barcode.barcode").regex(pattern);
c.and("barcode.status").is(BARCODE_STATUS.IN_STORE);
if (storageIdList != null) {
c = c.and("storageId").in(storageIdList);
......@@ -945,7 +951,7 @@ public class StoragePosManagerImpl implements IStoragePosManager {
Query q = new Query(c);
q.with(sort);
String proName = "subCodeList." + (6 - 1);
String proName = "barcode.subCodeList." + (maxCount - 1);
q.addCriteria(Criteria.where(proName).exists(false));
StoragePos pos = storagePosDao.findOne(q);
if (pos == null) {
......
......@@ -79,7 +79,7 @@ public class SpReturnInventoryController {
if (returnInventoryNo == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的退库单信息");
}
String exeResult = returnNoCache.Execute(returnInventoryNo);
String exeResult = spareNoCache.ExecuteReturn(returnInventoryNo);
if(ObjectUtil.isNotEmpty(exeResult)){
return ResultBean.newErrorResult(-1, "", "执行退库单失败:"+exeResult);
......
......@@ -95,7 +95,7 @@ public class SpSpareNoController {
if (spareNo == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的入库单信息");
}
String exeResult = spareNoCache.Execute(spareNo);
String exeResult = spareNoCache.ExecuteSpare(spareNo);
if(ObjectUtil.isNotEmpty(exeResult)){
return ResultBean.newErrorResult(-1, "", "执行退库单失败:"+exeResult);
}
......
......@@ -100,142 +100,4 @@ public class ReturnNoCache {
returnNoManager.save(returnInventoryNo);
}
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
/**
*
*/
public synchronized String Execute(ReturnInventoryNo returnNo) {
try {
if (returnNo.getSpareStatus().equals(SpareNostatus.EXECUTING_STATUS)) {
return "已在执行中";
}
String orderNo=returnNo.getOrderNo();
log.info("开始执行ReturnInventoryNo[" +orderNo + "] ");
List<StoragePos> needOutPos = new ArrayList<>();
List<String> storageIdList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
storageIdList.add(storage.getId());
}
for (SpareNoDetail detail : returnNo.getDetailList()) {
String pn = detail.getPartno();
Collection<String> excludePosIds = taskService.excludePosIds();
//根据pn查找
StoragePos pos = storagePosManager.findBoxPNInStorages(storageIdList, pn, excludePosIds, dataCache.getCheckOutType());
if (pos != null) {
Barcode boxBarcode = pos.getBarcode();
for (Barcode subBarcode :
boxBarcode.getSubCodeList()) {
if (subBarcode.getPartNumber().equals(pn)) {
subBarcode.setOut(false);
subBarcode.updateExtraData("needInNum", detail.getInQty() + "");
log.info("入库单" + orderNo+ ", Pn=" + pn + ",查找到库位号=" + pos.getPosName() + ",料箱号=" + boxBarcode.getBarcode() + ",格口号=" + subBarcode.getBarcode() + ",需要入库数量=" + detail.getInQty());
}
}
boxBarcode.setOut(false);
boxBarcode.setStatus(BARCODE_STATUS.IN_STORE);
needOutPos.add(pos);
} else {
Barcode newPn = new Barcode();
newPn.setPn(pn);
newPn.setAmount(0);
newPn.setInitialAmount(0);
newPn.setOut(false);
newPn.updateExtraData("needInNum", detail.getInQty() + "");
//查找准备出库的料箱中是否有空格口
StoragePos emptyPos = needOutPos.stream()
.filter(emptyP -> (emptyP.getBarcode().getSubCodeList().size() < 6))
.findFirst()
.orElse(null);
Barcode emptyBox = null;
if (emptyPos != null) {
//使用此格口
emptyBox = emptyPos.getBarcode();
newPn.setBarcode(emptyBox.getBarcode() + "-" + emptyBox.getSubCodeList().size());
newPn = barcodeManager.saveBarcode(newPn);
List<Barcode> subL = emptyBox.getSubCodeList();
subL.add(newPn);
emptyBox.setSubCodeList(subL);
log.info("入库单" + orderNo + ", Pn=" + pn + ",使用料箱的空格口=" + pos.getPosName() + ",料箱号=" + emptyBox.getBarcode() + ",格口号=" + newPn.getBarcode() + ",需要入库数量=" + detail.getInQty());
} else {
//寻找一个空格口
excludePosIds = taskService.excludePosIds();
emptyPos = storagePosManager.findEmptyBoxToPutIn(storageIdList, pn, excludePosIds, dataCache.getCheckOutType());
emptyBox = emptyPos.getBarcode();
if (pos != null) {
newPn.setBarcode(emptyBox.getBarcode() + "-" + emptyBox.getSubCodeList().size());
newPn = barcodeManager.saveBarcode(newPn);
List<Barcode> subL = emptyBox.getSubCodeList();
subL.add(newPn);
emptyBox.setSubCodeList(subL);
emptyBox.setOut(false);
emptyBox.setStatus(BARCODE_STATUS.IN_STORE);
needOutPos.add(pos);
log.info("入库单" + orderNo + ", Pn=" + pn + ",查找到有空格口料箱=" + pos.getPosName() + ",料箱号=" + emptyBox.getBarcode() + ",格口号=" + newPn.getBarcode() + ",需要入库数量=" + detail.getInQty());
} else {
log.info("入库单" + orderNo + ", Pn=" + pn + ",未找到可用的空料箱=");
}
}
}
}
//开始生成出库任务
int index = 1;
for (StoragePos pos : needOutPos
) {
Barcode barcode = pos.getBarcode();
log.info("入库单" + orderNo + ", 为库位=" + pos.getPosName() + ",料箱=" + barcode.getBarcode() + "生成出库任务:" + index);
barcodeManager.saveBarcode(barcode);
storagePosManager.save(pos);
Storage storage = dataCache.getStorageById(pos.getStorageId());
log.info(pos.getPosName() + "出库,料箱号为:" + barcode.getBarcode());
DataLog task = new DataLog(storage, barcode, pos);
task.setSourceId(returnNo.getId());
task.setSourceName(orderNo);
task.setSubSourceId(barcode.getLockName());
task.setSubSourceInfo(barcode.getLockName());
task.setLoc("s1");
task.setType(OP.CHECKOUT);
task.setCreator(SecurityUtils.getCurrentUsername());
task.setStatus(OP_STATUS.WAIT.name());
try {
taskService.addTaskToExecute(task);
} catch (Exception e) {
e.getMessage();
}
index++;
}
returnNo.setSpareStatus(SpareNostatus.EXECUTING_STATUS);
addToMap(returnNo);
returnNoManager.save(returnNo);
} catch (Exception exception) {
log.error("执行ReturnInventoryNo 出错: " + exception.toString());
}
return "";
}
}
......@@ -173,4 +173,20 @@ public class SpBoxUtil {
}
public static int GetBoxSubCount(String boxStr) {
//返回格口数量
if (boxStr.startsWith("CS")) {
return 6;
} else if (boxStr.startsWith("CB")) {
return 4;
} else if (boxStr.startsWith("CM")) {
return 1;
}
return 0;
}
}
package com.neotel.smfcore.custom.luxsan_sp.util;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
......@@ -14,9 +15,12 @@ import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoDetail;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoResult;
import com.neotel.smfcore.custom.luxsan_sp.bean.BaseNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.ISpareNoManager;
import lombok.extern.slf4j.Slf4j;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
......@@ -127,18 +131,55 @@ public class SpareNoCache {
@Autowired
private TaskService taskService;
@Autowired
private ReturnNoCache returnNoCache;
@Autowired
private IReturnNoManager returnNoManager;
public String ExecuteReturn(ReturnInventoryNo returnNo ){
if (returnNo.getSpareStatus().equals(SpareNostatus.EXECUTING_STATUS)) {
return "已在执行中";
}
String result=ExecuteNo(returnNo.getOrderNo(), returnNo);
if(ObjectUtil.isNotEmpty(result)){
return result;
}
returnNo.setSpareStatus(SpareNostatus.EXECUTING_STATUS);
returnNoCache. addToMap(returnNo);
returnNoManager.save(returnNo);
return "";
}
public String ExecuteSpare(SpareNo spareNo){
if (spareNo.getSpareStatus().equals(SpareNostatus.EXECUTING_STATUS)) {
return "已在执行中";
}
String result=ExecuteNo(spareNo.getSpareNo(), spareNo);
if(ObjectUtil.isNotEmpty(result)){
return result;
}
spareNo.setSpareStatus(SpareNostatus.EXECUTING_STATUS);
addToMap(spareNo);
spareNoManager.save(spareNo);
return "";
}
/**
*
*/
public synchronized String Execute(SpareNo spareNo) {
private synchronized String ExecuteNo( String orderNo, BaseNo baseNo) {
try {
if (spareNo.getSpareStatus().equals(SpareNostatus.EXECUTING_STATUS)) {
if (baseNo.getSpareStatus().equals(SpareNostatus.EXECUTING_STATUS)) {
return "已在执行中";
}
String orderNo=spareNo.getSpareNo();
log.info("开始执行ReturnInventoryNo[" +orderNo + "] ");
log.info("开始执行 入库单 [" +orderNo + "] ");
List<StoragePos> needOutPos = new ArrayList<>();
List<String> storageIdList = new ArrayList<>();
......@@ -146,7 +187,7 @@ public class SpareNoCache {
storageIdList.add(storage.getId());
}
for (SpareNoDetail detail : spareNo.getDetailList()) {
for (SpareNoDetail detail : baseNo.getDetailList()) {
String pn = detail.getPartno();
......@@ -177,10 +218,16 @@ public class SpareNoCache {
newPn.setOut(false);
newPn.updateExtraData("needInNum", detail.getInQty() + "");
//查找准备出库的料箱中是否有空格口
StoragePos emptyPos = needOutPos.stream()
.filter(emptyP -> (emptyP.getBarcode().getSubCodeList().size() < 6))
.findFirst()
.orElse(null);
StoragePos emptyPos = null;
for (StoragePos exPos :
needOutPos) {
int subCount = SpBoxUtil.GetBoxSubCount(exPos.getBarcode().getBarcode());
if (exPos.getBarcode().getSubCodeList().size() < subCount) {
emptyPos = exPos;
break;
}
}
Barcode emptyBox = null;
if (emptyPos != null) {
//使用此格口
......@@ -195,23 +242,33 @@ public class SpareNoCache {
} else {
excludePosIds = taskService.excludePosIds();
//寻找一个空格口
emptyPos = storagePosManager.findEmptyBoxToPutIn(storageIdList, pn, excludePosIds, dataCache.getCheckOutType());
emptyBox = emptyPos.getBarcode();
if (pos != null) {
newPn.setBarcode(emptyBox.getBarcode() + "-" + emptyBox.getSubCodeList().size());
newPn = barcodeManager.saveBarcode(newPn);
List<Barcode> subL = emptyBox.getSubCodeList();
subL.add(newPn);
emptyBox.setSubCodeList(subL);
emptyBox.setOut(false);
emptyBox.setStatus(BARCODE_STATUS.IN_STORE);
needOutPos.add(pos);
log.info("入库单" + orderNo + ", Pn=" + pn + ",查找到有空格口料箱=" + pos.getPosName() + ",料箱号=" + emptyBox.getBarcode() + ",格口号=" + newPn.getBarcode() + ",需要入库数量=" + detail.getInQty());
} else {
log.info("入库单" + orderNo + ", Pn=" + pn + ",未找到可用的空料箱=");
List<String> boxTypes = new ArrayList<>();
boxTypes.add("CS");
boxTypes.add("CB");
boxTypes.add("CM");
for (String type :
boxTypes) {
int count = SpBoxUtil.GetBoxSubCount(type);
emptyPos = storagePosManager.findEmptyBoxToPutIn(storageIdList, pn, excludePosIds, dataCache.getCheckOutType(), type, count);
emptyBox = emptyPos.getBarcode();
if (pos != null) {
newPn.setBarcode(emptyBox.getBarcode() + "-" + emptyBox.getSubCodeList().size());
newPn = barcodeManager.saveBarcode(newPn);
List<Barcode> subL = emptyBox.getSubCodeList();
subL.add(newPn);
emptyBox.setSubCodeList(subL);
emptyBox.setOut(false);
emptyBox.setStatus(BARCODE_STATUS.IN_STORE);
needOutPos.add(pos);
log.info("入库单" + orderNo + ", Pn=" + pn + "," + type + "查找到有空格口料箱=" + pos.getPosName() + ",料箱号=" + emptyBox.getBarcode() + ",格口号=" + newPn.getBarcode() + ",需要入库数量=" + detail.getInQty());
break;
} else {
log.info("入库单" + orderNo + ", Pn=" + pn + "," + type + "未找到可用的空料箱=");
}
}
}
}
......@@ -229,7 +286,7 @@ public class SpareNoCache {
Storage storage = dataCache.getStorageById(pos.getStorageId());
log.info(pos.getPosName() + "出库,料箱号为:" + barcode.getBarcode());
DataLog task = new DataLog(storage, barcode, pos);
task.setSourceId(spareNo.getId());
task.setSourceId(baseNo.getId());
task.setSourceName(orderNo);
task.setSubSourceId(barcode.getLockName());
task.setSubSourceInfo(barcode.getLockName());
......@@ -245,13 +302,12 @@ public class SpareNoCache {
index++;
}
spareNo.setSpareStatus(SpareNostatus.EXECUTING_STATUS);
addToMap(spareNo);
spareNoManager.save(spareNo);
} catch (Exception exception) {
log.error("执行ReturnInventoryNo 出错: " + exception.toString());
}
return "";
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!