初步完成生产准备改造

This commit is contained in:
Stang 2024-11-06 15:51:45 +08:00
parent 17e64f7c75
commit 1ea32ca5e5
6 changed files with 74 additions and 29 deletions

View File

@ -306,11 +306,15 @@ public class BaseKnifeController extends BaseController
@PostMapping("/open/productionArrangements")
@ResponseBody
public AjaxResult productionArrangements(@RequestBody String json) {
// 验证请求数据
List<BaseTechnologyBom> technologyBomList = JSON.parseArray(json, BaseTechnologyBom.class);
if (technologyBomList.isEmpty() || technologyBomList.size() == 1 && technologyBomList.get(0).getKnifeCode() == null)
return AjaxResult.error("未检测到工艺bom项");
technologyBomList.forEach(baseTechnologyBom -> baseTechnologyBomService.insertBaseTechnologyBom(baseTechnologyBom));
// 记录数据修改
List<BaseKnife> baseKnifeOriginList = new ArrayList<>();
// 构建日志
SysOperLog operLog = new SysOperLog();
operLog.setTitle("生产准备");
@ -340,6 +344,7 @@ public class BaseKnifeController extends BaseController
// 台账表中查询工具 并记录数量
mdItemTemp = mdItemService.selectMdItemByCode(techBom.getKnifeCode());
if (mdItemTemp == null){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("物料台账查询错误:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("物料台账查询错误", techBom.getKnifeCode());
@ -358,12 +363,12 @@ public class BaseKnifeController extends BaseController
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
}
BomRoute bomRoute = bomRouteService.selectBomRouteByBomRouteId(bomRouteList.get(0).getBomRouteId());
if (!bomRoute.getMbbProduBomList().isEmpty()) {
@ -376,6 +381,7 @@ public class BaseKnifeController extends BaseController
sitmTempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
if (sitmTempList.isEmpty()){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
@ -383,6 +389,7 @@ public class BaseKnifeController extends BaseController
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()){
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
@ -393,17 +400,20 @@ public class BaseKnifeController extends BaseController
// 判断基础物料是否充足
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
}
}
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("暂无记录整刀bom项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("暂无记录整刀bom项", techBom.getKnifeCode());
}
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足", techBom.getKnifeCode());
@ -412,8 +422,16 @@ public class BaseKnifeController extends BaseController
// 将物料填入集合
tempList.forEach(item -> {
if (knifeCount.get() > 0 && tempList.size() > countMap.get(item.getKnifeCode())) {
// 更新数量
knifeCount.getAndDecrement();
countMap.put(item.getKnifeCode(), countMap.get(item.getKnifeCode()) + 1);
// 记录源数据然后锁定
baseKnifeOriginList.add(item);
item.setPlanSheet(techBom.getTechnologyBomId());
item.setIsLocked(1);
item.setLockedStartTime(techBom.getLockedStartTime());
item.setLockedEndTime(techBom.getLockedEndTime());
baseKnifeService.updateBaseKnife(item);
}
});
if (knifeCount.get() > 0) {
@ -423,6 +441,7 @@ public class BaseKnifeController extends BaseController
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
@ -440,6 +459,7 @@ public class BaseKnifeController extends BaseController
sitmTempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
if (sitmTempList.isEmpty()){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
@ -447,6 +467,7 @@ public class BaseKnifeController extends BaseController
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()){
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
@ -457,17 +478,20 @@ public class BaseKnifeController extends BaseController
// 判断基础物料是否充足
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
}
}
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("暂无记录整刀bom项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("暂无记录整刀bom项", techBom.getKnifeCode());
}
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足", techBom.getKnifeCode());
@ -504,6 +528,7 @@ public class BaseKnifeController extends BaseController
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
@ -511,14 +536,16 @@ public class BaseKnifeController extends BaseController
WmsZdTask wmsZdTask = new WmsZdTask();
wmsZdTask.setmProductId(mdItem.getItemId());
wmsZdTask.setCode(techBom.getProcessCode() + mdItem.getItemCode());
wmsZdTask.setName(techBom.getProcessName() + "[" + mdItem.getItemName() + "]");
wmsZdTask.setAttr4(techBom.getTechnologyBomId());
wmsZdTask.setCode(techBom.getProcessCode());
wmsZdTask.setName(techBom.getProcessName());
wmsZdTask.setProductIdQty(count);
wmsZdTask.setAttr1(bomRouteList.get(0).getBomRouteId());
wmsZdTask.setCreateTime(DateUtils.getNowDate());
zdTaskService.insertWmsZdTask(wmsZdTask);
msg = "生产准备验证成功!已生成组装任务!";
msg = "生产准备验证成功!缺少物料已生成组装任务!";
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("缺少BOM项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("缺少BOM项", techBom.getKnifeCode());
@ -541,10 +568,8 @@ public class BaseKnifeController extends BaseController
@PutMapping("/zdTask")
public AjaxResult zdTask(@RequestBody WmsZdTask zdTask)
{
String planSheet = "JHD001";
String batchNum = "ZZPC001";
// 判断物料是否充足
BomRoute bomRoute = bomRouteService.selectBomRouteByBomRouteId(zdTask.getAttr1());
BaseKnife baseKnifeWrapper = new BaseKnife();
@ -561,8 +586,19 @@ public class BaseKnifeController extends BaseController
List<WmsOutPlanDetail> wmsOutPlanDetailList = new ArrayList<>();
List<BaseKnife> baseKnifeListOutPlan = new ArrayList<>();
// 查询工艺bom
BaseTechnologyBom technologyBom = new BaseTechnologyBom();
if (zdTask.getAttr4() != null){
technologyBom = baseTechnologyBomService.selectBaseTechnologyBomByTechnologyBomId(zdTask.getAttr4());
} else {
technologyBom.setFigureCode(zdTask.getCode());
technologyBom.setLockedStartTime(DateUtils.getNowDate());
technologyBom.setLockedEndTime(DateUtils.getNowDate());
}
// 出库基础物料
WmsOutPlan outPlan = new WmsOutPlan();
outPlan.setPlanCode(zdTask.getCode());
outPlan.setPlanCode(technologyBom.getFigureCode());
outPlan.setWmsBusinessTypeId(12L);
outPlan.setPlanState("1");
outPlan.setPlanType("ZDCK");
@ -573,6 +609,7 @@ public class BaseKnifeController extends BaseController
// 锁定物料
Boolean outPlanFlag = true;
for (int i = 0; i < zdTask.getProductIdQty(); i++) {
// 构建整刀
BaseKnife baseKnife = new BaseKnife();
MdItem mdItem = mdItemService.selectMdItemById(zdTask.getmProductId());
baseKnife.setMbbBdMrlId(zdTask.getmProductId());
@ -581,17 +618,20 @@ public class BaseKnifeController extends BaseController
baseKnife.setKnifeUnit(mdItem.getUnitName());
baseKnife.setKnifeType(mdItem.getItemTypeName());
baseKnife.setAreaCode(zdTask.getAttr3());
baseKnife.setSafeStock(mdItem.getMinStock().toString().split("\\.")[0]);
baseKnife.setSafeStock(mdItem.getMinStock());
baseKnife.setStandardQuantity("1");
baseKnife.setKnifeLife(100);
baseKnife.setKnifeFineState(0);
baseKnife.setIsLocked(0);
baseKnife.setPlanSheet(planSheet);
baseKnife.setIsLocked(1);
baseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
baseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
baseKnife.setPlanSheet(zdTask.getAttr4());
baseKnife.setItemOrProduct("PRODUCT");
baseKnife.setCreateBy(getUsername());
baseKnife.setCreateTime(DateUtils.getNowDate());
baseKnifeService.insertBaseKnife(baseKnife);
// 锁定物料
int resetCount = 0;
for (MbbProduBom mbbProduBom : bomRoute.getMbbProduBomList()) {
baseKnifeWrapper.setMbbBdMrlId(mbbProduBom.getMdItemId());
@ -599,6 +639,7 @@ public class BaseKnifeController extends BaseController
baseKnifeList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
if (outPlanFlag) {
// 出库任务
MdItem mdItemOutPlan = mdItemService.selectMdItemById(mbbProduBom.getMdItemId());
WmsOutPlanDetail outPlanDetail = new WmsOutPlanDetail();
outPlanDetail.setWmsOutPlanId(outPlan.getWmsOutPlanId());
@ -617,13 +658,14 @@ public class BaseKnifeController extends BaseController
wmsOutPlanDetailList.add(outPlanDetail);
}
// 锁定物料
int bomCount = mbbProduBom.getStandardDosage();
for (BaseKnife wmsBaseKnife : baseKnifeList){
if (bomCount > 0){
wmsBaseKnife.setIsLocked(1);
wmsBaseKnife.setKnifeFineState(2);
wmsBaseKnife.setLockedStartTime(new Date());
wmsBaseKnife.setLockedEndTime(new Date());
wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
wmsBaseKnife.setAttr1(baseKnife.getBaseKnifeId());
baseKnifeListOutPlan.add(wmsBaseKnife);
baseKnifeService.updateBaseKnife(wmsBaseKnife);
@ -633,15 +675,18 @@ public class BaseKnifeController extends BaseController
}
}
// 更新重置次数
outPlanFlag = false;
baseKnife.setResetCount(resetCount);
baseKnifeService.updateBaseKnife(baseKnife);
}
// 出库
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());
@ -651,6 +696,7 @@ public class BaseKnifeController extends BaseController
wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity);
}
// 出库任务
WmsOutTask wmsOutTask = new WmsOutTask();
wmsOutTask.setWmsOutPlanId(outPlan.getWmsOutPlanId());
wmsOutTask.setWmsOutPlanCode(outPlan.getPlanCode());
@ -672,17 +718,19 @@ public class BaseKnifeController extends BaseController
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
}
// 整刀入库计划
Random random = new Random();
WmsInPlan wmsInPlan = new WmsInPlan();
wmsInPlan.setState("1");
wmsInPlan.setSourceType("SGLR");
wmsInPlan.setCellCode(zdTask.getAttr3());
wmsInPlan.setPlanCode(zdTask.getCode() + random.nextInt(100));
wmsInPlan.setPlanCode(technologyBom.getFigureCode());
wmsInPlan.setRelBillCode("组装单据");
wmsInPlan.setPlanTypeId("13");
wmsInPlan.setCreateBy(getUsername());
wmsInPlan.setCreateTime(DateUtils.getNowDate());
// 入库任务明细
List<WmsInPlanDetails> wmsInPlanDetailsList = new ArrayList<>();
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString());
@ -695,6 +743,7 @@ public class BaseKnifeController extends BaseController
wmsInPlan.setWmsInPlanDetailsList(wmsInPlanDetailsList);
wmsInPlanService.insertWmsInPlan(wmsInPlan);
// 入库任务
MdItem mdItem = mdItemService.selectMdItemById(zdTask.getmProductId());
WmsInTask wmsInTask = new WmsInTask();
wmsInTask.setPlanInId(wmsInPlan.getPlanId());
@ -710,9 +759,11 @@ public class BaseKnifeController extends BaseController
wmsInTask.setPlanInStatus("1");
wmsInTaskService.insertWmsInTask(wmsInTask);
// 更新数量
mdItem.setStandardNumber(mdItem.getStandardNumber() + zdTask.getProductIdQty());
mdItemService.updateMdItem(mdItem);
// 更新组装任务
zdTask.setStatus("1");
zdTask.setQtyOk(zdTask.getProductIdQty());
zdTaskService.updateWmsZdTask(zdTask);

