zhubaomin
2024-08-29 6ff1146dd3e06d991e8bc246bb3e9f3644699254
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
@@ -8,12 +8,14 @@
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;
@@ -43,6 +45,7 @@
    private BaSettingsMapper settingsDao ;
    private SeWaterTypeMapper waterTypeDao ;
    private RmIrrigateProfileMapper rmIrrigateProfileDao;
    private PrWaterPriceMapper prWaterPriceDao;
    @Autowired
    public void setResourceLoader(ResourceLoader resourceLoader){
@@ -77,6 +80,11 @@
    @Autowired
    public void setRmIrrigateProfileDao(RmIrrigateProfileMapper rmIrrigateProfileDao) {
        this.rmIrrigateProfileDao = rmIrrigateProfileDao;
    }
    @Autowired
    public void setWaterPriceDao(PrWaterPriceMapper prWaterPriceDao) {
        this.prWaterPriceDao = prWaterPriceDao;
    }
    /**
@@ -189,6 +197,12 @@
                                }
                            }
                        }
                        if(!this.existWaterTypes()){
                            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);
                            }
                        }
                    }
                }else{
                    break ;
@@ -238,7 +252,7 @@
     * @return 存在否
     */
    private boolean existWaterTypes(){
        Long total = this.waterTypeDao.selectCount(null) ;
        Long total = this.prWaterPriceDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
@@ -248,6 +262,15 @@
     */
    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) ;
    }
@@ -370,4 +393,21 @@
        }
    }
    /**
     * 保存水价
     * @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);
        }
    }
}