wuzeyu
2024-09-02 8edc6710d6ff4612b61e515226fa7df57be4f2be
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
6个文件已添加
18个文件已修改
1889 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/AreaCode2023Mapper.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientCardMapper.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/AreaCode2023.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaDistrict.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoDistrict.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoMapCenter.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoCardInfo.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-database-pj.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/AreaCode2023Mapper.xml 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml 1219 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/PipIrrBaseApplication.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/dict/DictCtrl.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/dict/DictSv.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/qo/DistrictQO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java 157 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/AreaCode2023Mapper.java
New file
@@ -0,0 +1,38 @@
package com.dy.pipIrrGlobal.daoBa;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoBa.AreaCode2023;
import com.dy.pipIrrGlobal.voBa.VoDistrict;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * @author ZhuBaoMin
 * @date 2024-08-30 16:09
 * @LastEditTime 2024-08-30 16:09
 * @Description
 */
@Mapper
public interface AreaCode2023Mapper extends BaseMapper<AreaCode2023> {
    int deleteByPrimaryKey(Long code);
    int insert(AreaCode2023 record);
    int insertSelective(AreaCode2023 record);
    AreaCode2023 selectByPrimaryKey(Long code);
    int updateByPrimaryKeySelective(AreaCode2023 record);
    int updateByPrimaryKey(AreaCode2023 record);
    /**
     * 根据区划代码查询指定级别行政区划
     * @param aredCode
     * @param level
     * @return
     */
    List<VoDistrict> getDistrictS(@Param("aredCode") String aredCode, @Param("level") Integer level);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientCardMapper.java
@@ -3,11 +3,9 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.voSe.VoCardInfo;
import com.dy.pipIrrGlobal.voSe.VoCardInfo1;
import com.dy.pipIrrGlobal.voSe.VoCards;
import com.dy.pipIrrGlobal.voSe.VoCards2;
import com.dy.pipIrrGlobal.voSt.VoICCard;
import com.dy.pipIrrGlobal.voWe.VoCards3;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -190,4 +188,18 @@
     * @return
     */
    Double getTotalMoneyIcCards();
    /**
     * 根据水卡地址获取水卡数量,用来判断该卡是否允许开卡
     * @param cardAddr
     * @return
     */
    Long getCountByCardAddr(String cardAddr);
    /**
     * 根据水卡地址获取指定状态的水卡数量,用来判断该卡是否允许开卡
     * @param cardAddr
     * @return
     */
    Long getCountByCardAddrAndState(String cardAddr);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/AreaCode2023.java
New file
@@ -0,0 +1,52 @@
package com.dy.pipIrrGlobal.pojoBa;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import lombok.*;
/**
 * @author ZhuBaoMin
 * @date 2024-08-30 16:09
 * @LastEditTime 2024-08-30 16:09
 * @Description
 */
@TableName(value="area_code_2023", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class AreaCode2023 implements BaseEntity {
    public static final long serialVersionUID = 202408301613001L;
    /**
    * 区划代码
    */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private Long code;
    /**
    * 名称
    */
    private String name;
    /**
    * 级别1-5,省市县镇村
    */
    private Boolean level;
    /**
    * 父级区划代码
    */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private Long pcode;
    /**
    * 城乡分类
    */
    private Integer category;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaDistrict.java
@@ -42,6 +42,7 @@
     * 上级行下区ID
     */
    @Schema(description = "上级实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long supperId;
    /**
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoDistrict.java
New file
@@ -0,0 +1,30 @@
package com.dy.pipIrrGlobal.voBa;
import lombok.Data;
/**
 * @author ZhuBaoMin
 * @date 2024-08-30 16:02
 * @LastEditTime 2024-08-30 16:02
 * @Description 区划视图对象
 */
@Data
public class VoDistrict {
    private static final long serialVersionUID = 202408301604001L;
    /**
     * 区划名称
     */
    private String name;
    /**
     * 区划代码
     */
    private String code;
    /**
     * 级别,1-5省市县镇村
     */
    private Integer level;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoMapCenter.java
New file
@@ -0,0 +1,31 @@
package com.dy.pipIrrGlobal.voBa;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import lombok.Data;
import java.math.BigDecimal;
/**
 * @author ZhuBaoMin
 * @date 2024-08-29 17:27
 * @LastEditTime 2024-08-29 17:27
 * @Description
 */
@Data
public class VoMapCenter {
    private static final long serialVersionUID = 202408291727001L;
    /**
     * 纬度
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private BigDecimal lat;
    /**
     * 经度
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private BigDecimal lng;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java
@@ -22,9 +22,11 @@
    private String rtuAddr;
    private String vcNum;
    private String orderNo;
    private String vcNum;
    private String state;
    //private Date openTime;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoCardInfo.java
@@ -1,5 +1,7 @@
package com.dy.pipIrrGlobal.voSe;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.dy.common.po.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -17,6 +19,7 @@
    private static final long serialVersionUID = 1L;
    @Schema(title = "水卡编号")
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private Long cardNum;
    @Schema(title = "卡片类型")
pipIrr-platform/pipIrr-global/src/main/resources/application-database-pj.yml
@@ -5,8 +5,8 @@
            #name: pj
            type: com.alibaba.druid.pool.DruidDataSource
            driverClassName: com.mysql.cj.jdbc.Driver
            #url: jdbc:mysql://192.168.40.166:3306/pipIrr_pj?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            #url: jdbc:mysql://8.130.130.233:3306/pipIrr_pj?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://192.168.40.166:3306/pipIrr_pj?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://8.130.130.233:3306/pipIrr_pj?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            #url: jdbc:mysql://8.140.179.55:3306/pipIrr_pj?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            url: jdbc:mysql://127.0.0.1:3306/pipIrr_pj?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            username: root
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
@@ -7,7 +7,6 @@
            driverClassName: com.mysql.cj.jdbc.Driver
#            url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://8.130.130.233:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            #url: jdbc:mysql://8.140.179.55:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            username: root
            password: dysql,;.abc!@#
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
@@ -10,6 +10,14 @@
                    </city>
                </province>
            </districts>
            <dictionaries>
                <dict code="protocol" title="协议" valueType="2">
                    <dictItem>
                        <item1 dictCode="protocol" value="p206V1_0_1" name="老协议" status="1" sort="0" />
                        <item2 dictCode="protocol" value="p206V202404" name="新协议" status="0" sort="1" />
                    </dictItem>
                </dict>
            </dictionaries>
            <user name="超级管理员" phone="admin" password="admin" supperAdmin="1" />
            <payments>
                <item1 name="现金"/>
@@ -28,15 +36,16 @@
                <item4 typeName="养殖用水"/>
                <item5 typeName="绿化用水"/>
            </waterTypes>
            <waterPrice price="0.90" />
            <irrigateProfile>
                <item1 default_value = "10" unit = "2" sort = "1" type = "1"/>
                <item2 default_value = "20" unit = "2" sort = "2" type = "1" />
                <item3 default_value = "1" unit = "1" sort = "3" type = "1"/>
                <item4 default_value = "2" unit = "1" sort = "4" type = "1"/>
                <item5 default_value = "20" unit = "3" sort = "1" type = "2"/>
                <item6 default_value = "30" unit = "3" sort = "2" type = "2"/>
                <item7 default_value = "50" unit = "3" sort = "3" type = "2"/>
                <item8 default_value = "80" unit = "3" sort = "4" type = "2"/>
                <item1 defaultValue = "10" unit = "2" sort = "1" type = "1"/>
                <item2 defaultValue = "20" unit = "2" sort = "2" type = "1" />
                <item3 defaultValue = "1" unit = "1" sort = "3" type = "1"/>
                <item4 defaultValue = "2" unit = "1" sort = "4" type = "1"/>
                <item5 defaultValue = "20" unit = "3" sort = "1" type = "2"/>
                <item6 defaultValue = "30" unit = "3" sort = "2" type = "2"/>
                <item7 defaultValue = "50" unit = "3" sort = "3" type = "2"/>
                <item8 defaultValue = "80" unit = "3" sort = "4" type = "2"/>
            </irrigateProfile>
        </org1>
        <org2 tag="pj" name="片角" enable="false">
@@ -47,6 +56,14 @@
                    </city>
                </province>
            </districts>
            <dictionaries>
                <dict code="protocol" title="协议" valueType="2">
                    <dictItem>
                        <item1 dictCode="protocol" value="p206V1_0_1" name="老协议" status="1" sort="0" />
                        <item2 dictCode="protocol" value="p206V202404" name="新协议" status="0" sort="1" />
                    </dictItem>
                </dict>
            </dictionaries>
            <user name="超级管理员" phone="admin" password="admin" supperAdmin="1" />
            <payments>
                <item1 name="现金"/>
@@ -65,15 +82,16 @@
                <item4 typeName="养殖用水"/>
                <item5 typeName="绿化用水"/>
            </waterTypes>
            <waterPrice price="0.90" />
            <irrigateProfile>
                <item1 default_value = "10" unit = "2" sort = "1" type = "1"/>
                <item2 default_value = "20" unit = "2" sort = "2" type = "1" />
                <item3 default_value = "1" unit = "1" sort = "3" type = "1"/>
                <item4 default_value = "2" unit = "1" sort = "4" type = "1"/>
                <item5 default_value = "20" unit = "3" sort = "1" type = "2"/>
                <item6 default_value = "30" unit = "3" sort = "2" type = "2"/>
                <item7 default_value = "50" unit = "3" sort = "3" type = "2"/>
                <item8 default_value = "80" unit = "3" sort = "4" type = "2"/>
                <item1 defaultValue = "10" unit = "2" sort = "1" type = "1"/>
                <item2 defaultValue = "20" unit = "2" sort = "2" type = "1" />
                <item3 defaultValue = "1" unit = "1" sort = "3" type = "1"/>
                <item4 defaultValue = "2" unit = "1" sort = "4" type = "1"/>
                <item5 defaultValue = "20" unit = "3" sort = "1" type = "2"/>
                <item6 defaultValue = "30" unit = "3" sort = "2" type = "2"/>
                <item7 defaultValue = "50" unit = "3" sort = "3" type = "2"/>
                <item8 defaultValue = "80" unit = "3" sort = "4" type = "2"/>
            </irrigateProfile>
        </org2>
    </orgs>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/AreaCode2023Mapper.xml
New file
@@ -0,0 +1,115 @@
<?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.daoBa.AreaCode2023Mapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.AreaCode2023">
    <!--@mbg.generated-->
    <!--@Table area_code_2023-->
    <id column="code" jdbcType="BIGINT" property="code" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="level" jdbcType="BOOLEAN" property="level" />
    <result column="pcode" jdbcType="BIGINT" property="pcode" />
    <result column="category" jdbcType="INTEGER" property="category" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    code, `name`, `level`, pcode, category
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from area_code_2023
    where code = #{code,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from area_code_2023
    where code = #{code,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023">
    <!--@mbg.generated-->
    insert into area_code_2023 (code, `name`, `level`,
      pcode, category)
    values (#{code,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=BOOLEAN},
      #{pcode,jdbcType=BIGINT}, #{category,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023">
    <!--@mbg.generated-->
    insert into area_code_2023
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="level != null">
        `level`,
      </if>
      <if test="pcode != null">
        pcode,
      </if>
      <if test="category != null">
        category,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=BIGINT},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        #{level,jdbcType=BOOLEAN},
      </if>
      <if test="pcode != null">
        #{pcode,jdbcType=BIGINT},
      </if>
      <if test="category != null">
        #{category,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023">
    <!--@mbg.generated-->
    update area_code_2023
    <set>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        `level` = #{level,jdbcType=BOOLEAN},
      </if>
      <if test="pcode != null">
        pcode = #{pcode,jdbcType=BIGINT},
      </if>
      <if test="category != null">
        category = #{category,jdbcType=INTEGER},
      </if>
    </set>
    where code = #{code,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023">
    <!--@mbg.generated-->
    update area_code_2023
    set `name` = #{name,jdbcType=VARCHAR},
      `level` = #{level,jdbcType=BOOLEAN},
      pcode = #{pcode,jdbcType=BIGINT},
      category = #{category,jdbcType=INTEGER}
    where code = #{code,jdbcType=BIGINT}
  </update>
  <!--根据区划代码查询指定级别行政区划-->
  <select id="getDistrictS" resultType="com.dy.pipIrrGlobal.voBa.VoDistrict">
    SELECT
        name,
        CASE
            WHEN level = 4 THEN SUBSTRING(code,7,3)
            WHEN level = 5 THEN SUBSTRING(code,10,3)
        END AS code,
        level
    FROM area_code_2023
    WHERE code LIKE CONCAT('%', #{aredCode}, '%') AND level = #{level}
  </select>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml
@@ -1,618 +1,653 @@
<?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.SeClientCardMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
    <!--@mbg.generated-->
    <!--@Table se_client_card-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="protocol" jdbcType="VARCHAR" property="protocol" />
    <result column="cardAddr" jdbcType="VARCHAR" property="cardaddr" />
    <result column="cardNum" jdbcType="BIGINT" property="cardnum" />
    <result column="clientId" jdbcType="BIGINT" property="clientid" />
    <result column="money" jdbcType="FLOAT" property="money" />
    <result column="state" jdbcType="TINYINT" property="state" />
    <result column="original_card_id" jdbcType="BIGINT" property="originalCardId"/>
    <result column="createDt" jdbcType="TIMESTAMP" property="createdt" />
    <result column="replaceDt" jdbcType="TIMESTAMP" property="replacedt" />
    <result column="rechargeDt" jdbcType="TIMESTAMP" property="rechargedt" />
    <result column="lossDtDt" jdbcType="TIMESTAMP" property="lossdtdt" />
    <result column="cancelDt" jdbcType="TIMESTAMP" property="canceldt" />
    <result column="unlockDt" jdbcType="TIMESTAMP" property="unlockdt" />
    <result column="reversalDt" jdbcType="TIMESTAMP" property="reversaldt" />
    <result column="refundDt" jdbcType="TIMESTAMP" property="refunddt" />
    <result column="consumeDt" jdbcType="TIMESTAMP" property="consumedt" />
    <result column="lastOper" jdbcType="TINYINT" property="lastoper" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, protocol, cardAddr, cardNum, clientId, money, `state`, original_card_id, createDt, replaceDt, rechargeDt,
    lossDtDt, cancelDt, unlockDt, reversalDt, refundDt, consumeDt, lastOper, remarks
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from se_client_card
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from se_client_card
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <!--依据水卡地址获取水卡编号(12月19日废弃)-->
  <select id="getCardIdByAddr" resultType="java.lang.Long">
    SELECT id AS cardId FROM se_client_card WHERE cardAddr = #{cardAddr}
  </select>
  <!--根据水卡编号获取水卡表主键(12月19日添加后废弃)-->
  <select id="getCardIdByNum" resultType="java.lang.Long">
    SELECT id AS cardId FROM se_client_card WHERE cardNum = #{cardNum}
  </select>
  <!--根据水卡编号获取水卡表主键及农户编号-->
  <select id="getCardIdAndClientNum" resultType="java.util.Map">
    <!--    SELECT id AS cardId, clientNum FROM se_client_card WHERE cardNum = #{cardNum}-->
    SELECT
      card.id AS cardId,
      cli.clientNum,
      cli.id AS clientId,
      protocol
    FROM se_client_card card
    INNER JOIN se_client cli ON card.clientId = cli.id
    WHERE card.cardNum = #{cardNum}
  </select>
  <!-- 根据水卡编号获取水卡对应的农户id和姓名 -->
  <select id="getClientIdAndNameByCardAddrAndCardNo" resultType="java.util.Map">
    SELECT
    cli.id AS clientId,
    cli.name AS clientName
    FROM se_client_card card
    INNER JOIN se_client cli ON card.clientId = cli.id
    WHERE card.cardAddr = #{cardAddr} and  card.cardNum = #{cardNum}
  </select>
  <!-- 根据水卡编号获取水卡 -->
  <select id="getCardsByAddrAndNum"  resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo1">
    SELECT
    id,
    money
    FROM se_client_card
    WHERE cardAddr = #{cardAddr} and  cardNum = #{cardNum}
  </select>
  <!--根据行政区划串模糊查询水卡编号-->
  <select id="getCardNumOfMax"  resultType="java.lang.String">
    SELECT cardNum
    FROM se_client_card
    WHERE cardNum LIKE CONCAT(#{areaCode},'%')
    ORDER BY cardNum desc
    LIMIT 0,1
  </select>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
    <!--@mbg.generated-->
    insert into se_client_card (id, protocol, cardAddr, cardNum, clientId,
      money, `state`, original_card_id, createDt,
      replaceDt, rechargeDt, lossDtDt,
      cancelDt, unlockDt, reversalDt, refundDt,
      consumeDt, lastOper, remarks
      )
    values (#{id,jdbcType=BIGINT}, #{protocol,jdbcType=VARCHAR}, #{cardaddr,jdbcType=VARCHAR}, #{cardnum,jdbcType=BIGINT}, #{clientid,jdbcType=BIGINT},
      #{money,jdbcType=FLOAT}, #{state,jdbcType=TINYINT}, #{originalCardId,jdbcType=BIGINT}, #{createdt,jdbcType=TIMESTAMP},
      #{replacedt,jdbcType=TIMESTAMP}, #{rechargedt,jdbcType=TIMESTAMP}, #{lossdtdt,jdbcType=TIMESTAMP},
      #{canceldt,jdbcType=TIMESTAMP}, #{unlockdt,jdbcType=TIMESTAMP}, #{reversaldt,jdbcType=TIMESTAMP},
      #{refunddt,jdbcType=TIMESTAMP}, #{consumedt,jdbcType=TIMESTAMP}, #{lastoper,jdbcType=TINYINT}, #{remarks,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into se_client_card
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
        <!--@mbg.generated-->
        <!--@Table se_client_card-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="protocol" jdbcType="VARCHAR" property="protocol"/>
        <result column="cardAddr" jdbcType="VARCHAR" property="cardaddr"/>
        <result column="cardNum" jdbcType="BIGINT" property="cardnum"/>
        <result column="clientId" jdbcType="BIGINT" property="clientid"/>
        <result column="money" jdbcType="FLOAT" property="money"/>
        <result column="state" jdbcType="TINYINT" property="state"/>
        <result column="original_card_id" jdbcType="BIGINT" property="originalCardId"/>
        <result column="createDt" jdbcType="TIMESTAMP" property="createdt"/>
        <result column="replaceDt" jdbcType="TIMESTAMP" property="replacedt"/>
        <result column="rechargeDt" jdbcType="TIMESTAMP" property="rechargedt"/>
        <result column="lossDtDt" jdbcType="TIMESTAMP" property="lossdtdt"/>
        <result column="cancelDt" jdbcType="TIMESTAMP" property="canceldt"/>
        <result column="unlockDt" jdbcType="TIMESTAMP" property="unlockdt"/>
        <result column="reversalDt" jdbcType="TIMESTAMP" property="reversaldt"/>
        <result column="refundDt" jdbcType="TIMESTAMP" property="refunddt"/>
        <result column="consumeDt" jdbcType="TIMESTAMP" property="consumedt"/>
        <result column="lastOper" jdbcType="TINYINT" property="lastoper"/>
        <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id,
      </if>
      <if test="protocol != null">
        protocol,
      </if>
      <if test="cardaddr != null">
        cardAddr,
      </if>
      <if test="cardnum != null">
        cardNum,
      </if>
      <if test="clientid != null">
        clientId,
      </if>
      <if test="money != null">
        money,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="originalCardId != null">
        original_card_id,
      </if>
      <if test="createdt != null">
        createDt,
      </if>
      <if test="replacedt != null">
        replaceDt,
      </if>
      <if test="rechargedt != null">
        rechargeDt,
      </if>
      <if test="lossdtdt != null">
        lossDtDt,
      </if>
      <if test="canceldt != null">
        cancelDt,
      </if>
      <if test="unlockdt != null">
        unlockDt,
      </if>
      <if test="reversaldt != null">
        reversalDt,
      </if>
      <if test="refunddt != null">
        refundDt,
      </if>
      <if test="consumedt != null">
        consumeDt,
      </if>
      <if test="lastoper != null">
        lastOper,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="protocol != null">
        #{protocol,jdbcType=VARCHAR},
      </if>
      <if test="cardaddr != null">
        #{cardaddr,jdbcType=VARCHAR},
      </if>
      <if test="cardnum != null">
        #{cardnum,jdbcType=BIGINT},
      </if>
      <if test="clientid != null">
        #{clientid,jdbcType=BIGINT},
      </if>
      <if test="money != null">
        #{money,jdbcType=FLOAT},
      </if>
      <if test="state != null">
        #{state,jdbcType=TINYINT},
      </if>
      <if test="originalCardId != null">
        #{originalCardId,jdbcType=BIGINT},
      </if>
      <if test="createdt != null">
        #{createdt,jdbcType=TIMESTAMP},
      </if>
      <if test="replacedt != null">
        #{replacedt,jdbcType=TIMESTAMP},
      </if>
      <if test="rechargedt != null">
        #{rechargedt,jdbcType=TIMESTAMP},
      </if>
      <if test="lossdtdt != null">
        #{lossdtdt,jdbcType=TIMESTAMP},
      </if>
      <if test="canceldt != null">
        #{canceldt,jdbcType=TIMESTAMP},
      </if>
      <if test="unlockdt != null">
        #{unlockdt,jdbcType=TIMESTAMP},
      </if>
      <if test="reversaldt != null">
        #{reversaldt,jdbcType=TIMESTAMP},
      </if>
      <if test="refunddt != null">
        #{refunddt,jdbcType=TIMESTAMP},
      </if>
      <if test="consumedt != null">
        #{consumedt,jdbcType=TIMESTAMP},
      </if>
      <if test="lastoper != null">
        #{lastoper,jdbcType=TINYINT},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
    <!--@mbg.generated-->
    update se_client_card
    <set>
      <if test="protocol != null">
        protocol = #{protocol,jdbcType=VARCHAR},
      </if>
      <if test="cardaddr != null">
        cardAddr = #{cardaddr,jdbcType=VARCHAR},
      </if>
      <if test="cardnum != null">
        cardNum = #{cardnum,jdbcType=BIGINT},
      </if>
      <if test="clientid != null">
        clientId = #{clientid,jdbcType=BIGINT},
      </if>
      <if test="money != null">
        money = #{money,jdbcType=FLOAT},
      </if>
      <if test="state != null">
        `state` = #{state,jdbcType=TINYINT},
      </if>
      <if test="originalCardId != null">
        `original_card_id` = #{originalCardId,jdbcType=BIGINT},
      </if>
      <if test="createdt != null">
        createDt = #{createdt,jdbcType=TIMESTAMP},
      </if>
      <if test="replacedt != null">
        replaceDt = #{replacedt,jdbcType=TIMESTAMP},
      </if>
      <if test="rechargedt != null">
        rechargeDt = #{rechargedt,jdbcType=TIMESTAMP},
      </if>
      <if test="lossdtdt != null">
        lossDtDt = #{lossdtdt,jdbcType=TIMESTAMP},
      </if>
      <if test="canceldt != null">
        cancelDt = #{canceldt,jdbcType=TIMESTAMP},
      </if>
      <if test="unlockdt != null">
        unlockDt = #{unlockdt,jdbcType=TIMESTAMP},
      </if>
      <if test="reversaldt != null">
        reversalDt = #{reversaldt,jdbcType=TIMESTAMP},
      </if>
      <if test="refunddt != null">
        refundDt = #{refunddt,jdbcType=TIMESTAMP},
      </if>
      <if test="consumedt != null">
        consumeDt = #{consumedt,jdbcType=TIMESTAMP},
      </if>
      <if test="lastoper != null">
        lastOper = #{lastoper,jdbcType=TINYINT},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
    <!--@mbg.generated-->
    update se_client_card
    set protocol = #{protocol,jdbcType=VARCHAR},
      cardAddr = #{cardaddr,jdbcType=VARCHAR},
      cardNum = #{cardnum,jdbcType=BIGINT},
      clientId = #{clientid,jdbcType=BIGINT},
      money = #{money,jdbcType=FLOAT},
      `state` = #{state,jdbcType=TINYINT},
      original_card_id = #{originalCardId,jdbcType=BIGINT},
      createDt = #{createdt,jdbcType=TIMESTAMP},
      replaceDt = #{replacedt,jdbcType=TIMESTAMP},
      rechargeDt = #{rechargedt,jdbcType=TIMESTAMP},
      lossDtDt = #{lossdtdt,jdbcType=TIMESTAMP},
      cancelDt = #{canceldt,jdbcType=TIMESTAMP},
      unlockDt = #{unlockdt,jdbcType=TIMESTAMP},
      reversalDt = #{reversaldt,jdbcType=TIMESTAMP},
      refundDt = #{refunddt,jdbcType=TIMESTAMP},
      consumeDt = #{consumedt,jdbcType=TIMESTAMP},
      lastOper = #{lastoper,jdbcType=TINYINT},
      remarks = #{remarks,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateMoney" >
    update se_client_card
    set money = #{money,jdbcType=FLOAT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据农户主键获取水卡列表(物理卡+虚拟卡)-->
  <select id="getCardInfoByClientId" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo">
    SELECT
    *
    FROM
    (SELECT
    '物理卡' AS cardType,
    clientCard.cardNum   AS CardNum,
    clientCard.money   AS Money,
    (CASE
    WHEN clientCard.state = 1 THEN '正常'
    WHEN clientCard.state = 2 THEN '已注销'
    ELSE '已挂失'
    END) AS State
    FROM se_client client
    LEFT JOIN se_client_card clientCard ON clientCard.clientId = client.id
    WHERE client.id = #{clientId,jdbcType=BIGINT}
    UNION ALL
    SELECT
    '虚拟卡' AS cardType,
    virtualCard.vc_num   AS CardNum,
    virtualCard.money   AS vcMoney,
    (CASE
    WHEN virtualCard.in_use = 0 THEN '未使用'
    WHEN virtualCard.in_use = 1 THEN '使用中'
    END) AS State
    FROM se_client client
    LEFT JOIN se_virtual_card virtualCard ON client.id = virtualCard.client_id
    WHERE client.id = #{clientId,jdbcType=BIGINT}
    ) card
    ORDER BY card.Money DESC , card.State DESC
  </select>
  <!--根据水卡编号获取操作记录列表-->
  <select id="getOperateRecordsByCardNum" resultType="java.util.HashMap">
    SELECT * FROM v_operate WHERE cardNum = #{cardNum,jdbcType=BIGINT}
  </select>
  <!--根据水卡编号获取余额-->
  <select id="getMoneyByCardNum" resultType="java.lang.Float">
    SELECT money FROM se_client_card WHERE cardNum = #{cardNum,jdbcType=BIGINT}
  </select>
  <!--根据水卡编号获取充值总额-->
  <select id="sumRechargeByCardNum" resultType="java.lang.Float">
    SELECT
      SUM(his.amount) AS amount
    FROM se_recharge_history his
        INNER JOIN se_client_card card ON his.cardId = card.id
    WHERE card.cardNum = #{cardNum,jdbcType=BIGINT}
  </select>
  <!--根据水卡编号获取卡片状态:1-开卡,2-补卡,3-充值,4-挂失,5-注销,6-解锁,7-冲正,8-消费-->
  <select id="getCardStateByCardNum" resultType="java.lang.String">
<!--    SELECT-->
<!--      (CASE-->
<!--         WHEN lastOper = 1 THEN "开卡"-->
<!--         WHEN lastOper = 2 THEN "补卡"-->
<!--         WHEN lastOper = 3 THEN "充值"-->
<!--         WHEN lastOper = 4 THEN "挂失"-->
<!--         WHEN lastOper = 5 THEN "注销"-->
<!--         WHEN lastOper = 6 THEN "解锁"-->
<!--         WHEN lastOper = 7 THEN "冲正"-->
<!--         WHEN lastOper = 8 THEN "消费"-->
<!--        END) AS stateName-->
<!--    FROM se_client_card-->
<!--    WHERE cardNum = ${cardNum}-->
    SELECT
        (CASE
            WHEN state = 1 THEN '正常'
            WHEN state = 2 THEN '已注销'
            WHEN state = 3 THEN '已挂失'
        END) AS stateName
    FROM se_client_card
    WHERE cardNum = #{cardNum,jdbcType=BIGINT}
  </select>
  <!--根据指定条件获取水卡列表记录数,应用程序使用-->
  <select id="getCardsCount" parameterType="java.util.Map" resultType="java.lang.Long">
    SELECT
        COUNT(*) AS recordCount
    FROM se_client_card card
      INNER JOIN se_client cli ON card.clientId = cli.id
    <where>
      AND card.state = 1
      <if test = "clientNum != null and clientNum !=''">
        AND cli.clientNum like CONCAT('%',#{clientNum},'%')
      </if>
      <if test = "clientName != null and clientName !=''">
        AND cli.name like CONCAT('%',#{clientName},'%')
      </if>
      <if test = "cardNum != null and cardNum !=''">
        AND card.cardNum like CONCAT('%',#{cardNum},'%')
      </if>
    </where>
  </select>
  <!--根据指定条件获取水卡列表,应用程序使用-->
  <select id="getCards" resultType="com.dy.pipIrrGlobal.voSe.VoCards">
    SELECT
        cli.clientNum,
        cli.name AS clientName,
        cardNum,
<!--        CASE-->
<!--            WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))-->
<!--            ELSE card.cardNum-->
<!--        END AS cardNum,-->
        cli.phone,
        cli.idCard,
        card.state AS cardState,
<!--        (CASE-->
<!--            WHEN card.state = 1 THEN '正常'-->
<!--            WHEN card.state = 2 THEN '已注销'-->
<!--            WHEN card.state = 3 THEN '已挂失'-->
<!--        End) AS stateName,-->
        '正常' AS stateName,
        '农户卡' AS cardType,
        FORMAT(card.money, 2) AS money
    FROM se_client_card card
        INNER JOIN se_client cli ON card.clientId = cli.id
    <where>
      AND card.state = 1
      <if test = "clientNum != null and clientNum !=''">
        AND cli.clientNum like CONCAT('%',#{clientNum},'%')
      </if>
      <if test = "clientName != null and clientName !=''">
        AND cli.name like CONCAT('%',#{clientName},'%')
      </if>
      <if test = "cardNum != null and cardNum !=''">
        AND card.cardNum like CONCAT('%',#{cardNum},'%')
      </if>
    </where>
    ORDER BY card.id
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
  </select>
  <!--获取已挂失未补卡的记录数量-->
  <select id="getUnreplacedRecordCount" resultType="java.lang.Long">
    SELECT
        COUNT(*) AS recordCount
    FROM se_client_card card
           INNER JOIN se_client cli ON card.clientId = cli.id
    WHERE card.state = 3 AND NOT EXISTS (SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.cardNum)
  </select>
  <!--获取已挂失未补卡的记录-->
  <select id="getUnreplaced" resultType="com.dy.pipIrrGlobal.voSe.VoCards">
    SELECT
        cli.clientNum,
        cli.name AS clientName,
        cardNum,
<!--        CASE-->
<!--          WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))-->
<!--          ELSE card.cardNum-->
<!--        END AS cardNum,-->
        cli.phone,
        cli.idCard,
        card.state AS cardState,
        '已挂失' AS stateName,
        '农户卡' AS cardType,
        FORMAT(card.money,2) AS money
    FROM se_client_card card
        INNER JOIN se_client cli ON card.clientId = cli.id
    WHERE card.state = 3 AND NOT EXISTS (SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.id)
    ORDER BY card.id
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
  </select>
  <!--根据指定水卡编号获取挂失事记录数量(补卡、解锁使用)-->
  <select id="getLostCount" resultType="java.lang.Integer">
    SELECT
        COUNT(*) AS recordCount
    FROM se_client_card card
    <where>
      AND card.state = 3
      <if test = "cardNum != null and cardNum > 0">
        AND card.cardNum = #{cardNum}
      </if>
    </where>
  </select>
  <!--根据指定水卡编号获取已补卡数量(补卡、解锁使用)-->
  <select id="getReplacedCount" resultType="java.lang.Integer">
    SELECT
        COUNT(*) AS recordCount
    FROM se_client_card card
        INNER JOIN se_client_card card2 ON card2.original_card_id = card.id
    <where>
      <if test = "cardNum != null and cardNum > 0">
        AND card.cardNum = #{cardNum}
      </if>
    </where>
  </select>
  <!--根据农户姓名和手机号获取水卡列表记录数,应用程序使用-->
  <select id="getCardsByClientNameAndPhoneCount" resultType="java.lang.Long">
    SELECT
      COUNT(*) AS recordCount
    FROM se_client_card card
    INNER JOIN se_client cli ON card.clientId = cli.id
    <where>
      card.state = 1
      <if test = "clientName != null and clientName !=''">
        AND cli.name like CONCAT('%',#{clientName},'%')
      </if>
      <if test = "phone != null and phone !=''">
        AND cli.phone like CONCAT('%',#{phone},'%')
      </if>
    </where>
        remarks
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from se_client_card
        where id = #{id,jdbcType=BIGINT}
    </select>
  <!--根据农户姓名和手机号获取水卡列表,应用程序使用-->
  <select id="getCardsByClientNameAndPhone" resultType="com.dy.pipIrrGlobal.voSe.VoCards2">
    SELECT
    card.id AS clientCardId,
    cli.id AS clientId,
    cli.clientNum,
    cli.name AS clientName,
    card.cardNum,
    cli.phone,
    cli.idCard,
    card.state AS cardState,
    (CASE
    WHEN card.state = 1 THEN '正常'
    WHEN card.state = 2 THEN '已注销'
    WHEN card.state = 3 THEN '已挂失'
    End) AS stateName,
    '农户卡' AS cardType,
    FORMAT(card.money, 2) AS money
    FROM se_client_card card
    INNER JOIN se_client cli ON card.clientId = cli.id
    <where>
      card.state = 1
      <if test = "clientName != null and clientName !=''">
        AND cli.name like CONCAT('%',#{clientName},'%')
      </if>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        delete
        from se_client_card
        where id = #{id,jdbcType=BIGINT}
    </delete>
      <if test = "phone != null and phone !=''">
        AND cli.phone like CONCAT('%',#{phone},'%')
      </if>
    </where>
    ORDER BY card.id
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
  </select>
  <!--根据农户ID查询正常状态的水卡列表,小程序使用-->
  <select id="getCardsByClientID" resultType="com.dy.pipIrrGlobal.voWe.VoCards3">
    SELECT
    card.id AS clientCardId,
    cli.id AS clientId,
    cli.clientNum,
    cli.name AS clientName,
    card.cardNum,
    cli.phone,
    cli.idCard,
    card.state AS cardState,
    (CASE
    WHEN card.state = 1 THEN '正常'
    WHEN card.state = 2 THEN '已注销'
    WHEN card.state = 3 THEN '已挂失'
    End) AS stateName,
    '农户卡' AS cardType,
    FORMAT(card.money, 2) AS money
    FROM se_client_card card
    INNER JOIN se_client cli ON card.clientId = cli.id
    where
      card.state = 1
      AND cli.id like CONCAT('%',#{clientId},'%')
    <!--依据水卡地址获取水卡编号(12月19日废弃)-->
    <select id="getCardIdByAddr" resultType="java.lang.Long">
        SELECT id AS cardId
        FROM se_client_card
        WHERE cardAddr = #{cardAddr}
    </select>
    <!--根据水卡编号获取水卡表主键(12月19日添加后废弃)-->
    <select id="getCardIdByNum" resultType="java.lang.Long">
        SELECT id AS cardId
        FROM se_client_card
        WHERE cardNum = #{cardNum}
    </select>
    <!--根据水卡编号获取水卡表主键及农户编号-->
    <select id="getCardIdAndClientNum" resultType="java.util.Map">
        <!--    SELECT id AS cardId, clientNum FROM se_client_card WHERE cardNum = #{cardNum}-->
        SELECT card.id AS cardId,
               cli.clientNum,
               cli.id  AS clientId,
               protocol
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        WHERE card.cardNum = #{cardNum}
    </select>
    <!-- 根据水卡编号获取水卡对应的农户id和姓名 -->
    <select id="getClientIdAndNameByCardAddrAndCardNo" resultType="java.util.Map">
        SELECT cli.id   AS clientId,
               cli.name AS clientName
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        WHERE card.cardAddr = #{cardAddr}
          and card.cardNum = #{cardNum}
    </select>
    ORDER BY card.id
  </select>
  <!--当前余额总量(物理卡)-->
  <select id="getTotalMoneyIcCards" resultType="java.lang.Double">
    SELECT
      IFNULL(SUM(money),0) AS totalMoney
    FROM
      `se_client_card`
    WHERE state = 1
  </select>
    <!-- 根据水卡编号获取水卡 -->
    <select id="getCardsByAddrAndNum" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo1">
        SELECT id,
               money
        FROM se_client_card
        WHERE cardAddr = #{cardAddr}
          and cardNum = #{cardNum}
    </select>
    <!--根据行政区划串模糊查询水卡编号-->
    <select id="getCardNumOfMax" resultType="java.lang.String">
        SELECT cardNum
        FROM se_client_card
        WHERE cardNum LIKE CONCAT(#{areaCode}, '%')
        ORDER BY cardNum desc
        LIMIT 0,1
    </select>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
        <!--@mbg.generated-->
        insert into se_client_card (id, protocol, cardAddr, cardNum, clientId,
                                    money, `state`, original_card_id, createDt,
                                    replaceDt, rechargeDt, lossDtDt,
                                    cancelDt, unlockDt, reversalDt, refundDt,
                                    consumeDt, lastOper, remarks)
        values (#{id,jdbcType=BIGINT}, #{protocol,jdbcType=VARCHAR}, #{cardaddr,jdbcType=VARCHAR},
                #{cardnum,jdbcType=BIGINT}, #{clientid,jdbcType=BIGINT},
                #{money,jdbcType=FLOAT}, #{state,jdbcType=TINYINT}, #{originalCardId,jdbcType=BIGINT},
                #{createdt,jdbcType=TIMESTAMP},
                #{replacedt,jdbcType=TIMESTAMP}, #{rechargedt,jdbcType=TIMESTAMP}, #{lossdtdt,jdbcType=TIMESTAMP},
                #{canceldt,jdbcType=TIMESTAMP}, #{unlockdt,jdbcType=TIMESTAMP}, #{reversaldt,jdbcType=TIMESTAMP},
                #{refunddt,jdbcType=TIMESTAMP}, #{consumedt,jdbcType=TIMESTAMP}, #{lastoper,jdbcType=TINYINT},
                #{remarks,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into se_client_card
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="protocol != null">
                protocol,
            </if>
            <if test="cardaddr != null">
                cardAddr,
            </if>
            <if test="cardnum != null">
                cardNum,
            </if>
            <if test="clientid != null">
                clientId,
            </if>
            <if test="money != null">
                money,
            </if>
            <if test="state != null">
                `state`,
            </if>
            <if test="originalCardId != null">
                original_card_id,
            </if>
            <if test="createdt != null">
                createDt,
            </if>
            <if test="replacedt != null">
                replaceDt,
            </if>
            <if test="rechargedt != null">
                rechargeDt,
            </if>
            <if test="lossdtdt != null">
                lossDtDt,
            </if>
            <if test="canceldt != null">
                cancelDt,
            </if>
            <if test="unlockdt != null">
                unlockDt,
            </if>
            <if test="reversaldt != null">
                reversalDt,
            </if>
            <if test="refunddt != null">
                refundDt,
            </if>
            <if test="consumedt != null">
                consumeDt,
            </if>
            <if test="lastoper != null">
                lastOper,
            </if>
            <if test="remarks != null">
                remarks,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="protocol != null">
                #{protocol,jdbcType=VARCHAR},
            </if>
            <if test="cardaddr != null">
                #{cardaddr,jdbcType=VARCHAR},
            </if>
            <if test="cardnum != null">
                #{cardnum,jdbcType=BIGINT},
            </if>
            <if test="clientid != null">
                #{clientid,jdbcType=BIGINT},
            </if>
            <if test="money != null">
                #{money,jdbcType=FLOAT},
            </if>
            <if test="state != null">
                #{state,jdbcType=TINYINT},
            </if>
            <if test="originalCardId != null">
                #{originalCardId,jdbcType=BIGINT},
            </if>
            <if test="createdt != null">
                #{createdt,jdbcType=TIMESTAMP},
            </if>
            <if test="replacedt != null">
                #{replacedt,jdbcType=TIMESTAMP},
            </if>
            <if test="rechargedt != null">
                #{rechargedt,jdbcType=TIMESTAMP},
            </if>
            <if test="lossdtdt != null">
                #{lossdtdt,jdbcType=TIMESTAMP},
            </if>
            <if test="canceldt != null">
                #{canceldt,jdbcType=TIMESTAMP},
            </if>
            <if test="unlockdt != null">
                #{unlockdt,jdbcType=TIMESTAMP},
            </if>
            <if test="reversaldt != null">
                #{reversaldt,jdbcType=TIMESTAMP},
            </if>
            <if test="refunddt != null">
                #{refunddt,jdbcType=TIMESTAMP},
            </if>
            <if test="consumedt != null">
                #{consumedt,jdbcType=TIMESTAMP},
            </if>
            <if test="lastoper != null">
                #{lastoper,jdbcType=TINYINT},
            </if>
            <if test="remarks != null">
                #{remarks,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
        <!--@mbg.generated-->
        update se_client_card
        <set>
            <if test="protocol != null">
                protocol = #{protocol,jdbcType=VARCHAR},
            </if>
            <if test="cardaddr != null">
                cardAddr = #{cardaddr,jdbcType=VARCHAR},
            </if>
            <if test="cardnum != null">
                cardNum = #{cardnum,jdbcType=BIGINT},
            </if>
            <if test="clientid != null">
                clientId = #{clientid,jdbcType=BIGINT},
            </if>
            <if test="money != null">
                money = #{money,jdbcType=FLOAT},
            </if>
            <if test="state != null">
                `state` = #{state,jdbcType=TINYINT},
            </if>
            <if test="originalCardId != null">
                `original_card_id` = #{originalCardId,jdbcType=BIGINT},
            </if>
            <if test="createdt != null">
                createDt = #{createdt,jdbcType=TIMESTAMP},
            </if>
            <if test="replacedt != null">
                replaceDt = #{replacedt,jdbcType=TIMESTAMP},
            </if>
            <if test="rechargedt != null">
                rechargeDt = #{rechargedt,jdbcType=TIMESTAMP},
            </if>
            <if test="lossdtdt != null">
                lossDtDt = #{lossdtdt,jdbcType=TIMESTAMP},
            </if>
            <if test="canceldt != null">
                cancelDt = #{canceldt,jdbcType=TIMESTAMP},
            </if>
            <if test="unlockdt != null">
                unlockDt = #{unlockdt,jdbcType=TIMESTAMP},
            </if>
            <if test="reversaldt != null">
                reversalDt = #{reversaldt,jdbcType=TIMESTAMP},
            </if>
            <if test="refunddt != null">
                refundDt = #{refunddt,jdbcType=TIMESTAMP},
            </if>
            <if test="consumedt != null">
                consumeDt = #{consumedt,jdbcType=TIMESTAMP},
            </if>
            <if test="lastoper != null">
                lastOper = #{lastoper,jdbcType=TINYINT},
            </if>
            <if test="remarks != null">
                remarks = #{remarks,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
        <!--@mbg.generated-->
        update se_client_card
        set protocol         = #{protocol,jdbcType=VARCHAR},
            cardAddr         = #{cardaddr,jdbcType=VARCHAR},
            cardNum          = #{cardnum,jdbcType=BIGINT},
            clientId         = #{clientid,jdbcType=BIGINT},
            money            = #{money,jdbcType=FLOAT},
            `state`          = #{state,jdbcType=TINYINT},
            original_card_id = #{originalCardId,jdbcType=BIGINT},
            createDt         = #{createdt,jdbcType=TIMESTAMP},
            replaceDt        = #{replacedt,jdbcType=TIMESTAMP},
            rechargeDt       = #{rechargedt,jdbcType=TIMESTAMP},
            lossDtDt         = #{lossdtdt,jdbcType=TIMESTAMP},
            cancelDt         = #{canceldt,jdbcType=TIMESTAMP},
            unlockDt         = #{unlockdt,jdbcType=TIMESTAMP},
            reversalDt       = #{reversaldt,jdbcType=TIMESTAMP},
            refundDt         = #{refunddt,jdbcType=TIMESTAMP},
            consumeDt        = #{consumedt,jdbcType=TIMESTAMP},
            lastOper         = #{lastoper,jdbcType=TINYINT},
            remarks          = #{remarks,jdbcType=VARCHAR}
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateMoney">
        update se_client_card
        set money = #{money,jdbcType=FLOAT}
        where id = #{id,jdbcType=BIGINT}
    </update>
    <!--根据农户主键获取水卡列表(物理卡+虚拟卡)-->
    <select id="getCardInfoByClientId" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo">
        SELECT *
        FROM (SELECT '物理卡'        AS cardType,
                     card.cardNum AS cardNum,
                     card.money   AS money,
                     (CASE
                          WHEN card.state = 1 THEN '正常'
                          WHEN card.state = 2 THEN '已注销'
                          ELSE '已挂失'
                         END)     AS state
              FROM se_client_card card
                       INNER JOIN se_client cli ON cli.id = card.clientId
              WHERE card.clientId = #{clientId,jdbcType=BIGINT}
              UNION ALL
              SELECT '虚拟卡'     AS cardType,
                     vc.vc_num AS cardNum,
                     vc.money  AS money,
                     (CASE
                          WHEN vc.in_use = 0 THEN '未使用'
                          WHEN vc.in_use = 1 THEN '使用中'
                         END)  AS state
              FROM se_virtual_card vc
                       INNER JOIN se_client cli ON cli.id = vc.client_id
              WHERE vc.client_id = #{clientId,jdbcType=BIGINT}
        <!--              SELECT '虚拟卡'              AS cardType,-->
        <!--                     virtualCard.vc_num AS CardNum,-->
        <!--                     virtualCard.money  AS vcMoney,-->
        <!--                     (CASE-->
        <!--                          WHEN virtualCard.in_use = 0 THEN '未使用'-->
        <!--                          WHEN virtualCard.in_use = 1 THEN '使用中'-->
        <!--                         END)           AS State-->
        <!--              FROM se_client client-->
        <!--                       LEFT JOIN se_virtual_card virtualCard ON client.id = virtualCard.client_id-->
        <!--              WHERE client.id = #{clientId,jdbcType=BIGINT}-->
        ) card
        ORDER BY card.Money DESC, card.State DESC
    </select>
    <!--根据水卡编号获取操作记录列表-->
    <select id="getOperateRecordsByCardNum" resultType="java.util.HashMap">
        SELECT *
        FROM v_operate
        WHERE cardNum = #{cardNum,jdbcType=BIGINT}
    </select>
    <!--根据水卡编号获取余额-->
    <select id="getMoneyByCardNum" resultType="java.lang.Float">
        SELECT money
        FROM se_client_card
        WHERE cardNum = #{cardNum,jdbcType=BIGINT}
    </select>
    <!--根据水卡编号获取充值总额-->
    <select id="sumRechargeByCardNum" resultType="java.lang.Float">
        SELECT SUM(his.amount) AS amount
        FROM se_recharge_history his
                 INNER JOIN se_client_card card ON his.cardId = card.id
        WHERE card.cardNum = #{cardNum,jdbcType=BIGINT}
    </select>
    <!--根据水卡编号获取卡片状态:1-开卡,2-补卡,3-充值,4-挂失,5-注销,6-解锁,7-冲正,8-消费-->
    <select id="getCardStateByCardNum" resultType="java.lang.String">
        <!--    SELECT-->
        <!--      (CASE-->
        <!--         WHEN lastOper = 1 THEN "开卡"-->
        <!--         WHEN lastOper = 2 THEN "补卡"-->
        <!--         WHEN lastOper = 3 THEN "充值"-->
        <!--         WHEN lastOper = 4 THEN "挂失"-->
        <!--         WHEN lastOper = 5 THEN "注销"-->
        <!--         WHEN lastOper = 6 THEN "解锁"-->
        <!--         WHEN lastOper = 7 THEN "冲正"-->
        <!--         WHEN lastOper = 8 THEN "消费"-->
        <!--        END) AS stateName-->
        <!--    FROM se_client_card-->
        <!--    WHERE cardNum = ${cardNum}-->
        SELECT (CASE
                    WHEN state = 1 THEN '正常'
                    WHEN state = 2 THEN '已注销'
                    WHEN state = 3 THEN '已挂失'
            END) AS stateName
        FROM se_client_card
        WHERE cardNum = #{cardNum,jdbcType=BIGINT}
    </select>
    <!--根据指定条件获取水卡列表记录数,应用程序使用-->
    <select id="getCardsCount" parameterType="java.util.Map" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        <where>
            AND card.state = 1
            <if test="clientNum != null and clientNum != ''">
                AND cli.clientNum like CONCAT('%', #{clientNum}, '%')
            </if>
            <if test="clientName != null and clientName != ''">
                AND cli.name like CONCAT('%', #{clientName}, '%')
            </if>
            <if test="cardNum != null and cardNum != ''">
                AND card.cardNum like CONCAT('%', #{cardNum}, '%')
            </if>
        </where>
    </select>
    <!--根据指定条件获取水卡列表,应用程序使用-->
    <select id="getCards" resultType="com.dy.pipIrrGlobal.voSe.VoCards">
        SELECT cli.clientNum,
               cli.name AS clientName,
               cardNum,
        <!--        CASE-->
        <!--            WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))-->
        <!--            ELSE card.cardNum-->
        <!--        END AS cardNum,-->
        cli.phone,
        cli.idCard,
        card.state AS cardState,
        <!--        (CASE-->
        <!--            WHEN card.state = 1 THEN '正常'-->
        <!--            WHEN card.state = 2 THEN '已注销'-->
        <!--            WHEN card.state = 3 THEN '已挂失'-->
        <!--        End) AS stateName,-->
        '正常'                  AS stateName,
        '农户卡'                 AS cardType,
        FORMAT(card.money, 2) AS money
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        <where>
            AND card.state = 1
            <if test="clientNum != null and clientNum != ''">
                AND cli.clientNum like CONCAT('%', #{clientNum}, '%')
            </if>
            <if test="clientName != null and clientName != ''">
                AND cli.name like CONCAT('%', #{clientName}, '%')
            </if>
            <if test="cardNum != null and cardNum != ''">
                AND card.cardNum like CONCAT('%', #{cardNum}, '%')
            </if>
        </where>
        ORDER BY card.id
        <trim prefix="limit ">
            <if test="start != null and count != null">
                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
            </if>
        </trim>
    </select>
    <!--获取已挂失未补卡的记录数量-->
    <select id="getUnreplacedRecordCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        WHERE card.state = 3
          AND NOT EXISTS(SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.cardNum)
    </select>
    <!--获取已挂失未补卡的记录-->
    <select id="getUnreplaced" resultType="com.dy.pipIrrGlobal.voSe.VoCards">
        SELECT cli.clientNum,
               cli.name AS clientName,
               cardNum,
        <!--        CASE-->
        <!--          WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))-->
        <!--          ELSE card.cardNum-->
        <!--        END AS cardNum,-->
        cli.phone,
        cli.idCard,
        card.state            AS cardState,
        '已挂失'                 AS stateName,
        '农户卡'                 AS cardType,
        FORMAT(card.money, 2) AS money
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        WHERE card.state = 3
          AND NOT EXISTS(SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.id)
        ORDER BY card.id
        <trim prefix="limit ">
            <if test="start != null and count != null">
                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
            </if>
        </trim>
    </select>
    <!--根据指定水卡编号获取挂失事记录数量(补卡、解锁使用)-->
    <select id="getLostCount" resultType="java.lang.Integer">
        SELECT COUNT(*) AS recordCount
        FROM se_client_card card
        <where>
            AND card.state = 3
            <if test="cardNum != null and cardNum > 0">
                AND card.cardNum = #{cardNum}
            </if>
        </where>
    </select>
    <!--根据指定水卡编号获取已补卡数量(补卡、解锁使用)-->
    <select id="getReplacedCount" resultType="java.lang.Integer">
        SELECT COUNT(*) AS recordCount
        FROM se_client_card card
                 INNER JOIN se_client_card card2 ON card2.original_card_id = card.id
        <where>
            <if test="cardNum != null and cardNum > 0">
                AND card.cardNum = #{cardNum}
            </if>
        </where>
    </select>
    <!--根据农户姓名和手机号获取水卡列表记录数,应用程序使用-->
    <select id="getCardsByClientNameAndPhoneCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        <where>
            card.state = 1
            <if test="clientName != null and clientName != ''">
                AND cli.name like CONCAT('%', #{clientName}, '%')
            </if>
            <if test="phone != null and phone != ''">
                AND cli.phone like CONCAT('%', #{phone}, '%')
            </if>
        </where>
    </select>
    <!--根据农户姓名和手机号获取水卡列表,应用程序使用-->
    <select id="getCardsByClientNameAndPhone" resultType="com.dy.pipIrrGlobal.voSe.VoCards2">
        SELECT card.id               AS clientCardId,
               cli.id                AS clientId,
               cli.clientNum,
               cli.name              AS clientName,
               card.cardNum,
               cli.phone,
               cli.idCard,
               card.state            AS cardState,
               (CASE
                    WHEN card.state = 1 THEN '正常'
                    WHEN card.state = 2 THEN '已注销'
                    WHEN card.state = 3 THEN '已挂失'
                   End)              AS stateName,
               '农户卡'                 AS cardType,
               FORMAT(card.money, 2) AS money
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        <where>
            card.state = 1
            <if test="clientName != null and clientName != ''">
                AND cli.name like CONCAT('%', #{clientName}, '%')
            </if>
            <if test="phone != null and phone != ''">
                AND cli.phone like CONCAT('%', #{phone}, '%')
            </if>
        </where>
        ORDER BY card.id
        <trim prefix="limit ">
            <if test="start != null and count != null">
                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
            </if>
        </trim>
    </select>
    <!--根据农户ID查询正常状态的水卡列表,小程序使用-->
    <select id="getCardsByClientID" resultType="com.dy.pipIrrGlobal.voWe.VoCards3">
        SELECT card.id               AS clientCardId,
               cli.id                AS clientId,
               cli.clientNum,
               cli.name              AS clientName,
               card.cardNum,
               cli.phone,
               cli.idCard,
               card.state            AS cardState,
               (CASE
                    WHEN card.state = 1 THEN '正常'
                    WHEN card.state = 2 THEN '已注销'
                    WHEN card.state = 3 THEN '已挂失'
                   End)              AS stateName,
               '农户卡'                 AS cardType,
               FORMAT(card.money, 2) AS money
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        where card.state = 1
          AND cli.id like CONCAT('%', #{clientId}, '%')
        ORDER BY card.id
    </select>
    <!--当前余额总量(物理卡)-->
    <select id="getTotalMoneyIcCards" resultType="java.lang.Double">
        SELECT IFNULL(SUM(money), 0) AS totalMoney
        FROM `se_client_card`
        WHERE state = 1
    </select>
    <!--根据水卡地址获取水卡数量-->
    <select id="getCountByCardAddr" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client_card
        WHERE cardAddr = #{cardAddr}
    </select>
    <!--根据水卡地址获取指定状态的水卡数量-->
    <select id="getCountByCardAddrAndState" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client_card
        WHERE cardAddr = #{cardAddr}
          AND state IN (1, 3)
    </select>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/PipIrrBaseApplication.java
@@ -18,7 +18,7 @@
                })
        }
)
@MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa","com.dy.pipIrrGlobal.daoSe","com.dy.pipIrrGlobal.daoRm"})
@MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa","com.dy.pipIrrGlobal.daoSe","com.dy.pipIrrGlobal.daoRm","com.dy.pipIrrGlobal.daoPr"})
public class PipIrrBaseApplication {
    public static void main(String[] args) {
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/dict/DictCtrl.java
@@ -4,6 +4,7 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.voBa.VoDictItem;
import com.dy.pipIrrGlobal.voBa.VoMapCenter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,4 +41,25 @@
        return BaseResponseUtils.buildSuccess(dictSv.getDictItemsByDictCode(dictCode));
    }
    /**
     * 根据配置项名称获取配置项值
     * @param itemName
     * @return
     */
    @GetMapping(path = "setting")
    @SsoAop()
    public BaseResponse<String> getSettingValue(String itemName) {
        return BaseResponseUtils.buildSuccess(dictSv.getItemValue(itemName));
    }
    /**
     * 获取地图中心坐标
     * @return
     */
    @GetMapping(path = "map_center")
    @SsoAop
    public BaseResponse<VoMapCenter> getMapCenter() {
        return BaseResponseUtils.buildSuccess(dictSv.getMapCenter());
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/dict/DictSv.java
@@ -1,11 +1,14 @@
package com.dy.pipIrrBase.dict;
import com.dy.pipIrrGlobal.daoBa.BaDictItemMapper;
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.voBa.VoDictItem;
import com.dy.pipIrrGlobal.voBa.VoMapCenter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -23,6 +26,9 @@
    @Autowired
    private BaDictItemMapper dictItemMapper;
    @Autowired
    private BaSettingsMapper baSettingsMapper;
    /**
     * 根据字典Code获取字典项
     * @param dictCode
@@ -32,4 +38,27 @@
        List<VoDictItem> rs = Optional.ofNullable(dictItemMapper.getDictItemsByDictCode(dictCode)).orElse(new ArrayList<>());
        return rs ;
    }
    /**
     * 根据配置项名称获取配置项值
     * @param itemName
     * @return
     */
    public String getItemValue(String itemName) {
        return baSettingsMapper.getItemValue(itemName);
    }
    /**
     * 获取地图中心坐标
     * @return
     */
    public VoMapCenter getMapCenter() {
        BigDecimal lat = new BigDecimal(baSettingsMapper.getItemValue("lat"));
        BigDecimal lng = new BigDecimal(baSettingsMapper.getItemValue("lng"));
        VoMapCenter po = new VoMapCenter();
        po.setLat(lat);
        po.setLng(lng);
        return po;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
@@ -9,9 +9,11 @@
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrBase.district.qo.DistrictQO;
import com.dy.pipIrrGlobal.pojoBa.BaClient;
import com.dy.pipIrrGlobal.pojoBa.BaDistrict;
import com.dy.pipIrrGlobal.util.DistrictLevel;
import com.dy.pipIrrGlobal.voBa.VoDistrict;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -324,4 +326,29 @@
        //return BaseResponseUtils.buildSuccess();
    }
    /**
     * 根据区划代码查询指定级别行政区划
     * @param qo
     * @return
     */
    @GetMapping(path = "/districts")
    @SsoAop()
    public BaseResponse<List<VoDistrict>> getDistrictS(DistrictQO qo) {
        String aredCode = qo.getAredCode();
        Integer level = qo.getLevel();
        if((aredCode.trim().length() == 6 && level == 4) || (aredCode.trim().length() == 9 && level == 5)) {
            try {
                return BaseResponseUtils.buildSuccess(sv.getDistrictS(qo));
            } catch (Exception e) {
                log.error("获取开卡记录异常", e);
                return BaseResponseUtils.buildException(e.getMessage());
            }
        }else {
            return BaseResponseUtils.buildErrorMsg("行政区划位数与级别不匹配");
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java
@@ -1,8 +1,11 @@
package com.dy.pipIrrBase.district;
import com.dy.pipIrrBase.district.qo.DistrictQO;
import com.dy.pipIrrGlobal.daoBa.AreaCode2023Mapper;
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.pojoBa.BaDistrict;
import com.dy.pipIrrGlobal.util.DistrictLevel;
import com.dy.pipIrrGlobal.voBa.VoDistrict;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -16,10 +19,16 @@
public class DistrictSv {
    private BaDistrictMapper dao;
    private AreaCode2023Mapper areaCode2023Dao;
    @Autowired
    private void setDao(BaDistrictMapper dao){
        this.dao = dao;
    }
    @Autowired
    private void setDao(AreaCode2023Mapper areaCode2023Dao){
        this.areaCode2023Dao = areaCode2023Dao;
    }
    /**
@@ -117,4 +126,13 @@
    public List<Map<String, Object>> getDistrictsBySupperId(Long supperId) {
        return dao.getDistrictsBySupperId(supperId);
    }
    /**
     * 根据区划代码查询指定级别行政区划
     * @param qo
     * @return
     */
    public List<VoDistrict> getDistrictS(DistrictQO qo) {
        return areaCode2023Dao.getDistrictS(qo.getAredCode(), qo.getLevel());
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/qo/DistrictQO.java
New file
@@ -0,0 +1,21 @@
package com.dy.pipIrrBase.district.qo;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * @author ZhuBaoMin
 * @date 2024-08-30 16:28
 * @LastEditTime 2024-08-30 16:28
 * @Description
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class DistrictQO {
    private String aredCode;
    private Integer level;
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
@@ -5,15 +5,13 @@
import com.dy.common.mybatis.envm.Disabled;
import com.dy.common.util.ConfigXml4Springboot;
import com.dy.common.util.MD5;
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
import com.dy.pipIrrGlobal.daoBa.*;
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.pojoBa.*;
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 +41,9 @@
    private BaSettingsMapper settingsDao ;
    private SeWaterTypeMapper waterTypeDao ;
    private RmIrrigateProfileMapper rmIrrigateProfileDao;
    private PrWaterPriceMapper prWaterPriceDao;
    private BaDictMapper baDictDao;
    private BaDictItemMapper baDictItemDao;
    @Autowired
    public void setResourceLoader(ResourceLoader resourceLoader){
@@ -77,6 +78,21 @@
    @Autowired
    public void setRmIrrigateProfileDao(RmIrrigateProfileMapper rmIrrigateProfileDao) {
        this.rmIrrigateProfileDao = rmIrrigateProfileDao;
    }
    @Autowired
    public void setWaterPriceDao(PrWaterPriceMapper prWaterPriceDao) {
        this.prWaterPriceDao = prWaterPriceDao;
    }
    @Autowired
    public void setBaDictDao(BaDictMapper baDictDao) {
        this.baDictDao = baDictDao;
    }
    @Autowired
    public void setBaDictItemDao(BaDictItemMapper baDictItemDao) {
        this.baDictItemDao = baDictItemDao;
    }
    /**
@@ -178,13 +194,53 @@
                            if(configXml.existElement(doc, "config.orgs.org" + num + ".irrigateProfile")){
                                for(int i = 1 ; i < 10000; i++){
                                    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 defaultValue = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"defaultValue", 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);
                                        this.saveIrrigateProfile(orgTag, defaultValue, unit,sort,type);
                                    }else{
                                        break ;
                                    }
                                }
                            }
                        }
                        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 ;
                                    }
                                }
                            }
                        }
                        if(!this.existWaterPrice()){
                            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);
                            }
                        }
                        if(!this.existDict()){
                            if(configXml.existElement(doc, "config.orgs.org" + num + ".dictionaries.dict")){
                                String code = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict","code", null, false, null) ;
                                String title = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict","title", null, false, null) ;
                                String valueType = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict","valueType", null, false, null) ;
                                this.saveDicts(orgTag, code,title,valueType);
                                if(configXml.existElement(doc, "config.orgs.org" + num + ".dictionaries.dict.dictItem")){
                                    for(int i = 1 ; i < 10000; i++){
                                        if(configXml.existElement(doc, "config.orgs.org" + num + ".dictionaries.dict.dictItem.item" + i)){
                                            String dictCode = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict.dictItem.item" + i,"dictCode", null, false, null) ;
                                            String value = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict.dictItem.item" + i,"value", null, false, null) ;
                                            String name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict.dictItem.item" + i,"name", null, false, null) ;
                                            String status = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict.dictItem.item" + i,"status", null, false, null) ;
                                            String sort = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".dictionaries.dict.dictItem.item" + i,"sort", null, false, null) ;
                                            this.saveDictItems(orgTag,dictCode,value,name,status,sort);
                                        }else{
                                            break ;
                                        }
                                    }
                                }
                            }
@@ -238,7 +294,7 @@
     * @return 存在否
     */
    private boolean existWaterTypes(){
        Long total = this.waterTypeDao.selectCount(null) ;
        Long total = this.prWaterPriceDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
@@ -248,6 +304,24 @@
     */
    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) ;
    }
    /**
     * 数据库中是否存在字典
     * @return
     */
    private boolean existDict() {
        Long total = this.baDictDao.selectCount(null);
        return (total != null && total > 0) ;
    }
@@ -366,8 +440,73 @@
            po.setUnit(Byte.valueOf(unit));
            po.setSort(Integer.parseInt(sort));
            po.setType(Byte.valueOf(type));
            po.setDeleted(0L);
            this.rmIrrigateProfileDao.insert(po);
        }
    }
    /**
     * 保存水价
     * @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);
        }
    }
    /**
     * 保存字典
     * @param orgTag
     * @param code
     * @param title
     * @param valueType
     * @return
     */
    private void saveDicts(String orgTag, String code, String title, String valueType) {
        if((code != null && !code.trim().equals("")) &&
                (title != null && !title.trim().equals("")) &&
                (valueType != null && !valueType.trim().equals(""))) {
            BaDict po = new BaDict();
            po.setCode(code);
            po.setTitle(title);
            po.setValueType(Byte.valueOf(valueType));
            po.setHashCode("c4ca4238a0b923820dcc509a6f75849b");
            po.setDeleted(0L);
            this.baDictDao.insert(po);
        }
    }
    /**
     * 保存字典项
     * @param orgTag
     * @param dictCode
     * @param value
     * @param name
     * @param status
     * @param sort
     */
    private void saveDictItems(String orgTag, String dictCode, String value, String name, String status, String sort) {
        if((dictCode != null && !dictCode.trim().equals("")) &&
                (value != null && !value.trim().equals("")) &&
                (name != null && !name.trim().equals("")) &&
                (status != null && !status.trim().equals("")) &&
                (sort != null && !sort.trim().equals(""))) {
            BaDictItem po = new BaDictItem();
            po.setDictCode(dictCode);
            po.setValue(value);
            po.setName(name);
            po.setStatus(Byte.valueOf(status));
            po.setSort(Integer.parseInt(sort));
            po.setDeleted(0L);
            this.baDictItemDao.insert(po);
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
@@ -67,12 +67,13 @@
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(QueryVo vo){
        try {
            QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo);
            if(res.itemTotal != null && res.itemTotal > 0) {
                return BaseResponseUtils.buildSuccess(res);
            }else {
                return BaseResponseUtils.buildSuccess(ProjectResultCode.NO_DIVIDES.getMessage());
            }
            //QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo);
            //if(res.itemTotal != null && res.itemTotal > 0) {
            //    return BaseResponseUtils.buildSuccess(res);
            //}else {
            //    return BaseResponseUtils.buildSuccess(ProjectResultCode.NO_DIVIDES.getMessage());
            //}
            return BaseResponseUtils.buildSuccess(divideSv.getDivides(vo));
        } catch (Exception e) {
            log.error("获取开卡记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java
@@ -76,6 +76,11 @@
            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        // 依据水卡地址判断该卡是否可以开卡,未开过卡或不是正常状态、挂失状态的可开卡
        if(!cardOperateSv.canActiveCard(po.getCardAddr())) {
            return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_CARD_ESIST.getMessage());
        }
        Long clientId = po.getClientId();
        // 获取5级行政区划串areaCode
@@ -153,7 +158,13 @@
        seCardOperate.setMoney(0f);
        seCardOperate.setCardCost(cardCost);
        seCardOperate.setPaymentId(paymentId);
        seCardOperate.setOperateType(OperateTypeENUM.ACTIVE.getCode());
        if(originalCardId != null) {
            // 补卡
            seCardOperate.setOperateType(OperateTypeENUM.REISSUE.getCode());
        }else {
            // 开新卡
            seCardOperate.setOperateType(OperateTypeENUM.ACTIVE.getCode());
        }
        seCardOperate.setRemarks(remarks);
        seCardOperate.setOperator(operator);
        seCardOperate.setOperateDt(activeTime);
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java
@@ -491,4 +491,26 @@
    public Double getTradeAmountByCardNo(Long cardNum) {
        return seCardOperateMapper.getTradeAmountByCardNo(cardNum);
    }
    /**
     * 根据水卡地址判断该卡是否可以开卡
     * @param cardAddr
     * @return
     */
    public Boolean canActiveCard(String cardAddr) {
        // 指定水卡地址的水卡数量
        Long cardCount = Optional.ofNullable(seClientCardMapper.getCountByCardAddr(cardAddr)).orElse(0L);
        if(cardCount == 0) {
           return true;
        }
        // 指定水卡地址且正常状态或挂失状态的水卡数量
        cardCount = Optional.ofNullable(seClientCardMapper.getCountByCardAddrAndState(cardAddr)).orElse(0L);
        if(cardCount == 0) {
            return true;
        }
        return false;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java
@@ -19,6 +19,7 @@
    AREA_CODE_MISTAKE(10001, "该农户行政区划异常"),
    CLIENT_NUM_ERROR(10001, "农户编号错误"),
    CARD_NUMBER_OVERRUN(10002, "水卡编号已满"),
    ACTIVE_FAIL_CARD_ESIST(10005, "开卡失败-此卡已存在"),
    ACTIVE_FAIL_WRITE_CLIENT_CARD_ERROR(10003, "开卡失败-农户卡写入异常"),
    ACTIVE_FAIL_WRITE_ACTIVE_CARD_ERROR(10004, "开卡失败-开卡记录写入异常"),
    ACTIVE_FAIL_RECHARGE_EXCEPTION(10005, "开卡失败-充值异常"),