| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- <?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.dk.mdm.mapper.mst.MoneyAccountMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- mac_id
- , mac_code, mac_name, mac_type, balance, display_no, flg_default, mac_receipt_code, acc_date, flg_negative, remarks, flg_valid, cp_id
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.MoneyAccount">
- <id column="mac_id" property="macId"/>
- <result column="mac_code" property="macCode"/>
- <result column="mac_name" property="macName"/>
- <result column="mac_type" property="macType" typeHandler="UuidTypeHandler"/>
- <result column="balance" property="balance"/>
- <result column="display_no" property="displayNo"/>
- <result column="flg_default" property="flgDefault"/>
- <result column="mac_receipt_code" property="macReceiptCode" typeHandler="JsonTypeHandler"/>
- <result column="acc_date" property="accDate"/>
- <result column="flg_negative" property="flgNegative"/>
- <result column="remarks" property="remarks"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- </resultMap>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mst.MoneyAccountResponse">
- <id column="mac_id" property="macId"/>
- <result column="mac_code" property="macCode"/>
- <result column="mac_name" property="macName"/>
- <result column="mac_type" property="macType" typeHandler="UuidTypeHandler"/>
- <result column="balance" property="balance"/>
- <result column="display_no" property="displayNo"/>
- <result column="flg_default" property="flgDefault"/>
- <result column="mac_receipt_code" property="macReceiptCode" typeHandler="JsonTypeHandler"/>
- <result column="acc_date" property="accDate"/>
- <result column="flg_negative" property="flgNegative"/>
- <result column="remarks" property="remarks"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="macTypeName" property="macTypeName"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="macCode != null and macCode != ''">
- AND t.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
- </if>
- <if test="macName != null and macName != ''">
- AND t.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
- </if>
- <if test="remarks != null and remarks != ''">
- AND t.remarks LIKE concat('%',my_ex.likequery(#{remarks}),'%')
- </if>
- <if test="cpId != null">
- AND t.cp_id = #{cpId}
- </if>
- <if test="flgValidList != null and flgValidList.size>0">
- AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
- </if>
- <if test="flgValid != null ">
- AND t.flg_valid = #{flgValid}
- </if>
- <if test="flgDefault != null ">
- AND t.flg_default = #{flgDefault}
- </if>
- <if test="macType != null">
- AND t.mac_Type = #{macType} ::uuid
- </if>
- <if test="macTypeList != null and macTypeList.size() > 0">
- AND t.mac_Type =any(#{macTypeList, typeHandler=UuidListTypeHandler})
- </if>
- </where>
- </sql>
- <!-- 查询表t_mst_money_account,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMapResponse">
- SELECT t.mac_id,
- <<<<<<< HEAD
- t.mac_code,
- t.mac_name,
- t.mac_Type,
- dd.data_value AS "macTypeName",
- t.balance,
- t.display_no,
- t.mac_receipt_code,
- t.acc_date,
- t.flg_negative,
- t.remarks,
- t.flg_valid,
- t.cp_id,
- coalesce(tmti.amt_trf, 0) as "initBalance"
- =======
- t.mac_code,
- t.mac_name,
- t.mac_Type,
- dd.data_value AS "macTypeName",
- t.balance,
- t.display_no,
- t.mac_receipt_code,
- t.acc_date,
- t.flg_negative,
- t.remarks,
- t.flg_valid,
- t.flg_default,
- t.cp_id,
- coalesce(tmti.amt_trf, 0) as "initBalance"
- >>>>>>> 83f9d270283aa09f581977351123c663d2d1f6a5
- FROM dkic_b.t_mst_money_account as t
- left join dkic_b.t_mst_dictionary_data as dd on t.mac_type = dd.data_id
- left join(select tmti.trf_in_mac, tmti.amt_trf
- from dkic_b.t_mac_transfer as tmt
- inner join dkic_b.t_mac_transfer_item as tmti
- on tmti.trf_id = tmt.trf_id and tmt.flg_valid
- and tmti.flg_valid and tmt.trf_type = 0) tmti
- on tmti.trf_in_mac = t.mac_id
- <include refid="Condition"/>
- order by t.display_no
- </select>
- <!-- 查询表t_mst_money_account,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT count(1)
- FROM dkic_b.t_mst_money_account as t
- <include refid="Condition"/>
- </select>
- <!-- 根据主键查询表t_mst_money_account的一行数据 -->
- <select id="selectById" resultMap="BaseResultMapResponse">
- SELECT t.mac_id,
- t.mac_code,
- t.mac_name,
- t.mac_Type,
- dd.data_value AS "macTypeName",
- t.balance,
- t.display_no,
- t.mac_receipt_code,
- t.acc_date,
- t.flg_negative,
- t.remarks,
- t.flg_valid,
- t.cp_id,
- coalesce(tmti.amt_trf, 0) as "initBalance",
- t.flg_default
- FROM dkic_b.t_mst_money_account as t
- left join dkic_b.t_mst_dictionary_data as dd on t.mac_type = dd.data_id
- left join(select tmti.trf_in_mac, tmti.amt_trf
- from dkic_b.t_mac_transfer as tmt
- inner join dkic_b.t_mac_transfer_item as tmti
- on tmti.trf_id = tmt.trf_id and tmt.flg_valid
- and tmti.flg_valid and tmt.trf_type = 0) tmti
- on tmti.trf_in_mac = t.mac_id
- WHERE t.mac_id = #{id}::uuid
- </select>
- <!-- 王英杰 2024年3月6日 微信小程序用 -->
- <select id="wxSelectByCond" resultType="java.util.Map">
- SELECT T
- .*
- FROM
- (
- SELECT
- tmdd.data_id AS "macId",
- null AS "macType",
- null AS "macCode",
- tmdd.data_value AS "macName",
- null AS "Remarks",
- 'true' AS "flgValid",
- null AS "macTypeName",
- null AS "macId",
- null AS "balance",
- null AS "displayNo",
- 'true' AS "flgNegative",
- tmdd.cp_id
- FROM
- dkic_b.t_mst_dictionary_data tmdd
- WHERE
- tmdd.cp_id = #{cpId} and
- tmdd.dict_code = '基础资料-账户' UNION ALL
- SELECT
- t.mac_id AS "macId",
- t.mac_Type as "macType",
- t.mac_code AS "macCode",
- t.mac_name AS "macName",
- t.remarks AS "Remarks",
- t.flg_valid AS "flgValid",
- dd.data_value AS "macTypeName",
- t.mac_id AS "macId",
- t.balance AS "balance",
- t.display_no AS "displayNo",
- t.flg_negative as "flgNegative",
- t.cp_id
- FROM
- dkic_b.t_mst_money_account as t
- LEFT JOIN dkic_b.t_mst_dictionary_data dd ON t.mac_type = dd.data_id
- <include refid="Condition"/>
- ) T
- <where>
- <if test="searchText !=null">
- AND T."macName" LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- </if>
- </where>
- </select>
- <!-- 王英杰 2024年3月6日 微信小程序用 -->
- <select id="wxCountByCond" resultType="Long">
- SELECT
- count(1)
- FROM
- (
- SELECT
- null AS "macType",
- tmdd.data_value AS "macCode",
- null AS "macName",
- null AS "Remarks",
- null AS "flgValid",
- null AS "macTypeName",
- null AS "macId",
- null AS "balance",
- null AS "displayNo"
- FROM
- dkic_b.t_mst_dictionary_data tmdd
- WHERE
- tmdd.dict_code = '账户类别' UNION ALL
- SELECT
- t.mac_Type as "macType",
- t.mac_code AS "macCode",
- t.mac_name AS "macName",
- t.remarks AS "Remarks",
- t.flg_valid AS "flgValid",
- dd.data_value AS "macTypeName",
- t.mac_id AS "macId",
- t.balance AS "balance",
- t.display_no AS "displayNo"
- FROM
- dkic_b.t_mst_money_account as t
- LEFT JOIN dkic_b.t_mst_dictionary_data dd ON t.mac_type = dd.data_id
- <include refid="Condition"/>
- ) T
- <where>
- <if test="searchText !=null">
- AND T."macName" LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- </if>
- </where>
- </select>
- <select id="selectDisplayNo" resultType="Integer">
- SELECT MAX(display_no) + 1
- FROM dkic_b.t_mst_money_account t
- WHERE t.cp_id = #{cpId}
- </select>
- <!-- 根据主键锁定表t_mst_money_account的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_b.t_mst_money_account
- WHERE mac_id = #{id}::uuid
- for update
- </select>
- <insert id="insertBatch">
- insert into dkic_b.t_mst_money_account
- (
- <trim suffixOverrides=",">
- mac_code,
- mac_name,
- mac_type,
- balance,
- display_no,
- flg_default,
- acc_date,
- flg_negative,
- remarks,
- cp_id,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.macCode},
- #{item.macName},
- #{item.macType} ::uuid,
- #{item.balance},
- #{item.displayNo},
- #{item.flgDefault},
- #{item.accDate},
- #{item.flgNegative},
- #{item.remarks},
- #{item.cpId},
- </trim>
- )
- </foreach>
- </insert>
- </mapper>
|