Commit 2f07434e 孙克

原材料仓料箱出入库时不更新storagePos的Barcode字段, 通过status字段来区分是否在库

1 个父辈 802303cc
......@@ -465,7 +465,7 @@ public class BarcodeRule {
}
public CodeBean toCodeBean(String codeStr){
log.info("开始解析条码["+codeStr+"]");
log.debug("开始解析条码["+codeStr+"]");
CodeBean codeBean = new CodeBean();
codeBean.setCodeStr(codeStr);
//是否带有位置信息
......@@ -523,7 +523,7 @@ public class BarcodeRule {
codeArr = codeStr.split(separator,-1);
//条码与规则长度对应不上
if(codeArr.length != length){
log.info("条码["+codeStr+"]与规则【"+ruleStr+"】长度不同");
log.debug("条码["+codeStr+"]与规则【"+ruleStr+"】长度不同");
codeBean.setError("smfcore.error.barcode.wrongLength",new String[]{codeStr}, "条码[{0}]长度错误");
return codeBean;
}else{
......@@ -542,7 +542,7 @@ public class BarcodeRule {
}
if(Strings.isNullOrEmpty(reelId)){
log.info("条码解析失败,未找到RI字段");
log.debug("条码解析失败,未找到RI字段");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"RI"},"条码解析失败,未找到{0}字段");
return codeBean;
}
......@@ -550,14 +550,14 @@ public class BarcodeRule {
String partNumber = partNumber_item.getStrValue(codeArr);
if(Strings.isNullOrEmpty(partNumber)){
log.info("条码解析失败,未找到PN字段");
log.debug("条码解析失败,未找到PN字段");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"PN"}, "条码解析失败,未找到{0}字段");
return codeBean;
}
if(batch_item.hasThisField()) {
String batch = batch_item.getStrValue(codeArr);
if (batch.indexOf("-") == -1) {
log.info("条码解析失败,BATCH字段不合规则");
log.debug("条码解析失败,BATCH字段不合规则");
codeBean.setError("smfcore.error.barcode.noField", new String[]{"BATCH"}, "条码解析失败,未找到{0}字段");
return codeBean;
}
......@@ -576,13 +576,13 @@ public class BarcodeRule {
if(quantity_item.hasThisField()){
quantity = quantity_item.getIntValue(codeArr);
if(quantity == -1){
log.info("条码解析失败,未找到QTY 字段");
log.debug("条码解析失败,未找到QTY 字段");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"QTY"},"条码解析失败,未找到{0}字段");
return codeBean;
}
if (quantity == 0) {
if (!(codeStr.startsWith("CS") || codeStr.startsWith("CM") || codeStr.startsWith("CB"))) {
log.info("条码解析失败,未找到QTY 字段");
log.debug("条码解析失败,未找到QTY 字段");
codeBean.setError("smfcore.error.barcode.noField", new String[]{"QTY"}, "条码解析失败,未找到{0}字段");
return codeBean;
}
......@@ -591,7 +591,7 @@ public class BarcodeRule {
Date produceDate= produceDate_item.getDateValue(codeArr);
if(produceDate_item.hasThisField() && produceDate == null){
log.info("条码解析失败,PRODATE字段不合规则");
log.debug("条码解析失败,PRODATE字段不合规则");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"PRODATE"},"条码解析失败,未找到{0}字段");
return codeBean;
}
......@@ -629,7 +629,7 @@ public class BarcodeRule {
if (dateCode_item.hasThisField()) {
String dateCode = dateCode_item.getStrValue(codeArr);
if (dateCode.indexOf("-") == -1) {
log.info("条码解析失败,DATECODE字段不合规则");
log.debug("条码解析失败,DATECODE字段不合规则");
codeBean.setError("smfcore.error.barcode.noField", new String[]{"DATECODE"}, "条码解析失败,未找到{0}字段");
return codeBean;
}
......@@ -693,7 +693,7 @@ public class BarcodeRule {
codeArr = codeStr.split(separator, -1);
//条码与规则长度对应不上
if (codeArr.length != length) {
log.info("条码[" + codeStr + "]与规则【" + ruleStr + "】长度不同");
log.debug("条码[" + codeStr + "]与规则【" + ruleStr + "】长度不同");
return null;
} else {
codeArr = codeStr.split(separator, length);
......@@ -710,7 +710,7 @@ public class BarcodeRule {
reelId = reelId_item.getStrValue(codeArr);
}
if (Strings.isNullOrEmpty(reelId)) {
log.info("条码解析失败,未找到RI字段");
log.debug("条码解析失败,未找到RI字段");
//codeBean.setError("smfcore.error.barcode.noField",new String[]{"RI"},"条码解析失败,未找到{0}字段");
return null;
}
......@@ -721,7 +721,7 @@ public class BarcodeRule {
memo = memo_item.getStrValue(codeArr);
}
if (Strings.isNullOrEmpty(memo)){
log.info("条码解析失败,未找到MEMO字段");
log.debug("条码解析失败,未找到MEMO字段");
return null;
}
......@@ -729,7 +729,7 @@ public class BarcodeRule {
String partNumber = partNumber_item.getStrValue(codeArr);
if (Strings.isNullOrEmpty(partNumber)) {
log.info("条码解析失败,未找到PN字段");
log.debug("条码解析失败,未找到PN字段");
return null;
}
grLabel.setPartNumber(partNumber);
......@@ -737,7 +737,7 @@ public class BarcodeRule {
if (quantity_item.hasThisField()) {
quantity = quantity_item.getIntValue(codeArr);
if (quantity == -1) {
log.info("条码解析失败,未找到QTY 字段");
log.debug("条码解析失败,未找到QTY 字段");
return null;
}
}
......
......@@ -626,7 +626,7 @@ public class Barcode extends BasePo implements Serializable {
}
}
public void removeFromSubCodes(Barcode subCode){
public synchronized void removeFromSubCodes(Barcode subCode){
if(subCodeList != null && subCodeList.size() > 0){
boolean removeOk = subCodeList.removeIf(t -> t.getBarcode().equals(subCode.getBarcode()));
if(removeOk){
......
......@@ -410,6 +410,7 @@ public class CodeResolve {
*/
public Barcode resolveOneValideBarcode(String codeStr,int type) throws ValidateException{
if(org.apache.logging.log4j.util.Strings.isBlank(codeStr)){
log.info("未扫到条码");
throw new ValidateException("smfcore.error.barcode.empty","未扫到条码");
}
Collection<CodeBean> codeBeans = resolveCodeStr(codeStr, type);
......@@ -421,6 +422,7 @@ public class CodeResolve {
if(barcode == null){
barcode = barcodeFromRule;
}else{
log.info("从["+codeStr+"]中找到多个有效条码");
throw new ValidateException("smfcore.error.barcode.many","找到多个有效的条码",new String[]{codeStr});
}
}else{
......@@ -429,6 +431,7 @@ public class CodeResolve {
}
if(barcode == null){
log.info("从["+codeStr+"]中未找到有效的条码");
throw new ValidateException("smfcore.error.barcode.invalid", "未找到有效的条码",new String[]{codeStr});
}
return barcode;
......
......@@ -142,7 +142,7 @@ public class MessageUtils {
// log.info("获取资源[" + msgKey + "][" + defaultMsg + "][" + lanType + "]失败:未找到code[" + msgKey + "]对应语言[" + lanType + "]");
return msg.getMsg();
}
log.info("获取资源[" + msgKey + "][" + defaultMsg + "][" + lanType + "]失败:未找到code[" + msgKey + "]");
log.debug("获取资源[" + msgKey + "][" + defaultMsg + "][" + lanType + "]失败:未找到code[" + msgKey + "]");
}
return defaultMsg;
}
......
......@@ -134,7 +134,7 @@ public class CDeviceController {
}
log.info("料串["+materialStr+"]上的物料["+barcode.getBarcode()+"] 放入了料["+binCodeStr+"]");
log.info("料串["+materialStr+"]上的物料["+barcode.getBarcode()+"] 放入了料["+binCodeStr+"]");
//判断是否存在料箱中
if (StringUtils.isNotEmpty(barcode.getPosName())) {
log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
......@@ -167,10 +167,10 @@ public class CDeviceController {
try{
String boxStr = BoxHandleUtil.getBoxStr(binCodeStr);
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
inPos = storagePosManager.getByBarcode(boxStr);
inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if(inPos != null){
boxBarcode = inPos.getBarcode();
log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料["+barcode.getBarcode()+"]放入了料格中");
//log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料["+barcode.getBarcode()+"]放入了料格中");
}
}catch (ValidateException ve){
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料格条码不正确:" + binCodeStr);
......@@ -197,6 +197,9 @@ public class CDeviceController {
barcode = barcodeManager.save(barcode);
generatePutInTask(barcode, boxBarcode);
boxBarcode.updateSubCodes(barcode);
boxBarcode.setAmount(boxBarcode.getAmount()+barcode.getAmount());
barcodeManager.save(boxBarcode);
if(inPos != null){
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos.setBarcode(boxBarcode);
......@@ -266,6 +269,28 @@ public class CDeviceController {
//2.获取空库位
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
StoragePos pos = locOnePos(boxBarcode);
if(pos == null){
return ResultBean.newErrorResult(-1, "", boxStr + "未找到可用库位");
}
//4.生成入库任务
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog dataLog = taskService.addPutInTaskToExecute(storage, boxBarcode, pos);
return ResultBean.newOkResult(dataLog);
}
private StoragePos locOnePos(Barcode boxBarcode){
//判断信息是否在已经在库位中(出入库只改变料箱位置状态,不从StoragePos表中清除)
StoragePos pos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (pos != null){
return pos;
}
List<String> cidList = new ArrayList<>();
List<Storage> storageList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
......@@ -273,34 +298,31 @@ public class CDeviceController {
cidList.add(storage.getCid());
}
Barcode barcode = codeResolve.resolveOneValideBarcode(boxStr);
//判断有没有在库
if (StringUtils.isNotEmpty(barcode.getPosName())){
return ResultBean.newErrorResult(-1,"",boxStr+"已经存在库位:"+barcode.getPosName());
}
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", "");
pos = taskService.findEmptyPosForPutIn(storageList, boxBarcode, "", "");
if (pos == null) {
return ResultBean.newErrorResult(-1, "", boxStr + "未找到可用库位");
}
//3.锁定库位
Storage storage = dataCache.getStorageById(pos.getStorageId());
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(barcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(pos.getPosName());
reelLocInfo.setLockPosId(pos.getId());
reelLocInfo = ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, cidList);
if (reelLocInfo == null) {
return ResultBean.newErrorResult(-1, "", "[" + barcode.getBarcode() + "]库位锁定失败,暂停入库", new String[]{});
log.info(boxBarcode.getBarcode() + "未找到可用库位");
return null;
}else{
log.info("料箱["+boxBarcode.getBarcode()+"]信息加入库位["+pos.getPosName()+"]中");
pos.setBarcode(boxBarcode);
pos.setUsed(true);
storagePosManager.save(pos);
//3.锁定库位
Storage storage = dataCache.getStorageById(pos.getStorageId());
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(boxBarcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(pos.getPosName());
reelLocInfo.setLockPosId(pos.getId());
reelLocInfo = ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, cidList);
if (reelLocInfo == null) {
log.info("[" + boxBarcode.getBarcode() + "]库位锁定失败,暂停入库");
return null;
}
}
//4.生成入库任务
DataLog dataLog = taskService.addPutInTaskToExecute(storage, barcode, pos);
return pos;
return ResultBean.newOkResult(dataLog);
}
......@@ -348,22 +370,12 @@ public class CDeviceController {
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(box);
StoragePos inPos = storagePosManager.getByBarcode(boxStr);
StoragePos inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if(inPos != null){
boxBarcode = inPos.getBarcode();
log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料从料格中出库");
//log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料从料格中出库");
}
//2.获取要出库的code
//int seq = binCode.getSeq();
//Barcode barcode = null;
// for (Barcode subCode : boxBarcode.getSubCodeList()) {
// if (seq == subCode.getSeq() && binCode.getBarcode().equals(subCode.getPosName())) {
// barcode = subCode;
// break;
// }
// }
List<Barcode> subCodeList = boxBarcode.getSubCodeList();
for (Barcode subCode : subCodeList) {
if (boxStr.equals(subCode.getPosName()) && subCode.isOut()){
......@@ -413,7 +425,7 @@ public class CDeviceController {
boxBarcode.removeFromSubCodes(subCode);
barcodeManager.save(boxBarcode);
if(inPos != null){
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
//为保证数据一致性, pos中的box barcode也需要更新
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
......@@ -462,7 +474,11 @@ public class CDeviceController {
}
statusStr = statusStr.toUpperCase();
log.info("更新料箱:" + boxStr + ",任务状态为:" + statusStr);
String taskType = "入库";
if(task.isCheckOutTask()){
taskType = "出库";
}
log.info("更新料箱[" + boxStr + "]的"+taskType+"任务["+task.getId()+"]状态为:" + statusStr);
//2.判断更新状态和当前状态任务是否相同
if (task.getStatus().equals(statusStr)) {
......@@ -513,20 +529,6 @@ public class CDeviceController {
return ResultBean.newErrorResult(-1,"","未找到"+boxStr+"的入库库位");
}
@ApiOperation("不再使用")
@RequestMapping("/getBarcode")
@AnonymousAccess
@Deprecated
public Barcode getBarcode(@RequestBody Map<String,String> paramMap){
String codeStr = paramMap.get("codeStr");
//解析条码为barcode
Barcode barcode = codeResolve.resolveCode(codeStr);
if (barcode == null) {
return null;
}
return barcode;
}
@ApiOperation("入料机构获取可用料格")
@RequestMapping("/validBin")
@AnonymousAccess
......@@ -554,6 +556,11 @@ public class CDeviceController {
for (String binId : binList) {
String boxStr = BoxHandleUtil.getBoxStr(binId);
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
//为料箱分配一个库位,直接放到库位中, 如果没有库位, 那么这个料箱不允许使用
String canPutIn = canMaterialPutInBin(stackerBarcode,boxBarcode,binId);
if(canPutIn.isEmpty()){
validBinList.add(binId);
......@@ -587,16 +594,16 @@ public class CDeviceController {
if(barcode.getPosName().equals(binId)){
//因为bin中的物料都是一样的料号,供应商,库别,过账日期,所以只需要找到Bin中的第一个物料进行比对就可以了
if(!barcode.getPartNumber().equals(reelBarcode.getPartNumber())){
return "料格中物料的料号["+barcode.getPartNumber()+"]与["+reelBarcode.getBarcode()+"]的料号["+reelBarcode.getPartNumber()+"]不一致";
return "料格中["+binId+"]物料的料号["+barcode.getPartNumber()+"]与["+reelBarcode.getBarcode()+"]的料号["+reelBarcode.getPartNumber()+"]不一致";
}
if(!barcode.getProvider().equals(reelBarcode.getProvider())){
return "料格中物料的供应商["+barcode.getProvider()+"]与["+reelBarcode.getBarcode()+"]的供应商["+reelBarcode.getProvider()+"]不一致";
return "料格中["+binId+"]物料的供应商["+barcode.getProvider()+"]与["+reelBarcode.getBarcode()+"]的供应商["+reelBarcode.getProvider()+"]不一致";
}
if(!barcode.getWarehouseCode().equals(reelBarcode.getWarehouseCode())){
return "料格中物料的库别["+barcode.getWarehouseCode()+"]与["+reelBarcode.getBarcode()+"]的库别["+reelBarcode.getWarehouseCode()+"]不一致";
return "料格中["+binId+"]物料的库别["+barcode.getWarehouseCode()+"]与["+reelBarcode.getBarcode()+"]的库别["+reelBarcode.getWarehouseCode()+"]不一致";
}
if(!barcode.getProduceDate().equals(reelBarcode.getProduceDate())){
return "料格中物料的供应商["+barcode.getProvider()+"]与["+reelBarcode.getBarcode()+"]的供应商["+reelBarcode.getPartNumber()+"]不一致";
return "料格中["+binId+"]物料的供应商["+barcode.getProvider()+"]与["+reelBarcode.getBarcode()+"]的供应商["+reelBarcode.getPartNumber()+"]不一致";
}
}
}
......@@ -619,11 +626,6 @@ public class CDeviceController {
dataLog.setBatchInfo(barcode.getBatch());
dataLog.setSourceName(barcode.getBarSource());
dataLog.setWarehouseCode(barcode.getWarehouseCode());
boxBarcode.updateSubCodes(barcode);
boxBarcode.setAmount(boxBarcode.getAmount()+barcode.getAmount());
barcodeManager.save(boxBarcode);
taskService.updateFinishedTask(dataLog);
}
}
......@@ -90,7 +90,7 @@ public class BoxHandleUtil {
barcode.setUsedDate(new Date());
//仓位状态
barcode.setCheckOutDate(new Date(), "");
barcode.setPosName("");
//barcode.setPosName("");
barcode.setOrderItemId("");
barcode.setOrderId("");
barcode.setLockName("");
......@@ -98,8 +98,8 @@ public class BoxHandleUtil {
barcodeManager.save(barcode);
}
storagePos.setBarcode(null);
storagePos.setUsed(false);
//storagePos.setBarcode(null);
//storagePos.setUsed(false);
storagePosManager.save(storagePos);
log.info("出库完成,清空仓位: " + storagePos.getId() + "[" + storagePos.getPosName() + "]");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!