From bc8ab2ccb801ece9f2638098e8acd07f3ef1978d Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期五, 30 八月 2024 20:35:09 +0800
Subject: [PATCH] 2024-08-30 朱宝民 解决获取水卡列表接口错误,无虚拟卡时不显示空对象

---
 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java |   96 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 1 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
index 11c4f8a..4e54a8f 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
@@ -8,11 +8,15 @@
 import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
 import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
 import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
+import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper;
+import com.dy.pipIrrGlobal.daoRm.RmIrrigateProfileMapper;
 import com.dy.pipIrrGlobal.daoSe.SePaymentMethodMapper;
 import com.dy.pipIrrGlobal.daoSe.SeWaterTypeMapper;
 import com.dy.pipIrrGlobal.pojoBa.BaDistrict;
 import com.dy.pipIrrGlobal.pojoBa.BaSettings;
 import com.dy.pipIrrGlobal.pojoBa.BaUser;
+import com.dy.pipIrrGlobal.pojoPr.PrWaterPrice;
+import com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile;
 import com.dy.pipIrrGlobal.pojoSe.SePaymentMethod;
 import com.dy.pipIrrGlobal.pojoSe.SeWaterType;
 import com.dy.pipIrrGlobal.util.DistrictLevel;
@@ -40,6 +44,8 @@
     private SePaymentMethodMapper paymentMethodDao ;
     private BaSettingsMapper settingsDao ;
     private SeWaterTypeMapper waterTypeDao ;
+    private RmIrrigateProfileMapper rmIrrigateProfileDao;
+    private PrWaterPriceMapper prWaterPriceDao;
 
     @Autowired
     public void setResourceLoader(ResourceLoader resourceLoader){
@@ -71,6 +77,15 @@
         this.waterTypeDao = waterTypeDao ;
     }
 
+    @Autowired
+    public void setRmIrrigateProfileDao(RmIrrigateProfileMapper rmIrrigateProfileDao) {
+        this.rmIrrigateProfileDao = rmIrrigateProfileDao;
+    }
+
+    @Autowired
+    public void setWaterPriceDao(PrWaterPriceMapper prWaterPriceDao) {
+        this.prWaterPriceDao = prWaterPriceDao;
+    }
 
     /**
      * SpringBoot瀹瑰櫒宸茬粡鍑嗗濂戒簡
@@ -167,6 +182,21 @@
                                 }
                             }
                         }
+                        if(!this.existIrrigateProfile()){
+                            if(configXml.existElement(doc, "config.orgs.org" + num + ".irrigateProfile")){
+                                for(int i = 1 ; i < 10000; i++){
+                                    if(configXml.existElement(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i)){
+                                        String default_value = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"default_value", null, false, null) ;
+                                        String unit = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"unit", null, false, null) ;
+                                        String sort = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"sort", null, false, null) ;
+                                        String type = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"type", null, false, null) ;
+                                        this.saveIrrigateProfile(orgTag, default_value, unit,sort,type);
+                                    }else{
+                                        break ;
+                                    }
+                                }
+                            }
+                        }
                         if(!this.existWaterTypes()){
                             if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes")){
                                 for(int i = 1 ; i < 10000; i++){
@@ -177,6 +207,12 @@
                                         break ;
                                     }
                                 }
+                            }
+                        }
+                        if(!this.existWaterPrice()){
+                            if(configXml.existElement(doc, "config.orgs.org" + num + ".waterPrice")){
+                                String price = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".waterPrice","price", null, false, null) ;
+                                this.saveWaterPrice(orgTag, price);
                             }
                         }
                     }
@@ -228,7 +264,25 @@
      * @return 瀛樺湪鍚�
      */
     private boolean existWaterTypes(){
-        Long total = this.waterTypeDao.selectCount(null) ;
+        Long total = this.prWaterPriceDao.selectCount(null) ;
+        return (total != null && total > 0) ;
+    }
+
+    /**
+     * 鏁版嵁搴撲腑鏄惁瀛樺湪鐏屾簤閰嶇疆
+     * @return
+     */
+    private boolean existIrrigateProfile(){
+        Long total = this.rmIrrigateProfileDao.selectCount(null) ;
+        return (total != null && total > 0) ;
+    }
+
+    /**
+     * 鏁版嵁搴撲腑鏄惁瀛樺湪姘翠环
+     * @return
+     */
+    private boolean existWaterPrice() {
+        Long total = this.prWaterPriceDao.selectCount(null);
         return (total != null && total > 0) ;
     }
 
@@ -328,4 +382,44 @@
         }
     }
 
+    /**
+     * 淇濆瓨鐏屾簤閰嶇疆
+     * @param orgTag
+     * @param default_value
+     * @param unit
+     * @param sort
+     * @param type
+     * @throws Exception
+     */
+    private void saveIrrigateProfile(String orgTag, String default_value, String unit, String sort, String type) throws Exception{
+        if((default_value != null && !default_value.trim().equals("")) &&
+                (unit != null && !unit.trim().equals("")) &&
+                (sort != null && !sort.trim().equals("")) &&
+                (type != null && !type.trim().equals(""))){
+            RmIrrigateProfile po = new RmIrrigateProfile();
+            po.setDefaultValue(Integer.parseInt(default_value));
+            po.setUnit(Byte.valueOf(unit));
+            po.setSort(Integer.parseInt(sort));
+            po.setType(Byte.valueOf(type));
+            this.rmIrrigateProfileDao.insert(po);
+        }
+    }
+
+    /**
+     * 淇濆瓨姘翠环
+     * @param price
+     */
+    private void saveWaterPrice(String orgTag, String price) {
+        if(price != null && !price.trim().equals("")) {
+            PrWaterPrice po = new PrWaterPrice();
+            po.setPrice(Double.parseDouble(price));
+            po.setDeleted((byte)0);
+            this.prWaterPriceDao.insert(po);
+
+        }
+
+    }
+
+
+
 }

--
Gitblit v1.8.0