From e7c0b5be2a66f8f46515d9f8eb267d00eced2538 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期五, 28 六月 2024 16:31:14 +0800
Subject: [PATCH] 系统初始化 增加用水类型初始化
---
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWaterTypeMapper.java | 26 ++++++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWaterType.java | 47 +++++++++++
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWaterTypeMapper.xml | 67 ++++++++++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java | 43 ++++++++++
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml | 7 +
5 files changed, 190 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWaterTypeMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWaterTypeMapper.java
new file mode 100644
index 0000000..8e663ae
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWaterTypeMapper.java
@@ -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);
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWaterType.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWaterType.java
new file mode 100644
index 0000000..80d6485
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWaterType.java
@@ -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;
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml b/pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
index c427921..f914f43 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
+++ b/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>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWaterTypeMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWaterTypeMapper.xml
new file mode 100644
index 0000000..28b146d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWaterTypeMapper.xml
@@ -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>
\ No newline at end of file
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 9779e1b..fd569a6 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
@@ -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) ;
+ }
+ }
+
}
--
Gitblit v1.8.0