1、*Mapper.java继承泛型错误修改
2、行政区实体中增加编号属性
3、行政区级别枚举去掉组
4、实现系统启动后初始化数据库数据监听器
14个文件已修改
3个文件已添加
350 ■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaBlockMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaDistrictMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaRolePrivilegeMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaDistrict.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/TypeConversionEnum.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-database.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaDistrictMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/config/WebListenerConfiguration.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictVo.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictVoMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java 183 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/resources/init-config.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/文档/增加一个应用机构.docx 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml.java
@@ -104,7 +104,27 @@
            }
        }
    }
    /**
     * æ£€æŸ¥å…ƒç´ æ˜¯å¦å­˜åœ¨
     * @param doc doc对象
     * @param elementName å…ƒç´ åç§°
     * @return è¿”回结果  è¿”回结果
     */
    public Element getElement(Document doc, String elementName){
        if(doc == null){
            return null ;
        }
        if(elementName == null){
            return null ;
        }
        elementName = elementName.trim() ;
        if(elementName.equals("")){
            return null ;
        }
        return this.get_element(doc, elementName) ;
    }
    /**
     * æ£€æŸ¥å…ƒç´ æ˜¯å¦å­˜åœ¨
     * @param doc doc对象
@@ -121,8 +141,8 @@
        elementName = elementName.trim() ;
        if(elementName.equals("")){
            return false ;
        }
        Element e = this.getElement(doc, elementName) ;
        }
        Element e = this.get_element(doc, elementName) ;
        return e != null;
    }
@@ -168,7 +188,7 @@
     * @throws Exception  æŠ›å‡ºå¼‚常
     */
    public String getSetAttrTxt(Document doc, String elementName, String attrName, String attPropertyNameFix, Boolean canBlank, String setValue) throws Exception{
        Element e = this.checkAndGetElement(doc, elementName);
        Element e = this.check_and_get_element(doc, elementName);
        return this.getSetAttrTxt(e, attrName, attPropertyNameFix, canBlank, setValue) ;
    }
    
@@ -204,7 +224,7 @@
     * @throws Exception  æŠ›å‡ºå¼‚常
     */
    public Integer getSetAttrPlusInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
        Element e = this.checkAndGetElement(doc, elementName);
        Element e = this.check_and_get_element(doc, elementName);
        return this.getSetAttrPlusInt(e, attrName, attPropertyNameFix, min, max, setValue) ;
    }
@@ -248,7 +268,7 @@
     * @throws Exception  æŠ›å‡ºå¼‚常
     */
    public Integer getSetAttrInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
        Element e = this.checkAndGetElement(doc, elementName);
        Element e = this.check_and_get_element(doc, elementName);
        return this.getSetAttrInt(e, attrName, attPropertyNameFix, min, max, setValue) ;
    }
    
@@ -291,7 +311,7 @@
     * @throws Exception  æŠ›å‡ºå¼‚常
     */
    public Double getSetAttrPlusDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
        Element e = this.checkAndGetElement(doc, elementName);
        Element e = this.check_and_get_element(doc, elementName);
        return this.getSetAttrPlusDouble(e, attrName, attPropertyNameFix, min, max, setValue) ;
    }
    
@@ -335,7 +355,7 @@
     * @throws Exception  æŠ›å‡ºå¼‚常
     */
    public Double getSetAttrDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
        Element e = this.checkAndGetElement(doc, elementName);
        Element e = this.check_and_get_element(doc, elementName);
        return this.getSetAttrDouble(e, attrName, attPropertyNameFix, min, max, setValue) ;
    }
    
@@ -371,7 +391,7 @@
     * @param elementName å…ƒç´ åç§° å…ƒç´ åï¼Œå½¢å¦‚"config.base.test"
     * @return è¿”回结果
     */
    private Element getElement(Document doc, String elementName){
    private Element get_element(Document doc, String elementName){
        Element e = null ;
        Element root ;
        String nm ;
@@ -383,7 +403,7 @@
                if(eNames.length == 1){
                    e = root ;
                }else{
                    e = this.getNextElement(root, eNames, 1) ;
                    e = this.get_next_element(root, eNames, 1) ;
                }
            }
        }
