Commit 35d882b9 zshaohui

盘点功能 优化提交

1 个父辈 33d99616
...@@ -291,4 +291,9 @@ public class BarcodeDto implements Serializable { ...@@ -291,4 +291,9 @@ public class BarcodeDto implements Serializable {
@ApiModelProperty("标签id") @ApiModelProperty("标签id")
private String labelId; private String labelId;
//出库异常信息
private String outExpInfo = "";
private Map<String,String> extraDataMap = new HashMap<>();
} }
...@@ -33,6 +33,8 @@ import com.neotel.smfcore.custom.lizhen.agvBox.service.manager.InventoryDataMana ...@@ -33,6 +33,8 @@ import com.neotel.smfcore.custom.lizhen.agvBox.service.manager.InventoryDataMana
import com.neotel.smfcore.custom.lizhen.agvBox.util.BoxUtil; import com.neotel.smfcore.custom.lizhen.agvBox.util.BoxUtil;
import com.neotel.smfcore.custom.lizhen.agvBox.util.StationCacheUtil; import com.neotel.smfcore.custom.lizhen.agvBox.util.StationCacheUtil;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType; import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.luxsan.api.bean.request.QueryBinRequest;
import com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil;
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.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;
...@@ -120,35 +122,69 @@ public class InventoryController { ...@@ -120,35 +122,69 @@ public class InventoryController {
break; break;
} }
} }
int count = storagePosManager.countByQuery(new Query(Criteria.where("storageId").is(storageId))); //统计箱子总数
Query query = new Query(Criteria.where("storageId").is(storageId));
query.fields().include("posName", "barcode.barcode","barcode.extraDataMap");
List<StoragePos> storagePosList = storagePosManager.findByQuery(query);
//开始获取已经盘点的料箱信息
String inventoryBatch = dataCache.getCache(INVENTORY_DATA) + ""; String inventoryBatch = dataCache.getCache(INVENTORY_DATA) + "";
if (StringUtils.isNotBlank(inventoryBatch) && !"-1".equals(inventoryBatch)) { if (StringUtils.isNotBlank(inventoryBatch) && !"-1".equals(inventoryBatch)) {
List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch)/*.and("status").is(InventoryStatus.FINISHED.name())*/)); List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch)));
if (dataList != null && !dataList.isEmpty()) { if (dataList != null && !dataList.isEmpty()) {
List<String> posNameList = new ArrayList<>(); //料箱库位有变化,重新赋值
for (InventoryData data : dataList) { for (InventoryData data : dataList) {
boolean isFinished = isInventoryDataFinshed(data.getPosName(), dataList); for (StoragePos pos : storagePosList) {
if (isFinished) { Barcode barcode = pos.getBarcode();
if (posNameList.isEmpty()) { if (barcode != null){
posNameList.add(data.getPosName()); if (barcode.getBarcode().equals(data.getBox())){
} else { data.setPosName(pos.getPosName());
if (!posNameList.contains(data.getPosName())) { data.setOriPosName(pos.getPosName());
posNameList.add(data.getPosName()); //data.setExtraDataMap(barcode.getExtraDataMap());
break;
} }
} }
} }
} }
inventoryCount = posNameList.size(); //判断是否盘点完成
for (InventoryData data : dataList) {
boolean isFinished = isInventoryDataFinshed(data.getPosName(), dataList);
if (isFinished){
inventoryCount++;
}
}
//获取到哪一列已经盘点完成
finishInventory = getFinishInventoryPosName(storagePosList, dataList);
} }
finishInventory = getFinishInventoryPosName(inventoryBatch, dataList);
} }
List<String> outExpBox = getOutExpBarcodePosName(storagePosList);
resultMap.put("inventoryCount", inventoryCount); resultMap.put("inventoryCount", inventoryCount);
resultMap.put("count", count); resultMap.put("count", storagePosList.size());
resultMap.put("inventoryBatch", StringUtils.isBlank(inventoryBatch) || "-1".equals(inventoryBatch) ? "" : inventoryBatch); resultMap.put("inventoryBatch", StringUtils.isBlank(inventoryBatch) || "-1".equals(inventoryBatch) ? "" : inventoryBatch);
resultMap.put("finishInventory", finishInventory); resultMap.put("finishInventory", finishInventory);
resultMap.put("outExpBox",outExpBox);
return ResultBean.newOkResult(resultMap); return ResultBean.newOkResult(resultMap);
} }
private List<String> getOutExpBarcodePosName(List<StoragePos> storagePosList) {
List<String> posNameList = new ArrayList<>();
for (StoragePos pos : storagePosList) {
Barcode barcode = pos.getBarcode();
if (barcode != null) {
Map<String, String> extraDataMap = barcode.getExtraDataMap();
if (extraDataMap != null && !extraDataMap.isEmpty()) {
for (String key : extraDataMap.keySet()) {
if (key.startsWith(CommonUtil.outExpPrefix)) {
posNameList.add(pos.getPosName());
break;
}
}
}
}
}
return posNameList;
}
private boolean isInventoryDataFinshed(String posName, List<InventoryData> dataList) { private boolean isInventoryDataFinshed(String posName, List<InventoryData> dataList) {
boolean isFinished = true; boolean isFinished = true;
for (InventoryData data : dataList) { for (InventoryData data : dataList) {
...@@ -163,7 +199,6 @@ public class InventoryController { ...@@ -163,7 +199,6 @@ public class InventoryController {
return isFinished; return isFinished;
} }
/** /**
* 开始盘点 * 开始盘点
* *
...@@ -229,48 +264,60 @@ public class InventoryController { ...@@ -229,48 +264,60 @@ public class InventoryController {
@RequestMapping("/getStoragePosData") @RequestMapping("/getStoragePosData")
//@AnonymousAccess //@AnonymousAccess
public List<StoragePosDto> getStoragePosData(String posName) { public List<StoragePosDto> getStoragePosData(String posName) {
List<Storage> storageList = new ArrayList<>(); List<StoragePosDto> resultList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
if (!storage.isVirtual()) { //获取盘点批次
storageList.add(storage);
}
}
String inventoryBatch = dataCache.getCache(INVENTORY_DATA) + ""; String inventoryBatch = dataCache.getCache(INVENTORY_DATA) + "";
//获取所有库位信息
for (Storage storage : storageList) { //模糊查询,对应的所有库位信息
List<StoragePos> storagePosList = storagePosManager.findByQuery(inventoryQuery(posName, storage.getId(), null)); Query query = new Query(Criteria.where("posName").regex(posName));
List<StoragePosDto> resultList = new ArrayList<>(); query.fields().exclude("barcode.subCodeList");
List<StoragePosDto> storagePosDtos = storagePosMapper.toDto(storagePosList); List<StoragePos> storagePosList = storagePosManager.findByQuery(query);
if (inventoryBatch != null) { if (storagePosList != null && !storagePosList.isEmpty()) {
for (StoragePosDto pos : storagePosDtos) {
BarcodeDto barcode = pos.getBarcode(); //提取到所有料箱信息
if (barcode != null) { List<StoragePosDto> storagePosDtoList = storagePosMapper.toDto(storagePosList);
if (barcode.getStatus() != BARCODE_STATUS.IN_STORE) { for (StoragePosDto pos : storagePosDtoList) {
pos.setBarcode(null); BarcodeDto barcode = pos.getBarcode();
} else { if (barcode != null) {
List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch).and("box").is(barcode.getBarcode()))); List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch)
if (dataList != null && !dataList.isEmpty()) { .and("box").is(barcode.getBarcode())));
List<String> statusList = new ArrayList<>(); if (dataList != null && !dataList.isEmpty()) {
for (InventoryData data : dataList) { List<String> statusList = new ArrayList<>();
statusList.add(data.getStatus()); for (InventoryData data : dataList) {
} statusList.add(data.getStatus());
if (statusList.contains(InventoryStatus.NEW.name())) { }
pos.setInventoryStatus(InventoryStatus.NEW.name()); if (statusList.contains(InventoryStatus.NEW.name())) {
} else if (!statusList.contains(InventoryStatus.NEW.name()) && statusList.contains(InventoryStatus.EXECUTING.name())) { pos.setInventoryStatus(InventoryStatus.NEW.name());
pos.setInventoryStatus(InventoryStatus.EXECUTING.name()); } else if (!statusList.contains(InventoryStatus.NEW.name()) && statusList.contains(InventoryStatus.EXECUTING.name())) {
} else if (!statusList.contains(InventoryStatus.NEW.name()) && !statusList.contains(InventoryStatus.EXECUTING.name())) { pos.setInventoryStatus(InventoryStatus.EXECUTING.name());
pos.setInventoryStatus(InventoryStatus.FINISHED.name()); } else if (!statusList.contains(InventoryStatus.NEW.name()) && !statusList.contains(InventoryStatus.EXECUTING.name())) {
pos.setInventoryStatus(InventoryStatus.FINISHED.name());
}
}
//判断是否有异常
Map<String, String> extraDataMap = barcode.getExtraDataMap();
if (extraDataMap != null && !extraDataMap.isEmpty()) {
for (String key : extraDataMap.keySet()) {
if (key.startsWith(CommonUtil.outExpPrefix)) {
String outExpInfo = barcode.getOutExpInfo();
String value = extraDataMap.get(key);
if (StringUtils.isNotEmpty(outExpInfo)) {
barcode.setOutExpInfo(outExpInfo + "," + value);
} else {
barcode.setOutExpInfo(value);
} }
} }
} }
} }
resultList.add(pos);
} }
resultList.add(pos);
} }
}
if (resultList != null && !resultList.isEmpty()) {
resultList = resultList.stream().sorted(Comparator.comparing(StoragePosDto::getPosName).reversed()).collect(Collectors.toList()); resultList = resultList.stream().sorted(Comparator.comparing(StoragePosDto::getPosName).reversed()).collect(Collectors.toList());
return resultList;
} }
return new ArrayList<>(); return resultList;
} }
...@@ -283,7 +330,6 @@ public class InventoryController { ...@@ -283,7 +330,6 @@ public class InventoryController {
@RequestMapping("/inventoryOut") @RequestMapping("/inventoryOut")
//@AnonymousAccess //@AnonymousAccess
public synchronized ResultBean inventoryOut(@RequestBody List<String> storagePosIdList) { public synchronized ResultBean inventoryOut(@RequestBody List<String> storagePosIdList) {
String msg = "";
String inventoryBatch = dataCache.getCache(INVENTORY_DATA) + ""; String inventoryBatch = dataCache.getCache(INVENTORY_DATA) + "";
if (StringUtils.isBlank(inventoryBatch) || "-1".equals(inventoryBatch)) { if (StringUtils.isBlank(inventoryBatch) || "-1".equals(inventoryBatch)) {
return ResultBean.newErrorResult(-1, "", "请点击开始盘点"); return ResultBean.newErrorResult(-1, "", "请点击开始盘点");
...@@ -291,80 +337,63 @@ public class InventoryController { ...@@ -291,80 +337,63 @@ public class InventoryController {
if (storagePosIdList == null || storagePosIdList.isEmpty()) { if (storagePosIdList == null || storagePosIdList.isEmpty()) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"库位"}); return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"库位"});
} }
if (storagePosIdList != null && !storagePosIdList.isEmpty()) { //查询料箱信息
List<StoragePos> storagePosList = storagePosManager.findByQuery(inventoryQuery(null, null, storagePosIdList)); Query query = new Query(Criteria.where("id").in(storagePosIdList));
if (storagePosList == null || storagePosList.isEmpty()) { List<StoragePos> storagePosList = storagePosManager.findByQuery(query);
return ResultBean.newErrorResult(-1, "smfcore.label.noReel", "未找到可出库的物料"); //开始循环处理数据
} for (StoragePos pos : storagePosList) {
//判断料箱在不在库
//查询到料箱信息 Barcode barcode = pos.getBarcode();
List<String> barcodeList = new ArrayList<>(); if (barcode == null || barcode.getStatus() != BARCODE_STATUS.IN_STORE) {
for (StoragePos pos : storagePosList) { return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不在库,请核实");
Barcode barcode = pos.getBarcode();
if (barcode != null) {
if (barcode.getStatus() != BARCODE_STATUS.IN_STORE) {
log.info(barcode.getBarcode() + "料箱不在库,跳过");
} else {
barcodeList.add(barcode.getBarcode());
}
}
} }
//判断是否有未完成的任务
//判断是否已经生成盘点记录 String barcodeStr = barcode.getBarcode();
List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch).and("box").in(barcodeList))); List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch).and("box").is(barcodeStr)));
if (dataList != null && !dataList.isEmpty()) { if (dataList != null && !dataList.isEmpty()) {
List<String> boxList = dataList.stream().map(InventoryData::getBox).collect(Collectors.toList()); return ResultBean.newErrorResult(-1, "", "料箱:" + barcodeStr + "已经进行过盘点出库,请核实");
boxList = boxList.stream().distinct().collect(Collectors.toList());
return ResultBean.newErrorResult(-1, "", JsonUtil.toJsonStr(boxList) + "已经进行过盘点出库,请核实");
} }
//判断是否有未完成的任务 //判断是否有未完成的任务
List<DataLog> allTasks = taskService.getAllTasks(); List<DataLog> allTasks = taskService.getAllTasks();
for (String barcodeStr : barcodeList) { for (DataLog dataLog : allTasks) {
for (DataLog dataLog : allTasks) { if (barcodeStr.equals(dataLog.getBarcode())) {
if (!dataLog.isFinished() && !dataLog.isCancel()) { if (!dataLog.isFinished() && !dataLog.isCancel()) {
if (barcodeStr.equals(dataLog.getBarcode())) { return ResultBean.newErrorResult(-1, "", barcodeStr + "有未完成出库/入库任务,请核实");
log.info(barcodeStr + "有未完成的任务");
return ResultBean.newErrorResult(-1, "", barcodeStr + "有未完成的任务,请确认");
}
} }
} }
} }
}
for (StoragePos pos : storagePosList) { //开始生成出库任务
log.info("盘点出库的库位为:" + pos.getPosName()); String msg = "";
Barcode barcode = pos.getBarcode(); for (StoragePos pos : storagePosList) {
if (barcode != null) { Barcode barcode = pos.getBarcode();
if (barcode.getStatus() != BARCODE_STATUS.IN_STORE) { if (barcode == null || barcode.getStatus() != BARCODE_STATUS.IN_STORE) {
continue; continue;
}
log.info("盘点出库的物料为:" + barcode.getBarcode());
Storage storage = dataCache.getStorageById(pos.getStorageId());
//生成出库任务
DataLog dataLog = new DataLog(storage, barcode, pos);
dataLog.setType(OP.CHECKOUT);
dataLog.setCreator(SecurityUtils.getLoginUsername());
dataLog.setExtendType(ExtendType.INVENTORY_CHECKOUT); //盘点出库
dataLog.setInventoryBatch(dataCache.getCache(INVENTORY_DATA));
dataLog.setLoc(TaskCurrentLoc.Manual_FeedingInlet);
dataLog.setSourceName("盘点出库");
try {
taskService.addTaskToExecute(dataLog);
} catch (Exception e) {
log.error("盘点出库失败:", e);
msg = StringUtils.isBlank(msg) ? dataLog.getBarcode() : msg + "," + dataLog.getBarcode();
continue;
}
}
//生成盘点数据
generateInventoryData(barcode, pos);
} }
log.info("盘点出库的物料为:" + barcode.getBarcode() + ",库位为:" + pos.getPosName());
Storage storage = dataCache.getStorageById(pos.getStorageId());
//生成出库任务
DataLog dataLog = new DataLog(storage, barcode, pos);
dataLog.setType(OP.CHECKOUT);
dataLog.setCreator(SecurityUtils.getLoginUsername());
dataLog.setExtendType(ExtendType.INVENTORY_CHECKOUT); //盘点出库
dataLog.setInventoryBatch(dataCache.getCache(INVENTORY_DATA));
dataLog.setLoc(TaskCurrentLoc.Manual_FeedingInlet);
dataLog.setSourceName("盘点出库");
try {
taskService.addTaskToExecute(dataLog);
} catch (Exception e) {
log.error("盘点出库失败:", e);
msg = StringUtils.isBlank(msg) ? dataLog.getBarcode() : msg + "," + dataLog.getBarcode();
continue;
}
//生成盘点数据
generateInventoryData(barcode, pos);
} }
if (StringUtils.isNotBlank(msg)) { ResultBean resultBean = ResultBean.newOkResult("");
msg = msg + "已经有出入库任务请核实"; resultBean.setMsg(msg);
return ResultBean.newOkResult("", "", msg); return resultBean;
}
return ResultBean.newOkResult("");
} }
...@@ -688,6 +717,11 @@ public class InventoryController { ...@@ -688,6 +717,11 @@ public class InventoryController {
data.setPosName(pos.getPosName()); data.setPosName(pos.getPosName());
inventoryDataManager.save(data); inventoryDataManager.save(data);
} else { } else {
//获取到异常出库的数据
Map<String, String> extraDataMap = barcode.getExtraDataMap();
if (extraDataMap == null){
extraDataMap = new HashMap<>();
}
List<Barcode> subCodeList = barcode.getSubCodeList(); List<Barcode> subCodeList = barcode.getSubCodeList();
String partition = getInventoryPartition(subCodeList); String partition = getInventoryPartition(subCodeList);
String boxStr = barcode.getBarcode(); String boxStr = barcode.getBarcode();
...@@ -712,7 +746,9 @@ public class InventoryController { ...@@ -712,7 +746,9 @@ public class InventoryController {
data.setAmout(partitionNum); data.setAmout(partitionNum);
data.setInventoryBatch(inventoryBatch); data.setInventoryBatch(inventoryBatch);
data.setOriPosName(posName); data.setOriPosName(posName);
if (partition.equals(boxStr + "-0" + i)) {
String boxPar = boxStr + "-0" + i;
if (partition.equals(boxPar) || extraDataMap.get(CommonUtil.outExpPrefix+boxPar) != null) {
data.setNeedInventory(true); data.setNeedInventory(true);
} else { } else {
data.setNeedInventory(false); data.setNeedInventory(false);
...@@ -742,45 +778,71 @@ public class InventoryController { ...@@ -742,45 +778,71 @@ public class InventoryController {
} }
private Query inventoryQuery(String posName, String storageId, List<String> storagePosIdList) { private List<String> getFinishInventoryPosName(List<StoragePos> storagePosList, List<InventoryData> dataList) {
Query query = new Query(); List<String> finishPosName = new ArrayList<>();
//Criteria criteria = Criteria.where("barcode.status").is(BARCODE_STATUS.IN_STORE);
Criteria criteria = new Criteria(); //构造数据
if (storagePosIdList != null && !storagePosIdList.isEmpty()) { Map<String, List<String>> cachePosNameMap = new HashMap<>();
criteria.and("id").in(storagePosIdList); for (StoragePos pos : storagePosList) {
} String posName = pos.getPosName();
if (StringUtils.isNotBlank(storageId)) { Barcode barcode = pos.getBarcode();
criteria.and("storageId").is(storageId); if(barcode != null){
} posName = posName.substring(0,posName.length()-3);
if (StringUtils.isNotBlank(posName)) { List<String> cacheBarcodeList = cachePosNameMap.get(posName);
Pattern pattern = Pattern.compile(QueryHelp.escapeExprSpecialWord(posName), Pattern.CASE_INSENSITIVE); if (cacheBarcodeList == null){
criteria.and("posName").regex(pattern); cacheBarcodeList = new ArrayList<>();
}
cacheBarcodeList.add(barcode.getBarcode());
cachePosNameMap.put(posName,cacheBarcodeList);
}
} }
//获取到在库的库存信息
query.addCriteria(criteria);
//query.fields().include("barcode", "updateDate", "storageId","posName");
return query;
}
private List<String> getFinishInventoryPosName(String inventoryBatch,List<InventoryData> dataList) { //开始循环处理数据
List<String> finishPosName = new ArrayList<>(); for (String key : cachePosNameMap.keySet()) {
//List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch))); List<String> barcodeList = cachePosNameMap.get(key);
//获取原始库位 if (barcodeList == null || barcodeList.isEmpty()){
List<String> oriPosNameList = dataList.stream().map(InventoryData::getOriPosName).collect(Collectors.toList()); finishPosName.add(key);
oriPosNameList = oriPosNameList.stream().distinct().collect(Collectors.toList()); } else {
for (String oriPosName : oriPosNameList) { boolean hasData = true;
boolean isFinished = true; for (String barcodeStr : barcodeList) {
for (InventoryData data : dataList) { boolean hasSameData = false;
if (data.getOriPosName().equals(oriPosName)){ for (InventoryData data : dataList) {
if (!data.getStatus().equals(InventoryStatus.FINISHED.name())){ if (barcodeStr.equals(data.getBox())){
isFinished = false; hasSameData =true;
break;
}
}
if (!hasSameData){
hasData = false;
break; break;
} }
} }
if (!hasData){
continue;
}
//判断是否全部完成
boolean finished = true;
for (String barcodeStr : barcodeList) {
for (InventoryData data : dataList) {
if (barcodeStr.equals(data.getBox())) {
if (!data.getStatus().equals(InventoryStatus.FINISHED.name())){
finished = false;
break;
}
}
}
if (!finished){
break;
}
}
if (finished){
finishPosName.add(key);
}
} }
if (isFinished) { }
finishPosName.add(oriPosName); if (finishPosName != null && !finishPosName.isEmpty()) {
} finishPosName = finishPosName.stream().distinct().collect(Collectors.toList());
} }
return finishPosName; return finishPosName;
} }
......
...@@ -12,4 +12,6 @@ public class CommonUtil { ...@@ -12,4 +12,6 @@ public class CommonUtil {
private void setPlantCode(String code){ private void setPlantCode(String code){
CommonUtil.plantCode = code; CommonUtil.plantCode = code;
} }
public static String outExpPrefix = "Out_Exp";
} }
...@@ -1213,119 +1213,110 @@ public class CDeviceController { ...@@ -1213,119 +1213,110 @@ public class CDeviceController {
log.info("物料放到料串上,通知出库,隔口号为:" + boxPar + ",条码信息为:" + code + "当前位置为:" + currentLoc + "条码编号为:" + stacker); log.info("物料放到料串上,通知出库,隔口号为:" + boxPar + ",条码信息为:" + code + "当前位置为:" + currentLoc + "条码编号为:" + stacker);
//code为1,代表数据异常
if (StringUtils.isEmpty(boxPar)) {
saveMessage(MessageType.ERROR.name(), currentLoc, "料箱隔口号不能为空");
return ResultBean.newErrorResult(1, "", "料箱隔口号不能为空");
}
Barcode boxBarcode = null; Barcode alearyOutBarcode = null;
String box = BoxHandleUtil.getBoxStr(boxPar, false); try {
StoragePos pos = storagePosManager.getByBarcode(box); if (StringUtils.isEmpty(code)) {
if (pos != null) { saveMessage(MessageType.ERROR.name(), currentLoc, "未扫到条码信息");
boxBarcode = pos.getBarcode(); } else {
} else { alearyOutBarcode = codeResolve.resolveOneValideBarcode(code);
boxBarcode = barcodeManager.findByBarcode(box); }
} catch (Exception e) {
log.info("解析出库的条码失败:", e);
saveMessage(MessageType.ERROR.name(), currentLoc, code + "解析条码失败,错误信息为:" + e.getMessage());
} }
if (boxBarcode == null) {
saveMessage(MessageType.ERROR.name(), currentLoc, "料箱隔口号:" + boxPar + "对应的料箱信息不存在");
return ResultBean.newErrorResult(2, "", "料箱隔口号:" + boxPar + "对应的料箱信息不存在");
//1.解析条码内容
//Barcode binCode = codeResolve.resolveOneValideBarcode(boxStr);
//解析料箱信息
String box = BoxHandleUtil.getBoxStr(boxPar, true);
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(box);
StoragePos inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (inPos != null) {
boxBarcode = inPos.getBarcode();
//log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料从料格中出库");
} }
List<Barcode> subCodeList = boxBarcode.getSubCodeList();
//2.获取要出库的code
int seq = BoxHandleUtil.getSeq(boxBarcode, boxPar);
Barcode barcode = null; Barcode barcode = null;
//如果code为空,或者为"noCode",则寻找第一盘 for (Barcode subCode : subCodeList) {
if (StringUtils.isEmpty(code) || "noCode".equals(code)) { if (seq == subCode.getSeq() && boxPar.equals(subCode.getPosName())) {
int seq = BoxHandleUtil.getSeq(boxBarcode, boxPar); barcode = subCode;
for (Barcode subCode : boxBarcode.getSubCodeList()) { break;
if (seq == subCode.getSeq() && boxPar.equals(subCode.getPosName())) {
barcode = subCode;
break;
}
} }
saveMessage(MessageType.ERROR.name(), currentLoc, "条码信息为空,寻找到序列号为:" + seq);
//return ResultBean.newErrorResult(1, "", "条码信息不能为空");
} else {
barcode = codeResolve.resolveOneValideBarcode(code);
} }
//3.判断barcode是否为空
if (barcode == null) { if (barcode == null) {
saveMessage(MessageType.ERROR.name(), currentLoc, "条码:" + code + "解析失败"); return ResultBean.newErrorResult(-1, "", "未找到可以出库的物料");
return ResultBean.newErrorResult(2, "", "条码:" + code + "解析失败");
} }
//更新料串缓存信息 //更新料串缓存信息
// log.info("先清空:" + stacker + "位置缓存的信息"); //log.info("先清空:"+materialStr+"位置缓存的信息");
// MaterialLocUtil.updateStackerLoc(stacker, "", null,); //MaterialLocUtil.updateStackerLoc(materialStr,"",null);
//code为3时,代表不在此箱子中,直接出库/通知WMS失败 List<Barcode> barcodeList = new ArrayList<>();
List<String> messageList = new ArrayList<>(); for (Barcode subCode : subCodeList) {
String posName = barcode.getPosName(); if (boxPar.equals(subCode.getPosName())) {
log.info("当前料箱是:" + boxPar + "要出库的料盘信息为:" + barcode.getBarcode() + "对应的库位为:" + posName); barcodeList.add(subCode);
if (!boxPar.equals(posName)) {
//先清空数据
if (StringUtils.isNotEmpty(posName)) {
Barcode newBoxBarcode = null;
String newBoxStr = BoxHandleUtil.getBoxStr(posName, false);
StoragePos newPos = storagePosManager.getByBarcode(newBoxStr);
if (newPos != null) {
newBoxBarcode = newPos.getBarcode();
} else {
newBoxBarcode = barcodeManager.findByBarcode(newBoxStr);
}
if (newBoxBarcode != null) {
newBoxBarcode.removeFromSubCodes(barcode);
barcodeManager.save(newBoxBarcode);
if (newPos != null) {
newPos.setBarcode(newBoxBarcode);
storagePosManager.save(newPos);
}
}
} }
messageList.add(barcode.getBarcode() + "对应的库位为:" + posName + "与当前要出库的料箱隔口号:" + boxPar + "不一致"); }
saveMessage(MessageType.WARNING.name(), currentLoc, barcode.getBarcode() + "对应的库位为:" + posName + "与当前要出库的料箱隔口号:" + boxPar + "不一致");
} else { //判断barcode是否为需要出库的
List<Barcode> subCodeList = boxBarcode.getSubCodeList(); if (!barcode.isOut()) {
//找到对应的料箱隔口,判断是否有要出的物料信息 log.info(barcode.getBarcode() + "不是要出库的料盘");
List<Barcode> barcodeList = new ArrayList<>(); Barcode needOutBarcode = null;
for (Barcode subCode : subCodeList) { for (Barcode subCode : barcodeList) {
if (boxPar.equals(subCode.getPosName())) { if (subCode.isOut()) {
barcodeList.add(subCode); needOutBarcode = subCode;
break;
} }
} }
if (!barcode.isOut()) { if (needOutBarcode != null) {
log.info(barcode.getBarcode() + "不是要出库的料盘,隔口号为:" + boxPar); String orderItemId = needOutBarcode.getOrderItemId();
Barcode needOutBarcode = null; needOutBarcode.setOrderItemId("");
for (Barcode subCode : barcodeList) { needOutBarcode.setOut(false);
if (subCode.isOut()) { log.info(needOutBarcode.getBarcode() + "需要改成不需要出库");
needOutBarcode = subCode; barcodeManager.save(needOutBarcode);
break; boxBarcode.updateSubCodes(needOutBarcode);
} barcode.setOut(true);
} barcode.setOrderItemId(orderItemId);
if (needOutBarcode != null) { log.info(barcode.getBarcode() + "改成要出库,orderItemId为:" + orderItemId);
String orderItemId = needOutBarcode.getOrderItemId(); }
needOutBarcode.setOrderItemId(""); }
needOutBarcode.setOut(false);
log.info(needOutBarcode.getBarcode() + "需要改成不需要出库"); //判断是否异常
barcodeManager.save(needOutBarcode); if (alearyOutBarcode != null) {
boxBarcode.updateSubCodes(needOutBarcode); String barcodeStr = alearyOutBarcode.getBarcode();
barcode.setOut(true); if (!barcodeStr.equals(barcode.getBarcode())) {
barcode.setOrderItemId(orderItemId); saveMessage(MessageType.ERROR.name(), currentLoc, "传入的条码为:" + barcodeStr + ",按顺序出库的条码为:" + barcode.getBarcode() + "不一致");
barcodeManager.save(barcode); boxBarcode.updateExtraData(CommonUtil.outExpPrefix + boxPar, boxPar);
boxBarcode.updateSubCodes(barcode);
barcodeManager.save(boxBarcode);
if (pos != null) {
pos.setBarcode(boxBarcode);
storagePosManager.save(pos);
}
log.info(barcode.getBarcode() + "改成要出库,orderItemId为:" + orderItemId);
}
} }
} }
log.info(barcode.getBarcode() + "从" + boxPar + "出库,位置为:" + currentLoc + "料串为:" + stacker);
//4.开始生成出库任务
log.info(barcode.getBarcode() + "从" + boxPar + "出库,序列号为:" + seq + ".位置为:" + currentLoc);
if (!barcode.isOut()) {
return ResultBean.newErrorResult(-1, "", barcode.getPosName() + "没有要出库的料盘");
}
String orderItemId = barcode.getOrderItemId(); String orderItemId = barcode.getOrderItemId();
String orderId = ""; String orderId = "";
String orderNo = ""; String orderNo = "";
if (StringUtils.isNotEmpty(orderItemId)) { if (StringUtils.isNotEmpty(orderItemId)) {
int checkType = -1; int checkType = -1;
String pkItemId = ""; String pkItemId = "";
String face = ""; String face = "";
...@@ -1348,35 +1339,65 @@ public class CDeviceController { ...@@ -1348,35 +1339,65 @@ public class CDeviceController {
checkType = order.getCheckType(); checkType = order.getCheckType();
} }
} }
//同时 更新下 缓存目的地
if (StringUtils.isNotEmpty(targetLoc)) { //通知WMS
if (targetLoc.endsWith("BG")) {
log.info("自动绑定料串[" + stacker + "]目的地:C2-3F-BG");
MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-BG",1,orderNo);
} else if (targetLoc.endsWith("CG")) {
log.info("自动绑定料串[" + stacker + "]目的地:C2-3F-CG");
MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-CG",1,orderNo);
}
}
if (checkType == LiteorderCheckType.PICKING_CHECKOUT) { if (checkType == LiteorderCheckType.PICKING_CHECKOUT) {
try { try {
LuxsanApi.pickingIssue(new PickingIssueRequest(CommonUtil.plantCode, orderNo, pkItemId, barcode.getPartNumber() LuxsanApi.pickingIssue(new PickingIssueRequest(CommonUtil.plantCode, orderNo, pkItemId, barcode.getPartNumber()
, barcode.getWarehouseCode(), brand, face, batchCode, Arrays.asList(barcode.getBarcode()))); , barcode.getWarehouseCode(), brand, face, batchCode, Arrays.asList(barcode.getBarcode())));
//同时 更新下 缓存目的地
if (StringUtils.isNotEmpty(targetLoc)) {
if (targetLoc.endsWith("BG")) {
log.info("自动绑定料串[" + stacker + "]目的地:C2-3F-BG");
MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-BG", 1, orderItem.getOrderNo());
} else if (targetLoc.endsWith("CG")) {
log.info("自动绑定料串[" + stacker + "]目的地:C2-3F-CG");
MaterialLocUtil.updateStackerLoc(stacker, "", "C2-3F-CG", 1, orderItem.getOrderNo());
}
}
} catch (Exception e) { } catch (Exception e) {
saveMessage(MessageType.ERROR.name(), currentLoc, "通知WMS失败:" + e.getMessage() + "隔口号为" + boxPar); log.info(barcode.getBarcode() + "PK发料失败:" + e.getMessage() + ",隔口:" + barcode.getPosName() + "需要清空出库信息");
log.info(barcode.getBarcode() + "通知WMS失败:" + e.getMessage() + "隔口号为" + boxPar);
List<Barcode> newSubCodeList = new ArrayList<>();
for (Barcode subCode : boxBarcode.getSubCodeList()) {
if (subCode.isOut()) {
if (barcode.getPosName().equals(subCode.getPosName())) {
newSubCodeList.add(subCode);
}
}
}
for (Barcode subCode : newSubCodeList) {
if (subCode.isOut()) {
if (barcode.getPosName().equals(subCode.getPosName())) {
String itemId = subCode.getOrderItemId();
subCode.setOut(false);
subCode.setSelectMsg(null);
subCode.setOrderItemId(null);
barcodeManager.save(subCode);
boxBarcode.updateSubCodes(subCode);
//生成任务
generateTask(subCode, OP_STATUS.CANCEL.name(), subCode.getAmount(), OP.CHECKOUT, itemId, "", 0, false);
log.info(subCode.getBarcode() + "隔口为:" + subCode.getPosName() + "需清除出库标记");
}
}
}
barcodeManager.save(boxBarcode);
if (inPos != null) {
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "请求PK发料失败,隔口:" + barcode.getPosName() + "出库信息已清空");
} }
} }
} else { } else {
//人工出库, //人工出库,
try { LuxsanApi.pickingIssue(new PickingIssueRequest(CommonUtil.plantCode, "SMFW" + System.currentTimeMillis(), "0", barcode.getPartNumber()
LuxsanApi.pickingIssue(new PickingIssueRequest(CommonUtil.plantCode, "SMFW" + System.currentTimeMillis(), "0", barcode.getPartNumber() , barcode.getWarehouseCode(), "", "", "", Arrays.asList(barcode.getBarcode())));
, barcode.getWarehouseCode(), "", "", "", Arrays.asList(barcode.getBarcode())));
} catch (Exception e) {
saveMessage(MessageType.ERROR.name(), currentLoc, "通知WMS失败:" + e.getMessage() + "隔口号为" + boxPar);
log.info(barcode.getBarcode() + "通知WMS失败:" + e.getMessage() + "隔口号为" + boxPar);
}
} }
DataLog dataLog = new DataLog(new Storage(), barcode, new StoragePos()); DataLog dataLog = new DataLog(new Storage(), barcode, new StoragePos());
dataLog.setSubSourceId(orderItemId); dataLog.setSubSourceId(orderItemId);
...@@ -1400,15 +1421,14 @@ public class CDeviceController { ...@@ -1400,15 +1421,14 @@ public class CDeviceController {
boxBarcode.updateExtraData(barcode.getPosName(), null); boxBarcode.updateExtraData(barcode.getPosName(), null);
boxBarcode.removeFromSubCodes(barcode); boxBarcode.removeFromSubCodes(barcode);
barcodeManager.save(boxBarcode); barcodeManager.save(boxBarcode);
if (pos != null) { if (inPos != null) {
//为保证数据一致性, pos中的box barcode也需要更新 //为保证数据一致性, pos中的box barcode也需要更新
pos.setBarcode(boxBarcode); inPos.setBarcode(boxBarcode);
storagePosManager.save(pos); storagePosManager.save(inPos);
} }
saveMessage(MessageType.INFO.name(), currentLoc, barcode.getBarcode() + "从料箱隔口号:" + barcode.getPosName() + "出库成功");
//清理条码档案信息 //清理条码档案信息
log.info(barcode.getBarcode() + "的库位设置为空");
barcode.setPosName(""); barcode.setPosName("");
barcode.setOut(false); barcode.setOut(false);
barcode.setOrderId(""); barcode.setOrderId("");
...@@ -1416,10 +1436,9 @@ public class CDeviceController { ...@@ -1416,10 +1436,9 @@ public class CDeviceController {
barcode.setBarSource(""); barcode.setBarSource("");
barcodeManager.save(barcode); barcodeManager.save(barcode);
Map<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
resultMap.put("binCode", boxPar); resultMap.put("binCode", boxPar);
//resultMap.put("seq",seq+""); resultMap.put("seq", seq + "");
resultMap.put("barcode", barcode.getBarcode()); resultMap.put("barcode", barcode.getBarcode());
resultMap.put("pickingId", orderNo); resultMap.put("pickingId", orderNo);
resultMap.put("platSize", barcode.getPlateSize() + ""); resultMap.put("platSize", barcode.getPlateSize() + "");
......
...@@ -391,6 +391,20 @@ public class ManualGrPutInController { ...@@ -391,6 +391,20 @@ public class ManualGrPutInController {
} }
boxBarcode.setSubCodeList(newSubCodeList); boxBarcode.setSubCodeList(newSubCodeList);
//清除标记
Map<String, String> extraDataMap = boxBarcode.getExtraDataMap();
if (extraDataMap != null && !extraDataMap.isEmpty()){
Map<String, String> resultMap = new HashMap<>();
for (String key: extraDataMap.keySet()) {
if (key.startsWith(CommonUtil.outExpPrefix)){
continue;
}
resultMap.put(key,extraDataMap.get(key));
}
boxBarcode.setExtraDataMap(resultMap);
}
boxBarcode = barcodeManager.save(boxBarcode); boxBarcode = barcodeManager.save(boxBarcode);
//同时更新pos表 //同时更新pos表
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!