Commit 5c03f747 zshaohui

odn出货,新功能提交

1 个父辈 2f87e280
......@@ -243,6 +243,7 @@ public class DataInitManager {
addNewFunctionMenu(2, wip, "bindCarton", "人工绑定", "bindCarton", "SemiFinishProducts/bindCarton/index", "bCarton", functionMenuMap);
addNewFunctionMenu(3, wip, "Shipment", "ODN出货", "Shipment", "SemiFinishProducts/Shipment/index", "Shipment", functionMenuMap);
addNewFunctionMenu(3, wip, "odnOut", "ODN出货(新)", "odnOut", "neolight/odnOut/index", "odnOut", functionMenuMap);
addNewFunctionMenu(4, wip, "requisition", "261&931领用", "requisition", "SemiFinishProducts/requisition/index", "requisition", functionMenuMap);
......@@ -255,7 +256,7 @@ public class DataInitManager {
addNewFunctionMenu(10, wip, "restoreRebox", "ODN还原补箱", "restoreRebox", "SemiFinishProducts/restoreRebox/index", "restoreRebox", functionMenuMap);
addNewFunctionMenu(11, wip, "manualTransfer", "手动储位转移", "manualTransfer", "manualTransfer/index", "manualTransfer", functionMenuMap);
addNewFunctionMenu(12, wip, "pickBox", "出货计算", "pickBox", "SemiFinishProducts/pickBox/index", "", functionMenuMap);
addNewFunctionMenu(12, wip, "pickBox", "出货计算", "pickBox", "SemiFinishProducts/pickBox/index", "pickBox", functionMenuMap);
addNewFunctionMenu(13, wip, "checkCarton", "核验绑定信息", "checkCarton", "checkCarton/index", "checkCarton", functionMenuMap);
......
......@@ -45,6 +45,7 @@ import com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.LiteorderCheckType;
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.wipstor.util.CalculateUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.TaskLocUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -1594,7 +1595,7 @@ public class LiteOrderCache {
throw new ValidateException("", "料号:" + pn + ",库别:" + warehouseCode + "未找到可用出库的物料");
}
List<StoragePos> targetPos = findTargetPos(posList, remainNum);
List<StoragePos> targetPos = CalculateUtil.findCombinationsByPos(posList, remainNum);
if (targetPos == null || targetPos.isEmpty()) {
throw new ValidateException("", "料号:" + pn + ",库别:" + warehouseCode + "未找到符合出库的组合");
}
......
......@@ -401,6 +401,8 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
private String moveType;
private List<Barcode> needOutBarcodeList;
public void setOutReelList(String reel) {
if (outReelList == null){
outReelList = new ArrayList<>();
......
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
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.FetchShipmentInfoRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchShipmentInfoResult;
import com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.bean.dto.FetchShipmentInfoDto;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.CalculateUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.bson.json.JsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@RestController
@RequestMapping("/odnCheckOutNew")
public class OdnCheckOutNewController {
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private ILiteOrderManager liteOrderManager;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private TaskService taskService;
@ApiOperation("获取ODN详情")
@RequestMapping("/getOdnDetail")
@AnonymousAccess
public ResultBean getOdnDetail(String odn) {
if (StringUtils.isBlank(odn)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"odn"});
}
LiteOrder liteOrder = liteOrderCache.getLiteOrder(odn);
if (liteOrder == null) {
liteOrder = liteOrderManager.findByOrderNo(odn);
}
if (liteOrder == null) {
liteOrder = odnInfoToLiteOrder(odn);
}
return ResultBean.newOkResult(liteOrder);
}
@ApiOperation("获取odn要出库的箱子")
@RequestMapping("/getOdnCheckOutBox")
@AnonymousAccess
public ResultBean getOdnCheckOutBox(@RequestBody Map<String, String> paramMap) {
log.info("收到odn出库信息为:" + JSON.toJSONString(paramMap));
//判断有没有正在执行的任务
if (StringUtils.isNotEmpty(liteOrderCache.hasExecutingOrder())) {
//throw new ValidateException("","有正在执行的工单,不允许恢复");
return ResultBean.newErrorResult(-1, "", "有正在执行的工单" + liteOrderCache.hasExecutingOrder() + ",请确认");
}
String odn = paramMap.get("odn");
if (StringUtils.isEmpty(odn)) {
return ResultBean.newErrorResult(-1, "", "odn单号不能为空");
}
List<String> palletIdList = new ArrayList<>();
String palletIdListStr = paramMap.get("palletList");
if (StringUtils.isNotEmpty(palletIdListStr)) {
palletIdList = JSONObject.parseArray(palletIdListStr, String.class);
}
//判断odn是否存在
LiteOrder liteOrder = liteOrderCache.getLiteOrder(odn);
if (liteOrder == null) {
liteOrder = liteOrderManager.findByOrderNo(odn);
}
if (liteOrder == null) {
liteOrder = odnInfoToLiteOrder(odn);
}
List<String> holdPosIdList = liteOrderCache.getHoldPosIdList(liteOrder);
//List<String> holdPosIdList = new ArrayList<>();
//判断输入的栈板号是否符合条件
List<StoragePos> storagePosList = new ArrayList<>();
if (palletIdList != null && !palletIdList.isEmpty()) {
storagePosList = findPosByPalletId(palletIdList, liteOrder,holdPosIdList);
}
//开始循环处理数据
List<String> excludePosIdList = new ArrayList<>();
for (LiteOrderItem orderItem : liteOrder.getOrderItems()) {
int targetNum = orderItem.getNeedNum() - orderItem.getTotalOutNum();
if (targetNum <= 0){
continue;
}
Collection<String> excludeOutPosIds = liteOrderCache.excludeOutPosIds();
if (excludePosIdList != null && !excludePosIdList.isEmpty()) {
excludeOutPosIds.addAll(excludePosIdList);
}
if (holdPosIdList != null && !holdPosIdList.isEmpty()){
excludeOutPosIds.addAll(holdPosIdList);
}
String pn = orderItem.getPn();
String warehouseCode = orderItem.getWarehouseCode();
//获取符合条件的pn
List<StoragePos> dbStoragePosList = storagePosManager.findOdnCalculatePos(pn, warehouseCode, excludeOutPosIds);
if (dbStoragePosList == null) {
dbStoragePosList = new ArrayList<>();
}
if (storagePosList != null && !storagePosList.isEmpty()) {
dbStoragePosList.addAll(storagePosList);
}
//去重
if (dbStoragePosList == null || dbStoragePosList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "料号:" + pn + "库别:" + warehouseCode + "库存中未找到料箱");
}
Map<String, StoragePos> collect = dbStoragePosList.stream().collect(Collectors.toMap(StoragePos::getId, storagePos -> storagePos, (existing, replacement) -> existing));
dbStoragePosList = new ArrayList<>(collect.values());
List<StoragePos> combinationsPosList = CalculateUtil.findCombinationsByPos(dbStoragePosList, targetNum);
if (combinationsPosList == null || combinationsPosList.isEmpty()){
return ResultBean.newErrorResult(-1,"","料号:" + pn +"库别:"+warehouseCode+"库存中未找到对应的组合数据");
}
//加载orderItem中
for (StoragePos pos : combinationsPosList) {
excludePosIdList.add(pos.getId());
}
List<Barcode> needOutBarcodeList = new ArrayList<>();
for (StoragePos pos : combinationsPosList) {
String posName = pos.getPosName();
Barcode barcode = pos.getBarcode();
barcode.setPosName(posName);
needOutBarcodeList.add(barcode);
}
orderItem.setNeedOutBarcodeList(needOutBarcodeList);
}
return ResultBean.newOkResult(liteOrder);
}
private List<StoragePos> findPosByPalletId(List<String> palletIdList,LiteOrder order, List<String> holdPosIdList) {
List<StoragePos> storagePosList = new ArrayList<>();
for (String palletId : palletIdList) {
if (StringUtils.isBlank(palletId)) {
throw new ValidateException("", "请核实传入的栈板id是否有空数据");
}
StoragePos pos = storagePosManager.findOne(new Query(Criteria.where("barcode.palletId").is(palletId)));
if (pos == null) {
throw new ValidateException("", palletId + "不在库位中,请核实");
}
Barcode barcode = pos.getBarcode();
if (holdPosIdList != null && !holdPosIdList.isEmpty()){
if (holdPosIdList.contains(pos.getId())){
throw new ValidateException("", palletId + "已经被hold,箱子号为:"+barcode.getBarcode());
}
}
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (barcode.getBarcode().equals(dataLog.getBarcode()) && !dataLog.isFinished() && !dataLog.isCancel()) {
throw new ValidateException("", palletId + "有正在执行的任务,对应的料箱号为:" + barcode.getBarcode());
}
}
//判断当前工单的料号与出库的是否相同
boolean hasSame = false;
for (LiteOrderItem orderItem : order.getOrderItems()) {
if (barcode.getPartNumber().equals(orderItem.getPn()) || barcode.getPn().equals(orderItem.getPn())) {
if (StringUtils.isNotBlank(barcode.getWarehouseCode())) {
if (barcode.getWarehouseCode().equals(orderItem.getWarehouseCode())) {
hasSame = true;
}
}
}
}
if (!hasSame) {
throw new ValidateException( "", palletId + "不符合当前odn的料号与库别,料箱号为:"+barcode.getBarcode());
}
storagePosList.add(pos);
}
return storagePosList;
}
private LiteOrder odnInfoToLiteOrder(String odn) {
LiteOrder liteOrder = new LiteOrder();
liteOrder.setOrderNo(odn);
List<LiteOrderItem> itemList = new ArrayList<>();
List<FetchShipmentInfoResult> resultList = LuxsanApi.fetchShipmentInfo(new FetchShipmentInfoRequest(CommonUtil.plantCode, odn));
for (FetchShipmentInfoResult result : resultList) {
LiteOrderItem orderItem = new LiteOrderItem();
orderItem.setPn(result.getMATERIAL_CODE());
orderItem.setRtvId(result.getRTV_ID());
orderItem.setPlantCode(result.getPLANT_CODE());
orderItem.setTicketCode(result.getTICKET_CODE());
orderItem.setTicketItem(result.getTICKET_ITEM());
orderItem.setMaterialCode(result.getMATERIAL_CODE());
orderItem.setWarehouseCode(result.getWAREHOUSE_CODE());
orderItem.setSrcWarehouse(result.getWAREHOUSE_CODE());
orderItem.setVendorCode(result.getVENDOR_CODE());
orderItem.setQty(result.getQTY());
orderItem.setUnit(result.getUNIT());
orderItem.setStatus(result.getSTATUS());
orderItem.setOriginQty(result.getORIGIN_QTY());
orderItem.setManufacture(result.getMANUFACTURE());
orderItem.setImportMode(result.getIMPORT_MODE());
orderItem.setImportCode(result.getIMPORT_CODE());
orderItem.setShipTo(result.getSHIP_TO());
//orderItem.setPn(result.getMATERIAL_CODE());
orderItem.setNeedNum(result.getQTY());
itemList.add(orderItem);
}
liteOrder.setOrderItems(itemList);
liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
return liteOrder;
}
}
......@@ -24,8 +24,8 @@ public class CalculateUtil {
for (StoragePos pos : storagePosList) {
Map<Integer, List<StoragePos>> temp = new HashMap<>(sumCounts); // 复制当前的和值映射,避免在迭代过程中修改
for (Map.Entry<Integer, List<StoragePos>> entry : temp.entrySet()) {
if (System.currentTimeMillis() - now >= 1000 * 60) {
log.info(target+"计算超过一分钟,退出");
if (System.currentTimeMillis() - now >= 1000 * 20) {
log.info(target+"计算超过20s,退出");
return new ArrayList<>();
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!