From 9de447f96e739c002a5f7760b67280b6ff81bba3 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期二, 07 五月 2024 14:56:23 +0800
Subject: [PATCH] 修改 分水房添加接口 村可以为空  分水房修改接口 手机号可以为空

---
 pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java |   76 ++++++++++++++++++++++++-------------
 1 files changed, 49 insertions(+), 27 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 56e50c2..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;
@@ -12,6 +13,7 @@
 
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * @author wuzeyu
@@ -25,6 +27,8 @@
 public class IntakeSv {
     @Autowired
     private PrIntakeMapper prIntakeMapper;
+    @Autowired
+    private PrDivideMapper prDivideMapper;
 
     /**
      * 娣诲姞鍙栨按鍙�
@@ -34,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);
     }
 
@@ -79,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);
 
@@ -104,35 +120,39 @@
 
     /**
      * 寰楀埌鎵�鏈夊彇姘村彛
+     *
      * @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
      */
@@ -142,19 +162,21 @@
 
     /**
      * 鏍规嵁鏉慖d鑾峰彇鍏ㄩ儴鍦板潃
+     *
      * @param villageId 鏉慖d
-     * @return  address  鍏ㄩ儴浜旂骇鍦板潃
+     * @return address  鍏ㄩ儴浜旂骇鍦板潃
      */
-    public String getAddressByVillageId(long villageId){
+    public String getAddressByVillageId(long villageId) {
         return prIntakeMapper.getAddressByVillageId(villageId);
     }
 
     /**
      * 鏍规嵁鍖哄煙Id鑾峰彇鍖哄煙绛夌骇
+     *
      * @param regionId 鍖哄煙Id
-     * @return  Level  鍖哄煙绛夌骇
+     * @return Level  鍖哄煙绛夌骇
      */
-    public int getLevelByRegionId(long regionId){
+    public int getLevelByRegionId(long regionId) {
         return prIntakeMapper.getLevelByRegionId(regionId);
     }
 }

--
Gitblit v1.8.0