wuzeyu
2024-06-28 e7c0b5be2a66f8f46515d9f8eb267d00eced2538
系统初始化 增加用水类型初始化
3个文件已添加
2个文件已修改
190 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWaterTypeMapper.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWaterType.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWaterTypeMapper.xml 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWaterTypeMapper.java
New file
@@ -0,0 +1,26 @@
package com.dy.pipIrrGlobal.daoSe;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoSe.SeWaterType;
import org.apache.ibatis.annotations.Mapper;
/**
 * @author :WuZeYu
 * @Date :2024/6/28  15:29
 * @LastEditTime :2024/6/28  15:29
 * @Description
 */
@Mapper
public interface SeWaterTypeMapper extends BaseMapper<SeWaterType> {
    int deleteByPrimaryKey(Long id);
    int insert(SeWaterType record);
    int insertSelective(SeWaterType record);
    SeWaterType selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(SeWaterType record);
    int updateByPrimaryKey(SeWaterType record);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWaterType.java
New file
@@ -0,0 +1,47 @@
package com.dy.pipIrrGlobal.pojoSe;
/**
 * @author :WuZeYu
 * @Date :2024/6/28  15:29
 * @LastEditTime :2024/6/28  15:29
 * @Description
 */
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;
/**
 * 用水类型表
 */
@TableName(value="se_water_type", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "用水类型实体")
public class SeWaterType implements BaseEntity {
    public static final long serialVersionUID = 202406281535001L;
    /**
     * 主键
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Long id;
    /**
    * 用水类型
    */
    @Schema(description = "用水类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotBlank(message = "用水类型不能为空")
    private String typename;
}
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
@@ -24,6 +24,13 @@
                    <item4 item_name="controllerType" item_value="57" remarks="控制器类型"/>
                    <item5 item_name="protocolName" item_value="p206V202404" remarks="协议名称"/>
            </settings>
            <waterTypes>
                <item1 typeName="灌溉用水"/>
                <item2 typeName="工业用水"/>
                <item3 typeName="生活用水"/>
                <item4 typeName="养殖用水"/>
                <item5 typeName="绿化用水"/>
            </waterTypes>
        </org1>
    </orgs>
</config>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWaterTypeMapper.xml
New file
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dy.pipIrrGlobal.daoSe.SeWaterTypeMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeWaterType">
    <!--@mbg.generated-->
    <!--@Table se_water_type-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="typeName" jdbcType="VARCHAR" property="typename" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, typeName
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from se_water_type
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from se_water_type
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWaterType">
    <!--@mbg.generated-->
    insert into se_water_type (id, typeName)
    values (#{id,jdbcType=BIGINT}, #{typename,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWaterType">
    <!--@mbg.generated-->
    insert into se_water_type
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="typename != null">
        typeName,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="typename != null">
        #{typename,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWaterType">
    <!--@mbg.generated-->
    update se_water_type
    <set>
      <if test="typename != null">
        typeName = #{typename,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWaterType">
    <!--@mbg.generated-->
    update se_water_type
    set typeName = #{typename,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
@@ -10,10 +10,12 @@
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
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.pojoSe.SePaymentMethod;
import com.dy.pipIrrGlobal.pojoSe.SeWaterType;
import com.dy.pipIrrGlobal.util.DistrictLevel;
import org.jdom2.Document;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +39,7 @@
    private BaUserMapper userDao ;
    private SePaymentMethodMapper paymentMethodDao ;
    private BaSettingsMapper settingsDao ;
    private SeWaterTypeMapper waterTypeDao ;
    @Autowired
    public void setDistriDao(BaDistrictMapper distriDao){
@@ -56,6 +59,11 @@
    @Autowired
    public void setSettingsDao(BaSettingsMapper settingsDao){
        this.settingsDao = settingsDao ;
    }
    @Autowired
    public void setWaterTypeDao(SeWaterTypeMapper waterTypeDao){
        this.waterTypeDao = waterTypeDao ;
    }
@@ -153,6 +161,18 @@
                            }
                        }
                    }
                    if(!this.existWaterTypes()){
                        if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes")){
                            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);
                                }else{
                                    break ;
                                }
                            }
                        }
                    }
                }else{
                    break ;
                }
@@ -193,6 +213,15 @@
     */
    private boolean existSettings(){
        Long total = this.settingsDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
    /**
     * 数据库中是否存在用水类型数据
     * @return 存在否
     */
    private boolean existWaterTypes(){
        Long total = this.waterTypeDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
@@ -278,4 +307,18 @@
        }
    }
    /**
     * 保存用水类型
     * @param orgTag 机构标签
     * @param typeName 名称
     */
    private void saveWaterType(String orgTag, String typeName) throws Exception{
        if(typeName != null && !typeName.trim().equals("")){
            SeWaterType po = new SeWaterType() ;
            po.setTypename(typeName);
            this.waterTypeDao.insert(po) ;
        }
    }
}