From 142d2b8b857fa53665ad4463d4967aa068217e19 Mon Sep 17 00:00:00 2001 From: HuangHuiKang Date: Mon, 27 Jul 2026 14:31:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=85=B7?= =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moldrepair/MoldRepairServiceImpl.java | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/moldrepair/MoldRepairServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/moldrepair/MoldRepairServiceImpl.java index c6a707226..3eec3280e 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/moldrepair/MoldRepairServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/moldrepair/MoldRepairServiceImpl.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldBrandDO; import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO; import cn.iocoder.yudao.module.common.dal.mysql.mold.MoldBrandMapper; +import cn.iocoder.yudao.module.common.enums.MoldBrandStatusEnum; import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil; import cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo.dashboard.EventStatisticsVO; import cn.iocoder.yudao.module.common.controller.admin.moldrepair.enums.RepairResultEnum; @@ -91,6 +92,7 @@ public class MoldRepairServiceImpl implements MoldRepairService { // 插入 MoldRepairDO moldRepair = BeanUtils.toBean(createReqVO, MoldRepairDO.class); moldRepairMapper.insert(moldRepair); + updateMoldBrandStatus(moldRepair.getMoldId(), MoldBrandStatusEnum.REPAIRING.getStatus()); sendCreateNotifyMessage(moldRepair); // 插入子表 @@ -124,7 +126,7 @@ public class MoldRepairServiceImpl implements MoldRepairService { @Transactional(rollbackFor = Exception.class) public void updateMoldRepair(MoldRepairSaveReqVO updateReqVO) { // 校验存在 - validateMoldRepairExists(updateReqVO.getId()); + MoldRepairDO oldMoldRepair = validateMoldRepairExists(updateReqVO.getId()); //编码重复判断 Long count = moldRepairMapper.selectCount(new LambdaQueryWrapper() @@ -140,6 +142,8 @@ public class MoldRepairServiceImpl implements MoldRepairService { // 更新 MoldRepairDO updateObj = BeanUtils.toBean(updateReqVO, MoldRepairDO.class); moldRepairMapper.updateById(updateObj); + Long moldId = updateReqVO.getMoldId() != null ? updateReqVO.getMoldId() : oldMoldRepair.getMoldId(); + updateMoldBrandStatusByRepairResult(moldId, updateReqVO.getRepairStatus()); // 更新子表 // updateMoldRepairLineList(updateReqVO.getId(), updateReqVO.getMoldRepairLines()); @@ -159,10 +163,12 @@ public class MoldRepairServiceImpl implements MoldRepairService { } - private void validateMoldRepairExists(Long id) { - if (moldRepairMapper.selectById(id) == null) { + private MoldRepairDO validateMoldRepairExists(Long id) { + MoldRepairDO moldRepair = moldRepairMapper.selectById(id); + if (moldRepair == null) { throw exception(MOLD_REPAIR_NOT_EXISTS); } + return moldRepair; } @Override @@ -304,6 +310,7 @@ public class MoldRepairServiceImpl implements MoldRepairService { moldRepairDO.setConfirmDate(updateReqVO.getConfirmDate()); moldRepairDO.setRepairResult(updateReqVO.getRepairResult()); moldRepairMapper.updateById(moldRepairDO); + updateMoldBrandStatusByRepairResult(moldRepairDO.getMoldId(), updateReqVO.getRepairResult()); batchUpdateTicketResults(updateReqVO.getUpdateReqVOList()); } @@ -457,14 +464,49 @@ public class MoldRepairServiceImpl implements MoldRepairService { .anyMatch(vo -> vo.getResult() != null && vo.getResult().equals(JobResultEnum.FAIL.getCode())); if (hasFail) { moldRepairDO.setRepairStatus(JobResultEnum.FAIL.getCode()); + updateMoldBrandStatus(moldRepairDO.getMoldId(), MoldBrandStatusEnum.REPAIRING.getStatus()); } else { moldRepairDO.setRepairStatus(JobResultEnum.PASS.getCode()); + updateMoldBrandStatus(moldRepairDO.getMoldId(), MoldBrandStatusEnum.STANDBY.getStatus()); } moldRepairMapper.updateById(moldRepairDO); } + private void updateMoldBrandStatusByRepairResult(Long moldId, String repairResult) { + if (StringUtils.isEmpty(repairResult)) { + return; + } + Integer status = isRepairPassed(repairResult) + ? MoldBrandStatusEnum.STANDBY.getStatus() + : MoldBrandStatusEnum.REPAIRING.getStatus(); + updateMoldBrandStatus(moldId, status); + } + + private boolean isRepairPassed(String repairResult) { + String value = repairResult.trim(); + return RepairResultEnum.PASS.getCode().toString().equals(value) + || RepairResultEnum.PASS.getDesc().equalsIgnoreCase(value) + || JobResultEnum.PASS.getCode().toString().equals(value) + || "PASS".equalsIgnoreCase(value) + || "通过".equals(value); + } + + private void updateMoldBrandStatus(Long moldId, Integer status) { + if (moldId == null || status == null) { + return; + } + MoldBrandDO moldBrand = moldBrandMapper.selectById(moldId); + if (moldBrand == null) { + throw exception(MOLD_SET_NOT_EXISTS); + } + MoldBrandDO updateObj = new MoldBrandDO(); + updateObj.setId(moldId); + updateObj.setStatus(status); + moldBrandMapper.updateById(updateObj); + } + private void validateBatchUpdateData(List updateReqVOList) {