完成物料多库位出库

This commit is contained in:
Stang 2024-11-15 17:38:39 +08:00
parent d079737970
commit e6a7bc32d8
4 changed files with 205 additions and 81 deletions

View File

@ -30,6 +30,7 @@ import com.ktg.common.enums.BusinessType;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo;
import static com.ktg.common.utils.SecurityUtils.getUsername;
import static com.ktg.generator.util.MultiModuleCodeGenerator.generateTaskCode;
/**
@ -448,6 +449,7 @@ public class BaseKnifeController extends BaseController {
baseKnifeOriginList.add(item);
item.setPlanSheet(planSheet);
item.setIsLocked(1);
item.setKnifeFineState(2);
item.setLockedStartTime(techBom.getLockedStartTime());
item.setLockedEndTime(techBom.getLockedEndTime());
baseKnifeService.updateBaseKnife(item);
@ -518,7 +520,7 @@ public class BaseKnifeController extends BaseController {
}
}
// 锁定 组刀
// 组刀
MdItem mdItem;
List<BaseKnife> baseKnifeList;
int count;
@ -543,7 +545,6 @@ public class BaseKnifeController extends BaseController {
if ("PRODUCT".equals(mdItem.getItemOrProduct())) {
// 查询整刀bom项 如果不存在说明 为基础物料或者没有记录此整刀的组装
bomRouteTemp.setMdItemId(mdItem.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
@ -572,6 +573,99 @@ public class BaseKnifeController extends BaseController {
}
}
// 生成出库计划单
WmsOutPlan outPlan = new WmsOutPlan();
outPlan.setPlanCode(planSheet);
outPlan.setWmsBusinessTypeId(16L);
outPlan.setPlanState("1");
outPlan.setPlanType("ZDCK");
outPlan.setCreateTime(DateUtils.getNowDate());
wmsOutPlanMapper.insertWmsOutPlan(outPlan);
String batchNum = "SCZBPC01";
// 出库任务进行基础物料的出库
HashMap<Long, HashMap<String, List<BaseKnife>>> baseKnifeHashMapMap = new HashMap<>();
// 遍历构建map
baseKnifeOriginList.forEach(item -> {
// 判断当前物料主键是否已经被收录
baseKnifeHashMapMap.computeIfAbsent(item.getMbbBdMrlId(), k -> new HashMap<>());
// 判断当前库位编码是否已经被收录
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).computeIfAbsent(item.getAreaCode(), k -> new ArrayList<>());
// 对当前台账对象进行收录
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).get(item.getAreaCode()).add(item);
});
// 生成出库计划明细
WmsOutPlan outPlanTemp = outPlan;
baseKnifeHashMapMap.keySet().forEach(mdItemId -> {
MdItem mdItemOutPlan = mdItemService.selectMdItemById(mdItemId);
// 根据库位编码遍历
baseKnifeHashMapMap.get(mdItemId).keySet().forEach(areaCode -> {
// 获得库位对象
WmStorageArea wmStorageAreaOutPlan = wmStorageAreaService.selectWmStorageAreaByAreaCode(areaCode);
WmsOutPlanDetail outPlanDetail = new WmsOutPlanDetail();
outPlanDetail.setWmsOutPlanId(outPlanTemp.getWmsOutPlanId());
outPlanDetail.setMdItemId(mdItemId);
outPlanDetail.setMdItemCode(mdItemOutPlan.getItemCode());
outPlanDetail.setMdItemName(mdItemOutPlan.getItemName());
outPlanDetail.setMdItemUnit(mdItemOutPlan.getUnitName());
outPlanDetail.setPlannedQuantity(baseKnifeHashMapMap.get(mdItemId).get(areaCode).size());
outPlanDetail.setRealQuantity(baseKnifeHashMapMap.get(mdItemId).get(areaCode).size());
outPlanDetail.setDetailBatchNum(batchNum);
outPlanDetail.setWmStorageAreaId(wmStorageAreaOutPlan.getAreaId());
outPlanDetail.setWmStorageAreaCode(wmStorageAreaOutPlan.getAreaCode());
outPlanDetail.setWmStorageAreaName(wmStorageAreaOutPlan.getAreaName());
outPlanDetail.setDetailState("1");
outPlanDetail.setCreateTime(DateUtils.getNowDate());
wmsOutPlanMapper.insertWmsOutPlanDetail(outPlanDetail);
// 遍历台账对象
baseKnifeHashMapMap.get(mdItemId).get(areaCode).forEach(item -> {
// 构建出库计划明细实体
WmsOutPlanDetailEntity wmsOutPlanDetailEntity = new WmsOutPlanDetailEntity();
wmsOutPlanDetailEntity.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
wmsOutPlanDetailEntity.setBaseKnifeId(item.getBaseKnifeId());
wmsOutPlanDetailEntity.setAreaCode(item.getAreaCode());
wmsOutPlanDetailEntity.setItemOrProduct(item.getItemOrProduct());
wmsOutPlanDetailEntity.setKnifeCode(item.getKnifeCode());
wmsOutPlanDetailEntity.setKnifeName(item.getKnifeName());
wmsOutPlanDetailEntity.setPlanSheet(item.getPlanSheet());
wmsOutPlanDetailEntity.setKnifeLife(item.getKnifeLife());
wmsOutPlanDetailEntity.setResetCount(item.getResetCount());
wmsOutPlanDetailEntity.setKnifeUnit(item.getKnifeUnit());
wmsOutPlanDetailEntity.setSafeStock(item.getKnifeType());
wmsOutPlanDetailEntity.setStandardQuantity(item.getStandardQuantity());
wmsOutPlanDetailEntity.setCreateTime(DateUtils.getNowDate());
wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity);
});
// 生成出库任务
WmsOutTask wmsOutTask = new WmsOutTask();
wmsOutTask.setWmsOutPlanId(outPlanTemp.getWmsOutPlanId());
wmsOutTask.setWmsOutPlanCode(outPlanTemp.getPlanCode());
wmsOutTask.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
// 出库类型 12组刀出库
wmsOutTask.setWmsBusinessTypeId(12L);
wmsOutTask.setTaskCode(generateTaskCode("CKT"));
wmsOutTask.setTaskNumber(outPlanDetail.getPlannedQuantity());
wmsOutTask.setOutNumber(outPlanDetail.getRealQuantity());
wmsOutTask.setWmStorageAreaId(outPlanDetail.getWmStorageAreaId());
wmsOutTask.setBatchNum(batchNum);
wmsOutTask.setMdItemId(outPlanDetail.getMdItemId());
wmsOutTask.setMdItemCode(outPlanDetail.getMdItemCode());
wmsOutTask.setMdItemName(outPlanDetail.getMdItemName());
wmsOutTask.setMdItemUnit(outPlanDetail.getMdItemUnit());
wmsOutTask.setTaskState("1");
wmsOutTask.setRecipientUsername("");
wmsOutTask.setCreateTime(DateUtils.getNowDate());
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
});
});
operLog.setJsonResult(msg);
operLog.setStatus(0);
operLogService.insertOperlog(operLog);
@ -830,7 +924,6 @@ public class BaseKnifeController extends BaseController {
wmsInTask.setPlanInStatus("1");
wmsInTaskService.insertWmsInTask(wmsInTask);
// 更新组装任务
zdTask.setStatus("1");
zdTask.setQtyOk(zdTask.getProductIdQty());

View File

@ -77,6 +77,8 @@ public class BaseKnife extends BaseEntity {
@Excel(name = "库区编码")
private String areaCode;
private String areaName;
/**
* 刀具寿命
*/
@ -415,6 +417,14 @@ public class BaseKnife extends BaseEntity {
this.zdTaskId = zdTaskId;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
@Override
public String toString() {
return "BaseKnife{" +

View File

@ -1,7 +1,6 @@
package com.ktg.mes.wm.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.core.domain.AjaxResult;
@ -190,11 +189,11 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
}
// 出库基础物料 根据图号查询出库计划如果不存在生成计划存在则往计划中添加任务
WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getPlanSheet());
WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getCode());
if (outPlan == null) {
// 构建新的出库计划
WmsOutPlan outPlanTemp = new WmsOutPlan();
outPlanTemp.setPlanCode(zdTask.getPlanSheet() == null ? zdTask.getCode() : zdTask.getPlanSheet());
outPlanTemp.setPlanCode(zdTask.getCode());
// 组刀出库
outPlanTemp.setWmsBusinessTypeId(16L);
outPlanTemp.setPlanState("1");
@ -206,7 +205,6 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
}
// 锁定物料
Boolean outPlanFlag = true;
for (int i = 0; i < zdTask.getProductIdQty(); i++) {
// 构建整刀
BaseKnife baseKnife = new BaseKnife();
@ -247,27 +245,6 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
baseKnifeWrapper.setIsLocked(0);
baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
if (outPlanFlag) {
// 出库任务进行基础物料的出库
MdItem mdItemOutPlan = mdItemMapper.selectMdItemById(mbbProduBom.getMdItemId());
WmsOutPlanDetail outPlanDetail = new WmsOutPlanDetail();
outPlanDetail.setWmsOutPlanId(outPlan.getWmsOutPlanId());
outPlanDetail.setMdItemId(mbbProduBom.getMdItemId());
outPlanDetail.setMdItemCode(mdItemOutPlan.getItemCode());
outPlanDetail.setMdItemName(mdItemOutPlan.getItemName());
outPlanDetail.setMdItemUnit(mdItemOutPlan.getUnitName());
outPlanDetail.setPlannedQuantity(mbbProduBom.getStandardDosage() * zdTask.getProductIdQty());
outPlanDetail.setRealQuantity(mbbProduBom.getStandardDosage() * zdTask.getProductIdQty());
outPlanDetail.setDetailBatchNum(batchNum);
// 查询库位信息
wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(zdTask.getAreaId());
outPlanDetail.setWmStorageAreaId(wmStorageArea.getAreaId());
outPlanDetail.setWmStorageAreaCode(wmStorageArea.getAreaCode());
outPlanDetail.setWmStorageAreaName(wmStorageArea.getAreaName());
outPlanDetail.setDetailState("1");
wmsOutPlanDetailList.add(outPlanDetail);
}
// 锁定基础 物料
int bomCount = mbbProduBom.getStandardDosage();
for (BaseKnife wmsBaseKnife : baseKnifeList) {
@ -281,6 +258,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
wmsBaseKnife.setPlanSheet(zdTask.getPlanSheet());
baseKnifeListOutPlan.add(wmsBaseKnife);
baseKnifeMapper.updateBaseKnife(wmsBaseKnife);
bomCount--;
// 记录刀片重置次数
resetCount += wmsBaseKnife.getResetCount();
@ -289,60 +267,96 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
}
// 更新重置次数
outPlanFlag = false;
baseKnife.setResetCount(resetCount - 1);
baseKnifeMapper.updateBaseKnife(baseKnife);
// 出库任务进行基础物料的出库
HashMap<Long, HashMap<String, List<BaseKnife>>> baseKnifeHashMapMap = new HashMap<>();
// 遍历构建map
baseKnifeListOutPlan.forEach(item -> {
// 判断当前物料主键是否已经被收录
baseKnifeHashMapMap.computeIfAbsent(item.getMbbBdMrlId(), k -> new HashMap<>());
// 判断当前库位编码是否已经被收录
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).computeIfAbsent(item.getAreaCode(), k -> new ArrayList<>());
// 对当前台账对象进行收录
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).get(item.getAreaCode()).add(item);
});
// 生成出库计划明细
WmsOutPlan outPlanTemp = outPlan;
baseKnifeHashMapMap.keySet().forEach(mdItemId -> {
MdItem mdItemOutPlan = mdItemMapper.selectMdItemById(mdItemId);
// 根据库位编码遍历
baseKnifeHashMapMap.get(mdItemId).keySet().forEach(areaCode -> {
// 获得库位对象
WmStorageArea wmStorageAreaOutPlan = wmStorageAreaMapper.selectWmStorageAreaByAreaCode(areaCode);
WmsOutPlanDetail outPlanDetail = new WmsOutPlanDetail();
outPlanDetail.setWmsOutPlanId(outPlanTemp.getWmsOutPlanId());
outPlanDetail.setMdItemId(mdItemId);
outPlanDetail.setMdItemCode(mdItemOutPlan.getItemCode());
outPlanDetail.setMdItemName(mdItemOutPlan.getItemName());
outPlanDetail.setMdItemUnit(mdItemOutPlan.getUnitName());
outPlanDetail.setPlannedQuantity(baseKnifeHashMapMap.get(mdItemId).get(areaCode).size());
outPlanDetail.setRealQuantity(baseKnifeHashMapMap.get(mdItemId).get(areaCode).size());
outPlanDetail.setDetailBatchNum(batchNum);
outPlanDetail.setWmStorageAreaId(wmStorageAreaOutPlan.getAreaId());
outPlanDetail.setWmStorageAreaCode(wmStorageAreaOutPlan.getAreaCode());
outPlanDetail.setWmStorageAreaName(wmStorageAreaOutPlan.getAreaName());
outPlanDetail.setDetailState("1");
outPlanDetail.setCreateBy(getUsername());
outPlanDetail.setCreateTime(DateUtils.getNowDate());
wmsOutPlanMapper.insertWmsOutPlanDetail(outPlanDetail);
// 遍历台账对象
baseKnifeHashMapMap.get(mdItemId).get(areaCode).forEach(item -> {
// 构建出库计划明细实体
WmsOutPlanDetailEntity wmsOutPlanDetailEntity = new WmsOutPlanDetailEntity();
wmsOutPlanDetailEntity.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
wmsOutPlanDetailEntity.setBaseKnifeId(item.getBaseKnifeId());
wmsOutPlanDetailEntity.setAreaCode(item.getAreaCode());
wmsOutPlanDetailEntity.setItemOrProduct(item.getItemOrProduct());
wmsOutPlanDetailEntity.setKnifeCode(item.getKnifeCode());
wmsOutPlanDetailEntity.setKnifeName(item.getKnifeName());
wmsOutPlanDetailEntity.setPlanSheet(item.getPlanSheet());
wmsOutPlanDetailEntity.setKnifeLife(item.getKnifeLife());
wmsOutPlanDetailEntity.setResetCount(item.getResetCount());
wmsOutPlanDetailEntity.setKnifeUnit(item.getKnifeUnit());
wmsOutPlanDetailEntity.setSafeStock(item.getKnifeType());
wmsOutPlanDetailEntity.setStandardQuantity(item.getStandardQuantity());
wmsOutPlanDetailEntity.setCreateBy(getUsername());
wmsOutPlanDetailEntity.setCreateTime(DateUtils.getNowDate());
wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity);
});
// 生成出库任务
WmsOutTask wmsOutTask = new WmsOutTask();
wmsOutTask.setWmsOutPlanId(outPlanTemp.getWmsOutPlanId());
wmsOutTask.setWmsOutPlanCode(outPlanTemp.getPlanCode());
wmsOutTask.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
// 出库类型 12组刀出库
wmsOutTask.setWmsBusinessTypeId(12L);
wmsOutTask.setTaskCode(generateTaskCode("CKT"));
wmsOutTask.setTaskNumber(outPlanDetail.getPlannedQuantity());
wmsOutTask.setOutNumber(outPlanDetail.getRealQuantity());
wmsOutTask.setWmStorageAreaId(outPlanDetail.getWmStorageAreaId());
wmsOutTask.setBatchNum(batchNum);
wmsOutTask.setMdItemId(outPlanDetail.getMdItemId());
wmsOutTask.setMdItemCode(outPlanDetail.getMdItemCode());
wmsOutTask.setMdItemName(outPlanDetail.getMdItemName());
wmsOutTask.setMdItemUnit(outPlanDetail.getMdItemUnit());
wmsOutTask.setTaskState("1");
wmsOutTask.setRecipientUsername("");
wmsOutTask.setCreateBy(getUsername());
wmsOutTask.setCreateTime(DateUtils.getNowDate());
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
});
});
}
// 出库
int i = 0;
for (WmsOutPlanDetail outPlanDetail : wmsOutPlanDetailList) {
wmsOutPlanMapper.insertWmsOutPlanDetail(outPlanDetail);
// 出库计划明细绑定实体
for (int j = 0; j < outPlanDetail.getPlannedQuantity(); j++) {
WmsOutPlanDetailEntity wmsOutPlanDetailEntity = new WmsOutPlanDetailEntity();
wmsOutPlanDetailEntity.setBaseKnifeId(baseKnifeListOutPlan.get(i).getBaseKnifeId());
wmsOutPlanDetailEntity.setAreaCode(baseKnifeListOutPlan.get(i).getAreaCode());
wmsOutPlanDetailEntity.setItemOrProduct(baseKnifeListOutPlan.get(i).getItemOrProduct());
wmsOutPlanDetailEntity.setKnifeCode(baseKnifeListOutPlan.get(i).getKnifeCode());
wmsOutPlanDetailEntity.setKnifeName(baseKnifeListOutPlan.get(i).getKnifeName());
wmsOutPlanDetailEntity.setPlanSheet(baseKnifeListOutPlan.get(i).getPlanSheet());
wmsOutPlanDetailEntity.setKnifeLife(baseKnifeListOutPlan.get(i).getKnifeLife());
wmsOutPlanDetailEntity.setResetCount(baseKnifeListOutPlan.get(i).getResetCount());
wmsOutPlanDetailEntity.setKnifeUnit(baseKnifeListOutPlan.get(i).getKnifeUnit());
wmsOutPlanDetailEntity.setSafeStock(baseKnifeListOutPlan.get(i).getKnifeType());
wmsOutPlanDetailEntity.setStandardQuantity(baseKnifeListOutPlan.get(i++).getStandardQuantity());
wmsOutPlanDetailEntity.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
wmsOutPlanDetailEntity.setCreateBy(getUsername());
wmsOutPlanDetailEntity.setCreateTime(DateUtils.getNowDate());
wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity);
}
// 生成出库任务
WmsOutTask wmsOutTask = new WmsOutTask();
wmsOutTask.setWmsOutPlanId(outPlan.getWmsOutPlanId());
wmsOutTask.setWmsOutPlanCode(outPlan.getPlanCode());
wmsOutTask.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
// 出库类型 12组刀出库
wmsOutTask.setWmsBusinessTypeId(12L);
wmsOutTask.setTaskCode(generateTaskCode(outPlan.getPlanCode()));
wmsOutTask.setTaskNumber(outPlanDetail.getPlannedQuantity());
wmsOutTask.setOutNumber(outPlanDetail.getRealQuantity());
wmsOutTask.setWmStorageAreaId(outPlanDetail.getWmStorageAreaId());
wmsOutTask.setBatchNum(batchNum);
wmsOutTask.setMdItemId(outPlanDetail.getMdItemId());
wmsOutTask.setMdItemCode(outPlanDetail.getMdItemCode());
wmsOutTask.setMdItemName(outPlanDetail.getMdItemName());
wmsOutTask.setMdItemUnit(outPlanDetail.getMdItemUnit());
wmsOutTask.setTaskState("1");
wmsOutTask.setRecipientUsername("");
wmsOutTask.setCreateBy(getUsername());
wmsOutTask.setCreateTime(DateUtils.getNowDate());
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
}
// 更新组装任务
zdTask.setStatus("1");
// zdTask.setQtyOk(zdTask.getProductIdQty());
@ -495,13 +509,13 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
// 整刀入库计划, 根据图号查询入库计划如果不存在生成计划存在则往计划中添加任务
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(zdTask.getAreaId());
WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getPlanSheet());
WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getCode());
if (wmsInPlan == null) {
WmsInPlan wmsInPlanTemp = new WmsInPlan();
wmsInPlanTemp.setState("1");
wmsInPlanTemp.setSourceType("SGLR");
wmsInPlanTemp.setCellCode(wmStorageArea.getAreaCode());
wmsInPlanTemp.setPlanCode(zdTask.getPlanSheet() == null ? zdTask.getCode() : zdTask.getPlanSheet());
wmsInPlanTemp.setPlanCode(zdTask.getCode());
wmsInPlanTemp.setRelBillCode("组装单据");
wmsInPlanTemp.setPlanTypeId("13");
wmsInPlanTemp.setCreateBy(getUsername());
@ -566,6 +580,10 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
baseKnifeMapper.updateBaseKnife(baseKnife);
});
// 生成出库任务
// 更新组装任务
zdTask.setStatus("2");
zdTask.setQtyOk(zdTask.getProductIdQty());

