<?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="mpPaymentRecordServiceDaoImpl">
|
|
|
<!-- 保存打印支取到账记录信息 add by wuxw 2018-07-03 -->
|
<insert id="saveMpPaymentRecordInfo" parameterType="Map">
|
insert into mp_payment_record(
|
mp_id, first_print_date, resolution_number, print_amount,
|
arrival_date, arrival_amount, withdrawer, shortage_or_arrears,
|
road_name, lane, `door`, room, owner_address, print_count, snake_case
|
) values (
|
#{mpId}, #{firstPrintDate}, #{resolutionNumber},
|
<if test="printAmount == null">0</if>
|
<if test="printAmount != null">#{printAmount}</if>,
|
#{arrivalDate},
|
<if test="arrivalAmount == null">0</if>
|
<if test="arrivalAmount != null">#{arrivalAmount}</if>,
|
#{withdrawer},
|
<if test="shortageOrArrears == null">0</if>
|
<if test="shortageOrArrears != null">#{shortageOrArrears}</if>,
|
#{roadName}, #{lane}, #{door}, #{room}, #{ownerAddress},
|
#{printCount}, #{snakeCase}
|
)
|
</insert>
|
|
<!-- 删除打印支取到账记录信息 -->
|
<delete id="deleteMpPaymentRecordInfo" parameterType="Map">
|
delete from mp_payment_record t
|
where 1 = 1
|
<!-- 支持按主键ID删除 -->
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<!-- 支持按mpId批量删除(可选条件) -->
|
<if test="mpId != null and mpId != ''">
|
and t.mp_id = #{mpId}
|
</if>
|
<!-- 支持按时间范围删除(可选条件) -->
|
<if test="startDate != null">
|
and t.first_print_date >= #{startDate}
|
</if>
|
<if test="endDate != null">
|
and t.first_print_date <= #{endDate}
|
</if>
|
<!-- 新增snake_case删除条件 -->
|
<if test="snakeCase != null and snakeCase != ''">
|
and t.snake_case = #{snakeCase}
|
</if>
|
</delete>
|
<!-- 查询打印支取到账记录信息 add by wuxw 2018-07-03 -->
|
<select id="getMpPaymentRecordInfo" parameterType="Map" resultType="Map">
|
select
|
t.mp_id,t.mp_id mpId,
|
t.first_print_date,t.first_print_date firstPrintDate,
|
t.resolution_number,t.resolution_number resolutionNumber,
|
t.print_amount,t.print_amount printAmount,
|
t.arrival_date,t.arrival_date arrivalDate,
|
t.arrival_amount,t.arrival_amount arrivalAmount,
|
t.withdrawer,
|
t.shortage_or_arrears,t.shortage_or_arrears shortageOrArrears,
|
t.road_name,t.road_name roadName,
|
t.lane,
|
t.`door`,
|
t.room,
|
t.owner_address,t.owner_address ownerAddress,
|
t.id,
|
t.print_count, t.print_count printCount,
|
t.snake_case, t.snake_case snakeCase <!-- 新增snake_case字段查询 -->
|
from mp_payment_record t
|
where 1 =1
|
<if test="mpId !=null and mpId != ''">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="firstPrintDate !=null">
|
and t.first_print_date = #{firstPrintDate}
|
</if>
|
<if test="resolutionNumber !=null and resolutionNumber != ''">
|
and t.resolution_number = #{resolutionNumber}
|
</if>
|
<if test="printAmount !=null">
|
and t.print_amount = #{printAmount}
|
</if>
|
<if test="arrivalDate !=null">
|
and t.arrival_date = #{arrivalDate}
|
</if>
|
<if test="arrivalAmount !=null">
|
and t.arrival_amount = #{arrivalAmount}
|
</if>
|
<if test="withdrawer !=null and withdrawer != ''">
|
and t.withdrawer = #{withdrawer}
|
</if>
|
<if test="shortageOrArrears !=null">
|
and t.shortage_or_arrears = #{shortageOrArrears}
|
</if>
|
<if test="roadName !=null and roadName != ''">
|
and t.road_name = #{roadName}
|
</if>
|
<if test="lane !=null and lane != ''">
|
and t.lane = #{lane}
|
</if>
|
<if test="door !=null and door != ''">
|
and t.door = #{door}
|
</if>
|
<if test="room !=null and room != ''">
|
and t.room = #{room}
|
</if>
|
<if test="ownerAddress !=null and ownerAddress != ''">
|
and t.owner_address = #{ownerAddress}
|
</if>
|
<if test="id !=null">
|
and t.id = #{id}
|
</if>
|
<!-- 新增printCount查询条件(字符串匹配) -->
|
<if test="printCount !=null and printCount != ''">
|
and t.print_count = #{printCount}
|
</if>
|
<!-- 新增snake_case查询条件 -->
|
<if test="snakeCase !=null and snakeCase != ''">
|
and t.snake_case = #{snakeCase}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startDate !=null">
|
and t.first_print_date >= #{startDate}
|
</if>
|
<if test="endDate !=null">
|
and t.first_print_date <= #{endDate}
|
</if>
|
<if test="startArrivalDate !=null">
|
and t.arrival_date >= #{startArrivalDate}
|
</if>
|
<if test="endArrivalDate !=null">
|
and t.arrival_date <= #{endArrivalDate}
|
</if>
|
order by t.id desc
|
<if test="page != -1 and page != null ">
|
limit #{page}, #{row}
|
</if>
|
|
</select>
|
|
|
<!-- 修改打印支取到账记录信息 add by wuxw 2018-07-03 -->
|
<update id="updateMpPaymentRecordInfo" parameterType="Map">
|
update mp_payment_record t set t.id = #{id}
|
<if test="newBId != null and newBId != ''">
|
,t.b_id = #{newBId}
|
</if>
|
<if test="mpId !=null and mpId != ''">
|
, t.mp_id = #{mpId}
|
</if>
|
<if test="firstPrintDate !=null">
|
, t.first_print_date = #{firstPrintDate}
|
</if>
|
<if test="resolutionNumber !=null and resolutionNumber != ''">
|
, t.resolution_number = #{resolutionNumber}
|
</if>
|
<if test="printAmount !=null">
|
, t.print_amount = #{printAmount}
|
</if>
|
<if test="arrivalDate !=null">
|
, t.arrival_date = #{arrivalDate}
|
</if>
|
<if test="arrivalAmount !=null">
|
, t.arrival_amount = #{arrivalAmount}
|
</if>
|
<if test="withdrawer !=null and withdrawer != ''">
|
, t.withdrawer = #{withdrawer}
|
</if>
|
<if test="shortageOrArrears !=null">
|
, t.shortage_or_arrears = #{shortageOrArrears}
|
</if>
|
<if test="roadName !=null and roadName != ''">
|
, t.road_name = #{roadName}
|
</if>
|
<if test="lane !=null and lane != ''">
|
, t.lane = #{lane}
|
</if>
|
<if test="door !=null and door != ''">
|
, t.door = #{door}
|
</if>
|
<if test="room !=null and room != ''">
|
, t.room = #{room}
|
</if>
|
<if test="ownerAddress !=null and ownerAddress != ''">
|
, t.owner_address = #{ownerAddress}
|
</if>
|
<!-- 新增printCount更新条件(字符串类型) -->
|
<if test="printCount !=null and printCount != ''">
|
, t.print_count = #{printCount}
|
</if>
|
<!-- 新增snake_case更新条件 -->
|
<if test="snakeCase !=null and snakeCase != ''">
|
, t.snake_case = #{snakeCase}
|
</if>
|
where 1=1
|
<if test="id !=null">
|
and t.id = #{id}
|
</if>
|
|
</update>
|
|
<!-- 查询打印支取到账记录数量 add by wuxw 2018-07-03 -->
|
<select id="queryMpPaymentRecordsCount" parameterType="Map" resultType="Map">
|
select count(1) count
|
from mp_payment_record t
|
where 1 =1
|
<if test="mpId !=null and mpId != ''">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="firstPrintDate !=null">
|
and t.first_print_date = #{firstPrintDate}
|
</if>
|
<if test="resolutionNumber !=null and resolutionNumber != ''">
|
and t.resolution_number = #{resolutionNumber}
|
</if>
|
<if test="printAmount !=null">
|
and t.print_amount = #{printAmount}
|
</if>
|
<if test="arrivalDate !=null">
|
and t.arrival_date = #{arrivalDate}
|
</if>
|
<if test="arrivalAmount !=null">
|
and t.arrival_amount = #{arrivalAmount}
|
</if>
|
<if test="withdrawer !=null and withdrawer != ''">
|
and t.withdrawer = #{withdrawer}
|
</if>
|
<if test="shortageOrArrears !=null">
|
and t.shortage_or_arrears = #{shortageOrArrears}
|
</if>
|
<if test="roadName !=null and roadName != ''">
|
and t.road_name = #{roadName}
|
</if>
|
<if test="lane !=null and lane != ''">
|
and t.lane = #{lane}
|
</if>
|
<if test="door !=null and door != ''">
|
and t.door = #{door}
|
</if>
|
<if test="room !=null and room != ''">
|
and t.room = #{room}
|
</if>
|
<if test="ownerAddress !=null and ownerAddress != ''">
|
and t.owner_address = #{ownerAddress}
|
</if>
|
<if test="id !=null">
|
and t.id = #{id}
|
</if>
|
<!-- 新增printCount查询条件(字符串匹配) -->
|
<if test="printCount !=null and printCount != ''">
|
and t.print_count = #{printCount}
|
</if>
|
<!-- 新增snake_case查询条件 -->
|
<if test="snakeCase !=null and snakeCase != ''">
|
and t.snake_case = #{snakeCase}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startDate !=null">
|
and t.first_print_date >= #{startDate}
|
</if>
|
<if test="endDate !=null">
|
and t.first_print_date <= #{endDate}
|
</if>
|
<if test="startArrivalDate !=null">
|
and t.arrival_date >= #{startArrivalDate}
|
</if>
|
<if test="endArrivalDate !=null">
|
and t.arrival_date <= #{endArrivalDate}
|
</if>
|
</select>
|
|
<!-- 批量插入打印支取到账记录 -->
|
<insert id="saveMpPaymentRecords" parameterType="Map">
|
insert into mp_payment_record(
|
mp_id, first_print_date, resolution_number, print_amount,
|
arrival_date, arrival_amount, withdrawer, shortage_or_arrears,
|
road_name, lane, `door`, room, owner_address, id, print_count, snake_case
|
) values
|
<foreach collection="mpPaymentRecordPos" item="item" separator=",">
|
( #{item.mpId}, #{item.firstPrintDate}, #{item.resolutionNumber},
|
<if test="item.printAmount == null">0</if><if test="item.printAmount != null">#{item.printAmount}</if>,
|
#{item.arrivalDate},
|
<if test="item.arrivalAmount == null">0</if><if test="item.arrivalAmount != null">#{item.arrivalAmount}</if>,
|
#{item.withdrawer},
|
<if test="item.shortageOrArrears == null">0</if><if test="item.shortageOrArrears != null">#{item.shortageOrArrears}</if>,
|
#{item.roadName}, #{item.lane}, #{item.door}, #{item.room}, #{item.ownerAddress}, #{id},
|
#{item.printCount}, #{item.snakeCase} <!-- 新增snake_case字段 -->
|
)
|
</foreach>
|
</insert>
|
|
<!-- 查询统计信息 -->
|
<select id="queryMpPaymentRecordStatistics" parameterType="Map" resultType="Map">
|
select
|
count(1) as total_count,
|
sum(t.print_amount) as total_print_amount,
|
sum(t.arrival_amount) as total_arrival_amount,
|
sum(t.shortage_or_arrears) as total_shortage,
|
avg(t.print_amount) as avg_print_amount,
|
avg(t.arrival_amount) as avg_arrival_amount,
|
min(t.first_print_date) as earliest_print_date,
|
max(t.first_print_date) as latest_print_date,
|
min(t.arrival_date) as earliest_arrival_date,
|
max(t.arrival_date) as latest_arrival_date
|
from mp_payment_record t
|
where 1 =1
|
<if test="mpId !=null and mpId != ''">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="startDate !=null">
|
and t.first_print_date >= #{startDate}
|
</if>
|
<if test="endDate !=null">
|
and t.first_print_date <= #{endDate}
|
</if>
|
<if test="startArrivalDate !=null">
|
and t.arrival_date >= #{startArrivalDate}
|
</if>
|
<if test="endArrivalDate !=null">
|
and t.arrival_date <= #{endArrivalDate}
|
</if>
|
<if test="withdrawer !=null and withdrawer != ''">
|
and t.withdrawer = #{withdrawer}
|
</if>
|
<if test="roadName !=null and roadName != ''">
|
and t.road_name = #{roadName}
|
</if>
|
<!-- 新增snake_case统计筛选条件 -->
|
<if test="snakeCase !=null and snakeCase != ''">
|
and t.snake_case = #{snakeCase}
|
</if>
|
</select>
|
|
<!-- 按月份分组统计 -->
|
<select id="queryMpPaymentRecordByMonth" parameterType="Map" resultType="Map">
|
select
|
date_format(t.first_print_date, '%Y-%m') as month,
|
count(1) as count,
|
sum(t.print_amount) as print_amount_sum,
|
sum(t.arrival_amount) as arrival_amount_sum,
|
sum(t.shortage_or_arrears) as shortage_sum
|
from mp_payment_record t
|
where 1 =1
|
<if test="mpId !=null and mpId != ''">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="startDate !=null">
|
and t.first_print_date >= #{startDate}
|
</if>
|
<if test="endDate !=null">
|
and t.first_print_date <= #{endDate}
|
</if>
|
<!-- 新增snake_case分组筛选条件 -->
|
<if test="snakeCase !=null and snakeCase != ''">
|
and t.snake_case = #{snakeCase}
|
</if>
|
group by date_format(t.first_print_date, '%Y-%m')
|
order by month desc
|
</select>
|
|
<!-- 按支取人分组统计 -->
|
<select id="queryMpPaymentRecordByWithdrawer" parameterType="Map" resultType="Map">
|
select
|
t.withdrawer,
|
count(1) as count,
|
sum(t.print_amount) as print_amount_sum,
|
sum(t.arrival_amount) as arrival_amount_sum,
|
sum(t.shortage_or_arrears) as shortage_sum
|
from mp_payment_record t
|
where 1 =1
|
<if test="mpId !=null and mpId != ''">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="startDate !=null">
|
and t.first_print_date >= #{startDate}
|
</if>
|
<if test="endDate !=null">
|
and t.first_print_date <= #{endDate}
|
</if>
|
<!-- 新增snake_case分组筛选条件 -->
|
<if test="snakeCase !=null and snakeCase != ''">
|
and t.snake_case = #{snakeCase}
|
</if>
|
group by t.withdrawer
|
order by print_amount_sum desc
|
</select>
|
|
</mapper>
|