96 lines
4.9 KiB
XML
96 lines
4.9 KiB
XML
<?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.bms.ar.mapper.ArBillLogMapper">
|
|
<resultMap id="ArBillLogResult" type="ArBillLog">
|
|
<id property="logId" column="log_id"/>
|
|
<result property="arBillId" column="ar_bill_id"/>
|
|
<result property="objectType" column="object_type"/>
|
|
<result property="objectId" column="object_id"/>
|
|
<result property="objectDisplay" column="object_display"/>
|
|
<result property="operationType" column="operation_type"/>
|
|
<result property="operationDesc" column="operation_desc"/>
|
|
<result property="fromStatus" column="from_status"/>
|
|
<result property="toStatus" column="to_status"/>
|
|
<result property="beforeData" column="before_data"/>
|
|
<result property="afterData" column="after_data"/>
|
|
<result property="operatorId" column="operator_id"/>
|
|
<result property="operatorName" column="operator_name"/>
|
|
<result property="operationSource" column="operation_source"/>
|
|
<result property="requestId" column="request_id"/>
|
|
<result property="traceId" column="trace_id"/>
|
|
<result property="result" column="result"/>
|
|
<result property="errorMessage" column="error_message"/>
|
|
<result property="clientIp" column="client_ip"/>
|
|
<result property="createTime" column="create_time"/>
|
|
</resultMap>
|
|
|
|
<select id="selectList" resultMap="ArBillLogResult">
|
|
select l.log_id, l.ar_bill_id, l.object_type, l.object_id, l.operation_type, l.operation_desc,
|
|
case l.object_type
|
|
when 'BILL' then b.bill_no
|
|
when 'EXPORT' then coalesce(e.file_name, b.bill_no)
|
|
when 'BALANCE_WRITEOFF' then bw.writeoff_no
|
|
else null
|
|
end as object_display,
|
|
l.from_status, l.to_status, l.before_data, l.after_data, l.operator_id, l.operator_name,
|
|
l.operation_source, l.request_id, l.trace_id, l.result, l.error_message, l.client_ip, l.create_time
|
|
from ar_bill_log l
|
|
left join ar_bill b on b.ar_bill_id = l.ar_bill_id
|
|
left join ar_bill_detail_export e on e.export_id = case when l.object_type = 'EXPORT' then cast(l.object_id as
|
|
unsigned) end
|
|
left join ar_balance_writeoff bw on bw.writeoff_id = case when l.object_type = 'BALANCE_WRITEOFF' then
|
|
cast(l.object_id as unsigned) end
|
|
<where>
|
|
<if test="query.arBillId != null">and l.ar_bill_id = #{query.arBillId}</if>
|
|
<if test="query.objectType != null and query.objectType != ''">and l.object_type = #{query.objectType}</if>
|
|
<if test="query.objectId != null and query.objectId != ''">and l.object_id = #{query.objectId}</if>
|
|
<if test="query.operationType != null and query.operationType != ''">and l.operation_type = #{query.operationType}</if>
|
|
<if test="query.operationSource != null and query.operationSource != ''">and l.operation_source = #{query.operationSource}
|
|
</if>
|
|
<if test="query.requestId != null and query.requestId != ''">and l.request_id = #{query.requestId}</if>
|
|
<if test="query.result != null and query.result != ''">and l.result = #{query.result}</if>
|
|
<include refid="com.bms.ar.mapper.ArBillScopeMapper.billScope"/>
|
|
</where>
|
|
order by l.create_time desc, l.log_id desc
|
|
</select>
|
|
|
|
<select id="selectSuccessByRequestId" resultMap="ArBillLogResult">
|
|
select log_id,
|
|
ar_bill_id,
|
|
object_type,
|
|
object_id,
|
|
operation_type,
|
|
operation_desc,
|
|
from_status,
|
|
to_status,
|
|
before_data,
|
|
after_data,
|
|
operator_id,
|
|
operator_name,
|
|
operation_source,
|
|
request_id,
|
|
trace_id,
|
|
result,
|
|
error_message,
|
|
client_ip,
|
|
create_time
|
|
from ar_bill_log
|
|
where request_id = #{requestId}
|
|
and object_type = #{objectType}
|
|
and result = #{result}
|
|
order by log_id limit 1
|
|
</select>
|
|
|
|
<insert id="insert" parameterType="ArBillLog" useGeneratedKeys="true" keyProperty="logId">
|
|
insert into ar_bill_log (ar_bill_id, object_type, object_id, operation_type, operation_desc, from_status,
|
|
to_status,
|
|
before_data, after_data, operator_id, operator_name, operation_source, request_id,
|
|
trace_id, result, error_message, client_ip, create_time)
|
|
values (#{arBillId}, #{objectType}, #{objectId}, #{operationType}, #{operationDesc}, #{fromStatus}, #{toStatus},
|
|
#{beforeData}, #{afterData}, #{operatorId}, #{operatorName}, #{operationSource}, #{requestId},
|
|
#{traceId}, #{result}, #{errorMessage}, #{clientIp}, sysdate())
|
|
</insert>
|
|
</mapper>
|