@@ -397,7 +417,7 @@
     * @param index æ•°ç»„下标
     * @return è¿”回结果
     */
    private Element getNextElement(Element base, String[] eNames, int index){
    private Element get_next_element(Element base, String[] eNames, int index){
        Element e = null ;
        String nm ;
        List<Element> list = base.getChildren() ;
@@ -408,7 +428,7 @@
                    if(eNames.length == index + 1){
                        e = el ;
                    }else{
                        e = this.getNextElement(el, eNames, index + 1) ;
                        e = this.get_next_element(el, eNames, index + 1) ;
                    }
                    break ;
                }
@@ -423,7 +443,7 @@
     * @return è¿”回结果
     * @throws Exception  æŠ›å‡ºå¼‚常
     */
    private Element checkAndGetElement(Document doc, String elementName)throws Exception{
    private Element check_and_get_element(Document doc, String elementName)throws Exception{
        if(doc == null){
            throw new Exception("配置文件的DOM对象为空!");
        }
@@ -434,7 +454,7 @@
        if(elementName.equals("")){
            throw new Exception("元素名为空!");
        }    
        Element e = this.getElement(doc, elementName) ;
        Element e = this.get_element(doc, elementName) ;
        if(e == null){
            throw new Exception("未得到名称为" + elementName + "的元素!");
        }
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaBlockMapper.java
@@ -10,7 +10,7 @@
import java.util.Map;
@Mapper
public interface BaBlockMapper extends BaseMapper<BaPrivilege> {
public interface BaBlockMapper extends BaseMapper<BaBlock> {
    /**
     * delete by primary key
     * @param id primaryKey
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaDistrictMapper.java
@@ -8,7 +8,8 @@
import java.util.List;
@Mapper
public interface BaDistrictMapper extends BaseMapper<BaPrivilege> {
public interface BaDistrictMapper extends BaseMapper<BaDistrict> {
    /**
     * select by primary key
     * @param id primary key
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaRolePrivilegeMapper.java
@@ -6,7 +6,7 @@
import org.apache.ibatis.annotations.Param;
@Mapper
public interface BaRolePrivilegeMapper extends BaseMapper<BaRolePrivilegeMapper> {
public interface BaRolePrivilegeMapper extends BaseMapper<BaRolePrivilege> {
    /**
     * insert record to table
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaDistrict.java
@@ -53,6 +53,15 @@
    public String name;
    /**
     * è¡Œæ”¿åŒºç¼–号
     */
    @Schema(description = "行政区编号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "行政区编号不能为空") //不能为空也不能为null
    @Max(message = "行政区编号不大于99", value = 99)
    @Min(message = "行政区编号不小于0",value = 0)
    public String num;
    /**
     * è¡Œæ”¿åŒºçº§åˆ«
     */
    @Schema(description = "行政区级别", requiredMode = Schema.RequiredMode.REQUIRED)
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java
@@ -12,8 +12,7 @@
    City((byte)1, "市"),
    County((byte)2, "县"),
    Town((byte)3,  "镇"),
    Village((byte)4,  "村"),
    Group((byte)5,  "组");
    Village((byte)4,  "村") ;
    @EnumValue
    public Byte code ;
@@ -33,4 +32,17 @@
    public String getName() {
        return this.name ;
    }
    public static DistrictLevel get(Byte code){
        if(code.byteValue() == City.code.byteValue()){
            return City ;
        }else if(code.byteValue() == County.code.byteValue()){
            return County ;
        }else if(code.byteValue() == Town.code.byteValue()){
            return Town ;
        }else if(code.byteValue() == Village.code.byteValue()){
            return Village ;
        }
        return null ;
    }
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/TypeConversionEnum.java
@@ -30,8 +30,6 @@
                rObj = DistrictLevel.Town ;
            }else if(sourceObj == DistrictLevel.Village.code){
                rObj = DistrictLevel.Village ;
            }else if(sourceObj == DistrictLevel.Group.code){
                rObj = DistrictLevel.Group ;
            }
            return rObj ;
        }
pipIrr-platform/pipIrr-global/src/main/resources/application-database.yml
@@ -106,6 +106,7 @@
                maxPoolPreparedStatementPerConnectionSize: 20
                #属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有:
                #监控统计用的filter:stat,日志用的filter:log4j,防御sql注入的filter:wall
                #弃用filter:stat,见https://blog.csdn.net/K_520_W/article/details/132382812
                filters: stat,wall,config
                webStatFilter:
                    # æ·»åŠ è¿‡æ»¤è§„åˆ™
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml
@@ -69,16 +69,6 @@
    </trim>
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ba_block
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteLogicById" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    update ba_block set deleted = 1
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaBlock">
    <!--@mbg.generated-->
    insert into ba_block (id, `name`, `header`, phone, area, color, deleted)
@@ -176,4 +166,16 @@
      deleted = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ba_block
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteLogicById" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    update ba_block set deleted = 1
    where id = #{id,jdbcType=BIGINT}
  </delete>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaDistrictMapper.xml
@@ -7,13 +7,16 @@
    <id column="id" jdbcType="BIGINT" property="id" />
    <id column="supperId" jdbcType="BIGINT" property="supperId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="num" jdbcType="TINYINT" property="num" />
    <result property="level" column="level" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.pipIrrGlobal.util.DistrictLevel"/>
    <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.common.mybatis.envm.Deleted"/>
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, supperId, `name`, `level`, deleted
    id, supperId, `name`, num, `level`, deleted
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
@@ -21,6 +24,7 @@
    from ba_district
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="selectByLevel" parameterType="java.lang.Byte" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
@@ -28,6 +32,7 @@
    from ba_district
    where level = #{level,jdbcType=TINYINT}
  </select>
  <select id="selectBySupperId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
@@ -35,16 +40,19 @@
    from ba_district
    where supperId = #{supperId,jdbcType=BIGINT}
  </select>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict">
    <!--@mbg.generated-->
    insert into ba_district (id, supperId, `name`, `level`, deleted)
    insert into ba_district (id, supperId, `name`, num, `level`, deleted)
    values (#{id,jdbcType=BIGINT},
            #{supperId,jdbcType=BIGINT},
            #{name,jdbcType=VARCHAR},
            #{num,jdbcType=TINYINT},
            #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
            #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}
    )
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict">
    <!--@mbg.generated-->
    insert into ba_district
@@ -57,6 +65,9 @@
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="num != null">
        num,
      </if>
      <if test="level != null">
        `level`,
@@ -75,6 +86,9 @@
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="num != null">
        #{num,jdbcType=TINYINT},
      </if>
      <if test="level != null">
        #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
      </if>
@@ -89,6 +103,9 @@
    <set>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="num != null">
        num = #{num,jdbcType=TINYINT},
      </if>
      <if test="supperId != null">
        supperId = #{supperId,jdbcType=BIGINT},
@@ -107,6 +124,7 @@
    update ba_district
    set supperId = #{supperId,jdbcType=BIGINT},
        `name` = #{name,jdbcType=VARCHAR},
        num = #{num,jdbcType=TINYINT},
        `level` = #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
        deleted = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/config/WebListenerConfiguration.java
@@ -1,6 +1,7 @@
package com.dy.pipIrrBase.config;
import com.dy.common.webListener.GenerateIdSetSuffixListener;
import com.dy.pipIrrBase.util.InitListener;
import jakarta.servlet.ServletContextListener;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
@@ -14,6 +15,7 @@
     */
    //private static final int order_config = 0 ;
    private static final int order_idSetSuffix = 1 ;
    //private static final int order_init = 2 ;
    /*
    * è§£æžå„种***.config配置的ConfigListener,暂时不采用此种配置方式
@@ -36,14 +38,26 @@
    */
    /**
     * å†…部提供listener,该listener在系统启动时,根据配置设置ID产生器的后缀
     * å†…部提供listener,该listener在系统启动时,根据配置 è®¾ç½®ID产生器的后缀
     * @return æ³¨å†ŒBean
     */
    @Bean
    public ServletListenerRegistrationBean<? extends ServletContextListener> reqSsoListener() {
    public ServletListenerRegistrationBean<? extends ServletContextListener> regSsoListener() {
        ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>();
        listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener());
        listenerRegistrationBean.setOrder(order_idSetSuffix);
        return listenerRegistrationBean;
    }
//    /**
//     * å†…部提供listener,该listener在系统启动时,初始化数据库数据
//     * @return æ³¨å†ŒBean
//     */
//    @Bean
//    public ServletListenerRegistrationBean<? extends ServletContextListener> regInitListener() {
//        ServletListenerRegistrationBean<InitListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>();
//        listenerRegistrationBean.setListener(new InitListener());
//        listenerRegistrationBean.setOrder(order_init);
//        return listenerRegistrationBean;
//    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
@@ -56,7 +56,7 @@
    })
    @GetMapping(path = "allLevel")
    public BaseResponse<List<DistrictLevel>> allDistrictLevels(){
        List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village, DistrictLevel.Group) ;
        List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village) ;
        return BaseResponseUtils.buildSuccess(list);
    }
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictVo.java
@@ -26,6 +26,11 @@
    @Length(message = "行政区名称小于{max}字", min = 1, max = 25)
    public String name ;
    @Schema(description = "行政区编号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "行政区编号不能为空") //不能为空也不能为null
    @Length(message = "行政区编号是一位或两位数", min = 1, max = 2)
    public String num ;
    @Schema(description = "行政区级别", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "行政区级别不能为空") //不能为空也不能为null
    @Max(message = "行政区级别不正确", value = 10)
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictVoMapper.java
@@ -17,6 +17,7 @@
    @Mapping(target = "id", source = "supperId")
    @Mapping(target = "supperId", source = "supperId")
    @Mapping(target = "name", source = "name")
    @Mapping(target = "num", source = "num")
    @Mapping(target = "level", source = "level", qualifiedByName = "districtLevelByteToObj")
    @Mapping(target = "deleted", source = "deleted", qualifiedByName = "deletedByteToObj")
    @Mapping(target = "subDistricts", ignore = true)
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
New file
@@ -0,0 +1,183 @@
package com.dy.pipIrrBase.util;
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.common.mybatis.envm.Deleted;
import com.dy.common.mybatis.envm.Disabled;
import com.dy.common.util.ConfigXml;
import com.dy.common.util.MD5;
import com.dy.common.webListener.ConfigListener;
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
import com.dy.pipIrrGlobal.pojoBa.BaDistrict;
import com.dy.pipIrrGlobal.pojoBa.BaUser;
import com.dy.pipIrrGlobal.util.DistrictLevel;
import org.jdom2.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import java.net.URL;
/**
 * ç›‘听器,实现功能:在系统启动时初始化,向数据库中插入数据
 * æœ¬ç›‘听器不能采用ServletContextListener方式,因为Servlet上下文Context创建后
 * Spring容器并没有创建完,而本类中用珐了Spring容器中的Bean,即distriDao, userDao。
 * æ‰€ä»¥é‡‡ç”¨äº†Spring事件监听器来实现
 */
@Component
public class InitListener implements ApplicationListener<ApplicationReadyEvent> {
    private BaDistrictMapper distriDao ;
    private BaUserMapper userDao ;
    @Autowired
    public void setDistriDao(BaDistrictMapper distriDao){
        this.distriDao = distriDao ;
    }
    @Autowired
    public void setUserDao(BaUserMapper userDao){
        this.userDao = userDao ;
    }
    /**
     * SpringBoot容器已经准备好了
     * @param event äº‹ä»¶
     */
    @Override
    public void onApplicationEvent(@NonNull ApplicationReadyEvent event) {
        try {
            //等1秒,等待com.alibaba.druid.pool.DruidDataSource实始化完成
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            this.init(event);
        }
    }
    /**
     * å®žå§‹åŒ–
     */
    @SuppressWarnings("unused ")
    private void init(ApplicationReadyEvent event){
        try {
            URL configFileURL = ConfigListener.class.getResource("/init-config.xml" );
            ConfigXml configXml = new ConfigXml() ;
            Document doc = configXml.createDom(configFileURL) ;
            this.doInit(configXml, doc);
        } catch (Exception e) {
            System.out.println("系统启动时,初始化配置出错 !");
            System.out.println(e.getMessage());
            e.printStackTrace();
        }
    }
    private void doInit(ConfigXml configXml, Document doc) throws Exception{
        if(configXml != null && doc != null){
            for(int num = 1; num <= 10000; num++){
                if(configXml.existElement(doc, "config.orgs.org" + num)){
                    String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num,"name", null, false, null) ;
                    //设置数据源
                    DataSourceContext.set(orgTag);
                    if(!this.existDistricts()){
                        if(configXml.existElement(doc, "config.orgs.org" + num + ".districts.city")){
                            String distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city","name", null, false, null) ;
                            String distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city","num", null, false, null) ;
                            Integer distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.city","level", null, 1, 99,null) ;
                            Long supperId = this.saveDistrict(null, distriName, distriNum, distriLevel);
                            if(supperId != null && configXml.existElement(doc, "config.orgs.org" + num + ".districts.city.country")){
                                distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city.country","name", null, false, null) ;
                                distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city.country","num", null, false, null) ;
                                distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.city.country","level", null, 1, 99,null) ;
                                this.saveDistrict(supperId, distriName, distriNum, distriLevel);
                            }
                        }
                    }
                    if(!this.existUsers()){
                        if(configXml.existElement(doc, "config.orgs.org" + num + ".user")){
                            String name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","name", null, false, null) ;
                            String phone = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","phone", null, false, null) ;
                            String password = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","password", null, false, null) ;
                            Integer supperAdmin = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".user","supperAdmin", null, 0, 1,null) ;
                            this.saveUser(orgTag, name, phone, password, supperAdmin);
                        }
                    }
                }else{
                    break ;
                }
            }
        }
    }
    /**
     * æ•°æ®åº“中是否存在行政区划数据
     * @return å­˜åœ¨å¦
     */
    private boolean existDistricts(){
        Long total = this.distriDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
    /**
     * æ•°æ®åº“中是否存在行政区划数据
     * @return å­˜åœ¨å¦
     */
    private boolean existUsers(){
        Long total = this.userDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
    /**
     * æ•°æ®åº“中保存行政区划实体
     * @param supperId ä¸Šçº§ID
     * @param name åç§°
     * @param num ç¼–号
     * @param level çº§åˆ«
     * @return id
     */
    private Long saveDistrict(Long supperId, String name, String num, Integer level){
        if((name != null && !name.trim().equals("")) &&
                (num != null && !num.trim().equals("")) &&
                level != null){
            BaDistrict po = new BaDistrict() ;
            po.supperId = supperId ;
            po.name = name ;
            po.num = num ;
            po.level = DistrictLevel.get(level.byteValue()) ;
            po.deleted = Deleted.NO ;
            this.distriDao.insert(po) ;
            return po.getId() ;
        }else{
            return null ;
        }
    }
    /**
     * ä¿å­˜ç”¨æˆ·
     * @param orgTag æœºæž„标签
     * @param name åç§°
     * @param phone æ‰‹æœºå·
     * @param password å¯†ç 
     * @param supperAdmin æ˜¯å¦ä¸ºè¶…级管理员(1是,0否)
     */
    private void saveUser(String orgTag, String name, String phone, String password, Integer supperAdmin) throws Exception{
        if((name != null && !name.trim().equals("")) &&
                (phone != null && !phone.trim().equals("")) &&
                (password != null && !password.trim().equals("")) &&
                supperAdmin != null){
            BaUser po = new BaUser() ;
            po.name = name ;
            po.phone = phone ;
            po.password = MD5.encrypt(password) ;//进行加密码 ;
            po.orgTag = orgTag ;
            po.supperAdmin = supperAdmin.byteValue() ;
            po.disabled = Disabled.NO ;
            po.deleted = Deleted.NO ;
            this.userDao.insert(po) ;
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/resources/init-config.xml
New file
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <orgs>
        <!-- å¤šä¸ªç»„织,用编号区分,编号从1开始 -->
        <org1 name="ym">
            <districts>
                <city name="楚雄彝族自治州" num="23" level="1">
                    <country name="元谋县" num="28" level="2" />
                </city>
            </districts>
            <user name="超级管理员" phone="admin" password="admin" supperAdmin="1" />
        </org1>
    </orgs>
</config>
pipIrr-platform/Îĵµ/Ôö¼ÓÒ»¸öÓ¦Óûú¹¹.docx
Binary files differ