Commit 42184f56 zshaohui

原材料Gr手动入库

1 个父辈 0c23fb7a
......@@ -1382,93 +1382,72 @@ public class LiteOrderCache {
for (LiteOrderItem orderItem : cacheOrder.getOrderItems()) {
int remainNum = orderItem.getNeedNum() - orderItem.getTotalOutNum();
//1.查找所有符合条件的pn
if (remainNum <= 0) {
continue;
}
Collection<String> excludePosIds = excludeOutPosIds();
//找到hold的
List<String> holdPosIdList = getHoldPosIdList(cacheOrder);
if (holdPosIdList != null && !holdPosIdList.isEmpty()) {
excludePosIds.addAll(holdPosIdList);
}
if (dataLogList != null && !dataLogList.isEmpty()) {
for (DataLog dataLog : dataLogList) {
excludePosIds.add(dataLog.getPosId());
}
}
String partNumber = orderItem.getPn();
int taskNum = 0;
int remainNum = orderItem.getNeedNum() - orderItem.getTotalOutNum();
String pn = orderItem.getPn();
String warehouseCode = orderItem.getWarehouseCode();
Criteria c = Criteria.where("barcode.partNumber").is(pn)
.and("id").nin(excludePosIds)
.and("enabled").is(true)
.and("storageId").in(storageIdList)
.and("barcode.warehouseCode").is(warehouseCode);
while (taskNum < remainNum) {
List<StoragePos> posList = storagePosManager.findByQuery(new Query(c));
log.info(orderNo + "已分配数量为:"+taskNum+",剩余数量为:"+remainNum);
if (storageIdList != null && !storageIdList.isEmpty()) {
posList.addAll(0, storagePosList);
}
Collection<String> excludePosIds = excludeOutPosIds();
if (dataLogList != null && !dataLogList.isEmpty()){
for (DataLog dataLog : dataLogList) {
excludePosIds.add(dataLog.getPosId());
}
}
if (posList == null || posList.isEmpty()) {
finishedOrderTasks(cacheOrder);
throw new ValidateException("", orderItem.getPn() + "库存不足,odn:" + cacheOrder.getOrderNo() + "无法进行出库");
}
//1.先从执行的料箱中出库
StoragePos pos = null;
if (storagePosList != null && !storagePosList.isEmpty()) {
for (StoragePos storagePos : storagePosList) {
if (excludePosIds.contains(storagePos.getId())) {
continue;
}
if (partNumber.equals(storagePos.getBarcode().getPartNumber())) {
pos = storagePos;
break;
}
}
}
//开始寻找组合数量为needOutNum的库存
List<Integer> amountList = new ArrayList<>();
for (StoragePos storagePos : posList) {
Barcode barcode = storagePos.getBarcode();
amountList.add(barcode.getQty());
if (pos == null) {
pos = storagePosManager.findPartNumberInStorages(storageIdList, partNumber, excludePosIds, checkoutType, orderItem.getBrand(),orderItem.getWarehouseCode());
}
if (pos == null) {
break;
} else {
Barcode barcode = pos.getBarcode();
log.info(barcode.getBarcode() + "需要生成出库任务,工单号为:" + orderNo+",数量为:"+barcode.getQty());
taskNum = taskNum + barcode.getQty();
taskReelCount = taskReelCount + 1;
DataLog task = newTask(pos);
task.setSourceId(cacheOrder.getId());
task.setSourceName(cacheOrder.getOrderNo());
task.setSubSourceId(orderItem.getId());
task.setSubSourceInfo(orderItem.getFeederInfo());
task.setType(OP.CHECKOUT);
task.setStatus(OP_STATUS.WAIT.name());
task.setLoc(TaskLocUtil.OUT);
if (StringUtils.isNotEmpty(barcode.getCartonId())){
task.setCartonId(barcode.getCartonId());
}
task.setOdn(true);
dataLogList.add(task);
}
}
//寻找到组合
List<List<Integer>> combinations = CombinationUtil.findCombinationsWithoutDuplicates(amountList, remainNum);
Collections.sort(combinations, Comparator.comparingInt(List::size));
if (combinations.isEmpty()) {
//如果数量不满足,则提示出来
if (taskNum < remainNum){
finishedOrderTasks(cacheOrder);
throw new ValidateException("", orderItem.getPn() + "需要出库的数量为:" + remainNum + ",未找到符合条件的组合");
throw new ValidateException("", orderItem.getPn()+"库存不足,odn:"+cacheOrder.getOrderNo()+"无法进行出库");
}
}
//开始出库
List<Integer> needOutNumList = combinations.get(0);
while (needOutNumList.size() > 0) {
Integer qty = needOutNumList.get(0);
for (StoragePos pos : posList) {
if (excludePosIds.contains(pos.getId())) {
continue;
}
Barcode barcode = pos.getBarcode();
if (barcode.getQty() == qty) {
log.info(barcode.getBarcode() + "需要生成出库任务,工单号为:" + orderNo + ",数量为:" + barcode.getQty());
taskReelCount = taskReelCount + 1;
DataLog task = newTask(pos);
task.setSourceId(cacheOrder.getId());
task.setSourceName(cacheOrder.getOrderNo());
task.setSubSourceId(orderItem.getId());
task.setSubSourceInfo(orderItem.getFeederInfo());
task.setType(OP.CHECKOUT);
task.setStatus(OP_STATUS.WAIT.name());
task.setLoc(TaskLocUtil.OUT);
if (StringUtils.isNotEmpty(barcode.getCartonId())) {
task.setCartonId(barcode.getCartonId());
}
task.setOdn(true);
dataLogList.add(task);
excludePosIds.add(pos.getId());
break;
}
}
needOutNumList.remove(0);
}
for (DataLog dataLog : dataLogList) {
taskService.addTaskToExecute(dataLog);
}
if (taskReelCount <= 0) {
......@@ -1477,9 +1456,6 @@ public class LiteOrderCache {
throw new ValidateException("smfcore.order.out.noTask", "工单无可执行的任务");
}
for (DataLog dataLog : dataLogList) {
taskService.addTaskToExecute(dataLog);
}
cacheOrder.setTaskReelCount(taskReelCount);
......
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller.manual;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
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.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.NewLabelToCellRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.QueryGrStatusRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.NewLabelToCellResult;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrStatusResult;
import com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.QueryGrStatusDto;
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.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ApiOperation("手动GR入库")
@Slf4j
@RequestMapping("/manualGr")
@RestController
public class ManualGrPutInController {
@Autowired
private CodeResolve codeResolve;
@Autowired
private SmfApi smfApi;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private TaskService taskService;
@Autowired
private DataCache dataCache;
@ApiOperation("获取GR已过账的列表")
@RequestMapping("/grStatus")
@AnonymousAccess
public ResultBean grStatus(@RequestBody Map<String, String> paramMap) {
//物料
String codeStr = paramMap.get("codeStr");
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"条码信息"});
}
//解析条码为barcode
Barcode barcode = codeResolve.resolveCode(codeStr);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "条码无效");
}
QueryGrStatusRequest request = new QueryGrStatusRequest(CommonUtil.plantCode, barcode.getProvider(), barcode.getPartNumber(), "", "");
List<QueryGrStatusResult> queryGrStatusList = LuxsanApi.queryGrStatus(request);
return ResultBean.newOkResult(QueryGrStatusDto.convertQueryGrStatusResultDto(queryGrStatusList));
}
@ApiOperation("获取料箱信息")
@RequestMapping("/getBoxInfo")
@AnonymousAccess
public ResultBean getBoxInfo(String boxStr){
if (StringUtils.isEmpty(boxStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr));
}
@ApiOperation("GR料盘入到料格")
@RequestMapping("/reelToBox")
@AnonymousAccess
public synchronized ResultBean reelToBox(@RequestBody Map<String, String> paramMap) {
String binCode = paramMap.get("binCode"); //料格信息
String udCode = paramMap.get("udCode"); //过账编码
String codeStr = paramMap.get("codeStr"); //条码信息
String warhouseCode = paramMap.get("warhouseCode"); //库别
String grCode = paramMap.get("grCode"); //GrCode
String boxStr = paramMap.get("boxStr"); //料箱信息
log.info("人工GR入库,料格信息为:" + binCode + ",过账编码为:" + udCode + "条码信息为:" + codeStr);
if (StringUtils.isEmpty(binCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料格信息"});
}
if (StringUtils.isEmpty(udCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"过账编码"});
}
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"条码信息"});
}
if (StringUtils.isEmpty(warhouseCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"库别"});
}
if (StringUtils.isEmpty(grCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"Gr信息"});
}
if (StringUtils.isEmpty(boxStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
//判断条码是否正常
Barcode barcode = null;
try {
barcode = codeResolve.resolveOneValideBarcode(codeStr);
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg());
}
//判断是否存在料箱中
if (StringUtils.isNotEmpty(barcode.getPosName())) {
log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
}
//找到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 (!binCode.startsWith(boxBarcode.getBarcode())){
return ResultBean.newErrorResult(-1,"","当前扫描的隔口"+binCode+"与料箱信息:"+boxStr+"不匹配");
}
//判断是否为禁用料
barcode = smfApi.canPutInAfterResolve(barcode);
//判断隔口能否放入
if (boxBarcode != null){
if (BinCacheUtil.canPutInBinCode(binCode, warhouseCode)) {
NewLabelToCellResult cell = LuxsanApi.newLabelToCell(new NewLabelToCellRequest(CommonUtil.plantCode, Arrays.asList(udCode), barcode.getAmount(), binCode, Arrays.asList(barcode.getFullCode())));
//将GR日期设置为生产日期
Date grDate = DateUtil.getNoTimeDate(cell.getGR_DATE());
barcode.setProduceDate(grDate);
barcode.setLabelId(cell.getLABEL_ID());
barcode.setPosName(binCode);
barcode.setWarehouseCode(warhouseCode);
barcode.setBarSource(grCode);
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));
}
}
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCode);
}
@ApiOperation("完成装箱并入库")
@RequestMapping("/boxToPos")
@AnonymousAccess
public synchronized ResultBean boxToPos(String boxStr) {
if (StringUtils.isEmpty(boxStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
//1.判断有没有正在执行的任务
List<DataLog> taskList = taskService.getAllTasks();
for (DataLog dataLog : taskList) {
if (boxStr.startsWith(dataLog.getBarcode())) {
if (!dataLog.isFinished() && !dataLog.isCancel()) {
if (dataLog.isPutInTask()) {
return ResultBean.newOkResult(dataLog);
} else {
log.info(boxStr + "有正在执行的出库任务,服务器更改状态为完成");
dataLog.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(dataLog);
}
}
}
}
//2.获取空库位
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
StoragePos pos = BoxHandleUtil.locOnePos(boxBarcode);
if (pos == null) {
return ResultBean.newErrorResult(-1, "", boxStr + "未找到可用库位");
}
//4.生成入库任务
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog dataLog = taskService.addPutInTaskToExecute(storage, boxBarcode, pos, TaskCurrentLoc.Manual_DischargeHole);
return ResultBean.newOkResult("库位为:"+dataLog.getPosName());
}
private void generatePutInTask(Barcode barcode, Barcode boxBarcode,String status) {
DataLog dataLog = new DataLog();
dataLog.setPosId(boxBarcode.getId());
dataLog.setPosName(barcode.getPosName());
dataLog.setBarcode(barcode.getBarcode());
dataLog.setW(barcode.getPlateSize());
dataLog.setH(barcode.getHeight());
dataLog.setPartNumber(barcode.getPartNumber());
dataLog.setNum(barcode.getAmount());
dataLog.setType(OP.PUT_IN);
dataLog.setStatus(status);
dataLog.setBatchInfo(barcode.getBatch());
dataLog.setSourceName(barcode.getBarSource());
dataLog.setWarehouseCode(barcode.getWarehouseCode());
taskService.updateFinishedTask(dataLog);
}
}
......@@ -25,6 +25,7 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
......@@ -62,6 +63,20 @@ public class BoxHandleUtil {
}
/**
* key 为料箱号
* value 为数量
*/
private static Map<String, Integer> boxAllCountMap = new ConcurrentHashMap<>();
/**
* key为箱号
* value为A、B面
*/
private static Map<String, String> boxSideMap = new ConcurrentHashMap<>();
public static void intoPos(DataLog opTask) {
//已完成,加入库存,并且从完成队列中清除
StoragePos storagePos = storagePosManager.get(opTask.getPosId());
......@@ -84,10 +99,10 @@ public class BoxHandleUtil {
taskService.updateFinishedTask(opTask);
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()){
if (subCodeList != null && !subCodeList.isEmpty()) {
for (Barcode subCode : subCodeList) {
if (subCode.isOut()){
log.info(barcode.getBarcode()+"有要出库的任务,需要重新出库");
if (subCode.isOut()) {
log.info(barcode.getBarcode() + "有要出库的任务,需要重新出库");
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
DataLog dataLog = new DataLog(storage, barcode, storagePos);
dataLog.setType(OP.CHECKOUT);
......@@ -138,7 +153,7 @@ public class BoxHandleUtil {
}
public static StoragePos callEmptyBox(String size,String outLet,String wareHouseCode,List<String> needBinCodeList) {
public static StoragePos callEmptyBox(String size, String outLet, String wareHouseCode, List<String> needBinCodeList) {
String box = "";
if ("7".equals(size)) {
box = "C07";
......@@ -150,8 +165,8 @@ public class BoxHandleUtil {
//判断有没有可用的料箱
List<String> boxList = BinCacheUtil.getBoxList(wareHouseCode);
if (boxList == null || boxList.isEmpty()){
log.info(wareHouseCode+"未找到可用料箱");
if (boxList == null || boxList.isEmpty()) {
log.info(wareHouseCode + "未找到可用料箱");
return null;
}
......@@ -166,7 +181,7 @@ public class BoxHandleUtil {
c.and("barcode.status").is(BARCODE_STATUS.IN_STORE);
c.and("barcode.barcode").in(boxList);
if (needBinCodeList != null && !needBinCodeList.isEmpty()){
if (needBinCodeList != null && !needBinCodeList.isEmpty()) {
List<Criteria> criteriaList = new ArrayList<>();
......@@ -214,7 +229,7 @@ public class BoxHandleUtil {
}
} else if ("13".equals(size) || "15".equals(size)) {
String binCode = barcode.getBarcode() + "-01";
if (countMap.get(binCode) == null || countMap.get(binCode) == 0){
if (countMap.get(binCode) == null || countMap.get(binCode) == 0) {
storagePos = pos;
break;
}
......@@ -226,19 +241,19 @@ public class BoxHandleUtil {
if (storagePos != null) {
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
String toLoc = "In_FeedingInlet";
if (StringUtils.isNotEmpty(outLet)){
if ("1".equals(outLet)){
if (StringUtils.isNotEmpty(outLet)) {
if ("1".equals(outLet)) {
toLoc = "In1_FeedingInlet";
} else if ("2".equals(outLet)){
} else if ("2".equals(outLet)) {
toLoc = "In2_FeedingInlet";
}
}
int priority = 0;
if (needBinCodeList != null && !needBinCodeList.isEmpty()){
if (needBinCodeList != null && !needBinCodeList.isEmpty()) {
priority = 999;
}
generateTask(storage, storagePos.getBarcode(), storagePos, OP.CHECKOUT, OP_STATUS.WAIT.name(), toLoc, ExtendType.STORAGE_CHECKOUT,priority);
generateTask(storage, storagePos.getBarcode(), storagePos, OP.CHECKOUT, OP_STATUS.WAIT.name(), toLoc, ExtendType.STORAGE_CHECKOUT, priority);
return storagePos;
}
......@@ -246,7 +261,7 @@ public class BoxHandleUtil {
}
private static DataLog generateTask(Storage storage, Barcode barcode, StoragePos pos, int type, String status, String loc, int extendType,int priority) {
private static DataLog generateTask(Storage storage, Barcode barcode, StoragePos pos, int type, String status, String loc, int extendType, int priority) {
//开始入库任务
DataLog task = new DataLog(storage, barcode, pos);
task.setType(type);
......@@ -268,7 +283,7 @@ public class BoxHandleUtil {
}
public static String getBoxStr(String code,boolean suffix) {
public static String getBoxStr(String code, boolean suffix) {
if (code.endsWith("A") || code.endsWith("B")) {
code = code.substring(0, code.length() - 1);
if (suffix) {
......@@ -287,17 +302,18 @@ public class BoxHandleUtil {
/**
* 获取序列号
*
* @param boxBarcode
* @param binCode
* @return
*/
public static int getSeq(Barcode boxBarcode,String binCode) {
public static int getSeq(Barcode boxBarcode, String binCode) {
int seq = 0;
List<Barcode> subCodeList = boxBarcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()){
if (subCodeList != null && !subCodeList.isEmpty()) {
for (Barcode barcode : subCodeList) {
if (binCode.equals(barcode.getPosName())){
if (seq < barcode.getSeq()){
if (binCode.equals(barcode.getPosName())) {
if (seq < barcode.getSeq()) {
seq = barcode.getSeq();
}
}
......@@ -306,10 +322,10 @@ public class BoxHandleUtil {
return seq;
}
public static StoragePos locOnePos(Barcode boxBarcode){
public static StoragePos locOnePos(Barcode boxBarcode) {
//判断信息是否在已经在库位中(出入库只改变料箱位置状态,不从StoragePos表中清除)
StoragePos pos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (pos != null){
if (pos != null) {
return pos;
}
......@@ -324,8 +340,8 @@ public class BoxHandleUtil {
if (pos == null) {
log.info(boxBarcode.getBarcode() + "未找到可用库位");
return null;
}else{
log.info("料箱["+boxBarcode.getBarcode()+"]信息加入库位["+pos.getPosName()+"]中");
} else {
log.info("料箱[" + boxBarcode.getBarcode() + "]信息加入库位[" + pos.getPosName() + "]中");
pos.setBarcode(boxBarcode);
pos.setUsed(true);
storagePosManager.save(pos);
......@@ -346,4 +362,142 @@ public class BoxHandleUtil {
return pos;
}
public static Map<String, Object> getBoxInfo(String code) {
Map<String, Object> resultMap = new HashMap<>();
String platsize = "";
int boxAllCount = 0;
int boxRemainingCount = 0;
String boxStr = "";
String msg = "";
List<List<Integer>> boxPartitionCounts = new ArrayList<>();
if (StringUtils.isNotBlank(code)) {
if (code.startsWith("C07") || code.startsWith("C13") || code.startsWith("C15")) {
String endStr = code.substring(code.length() - 1); //得到是A、B面
boxStr = getBoxStr(code, false);
if (boxSideMap.get(boxStr) != null) {
endStr = boxSideMap.get(boxStr);
} else {
boxSideMap.put(boxStr, endStr);
}
//1、获取料箱的
Barcode barcode = barcodeManager.findByBarcode(boxStr);
if (barcode != null) {
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
if (boxAllCountMap.get(boxStr) == null) {
boxAllCountMap.put(boxStr, subCodeList.size());
}
//进行库位分组
Map<String, Long> allCountMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
//得到需要出库的数量
Map<String, Long> needOutCountMap = new HashMap<>();
List<Barcode> outSubCodeList = subCodeList.stream().filter(s -> s.isOut()).collect(Collectors.toList());
if (outSubCodeList != null && !outSubCodeList.isEmpty()) {
needOutCountMap = outSubCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
}
List<Integer> partition1 = new ArrayList<>();
partition1.add(getCountByPartition(needOutCountMap, boxStr + "-01"));
partition1.add(getCountByPartition(allCountMap, boxStr + "-01"));
partition1.add(1);
List<Integer> partition2 = new ArrayList<>();
partition2.add(getCountByPartition(needOutCountMap, boxStr + "-02"));
partition2.add(getCountByPartition(allCountMap, boxStr + "-02"));
partition2.add(2);
List<Integer> partition3 = new ArrayList<>();
partition3.add(getCountByPartition(needOutCountMap, boxStr + "-03"));
partition3.add(getCountByPartition(allCountMap, boxStr + "-03"));
partition3.add(3);
List<Integer> partition4 = new ArrayList<>();
partition4.add(getCountByPartition(needOutCountMap, boxStr + "-04"));
partition4.add(getCountByPartition(allCountMap, boxStr + "-04"));
partition4.add(4);
List<Integer> partition5 = new ArrayList<>();
partition5.add(getCountByPartition(needOutCountMap, boxStr + "-05"));
partition5.add(getCountByPartition(allCountMap, boxStr + "-05"));
partition5.add(5);
List<Integer> partition6 = new ArrayList<>();
partition6.add(getCountByPartition(needOutCountMap, boxStr + "-06"));
partition6.add(getCountByPartition(allCountMap, boxStr + "-06"));
partition6.add(6);
//根据箱子面展示不同的隔扣
if (boxStr.startsWith("C07")) {
platsize = "7";
if ("A".equals(endStr)) {
boxPartitionCounts.add(partition2);
boxPartitionCounts.add(partition4);
boxPartitionCounts.add(partition6);
boxPartitionCounts.add(partition1);
boxPartitionCounts.add(partition3);
boxPartitionCounts.add(partition5);
} else {
boxPartitionCounts.add(partition5);
boxPartitionCounts.add(partition3);
boxPartitionCounts.add(partition1);
boxPartitionCounts.add(partition6);
boxPartitionCounts.add(partition4);
boxPartitionCounts.add(partition2);
}
} else if (boxStr.startsWith("C13")) {
platsize = "13";
if ("A".equals(endStr)) {
boxPartitionCounts.add(partition1);
boxPartitionCounts.add(partition2);
boxPartitionCounts.add(partition3);
} else {
boxPartitionCounts.add(partition3);
boxPartitionCounts.add(partition2);
boxPartitionCounts.add(partition1);
}
} else if (boxStr.startsWith("C15")) {
platsize = "15";
if ("A".equals(endStr)) {
boxPartitionCounts.add(partition1);
boxPartitionCounts.add(partition2);
boxPartitionCounts.add(partition3);
} else {
boxPartitionCounts.add(partition3);
boxPartitionCounts.add(partition2);
boxPartitionCounts.add(partition1);
}
}
boxAllCount = boxAllCountMap.get(boxStr) == null ? 0 : boxAllCountMap.get(boxStr);
boxRemainingCount = subCodeList.size();
}
}
}
}
resultMap.put("platsize", platsize);
resultMap.put("boxPartitionCounts", boxPartitionCounts);
resultMap.put("boxAllCount", boxAllCount);
resultMap.put("boxRemainingCount", boxRemainingCount);
resultMap.put("currentRfid", boxStr);
resultMap.put("box", boxStr);
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (queueTask.getBarcode().equals(boxStr)) {
if (queueTask.isCheckOutTask()) {
msg = boxStr + "需执行出库操作";//提示信息
} else {
msg = boxStr + "需执行入库操作";//提示信息
}
}
}
resultMap.put("msg", msg);
return resultMap;
}
private static int getCountByPartition(Map<String, Long> paramMap, String partition) {
return paramMap.get(partition) == null ? 0 : paramMap.get(partition).intValue();
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!