| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- <?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.CompanyMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- cp_id, cp_code, cp_name, svc_code, opening_date, grade_code, end_date, max_staff_num, cur_staff_num, flg_valid, remarks, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user, owner, cp_manager, cp_phone, cp_size, shop_size, feedback,cp_status
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.Company">
- <id column="cp_id" property="cpId"/>
- <result column="cp_code" property="cpCode"/>
- <result column="cp_name" property="cpName"/>
- <result column="svc_code" property="svcCode"/>
- <result column="opening_date" property="openingDate" typeHandler="TimestampTypeHandler"/>
- <result column="grade_code" property="gradeCode"/>
- <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
- <result column="max_staff_num" property="maxStaffNum"/>
- <result column="cur_staff_num" property="curStaffNum"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="remarks" property="remarks"/>
- <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_app_code" property="opAppCode"/>
- <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
- <result column="op_db_user" property="opDbUser"/>
- <result column="owner" property="owner" typeHandler="UuidTypeHandler"/>
- <result column="cp_manager" property="cpManager"/>
- <result column="cp_phone" property="cpPhone"/>
- <result column="cp_size" property="cpSize"/>
- <result column="shop_size" property="shopSize"/>
- <result column="feedback" property="feedback"/>
- <result column="cpStatus" property="cpStatus"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="cpCode != null and cpCode != ''">
- AND cp_code = #{cpCode}
- </if>
- <if test="cpName != null and cpName != ''">
- AND cp_name = #{cpName}
- </if>
- <if test="svcCode != null and svcCode != ''">
- AND svc_code = #{svcCode}
- </if>
- <if test="openingDate != null">
- AND opening_date = #{openingDate}
- </if>
- <if test="gradeCode != null and gradeCode != ''">
- AND grade_code = #{gradeCode}
- </if>
- <if test="endDate != null">
- AND end_date = #{endDate}
- </if>
- <if test="maxStaffNum != null">
- AND max_staff_num = #{maxStaffNum}
- </if>
- <if test="curStaffNum != null">
- AND cur_staff_num = #{curStaffNum}
- </if>
- <if test="flgValid != null">
- AND flg_valid = #{flgValid}
- </if>
- <if test="remarks != null and remarks != ''">
- AND remarks = #{remarks}
- </if>
- <if test="opCreateTime != null">
- AND op_create_time = #{opCreateTime}
- </if>
- <if test="opCreateUserId != null and opCreateUserId != ''">
- AND op_create_user_id = #{opCreateUserId}
- </if>
- <if test="opUpdateTime != null">
- AND op_update_time = #{opUpdateTime}
- </if>
- <if test="opUpdateUserId != null and opUpdateUserId != ''">
- AND op_update_user_id = #{opUpdateUserId}
- </if>
- <if test="opAppCode != null and opAppCode != ''">
- AND op_app_code = #{opAppCode}
- </if>
- <if test="opTimestamp != null">
- AND op_timestamp = #{opTimestamp}
- </if>
- <if test="opDbUser != null and opDbUser != ''">
- AND op_db_user = #{opDbUser}
- </if>
- <if test="owner != null and owner != ''">
- AND owner = #{owner}
- </if>
- <if test="cpManager != null and cpManager != ''">
- AND cp_manager = #{cpManager}
- </if>
- <if test="cpPhone != null and cpPhone != ''">
- AND cp_phone = #{cpPhone}
- </if>
- <if test="cpSize != null and cpSize != ''">
- AND cp_size = #{cpSize}
- </if>
- <if test="shopSize != null and shopSize != ''">
- AND shop_size = #{shopSize}
- </if>
- <if test="feedback != null and feedback != ''">
- AND feedback = #{feedback}
- </if>
- </where>
- </sql>
- <sql id="Base_Column_List_list">
- tac.cp_id,
- tac.cp_code,
- tac.cp_name,
- tac.svc_code,
- tac.opening_date,
- tac.grade_code,
- tac.end_date,
- tac.max_staff_num,
- tac.cur_staff_num,
- tac.flg_valid,
- tac.remarks,
- tac.op_create_time,
- tac.op_create_user_id,
- tac.op_update_time,
- tac.op_update_user_id,
- tac.op_app_code,
- tac.op_timestamp,
- tac.op_db_user,
- tac.owner,
- tac.cp_manager,
- tac.cp_phone,
- tac.cp_size,
- tac.shop_size,
- tac.feedback,
- tac.cp_status,
- tac.license
- </sql>
- <resultMap id="BaseResultMap_list" type="com.dk.mdm.model.response.mst.CompanyResponse">
- <id column="cp_id" property="cpId"/>
- <result column="cp_code" property="cpCode"/>
- <result column="cp_name" property="cpName"/>
- <result column="svc_code" property="svcCode"/>
- <result column="opening_date" property="openingDate" typeHandler="TimestampTypeHandler"/>
- <result column="grade_code" property="gradeCode"/>
- <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
- <result column="max_staff_num" property="maxStaffNum"/>
- <result column="cur_staff_num" property="curStaffNum"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="remarks" property="remarks"/>
- <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_app_code" property="opAppCode"/>
- <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
- <result column="op_db_user" property="opDbUser"/>
- <result column="owner" property="owner" typeHandler="UuidTypeHandler"/>
- <result column="cp_manager" property="cpManager"/>
- <result column="cp_phone" property="cpPhone"/>
- <result column="cp_size" property="cpSize"/>
- <result column="shop_size" property="shopSize"/>
- <result column="feedback" property="feedback"/>
- <result column="cp_status" property="cpStatus"/>
- <result column="license" property="license"/>
- </resultMap>
- <sql id="Condition_list">
- <where>
- <if test="cpId != null and cpId != ''">
- AND tac.cp_id = #{cpId}
- </if>
- <if test="cpCode != null and cpCode != ''">
- AND tac.cp_code = #{cpCode}
- </if>
- <if test="cpName != null and cpName != ''">
- AND tac.cp_name LIKE concat('%',my_ex.likequery(#{cpName}),'%')
- </if>
- <if test="svcCode != null and svcCode != ''">
- AND tac.svc_code = #{svcCode}
- </if>
- <if test="openingDate != null">
- AND tac.opening_date = #{openingDate}
- </if>
- <if test="gradeCode != null and gradeCode != ''">
- AND tac.grade_code = #{gradeCode}
- </if>
- <if test="endDate != null">
- AND tac.end_date = #{endDate}
- </if>
- <if test="maxStaffNum != null">
- AND tac.max_staff_num = #{maxStaffNum}
- </if>
- <if test="curStaffNum != null">
- AND tac.cur_staff_num = #{curStaffNum}
- </if>
- <if test="flgValid != null">
- AND tac.flg_valid = #{flgValid}
- </if>
- <if test="remarks != null and remarks != ''">
- AND tac.remarks = #{remarks}
- </if>
- <if test="opCreateTime != null">
- AND tac.op_create_time = #{opCreateTime}
- </if>
- <if test="opCreateUserId != null and opCreateUserId != ''">
- AND tac.op_create_user_id = #{opCreateUserId}
- </if>
- <if test="opUpdateTime != null">
- AND tac.op_update_time = #{opUpdateTime}
- </if>
- <if test="opUpdateUserId != null and opUpdateUserId != ''">
- AND tac.op_update_user_id = #{opUpdateUserId}
- </if>
- <if test="opAppCode != null and opAppCode != ''">
- AND tac.op_app_code = #{opAppCode}
- </if>
- <if test="opTimestamp != null">
- AND tac.op_timestamp = #{opTimestamp}
- </if>
- <if test="opDbUser != null and opDbUser != ''">
- AND tac.op_db_user = #{opDbUser}
- </if>
- <if test="owner != null and owner != ''">
- AND tac.owner = #{owner}
- </if>
- <if test="cpManager != null and cpManager != ''">
- AND tac.cp_manager = #{cpManager}
- </if>
- <if test="cpPhone != null and cpPhone != ''">
- AND tac.cp_phone LIKE concat('%',my_ex.likequery(#{cpPhone}),'%')
- </if>
- <if test="cpSize != null and cpSize != ''">
- AND tac.cp_size = #{cpSize}
- </if>
- <if test="shopSize != null and shopSize != ''">
- AND tac.shop_size = #{shopSize}
- </if>
- <if test="feedback != null and feedback != ''">
- AND tac.feedback = #{feedback}
- </if>
- <if test="openingDateStart != null and openingDateEnd != null">
- AND tac.opening_date >= #{openingDateStart}::timestamp with time zone
- AND tac.opening_date < #{openingDateEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="endDateStart != null and endDateEnd != null">
- AND tac.end_date >= #{endDateStart}::timestamp with time zone
- AND tac.end_date < #{endDateEnd}::timestamp with time zone + interval '1 day'
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键cpId批量操作 -->
- WHERE cp_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表dkic_a.t_a_company,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMap_list">
- SELECT
- <include refid="Base_Column_List_list"/>
- ,tss.svc_ip
- ,tss.svc_port
- ,case when (select count(1) from dkic_a.t_mst_receipt tmr where tmr.receipt_status = '发票状态-申请' and tmr.cp_id = tac.cp_id) > 0
- then TRUE else false END as "invoicingFlag"
- FROM dkic_a.t_a_company tac
- left join dkic_a.t_s_service tss
- on tac.svc_code = tss.svc_code
- <include refid="Condition_list"/>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表dkic_a.t_a_company,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_a.t_a_company tac
- <include refid="Condition_list"/>
- </select>
- <!-- 根据主键锁定表dkic_a.t_a_company的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_a_company
- WHERE cp_id = #{cpId}
- for update
- </select>
- <!-- 根据主键锁定表dkic_a.t_a_company的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_a_company
- <include refid="idsForeach"/>
- for update
- </select>
- <insert id="insertBatch">
- insert into dkic_a.t_a_company
- (
- <trim suffixOverrides=",">
- cp_code,
- cp_name,
- svc_code,
- opening_date,
- grade_code,
- end_date,
- max_staff_num,
- cur_staff_num,
- remarks,
- op_app_code,
- owner,
- cp_manager,
- cp_phone,
- cp_size,
- shop_size,
- feedback,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.cpCode},
- #{item.cpName},
- #{item.svcCode},
- #{item.openingDate},
- #{item.gradeCode},
- #{item.endDate},
- #{item.maxStaffNum},
- #{item.curStaffNum},
- #{item.remarks},
- #{item.opAppCode},
- #{item.owner}::uuid,
- #{item.cpManager},
- #{item.cpPhone},
- #{item.cpSize},
- #{item.shopSize},
- #{item.feedback},
- </trim>
- )
- </foreach>
- </insert>
- <!-- 获取商户的地址服务 -->
- <select id="selectServiceAllot" resultType="String">
- SELECT dkic_a.f_allot_service(#{gradeCode})
- </select>
- <!-- 获取商户的IP地址和端口 -->
- <select id="selectIPAndPort" resultType="java.util.Map">
- SELECT ts.svc_ip ,
- ts.svc_port
- from dkic_a.t_s_service ts
- where ts.svc_code = #{svcCode}
- </select>
- <!--更新公司所有者-->
- <update id="updateOwners">
- update dkic_a.t_a_company set owner = #{userId}::uuid
- where cp_Id = #{cpId}
- </update>
- <!--责任人转让-->
- <update id="updateCpManager">
- update dkic_a.t_a_company
- set owner = #{userId}::uuid
- ,cp_manager = #{staffName}
- ,cp_phone = #{staffPhone}
- where cp_Id = #{cpId}
- </update>
- </mapper>
|