工具库生产准备

This commit is contained in:
汤锦科 2024-12-20 10:52:52 +08:00
parent 1d9e31b5fa
commit 19b97b234b
21 changed files with 1678 additions and 171 deletions

View File

@ -1,5 +1,6 @@
package com.ktg.mes.md.controller;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.http.HttpServletResponse;
@ -7,7 +8,9 @@ import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.ktg.common.utils.DateUtils;
import com.ktg.generator.util.MultiModuleCodeGenerator;
import com.ktg.mes.cal.utils.CalendarUtil;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.mapper.BaseKnifeLockedMapper;
import com.ktg.mes.md.mapper.WmsOutPlanDetailEntityMapper;
import com.ktg.mes.md.mapper.WmsOutPlanMapper;
import com.ktg.mes.md.mapper.WmsOutTaskMapper;
@ -20,6 +23,10 @@ import com.ktg.mes.wm.service.IWmsInTaskService;
import com.ktg.mes.wm.service.IWmsZdTaskService;
import com.ktg.system.domain.SysOperLog;
import com.ktg.system.service.ISysOperLogService;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -82,6 +89,12 @@ public class BaseKnifeController extends BaseController {
@Autowired
private ProductionArrangementsMapper productionArrangementsMapper;
@Autowired
private BaseKnifeLockedMapper baseKnifeLockedMapper;
@Autowired
private MyConfig myConfig;
/**
* 列表查询
@ -133,6 +146,31 @@ public class BaseKnifeController extends BaseController {
return getDataTable(list);
}
/**
* 列表查询
*
* @return
*/
@PostMapping("/open/life")
public AjaxResult life(@RequestBody BaseKnife baseKnife) {
// 检查台账是否存在
BaseKnife baseKnifeOrigin = baseKnifeService.selectBaseKnifeByBaseKnifeId(baseKnife.getBaseKnifeId());
if (baseKnifeOrigin == null) return AjaxResult.error();
// 计算消耗寿命
int currentLife = baseKnifeOrigin.getKnifeLife() + baseKnifeOrigin.getResetCount() * 100 - baseKnife.getKnifeLife();
if (currentLife > 0){
baseKnifeOrigin.setKnifeLife(currentLife % 100);
baseKnifeOrigin.setResetCount(currentLife / 100);
} else {
baseKnifeOrigin.setKnifeLife(0);
baseKnifeOrigin.setResetCount(0);
}
baseKnifeService.updateBaseKnife(baseKnifeOrigin);
return AjaxResult.success();
}
@PostMapping("/open/checkForAlignment/{technologyCode}")
@ResponseBody
public AjaxResult checkForAlignment(@PathVariable String technologyCode) {
@ -142,7 +180,7 @@ public class BaseKnifeController extends BaseController {
// 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项");
throw new RuntimeException("未检测到工艺bom项");
// 构建日志
SysOperLog operLog = new SysOperLog();
@ -174,19 +212,70 @@ public class BaseKnifeController extends BaseController {
if (mdItemTemp == null) {
operLog.setJsonResult("物料台账查询错误:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("物料台账查询错误", techBom.getKnifeCode());
throw new RuntimeException("物料台账查询错误" + techBom.getKnifeCode());
}
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()) {
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
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("物料不足", techBom.getKnifeCode());
throw new RuntimeException("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);
throw new RuntimeException("基础物料不足进行组装工具" + 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);
throw new RuntimeException("基础物料不足进行组装工具" + 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);
throw new RuntimeException("基础物料不足进行组装工具" + bom.getMdItemCode());
}
}
} else {
operLog.setJsonResult("暂无记录整刀bom项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("暂无记录整刀bom项" + techBom.getKnifeCode());
}
} else {
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("基础物料不足" + techBom.getKnifeCode());
}
} else {
// 将物料填入集合
tempList.forEach(item -> {
@ -197,9 +286,60 @@ public class BaseKnifeController extends BaseController {
}
});
if (knifeCount.get() > 0) {
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
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("物料不足", techBom.getKnifeCode());
throw new RuntimeException("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);
throw new RuntimeException("基础物料不足进行组装工具" + 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);
throw new RuntimeException("基础物料不足进行组装工具" + 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);
throw new RuntimeException("基础物料不足进行组装工具" + bom.getMdItemCode());
}
}
} else {
operLog.setJsonResult("暂无记录整刀bom项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("暂无记录整刀bom项" + techBom.getKnifeCode());
}
} else {
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("基础物料不足" + techBom.getKnifeCode());
}
}
}
}
@ -214,28 +354,31 @@ public class BaseKnifeController extends BaseController {
@PostMapping("/open/productionArrangements")
@ResponseBody
@Transactional
public AjaxResult productionArrangements(@RequestBody ProductionArrangements productionArrangements) {
// 检查计划单是否已存在
public AjaxResult productionArrangements(@RequestBody ProductionArrangements productionArrangements) throws IOException {
// 检查计划单是否已存在 从台账表中寻找
BaseKnife baseKnifePlan = new BaseKnife();
baseKnifePlan.setPlanSheet(productionArrangements.getPlanSheet());
if (!baseKnifeService.selectBaseKnifeList(baseKnifePlan).isEmpty())
return AjaxResult.error("该计划单已存在,请更换重试");
// 检查计划单是否已存在 从组装任务表中寻找
WmsZdTask wmsZdTaskValid = new WmsZdTask();
wmsZdTaskValid.setPlanSheet(productionArrangements.getPlanSheet());
if (!zdTaskService.selectWmsZdTaskList(wmsZdTaskValid).isEmpty())
return AjaxResult.error("该计划单已存在,请更换重试");
// 检查计划单是否已存在 从物料预订表中寻找
BaseKnifeLocked baseKnifeLockedValid = new BaseKnifeLocked();
baseKnifeLockedValid.setPlanSheet(productionArrangements.getPlanSheet());
if (!baseKnifeLockedMapper.selectBaseKnifeLockedList(baseKnifeLockedValid).isEmpty())
return AjaxResult.error("该计划单已存在,请更换重试");
// 齐套性检查
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工艺
// 验证工艺BOM是否存在
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项");
// 记录数据修改
// 记录已经列入订单需求的物料数据
List<BaseKnife> baseKnifeOriginList = new ArrayList<>();
// 参数列表
@ -260,8 +403,9 @@ public class BaseKnifeController extends BaseController {
// 接口返回信息
String msg = "生产准备验证成功!";
// 记录所需物料数量的map
// 记录所符合需求的物料数量 map 需要组装的物料数量
Map<String, Integer> countMap = new HashMap<>();
Map<String, Integer> zdTaskMap = new HashMap<>();
BaseKnife baseKnifeWrapper = new BaseKnife();
BomRoute bomRouteTemp = new BomRoute();
MdItem mdItemTemp = new MdItem();
@ -270,30 +414,88 @@ public class BaseKnifeController extends BaseController {
for (BaseTechnologyBom techBom : technologyBomList) {
// 空则0
countMap.putIfAbsent(techBom.getKnifeCode(), 0);
zdTaskMap.putIfAbsent(techBom.getKnifeCode(), 0);
// 台账表中查询工具 并记录数量
// 查询物料编码是否存在
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());
throw new RuntimeException("物料台账查询错误" + techBom.getKnifeCode());
}
// 查询复合条件的台账
// 查询符合条件的台账 锁定状态为 0 空闲中
baseKnifeWrapper.setMbbBdMrlId(mdItemTemp.getItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> tempList = this.baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
// 记录此项工艺需要的物料数量
AtomicInteger knifeCount = new AtomicInteger(techBom.getKnifeCount());
// 如果台账表中不存在尝试组刀任务查询
if (tempList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
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("物料不足", techBom.getKnifeCode());
throw new RuntimeException("Bom头查询错误" + techBom.getKnifeCode());
}
// 获取整刀BOM 进行子项遍历
BomRoute bomRoute = bomRouteService.selectBomRouteByBomRouteId(bomRouteList.get(0).getBomRouteId());
if (!bomRoute.getMbbProduBomList().isEmpty()) {
// 记录需要组装的数量 能够组装的数量
int knifeNeedQuantity = zdTaskMap.get(techBom.getKnifeCode()) + techBom.getKnifeCount();
int knifeHaveQuantity = this.getBomZdTaskQuantity(bomRoute, knifeNeedQuantity);
// 如果组装出来的数量不够 去预订其他订单中的
if (knifeHaveQuantity < knifeNeedQuantity) {
// 当前库内无符合需求的物料 尝试查询已经在订单中的刀但作业时间不同
List<Long> lockedBaseKnifeIds = this.getLockedBaseKnifeId(mdItemTemp.getItemCode(), productionArrangements, knifeNeedQuantity - knifeHaveQuantity);
if (!lockedBaseKnifeIds.isEmpty()) {
lockedBaseKnifeIds.forEach(lockedBaseKnifeId -> {
BaseKnife lockedBaseKnife = baseKnifeService.selectBaseKnifeByBaseKnifeId(lockedBaseKnifeId);
// 新增一条台账锁定记录 预订台账
BaseKnifeLocked baseKnifeLocked = new BaseKnifeLocked();
baseKnifeLocked.setPlanSheet(productionArrangements.getPlanSheet());
baseKnifeLocked.setStatus(0); // 状态未完成
baseKnifeLocked.setLockedStartTime(productionArrangements.getStartTime());
baseKnifeLocked.setLockedEndTime(productionArrangements.getEndTime());
baseKnifeLocked.setItemCode(lockedBaseKnife.getKnifeCode());
baseKnifeLocked.setBaseKnifeId(lockedBaseKnife.getBaseKnifeId());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
});
// 更新需要组装的数量 生产准备中已准备好的数量
zdTaskMap.put(techBom.getKnifeCode(), knifeHaveQuantity);
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + lockedBaseKnifeIds.size());
msg = msg + "【已预订" + lockedBaseKnifeIds.size() + "把整刀】";
} else {
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("基础物料不足进行组装工具" + techBom.getKnifeCode());
}
} else {
// 更新需要组装的数量 生产准备中已准备好的数量
zdTaskMap.put(techBom.getKnifeCode(), knifeHaveQuantity);
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + knifeNeedQuantity);
}
} else {
operLog.setJsonResult("暂无记录整刀bom项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("暂无记录整刀bom项" + techBom.getKnifeCode());
}
} else {
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("基础物料不足" + techBom.getKnifeCode());
}
} else {
// 将物料填入集合
tempList.forEach(item -> {
@ -301,22 +503,105 @@ public class BaseKnifeController extends BaseController {
// 更新数量
knifeCount.getAndDecrement();
countMap.put(item.getKnifeCode(), countMap.get(item.getKnifeCode()) + 1);
// 记录源数据然后锁定
baseKnifeOriginList.add(item);
// 锁定
item.setPlanSheet(productionArrangements.getPlanSheet());
item.setIsLocked(1);
item.setLockedStartTime(techBom.getLockedStartTime());
item.setLockedEndTime(techBom.getLockedEndTime());
item.setIsLocked(1); // 锁定整刀台账
item.setLockedStartTime(productionArrangements.getStartTime());
item.setLockedEndTime(productionArrangements.getEndTime());
baseKnifeService.updateBaseKnife(item);
// 记录锁定记录
baseKnifeOriginList.add(item);
}
});
if (knifeCount.get() > 0) {
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
// 查询整刀bom项 如果不存在说明 为基础物料或者没有记录此整刀的组装
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("物料不足:" + techBom.getKnifeCode());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()) {
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("物料不足", techBom.getKnifeCode());
throw new RuntimeException("Bom头查询错误" + techBom.getKnifeCode());
}
// 获取整刀BOM 进行子项遍历
BomRoute bomRoute = bomRouteService.selectBomRouteByBomRouteId(bomRouteList.get(0).getBomRouteId());
if (!bomRoute.getMbbProduBomList().isEmpty()) {
// 记录需要组装的数量 能够组装的数量
int knifeNeedQuantity = zdTaskMap.get(techBom.getKnifeCode()) + knifeCount.get();
int knifeHaveQuantity = this.getBomZdTaskQuantity(bomRoute, knifeNeedQuantity);
// 如果组装出来的数量不够 去预订其他订单中的
if (knifeHaveQuantity < knifeNeedQuantity) {
// 当前库内无符合需求的物料 尝试查询已经在订单中的刀但作业时间不同
List<Long> lockedBaseKnifeIds = this.getLockedBaseKnifeId(mdItemTemp.getItemCode(), productionArrangements, knifeNeedQuantity - knifeHaveQuantity);
if (!lockedBaseKnifeIds.isEmpty()) {
lockedBaseKnifeIds.forEach(lockedBaseKnifeId -> {
BaseKnife lockedBaseKnife = baseKnifeService.selectBaseKnifeByBaseKnifeId(lockedBaseKnifeId);
// 新增一条台账锁定记录 预订台账
BaseKnifeLocked baseKnifeLocked = new BaseKnifeLocked();
baseKnifeLocked.setPlanSheet(productionArrangements.getPlanSheet());
baseKnifeLocked.setStatus(0);
baseKnifeLocked.setLockedStartTime(productionArrangements.getStartTime());
baseKnifeLocked.setLockedEndTime(productionArrangements.getEndTime());
baseKnifeLocked.setItemCode(lockedBaseKnife.getKnifeCode());
baseKnifeLocked.setBaseKnifeId(lockedBaseKnife.getBaseKnifeId());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
});
// 更新需要组装的数量 生产准备中已准备好的数量
zdTaskMap.put(techBom.getKnifeCode(), knifeHaveQuantity);
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + lockedBaseKnifeIds.size());
msg = msg + "【已预订" + lockedBaseKnifeIds.size() + "把整刀】";
} else {
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("基础物料不足进行组装工具" + techBom.getKnifeCode());
}
} else {
// 更新需要组装的数量 生产准备中已准备好的数量
zdTaskMap.put(techBom.getKnifeCode(), knifeHaveQuantity);
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + knifeNeedQuantity);
}
} else {
operLog.setJsonResult("暂无记录整刀bom项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("暂无记录整刀bom项" + techBom.getKnifeCode());
}
} else {
operLog.setJsonResult("基础物料不足:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
throw new RuntimeException("基础物料不足" + techBom.getKnifeCode());
}
}
}
}
// 组刀
for (Map.Entry<String, Integer> zdTaskItem : zdTaskMap.entrySet()){
if (zdTaskItem.getValue() != 0){
MdItem mdItem = mdItemService.selectMdItemByCode(zdTaskItem.getKey());
BomRoute bomRouteWrapper = new BomRoute();
bomRouteWrapper.setMdItemId(mdItem.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteWrapper);
// 生成组装任务
WmsZdTask wmsZdTask = new WmsZdTask();
wmsZdTask.setmProductId(mdItem.getItemId());
wmsZdTask.setPlanSheet(productionArrangements.getPlanSheet());
wmsZdTask.setCode(generateTaskCode(productionArrangements.getTechnologyCode()));
wmsZdTask.setName(productionArrangements.getPlanSheet());
wmsZdTask.setProductIdQty(zdTaskItem.getValue());
wmsZdTask.setBomId(bomRouteList.get(0).getBomRouteId());
wmsZdTask.setCreateTime(DateUtils.getNowDate());
zdTaskService.insertWmsZdTask(wmsZdTask);
msg = "生产准备验证成功!缺少物料已生成组装任务!";
}
}
@ -324,9 +609,12 @@ public class BaseKnifeController extends BaseController {
productionArrangements.setTechnologyCode(productionArrangements.getTechnologyCode());
productionArrangements.setProcessUnit(productionArrangements.getProcessUnit());
productionArrangements.setStatus(0);
productionArrangements.setStartTime(productionArrangements.getStartTime());
productionArrangements.setEndTime(productionArrangements.getEndTime());
productionArrangements.setCreateTime(DateUtils.getNowDate());
productionArrangementsMapper.insertProductionArrangements(productionArrangements);
if (!msg.contains("缺少物料已生成组装任务!") && !msg.contains("已预订")) {
// 生成出库计划单
WmsOutPlan outPlan = new WmsOutPlan();
outPlan.setPlanCode(productionArrangements.getPlanSheet());
@ -350,6 +638,16 @@ public class BaseKnifeController extends BaseController {
// 对当前台账对象进行收录
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).get(item.getAreaCode()).add(item);
// 新增一条台账锁定记录 预订台账
BaseKnifeLocked baseKnifeLocked = new BaseKnifeLocked();
baseKnifeLocked.setPlanSheet(productionArrangements.getPlanSheet());
baseKnifeLocked.setStatus(0);
baseKnifeLocked.setLockedStartTime(productionArrangements.getStartTime());
baseKnifeLocked.setLockedEndTime(productionArrangements.getEndTime());
baseKnifeLocked.setItemCode(item.getKnifeCode());
baseKnifeLocked.setBaseKnifeId(item.getBaseKnifeId());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
});
// 生成出库计划明细
@ -422,6 +720,8 @@ public class BaseKnifeController extends BaseController {
productionArrangements.setStatus(1);
productionArrangementsMapper.updateProductionArrangements(productionArrangements);
this.productionArrangementsIsOk(productionArrangements);
}
operLog.setJsonResult(msg);
operLog.setStatus(0);
@ -429,6 +729,415 @@ public class BaseKnifeController extends BaseController {
return AjaxResult.success(msg);
}
// 调用生产准备完成接口
public void productionArrangementsIsOk(ProductionArrangements productionArrangements) throws IOException {
// 产线控制系统生产准备完成接口
String url = myConfig.getProductionControlPath() + "/cutterapi/cutComplete";
// 请求客户端
OkHttpClient client = new OkHttpClient();
// 构建请求数据
Map<String, Object> requestMap = new HashMap<>();
requestMap.put("prodordercode", productionArrangements.getPlanSheet());
requestMap.put("result", "0");
requestMap.put("completetime", CalendarUtil.getDateTimeStr());
// 获取工艺信息
BaseTechnologyBom technologyBomWrapper = new BaseTechnologyBom();
technologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomList(technologyBomWrapper);
BaseKnife baseKnifeWrapper = new BaseKnife();
baseKnifeWrapper.setPlanSheet(productionArrangements.getPlanSheet());
// 获取刀具信息
List<Map<String, String>> cutterList = new ArrayList<>();
technologyBomList.forEach(baseTechnologyBom -> {
baseKnifeWrapper.setKnifeCode(baseTechnologyBom.getKnifeCode());
List<BaseKnife> baseKnifeList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
baseKnifeList.forEach(baseKnife -> {
Map<String, String> map = new HashMap<>();
map.put("specno", baseTechnologyBom.getProcessCode());
map.put("code", baseKnife.getKnifeCode());
map.put("name", baseKnife.getKnifeName());
map.put("life", baseKnife.getKnifeLife().toString());
cutterList.add(map);
});
});
requestMap.put("cutterinfo", cutterList);
// 构建请求数据
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(mediaType, JSON.toJSONString(requestMap));
// 请求体
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();
// 发送请求
try(Response response = client.newCall(request).execute()) {
if (!response.isSuccessful())
throw new IOException("Unexpected code " + response);
// 请求响应
String responseBody = response.body().string();
System.out.println(responseBody);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public int getBomZdTaskQuantity(BomRoute bomRoute, Integer knifeCount){
// 记录基础物料数量的map
Map<String, Integer> baseKnifeItemCount = new HashMap<>();
// 遍历bom项 从台账表中筛选对应基础物料
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
// 查询基础物料不包含已锁定的
BaseKnife baseKnifeWrapper = new BaseKnife();
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
// 填充基础物料数量
baseKnifeItemCount.put(bom.getMdItemCode(), sitmTempList.size());
}
// 更具需要的物料数量计算基础物料能组装多少
for (int i = 0; i < knifeCount; i++){
// 遍历bom项 并减去数量
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
if (baseKnifeItemCount.get(bom.getMdItemCode()) - bom.getStandardDosage() >= 0){
baseKnifeItemCount.put(bom.getMdItemCode(), baseKnifeItemCount.get(bom.getMdItemCode()) - bom.getStandardDosage());
} else return i;
}
}
return knifeCount;
}
public List<Long> getLockedBaseKnifeId(String mdItemCode, ProductionArrangements productionArrangements, int count){
// 查询该物料编码的锁定记录
BaseKnifeLocked baseKnifeLockedWrapper = new BaseKnifeLocked();
baseKnifeLockedWrapper.setItemCode(mdItemCode);
baseKnifeLockedWrapper.setStatus(0);
List<BaseKnifeLocked> baseKnifeLockedList = baseKnifeLockedMapper.selectBaseKnifeLockedList(baseKnifeLockedWrapper);
// 根据台账ID进行分组
Map<Long, List<BaseKnifeLocked>> groupBaseKnifeLocked = new HashMap<>();
for (BaseKnifeLocked item : baseKnifeLockedList){
Long key = item.getBaseKnifeId();
// 判断是否已经锁定, 未锁定则跳过
BaseKnife baseKnife = baseKnifeService.selectBaseKnifeByBaseKnifeId(key);
if (baseKnife.getIsLocked() == 0 ) continue;
// 进行分组
if (groupBaseKnifeLocked.containsKey(key)){
groupBaseKnifeLocked.get(key).add(item);
} else {
List<BaseKnifeLocked> tempList = new ArrayList<>();
tempList.add(item);
groupBaseKnifeLocked.put(key, tempList);
}
}
// 遍历获取锁定时间不吻合的项
List<Long> lockedBaseKnifeIds = new ArrayList<>();
for (Map.Entry<Long, List<BaseKnifeLocked>> entry : groupBaseKnifeLocked.entrySet()){
if (count > 0){
boolean flag = true;
for (BaseKnifeLocked baseKnifeLocked : entry.getValue()){
// 如果已经锁定的开始时间在生产计划开始时间之后并且结束时间在生产计划开始时间之后则不符合
if (baseKnifeLocked.getLockedStartTime().getTime() < productionArrangements.getStartTime().getTime()){
if (baseKnifeLocked.getLockedEndTime().getTime() > productionArrangements.getStartTime().getTime()) {
flag = false;
break;
}
} else { // 如果已经锁定的开始时间在生产计划开始时间之前并且开始时间在生产计划结束时间之前则不符合
if (baseKnifeLocked.getLockedStartTime().getTime() < productionArrangements.getEndTime().getTime()) {
flag = false;
break;
}
}
}
if (flag) {
lockedBaseKnifeIds.add(entry.getKey());
count--;
}
} else return lockedBaseKnifeIds;
}
// 数量是否足够
if (count > 0) return new ArrayList<>();
else return lockedBaseKnifeIds;
}
/**
* 修改工具台账
*/
@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())
throw new RuntimeException("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");
outPlanDetail.setCreateTime(DateUtils.getNowDate());
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("SCZB");
wmsInPlanTemp.setCellCode(zdTask.getAttr3());
wmsInPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4());
wmsInPlanTemp.setRelBillCode("组装单据");
wmsInPlanTemp.setPlanTypeId(9L);
wmsInPlanTemp.setPlanTypeCode("ZDHK");
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());
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.setPlanTypeCode("ZDHK");
wmsInTask.setPlanInStatus("1");
wmsInTaskService.insertWmsInTask(wmsInTask);
// 更新组装任务
zdTask.setStatus("1");
zdTask.setQtyOk(zdTask.getProductIdQty());
zdTaskService.updateWmsZdTask(zdTask);
return AjaxResult.success();
}
/**
* 查询工具台账列表
*/
@ -485,6 +1194,7 @@ public class BaseKnifeController extends BaseController {
@Log(title = "工具台账", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BaseKnife baseKnife) {
baseKnife.setCreateBy(getUsername());
return toAjax(baseKnifeService.insertBaseKnife(baseKnife));
}
@ -495,6 +1205,7 @@ public class BaseKnifeController extends BaseController {
@Log(title = "工具台账", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BaseKnife baseKnife) {
baseKnife.setUpdateBy(getUsername());
return toAjax(baseKnifeService.updateBaseKnife(baseKnife));
}

View File

@ -0,0 +1,134 @@
package com.ktg.mes.md.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* 台账锁定对象 BASE_KNIFE_LOCKED
*
* @author yinjinlu
* @date 2024-12-09
*/
public class BaseKnifeLocked extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 刀具台账 */
@Excel(name = "刀具台账")
private Long baseKnifeId;
/** 计划单 */
@Excel(name = "计划单")
private String planSheet;
/** 计划单 */
@Excel(name = "物料编码")
private String itemCode;
/** 锁定开始时间 */
@Excel(name = "锁定开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date lockedStartTime;
/** 锁定结束时间 */
@Excel(name = "锁定结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date lockedEndTime;
/** 消耗定额 */
@Excel(name = "消耗定额")
private Integer expendLife;
/** 状态 */
@Excel(name = "状态")
private Integer status;
/** 主键ID */
private Long baseKnifeLockedId;
public void setBaseKnifeId(Long baseKnifeId)
{
this.baseKnifeId = baseKnifeId;
}
public Long getBaseKnifeId()
{
return baseKnifeId;
}
public void setPlanSheet(String planSheet)
{
this.planSheet = planSheet;
}
public String getPlanSheet()
{
return planSheet;
}
public void setLockedStartTime(Date lockedStartTime)
{
this.lockedStartTime = lockedStartTime;
}
public Date getLockedStartTime()
{
return lockedStartTime;
}
public void setLockedEndTime(Date lockedEndTime)
{
this.lockedEndTime = lockedEndTime;
}
public Date getLockedEndTime()
{
return lockedEndTime;
}
public void setBaseKnifeLockedId(Long baseKnifeLockedId)
{
this.baseKnifeLockedId = baseKnifeLockedId;
}
public Long getBaseKnifeLockedId()
{
return baseKnifeLockedId;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public Integer getExpendLife() {
return expendLife;
}
public void setExpendLife(Integer expendLife) {
this.expendLife = expendLife;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("baseKnifeId", getBaseKnifeId())
.append("planSheet", getPlanSheet())
.append("lockedStartTime", getLockedStartTime())
.append("lockedEndTime", getLockedEndTime())
.append("baseKnifeLockedId", getBaseKnifeLockedId())
.toString();
}
}

View File

@ -42,6 +42,10 @@ public class MbbProduBom extends BaseEntity
@Excel(name = "标准用量")
private Integer standardDosage;
/** 标准用量 */
@Excel(name = "当期库存")
private Long currentInventory;
/** 预留字段1 */
private String attr1;
@ -154,6 +158,14 @@ public class MbbProduBom extends BaseEntity
return attr4;
}
public Long getCurrentInventory() {
return currentInventory;
}
public void setCurrentInventory(Long currentInventory) {
this.currentInventory = currentInventory;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -0,0 +1,63 @@
package com.ktg.mes.md.domain;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MyConfig {
@Value("${globalConfig.toolSettingXml.localPath}")
private String toolSettingXmlPath;
@Value("${globalConfig.toolSettingXml.remoteUrl}")
private String remoteUrl;
@Value("${globalConfig.toolSettingXml.remoteUser}")
private String remoteUser;
@Value("${globalConfig.toolSettingXml.remotePass}")
private String remotePass;
@Value("${globalConfig.productionControl.path}")
private String productionControlPath;
public String getToolSettingXmlPath() {
return toolSettingXmlPath;
}
public void setToolSettingXmlPath(String toolSettingXmlPath) {
this.toolSettingXmlPath = toolSettingXmlPath;
}
public String getProductionControlPath() {
return productionControlPath;
}
public void setProductionControlPath(String productionControlPath) {
this.productionControlPath = productionControlPath;
}
public String getRemoteUrl() {
return remoteUrl;
}
public void setRemoteUrl(String remoteUrl) {
this.remoteUrl = remoteUrl;
}
public String getRemoteUser() {
return remoteUser;
}
public void setRemoteUser(String remoteUser) {
this.remoteUser = remoteUser;
}
public String getRemotePass() {
return remotePass;
}
public void setRemotePass(String remotePass) {
this.remotePass = remotePass;
}
}

View File

@ -0,0 +1,64 @@
package com.ktg.mes.md.mapper;
import com.ktg.mes.md.domain.BaseKnifeLocked;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 台账锁定Mapper接口
*
* @author yinjinlu
* @date 2024-12-09
*/
@Mapper
public interface BaseKnifeLockedMapper
{
/**
* 查询台账锁定
*
* @param baseKnifeLockedId 台账锁定主键
* @return 台账锁定
*/
public BaseKnifeLocked selectBaseKnifeLockedByBaseKnifeLockedId(String baseKnifeLockedId);
/**
* 查询台账锁定列表
*
* @param baseKnifeLocked 台账锁定
* @return 台账锁定集合
*/
public List<BaseKnifeLocked> selectBaseKnifeLockedList(BaseKnifeLocked baseKnifeLocked);
/**
* 新增台账锁定
*
* @param baseKnifeLocked 台账锁定
* @return 结果
*/
public int insertBaseKnifeLocked(BaseKnifeLocked baseKnifeLocked);
/**
* 修改台账锁定
*
* @param baseKnifeLocked 台账锁定
* @return 结果
*/
public int updateBaseKnifeLocked(BaseKnifeLocked baseKnifeLocked);
/**
* 删除台账锁定
*
* @param baseKnifeLockedId 台账锁定主键
* @return 结果
*/
public int deleteBaseKnifeLockedByBaseKnifeLockedId(String baseKnifeLockedId);
/**
* 批量删除台账锁定
*
* @param baseKnifeLockedIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteBaseKnifeLockedByBaseKnifeLockedIds(String[] baseKnifeLockedIds);
}

View File

@ -123,4 +123,6 @@ public interface BaseKnifeMapper {
List<BaseKnife> selectBaseKnifeNotValidList(BaseKnife baseKnifeWrapper);
List<String> selectNotEmptyAreaCodeList();
List<BaseKnife> selectBaseKnifeListByMbbBdMrlId(Long itemId);
}

View File

@ -2,6 +2,7 @@ package com.ktg.mes.md.mapper;
import java.util.List;
import com.ktg.mes.md.domain.BaseTechnologyBom;
import org.apache.ibatis.annotations.Mapper;
/**
* 工艺bomMapper接口
@ -9,6 +10,7 @@ import com.ktg.mes.md.domain.BaseTechnologyBom;
* @author yinjinlu
* @date 2024-11-01
*/
@Mapper
public interface BaseTechnologyBomMapper
{
/**

View File

@ -3,6 +3,7 @@ package com.ktg.mes.md.mapper;
import java.util.List;
import com.ktg.mes.md.domain.WmsOutPlanDetailEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 出库计划明细实体Mapper接口
@ -10,6 +11,7 @@ import com.ktg.mes.md.domain.WmsOutPlanDetailEntity;
* @author yinjinlu
* @date 2024-11-11
*/
@Mapper
public interface WmsOutPlanDetailEntityMapper {
/**
* 查询出库计划明细实体

View File

@ -2,6 +2,7 @@ package com.ktg.mes.md.mapper;
import com.ktg.mes.md.domain.WmsOutPlan;
import com.ktg.mes.md.domain.WmsOutPlanDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -12,6 +13,7 @@ import java.util.List;
* @author yinjinlu
* @date 2024-11-01
*/
@Mapper
public interface WmsOutPlanMapper {
/**
* 查询出库计划管理

View File

@ -1,6 +1,7 @@
package com.ktg.mes.md.mapper;
import com.ktg.mes.md.domain.WmsOutTask;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -10,6 +11,7 @@ import java.util.List;
* @author yinjinlu
* @date 2024-11-02
*/
@Mapper
public interface WmsOutTaskMapper {
/**
* 查询出库任务

View File

@ -2,6 +2,7 @@ package com.ktg.mes.md.service.impl;
import java.util.List;
import com.ktg.common.utils.DateUtils;
import com.ktg.mes.md.mapper.BaseKnifeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -24,6 +25,9 @@ public class BomRouteServiceImpl implements IBomRouteService
@Autowired
private BomRouteMapper bomRouteMapper;
@Autowired
private BaseKnifeMapper baseKnifeMapper;
/**
* 查询BOM头
*
@ -33,7 +37,11 @@ public class BomRouteServiceImpl implements IBomRouteService
@Override
public BomRoute selectBomRouteByBomRouteId(Long bomRouteId)
{
return bomRouteMapper.selectBomRouteByBomRouteId(bomRouteId);
BomRoute bomRoute = bomRouteMapper.selectBomRouteByBomRouteId(bomRouteId);
bomRoute.getMbbProduBomList().forEach(item -> {
item.setCurrentInventory(this.baseKnifeMapper.countBaseKnife(item.getMdItemId()));
});
return bomRoute;
}
/**

View File

@ -1,23 +1,36 @@
package com.ktg.mes.md.service.impl;
import com.alibaba.fastjson.JSON;
import com.ktg.common.utils.DateUtils;
import com.ktg.mes.cal.utils.CalendarUtil;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.mapper.*;
import com.ktg.mes.md.service.IWmsOutTaskService;
import com.ktg.mes.wm.domain.UcmCtBase;
import com.ktg.mes.wm.domain.UcmCtMaterial;
import com.ktg.mes.wm.domain.WmStorageArea;
import com.ktg.mes.wm.domain.WmsZdTask;
import com.ktg.mes.wm.mapper.UcmCtBaseMapper;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.mapper.WmsZdTaskMapper;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -55,6 +68,9 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService {
@Autowired
private UcmCtMaterialMapper2 ucmCtMaterialMapper2;
@Autowired
private WmsZdTaskMapper wmsZdTaskMapper;
/**
* 查询出库任务
*
@ -239,10 +255,52 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService {
// 更新出库任务状态
wmsOutTask.setTaskState("1");
wmsOutTaskMapper.updateWmsOutTask(wmsOutTask);
// 完成标识
boolean flag = true;
// 判断是否来自组装任务
WmsZdTask wmsZdTaskWrapper = new WmsZdTask();
wmsZdTaskWrapper.setCode(wmsOutTask.getWmsOutPlanCode());
List<WmsZdTask> wmsZdTaskList = wmsZdTaskMapper.selectWmsZdTaskList(wmsZdTaskWrapper);
if (!wmsZdTaskList.isEmpty()) {
// 获取组装任务
WmsZdTask wmsZdTask = wmsZdTaskList.get(0);
// 检测是否完成
WmsOutTask wmsOutTaskWrapper = new WmsOutTask();
wmsOutTaskWrapper.setWmsOutPlanCode(wmsZdTask.getCode());
List<WmsOutTask> wmsOutTaskList = wmsOutTaskMapper.selectWmsOutTaskList(wmsOutTaskWrapper);
// 遍历状态
for (WmsOutTask item : wmsOutTaskList) {
if (Objects.equals("0", item.getTaskState())) {
flag = false;
break;
}
}
}
if (flag) {
this.wmsZdTaskFinish(wmsOutTask.getWmsOutPlanCode());
}
}
return true;
}
public void wmsZdTaskFinish(String planCode) {
WmsZdTask wmsZdTaskWrapper = new WmsZdTask();
wmsZdTaskWrapper.setCode(planCode);
List<WmsZdTask> wmsZdTaskList = wmsZdTaskMapper.selectWmsZdTaskList(wmsZdTaskWrapper);
if (!wmsZdTaskList.isEmpty()) {
// 获取组装任务 更新状态
WmsZdTask wmsZdTask = wmsZdTaskList.get(0);
wmsZdTask.setStatus("1");
wmsZdTaskMapper.updateWmsZdTask(wmsZdTask);
}
}
@Transactional
@Override
public boolean autoRunWmsOutTask(Long[] wmsOutTaskIds) {

View File

@ -1,29 +1,37 @@
package com.ktg.mes.wm.controller;
import com.alibaba.fastjson.JSON;
import com.ktg.common.annotation.Log;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.core.page.TableDataInfo;
import com.ktg.common.enums.BusinessType;
import com.ktg.common.utils.DateUtils;
import com.ktg.common.utils.StringUtils;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.mes.md.domain.BaseKnife;
import com.ktg.mes.md.domain.MdItem;
import com.ktg.mes.cal.utils.CalendarUtil;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.mapper.*;
import com.ktg.mes.md.service.IBaseKnifeService;
import com.ktg.mes.md.service.IMdItemService;
import com.ktg.mes.wm.domain.UcmCtBase;
import com.ktg.mes.wm.domain.WmStorageArea;
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
import com.ktg.mes.wm.domain.WmsInTask;
import com.ktg.mes.wm.domain.*;
import com.ktg.mes.wm.mapper.ProductionArrangementsMapper;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.service.*;
import lombok.RequiredArgsConstructor;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.io.IOException;
import java.util.*;
import static com.ktg.generator.util.MultiModuleCodeGenerator.generateTaskCode;
/**
* 入库任务Controller
@ -40,9 +48,20 @@ public class WmsInTaskController extends BaseController {
private final IBaseKnifeService baseKnifeService;
private final IWmStorageAreaService wmStorageAreaService;
private final IWmsInPlanDetailEntityService wmsInPlanDetailEntityService;
private final WmsOutPlanDetailEntityMapper wmsOutPlanDetailEntityMapper;
private final IUcmCtBaseService ucmCtBaseService;
private final IWmStorageLocationService wmStorageLocationService;
private final BaseKnifeLockedMapper baseKnifeLockedMapper;
private final IUcmCtBaseService umcCtBaseService;
private final ProductionArrangementsMapper productionArrangementsMapper;
private final BaseTechnologyBomMapper baseTechnologyBomMapper;
private final BaseKnifeMapper baseKnifeMapper;
private final WmsOutPlanMapper wmsOutPlanMapper;
private final WmsOutTaskMapper wmsOutTaskMapper;
private final MdItemMapper mdItemMapper;
private final WmStorageAreaMapper wmStorageAreaMapper;
private final MyConfig myConfig;
/**
* 查询入库任务列表
@ -191,6 +210,49 @@ public class WmsInTaskController extends BaseController {
baseKnife.setAreaName(wmStorageArea.getAreaName());
// 更新台账状态
baseKnifeService.updateBaseKnife(baseKnife);
// 判断物料是否有绑定了订单
if (baseKnife.getPlanSheet() != null){
// 获取台账锁定实体并将状态设置为已完成
BaseKnifeLocked baseKnifeLockedWrapper = new BaseKnifeLocked();
baseKnifeLockedWrapper.setStatus(0);
baseKnifeLockedWrapper.setBaseKnifeId(baseKnife.getBaseKnifeId());
baseKnifeLockedWrapper.setPlanSheet(baseKnife.getPlanSheet());
List<BaseKnifeLocked> baseKnifeLockedList = baseKnifeLockedMapper.selectBaseKnifeLockedList(baseKnifeLockedWrapper);
// 获取实体并修改状态
BaseKnifeLocked baseKnifeLocked;
if (!baseKnifeLockedList.isEmpty()){
baseKnifeLocked = baseKnifeLockedList.get(0);
baseKnifeLocked.setStatus(1);
baseKnifeLockedMapper.updateBaseKnifeLocked(baseKnifeLocked);
}
// 再次查询物料是否有预订订单
baseKnifeLockedWrapper.setPlanSheet(null);
baseKnifeLockedList = baseKnifeLockedMapper.selectBaseKnifeLockedList(baseKnifeLockedWrapper);
if (!baseKnifeLockedList.isEmpty()){
baseKnifeLocked = baseKnifeLockedList.get(0);
baseKnife.setPlanSheet(baseKnifeLocked.getPlanSheet());
baseKnife.setIsLocked(1);
baseKnife.setLockedStartTime(baseKnifeLocked.getLockedStartTime());
baseKnife.setLockedEndTime(baseKnifeLocked.getLockedEndTime());
baseKnifeService.updateBaseKnife(baseKnife);
// 检测订单是否完成完成则出库整刀
if (this.checkFinal(baseKnifeLocked.getPlanSheet())) {
try {
this.createOutTask(baseKnifeLocked.getPlanSheet());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} else {
// 订单解绑
baseKnife.setPlanSheet("");
baseKnifeService.updateBaseKnife(baseKnife);
}
}
});
} else if (Objects.equals(wmsInTask.getPlanTypeId(), "15")) {
// 拆刀回库
@ -302,4 +364,209 @@ public class WmsInTaskController extends BaseController {
}
return toAjax(1);
}
// 检查订单完成状态
public Boolean checkFinal(String planSheet) {
// 获取订单记录
ProductionArrangements productionArrangements = productionArrangementsMapper.selectProductionArrangementsByPlanSheet(planSheet);
BaseTechnologyBom baseTechnologyBomWrapper = new BaseTechnologyBom();
baseTechnologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
// 判断订单锁定的物料是否足够
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) throws IOException {
// 构建出库计划
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);
BaseTechnologyBom baseTechnologyBomWrapper = new BaseTechnologyBom();
baseTechnologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
// 判断订单锁定的物料是否足够
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);
});
// 生成出库计划明细
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);
// 给产线控制系统发指令
this.productionArrangementsIsOk(productionArrangements);
}
// 调用生产准备完成接口
public void productionArrangementsIsOk(ProductionArrangements productionArrangements) throws IOException {
// 产线控制系统生产准备完成接口
String url = myConfig.getProductionControlPath() + "/cutterapi/cutComplete";
// 请求客户端
OkHttpClient client = new OkHttpClient();
// 构建请求数据
Map<String, Object> requestMap = new HashMap<>();
requestMap.put("prodordercode", productionArrangements.getPlanSheet());
requestMap.put("result", "0");
requestMap.put("completetime", CalendarUtil.getDateTimeStr());
// 获取工艺信息
BaseTechnologyBom technologyBomWrapper = new BaseTechnologyBom();
technologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(technologyBomWrapper);
BaseKnife baseKnifeWrapper = new BaseKnife();
baseKnifeWrapper.setPlanSheet(productionArrangements.getPlanSheet());
// 获取刀具信息
List<Map<String, String>> cutterList = new ArrayList<>();
technologyBomList.forEach(baseTechnologyBom -> {
baseKnifeWrapper.setKnifeCode(baseTechnologyBom.getKnifeCode());
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
baseKnifeList.forEach(baseKnife -> {
Map<String, String> map = new HashMap<>();
map.put("specno", baseTechnologyBom.getProcessCode());
map.put("code", baseKnife.getKnifeCode());
map.put("name", baseKnife.getKnifeName());
map.put("life", baseKnife.getKnifeLife().toString());
cutterList.add(map);
});
});
requestMap.put("cutterinfo", cutterList);
// 构建请求数据
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(mediaType, JSON.toJSONString(requestMap));
// 请求体
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();
// 发送请求
try(Response response = client.newCall(request).execute()) {
if (!response.isSuccessful())
throw new IOException("Unexpected code " + response);
// 请求响应
String responseBody = response.body().string();
System.out.println(responseBody);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -1,11 +1,12 @@
package com.ktg.mes.wm.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;
import java.util.List;
import java.sql.Date;
/**
* 生产准备记录对象 PRODUCTION_ARRANGEMENTS
@ -35,6 +36,12 @@ public class ProductionArrangements extends BaseEntity
@Excel(name = "状态")
private Integer status;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/** 预留字段1 */
@Excel(name = "预留字段1")
private String attr1;
@ -133,6 +140,23 @@ public class ProductionArrangements extends BaseEntity
return attr4;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
@Override
public String toString() {
return "ProductionArrangements{" +

View File

@ -2,6 +2,7 @@ package com.ktg.mes.wm.mapper;
import java.util.List;
import com.ktg.mes.wm.domain.ProductionArrangements;
import org.apache.ibatis.annotations.Mapper;
/**
* 生产准备记录Mapper接口
@ -9,6 +10,7 @@ import com.ktg.mes.wm.domain.ProductionArrangements;
* @author yinjinlu
* @date 2024-11-18
*/
@Mapper
public interface ProductionArrangementsMapper
{
/**

View File

@ -113,8 +113,8 @@ public class WmsInTaskServiceImpl implements IWmsInTaskService {
task.setCellY(wmStorageArea.getPositionY().toString());
task.setCellZ(wmStorageArea.getPositionZ().toString());
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityService.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery);
task.setWmsInPlanDetailEntityList(wmsInPlanDetailEntityList);
// List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityService.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery);
// task.setWmsInPlanDetailEntityList(wmsInPlanDetailEntityList);
wmsInTaskList.add(task);
});
return wmsInTaskList;

View File

@ -74,6 +74,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
@Autowired
private ProductionArrangementsMapper productionArrangementsMapper;
@Autowired
private BaseKnifeLockedMapper baseKnifeLockedMapper;
/**
* 查询组装任务
*
@ -176,18 +179,25 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
// 查询工艺bom
BaseTechnologyBom technologyBom = new BaseTechnologyBom();
ProductionArrangements productionArrangements = new ProductionArrangements();
Boolean lockedFlag = false;
// attr4 组装任务所属计划单 如果为空则是手动组装任务不需要锁定
// 如果为空则是手动组装任务不需要锁定, 不为空说明是组装任务生成的计划单
if (zdTask.getPlanSheet() != null) {
lockedFlag = true;
// 获取工序工艺bom
BaseTechnologyBom technologyBomWrapper = new BaseTechnologyBom();
technologyBomWrapper.setProcessCode(zdTask.getProcessCode());
MdItem mdItemTemp = mdItemMapper.selectMdItemById(zdTask.getmProductId());
technologyBomWrapper.setKnifeCode(mdItemTemp.getItemCode());
technologyBom = baseTechnologyBomMapper.selectBaseTechnologyBomList(technologyBomWrapper).get(0);
// 获取生产准备记录中的锁定开始结束时间
ProductionArrangements productionArrangementsWrapper = new ProductionArrangements();
productionArrangementsWrapper.setPlanSheet(zdTask.getPlanSheet());
productionArrangements = productionArrangementsMapper.selectProductionArrangementsList(productionArrangementsWrapper).get(0);
}
// 出库基础物料 根据图号查询出库计划如果不存在生成计划存在则往计划中添加任务
// 出库基础物料 根据订单号查询出库计划如果不存在生成计划存在则往计划中添加任务
WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getCode());
if (outPlan == null) {
// 构建新的出库计划
@ -220,15 +230,16 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
baseKnife.setKnifeLife(100);
baseKnife.setKnifeFineState(1);
baseKnife.setIsValid(1);
// 判断是否需要锁定整刀
// 判断是否需要锁定整刀来自订单的组装任务需要锁定
if (lockedFlag) {
baseKnife.setIsLocked(1);
baseKnife.setKnifeFineState(2);
baseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
baseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
baseKnife.setKnifeFineState(1);
baseKnife.setLockedStartTime(productionArrangements.getStartTime());
baseKnife.setLockedEndTime(productionArrangements.getEndTime());
} else {
baseKnife.setIsLocked(0);
}
// attr4 计划编码 整刀
baseKnife.setPlanSheet(zdTask.getPlanSheet());
baseKnife.setZdTaskId(zdTask.getWmsZdTaskId());
@ -237,6 +248,19 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
baseKnife.setCreateTime(DateUtils.getNowDate());
baseKnifeMapper.insertBaseKnife(baseKnife);
if (lockedFlag) {
// 添加物料锁定记录
BaseKnifeLocked baseKnifeLocked = new BaseKnifeLocked();
baseKnifeLocked.setPlanSheet(zdTask.getPlanSheet());
baseKnifeLocked.setBaseKnifeId(baseKnife.getBaseKnifeId());
baseKnifeLocked.setItemCode(mdItem.getItemCode());
baseKnifeLocked.setExpendLife(technologyBom.getExpendLife());
baseKnifeLocked.setStatus(0);
baseKnifeLocked.setLockedStartTime(productionArrangements.getStartTime());
baseKnifeLocked.setLockedEndTime(productionArrangements.getEndTime());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
}
// 锁定物料
int resetCount = 0;
for (MbbProduBom mbbProduBom : bomRoute.getMbbProduBomList()) {
@ -249,11 +273,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
int bomCount = mbbProduBom.getStandardDosage();
for (BaseKnife wmsBaseKnife : baseKnifeList) {
if (bomCount > 0) {
// 绑定到组装任务 整刀父id
wmsBaseKnife.setZdTaskId(zdTask.getWmsZdTaskId());
wmsBaseKnife.setIsLocked(1);
wmsBaseKnife.setKnifeFineState(2);
wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
wmsBaseKnife.setParentId(baseKnife.getBaseKnifeId());
wmsBaseKnife.setPlanSheet(zdTask.getPlanSheet());
baseKnifeListOutPlan.add(wmsBaseKnife);
@ -268,6 +290,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
// 更新重置次数
baseKnife.setResetCount(resetCount - 1);
// 设置rfid, 为整刀编码加序号 例如整刀编码为 aaa 则整刀rfid为 aaa0001 aaa0002, 传个i在当前事务中新增的台账还没提交所以把循环系数加上
baseKnife.setRfid(this.getProductRfid(zdTask.getmProductId(), i));
baseKnifeMapper.updateBaseKnife(baseKnife);
}
@ -349,7 +374,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
wmsOutTask.setMdItemCode(outPlanDetail.getMdItemCode());
wmsOutTask.setMdItemName(outPlanDetail.getMdItemName());
wmsOutTask.setMdItemUnit(outPlanDetail.getMdItemUnit());
wmsOutTask.setTaskState("1");
wmsOutTask.setTaskState("0");
wmsOutTask.setRecipientUsername("");
wmsOutTask.setCreateBy(getUsername());
wmsOutTask.setCreateTime(DateUtils.getNowDate());
@ -358,11 +383,24 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
});
// 更新组装任务
zdTask.setStatus("1");
zdTask.setStatus("3");
wmsZdTaskMapper.updateWmsZdTask(zdTask);
return AjaxResult.success();
}
public String getProductRfid(Long itemId, int i){
MdItem mdItem = mdItemMapper.selectMdItemById(itemId);
// 获取最大的RFID 然后加1 RFID为物料的编码加序号
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeListByMbbBdMrlId(itemId);
if (baseKnifeList.isEmpty()) return mdItem.getItemCode() + String.format("%04d", 1);
else {
String index = baseKnifeList.get(0).getRfid().substring(baseKnifeList.get(0).getRfid().length() - 4);
Integer indexInt = Integer.parseInt(index) + 1 + i;
return mdItem.getItemCode() + String.format("%04d", indexInt);
}
}
@Override
@Transactional
@ -377,15 +415,16 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
// 整刀入库计划, 根据图号查询入库计划如果不存在生成计划存在则往计划中添加任务
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(zdTask.getAreaId());
WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getCode());
WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getPlanSheet());
if (wmsInPlan == null) {
WmsInPlan wmsInPlanTemp = new WmsInPlan();
wmsInPlanTemp.setState("1");
wmsInPlanTemp.setSourceType("SGLR");
wmsInPlanTemp.setSourceType(zdTask.getPlanSheet() != null ? "SCZB" : "ZZRW");
wmsInPlanTemp.setCellCode(wmStorageArea.getAreaCode());
wmsInPlanTemp.setPlanCode(zdTask.getCode());
wmsInPlanTemp.setPlanCode(zdTask.getPlanSheet() != null ? zdTask.getPlanSheet() : zdTask.getCode());
wmsInPlanTemp.setRelBillCode("组装单据");
wmsInPlanTemp.setPlanTypeId(13L);
wmsInPlanTemp.setPlanTypeId(9L);
wmsInPlanTemp.setPlanTypeCode("ZDHK");
wmsInPlanTemp.setCreateBy(getUsername());
wmsInPlanTemp.setCreateTime(DateUtils.getNowDate());
@ -426,6 +465,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
wmsInPlanService.updateWmsInPlan(wmsInPlan);
}
// 复查一遍入库计划
WmsInPlan inPlanTemp = wmsInPlanService.selectWmsInPlanByPlanId(wmsInPlan.getPlanId());
// 入库任务
MdItem mdItem = mdItemMapper.selectMdItemById(zdTask.getmProductId());
WmsInTask wmsInTask = new WmsInTask();
@ -441,7 +483,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
wmsInTask.setBatch(batchNum);
wmsInTask.setMaterialId(zdTask.getmProductId().toString());
wmsInTask.setPlanTypeId("9");
wmsInTask.setPlanInStatus("1");
wmsInTask.setPlanTypeCode("ZDHK");
wmsInTask.setPlanInStatus("0");
wmsInTask.setDetailInId(inPlanTemp.getWmsInPlanDetailsList().get(0).getDetailsId());
wmsInTask.setCreateBy(getUsername());
wmsInTask.setCreateTime(DateUtils.getNowDate());
wmsInTaskMapper.insertWmsInTask(wmsInTask);
@ -453,6 +497,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
return AjaxResult.success();
}
@Override
public String checkTaskCodeUnique(WmsZdTask wmsZdTask) {
WmsZdTask zdTask = wmsZdTaskMapper.checkTaskCodeUnique(wmsZdTask);

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ktg.mes.md.mapper.BaseKnifeLockedMapper">
<resultMap type="BaseKnifeLocked" id="BaseKnifeLockedResult">
<result property="baseKnifeId" column="BASE_KNIFE_ID" />
<result property="planSheet" column="PLAN_SHEET" />
<result property="itemCode" column="ITEM_CODE" />
<result property="expendLife" column="EXPEND_LIFE" />
<result property="status" column="STATUS" />
<result property="lockedStartTime" column="LOCKED_START_TIME" />
<result property="lockedEndTime" column="LOCKED_END_TIME" />
<result property="baseKnifeLockedId" column="BASE_KNIFE_LOCKED_ID" />
</resultMap>
<sql id="selectBaseKnifeLockedVo">
select BASE_KNIFE_ID, PLAN_SHEET, ITEM_CODE, EXPEND_LIFE, STATUS, LOCKED_START_TIME, LOCKED_END_TIME, BASE_KNIFE_LOCKED_ID from BASE_KNIFE_LOCKED
</sql>
<select id="selectBaseKnifeLockedList" parameterType="BaseKnifeLocked" resultMap="BaseKnifeLockedResult">
<include refid="selectBaseKnifeLockedVo"/>
<where>
<if test="baseKnifeId != null and baseKnifeId != ''"> and BASE_KNIFE_ID = #{baseKnifeId}</if>
<if test="planSheet != null and planSheet != ''"> and PLAN_SHEET = #{planSheet}</if>
<if test="itemCode != null and itemCode != ''"> and ITEM_CODE = #{itemCode}</if>
<if test="expendLife != null and expendLife != ''"> and EXPEND_LIFE = #{expendLife}</if>
<if test="status != null"> and STATUS = #{status}</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>
</where>
order by LOCKED_START_TIME
</select>
<select id="selectBaseKnifeLockedByBaseKnifeLockedId" parameterType="String" resultMap="BaseKnifeLockedResult">
<include refid="selectBaseKnifeLockedVo"/>
where BASE_KNIFE_LOCKED_ID = #{baseKnifeLockedId}
</select>
<insert id="insertBaseKnifeLocked" parameterType="BaseKnifeLocked" useGeneratedKeys="true" keyProperty="baseKnifeLockedId">
insert into BASE_KNIFE_LOCKED
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="baseKnifeId != null">BASE_KNIFE_ID,</if>
<if test="planSheet != null">PLAN_SHEET,</if>
<if test="itemCode != null">ITEM_CODE,</if>
<if test="expendLife != null">EXPEND_LIFE,</if>
<if test="status != null">STATUS,</if>
<if test="lockedStartTime != null">LOCKED_START_TIME,</if>
<if test="lockedEndTime != null">LOCKED_END_TIME,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="baseKnifeId != null">#{baseKnifeId},</if>
<if test="planSheet != null">#{planSheet},</if>
<if test="itemCode != null">#{itemCode},</if>
<if test="expendLife != null">#{expendLife},</if>
<if test="status != null">#{status},</if>
<if test="lockedStartTime != null">#{lockedStartTime},</if>
<if test="lockedEndTime != null">#{lockedEndTime},</if>
</trim>
</insert>
<update id="updateBaseKnifeLocked" parameterType="BaseKnifeLocked">
update BASE_KNIFE_LOCKED
<trim prefix="SET" suffixOverrides=",">
<if test="baseKnifeId != null">BASE_KNIFE_ID = #{baseKnifeId},</if>
<if test="planSheet != null">PLAN_SHEET = #{planSheet},</if>
<if test="itemCode != null">ITEM_CODE = #{itemCode},</if>
<if test="expendLife != null">EXPEND_LIFE = #{expendLife},</if>
<if test="status != null">STATUS = #{status},</if>
<if test="lockedStartTime != null">LOCKED_START_TIME = #{lockedStartTime},</if>
<if test="lockedEndTime != null">LOCKED_END_TIME = #{lockedEndTime},</if>
</trim>
where BASE_KNIFE_LOCKED_ID = #{baseKnifeLockedId}
</update>
<delete id="deleteBaseKnifeLockedByBaseKnifeLockedId" parameterType="String">
delete from BASE_KNIFE_LOCKED where BASE_KNIFE_LOCKED_ID = #{baseKnifeLockedId}
</delete>
<delete id="deleteBaseKnifeLockedByBaseKnifeLockedIds" parameterType="String">
delete from BASE_KNIFE_LOCKED where BASE_KNIFE_LOCKED_ID in
<foreach item="baseKnifeLockedId" collection="array" open="(" separator="," close=")">
#{baseKnifeLockedId}
</foreach>
</delete>
</mapper>

View File

@ -619,4 +619,15 @@
WHERE KNIFE_FINE_STATE == 1
GROUP BY AREA_CODE
</select>
<select id="selectBaseKnifeListByMbbBdMrlId" resultType="com.ktg.mes.md.domain.BaseKnife">
<include refid="selectBaseKnifeVo"/>
<where>
IS_VALID = 0
<if test="mbbBdMrlId != null and mbbBdMrlId != ''">
and MBB_BD_MRL_ID = #{mbbBdMrlId}
</if>
</where>
order by rfid desc
</select>
</mapper>

View File

@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="ProductionArrangements" id="ProductionArrangementsResult">
<result property="productionArrangementsId" column="PRODUCTION_ARRANGEMENTS_ID" />
<result property="planSheet" column="PLAN_SHEET" />
<result property="processCode" column="PROCESS_CODE" />
<result property="technologyCode" column="TECHNOLOGY_CODE" />
<result property="status" column="STATUS" />
<result property="attr1" column="ATTR1" />
<result property="attr2" column="ATTR2" />
@ -17,17 +17,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="CREATE_TIME" />
<result property="updateBy" column="UPDATE_BY" />
<result property="updateTime" column="UPDATE_TIME" />
<result property="startTime" column="START_TIME" />
<result property="endTime" column="END_TIME" />
</resultMap>
<sql id="selectProductionArrangementsVo">
select PRODUCTION_ARRANGEMENTS_ID, PLAN_SHEET, PROCESS_CODE, STATUS, ATTR1, ATTR2, ATTR3, ATTR4, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME from PRODUCTION_ARRANGEMENTS
select PRODUCTION_ARRANGEMENTS_ID, PLAN_SHEET, TECHNOLOGY_CODE, STATUS, ATTR1, ATTR2, ATTR3, ATTR4, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, START_TIME, END_TIME from PRODUCTION_ARRANGEMENTS
</sql>
<select id="selectProductionArrangementsList" parameterType="ProductionArrangements" resultMap="ProductionArrangementsResult">
<include refid="selectProductionArrangementsVo"/>
<where>
<if test="planSheet != null and planSheet != ''"> and PLAN_SHEET = #{planSheet}</if>
<if test="processCode != null and processCode != ''"> and PROCESS_CODE = #{processCode}</if>
<if test="technologyCode != null and technologyCode != ''"> and TECHNOLOGY_CODE = #{technologyCode}</if>
<if test="status != null and status != ''"> and STATUS = #{status}</if>
<if test="attr1 != null and attr1 != ''"> and ATTR1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''"> and ATTR2 = #{attr2}</if>
@ -37,6 +39,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null and createTime != ''"> and CREATE_TIME = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
<if test="updateTime != null and updateTime != ''"> and UPDATE_TIME = #{updateTime}</if>
<if test="startTime != null and startTime != ''"> and START_TIME = #{startTime}</if>
<if test="endTime != null and endTime != ''"> and END_TIME = #{endTime}</if>
</where>
</select>
@ -65,6 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">CREATE_TIME,</if>
<if test="updateBy != null">UPDATE_BY,</if>
<if test="updateTime != null">UPDATE_TIME,</if>
<if test="startTime != null">START_TIME,</if>
<if test="endTime != null">END_TIME,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planSheet != null">#{planSheet},</if>
@ -79,6 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
</trim>
</insert>
@ -96,6 +104,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">CREATE_TIME = #{createTime},</if>
<if test="updateBy != null">UPDATE_BY = #{updateBy},</if>
<if test="updateTime != null">UPDATE_TIME = #{updateTime},</if>
<if test="startTime != null">START_TIME = #{startTime},</if>
<if test="endTime != null">END_TIME = #{endTime},</if>
</trim>
where PRODUCTION_ARRANGEMENTS_ID = #{productionArrangementsId}
</update>

View File

@ -54,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="planOutId != null and planOutId != ''"> and PLAN_OUT_ID = #{planOutId}</if>
<if test="planOutType != null and planOutType != ''"> and PLAN_OUT_TYPE = #{planOutType}</if>
<if test="technologyBomId != null and technologyBomId != ''"> and technology_bom_id = #{technologyBomId}</if>
<if test="planSheet != null and planSheet != ''"> and plan_sheet = #{planSheet}</if>
<if test="qtyOk != null and qtyOk != ''"> and QTY_OK = #{qtyOk}</if>
<if test="remark != null and remark != ''"> and REMARK = #{remark}</if>
<if test="attr1 != null and attr1 != ''"> and ATTR1 = #{attr1}</if>