View File

@ -62,7 +62,7 @@ public class BaseKnife extends BaseEntity {
* 安全库存
*/
@Excel(name = "安全库存")
private String safeStock;
private Integer safeStock;
/**
* 标准数量
@ -262,7 +262,7 @@ public class BaseKnife extends BaseEntity {
this.knifeType = knifeType;
}
public String getSafeStock() {
public Integer getSafeStock() {
return safeStock;
}
@ -274,7 +274,7 @@ public class BaseKnife extends BaseEntity {
this.itemOrProduct = itemOrProduct;
}
public void setSafeStock(String safeStock) {
public void setSafeStock(Integer safeStock) {
this.safeStock = safeStock;
}

View File

@ -34,7 +34,7 @@ public class MdItem extends BaseEntity {
private String itemTypeName;
private String enableFlag;
private String safeStockFlag;
private Double minStock;
private Integer minStock;
private Double maxStock;
private String highValue;
private Integer attr1;
@ -163,11 +163,11 @@ public class MdItem extends BaseEntity {
this.safeStockFlag = safeStockFlag;
}
public Double getMinStock() {
public Integer getMinStock() {
return minStock;
}
public void setMinStock(Double minStock) {
public void setMinStock(Integer minStock) {
this.minStock = minStock;
}

View File

@ -147,7 +147,7 @@ public class WmsInTaskController extends BaseController {
baseKnife.setKnifeUnit(mbbBdMrlMitm.getUnitName());
baseKnife.setKnifeType(mbbBdMrlMitm.getItemTypeName());
baseKnife.setAreaCode(wmStorageArea.getAreaCode());
baseKnife.setSafeStock(mbbBdMrlMitm.getMinStock().toString().split("\\.")[0]);
baseKnife.setSafeStock(mbbBdMrlMitm.getMinStock());
baseKnife.setStandardQuantity("1");
baseKnife.setKnifeLife(100);
baseKnife.setKnifeFineState(0);

View File

@ -154,9 +154,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchMbbProduBom">
insert into MBB_PRODU_BOM( MBB_PRODU_BOM_ID, BOM_ROUTE_ID, MD_ITEM_ID, MD_ITEM_NAME, MD_ITEM_CODE, MD_ITEM_UNIT, STANDARD_DOSAGE, REMARK, ATTR1, ATTR2, ATTR3, ATTR4, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME) values
insert into MBB_PRODU_BOM( BOM_ROUTE_ID, MD_ITEM_ID, MD_ITEM_NAME, MD_ITEM_CODE, MD_ITEM_UNIT, STANDARD_DOSAGE, REMARK, ATTR1, ATTR2, ATTR3, ATTR4, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.mbbProduBomId}, #{item.bomRouteId}, #{item.mdItemId}, #{item.mdItemName}, #{item.mdItemCode}, #{item.mdItemUnit}, #{item.standardDosage}, #{item.remark}, #{item.attr1}, #{item.attr2}, #{item.attr3}, #{item.attr4}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
( #{item.bomRouteId}, #{item.mdItemId}, #{item.mdItemName}, #{item.mdItemCode}, #{item.mdItemUnit}, #{item.standardDosage}, #{item.remark}, #{item.attr1}, #{item.attr2}, #{item.attr3}, #{item.attr4}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
</mapper>

View File

@ -187,9 +187,6 @@
<if test="minStock != null and minStock != ''">
min_stock,
</if>
<if test="safeStockFlag == 'Y'.toString()">
max_stock,
</if>
<if test="highValue != null and highValue != ''">
high_value,
</if>
@ -239,12 +236,9 @@
#{enableFlag},
</if>
#{safeStockFlag},
<if test="safeStockFlag == 'Y'.toString() and minStock != null">
<if test="minStock != null and minStock != ''">
#{minStock},
</if>
<if test="safeStockFlag == 'Y'.toString() and safeStockFlag != null">
#{maxStock},
</if>
<if test="highValue != null and highValue != ''">
#{highValue},
</if>