Commit cfbf1646 张少辉

功能优化

1 个父辈 521e3849
...@@ -389,7 +389,13 @@ public class OutLineController { ...@@ -389,7 +389,13 @@ public class OutLineController {
} }
boxStr = getBoxStrbyBoxPartition(boxStr); boxStr = getBoxStrbyBoxPartition(boxStr);
//判断库位中 有没有
Barcode pidBarcode = barcodeManager.findByBarcode(boxStr); Barcode pidBarcode = barcodeManager.findByBarcode(boxStr);
StoragePos oriPos = storagePosManager.getByBarcode(pidBarcode.getBarcode());
if (oriPos != null) {
pidBarcode = oriPos.getBarcode();
}
List<Barcode> subCodes = pidBarcode.getSubCodeList(); List<Barcode> subCodes = pidBarcode.getSubCodeList();
if (subCodes == null || subCodes.isEmpty()) { if (subCodes == null || subCodes.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "料箱:" + boxStr + ",没有可出库的物料"); return ResultBean.newErrorResult(-1, "", "料箱:" + boxStr + ",没有可出库的物料");
...@@ -494,11 +500,9 @@ public class OutLineController { ...@@ -494,11 +500,9 @@ public class OutLineController {
} }
pidBarcode = barcodeManager.save(pidBarcode); pidBarcode = barcodeManager.save(pidBarcode);
if (oriPos != null){
StoragePos pos = BoxHandleUtil.locOnePos(pidBarcode); oriPos.setBarcode(pidBarcode);
if (pos != null) { storagePosManager.save(oriPos);
pos.setBarcode(pidBarcode);
storagePosManager.save(pos);
} }
if (!isOut) { if (!isOut) {
......
...@@ -700,9 +700,12 @@ public class CDeviceController { ...@@ -700,9 +700,12 @@ public class CDeviceController {
} else if (targetLoc.endsWith("2F")) { } else if (targetLoc.endsWith("2F")) {
log.info("自动绑定料串[" + materialStr + "]目的地:C1-2F"); log.info("自动绑定料串[" + materialStr + "]目的地:C1-2F");
MaterialLocUtil.updateStackerLoc(materialStr, "", "C1-2F", 1, orderItem.getOrderNo(), barcode); MaterialLocUtil.updateStackerLoc(materialStr, "", "C1-2F", 1, orderItem.getOrderNo(), barcode);
} else if (targetLoc.endsWith("1F")) { } else if (targetLoc.endsWith("C2/1F")) {
log.info("自动绑定料串[" + materialStr + "]目的地:C2-1F"); log.info("自动绑定料串[" + materialStr + "]目的地:C2-1F");
MaterialLocUtil.updateStackerLoc(materialStr, "", "C2-1F", 1, orderItem.getOrderNo(), barcode); MaterialLocUtil.updateStackerLoc(materialStr, "", "C2-1F", 1, orderItem.getOrderNo(), barcode);
} else if (targetLoc.endsWith("W2/1F")) {
log.info("自动绑定料串[" + materialStr + "]目的地:W2-1F");
MaterialLocUtil.updateStackerLoc(materialStr, "", "W2-1F", 1, orderItem.getOrderNo(), barcode);
} }
} }
...@@ -1007,8 +1010,12 @@ public class CDeviceController { ...@@ -1007,8 +1010,12 @@ public class CDeviceController {
if (boxBarcode != null) { if (boxBarcode != null) {
//判断隔口是否可以放入 //判断隔口是否可以放入
if (BinCacheUtil.canPutInBinCode(binCodeStr, warhouseCode)) { String canPutIn = BinCacheUtil.canMaterialPutInBin(barcode, boxBarcode, binCodeStr);
if (StringUtils.isEmpty(canPutIn)) {
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} else {
log.info(barcode.getBarcode() + "不可以放到料格:" + binCodeStr + ",原因为:" + canPutIn);
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCodeStr + ",原因为:" + canPutIn);
} }
} }
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCodeStr); return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCodeStr);
...@@ -1403,9 +1410,12 @@ public class CDeviceController { ...@@ -1403,9 +1410,12 @@ public class CDeviceController {
} else if (targetLoc.endsWith("2F")) { } else if (targetLoc.endsWith("2F")) {
log.info("自动绑定料串[" + stacker + "]目的地:C1-2F"); log.info("自动绑定料串[" + stacker + "]目的地:C1-2F");
MaterialLocUtil.updateStackerLoc(stacker, "", "C1-2F", 1, orderItem.getOrderNo(), barcode); MaterialLocUtil.updateStackerLoc(stacker, "", "C1-2F", 1, orderItem.getOrderNo(), barcode);
} else if (targetLoc.endsWith("1F")) { } else if (targetLoc.endsWith("C2/1F")) {
log.info("自动绑定料串[" + stacker + "]目的地:C2-1F"); log.info("自动绑定料串[" + stacker + "]目的地:C2-1F");
MaterialLocUtil.updateStackerLoc(stacker, "", "C2-1F", 1, orderItem.getOrderNo(), barcode); MaterialLocUtil.updateStackerLoc(stacker, "", "C2-1F", 1, orderItem.getOrderNo(), barcode);
} else if (targetLoc.endsWith("W2/1F")) {
log.info("自动绑定料串[" + stacker + "]目的地:W2-1F");
MaterialLocUtil.updateStackerLoc(stacker, "", "W2-1F", 1, orderItem.getOrderNo(), barcode);
} }
} }
...@@ -1860,17 +1870,20 @@ public class CDeviceController { ...@@ -1860,17 +1870,20 @@ public class CDeviceController {
String targetLoc = order.getLoc(); String targetLoc = order.getLoc();
if (StringUtils.isNotEmpty(targetLoc)){ if (StringUtils.isNotEmpty(targetLoc)){
if (targetLoc.endsWith("BG")) { if (targetLoc.endsWith("BG")) {
log.info("自动绑定料串[" + stacker + "]目的地:C2-3F-BG"); log.info(barcode.getBarcode()+"自动绑定料串[" + stacker + "]目的地:C2-3F-BG");
MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-BG", 1, orderItem.getOrderNo(),barcode); MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-BG", 1, orderItem.getOrderNo(),barcode);
} else if (targetLoc.endsWith("CG")) { } else if (targetLoc.endsWith("CG")) {
log.info("自动绑定料串[" + stacker + "]目的地:C2-3F-CG"); log.info(barcode.getBarcode()+"自动绑定料串[" + stacker + "]目的地:C2-3F-CG");
MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-CG", 1, orderItem.getOrderNo(),barcode); MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-CG", 1, orderItem.getOrderNo(),barcode);
} else if (targetLoc.endsWith("2F")){ } else if (targetLoc.endsWith("2F")){
log.info("自动绑定料串["+stacker+"]目的地:C1-2F"); log.info(barcode.getBarcode()+"自动绑定料串["+stacker+"]目的地:C1-2F");
MaterialLocUtil.updateStackerLoc(stacker,"", "C1-2F",1,orderItem.getOrderNo(),barcode); MaterialLocUtil.updateStackerLoc(stacker,"", "C1-2F",1,orderItem.getOrderNo(),barcode);
} else if (targetLoc.endsWith("1F")){ } else if (targetLoc.endsWith("C2/1F")){
log.info("自动绑定料串["+stacker+"]目的地:C2-1F"); log.info(barcode.getBarcode()+"自动绑定料串["+stacker+"]目的地:C2-1F");
MaterialLocUtil.updateStackerLoc(stacker,"", "C2-1F",1,orderItem.getOrderNo(),barcode); MaterialLocUtil.updateStackerLoc(stacker,"", "C2-1F",1,orderItem.getOrderNo(),barcode);
} else if (targetLoc.endsWith("W2/1F")){
log.info(barcode.getBarcode()+"自动绑定料串["+stacker+"]目的地:W2-1F");
MaterialLocUtil.updateStackerLoc(stacker,"", "W2-1F",1,orderItem.getOrderNo(),barcode);
} }
} }
} catch (ValidateException e) { } catch (ValidateException e) {
......
...@@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -49,6 +49,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.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@ApiOperation("手动GR入库") @ApiOperation("手动GR入库")
@Slf4j @Slf4j
...@@ -164,11 +165,12 @@ public class ManualGrPutInController { ...@@ -164,11 +165,12 @@ public class ManualGrPutInController {
return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr)); return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr));
} }
private Map<String,String> cacheBoxMap = new ConcurrentHashMap<>();
@ApiOperation("GR料盘入到料格") @ApiOperation("GR料盘入到料格")
@RequestMapping("/reelToBox") @RequestMapping("/reelToBox")
//@AnonymousAccess //@AnonymousAccess
public synchronized ResultBean reelToBox(@RequestBody Map<String, String> paramMap) { public ResultBean reelToBox(@RequestBody Map<String, String> paramMap) {
String binCode = paramMap.get("binCode"); //料格信息 String binCode = paramMap.get("binCode"); //料格信息
...@@ -204,149 +206,155 @@ public class ManualGrPutInController { ...@@ -204,149 +206,155 @@ public class ManualGrPutInController {
binCode = binCode.toUpperCase(Locale.ROOT); binCode = binCode.toUpperCase(Locale.ROOT);
boxStr = boxStr.toUpperCase(Locale.ROOT); boxStr = boxStr.toUpperCase(Locale.ROOT);
Barcode noDbBarcode = codeResolve.resolveCode(codeStr); String value = cacheBoxMap.get(boxStr);
if (noDbBarcode == null) { if (StringUtils.isEmpty(value)) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "条码无效"); cacheBoxMap.put(boxStr, boxStr);
} }
synchronized (cacheBoxMap.get(boxStr)) {
int w = 7; Barcode noDbBarcode = codeResolve.resolveCode(codeStr);
int h = 8; if (noDbBarcode == null) {
Component component = null; return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "条码无效");
if (component == null) {
BrandQtyResult result = LuxsanApi.brandQtyUrl(new BrandQtyRequest(noDbBarcode.getPartNumber(), noDbBarcode.getProvider()));
if (result == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的尺寸信息");
}
w = result.getReel_size();
if (w == 7) {
h = 8;
} else if (w == 13) {
h = 24;
} else if (w == 15) {
h = 32;
} }
} else {
w = component.getPlateSize();
h = component.getHeight();
}
if (13 == w){ int w = 7;
if (!binCode.startsWith("C13")){ int h = 8;
return ResultBean.newErrorResult(-1,"","13寸的物料,请放入C13的01号料格中"); Component component = null;
} else { if (component == null) {
if (!binCode.endsWith("-01")){ BrandQtyResult result = LuxsanApi.brandQtyUrl(new BrandQtyRequest(noDbBarcode.getPartNumber(), noDbBarcode.getProvider()));
return ResultBean.newErrorResult(-1,"","13寸的物料,请放入C13的01号料格中"); if (result == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的尺寸信息");
} }
} w = result.getReel_size();
} else if (15 == w){ if (w == 7) {
if (!binCode.startsWith("C15")){ h = 8;
return ResultBean.newErrorResult(-1,"","15寸的物料,请放入C15的01号料格中"); } else if (w == 13) {
} else { h = 24;
if (!binCode.endsWith("-01")){ } else if (w == 15) {
return ResultBean.newErrorResult(-1,"","15寸的物料,请放入C15的01号料格中"); h = 32;
} }
} else {
w = component.getPlateSize();
h = component.getHeight();
} }
} else if (7 == w){
if (binCode.startsWith("C15")){ if (13 == w) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C15中,请选择其他料格"); if (!binCode.startsWith("C13")) {
} return ResultBean.newErrorResult(-1, "", "13寸的物料,请放入C13的01号料格中");
if (binCode.startsWith("C13")){ } else {
if (binCode.endsWith("01")) { if (!binCode.endsWith("-01")) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C13的料格01中,请选择其他料格"); return ResultBean.newErrorResult(-1, "", "13寸的物料,请放入C13的01号料格中");
}
}
} else if (15 == w) {
if (!binCode.startsWith("C15")) {
return ResultBean.newErrorResult(-1, "", "15寸的物料,请放入C15的01号料格中");
} else {
if (!binCode.endsWith("-01")) {
return ResultBean.newErrorResult(-1, "", "15寸的物料,请放入C15的01号料格中");
}
}
} else if (7 == w) {
if (binCode.startsWith("C15")) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C15中,请选择其他料格");
}
if (binCode.startsWith("C13")) {
if (binCode.endsWith("01")) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C13的料格01中,请选择其他料格");
}
} }
} }
}
//判断条码是否正常 //判断条码是否正常
Barcode barcode = null; Barcode barcode = null;
try { try {
barcode = codeResolve.resolveOneValideBarcode("="+w+"x"+h+"="+codeStr); barcode = codeResolve.resolveOneValideBarcode("=" + w + "x" + h + "=" + codeStr);
} catch (ValidateException ve) { } catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg()); return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg());
} }
//判断是否存在料箱中 //判断是否存在料箱中
if (StringUtils.isNotEmpty(barcode.getPosName())) { if (StringUtils.isNotEmpty(barcode.getPosName())) {
log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName()); log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "已经存在料格" + barcode.getPosName()); return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
} }
//找到box信息 //找到box信息
Barcode boxBarcode = null; Barcode boxBarcode = null;
StoragePos inPos = null; StoragePos inPos = null;
try{ try {
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr); boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode()); inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if(inPos != null){ if (inPos != null) {
boxBarcode = inPos.getBarcode(); boxBarcode = inPos.getBarcode();
}
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料箱条码不正确:" + boxStr);
} }
}catch (ValidateException ve){
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料箱条码不正确:" + boxStr);
}
//判断料格条码和料箱是否匹配 //判断料格条码和料箱是否匹配
if (!binCode.startsWith(boxBarcode.getBarcode())){ if (!binCode.startsWith(boxBarcode.getBarcode())) {
return ResultBean.newErrorResult(-1,"","当前扫描的隔口"+binCode+"与料箱信息:"+boxStr+"不匹配"); return ResultBean.newErrorResult(-1, "", "当前扫描的隔口" + binCode + "与料箱信息:" + boxStr + "不匹配");
} }
//判断是否为禁用料 //判断是否为禁用料
barcode = smfApi.canPutInAfterResolve(barcode); barcode = smfApi.canPutInAfterResolve(barcode);
barcode.setWarehouseCode(warhouseCode); barcode.setWarehouseCode(warhouseCode);
int days = LuxsanApi.getInDate(new GetInDateRequest(CommonUtil.plantCode, barcode.getPartNumber(), barcode.getProvider(), barcode.getDateCode())); int days = LuxsanApi.getInDate(new GetInDateRequest(CommonUtil.plantCode, barcode.getPartNumber(), barcode.getProvider(), barcode.getDateCode()));
log.info(barcode.getBarcode()+"的剩余过期时间为:"+days); log.info(barcode.getBarcode() + "的剩余过期时间为:" + days);
if (days > 0) { if (days > 0) {
Date expireDate = cn.hutool.core.date.DateUtil.offsetDay(new Date(), days); Date expireDate = cn.hutool.core.date.DateUtil.offsetDay(new Date(), days);
barcode.setExpireDate(expireDate); barcode.setExpireDate(expireDate);
} }
if (barcode.getExpireDate() != null){ if (barcode.getExpireDate() != null) {
if (System.currentTimeMillis() > barcode.getExpireDate().getTime()) { if (System.currentTimeMillis() > barcode.getExpireDate().getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
} }
}
//判断隔口能否放入 //判断隔口能否放入
if (boxBarcode != null){ if (boxBarcode != null) {
String canPutIn = BinCacheUtil.canMaterialPutInBin(barcode, boxBarcode, binCode); String canPutIn = BinCacheUtil.canMaterialPutInBin(barcode, boxBarcode, binCode);
if (StringUtils.isEmpty(canPutIn)) { if (StringUtils.isEmpty(canPutIn)) {
NewLabelToCellResult cell = LuxsanApi.newLabelToCell(new NewLabelToCellRequest(CommonUtil.plantCode, Arrays.asList(udCode), barcode.getAmount(), binCode, Arrays.asList(barcode.getFullCode()))); NewLabelToCellResult cell = LuxsanApi.newLabelToCell(new NewLabelToCellRequest(CommonUtil.plantCode, Arrays.asList(udCode), barcode.getAmount(), binCode, Arrays.asList(barcode.getFullCode())));
//将GR日期设置为生产日期 //将GR日期设置为生产日期
Date grDate = DateUtil.getNoTimeDate(cell.getGR_DATE()); Date grDate = DateUtil.getNoTimeDate(cell.getGR_DATE());
barcode.setProduceDate(grDate); barcode.setProduceDate(grDate);
barcode.setLabelId(cell.getLABEL_ID()); barcode.setLabelId(cell.getLABEL_ID());
barcode.setPosName(binCode); barcode.setPosName(binCode);
barcode.setBarSource(grCode); barcode.setBarSource(grCode);
barcode.setWarehouseCode(warhouseCode); barcode.setWarehouseCode(warhouseCode);
barcode.setSeq(BoxHandleUtil.getSeq(boxBarcode,binCode)+1); barcode.setSeq(BoxHandleUtil.getSeq(boxBarcode, binCode) + 1);
barcode.setPutInTime(System.currentTimeMillis()); barcode.setPutInTime(System.currentTimeMillis());
// 刷新缓存中gr已过帐数量, 如果超出数量则报错 // 刷新缓存中gr已过帐数量, 如果超出数量则报错
int amount = barcode.getAmount(); int amount = barcode.getAmount();
GrUtil.addQty(grCode, grItem, amount); GrUtil.addQty(grCode, grItem, amount);
barcode = barcodeManager.save(barcode); barcode = barcodeManager.save(barcode);
generatePutInTask(barcode, boxBarcode, OP_STATUS.FINISHED.name()); generatePutInTask(barcode, boxBarcode, OP_STATUS.FINISHED.name());
boxBarcode.updateSubCodes(barcode); boxBarcode.UpdateSubCode(barcode);
boxBarcode.setWarehouseCode(warhouseCode); boxBarcode.setWarehouseCode(warhouseCode);
boxBarcode.setAmount(boxBarcode.getAmount()+barcode.getAmount()); boxBarcode.setAmount(boxBarcode.getAmount() + barcode.getAmount());
barcodeManager.save(boxBarcode); barcodeManager.save(boxBarcode);
if(inPos != null){ if (inPos != null) {
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新 //流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos.setBarcode(boxBarcode); inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos); storagePosManager.save(inPos);
}
return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr));
} else {
log.info(barcode.getBarcode() + "不可以放到料格:" + binCode + ",原因为:" + canPutIn);
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode + ",原因为:" + canPutIn);
} }
return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr));
} else {
log.info(barcode.getBarcode() + "不可以放到料格:" + binCode+",原因为:"+canPutIn);
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode+",原因为:"+canPutIn);
} }
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode);
} }
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode);
} }
......
...@@ -38,6 +38,7 @@ import java.util.Arrays; ...@@ -38,6 +38,7 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Api(tags = "退料到1楼") @Api(tags = "退料到1楼")
@Slf4j @Slf4j
...@@ -61,17 +62,19 @@ public class ManualReturnTowerController { ...@@ -61,17 +62,19 @@ public class ManualReturnTowerController {
private TaskService taskService; private TaskService taskService;
private Map<String,String> cacheBoxMap = new ConcurrentHashMap<>();
@ApiOperation("退库到料箱中") @ApiOperation("退库到料箱中")
@RequestMapping("/reelToBox") @RequestMapping("/reelToBox")
//@AnonymousAccess //@AnonymousAccess
public synchronized ResultBean reelToBox(@RequestBody Map<String, String> paramMap) { public ResultBean reelToBox(@RequestBody Map<String, String> paramMap) {
String wareHouseCode = paramMap.get("wareHouseCode"); String wareHouseCode = paramMap.get("wareHouseCode");
String binCode = paramMap.get("binCode"); //料格信息 String binCode = paramMap.get("binCode"); //料格信息
String codeStr = paramMap.get("codeStr"); //条码信息 String codeStr = paramMap.get("codeStr"); //条码信息
String boxStr = paramMap.get("boxStr"); //料箱信息 String boxStr = paramMap.get("boxStr"); //料箱信息
log.info("人工手动退料,料格信息为:" + binCode + ",料箱信息为:" + boxStr + "条码信息为:" + codeStr+",库别为:"+wareHouseCode); log.info("人工手动退料,料格信息为:" + binCode + ",料箱信息为:" + boxStr + "条码信息为:" + codeStr + ",库别为:" + wareHouseCode);
if (StringUtils.isEmpty(binCode)) { if (StringUtils.isEmpty(binCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料格信息"}); return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料格信息"});
...@@ -90,145 +93,152 @@ public class ManualReturnTowerController { ...@@ -90,145 +93,152 @@ public class ManualReturnTowerController {
binCode = binCode.toUpperCase(Locale.ROOT); binCode = binCode.toUpperCase(Locale.ROOT);
boxStr = boxStr.toUpperCase(Locale.ROOT); boxStr = boxStr.toUpperCase(Locale.ROOT);
//先进行料卷注册 String value = cacheBoxMap.get(boxStr);
LuxsanApi.whRegister(codeStr,wareHouseCode); if (StringUtils.isEmpty(value)) {
cacheBoxMap.put(boxStr, boxStr);
Barcode noDbBarcode = codeResolve.resolveCode(codeStr);
if (noDbBarcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "条码无效");
} }
synchronized (cacheBoxMap.get(boxStr)) {
int w = 7; //先进行料卷注册
int h = 8; LuxsanApi.whRegister(codeStr, wareHouseCode);
Component component = null;
if (component == null) { Barcode noDbBarcode = codeResolve.resolveCode(codeStr);
BrandQtyResult result = LuxsanApi.brandQtyUrl(new BrandQtyRequest(noDbBarcode.getPartNumber(), noDbBarcode.getProvider())); if (noDbBarcode == null) {
if (result == null) { return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "条码无效");
return ResultBean.newErrorResult(-1, "", "未找到对应的尺寸信息");
}
w = result.getReel_size();
if (w == 7) {
h = 8;
} else if (w == 13) {
h = 24;
} else if (w == 15) {
h = 32;
} }
} else {
w = component.getPlateSize();
h = component.getHeight();
}
if (13 == w){ int w = 7;
if (!binCode.startsWith("C13")){ int h = 8;
return ResultBean.newErrorResult(-1,"","13寸的物料,请放入C13的01号料格中"); Component component = null;
} else { if (component == null) {
if (!binCode.endsWith("-01")){ BrandQtyResult result = LuxsanApi.brandQtyUrl(new BrandQtyRequest(noDbBarcode.getPartNumber(), noDbBarcode.getProvider()));
return ResultBean.newErrorResult(-1,"","13寸的物料,请放入C13的01号料格中"); if (result == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的尺寸信息");
} }
} w = result.getReel_size();
} else if (15 == w){ if (w == 7) {
if (!binCode.startsWith("C15")){ h = 8;
return ResultBean.newErrorResult(-1,"","15寸的物料,请放入C15的01号料格中"); } else if (w == 13) {
} else { h = 24;
if (!binCode.endsWith("-01")){ } else if (w == 15) {
return ResultBean.newErrorResult(-1,"","15寸的物料,请放入C15的01号料格中"); h = 32;
} }
} else {
w = component.getPlateSize();
h = component.getHeight();
} }
} else if (7 == w){
if (binCode.startsWith("C15")){ if (13 == w) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C15中,请选择其他料格"); if (!binCode.startsWith("C13")) {
} return ResultBean.newErrorResult(-1, "", "13寸的物料,请放入C13的01号料格中");
if (binCode.startsWith("C13")){ } else {
if (binCode.endsWith("01")) { if (!binCode.endsWith("-01")) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C13的料格01中,请选择其他料格"); return ResultBean.newErrorResult(-1, "", "13寸的物料,请放入C13的01号料格中");
}
}
} else if (15 == w) {
if (!binCode.startsWith("C15")) {
return ResultBean.newErrorResult(-1, "", "15寸的物料,请放入C15的01号料格中");
} else {
if (!binCode.endsWith("-01")) {
return ResultBean.newErrorResult(-1, "", "15寸的物料,请放入C15的01号料格中");
}
}
} else if (7 == w) {
if (binCode.startsWith("C15")) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C15中,请选择其他料格");
}
if (binCode.startsWith("C13")) {
if (binCode.endsWith("01")) {
return ResultBean.newErrorResult(-1, "", "7寸的物料,不可以放入C13的料格01中,请选择其他料格");
}
} }
} }
}
//判断条码是否正常 //判断条码是否正常
Barcode barcode = null; Barcode barcode = null;
try {
barcode = codeResolve.resolveOneValideBarcode("="+w+"x"+h+"="+codeStr);
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg());
}
//判断是否存在料箱中 try {
if (StringUtils.isNotEmpty(barcode.getPosName())) { barcode = codeResolve.resolveOneValideBarcode("=" + w + "x" + h + "=" + codeStr);
log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName()); } catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "已经存在料格" + barcode.getPosName()); return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg());
}
//判断在WMS系统中,是否存在
barcode = LuxsanApi.fetchReel(barcode);
int days = LuxsanApi.getInDate(new GetInDateRequest(CommonUtil.plantCode, barcode.getPartNumber(), barcode.getProvider(), barcode.getDateCode()));
log.info(barcode.getBarcode()+"的剩余过期时间为:"+days);
if (days > 0) {
Date expireDate = cn.hutool.core.date.DateUtil.offsetDay(new Date(), days);
barcode.setExpireDate(expireDate);
}
if (barcode.getExpireDate() != null){
if (System.currentTimeMillis() > barcode.getExpireDate().getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
} }
}
//找到box信息 //判断是否存在料箱中
Barcode boxBarcode = null; if (StringUtils.isNotEmpty(barcode.getPosName())) {
StoragePos inPos = null; log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
try{ return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if(inPos != null){
boxBarcode = inPos.getBarcode();
} }
}catch (ValidateException ve){
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料箱条码不正确:" + boxStr);
}
//判断料格条码和料箱是否匹配
if (!binCode.startsWith(boxBarcode.getBarcode())){
return ResultBean.newErrorResult(-1,"","当前扫描的隔口"+binCode+"与料箱信息:"+boxStr+"不匹配");
}
//判断是否为禁用料 //判断在WMS系统中,是否存在
barcode = smfApi.canPutInAfterResolve(barcode); barcode = LuxsanApi.fetchReel(barcode);
//判断隔口能否放入 int days = LuxsanApi.getInDate(new GetInDateRequest(CommonUtil.plantCode, barcode.getPartNumber(), barcode.getProvider(), barcode.getDateCode()));
if (boxBarcode != null){ log.info(barcode.getBarcode() + "的剩余过期时间为:" + days);
if (days > 0) {
Date expireDate = cn.hutool.core.date.DateUtil.offsetDay(new Date(), days);
barcode.setExpireDate(expireDate);
}
if (barcode.getExpireDate() != null) {
if (System.currentTimeMillis() > barcode.getExpireDate().getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
String canPutIn = BinCacheUtil.canMaterialPutInBin(barcode, boxBarcode, binCode); //找到box信息
Barcode boxBarcode = null;
StoragePos inPos = null;
try {
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (inPos != null) {
boxBarcode = inPos.getBarcode();
}
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料箱条码不正确:" + boxStr);
}
if (StringUtils.isEmpty(canPutIn)) { //判断料格条码和料箱是否匹配
BackToWarehouseResult result = LuxsanApi.backToWarehouse(new BackToWarehouseRequest(CommonUtil.plantCode,binCode,"return",Arrays.asList(barcode.getBarcode()))); if (!binCode.startsWith(boxBarcode.getBarcode())) {
//String label_id = result.getLABEL_ID(); return ResultBean.newErrorResult(-1, "", "当前扫描的隔口" + binCode + "与料箱信息:" + boxStr + "不匹配");
barcode.setLabelId(result.getLABEL_ID()); }
barcode.setPosName(binCode);
barcode.setSeq(BoxHandleUtil.getSeq(boxBarcode,binCode)+1);
barcode.setPutInTime(System.currentTimeMillis());
barcode = barcodeManager.save(barcode);
generatePutInTask(barcode, boxBarcode, OP_STATUS.FINISHED.name()); //判断是否为禁用料
boxBarcode.updateSubCodes(barcode); barcode = smfApi.canPutInAfterResolve(barcode);
boxBarcode.setAmount(boxBarcode.getAmount()+barcode.getAmount());
barcodeManager.save(boxBarcode);
if(inPos != null){ //判断隔口能否放入
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新 if (boxBarcode != null) {
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos); String canPutIn = BinCacheUtil.canMaterialPutInBin(barcode, boxBarcode, binCode);
if (StringUtils.isEmpty(canPutIn)) {
BackToWarehouseResult result = LuxsanApi.backToWarehouse(new BackToWarehouseRequest(CommonUtil.plantCode, binCode, "return", Arrays.asList(barcode.getBarcode())));
//String label_id = result.getLABEL_ID();
barcode.setLabelId(result.getLABEL_ID());
barcode.setPosName(binCode);
barcode.setSeq(BoxHandleUtil.getSeq(boxBarcode, binCode) + 1);
barcode.setPutInTime(System.currentTimeMillis());
barcode = barcodeManager.save(barcode);
generatePutInTask(barcode, boxBarcode, OP_STATUS.FINISHED.name());
boxBarcode.updateSubCodes(barcode);
boxBarcode.setAmount(boxBarcode.getAmount() + barcode.getAmount());
barcodeManager.save(boxBarcode);
if (inPos != null) {
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr));
} else {
log.info(barcode.getBarcode() + "不可以放到料格:" + binCode + ",原因为:" + canPutIn);
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode + ",原因为:" + canPutIn);
} }
return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr));
} else {
log.info(barcode.getBarcode() + "不可以放到料格:" + binCode+",原因为:"+canPutIn);
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode+",原因为:"+canPutIn);
} }
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode);
} }
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode);
} }
......
...@@ -184,7 +184,7 @@ public class KafkaService { ...@@ -184,7 +184,7 @@ public class KafkaService {
for (EquipMsg equipMsg : equipMsgList) { for (EquipMsg equipMsg : equipMsgList) {
String errorCode = equipMsg.getErrorCode(); String errorCode = equipMsg.getErrorCode();
if (StringUtils.isEmpty(errorCode)){ if (StringUtils.isEmpty(errorCode) || StringUtils.isEmpty(equipMsg.getMsg())){
continue; continue;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!