初步完成生产准备中检索出其他订单中正在使用的刀具

This commit is contained in:
汤锦科 2024-12-11 17:24:43 +08:00
parent 009fbbf04d
commit ffb885d0aa
12 changed files with 1224 additions and 21 deletions

View File

@ -62,6 +62,10 @@
<groupId>com.ktg</groupId>
<artifactId>ktg-generator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSON;
import com.ktg.common.utils.DateUtils;
import com.ktg.generator.util.MultiModuleCodeGenerator;
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;
@ -82,6 +83,10 @@ public class BaseKnifeController extends BaseController {
@Autowired
private ProductionArrangementsMapper productionArrangementsMapper;
@Autowired
private BaseKnifeLockedMapper baseKnifeLockedMapper;
/**
* 列表查询
@ -313,15 +318,16 @@ public class BaseKnifeController extends BaseController {
}
@PostMapping("/open/productionArrangements")
@PostMapping("/open/productionArrangementsO")
@ResponseBody
@Transactional
public AjaxResult productionArrangements(@RequestBody ProductionArrangements productionArrangements) {
// 检查计划单是否已存在
public AjaxResult productionArrangementsO(@RequestBody ProductionArrangements productionArrangements) {
// 检查计划单是否已存在 从台账表中寻找
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())
@ -333,7 +339,7 @@ public class BaseKnifeController extends BaseController {
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());
@ -386,10 +392,11 @@ public class BaseKnifeController extends BaseController {
return AjaxResult.error("物料台账查询错误", 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());
@ -406,6 +413,7 @@ public class BaseKnifeController extends BaseController {
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
}
// 获取整刀BOM 进行子项遍历
BomRoute bomRoute = bomRouteService.selectBomRouteByBomRouteId(bomRouteList.get(0).getBomRouteId());
if (!bomRoute.getMbbProduBomList().isEmpty()) {
@ -416,6 +424,7 @@ public class BaseKnifeController extends BaseController {
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
// 判断基础物料是否足够
if (sitmTempList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
@ -611,6 +620,8 @@ 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);
@ -722,6 +733,566 @@ public class BaseKnifeController extends BaseController {
return AjaxResult.success(msg);
}
@PostMapping("/open/productionArrangements")
@ResponseBody
@Transactional
public AjaxResult productionArrangements(@RequestBody ProductionArrangements productionArrangements) {
// 检查计划单是否已存在 从台账表中寻找
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("该计划单已存在,请更换重试");
// 验证工艺BOM是否存在
BaseTechnologyBom baseTechnologyBomWrapper = new BaseTechnologyBom();
baseTechnologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
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<>();
// 参数列表
Map<String, Object> params = new HashMap<>();
params.put("planCode", productionArrangements.getPlanSheet());
params.put("processCode", productionArrangements.getTechnologyCode());
params.put("processUnit", productionArrangements.getProcessUnit());
// 构建日志
SysOperLog operLog = new SysOperLog();
operLog.setTitle("生产准备");
operLog.setBusinessType(0);
operLog.setRequestMethod("POST");
operLog.setOperName("上游系统");
operLog.setOperIp("上游系统");
operLog.setOperLocation("上游系统");
operLog.setOperUrl("/mes/md/baseKnife/open/productionArrangements");
operLog.setMethod("com.ktg.mes.md.controller.BaseKnifeController.productionArrangements()");
operLog.setOperParam(JSON.toJSONString(params));
operLog.setStatus(1);
operLog.setOperTime(new Date());
// 接口返回信息
String msg = "生产准备验证成功!";
// 记录所符合需求的物料数量 map
Map<String, Integer> countMap = new HashMap<>();
BaseKnife baseKnifeWrapper = new BaseKnife();
BomRoute bomRouteTemp = new BomRoute();
MdItem mdItemTemp = new MdItem();
// 遍历工艺bom 所需要的所有材料
for (BaseTechnologyBom techBom : technologyBomList) {
// 空则0
countMap.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());
}
// 查询符合条件的台账 锁定状态为 0 空闲中
baseKnifeWrapper.setMbbBdMrlId(mdItemTemp.getItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> tempList = this.baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
// 过滤不符合需求的物料 当前寿命小于工艺消耗定额
if (Objects.equals("PRODUCT", mdItemTemp.getItemOrProduct())) 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());
}
// 获取整刀BOM 进行子项遍历
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()) {
// 当前库内无符合需求的物料 尝试查询已经在订单中的刀但作业时间不同
List<Long> lockedBaseKnifeIds = this.getLockedBaseKnifeId(mdItemTemp.getItemCode(), productionArrangements, knifeCount.get(), techBom.getExpendLife());
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());
baseKnifeLocked.setExpendLife(techBom.getExpendLife());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
// 生产准备中的物料更新数量
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + 1);
});
} else {
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 {
// 当前库内无符合需求的物料 尝试查询已经在订单中的刀但作业时间不同
List<Long> lockedBaseKnifeIds = new ArrayList<>();
// 判断当前物料能组成几把刀 不够的刀从锁定中的拿
while (knifeCount.getAndDecrement() > 0) {
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
lockedBaseKnifeIds = this.getLockedBaseKnifeId(mdItemTemp.getItemCode(), productionArrangements, techBom.getKnifeCount() - knifeCount.get(), techBom.getExpendLife());
break;
}
}
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());
baseKnifeLocked.setExpendLife(techBom.getExpendLife());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
// 生产准备中的物料更新数量
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + 1);
});
} 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 -> {
if (knifeCount.get() > 0 && tempList.size() > countMap.get(item.getKnifeCode())) {
// 更新数量
knifeCount.getAndDecrement();
countMap.put(item.getKnifeCode(), countMap.get(item.getKnifeCode()) + 1);
// 记录源数据然后锁定
baseKnifeOriginList.add(item);
item.setPlanSheet(productionArrangements.getPlanSheet());
item.setIsLocked(1);
item.setLockedStartTime(productionArrangements.getStartTime());
item.setLockedEndTime(productionArrangements.getEndTime());
baseKnifeService.updateBaseKnife(item);
}
});
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()) {
List<Long> lockedBaseKnifeIds = this.getLockedBaseKnifeId(mdItemTemp.getItemCode(), productionArrangements, knifeCount.get(), techBom.getExpendLife());
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());
baseKnifeLocked.setExpendLife(techBom.getExpendLife());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
// 生产准备中的物料更新数量
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + 1);
});
} else {
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 {
List<Long> lockedBaseKnifeIds = new ArrayList<>();
// 判断当前物料能组成几把刀 不够的刀从锁定中的拿
while (knifeCount.getAndDecrement() > 0) {
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
lockedBaseKnifeIds = this.getLockedBaseKnifeId(mdItemTemp.getItemCode(), productionArrangements, techBom.getKnifeCount() - knifeCount.get(), techBom.getExpendLife());
break;
}
}
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());
baseKnifeLocked.setExpendLife(techBom.getExpendLife());
baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
// 生产准备中的物料更新数量
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + 1);
});
} 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());
// 更新countMap
if (techBom.getKnifeCount() >= countMap.get(techBom.getKnifeCode()))
countMap.put(techBom.getKnifeCode(), 0);
else
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + techBom.getKnifeCount());
// 先从台账表找
baseKnifeWrapper.setMbbBdMrlId(mdItem.getItemId());
baseKnifeWrapper.setIsLocked(0);
baseKnifeList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
if (Objects.equals("PRODUCT", mdItem.getItemOrProduct())) 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 wmsZdTaskWrapper = new WmsZdTask();
wmsZdTaskWrapper.setPlanSheet(productionArrangements.getPlanSheet());
wmsZdTaskWrapper.setmProductId(mdItem.getItemId());
List<WmsZdTask> wmsZdTaskList = zdTaskService.selectWmsZdTaskList(wmsZdTaskWrapper);
if (wmsZdTaskList.isEmpty()){
// 生成组装任务
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 {
WmsZdTask wmsZdTask = wmsZdTaskList.get(0);
wmsZdTask.setProductIdQty(wmsZdTask.getProductIdQty() + count);
wmsZdTask.setCreateTime(DateUtils.getNowDate());
msg = "生产准备验证成功!缺少物料已生成组装任务!";
}
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("缺少BOM项" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("缺少BOM项", techBom.getKnifeCode());
}
}
}
// 添加生产准备记录
// productionArrangements.setProcessCode(productionArrangements.getProcessCodes().toString());
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("缺少物料已生成组装任务!")) {
// 生成出库计划单
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<>();
// 遍历构建map
baseKnifeOriginList.forEach(item -> {
// 判断当前物料主键是否已经被收录
baseKnifeHashMapMap.computeIfAbsent(item.getMbbBdMrlId(), k -> new HashMap<>());
// 判断当前库位编码是否已经被收录
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).computeIfAbsent(item.getAreaCode(), k -> new ArrayList<>());
// 对当前台账对象进行收录
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).get(item.getAreaCode()).add(item);
// 出库
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);
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);
}
operLog.setJsonResult(msg);
operLog.setStatus(0);
operLogService.insertOperlog(operLog);
return AjaxResult.success(msg);
}
public List<Long> getLockedBaseKnifeId(String mdItemCode, ProductionArrangements productionArrangements, int count, int expendLife){
// 查询该物料编码的锁定记录
BaseKnifeLocked baseKnifeLockedWrapper = new BaseKnifeLocked();
baseKnifeLockedWrapper.setItemCode(mdItemCode);
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 || ((baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100) - item.getExpendLife()) < expendLife) 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;
}
/**
* 修改工具台账

View File

@ -0,0 +1,104 @@
package com.ktg.mes.md.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktg.common.annotation.Log;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.enums.BusinessType;
import com.ktg.mes.md.domain.BaseKnifeLocked;
import com.ktg.mes.md.service.IBaseKnifeLockedService;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo;
/**
* 台账锁定Controller
*
* @author yinjinlu
* @date 2024-12-09
*/
@RestController
@RequestMapping("/md/LOCKED")
public class BaseKnifeLockedController extends BaseController
{
@Autowired
private IBaseKnifeLockedService baseKnifeLockedService;
/**
* 查询台账锁定列表
*/
@PreAuthorize("@ss.hasPermi('md:LOCKED:list')")
@GetMapping("/list")
public TableDataInfo list(BaseKnifeLocked baseKnifeLocked)
{
startPage();
List<BaseKnifeLocked> list = baseKnifeLockedService.selectBaseKnifeLockedList(baseKnifeLocked);
return getDataTable(list);
}
/**
* 导出台账锁定列表
*/
@PreAuthorize("@ss.hasPermi('md:LOCKED:export')")
@Log(title = "台账锁定", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BaseKnifeLocked baseKnifeLocked)
{
List<BaseKnifeLocked> list = baseKnifeLockedService.selectBaseKnifeLockedList(baseKnifeLocked);
ExcelUtil<BaseKnifeLocked> util = new ExcelUtil<BaseKnifeLocked>(BaseKnifeLocked.class);
util.exportExcel(response, list, "台账锁定数据");
}
/**
* 获取台账锁定详细信息
*/
@PreAuthorize("@ss.hasPermi('md:LOCKED:query')")
@GetMapping(value = "/{baseKnifeLockedId}")
public AjaxResult getInfo(@PathVariable("baseKnifeLockedId") String baseKnifeLockedId)
{
return AjaxResult.success(baseKnifeLockedService.selectBaseKnifeLockedByBaseKnifeLockedId(baseKnifeLockedId));
}
/**
* 新增台账锁定
*/
@PreAuthorize("@ss.hasPermi('md:LOCKED:add')")
@Log(title = "台账锁定", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BaseKnifeLocked baseKnifeLocked)
{
return toAjax(baseKnifeLockedService.insertBaseKnifeLocked(baseKnifeLocked));
}
/**
* 修改台账锁定
*/
@PreAuthorize("@ss.hasPermi('md:LOCKED:edit')")
@Log(title = "台账锁定", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BaseKnifeLocked baseKnifeLocked)
{
return toAjax(baseKnifeLockedService.updateBaseKnifeLocked(baseKnifeLocked));
}
/**
* 删除台账锁定
*/
@PreAuthorize("@ss.hasPermi('md:LOCKED:remove')")
@Log(title = "台账锁定", businessType = BusinessType.DELETE)
@DeleteMapping("/{baseKnifeLockedIds}")
public AjaxResult remove(@PathVariable String[] baseKnifeLockedIds)
{
return toAjax(baseKnifeLockedService.deleteBaseKnifeLockedByBaseKnifeLockedIds(baseKnifeLockedIds));
}
}

View File

@ -0,0 +1,134 @@
package com.ktg.mes.md.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.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

@ -0,0 +1,63 @@
package com.ktg.mes.md.mapper;
import java.util.List;
import com.ktg.mes.md.domain.BaseKnifeLocked;
import org.apache.ibatis.annotations.Mapper;
/**
* 台账锁定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

@ -0,0 +1,61 @@
package com.ktg.mes.md.service;
import java.util.List;
import com.ktg.mes.md.domain.BaseKnifeLocked;
/**
* 台账锁定Service接口
*
* @author yinjinlu
* @date 2024-12-09
*/
public interface IBaseKnifeLockedService
{
/**
* 查询台账锁定
*
* @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 baseKnifeLockedIds 需要删除的台账锁定主键集合
* @return 结果
*/
public int deleteBaseKnifeLockedByBaseKnifeLockedIds(String[] baseKnifeLockedIds);
/**
* 删除台账锁定信息
*
* @param baseKnifeLockedId 台账锁定主键
* @return 结果
*/
public int deleteBaseKnifeLockedByBaseKnifeLockedId(String baseKnifeLockedId);
}

View File

@ -0,0 +1,93 @@
package com.ktg.mes.md.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktg.mes.md.mapper.BaseKnifeLockedMapper;
import com.ktg.mes.md.domain.BaseKnifeLocked;
import com.ktg.mes.md.service.IBaseKnifeLockedService;
/**
* 台账锁定Service业务层处理
*
* @author yinjinlu
* @date 2024-12-09
*/
@Service
public class BaseKnifeLockedServiceImpl implements IBaseKnifeLockedService
{
@Autowired
private BaseKnifeLockedMapper baseKnifeLockedMapper;
/**
* 查询台账锁定
*
* @param baseKnifeLockedId 台账锁定主键
* @return 台账锁定
*/
@Override
public BaseKnifeLocked selectBaseKnifeLockedByBaseKnifeLockedId(String baseKnifeLockedId)
{
return baseKnifeLockedMapper.selectBaseKnifeLockedByBaseKnifeLockedId(baseKnifeLockedId);
}
/**
* 查询台账锁定列表
*
* @param baseKnifeLocked 台账锁定
* @return 台账锁定
*/
@Override
public List<BaseKnifeLocked> selectBaseKnifeLockedList(BaseKnifeLocked baseKnifeLocked)
{
return baseKnifeLockedMapper.selectBaseKnifeLockedList(baseKnifeLocked);
}
/**
* 新增台账锁定
*
* @param baseKnifeLocked 台账锁定
* @return 结果
*/
@Override
public int insertBaseKnifeLocked(BaseKnifeLocked baseKnifeLocked)
{
return baseKnifeLockedMapper.insertBaseKnifeLocked(baseKnifeLocked);
}
/**
* 修改台账锁定
*
* @param baseKnifeLocked 台账锁定
* @return 结果
*/
@Override
public int updateBaseKnifeLocked(BaseKnifeLocked baseKnifeLocked)
{
return baseKnifeLockedMapper.updateBaseKnifeLocked(baseKnifeLocked);
}
/**
* 批量删除台账锁定
*
* @param baseKnifeLockedIds 需要删除的台账锁定主键
* @return 结果
*/
@Override
public int deleteBaseKnifeLockedByBaseKnifeLockedIds(String[] baseKnifeLockedIds)
{
return baseKnifeLockedMapper.deleteBaseKnifeLockedByBaseKnifeLockedIds(baseKnifeLockedIds);
}
/**
* 删除台账锁定信息
*
* @param baseKnifeLockedId 台账锁定主键
* @return 结果
*/
@Override
public int deleteBaseKnifeLockedByBaseKnifeLockedId(String baseKnifeLockedId)
{
return baseKnifeLockedMapper.deleteBaseKnifeLockedByBaseKnifeLockedId(baseKnifeLockedId);
}
}

View File

@ -3,6 +3,7 @@ package com.ktg.mes.wm.controller;
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.domain.BaseEntity;
import com.ktg.common.core.page.TableDataInfo;
import com.ktg.common.enums.BusinessType;
import com.ktg.common.utils.DateUtils;
@ -55,6 +56,7 @@ public class WmsInTaskController extends BaseController {
private final BaseTechnologyBomMapper baseTechnologyBomMapper;
private final WmsZdTaskMapper wmsZdTaskMapper;
private final WmStorageAreaMapper wmStorageAreaMapper;
private final BaseKnifeLockedMapper baseKnifeLockedMapper;
/**
* 查询入库任务列表
@ -79,6 +81,7 @@ public class WmsInTaskController extends BaseController {
return AjaxResult.success(wmsInTask);
}
/**
* 查询入库任务列表
*/
@ -228,6 +231,40 @@ public class WmsInTaskController extends BaseController {
}
// 更新台账状态
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 = 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())) this.createOutTask(baseKnifeLocked.getPlanSheet());
} else {
// 订单解绑
baseKnife.setPlanSheet(null);
baseKnifeService.updateBaseKnife(baseKnife);
}
}
});
} else if (Objects.equals(wmsInTask.getPlanTypeId(), "15")) {
// 拆刀回库

View File

@ -1,10 +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.Date;
import java.util.List;
/**
@ -28,12 +30,17 @@ public class ProductionArrangements extends BaseEntity
@Excel(name = "工艺编码")
private String technologyCode;
// @Excel(name = "工序号")
// private List<String> processCodes;
@Excel(name = "加工单元")
private String processUnit;
/** 开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/** 结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/** 状态 */
@Excel(name = "状态")
private Integer status;
@ -94,13 +101,21 @@ public class ProductionArrangements extends BaseEntity
this.processUnit = processUnit;
}
// public List<String> getProcessCodes() {
// return processCodes;
// }
//
// public void setProcessCodes(List<String> processCodes) {
// this.processCodes = processCodes;
// }
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;
}
public Integer getStatus()
{

View File

@ -78,6 +78,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
@Autowired
private ProductionArrangementsMapper productionArrangementsMapper;
@Autowired
private BaseKnifeLockedMapper baseKnifeLockedMapper;
@Autowired
private MyConfig myConfig;
@ -183,15 +186,22 @@ 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);
}
// 出库基础物料 根据图号查询出库计划如果不存在生成计划存在则往计划中添加任务
@ -231,8 +241,8 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
if (lockedFlag) {
baseKnife.setIsLocked(1);
baseKnife.setKnifeFineState(1);
baseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
baseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
baseKnife.setLockedStartTime(productionArrangements.getStartTime());
baseKnife.setLockedEndTime(productionArrangements.getEndTime());
} else {
baseKnife.setIsLocked(0);
}
@ -245,6 +255,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;
String rfid = "";
@ -261,8 +284,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
if ("ITEM".equals(wmsBaseKnife.getItemOrProduct())) rfid = wmsBaseKnife.getRfid();
wmsBaseKnife.setZdTaskId(zdTask.getWmsZdTaskId());
wmsBaseKnife.setIsLocked(1);
wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
wmsBaseKnife.setRfid("");
// wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
// wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
wmsBaseKnife.setParentId(baseKnife.getBaseKnifeId());
wmsBaseKnife.setPlanSheet(zdTask.getPlanSheet());
baseKnifeListOutPlan.add(wmsBaseKnife);

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

@ -17,10 +17,12 @@ 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, TECHNOLOGY_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">
@ -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>