From 8ecedca10d188de63618a5f839752c8bd172a1e6 Mon Sep 17 00:00:00 2001 From: shaoyong Date: Thu, 30 May 2024 09:06:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E4=BD=93=E7=AE=A1=E7=90=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op/mes/controller/MesLineController.java | 10 +++++++++- .../java/com/op/mes/mapper/MesLineMapper.java | 2 ++ .../com/op/mes/service/IMesLineService.java | 2 ++ .../mes/service/impl/MesLineServiceImpl.java | 19 ++++++++++--------- .../resources/mapper/mes/MesLineMapper.xml | 7 ++++++- .../mapper/mes/MesLineProcessMapper.xml | 2 +- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesLineController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesLineController.java index 55951d6f..449c8790 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesLineController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesLineController.java @@ -1,10 +1,12 @@ package com.op.mes.controller; import java.util.List; +import java.util.Optional; import javax.servlet.http.HttpServletResponse; import com.alibaba.nacos.shaded.com.google.protobuf.Internal; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -74,7 +76,13 @@ public class MesLineController extends BaseController { @Log(title = "线体管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody MesLine mesLine) { - return toAjax(mesLineService.insertMesLine(mesLine)); + MesLine vali = mesLineService.validate(mesLine.getLineCode()); + if (ObjectUtils.isEmpty(vali)){ + return toAjax(mesLineService.insertMesLine(mesLine)); + }else { + return error("线体已存在不能重复添加!"); + } + } /** diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesLineMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesLineMapper.java index 97da4096..06da9577 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesLineMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesLineMapper.java @@ -64,4 +64,6 @@ public interface MesLineMapper { * 选择线体 */ public List selectLineBody(MesLine mesLine); + + public MesLine validate(String lineCode); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesLineService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesLineService.java index 7c8cd0fe..78a085ea 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesLineService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesLineService.java @@ -63,4 +63,6 @@ public interface IMesLineService { * 选择线体 */ public List selectLineBody(MesLine mesLine); + + public MesLine validate(String lineCode); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesLineServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesLineServiceImpl.java index 7cf125e8..0c4c04cb 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesLineServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesLineServiceImpl.java @@ -105,7 +105,6 @@ public class MesLineServiceImpl implements IMesLineService { mesLine.setUpdateBy(SecurityUtils.getUsername()); List processList = mesLine.getProcessList(); List qualityList = mesLine.getQualityList(); - int flag = 0; if (!CollectionUtils.isEmpty(processList)) { //删除旧的工艺项 mesLineProcessService.deleteMesLineProcessByBelongTo(mesLine.getId()); @@ -126,16 +125,12 @@ public class MesLineServiceImpl implements IMesLineService { mesLineProcess.setLineCode(lineCode); mesLineProcess.setLineName(lineName); mesLineProcess.setFactoryCode(factoryCode); - flag += mesLineProcessService.insertMesLineProcess(mesLineProcess); + mesLineProcessService.insertMesLineProcess(mesLineProcess); } - }else { - return 0; - } - if (flag > 0){ - return mesLineMapper.updateMesLine(mesLine); - }else { - return 0; } + + return mesLineMapper.updateMesLine(mesLine); + } /** @@ -166,4 +161,10 @@ public class MesLineServiceImpl implements IMesLineService { public List selectLineBody(MesLine mesLine) { return mesLineMapper.selectLineBody(mesLine); } + + @Override + @DS("#header.poolName") + public MesLine validate(String lineCode) { + return mesLineMapper.validate(lineCode); + } } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesLineMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesLineMapper.xml index 8d38de3b..2738b225 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesLineMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesLineMapper.xml @@ -57,7 +57,7 @@ and factory_code = #{factoryCode} - and del_flag = '0' + and del_flag = '0' order by create_time @@ -148,4 +148,9 @@ and equipment_name like concat('%', #{lineName}, '%') + diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesLineProcessMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesLineProcessMapper.xml index ebda3ea3..81e67e1f 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesLineProcessMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesLineProcessMapper.xml @@ -75,7 +75,7 @@