Compare commits
2 Commits
a517e61398
...
de7aa40751
Author | SHA1 | Date | |
---|---|---|---|
de7aa40751 | |||
a627762b39 |
@ -133,11 +133,14 @@ public class BaseKnifeController extends BaseController {
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("/open/checkForAlignment")
|
||||
@PostMapping("/open/checkForAlignment/{technologyCode}")
|
||||
@ResponseBody
|
||||
public AjaxResult checkForAlignment(@RequestBody List<String> processCodeList) {
|
||||
// 获取工艺bom
|
||||
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomListByProcessCodeList(processCodeList);
|
||||
public AjaxResult checkForAlignment(@PathVariable String technologyCode) {
|
||||
// 验证bom工艺
|
||||
BaseTechnologyBom baseTechnologyBomWrapper = new BaseTechnologyBom();
|
||||
baseTechnologyBomWrapper.setTechnologyCode(technologyCode);
|
||||
// List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomListByProcessCodeList(productionArrangements.getProcessCodes());
|
||||
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
|
||||
if (technologyBomList.isEmpty() || technologyBomList.size() == 1 && technologyBomList.get(0).getKnifeCode() == null)
|
||||
return AjaxResult.error("未检测到工艺bom项");
|
||||
|
||||
@ -151,7 +154,7 @@ public class BaseKnifeController extends BaseController {
|
||||
operLog.setOperLocation("上游系统");
|
||||
operLog.setOperUrl("/mes/md/baseKnife/open/checkForAlignment");
|
||||
operLog.setMethod("com.ktg.mes.md.controller.BaseKnifeController.checkForAlignment()");
|
||||
operLog.setOperParam(JSON.toJSONString(processCodeList));
|
||||
operLog.setOperParam(JSON.toJSONString(technologyCode));
|
||||
operLog.setStatus(1);
|
||||
operLog.setOperTime(new Date());
|
||||
|
||||
@ -177,64 +180,13 @@ public class BaseKnifeController extends BaseController {
|
||||
baseKnifeWrapper.setMbbBdMrlId(mdItemTemp.getItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
List<BaseKnife> tempList = this.baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
tempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
|
||||
AtomicInteger knifeCount = new AtomicInteger(techBom.getKnifeCount());
|
||||
|
||||
// 如果台账表中不存在,尝试组刀任务查询
|
||||
if (tempList.isEmpty()) {
|
||||
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
|
||||
// 查询整刀bom项, 如果不存在说明 为基础物料,或者没有记录此整刀的组装
|
||||
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
|
||||
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
|
||||
if (bomRouteList.isEmpty()) {
|
||||
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()) {
|
||||
// 遍历bom项, 从台账表中筛选对应基础物料
|
||||
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
|
||||
// 查询基础物料。不包含已锁定的
|
||||
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
|
||||
if (sitmTempList.isEmpty()) {
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
|
||||
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
|
||||
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
|
||||
} else {
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
}
|
||||
} else {
|
||||
countMap.put(sitmTempList.get(0).getKnifeCode(), countMap.get(sitmTempList.get(0).getKnifeCode()) + bom.getStandardDosage() * knifeCount.get());
|
||||
}
|
||||
|
||||
// 判断基础物料是否充足
|
||||
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()) {
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
operLog.setJsonResult("暂无记录整刀bom项:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("暂无记录整刀bom项", techBom.getKnifeCode());
|
||||
}
|
||||
} else {
|
||||
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足", techBom.getKnifeCode());
|
||||
}
|
||||
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("物料不足", techBom.getKnifeCode());
|
||||
} else {
|
||||
// 将物料填入集合
|
||||
tempList.forEach(item -> {
|
||||
@ -245,60 +197,9 @@ public class BaseKnifeController extends BaseController {
|
||||
}
|
||||
});
|
||||
if (knifeCount.get() > 0) {
|
||||
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
|
||||
// 查询整刀bom项, 如果不存在说明 为基础物料,或者没有记录此整刀的组装
|
||||
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
|
||||
|
||||
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
|
||||
if (bomRouteList.isEmpty()) {
|
||||
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()) {
|
||||
// 遍历bom项, 从台账表中筛选对应基础物料
|
||||
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
|
||||
// 查询基础物料。不包含已锁定的
|
||||
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
|
||||
if (sitmTempList.isEmpty()) {
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
|
||||
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
|
||||
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
|
||||
} else {
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
}
|
||||
} else {
|
||||
countMap.put(sitmTempList.get(0).getKnifeCode(), countMap.get(sitmTempList.get(0).getKnifeCode()) + bom.getStandardDosage() * knifeCount.get());
|
||||
}
|
||||
|
||||
// 判断基础物料是否充足
|
||||
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()) {
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
operLog.setJsonResult("暂无记录整刀bom项:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("暂无记录整刀bom项", techBom.getKnifeCode());
|
||||
}
|
||||
} else {
|
||||
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足", techBom.getKnifeCode());
|
||||
}
|
||||
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("物料不足", techBom.getKnifeCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -321,13 +222,16 @@ public class BaseKnifeController extends BaseController {
|
||||
return AjaxResult.error("该计划单已存在,请更换重试");
|
||||
|
||||
// 齐套性检查
|
||||
AjaxResult ajaxResult = this.checkForAlignment(productionArrangements.getProcessCodes());
|
||||
AjaxResult ajaxResult = this.checkForAlignment(productionArrangements.getTechnologyCode());
|
||||
if (Integer.parseInt(String.valueOf(ajaxResult.get("code"))) != 200) {
|
||||
return AjaxResult.error(ajaxResult.get("msg").toString(), ajaxResult.get("data"));
|
||||
}
|
||||
|
||||
// 验证bom工艺
|
||||
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomListByProcessCodeList(productionArrangements.getProcessCodes());
|
||||
BaseTechnologyBom baseTechnologyBomWrapper = new BaseTechnologyBom();
|
||||
baseTechnologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
|
||||
// List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomListByProcessCodeList(productionArrangements.getProcessCodes());
|
||||
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
|
||||
if (technologyBomList.isEmpty() || technologyBomList.size() == 1 && technologyBomList.get(0).getKnifeCode() == null)
|
||||
return AjaxResult.error("未检测到工艺bom项");
|
||||
|
||||
@ -337,7 +241,7 @@ public class BaseKnifeController extends BaseController {
|
||||
// 参数列表
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("planCode", productionArrangements.getPlanSheet());
|
||||
params.put("processCodeList", productionArrangements.getProcessCodes());
|
||||
params.put("processCode", productionArrangements.getTechnologyCode());
|
||||
params.put("processUnit", productionArrangements.getProcessUnit());
|
||||
|
||||
// 构建日志
|
||||
@ -380,70 +284,16 @@ public class BaseKnifeController extends BaseController {
|
||||
baseKnifeWrapper.setMbbBdMrlId(mdItemTemp.getItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
List<BaseKnife> tempList = this.baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
tempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
|
||||
AtomicInteger knifeCount = new AtomicInteger(techBom.getKnifeCount());
|
||||
|
||||
// 如果台账表中不存在,尝试组刀任务查询
|
||||
if (tempList.isEmpty()) {
|
||||
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
|
||||
// 查询整刀bom项, 如果不存在说明 为基础物料,或者没有记录此整刀的组装
|
||||
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());
|
||||
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
|
||||
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("物料不足", techBom.getKnifeCode());
|
||||
|
||||
if (!bomRoute.getMbbProduBomList().isEmpty()) {
|
||||
// 遍历bom项, 从台账表中筛选对应基础物料
|
||||
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
|
||||
// 查询基础物料。不包含已锁定的
|
||||
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
|
||||
if (sitmTempList.isEmpty()) {
|
||||
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
|
||||
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());
|
||||
}
|
||||
} else {
|
||||
countMap.put(sitmTempList.get(0).getKnifeCode(), countMap.get(sitmTempList.get(0).getKnifeCode()) + bom.getStandardDosage() * knifeCount.get());
|
||||
}
|
||||
|
||||
// 判断基础物料是否充足
|
||||
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());
|
||||
}
|
||||
} else {
|
||||
// 将物料填入集合
|
||||
tempList.forEach(item -> {
|
||||
@ -461,231 +311,117 @@ public class BaseKnifeController extends BaseController {
|
||||
}
|
||||
});
|
||||
if (knifeCount.get() > 0) {
|
||||
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
|
||||
// 查询整刀bom项, 如果不存在说明 为基础物料,或者没有记录此整刀的组装
|
||||
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()) {
|
||||
// 遍历bom项, 从台账表中筛选对应基础物料
|
||||
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
|
||||
// 查询基础物料。不包含已锁定的
|
||||
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
|
||||
if (sitmTempList.isEmpty()) {
|
||||
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
|
||||
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
|
||||
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
|
||||
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());
|
||||
}
|
||||
} else {
|
||||
countMap.put(sitmTempList.get(0).getKnifeCode(), countMap.get(sitmTempList.get(0).getKnifeCode()) + bom.getStandardDosage() * knifeCount.get());
|
||||
}
|
||||
|
||||
// 判断基础物料是否充足
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 组刀
|
||||
MdItem mdItem;
|
||||
List<BaseKnife> baseKnifeList;
|
||||
int count;
|
||||
List<MbbProduBom> bomList;
|
||||
for (BaseTechnologyBom techBom : technologyBomList) {
|
||||
mdItem = mdItemService.selectMdItemByCode(techBom.getKnifeCode());
|
||||
count = techBom.getKnifeCount() - countMap.get(techBom.getKnifeCode());
|
||||
|
||||
// 先从台账表找
|
||||
baseKnifeWrapper.setMbbBdMrlId(mdItem.getItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
baseKnifeList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
baseKnifeList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
|
||||
for (BaseKnife wmsBaseKnife : baseKnifeList) {
|
||||
if (wmsBaseKnife.getKnifeLife() >= techBom.getExpendLife() && count > 0) {
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
// 整刀不足进行组装
|
||||
if (count > 0) {
|
||||
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));
|
||||
operLog.setJsonResult("Bom头查询错误:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
|
||||
}
|
||||
|
||||
// 生成组装任务
|
||||
WmsZdTask wmsZdTask = new WmsZdTask();
|
||||
wmsZdTask.setmProductId(mdItem.getItemId());
|
||||
wmsZdTask.setPlanSheet(productionArrangements.getPlanSheet());
|
||||
wmsZdTask.setCode(generateTaskCode(techBom.getProcessCode()));
|
||||
wmsZdTask.setName(techBom.getProcessName());
|
||||
wmsZdTask.setProductIdQty(count);
|
||||
wmsZdTask.setBomId(bomRouteList.get(0).getBomRouteId());
|
||||
wmsZdTask.setCreateTime(DateUtils.getNowDate());
|
||||
zdTaskService.insertWmsZdTask(wmsZdTask);
|
||||
msg = "生产准备验证成功!缺少物料已生成组装任务!";
|
||||
} else {
|
||||
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
|
||||
operLog.setJsonResult("缺少BOM项:" + techBom.getKnifeCode());
|
||||
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
|
||||
operLogService.insertOperlog(operLog);
|
||||
return AjaxResult.error("缺少BOM项", techBom.getKnifeCode());
|
||||
return AjaxResult.error("物料不足", techBom.getKnifeCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加生产准备记录
|
||||
productionArrangements.setProcessCode(productionArrangements.getProcessCodes().toString());
|
||||
productionArrangements.setTechnologyCode(productionArrangements.getTechnologyCode());
|
||||
productionArrangements.setProcessUnit(productionArrangements.getProcessUnit());
|
||||
productionArrangements.setStatus(0);
|
||||
productionArrangements.setCreateTime(DateUtils.getNowDate());
|
||||
productionArrangementsMapper.insertProductionArrangements(productionArrangements);
|
||||
|
||||
if (!msg.contains("缺少物料已生成组装任务!")){
|
||||
// 生成出库计划单
|
||||
WmsOutPlan outPlan = new WmsOutPlan();
|
||||
outPlan.setPlanCode(productionArrangements.getPlanSheet());
|
||||
outPlan.setWmsBusinessTypeId(16L);
|
||||
outPlan.setPlanState("1");
|
||||
outPlan.setPlanType("ZDCK");
|
||||
outPlan.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutPlanMapper.insertWmsOutPlan(outPlan);
|
||||
// 生成出库计划单
|
||||
WmsOutPlan outPlan = new WmsOutPlan();
|
||||
outPlan.setPlanCode(productionArrangements.getPlanSheet());
|
||||
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<>();
|
||||
String batchNum = "SCZBPC01";
|
||||
// 出库任务,进行基础物料的出库
|
||||
HashMap<Long, HashMap<String, List<BaseKnife>>> baseKnifeHashMapMap = new HashMap<>();
|
||||
|
||||
// 遍历构建map
|
||||
baseKnifeOriginList.forEach(item -> {
|
||||
// 判断当前物料主键是否已经被收录
|
||||
baseKnifeHashMapMap.computeIfAbsent(item.getMbbBdMrlId(), k -> 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()).computeIfAbsent(item.getAreaCode(), k -> new ArrayList<>());
|
||||
|
||||
// 对当前台账对象进行收录
|
||||
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).get(item.getAreaCode()).add(item);
|
||||
// 对当前台账对象进行收录
|
||||
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).get(item.getAreaCode()).add(item);
|
||||
});
|
||||
|
||||
// 出库
|
||||
item.setKnifeFineState(2);
|
||||
baseKnifeService.updateBaseKnife(item);
|
||||
});
|
||||
// 生成出库计划明细
|
||||
WmsOutPlan outPlanTemp = outPlan;
|
||||
baseKnifeHashMapMap.keySet().forEach(mdItemId -> {
|
||||
MdItem mdItemOutPlan = mdItemService.selectMdItemById(mdItemId);
|
||||
// 根据库位编码遍历
|
||||
baseKnifeHashMapMap.get(mdItemId).keySet().forEach(areaCode -> {
|
||||
// 获得库位对象
|
||||
WmStorageArea wmStorageAreaOutPlan = wmStorageAreaService.selectWmStorageAreaByAreaCode(areaCode);
|
||||
|
||||
// 生成出库计划明细
|
||||
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);
|
||||
|
||||
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("0");
|
||||
wmsOutTask.setRecipientUsername("");
|
||||
wmsOutTask.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
|
||||
// 遍历台账对象
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
productionArrangements.setStatus(1);
|
||||
productionArrangementsMapper.updateProductionArrangements(productionArrangements);
|
||||
}
|
||||
// 生成出库任务
|
||||
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("0");
|
||||
wmsOutTask.setRecipientUsername("");
|
||||
wmsOutTask.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
|
||||
});
|
||||
});
|
||||
|
||||
productionArrangements.setStatus(1);
|
||||
productionArrangementsMapper.updateProductionArrangements(productionArrangements);
|
||||
|
||||
operLog.setJsonResult(msg);
|
||||
operLog.setStatus(0);
|
||||
@ -693,265 +429,6 @@ public class BaseKnifeController extends BaseController {
|
||||
return AjaxResult.success(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改工具台账
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('md:baseKnife:edit')")
|
||||
@Log(title = "工具台账", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/zdTask")
|
||||
public AjaxResult zdTask(@RequestBody WmsZdTask zdTask) {
|
||||
String batchNum = "ZZPC001";
|
||||
|
||||
// 判断物料是否充足
|
||||
BomRoute bomRoute = bomRouteService.selectBomRouteByBomRouteId(zdTask.getAttr1());
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
List<BaseKnife> baseKnifeList = new ArrayList<>();
|
||||
|
||||
// 遍历组装整刀需要的bom物料
|
||||
for (MbbProduBom mbbProduBom : bomRoute.getMbbProduBomList()) {
|
||||
// 查找未锁定的物料
|
||||
baseKnifeWrapper.setMbbBdMrlId(mbbProduBom.getMdItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
baseKnifeList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
|
||||
// 如果未锁定的物料不足所需数量
|
||||
if (baseKnifeList.size() < mbbProduBom.getStandardDosage() * zdTask.getProductIdQty())
|
||||
return AjaxResult.error("bom物料不足进行组装:" + mbbProduBom.getMdItemCode());
|
||||
}
|
||||
|
||||
List<WmsOutPlanDetail> wmsOutPlanDetailList = new ArrayList<>();
|
||||
List<BaseKnife> baseKnifeListOutPlan = new ArrayList<>();
|
||||
|
||||
// 查询工艺bom
|
||||
BaseTechnologyBom technologyBom = new BaseTechnologyBom();
|
||||
Boolean lockedFlag = false;
|
||||
// attr4 组装任务所属计划单, 如果为空则是手动组装任务不需要锁定
|
||||
if (zdTask.getAttr4() != null) {
|
||||
lockedFlag = true;
|
||||
}
|
||||
|
||||
// 出库基础物料, 根据图号查询出库计划,如果不存在生成计划,存在则往计划中添加任务
|
||||
WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getAttr4());
|
||||
if (outPlan == null) {
|
||||
// 构建新的出库计划
|
||||
WmsOutPlan outPlanTemp = new WmsOutPlan();
|
||||
outPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4());
|
||||
outPlanTemp.setWmsBusinessTypeId(12L);
|
||||
outPlanTemp.setPlanState("1");
|
||||
outPlanTemp.setPlanType("ZDCK");
|
||||
outPlanTemp.setCreateBy(getUsername());
|
||||
outPlanTemp.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutPlanMapper.insertWmsOutPlan(outPlanTemp);
|
||||
outPlan = outPlanTemp;
|
||||
}
|
||||
|
||||
// 锁定物料
|
||||
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());
|
||||
baseKnife.setKnifeCode(mdItem.getItemCode());
|
||||
baseKnife.setKnifeName(mdItem.getItemName());
|
||||
baseKnife.setKnifeUnit(mdItem.getUnitName());
|
||||
baseKnife.setKnifeType(mdItem.getItemTypeName());
|
||||
// attr3 库位编码
|
||||
baseKnife.setAreaCode(zdTask.getAttr3());
|
||||
baseKnife.setSafeStock(mdItem.getMinStock());
|
||||
baseKnife.setStandardQuantity("1");
|
||||
baseKnife.setKnifeLife(100);
|
||||
baseKnife.setKnifeFineState(1);
|
||||
baseKnife.setIsValid(1);
|
||||
// 判断是否需要锁定整刀
|
||||
if (lockedFlag) {
|
||||
baseKnife.setIsLocked(1);
|
||||
baseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
|
||||
baseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
|
||||
} else {
|
||||
baseKnife.setIsLocked(0);
|
||||
}
|
||||
// attr4 计划编码, 整刀
|
||||
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());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
baseKnifeList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
|
||||
|
||||
if (outPlanFlag) {
|
||||
// 出库任务,进行基础物料的出库
|
||||
MdItem mdItemOutPlan = mdItemService.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 wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaCode(zdTask.getAttr3());
|
||||
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) {
|
||||
if (bomCount > 0) {
|
||||
wmsBaseKnife.setIsLocked(1);
|
||||
wmsBaseKnife.setKnifeFineState(2);
|
||||
wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
|
||||
wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
|
||||
wmsBaseKnife.setParentId(baseKnife.getBaseKnifeId());
|
||||
wmsBaseKnife.setPlanSheet(zdTask.getAttr4());
|
||||
baseKnifeListOutPlan.add(wmsBaseKnife);
|
||||
baseKnifeService.updateBaseKnife(wmsBaseKnife);
|
||||
bomCount--;
|
||||
// 记录刀片重置次数
|
||||
resetCount += wmsBaseKnife.getResetCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新重置次数
|
||||
outPlanFlag = false;
|
||||
baseKnife.setResetCount(resetCount - 1);
|
||||
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());
|
||||
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);
|
||||
|
||||
// 更新基础物料数量
|
||||
MdItem mdItem = mdItemService.selectMdItemById(outPlanDetail.getMdItemId());
|
||||
mdItemService.updateMdItem(mdItem);
|
||||
}
|
||||
|
||||
// 整刀入库计划, 根据图号查询入库计划,如果不存在生成计划,存在则往计划中添加任务
|
||||
WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getAttr4());
|
||||
if (wmsInPlan == null) {
|
||||
WmsInPlan wmsInPlanTemp = new WmsInPlan();
|
||||
wmsInPlanTemp.setState("1");
|
||||
wmsInPlanTemp.setSourceType("SGLR");
|
||||
wmsInPlanTemp.setCellCode(zdTask.getAttr3());
|
||||
wmsInPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4());
|
||||
wmsInPlanTemp.setRelBillCode("组装单据");
|
||||
wmsInPlanTemp.setPlanTypeId("13");
|
||||
wmsInPlanTemp.setCreateBy(getUsername());
|
||||
wmsInPlanTemp.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
// 入库任务明细
|
||||
List<WmsInPlanDetails> wmsInPlanDetailsList = new ArrayList<>();
|
||||
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
|
||||
wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString());
|
||||
wmsInPlanDetails.setBatch(batchNum);
|
||||
wmsInPlanDetails.setCellId(1L);
|
||||
wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString());
|
||||
wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString());
|
||||
wmsInPlanDetails.setPlanInStatus("0");
|
||||
wmsInPlanDetailsList.add(wmsInPlanDetails);
|
||||
wmsInPlanTemp.setWmsInPlanDetailsList(wmsInPlanDetailsList);
|
||||
wmsInPlanService.insertWmsInPlan(wmsInPlanTemp);
|
||||
wmsInPlan = wmsInPlanTemp;
|
||||
} else {
|
||||
// 入库任务明细
|
||||
List<WmsInPlanDetails> wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList();
|
||||
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
|
||||
wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString());
|
||||
wmsInPlanDetails.setBatch(batchNum);
|
||||
wmsInPlanDetails.setCellId(1L);
|
||||
wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString());
|
||||
wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString());
|
||||
wmsInPlanDetails.setPlanInStatus("0");
|
||||
wmsInPlanDetailsList.add(wmsInPlanDetails);
|
||||
wmsInPlan.setWmsInPlanDetailsList(wmsInPlanDetailsList);
|
||||
wmsInPlanService.updateWmsInPlan(wmsInPlan);
|
||||
}
|
||||
|
||||
// 入库任务
|
||||
MdItem mdItem = mdItemService.selectMdItemById(zdTask.getmProductId());
|
||||
WmsInTask wmsInTask = new WmsInTask();
|
||||
// 生成任务号
|
||||
String taskInCode = MultiModuleCodeGenerator.generateTaskCode("RKT");
|
||||
wmsInTask.setTaskInCode(taskInCode);
|
||||
wmsInTask.setPlanInId(wmsInPlan.getPlanId().toString());
|
||||
wmsInTask.setPlanInCode(wmsInPlan.getPlanCode());
|
||||
wmsInTask.setMaterialCode(mdItem.getItemCode());
|
||||
wmsInTask.setTaskInQuantity(zdTask.getProductIdQty());
|
||||
wmsInTask.setActualInQuantity(zdTask.getProductIdQty());
|
||||
WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaCode(zdTask.getAttr3());
|
||||
wmsInTask.setCellTgt(wmStorageArea.getAreaId());
|
||||
wmsInTask.setBatch(batchNum);
|
||||
wmsInTask.setMaterialId(zdTask.getmProductId().toString());
|
||||
wmsInTask.setPlanTypeId("9");
|
||||
wmsInTask.setPlanInStatus("1");
|
||||
wmsInTaskService.insertWmsInTask(wmsInTask);
|
||||
|
||||
// 更新组装任务
|
||||
zdTask.setStatus("1");
|
||||
zdTask.setQtyOk(zdTask.getProductIdQty());
|
||||
zdTaskService.updateWmsZdTask(zdTask);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询工具台账列表
|
||||
*/
|
||||
|
@ -72,6 +72,14 @@ public class BaseTechnologyBom extends BaseEntity
|
||||
@Excel(name = "预留字段4")
|
||||
private String attr4;
|
||||
|
||||
/** 预留字段4 */
|
||||
@Excel(name = "工艺编码")
|
||||
private String technologyCode;
|
||||
|
||||
/** 预留字段4 */
|
||||
@Excel(name = "工艺名称")
|
||||
private String technologyName;
|
||||
|
||||
public void setTechnologyBomId(String technologyBomId)
|
||||
{
|
||||
this.technologyBomId = technologyBomId;
|
||||
@ -199,6 +207,22 @@ public class BaseTechnologyBom extends BaseEntity
|
||||
return attr4;
|
||||
}
|
||||
|
||||
public String getTechnologyCode() {
|
||||
return technologyCode;
|
||||
}
|
||||
|
||||
public void setTechnologyCode(String technologyCode) {
|
||||
this.technologyCode = technologyCode;
|
||||
}
|
||||
|
||||
public String getTechnologyName() {
|
||||
return technologyName;
|
||||
}
|
||||
|
||||
public void setTechnologyName(String technologyName) {
|
||||
this.technologyName = technologyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
@ -70,6 +70,10 @@ public class InventoryBatch {
|
||||
@Excel(name = "入库/出库")
|
||||
private Integer inOrOut;
|
||||
|
||||
|
||||
@Excel(name = "入库/出库明细")
|
||||
private List<HashMap<String, Object>> infoList;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@ -155,4 +159,12 @@ public class InventoryBatch {
|
||||
public void setMdItemNum(Integer mdItemNum) {
|
||||
this.mdItemNum = mdItemNum;
|
||||
}
|
||||
|
||||
public List<HashMap<String, Object>> getInfoList() {
|
||||
return infoList;
|
||||
}
|
||||
|
||||
public void setInfoList(List<HashMap<String, Object>> infoList) {
|
||||
this.infoList = infoList;
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,8 @@ import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.mes.md.domain.*;
|
||||
import com.ktg.mes.md.mapper.*;
|
||||
import com.ktg.mes.md.service.IInventoryBatchService;
|
||||
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
|
||||
import com.ktg.mes.wm.domain.WmsInTask;
|
||||
import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper;
|
||||
import com.ktg.mes.wm.mapper.WmsInTaskMapper;
|
||||
import com.ktg.mes.wm.domain.*;
|
||||
import com.ktg.mes.wm.mapper.*;
|
||||
import com.ktg.mes.wm.service.impl.WmsInPlanDetailEntityServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -29,12 +27,27 @@ import static org.apache.commons.lang3.SystemUtils.getUserName;
|
||||
*/
|
||||
@Service
|
||||
public class InventoryBatchServiceImpl implements IInventoryBatchService {
|
||||
@Autowired
|
||||
@Autowired
|
||||
private BaseKnifeMapper baseKnifeMapper;
|
||||
|
||||
@Autowired
|
||||
private WmsOutPlanMapper wmsOutPlanMapper;
|
||||
|
||||
@Autowired
|
||||
private WmsInPlanMapper wmsInPlanMapper;
|
||||
|
||||
@Autowired
|
||||
private WmStorageLocationMapper wmStorageLocationMapper;
|
||||
|
||||
@Autowired
|
||||
private WmStorageAreaMapper wmStorageAreaMapper;
|
||||
|
||||
@Autowired
|
||||
private WmWarehouseMapper wmWarehouseMapper;
|
||||
|
||||
@Autowired
|
||||
private MdItemMapper mdItemMapper;
|
||||
|
||||
@Autowired
|
||||
private WmsOutPlanDetailEntityMapper wmsOutPlanDetailEntityMapper;
|
||||
|
||||
@ -72,6 +85,7 @@ public class InventoryBatchServiceImpl implements IInventoryBatchService {
|
||||
@Override
|
||||
public List<InventoryBatch> selectInventoryBatchList(InventoryBatch inventoryBatch) {
|
||||
|
||||
// 构建出库信息
|
||||
List<InventoryBatch> result = new ArrayList<>();
|
||||
|
||||
WmsOutTask wmsOutTaskWrapper = new WmsOutTask();
|
||||
@ -89,6 +103,69 @@ public class InventoryBatchServiceImpl implements IInventoryBatchService {
|
||||
inventoryBatchOut.setInOrOut(0);
|
||||
inventoryBatchOut.setDateTime(outTask.getCreateTime());
|
||||
inventoryBatchOut.setStatus(outTask.getTaskState());
|
||||
|
||||
// 获得当前出库计划明细实体列表,并遍历
|
||||
List<HashMap<String, Object>> hashMapList = new ArrayList<>();
|
||||
WmsOutPlanDetailEntity entityQuery = new WmsOutPlanDetailEntity();
|
||||
entityQuery.setWmsOutPlanDetailId(outTask.getWmsOutPlanDetailId());
|
||||
List<WmsOutPlanDetailEntity> wmsOutPlanDetailEntityList = wmsOutPlanDetailEntityMapper.selectWmsOutPlanDetailEntityList(entityQuery);
|
||||
wmsOutPlanDetailEntityList.forEach(outPlanDetailEntity -> {
|
||||
// 根据出库实例对象获取出库计划明细
|
||||
WmsOutPlanDetail wmsOutPlanDetail = this.wmsOutPlanMapper.selectWmsOutPlanDetailById(outPlanDetailEntity.getWmsOutPlanDetailId());
|
||||
|
||||
// 根据计划明细获得出库计划
|
||||
WmsOutPlan wmsOutPlan = this.wmsOutPlanMapper.selectWmsOutPlanByWmsOutPlanId(wmsOutPlanDetail.getWmsOutPlanId());
|
||||
|
||||
// 根据出库计划获得出库类型
|
||||
WmsBusinessType wmsBusinessType = this.wmsBusinessTypeMapper.selectWmsBusinessTypeByTypeId(wmsOutPlan.getWmsBusinessTypeId().toString());
|
||||
|
||||
// 获得物料
|
||||
MdItem mdItem = this.mdItemMapper.selectMdItemById(outTask.getMdItemId());
|
||||
|
||||
// 设定出库信息数据
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
/* 来自物料 */
|
||||
hashMap.put("mdItemId", mdItem.getItemId()); // 物料ID
|
||||
hashMap.put("mdItemCode", mdItem.getItemCode()); // 物料编码
|
||||
hashMap.put("mdItemName", mdItem.getItemName()); // 物料名称
|
||||
hashMap.put("mdItemUnit", mdItem.getUnitName()); // 物料单位
|
||||
hashMap.put("mdItemKnifeWarn", mdItem.getAttr2()); // 物料名称
|
||||
/* 来自出入库计划类型 */
|
||||
hashMap.put("planTypeId", wmsBusinessType.getTypeId()); // 出库类型ID
|
||||
hashMap.put("planTypeCode", wmsBusinessType.getCode()); // 出库类型编码
|
||||
hashMap.put("planTypeName", wmsBusinessType.getName()); // 出库类型名称
|
||||
/* 来自计划明细 */
|
||||
hashMap.put("detailBatchNum", wmsOutPlanDetail.getDetailBatchNum()); // 明细批次
|
||||
hashMap.put("wmStorageAreaId", wmsOutPlanDetail.getWmStorageAreaId()); // 库位ID
|
||||
hashMap.put("wmStorageAreaCode", wmsOutPlanDetail.getWmStorageAreaCode()); // 库位编码
|
||||
hashMap.put("wmStorageAreaName", wmsOutPlanDetail.getWmStorageAreaName()); // 库位名称
|
||||
hashMap.put("detailStatus", wmsOutPlanDetail.getDetailState()); // 明细状态
|
||||
|
||||
// 查询库区信息
|
||||
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(wmsOutPlanDetail.getWmStorageAreaId());
|
||||
WmStorageLocation wmStorageLocation = wmStorageLocationMapper.selectWmStorageLocationByLocationId(wmStorageArea.getLocationId());
|
||||
// 查询库房信息
|
||||
WmWarehouse wmWarehouse = wmWarehouseMapper.selectWmWarehouseByWarehouseId(wmStorageLocation.getWarehouseId());
|
||||
hashMap.put("wmWarehouseName", wmWarehouse.getWarehouseName()); // 库位名称
|
||||
/* 实体 */
|
||||
String outTime = null;
|
||||
if (outPlanDetailEntity.getCreateTime() != null)
|
||||
outTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(outPlanDetailEntity.getCreateTime());
|
||||
hashMap.put("dateTime", outTime); // 出库时间
|
||||
hashMap.put("baseKnifeId", outPlanDetailEntity.getBaseKnifeId());
|
||||
hashMap.put("planCode", outTask.getWmsOutPlanCode());
|
||||
// hashMap.put("knifeLife", nowWmsOutPlanDetailEntity.getKnifeLife());
|
||||
// hashMap.put("resetCount", nowWmsOutPlanDetailEntity.getResetCount());
|
||||
|
||||
// 寿命预警
|
||||
if ("PRODUCT".equals(outPlanDetailEntity.getItemOrProduct()) && outPlanDetailEntity.getKnifeLife() <= mdItem.getAttr2())
|
||||
hashMap.put("knifeWarning", true);
|
||||
else
|
||||
hashMap.put("knifeWarning", false);
|
||||
hashMapList.add(hashMap);
|
||||
});
|
||||
// 注入出库信息对象
|
||||
inventoryBatchOut.setInfoList(hashMapList);
|
||||
result.add(inventoryBatchOut);
|
||||
});
|
||||
|
||||
@ -108,6 +185,57 @@ public class InventoryBatchServiceImpl implements IInventoryBatchService {
|
||||
inventoryBatchIn.setInOrOut(1);
|
||||
inventoryBatchIn.setDateTime(inTask.getCreateTime());
|
||||
inventoryBatchIn.setStatus("1");
|
||||
|
||||
// 获取当期入库明细数据
|
||||
List<HashMap<String, Object>> hashMapList = new ArrayList<>();
|
||||
WmsInPlanDetailEntity entityQuery = new WmsInPlanDetailEntity();
|
||||
entityQuery.setPlanId(Long.parseLong(inTask.getPlanInId()));
|
||||
// entityQuery.setKnifeId(Long.parseLong(inTask.getPlanInId()));
|
||||
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityMapper.selectWmsInPlanDetailEntityList(entityQuery);
|
||||
wmsInPlanDetailEntityList.forEach(inPlanDetailEntity -> {
|
||||
// 根据出库计划获得出库类型
|
||||
WmsBusinessType wmsBusinessType = this.wmsBusinessTypeMapper.selectWmsBusinessTypeByTypeId(inTask.getPlanTypeId());
|
||||
|
||||
// 获得物料
|
||||
MdItem mdItem = this.mdItemMapper.selectMdItemById(Long.parseLong(inTask.getMaterialId()));
|
||||
|
||||
// 设定出库信息数据
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
/* 来自物料 */
|
||||
hashMap.put("mdItemId", mdItem.getItemId()); // 物料ID
|
||||
hashMap.put("mdItemCode", mdItem.getItemCode()); // 物料编码
|
||||
hashMap.put("mdItemName", mdItem.getItemName()); // 物料名称
|
||||
hashMap.put("mdItemUnit", mdItem.getUnitName()); // 物料单位
|
||||
hashMap.put("mdItemKnifeWarn", mdItem.getAttr2()); // 物料名称
|
||||
/* 来自出入库计划类型 */
|
||||
hashMap.put("planTypeId", wmsBusinessType.getTypeId()); // 入库类型ID
|
||||
hashMap.put("planTypeCode", wmsBusinessType.getCode()); // 入库类型编码
|
||||
hashMap.put("planTypeName", wmsBusinessType.getName()); // 入库类型名称
|
||||
/* 来自计划明细 */
|
||||
hashMap.put("detailBatchNum", inTask.getBatch()); // 明细批次
|
||||
hashMap.put("wmStorageAreaId", inTask.getCellTgt()); // 库位ID
|
||||
hashMap.put("wmStorageAreaName", inTask.getCellName()); // 库位名称
|
||||
hashMap.put("detailStatus", inTask.getPlanInStatus()); // 明细状态
|
||||
|
||||
// 查询库区信息
|
||||
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(inTask.getCellTgt());
|
||||
WmStorageLocation wmStorageLocation = wmStorageLocationMapper.selectWmStorageLocationByLocationId(wmStorageArea.getLocationId());
|
||||
// 查询库房信息
|
||||
WmWarehouse wmWarehouse = wmWarehouseMapper.selectWmWarehouseByWarehouseId(wmStorageLocation.getWarehouseId());
|
||||
hashMap.put("wmWarehouseName", wmWarehouse.getWarehouseName()); // 库位名称
|
||||
/* 实体 */
|
||||
String outTime = null;
|
||||
if (inPlanDetailEntity.getCreateTime() != null)
|
||||
outTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(inPlanDetailEntity.getCreateTime());
|
||||
hashMap.put("dateTime", outTime); // 出库时间
|
||||
hashMap.put("baseKnifeId", inPlanDetailEntity.getKnifeId());
|
||||
hashMap.put("planCode", inTask.getPlanInCode());
|
||||
// hashMap.put("knifeLife", nowWmsOutPlanDetailEntity.getKnifeLife());
|
||||
// hashMap.put("resetCount", nowWmsOutPlanDetailEntity.getResetCount());
|
||||
hashMapList.add(hashMap);
|
||||
});
|
||||
|
||||
inventoryBatchIn.setInfoList(hashMapList);
|
||||
result.add(inventoryBatchIn);
|
||||
});
|
||||
|
||||
|
@ -25,11 +25,8 @@ public class ProductionArrangements extends BaseEntity
|
||||
private String planSheet;
|
||||
|
||||
/** 工序号 */
|
||||
@Excel(name = "工序号")
|
||||
private String processCode;
|
||||
|
||||
@Excel(name = "工序号")
|
||||
private List<String> processCodes;
|
||||
@Excel(name = "工艺编码")
|
||||
private String technologyCode;
|
||||
|
||||
@Excel(name = "工序号")
|
||||
private String processUnit;
|
||||
@ -72,17 +69,16 @@ public class ProductionArrangements extends BaseEntity
|
||||
{
|
||||
return planSheet;
|
||||
}
|
||||
public void setProcessCode(String processCode)
|
||||
{
|
||||
this.processCode = processCode;
|
||||
|
||||
public String getTechnologyCode() {
|
||||
return technologyCode;
|
||||
}
|
||||
|
||||
public String getProcessCode()
|
||||
{
|
||||
return processCode;
|
||||
public void setTechnologyCode(String technologyCode) {
|
||||
this.technologyCode = technologyCode;
|
||||
}
|
||||
public void setStatus(Integer status)
|
||||
{
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@ -94,13 +90,7 @@ public class ProductionArrangements extends BaseEntity
|
||||
this.processUnit = processUnit;
|
||||
}
|
||||
|
||||
public List<String> getProcessCodes() {
|
||||
return processCodes;
|
||||
}
|
||||
|
||||
public void setProcessCodes(List<String> processCodes) {
|
||||
this.processCodes = processCodes;
|
||||
}
|
||||
|
||||
public Integer getStatus()
|
||||
{
|
||||
@ -148,8 +138,6 @@ public class ProductionArrangements extends BaseEntity
|
||||
return "ProductionArrangements{" +
|
||||
"productionArrangementsId='" + productionArrangementsId + '\'' +
|
||||
", planSheet='" + planSheet + '\'' +
|
||||
", processCode='" + processCode + '\'' +
|
||||
", processCodes=" + processCodes +
|
||||
", processUnit='" + processUnit + '\'' +
|
||||
", status=" + status +
|
||||
", attr1='" + attr1 + '\'' +
|
||||
|
@ -445,16 +445,6 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
wmsInTask.setCreateTime(DateUtils.getNowDate());
|
||||
wmsInTaskMapper.insertWmsInTask(wmsInTask);
|
||||
|
||||
// 整 刀台账设为有效
|
||||
baseKnifeList.forEach(baseKnife -> {
|
||||
baseKnife.setIsValid(0);
|
||||
baseKnife.setCreateTime(DateUtils.getNowDate());
|
||||
baseKnifeMapper.updateBaseKnife(baseKnife);
|
||||
});
|
||||
|
||||
// 检测订单是否完成,完成则出库整刀
|
||||
if (zdTask.getPlanSheet() != null && this.checkFinal(zdTask.getPlanSheet())) this.createOutTask(zdTask.getPlanSheet());
|
||||
|
||||
// 更新组装任务
|
||||
zdTask.setStatus("2");
|
||||
zdTask.setQtyOk(zdTask.getProductIdQty());
|
||||
@ -473,152 +463,5 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
}
|
||||
}
|
||||
|
||||
// 检查订单完成状态
|
||||
public Boolean checkFinal(String planSheet){
|
||||
// 获取订单记录
|
||||
ProductionArrangements productionArrangements = productionArrangementsMapper.selectProductionArrangementsByPlanSheet(planSheet);
|
||||
String[] processCodes = productionArrangements.getProcessCode().substring(1, productionArrangements.getProcessCode().length() - 1).split(",");
|
||||
for (String processCode : processCodes) {
|
||||
// 遍历工序
|
||||
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomListByProcessCode(processCode.trim());
|
||||
if (baseTechnologyBomList != null && baseTechnologyBomList.size() > 0) {
|
||||
// 判断订单锁定的物料是否足够
|
||||
for (BaseTechnologyBom technologyBom : baseTechnologyBomList) {
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(planSheet);
|
||||
baseKnifeWrapper.setKnifeCode(technologyBom.getKnifeCode());
|
||||
List<BaseKnife> baseKnifePlanSheetList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
if (baseKnifePlanSheetList.size() < technologyBom.getKnifeCount()) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查订单完成状态
|
||||
@Transactional
|
||||
public void createOutTask(String planSheet){
|
||||
// 构建出库计划
|
||||
WmsOutPlan outPlan = new WmsOutPlan();
|
||||
outPlan.setPlanCode(planSheet);
|
||||
outPlan.setWmsBusinessTypeId(16L);
|
||||
outPlan.setPlanState("1");
|
||||
outPlan.setPlanType("ZDCK");
|
||||
outPlan.setCreateBy(getUsername());
|
||||
outPlan.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutPlanMapper.insertWmsOutPlan(outPlan);
|
||||
|
||||
// 所有的物料
|
||||
List<BaseKnife> baseKnifeResultList = new ArrayList<>();
|
||||
|
||||
// 获取订单记录
|
||||
ProductionArrangements productionArrangements = productionArrangementsMapper.selectProductionArrangementsByPlanSheet(planSheet);
|
||||
String[] processCodes = productionArrangements.getProcessCode().substring(1, productionArrangements.getProcessCode().length() - 1).split(",");
|
||||
for (String processCode : processCodes) {
|
||||
// 遍历工序
|
||||
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomListByProcessCode(processCode.trim());
|
||||
if (baseTechnologyBomList != null && baseTechnologyBomList.size() > 0) {
|
||||
// 判断订单锁定的物料是否足够
|
||||
for (BaseTechnologyBom technologyBom : baseTechnologyBomList) {
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(planSheet);
|
||||
baseKnifeWrapper.setKnifeCode(technologyBom.getKnifeCode());
|
||||
List<BaseKnife> baseKnifeLockedList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
if (baseKnifeLockedList.size() == technologyBom.getKnifeCount()) baseKnifeResultList.addAll(baseKnifeLockedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String batchNum = "SCZBPC01";
|
||||
// 出库任务,进行整刀的出库
|
||||
HashMap<Long, HashMap<String, List<BaseKnife>>> baseKnifeHashMapMap = new HashMap<>();
|
||||
|
||||
// 遍历构建map
|
||||
baseKnifeResultList.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);
|
||||
|
||||
// 修改出库状态
|
||||
item.setKnifeFineState(2);
|
||||
baseKnifeMapper.updateBaseKnife(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.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("0");
|
||||
wmsOutTask.setRecipientUsername("");
|
||||
wmsOutTask.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
|
||||
});
|
||||
});
|
||||
|
||||
productionArrangements.setStatus(1);
|
||||
productionArrangementsMapper.updateProductionArrangements(productionArrangements);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="expendLife != null and expendLife != ''"> and EXPEND_LIFE = #{expendLife}</if>
|
||||
<if test="lockedStartTime != null and lockedStartTime != ''"> and LOCKED_START_TIME = #{lockedStartTime}</if>
|
||||
<if test="lockedEndTime != null and lockedEndTime != ''"> and LOCKED_END_TIME = #{lockedEndTime}</if>
|
||||
<if test="technologyCode != null and technologyCode != ''"> and TECHNOLOGY_CODE = #{technologyCode}</if>
|
||||
<if test="remark != null and remark != ''"> and REMARK = #{remark}</if>
|
||||
<if test="attr1 != null and attr1 != ''"> and ATTR1 = #{attr1}</if>
|
||||
<if test="attr2 != null and attr2 != ''"> and ATTR2 = #{attr2}</if>
|
||||
|
@ -54,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into PRODUCTION_ARRANGEMENTS
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="planSheet != null">PLAN_SHEET,</if>
|
||||
<if test="processCode != null">PROCESS_CODE,</if>
|
||||
<if test="technologyCode != null">TECHNOLOGY_CODE,</if>
|
||||
<if test="status != null">STATUS,</if>
|
||||
<if test="processUnit != null">PROCESS_UNIT,</if>
|
||||
<if test="attr1 != null">ATTR1,</if>
|
||||
@ -68,7 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="planSheet != null">#{planSheet},</if>
|
||||
<if test="processCode != null">#{processCode},</if>
|
||||
<if test="technologyCode != null">#{technologyCode},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="processUnit != null">#{processUnit},</if>
|
||||
<if test="attr1 != null">#{attr1},</if>
|
||||
@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update PRODUCTION_ARRANGEMENTS
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="planSheet != null">PLAN_SHEET = #{planSheet},</if>
|
||||
<if test="processCode != null">PROCESS_CODE = #{processCode},</if>
|
||||
<if test="technologyCode != null">TECHNOLOGY_CODE = #{technologyCode},</if>
|
||||
<if test="status != null">STATUS = #{status},</if>
|
||||
<if test="attr1 != null">ATTR1 = #{attr1},</if>
|
||||
<if test="attr2 != null">ATTR2 = #{attr2},</if>
|
||||
|
Loading…
Reference in New Issue
Block a user