| | |
| | | import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper; |
| | | import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper; |
| | | import com.dy.pipIrrGlobal.daoBa.BaUserMapper; |
| | | 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.pojoRm.RmIrrigateProfile; |
| | | import com.dy.pipIrrGlobal.pojoSe.SePaymentMethod; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeWaterType; |
| | | import com.dy.pipIrrGlobal.util.DistrictLevel; |
| | |
| | | private SePaymentMethodMapper paymentMethodDao ; |
| | | private BaSettingsMapper settingsDao ; |
| | | private SeWaterTypeMapper waterTypeDao ; |
| | | private RmIrrigateProfileMapper rmIrrigateProfileDao; |
| | | |
| | | @Autowired |
| | | public void setResourceLoader(ResourceLoader resourceLoader){ |
| | |
| | | this.waterTypeDao = waterTypeDao ; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setRmIrrigateProfileDao(RmIrrigateProfileMapper rmIrrigateProfileDao) { |
| | | this.rmIrrigateProfileDao = rmIrrigateProfileDao; |
| | | } |
| | | |
| | | /** |
| | | * SpringBoot容器已经准备好了 |
| | |
| | | } |
| | | } |
| | | } |
| | | if(!this.existWaterTypes()){ |
| | | if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes")){ |
| | | 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 + ".waterTypes.item" + i)){ |
| | | String typeName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".waterTypes.item" + i,"typeName", null, false, null) ; |
| | | this.saveWaterType(orgTag, typeName); |
| | | 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 ; |
| | | } |
| | |
| | | */ |
| | | private boolean existWaterTypes(){ |
| | | Long total = this.waterTypeDao.selectCount(null) ; |
| | | return (total != null && total > 0) ; |
| | | } |
| | | |
| | | /** |
| | | * 数据库中是否存在灌溉配置 |
| | | * @return |
| | | */ |
| | | private boolean existIrrigateProfile(){ |
| | | Long total = this.rmIrrigateProfileDao.selectCount(null) ; |
| | | return (total != null && total > 0) ; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存灌溉配置 |
| | | * @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); |
| | | } |
| | | } |
| | | |
| | | } |