View File

@ -14,6 +14,7 @@
<result property="safeStock" column="SAFE_STOCK"/>
<result property="standardQuantity" column="STANDARD_QUANTITY"/>
<result property="areaCode" column="AREA_CODE"/>
<result property="areaName" column="AREA_NAME"/>
<result property="knifeLife" column="KNIFE_LIFE"/>
<result property="knifeFineState" column="KNIFE_FINE_STATE"/>
<result property="isLocked" column="IS_LOCKED"/>
@ -81,6 +82,7 @@
BK.SAFE_STOCK,
BK.STANDARD_QUANTITY,
BK.AREA_CODE,
WSA.AREA_NAME AREA_NAME,
BK.KNIFE_LIFE,
BK.KNIFE_FINE_STATE,
BK.IS_LOCKED,
@ -104,6 +106,7 @@
from BASE_KNIFE BK
LEFT JOIN MD_ITEM MI on BK.MBB_BD_MRL_ID = MI.ITEM_ID
LEFT JOIN MD_ITEM_TYPE MIT ON MI.ITEM_TYPE_ID = MIT.ITEM_TYPE_ID
LEFT JOIN WM_STORAGE_AREA WSA ON WSA.AREA_CODE = BK.AREA_CODE
</sql>
<select id="selectBaseKnifeList" parameterType="BaseKnife" resultMap="BaseKnifeResult">