From 623397a394196189057db9c1948fe3b24f7fa4e3 Mon Sep 17 00:00:00 2001
From: 刘小明 <liuxm_a@163.com>
Date: 星期三, 24 七月 2024 15:34:14 +0800
Subject: [PATCH] 生产线和工站添加启用禁用的校验
---
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java | 20 ++++++++++++++++++++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java | 14 ++++++++++++++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java | 2 +-
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java | 3 +++
pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml | 3 +++
5 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
index 499abac..a28094c 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
@@ -36,4 +36,7 @@
String selectMaxCode();
List<PltStation> selectStationList(PltStation record);
+
+
+ long selectByLineAndStatus(Long lineId, boolean disabled);
}
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
index 159b02f..2f52121 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
@@ -153,6 +153,9 @@
<select id="selectMaxCode" resultType="java.lang.String">
select max(code) from plt_station
</select>
+ <select id="selectByLineAndStatus" resultType="java.lang.Long">
+ select count(1) from plt_station where line_id = #{lineId} and disabled = #{disabled} and deleted!=1
+ </select>
<update id="deleteLogicById" parameterType="java.lang.Long">
update plt_station set deleted = 1
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
index 082bcd8..5ed0602 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
@@ -74,7 +74,7 @@
@Log("璁剧疆鐢熶骇绾跨姸鎬�")
//{id: "2", disabled: true}
public BaseResponse<Boolean> disabled(@RequestBody PltProductionLine line){
- int count = sv.update(line);
+ int count = sv.updateStatus(line);
if (count <= 0) {
return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
} else {
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java
index 156892f..a661cbc 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java
@@ -2,6 +2,7 @@
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoPlt.PltProductionLineMapper;
+import com.dy.pmsGlobal.daoPlt.PltStationMapper;
import com.dy.pmsGlobal.pojoPlt.PltProductionLine;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
@@ -17,10 +18,15 @@
public class ProLineSv {
private PltProductionLineMapper dao;
+ private PltStationMapper stationDao;
@Autowired
public void setDao(PltProductionLineMapper dao) {
this.dao = dao;
+ }
+ @Autowired
+ public void setStationDao(PltStationMapper stationDao) {
+ this.stationDao = stationDao;
}
@Transactional
@@ -79,5 +85,19 @@
public List<PltProductionLine> selectAll() {
return dao.selectAll();
}
+
+ @Transactional
+ public int updateStatus(PltProductionLine line) {
+ if(line.disabled){
+ long count = stationDao.selectByLineAndStatus(line.id,false);
+ if(count>0){
+ throw new RuntimeException("璇ョ敓浜х嚎杩樻湁鍚敤鐘舵�佺殑宸ョ珯");
+ }
+ }
+ PltProductionLine lineParam = new PltProductionLine();
+ lineParam.id = line.id;
+ lineParam.disabled = line.disabled;
+ return dao.updateByPrimaryKeySelective(lineParam);
+ }
}
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java
index 75a83d1..783a93c 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java
@@ -2,7 +2,9 @@
import com.alibaba.excel.util.StringUtils;
import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoPlt.PltProductionLineMapper;
import com.dy.pmsGlobal.daoPlt.PltStationMapper;
+import com.dy.pmsGlobal.pojoPlt.PltProductionLine;
import com.dy.pmsGlobal.pojoPlt.PltStation;
import com.dy.pmsGlobal.util.QrCodeUtil;
import lombok.extern.slf4j.Slf4j;
@@ -20,6 +22,7 @@
public class StationSv {
private PltStationMapper dao;
+ private PltProductionLineMapper lineDao;
private static final String stationPrefix = "103" ;
private static final String DEFAULT_CODE = "0001";
private static final String CODE_FORMAT = "%04d";
@@ -27,6 +30,10 @@
@Autowired
public void setDao(PltStationMapper dao) {
this.dao = dao;
+ }
+ @Autowired
+ public void setLineDao(PltProductionLineMapper lineDao) {
+ this.lineDao = lineDao;
}
@Transactional
@@ -125,6 +132,13 @@
@Transactional
public int disabled(Long id, Boolean disabled) {
+ if(!disabled){
+ PltStation station1 = dao.selectByPrimaryKey(id);
+ PltProductionLine line = lineDao.selectByPrimaryKey(station1.lineId);
+ if(line.disabled){
+ throw new RuntimeException("璇ュ伐绔欐墍灞炵敓浜х嚎宸茬鐢�,璇峰厛鍚敤璇ョ敓浜х嚎");
+ }
+ }
PltStation station = new PltStation();
station.setId(id);
station.setDisabled(disabled);
--
Gitblit v1.8.0