From e7c48d5e68fa9405cbb745b39d77503fe29c3efa Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期一, 25 三月 2024 15:10:10 +0800
Subject: [PATCH] 修改添加控制器 同步添加取水口控制器关联表
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java | 96 ++++++++++++++++++++++++++++++++++++------------
1 files changed, 72 insertions(+), 24 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
index 7261b2c..7fd8e0b 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
@@ -1,6 +1,7 @@
package com.dy.pipIrrProject.intake;
import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoPr.PrDivideMapper;
import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
import com.dy.pipIrrGlobal.pojoPr.PrIntake;
import com.dy.pipIrrGlobal.voPr.VoIntake;
@@ -10,9 +11,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-
import java.util.List;
import java.util.Map;
+import java.util.Optional;
/**
* @author wuzeyu
@@ -26,6 +27,8 @@
public class IntakeSv {
@Autowired
private PrIntakeMapper prIntakeMapper;
+ @Autowired
+ private PrDivideMapper prDivideMapper;
/**
* 娣诲姞鍙栨按鍙�
@@ -35,41 +38,47 @@
*/
@Transactional
Integer addIntake(PrIntake po) {
- if (po.getTownId()==null||po.getTownId()==0)
- {
- Long townId=getSupperByVillageId(po.getVillageId());
- po.setTownId(townId);
+ Long villageId = Optional.ofNullable(po.getVillageId()).orElse(0L);
+
+ if (villageId != 0){
+ if (po.getTownId() == null || po.getTownId() == 0) {
+ Long townId = getSupperByVillageId(po.getVillageId());
+ po.setTownId(townId);
+ }
+ if (po.getCountyId() == null || po.getCountyId() == 0) {
+ Long countyId = getSupperByVillageId(getSupperByVillageId(po.getVillageId()));
+ po.setCountyId(countyId);
+ }
}
- if (po.getCountyId()==null||po.getCountyId()==0)
- {
- Long countyId=getSupperByVillageId(getSupperByVillageId(po.getVillageId()));
- po.setCountyId(countyId);
+ if (po.getBlockId() == null || po.getBlockId() == 0) {
+ Long blockId = prDivideMapper.getBlockIdById(po.getDivideId());
+ po.setBlockId(blockId);
}
return prIntakeMapper.insertSelective(po);
}
- public Long getSupperByVillageId(long vaId){
+
+ public Long getSupperByVillageId(long vaId) {
return prIntakeMapper.getSupperByVillageId(vaId);
}
/**
* 淇濆瓨淇敼瀹炰綋
+ *
* @param po 瀹炰綋
* @return 鏁伴噺
*/
- public int update(PrIntake po){
- if (po.getTownId()==null||po.getTownId()==0)
- {
- Long townId=getSupperByVillageId(po.getVillageId());
+ public int update(PrIntake po) {
+ if (po.getTownId() == null || po.getTownId() == 0) {
+ Long townId = getSupperByVillageId(po.getVillageId());
po.setTownId(townId);
}
- if (po.getCountyId()==null||po.getCountyId()==0)
- {
- Long countyId=getSupperByVillageId(getSupperByVillageId(po.getVillageId()));
+ if (po.getCountyId() == null || po.getCountyId() == 0) {
+ Long countyId = getSupperByVillageId(getSupperByVillageId(po.getVillageId()));
po.setCountyId(countyId);
}
- return this.prIntakeMapper.updateByPrimaryKeySelective(po) ;
+ return this.prIntakeMapper.updateByPrimaryKeySelective(po);
// return this.prIntakeMapper.updateByPrimaryKey(po);
}
@@ -80,6 +89,12 @@
* @return 鍙栨按鍙h褰曞垪琛�
*/
public QueryResultVo<List<VoIntake>> getIntakes(QueryVo queryVo) {
+// String isBinded = queryVo.getIsBinded();
+//
+// if(isBinded == null || isBinded.length() <= 0) {
+//
+// }
+
Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
Long itemTotal = prIntakeMapper.getRecordCount(params);
@@ -105,30 +120,63 @@
/**
* 寰楀埌鎵�鏈夊彇姘村彛
+ *
* @return 鎵�鏈夊彇姘村彛闆嗗悎
*/
public QueryResultVo<List<PrIntake>> selectAll() {
- QueryResultVo<List<PrIntake>> rsVo = new QueryResultVo<>() ;
- rsVo.obj = this.prIntakeMapper.selectAll() ;
- return rsVo ;
+ QueryResultVo<List<PrIntake>> rsVo = new QueryResultVo<>();
+ rsVo.obj = this.prIntakeMapper.selectAll();
+ return rsVo;
}
/**
* 寰楀埌涓�涓彇姘村彛
+ *
* @param id 鍙栨按鍙D
* @return 鍙栨按鍙e疄浣�
*/
public PrIntake selectById(Long id) {
- return this.prIntakeMapper.selectByPrimaryKey(id) ;
+ return this.prIntakeMapper.selectByPrimaryKey(id);
}
/**
* 閫昏緫鍒犻櫎瀹炰綋
+ *
* @param id 瀹炰綋ID
* @return 鏁伴噺
*/
@Transactional
- public int delete(Long id){
- return this.prIntakeMapper.deleteLogicById(id) ;
+ public int delete(Long id) {
+ return this.prIntakeMapper.deleteLogicById(id);
+ }
+
+ /**
+ * 鏍规嵁鍙栨按鍙g紪鍙疯幏鍙栨湭鍒犻櫎鐨勫彇姘村彛鏁伴噺
+ *
+ * @param intakeId
+ * @return
+ */
+ public Integer getRecordCountOfIntake(Long intakeId) {
+ return prIntakeMapper.getRecordCountOfIntake(intakeId);
+ }
+
+ /**
+ * 鏍规嵁鏉慖d鑾峰彇鍏ㄩ儴鍦板潃
+ *
+ * @param villageId 鏉慖d
+ * @return address 鍏ㄩ儴浜旂骇鍦板潃
+ */
+ public String getAddressByVillageId(long villageId) {
+ return prIntakeMapper.getAddressByVillageId(villageId);
+ }
+
+ /**
+ * 鏍规嵁鍖哄煙Id鑾峰彇鍖哄煙绛夌骇
+ *
+ * @param regionId 鍖哄煙Id
+ * @return Level 鍖哄煙绛夌骇
+ */
+ public int getLevelByRegionId(long regionId) {
+ return prIntakeMapper.getLevelByRegionId(regionId);
}
}
--
Gitblit v1.8.0