Merge branch 'master' of http://git.lionquexpress.com/wuweihua/BMS
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ar.mapper.ArBankAccountMapper">
|
||||
<resultMap id="ArBankAccountResult" type="ArBankAccount">
|
||||
<id property="bankAccountId" column="bank_account_id"/>
|
||||
@@ -19,12 +19,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDefaultByCurrency" resultMap="ArBankAccountResult">
|
||||
select bank_account_id, account_name, account_no, bank_name, currency,
|
||||
is_default, status, remark, create_by, create_time, update_by, update_time
|
||||
select bank_account_id,
|
||||
account_name,
|
||||
account_no,
|
||||
bank_name,
|
||||
currency,
|
||||
is_default,
|
||||
status,
|
||||
remark,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time
|
||||
from ar_bank_account
|
||||
where currency = #{currency}
|
||||
and status = '0'
|
||||
order by is_default desc, bank_account_id
|
||||
limit 1
|
||||
order by is_default desc, bank_account_id limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ar.mapper.ArBillDetailFeeMapper">
|
||||
<!-- 账单明细费用项读写;批量查询仅接收当前明细批次的 ID。 -->
|
||||
<resultMap id="ArBillDetailFeeResult" type="ArBillDetailFee">
|
||||
<id property="detailFeeId" column="detail_fee_id"/>
|
||||
<result property="detailId" column="detail_id"/>
|
||||
@@ -24,39 +25,116 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByDetailId" parameterType="long" resultMap="ArBillDetailFeeResult">
|
||||
select detail_fee_id, detail_id, prc_income_bill_fee_id, fee_no, fee_type, fee_name, sc_id, quantity,
|
||||
unit, unit_price, amount, currency, calculation_formula, round_mode, remark, create_by, create_time
|
||||
from ar_bill_detail_fee where detail_id = #{detailId} order by fee_no, detail_fee_id
|
||||
select detail_fee_id,
|
||||
detail_id,
|
||||
prc_income_bill_fee_id,
|
||||
fee_no,
|
||||
fee_type,
|
||||
fee_name,
|
||||
sc_id,
|
||||
quantity,
|
||||
unit,
|
||||
unit_price,
|
||||
amount,
|
||||
currency,
|
||||
calculation_formula,
|
||||
round_mode,
|
||||
remark,
|
||||
create_by,
|
||||
create_time
|
||||
from ar_bill_detail_fee
|
||||
where detail_id = #{detailId}
|
||||
order by fee_no, detail_fee_id
|
||||
</select>
|
||||
|
||||
<select id="selectByBillIdAndDetailId" resultMap="ArBillDetailFeeResult">
|
||||
select f.detail_fee_id,
|
||||
f.detail_id,
|
||||
f.prc_income_bill_fee_id,
|
||||
f.fee_no,
|
||||
f.fee_type,
|
||||
f.fee_name,
|
||||
f.sc_id,
|
||||
f.quantity,
|
||||
f.unit,
|
||||
f.unit_price,
|
||||
f.amount,
|
||||
f.currency,
|
||||
f.calculation_formula,
|
||||
f.round_mode,
|
||||
f.remark,
|
||||
f.create_by,
|
||||
f.create_time
|
||||
from ar_bill_detail_fee f
|
||||
inner join ar_bill_detail d on d.detail_id = f.detail_id
|
||||
where d.ar_bill_id = #{arBillId}
|
||||
and f.detail_id = #{detailId}
|
||||
order by f.fee_no, f.detail_fee_id
|
||||
</select>
|
||||
|
||||
<select id="selectByBillId" parameterType="long" resultMap="ArBillDetailFeeResult">
|
||||
select detail_fee_id, detail_id, prc_income_bill_fee_id, fee_no, fee_type, fee_name, sc_id, quantity,
|
||||
unit, unit_price, amount, currency, calculation_formula, round_mode, remark, create_by, create_time
|
||||
select detail_fee_id,
|
||||
detail_id,
|
||||
prc_income_bill_fee_id,
|
||||
fee_no,
|
||||
fee_type,
|
||||
fee_name,
|
||||
sc_id,
|
||||
quantity,
|
||||
unit,
|
||||
unit_price,
|
||||
amount,
|
||||
currency,
|
||||
calculation_formula,
|
||||
round_mode,
|
||||
remark,
|
||||
create_by,
|
||||
create_time
|
||||
from ar_bill_detail_fee
|
||||
where detail_id in (select detail_id from ar_bill_detail where ar_bill_id = #{arBillId})
|
||||
order by detail_id, fee_no, detail_fee_id
|
||||
</select>
|
||||
|
||||
<select id="selectByDetailIds" resultMap="ArBillDetailFeeResult">
|
||||
select detail_fee_id, detail_id, prc_income_bill_fee_id, fee_no, fee_type, fee_name, sc_id, quantity,
|
||||
unit, unit_price, amount, currency, calculation_formula, round_mode, remark, create_by, create_time
|
||||
from ar_bill_detail_fee
|
||||
where detail_id in
|
||||
<foreach collection="detailIds" item="detailId" open="(" separator="," close=")">
|
||||
#{detailId}
|
||||
</foreach>
|
||||
order by detail_id, fee_no, detail_fee_id
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ArBillDetailFee" useGeneratedKeys="true" keyProperty="detailFeeId">
|
||||
insert into ar_bill_detail_fee (
|
||||
detail_id, prc_income_bill_fee_id, fee_no, fee_type, fee_name, sc_id, quantity, unit, unit_price,
|
||||
amount, currency, calculation_formula, round_mode, remark, create_by, create_time
|
||||
) values (
|
||||
#{detailId}, #{prcIncomeBillFeeId}, #{feeNo}, #{feeType}, #{feeName}, #{scId}, #{quantity}, #{unit},
|
||||
#{unitPrice}, #{amount}, #{currency}, #{calculationFormula}, #{roundMode}, #{remark},
|
||||
#{createBy}, sysdate()
|
||||
)
|
||||
insert into ar_bill_detail_fee (detail_id, prc_income_bill_fee_id, fee_no, fee_type, fee_name, sc_id, quantity,
|
||||
unit, unit_price,
|
||||
amount, currency, calculation_formula, round_mode, remark, create_by,
|
||||
create_time)
|
||||
values (#{detailId}, #{prcIncomeBillFeeId}, #{feeNo}, #{feeType}, #{feeName}, #{scId}, #{quantity}, #{unit},
|
||||
#{unitPrice}, #{amount}, #{currency}, #{calculationFormula}, #{roundMode}, #{remark},
|
||||
#{createBy}, sysdate())
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="detailFeeId">
|
||||
insert into ar_bill_detail_fee (
|
||||
detail_id, prc_income_bill_fee_id, fee_no, fee_type, fee_name, sc_id, quantity, unit, unit_price,
|
||||
amount, currency, calculation_formula, round_mode, remark, create_by, create_time
|
||||
detail_id, prc_income_bill_fee_id, fee_no, fee_type, fee_name, sc_id, quantity, unit, unit_price,
|
||||
amount, currency, calculation_formula, round_mode, remark, create_by, create_time
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.detailId}, #{item.prcIncomeBillFeeId}, #{item.feeNo}, #{item.feeType}, #{item.feeName}, #{item.scId},
|
||||
#{item.quantity}, #{item.unit}, #{item.unitPrice}, #{item.amount}, #{item.currency},
|
||||
#{item.calculationFormula}, #{item.roundMode}, #{item.remark}, #{item.createBy}, sysdate())
|
||||
(#{item.detailId}, #{item.prcIncomeBillFeeId}, #{item.feeNo}, #{item.feeType}, #{item.feeName},
|
||||
#{item.scId},
|
||||
#{item.quantity}, #{item.unit}, #{item.unitPrice}, #{item.amount}, #{item.currency},
|
||||
#{item.calculationFormula}, #{item.roundMode}, #{item.remark}, #{item.createBy}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="long">
|
||||
delete
|
||||
f
|
||||
from ar_bill_detail_fee f
|
||||
inner join ar_bill_detail d on d.detail_id = f.detail_id
|
||||
where d.ar_bill_id =
|
||||
#{arBillId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ar.mapper.ArBillDetailMapper">
|
||||
<!-- 账单明细读写;详情页分页查询,导出任务按游标批量查询。 -->
|
||||
<resultMap id="ArBillDetailResult" type="ArBillDetail">
|
||||
<id property="detailId" column="detail_id"/>
|
||||
<result property="arBillId" column="ar_bill_id"/>
|
||||
@@ -38,6 +39,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from ar_bill_detail where ar_bill_id = #{arBillId} order by detail_no
|
||||
</select>
|
||||
|
||||
<select id="selectByBillIdAndSourceIds" resultMap="ArBillDetailResult">
|
||||
select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, receive_time,
|
||||
product_code, product_name, goods_description, country_code, country_name, dest_postcode,
|
||||
actual_weight, volume_weight, charge_weight, pkg_length, pkg_width, pkg_height,
|
||||
currency, total_amount, remark, create_by, create_time
|
||||
from ar_bill_detail
|
||||
where ar_bill_id = #{arBillId}
|
||||
and prc_order_bill_id in
|
||||
<foreach collection="sourceBillIds" item="sourceBillId" open="(" separator="," close=")">
|
||||
#{sourceBillId}
|
||||
</foreach>
|
||||
order by detail_no
|
||||
</select>
|
||||
|
||||
<resultMap id="ArBillDetailWithFeesResult" type="ArBillDetail" extends="ArBillDetailResult">
|
||||
<collection property="fees" ofType="ArBillDetailFee">
|
||||
<id property="detailFeeId" column="fee_detail_id"/>
|
||||
@@ -78,18 +93,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by d.detail_no, d.detail_id, f.fee_no, f.detail_fee_id
|
||||
</select>
|
||||
|
||||
<select id="selectExportPage" resultMap="ArBillDetailResult">
|
||||
select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, receive_time,
|
||||
product_code, product_name, goods_description, country_code, country_name, dest_postcode,
|
||||
actual_weight, volume_weight, charge_weight, pkg_length, pkg_width, pkg_height,
|
||||
currency, total_amount, remark, create_by, create_time
|
||||
from ar_bill_detail
|
||||
where ar_bill_id = #{arBillId} and detail_no > #{lastDetailNo}
|
||||
order by detail_no
|
||||
limit #{pageSize}
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ArBillDetail" useGeneratedKeys="true" keyProperty="detailId">
|
||||
insert into ar_bill_detail (
|
||||
ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, receive_time, product_code,
|
||||
product_name, goods_description, country_code, country_name, dest_postcode, actual_weight,
|
||||
volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, currency, total_amount,
|
||||
remark, create_by, create_time
|
||||
) values (
|
||||
#{arBillId}, #{prcOrderBillId}, #{detailNo}, #{orderNo}, #{trackingNo}, #{receiveTime},
|
||||
#{productCode}, #{productName}, #{goodsDescription}, #{countryCode}, #{countryName},
|
||||
#{destPostcode}, #{actualWeight}, #{volumeWeight}, #{chargeWeight}, #{pkgLength}, #{pkgWidth},
|
||||
#{pkgHeight}, #{currency}, #{totalAmount}, #{remark}, #{createBy}, sysdate()
|
||||
)
|
||||
insert into ar_bill_detail (ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, receive_time,
|
||||
product_code,
|
||||
product_name, goods_description, country_code, country_name, dest_postcode,
|
||||
actual_weight,
|
||||
volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, currency,
|
||||
total_amount,
|
||||
remark, create_by, create_time)
|
||||
values (#{arBillId}, #{prcOrderBillId}, #{detailNo}, #{orderNo}, #{trackingNo}, #{receiveTime},
|
||||
#{productCode}, #{productName}, #{goodsDescription}, #{countryCode}, #{countryName},
|
||||
#{destPostcode}, #{actualWeight}, #{volumeWeight}, #{chargeWeight}, #{pkgLength}, #{pkgWidth},
|
||||
#{pkgHeight}, #{currency}, #{totalAmount}, #{remark}, #{createBy}, sysdate())
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="detailId">
|
||||
@@ -107,4 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.currency}, #{item.totalAmount}, #{item.remark}, #{item.createBy}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="long">
|
||||
delete from ar_bill_detail where ar_bill_id = #{arBillId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ar.mapper.ArBillExportMapper">
|
||||
<!-- 导出任务和历史记录;PROCESSING/SUCCESS/FAILED 由异步执行器更新。 -->
|
||||
<resultMap id="ArBillExportResult" type="ArBillExport">
|
||||
<id property="exportId" column="export_id"/>
|
||||
<result property="arBillId" column="ar_bill_id"/>
|
||||
<result property="fileName" column="file_name"/>
|
||||
<result property="fileType" column="file_type"/>
|
||||
<result property="templateId" column="template_id"/>
|
||||
<result property="templateCode" column="template_code"/>
|
||||
<result property="templateVersion" column="template_version"/>
|
||||
<result property="templateStorageType" column="template_storage_type"/>
|
||||
<result property="templateStorageKey" column="template_storage_key"/>
|
||||
<result property="templateHash" column="template_hash"/>
|
||||
<result property="storageKey" column="storage_key"/>
|
||||
<result property="fileSize" column="file_size"/>
|
||||
<result property="fileHash" column="file_hash"/>
|
||||
@@ -21,8 +26,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectExportColumns">
|
||||
select export_id, ar_bill_id, file_name, file_type, template_code, template_version,
|
||||
storage_key, file_size, file_hash, row_count, export_status, export_by, export_time, remark
|
||||
select export_id,
|
||||
ar_bill_id,
|
||||
file_name,
|
||||
file_type,
|
||||
template_id,
|
||||
template_code,
|
||||
template_version,
|
||||
template_storage_type,
|
||||
template_storage_key,
|
||||
template_hash,
|
||||
storage_key,
|
||||
file_size,
|
||||
file_hash,
|
||||
row_count,
|
||||
export_status,
|
||||
export_by,
|
||||
export_time,
|
||||
remark
|
||||
from ar_bill_export
|
||||
</sql>
|
||||
|
||||
@@ -40,13 +61,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by export_time desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectProcessingByBillId" parameterType="long" resultMap="ArBillExportResult">
|
||||
<include refid="selectExportColumns"/>
|
||||
where ar_bill_id = #{arBillId} and export_status = 'PROCESSING'
|
||||
order by export_id desc limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ArBillExport" useGeneratedKeys="true" keyProperty="exportId">
|
||||
insert into ar_bill_export (
|
||||
ar_bill_id, file_name, file_type, template_code, template_version, storage_key,
|
||||
ar_bill_id, file_name, file_type, template_id, template_code, template_version,
|
||||
template_storage_type, template_storage_key, template_hash, storage_key,
|
||||
file_size, file_hash, row_count, export_status, export_by, export_time, remark
|
||||
) values (
|
||||
#{arBillId}, #{fileName}, #{fileType}, #{templateCode}, #{templateVersion}, #{storageKey},
|
||||
#{arBillId}, #{fileName}, #{fileType}, #{templateId}, #{templateCode}, #{templateVersion},
|
||||
#{templateStorageType}, #{templateStorageKey}, #{templateHash}, #{storageKey},
|
||||
#{fileSize}, #{fileHash}, #{rowCount}, #{exportStatus}, #{exportBy}, sysdate(), #{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="markSuccess" parameterType="ArBillExport">
|
||||
update ar_bill_export
|
||||
set storage_key = #{storageKey},
|
||||
file_size = #{fileSize},
|
||||
file_hash = #{fileHash},
|
||||
export_status = 'SUCCESS',
|
||||
remark = null
|
||||
where export_id = #{exportId} and export_status = 'PROCESSING'
|
||||
</update>
|
||||
|
||||
<update id="markFailed">
|
||||
update ar_bill_export
|
||||
set export_status = 'FAILED', remark = #{remark}
|
||||
where export_id = #{exportId} and export_status = 'PROCESSING'
|
||||
</update>
|
||||
|
||||
<update id="markExpiredProcessingAsFailed">
|
||||
update ar_bill_export
|
||||
set export_status = 'FAILED', remark = #{remark}
|
||||
where export_status = 'PROCESSING' and export_time < #{expiredBefore}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
<?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.ruoyi.ar.mapper.ArBillGenerateTaskMapper">
|
||||
<!-- 生成任务表是异步任务的持久化队列;状态更新均带前置状态条件,保证多节点抢占幂等。 -->
|
||||
<resultMap id="ArBillGenerateTaskResult" type="ArBillGenerateTask">
|
||||
<id property="taskId" column="task_id"/>
|
||||
<result property="taskNo" column="task_no"/>
|
||||
<result property="arBillId" column="ar_bill_id"/>
|
||||
<result property="selectionMode" column="selection_mode"/>
|
||||
<result property="requestPayload" column="request_payload"/>
|
||||
<result property="snapshotCreateTime" column="snapshot_create_time"/>
|
||||
<result property="lastSourceBillId" column="last_source_bill_id"/>
|
||||
<result property="totalCount" column="total_count"/>
|
||||
<result property="processedCount" column="processed_count"/>
|
||||
<result property="successCount" column="success_count"/>
|
||||
<result property="totalAmount" column="total_amount"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="errorMessage" column="error_message"/>
|
||||
<result property="requestToken" column="request_token"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="startedAt" column="started_at"/>
|
||||
<result property="heartbeatTime" column="heartbeat_time"/>
|
||||
<result property="finishedAt" column="finished_at"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="columns">
|
||||
select task_id,
|
||||
task_no,
|
||||
ar_bill_id,
|
||||
selection_mode,
|
||||
request_payload,
|
||||
snapshot_create_time,
|
||||
last_source_bill_id,
|
||||
total_count,
|
||||
processed_count,
|
||||
success_count,
|
||||
total_amount,
|
||||
status,
|
||||
error_message,
|
||||
request_token,
|
||||
create_by,
|
||||
create_time,
|
||||
started_at,
|
||||
heartbeat_time,
|
||||
finished_at
|
||||
from ar_bill_generate_task
|
||||
</sql>
|
||||
|
||||
<select id="selectById" parameterType="long" resultMap="ArBillGenerateTaskResult">
|
||||
<include refid="columns"/>
|
||||
where task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
<select id="selectByRequestToken" parameterType="string" resultMap="ArBillGenerateTaskResult">
|
||||
<include refid="columns"/>
|
||||
where request_token = #{requestToken}
|
||||
</select>
|
||||
|
||||
<!-- 前端恢复页面时查询当前用户仍需展示的任务。 -->
|
||||
<select id="selectActiveByCreateBy" resultMap="ArBillGenerateTaskResult">
|
||||
<include refid="columns"/>
|
||||
where create_by = #{createBy}
|
||||
and status in ('WAITING', 'RUNNING', 'CANCEL_REQUESTED')
|
||||
order by create_time desc, task_id desc
|
||||
</select>
|
||||
|
||||
<!-- 定时调度器按创建时间顺序取待处理任务。 -->
|
||||
<select id="selectWaiting" resultMap="ArBillGenerateTaskResult">
|
||||
<include refid="columns"/>
|
||||
where status = 'WAITING'
|
||||
order by create_time asc, task_id asc
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ArBillGenerateTask" useGeneratedKeys="true" keyProperty="taskId">
|
||||
insert into ar_bill_generate_task (task_no, ar_bill_id, selection_mode, request_payload, snapshot_create_time,
|
||||
last_source_bill_id, total_count, processed_count, success_count,
|
||||
total_amount,
|
||||
status, error_message, request_token, create_by, create_time, started_at,
|
||||
heartbeat_time, finished_at)
|
||||
values (#{taskNo}, #{arBillId}, #{selectionMode}, #{requestPayload}, #{snapshotCreateTime},
|
||||
#{lastSourceBillId}, #{totalCount}, #{processedCount}, #{successCount}, #{totalAmount},
|
||||
#{status}, #{errorMessage}, #{requestToken}, #{createBy}, sysdate(), #{startedAt},
|
||||
#{heartbeatTime}, #{finishedAt})
|
||||
</insert>
|
||||
|
||||
<!-- 条件更新抢占任务;返回 1 才表示当前节点真正拿到执行权。 -->
|
||||
<update id="markRunning">
|
||||
update ar_bill_generate_task
|
||||
set status = 'RUNNING',
|
||||
started_at = coalesce(started_at, #{startedAt}),
|
||||
heartbeat_time = #{startedAt}
|
||||
where task_id = #{taskId}
|
||||
and status = 'WAITING'
|
||||
</update>
|
||||
|
||||
<update id="updateTotalCount">
|
||||
update ar_bill_generate_task
|
||||
set total_count = #{totalCount},
|
||||
heartbeat_time = sysdate()
|
||||
where task_id = #{taskId}
|
||||
and status = 'RUNNING'
|
||||
</update>
|
||||
|
||||
<!-- 每批成功后写入游标、计数和心跳;游标用于故障恢复后继续扫描。 -->
|
||||
<update id="updateProgress">
|
||||
update ar_bill_generate_task
|
||||
set last_source_bill_id = #{lastSourceBillId},
|
||||
processed_count = #{processedCount},
|
||||
success_count = #{successCount},
|
||||
total_amount = #{totalAmount},
|
||||
heartbeat_time = #{heartbeatTime}
|
||||
where task_id = #{taskId}
|
||||
and status = 'RUNNING'
|
||||
</update>
|
||||
|
||||
<update id="markSuccess">
|
||||
update ar_bill_generate_task
|
||||
set status = 'SUCCESS',
|
||||
finished_at = #{finishedAt},
|
||||
heartbeat_time = #{finishedAt}
|
||||
where task_id = #{taskId}
|
||||
and status = 'RUNNING'
|
||||
</update>
|
||||
|
||||
<update id="markFailed">
|
||||
update ar_bill_generate_task
|
||||
set status = 'FAILED',
|
||||
error_message = #{errorMessage},
|
||||
finished_at = #{finishedAt},
|
||||
heartbeat_time = #{finishedAt}
|
||||
where task_id = #{taskId}
|
||||
and status in ('WAITING', 'RUNNING', 'CANCEL_REQUESTED')
|
||||
</update>
|
||||
|
||||
<update id="markCancelRequested">
|
||||
update ar_bill_generate_task
|
||||
set status = 'CANCEL_REQUESTED',
|
||||
heartbeat_time = sysdate()
|
||||
where task_id = #{taskId}
|
||||
and status in ('WAITING', 'RUNNING')
|
||||
</update>
|
||||
|
||||
<update id="markCanceled">
|
||||
update ar_bill_generate_task
|
||||
set status = 'CANCELED',
|
||||
error_message = '用户取消账单生成',
|
||||
finished_at = #{finishedAt},
|
||||
heartbeat_time = #{finishedAt}
|
||||
where task_id = #{taskId}
|
||||
and status in ('WAITING', 'RUNNING', 'CANCEL_REQUESTED')
|
||||
</update>
|
||||
|
||||
<!-- 执行节点宕机时恢复无心跳的 RUNNING 任务,供调度器重新投递。 -->
|
||||
<update id="resetExpiredRunning">
|
||||
update ar_bill_generate_task
|
||||
set status = 'WAITING',
|
||||
error_message = '任务执行节点已重启,已自动恢复等待处理',
|
||||
heartbeat_time = null
|
||||
where status = 'RUNNING'
|
||||
and heartbeat_time < #{expiredBefore}
|
||||
</update>
|
||||
|
||||
<!-- 取消请求长时间未完成时由补偿任务取出并执行数据清理。 -->
|
||||
<select id="selectCancelRequestedBefore" resultMap="ArBillGenerateTaskResult">
|
||||
<include refid="columns"/>
|
||||
where status = 'CANCEL_REQUESTED'
|
||||
and coalesce(heartbeat_time, create_time) < #{expiredBefore}
|
||||
order by create_time asc, task_id asc
|
||||
limit #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ar.mapper.ArBillLogMapper">
|
||||
<resultMap id="ArBillLogResult" type="ArBillLog">
|
||||
<id property="logId" column="log_id"/>
|
||||
@@ -28,24 +28,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectList" parameterType="ArBillLog" 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
|
||||
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_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
|
||||
left join ar_bill_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="arBillId != null">and l.ar_bill_id = #{arBillId}</if>
|
||||
<if test="objectType != null and objectType != ''">and l.object_type = #{objectType}</if>
|
||||
<if test="objectId != null and objectId != ''">and l.object_id = #{objectId}</if>
|
||||
<if test="operationType != null and operationType != ''">and l.operation_type = #{operationType}</if>
|
||||
<if test="operationSource != null and operationSource != ''">and l.operation_source = #{operationSource}</if>
|
||||
<if test="operationSource != null and operationSource != ''">and l.operation_source = #{operationSource}
|
||||
</if>
|
||||
<if test="requestId != null and requestId != ''">and l.request_id = #{requestId}</if>
|
||||
<if test="result != null and result != ''">and l.result = #{result}</if>
|
||||
</where>
|
||||
@@ -53,23 +56,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</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
|
||||
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}
|
||||
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 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>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ar.mapper.ArBillMapper">
|
||||
<!-- 账单头查询、状态流转和金额/生成进度更新。带 ForUpdate 的查询用于核销并发控制。 -->
|
||||
<resultMap id="ArBillResult" type="ArBill">
|
||||
<id property="arBillId" column="ar_bill_id"/>
|
||||
<result property="billNo" column="bill_no"/>
|
||||
@@ -19,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="writtenOffAmount" column="written_off_amount"/>
|
||||
<result property="unwrittenAmount" column="unwritten_amount"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="generationStatus" column="generation_status"/>
|
||||
<result property="billVersion" column="bill_version"/>
|
||||
<result property="bankAccountName" column="bank_account_name"/>
|
||||
<result property="bankAccountNo" column="bank_account_no"/>
|
||||
@@ -33,21 +35,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectArBillColumns">
|
||||
select ar_bill_id, bill_no, bill_name, customer_id, customer_code, customer_name,
|
||||
bill_period_start, bill_period_end, bill_date, currency, order_count,
|
||||
total_amount, written_off_amount, unwritten_amount, status, bill_version,
|
||||
bank_account_name, bank_account_no, bank_name, remark, confirmed_by,
|
||||
confirmed_time, create_by, create_time, update_by, update_time
|
||||
select ar_bill_id,
|
||||
bill_no,
|
||||
bill_name,
|
||||
customer_id,
|
||||
customer_code,
|
||||
customer_name,
|
||||
bill_period_start,
|
||||
bill_period_end,
|
||||
bill_date,
|
||||
currency,
|
||||
order_count,
|
||||
total_amount,
|
||||
written_off_amount,
|
||||
unwritten_amount,
|
||||
status,
|
||||
generation_status,
|
||||
bill_version,
|
||||
bank_account_name,
|
||||
bank_account_no,
|
||||
bank_name,
|
||||
remark,
|
||||
confirmed_by,
|
||||
confirmed_time,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time
|
||||
from ar_bill
|
||||
</sql>
|
||||
|
||||
<select id="selectArBillList" parameterType="com.ruoyi.ar.domain.vo.ArBillQuery" resultMap="ArBillResult">
|
||||
<include refid="selectArBillColumns"/>
|
||||
<where>
|
||||
and (generation_status is null or generation_status = 'READY')
|
||||
<if test="billNo != null and billNo != ''">and bill_no like concat('%', #{billNo}, '%')</if>
|
||||
<if test="billName != null and billName != ''">and bill_name like concat('%', #{billName}, '%')</if>
|
||||
<if test="customerCode != null and customerCode != ''">and customer_code like concat('%', #{customerCode}, '%')</if>
|
||||
<if test="customerName != null and customerName != ''">and customer_name like concat('%', #{customerName}, '%')</if>
|
||||
<if test="customerCode != null and customerCode != ''">and customer_code like concat('%', #{customerCode},
|
||||
'%')
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">and customer_name like concat('%', #{customerName},
|
||||
'%')
|
||||
</if>
|
||||
<if test="customerId != null">and customer_id = #{customerId}</if>
|
||||
<if test="status != null and status != ''">and status = #{status}</if>
|
||||
<if test="currency != null and currency != ''">and currency = #{currency}</if>
|
||||
@@ -59,11 +88,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectArBillById" parameterType="long" resultMap="ArBillResult">
|
||||
<include refid="selectArBillColumns"/> where ar_bill_id = #{arBillId}
|
||||
<include refid="selectArBillColumns"/>
|
||||
where ar_bill_id = #{arBillId}
|
||||
</select>
|
||||
|
||||
<select id="selectArBillByBillNo" parameterType="string" resultMap="ArBillResult">
|
||||
<include refid="selectArBillColumns"/> where bill_no = #{billNo}
|
||||
<include refid="selectArBillColumns"/>
|
||||
where bill_no = #{billNo}
|
||||
</select>
|
||||
|
||||
<select id="selectGeneratingByCustomerPeriod" resultMap="ArBillResult">
|
||||
<include refid="selectArBillColumns"/>
|
||||
where customer_id = #{customerId}
|
||||
and currency = #{currency}
|
||||
and bill_period_end = #{cutoffDate}
|
||||
and generation_status = 'GENERATING'
|
||||
order by ar_bill_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectMaxBillVersion" resultType="int">
|
||||
@@ -72,41 +113,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where customer_id = #{customerId}
|
||||
and bill_period_end = #{cutoffDate}
|
||||
and currency = #{currency}
|
||||
order by bill_version desc
|
||||
limit 1
|
||||
for update
|
||||
order by bill_version desc limit 1
|
||||
for
|
||||
update
|
||||
</select>
|
||||
|
||||
<select id="selectArBillByIdForUpdate" parameterType="long" resultMap="ArBillResult">
|
||||
<include refid="selectArBillColumns"/> where ar_bill_id = #{arBillId} for update
|
||||
<include refid="selectArBillColumns"/>
|
||||
where ar_bill_id = #{arBillId} for update
|
||||
</select>
|
||||
|
||||
<select id="selectUnsettledByCustomer" resultMap="ArBillResult">
|
||||
<include refid="selectArBillColumns"/>
|
||||
where customer_id = #{customerId}
|
||||
and status in ('CONFIRMED', 'PARTIAL_WRITTEN_OFF')
|
||||
and unwritten_amount > 0
|
||||
and status in ('CONFIRMED', 'PARTIAL_WRITTEN_OFF')
|
||||
and (generation_status is null or generation_status = 'READY')
|
||||
and unwritten_amount > 0
|
||||
order by bill_date asc, ar_bill_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertArBill" parameterType="ArBill" useGeneratedKeys="true" keyProperty="arBillId">
|
||||
insert into ar_bill (
|
||||
bill_no, bill_name, customer_id, customer_code, customer_name, bill_period_start, bill_period_end,
|
||||
bill_date, currency, order_count, total_amount, written_off_amount, unwritten_amount,
|
||||
status, bill_version, bank_account_name, bank_account_no, bank_name, remark,
|
||||
confirmed_by, confirmed_time, create_by, create_time, update_by, update_time
|
||||
) values (
|
||||
#{billNo}, #{billName}, #{customerId}, #{customerCode}, #{customerName}, #{billPeriodStart}, #{billPeriodEnd},
|
||||
#{billDate}, #{currency}, #{orderCount}, #{totalAmount}, #{writtenOffAmount}, #{unwrittenAmount},
|
||||
#{status}, #{billVersion}, #{bankAccountName}, #{bankAccountNo}, #{bankName}, #{remark},
|
||||
#{confirmedBy}, #{confirmedTime}, #{createBy}, sysdate(), #{updateBy}, sysdate()
|
||||
)
|
||||
insert into ar_bill (bill_no, bill_name, customer_id, customer_code, customer_name, bill_period_start,
|
||||
bill_period_end,
|
||||
bill_date, currency, order_count, total_amount, written_off_amount, unwritten_amount,
|
||||
status, generation_status, bill_version, bank_account_name, bank_account_no, bank_name,
|
||||
remark,
|
||||
confirmed_by, confirmed_time, create_by, create_time, update_by, update_time)
|
||||
values (#{billNo}, #{billName}, #{customerId}, #{customerCode}, #{customerName}, #{billPeriodStart},
|
||||
#{billPeriodEnd},
|
||||
#{billDate}, #{currency}, #{orderCount}, #{totalAmount}, #{writtenOffAmount}, #{unwrittenAmount},
|
||||
#{status}, #{generationStatus}, #{billVersion}, #{bankAccountName}, #{bankAccountNo}, #{bankName},
|
||||
#{remark},
|
||||
#{confirmedBy}, #{confirmedTime}, #{createBy}, sysdate(), #{updateBy}, sysdate())
|
||||
</insert>
|
||||
|
||||
<update id="updateArBillStatus">
|
||||
update ar_bill
|
||||
set status = #{status}, remark = #{remark}, update_by = #{operator}, update_time = sysdate(),
|
||||
confirmed_by = case when #{status} = 'CONFIRMED' then #{operator} else confirmed_by end,
|
||||
set status = #{status},
|
||||
remark = #{remark},
|
||||
update_by = #{operator},
|
||||
update_time = sysdate(),
|
||||
confirmed_by = case when #{status} = 'CONFIRMED' then #{operator} else confirmed_by end,
|
||||
confirmed_time = case when #{status} = 'CONFIRMED' then sysdate() else confirmed_time end
|
||||
where ar_bill_id = #{arBillId}
|
||||
and status = #{fromStatus}
|
||||
@@ -114,9 +161,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<update id="updateArBillAmounts">
|
||||
update ar_bill
|
||||
set written_off_amount = #{writtenOffAmount}, unwritten_amount = #{unwrittenAmount},
|
||||
status = #{status}, update_by = #{operator}, update_time = sysdate()
|
||||
set written_off_amount = #{writtenOffAmount},
|
||||
unwritten_amount = #{unwrittenAmount},
|
||||
status = #{status},
|
||||
update_by = #{operator},
|
||||
update_time = sysdate()
|
||||
where ar_bill_id = #{arBillId}
|
||||
and status = #{fromStatus}
|
||||
</update>
|
||||
|
||||
<update id="updateArBillProgress">
|
||||
update ar_bill
|
||||
set order_count = #{orderCount},
|
||||
total_amount = #{totalAmount},
|
||||
unwritten_amount = #{unwrittenAmount},
|
||||
bill_period_start = case
|
||||
when #{billPeriodStart} < bill_period_start then #{billPeriodStart}
|
||||
else bill_period_start end,
|
||||
update_by = #{operator},
|
||||
update_time = sysdate()
|
||||
where ar_bill_id = #{arBillId}
|
||||
</update>
|
||||
|
||||
<update id="updateArBillGenerationStatus">
|
||||
update ar_bill
|
||||
set generation_status = #{generationStatus},
|
||||
update_by = #{operator},
|
||||
update_time = sysdate(),
|
||||
remark = case when #{remark} is null or #{remark} = '' then remark else #{remark} end
|
||||
where ar_bill_id = #{arBillId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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.ruoyi.ar.mapper.ArExportTemplateMapper">
|
||||
<!-- 模板管理查询;导出提交时会把选中的模板版本快照到导出任务。 -->
|
||||
<resultMap id="ArExportTemplateResult" type="ArExportTemplate">
|
||||
<id property="templateId" column="template_id"/>
|
||||
<result property="templateCode" column="template_code"/>
|
||||
<result property="templateName" column="template_name"/>
|
||||
<result property="businessType" column="business_type"/>
|
||||
<result property="templateVersion" column="template_version"/>
|
||||
<result property="storageType" column="storage_type"/>
|
||||
<result property="storageKey" column="storage_key"/>
|
||||
<result property="fileHash" column="file_hash"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="isDefault" column="is_default"/>
|
||||
<result property="effectiveStart" column="effective_start"/>
|
||||
<result property="effectiveEnd" column="effective_end"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDefaultEnabled" resultMap="ArExportTemplateResult">
|
||||
select template_id,
|
||||
template_code,
|
||||
template_name,
|
||||
business_type,
|
||||
template_version,
|
||||
storage_type,
|
||||
storage_key,
|
||||
file_hash,
|
||||
status,
|
||||
is_default,
|
||||
effective_start,
|
||||
effective_end,
|
||||
remark
|
||||
from ar_export_template
|
||||
where business_type = #{businessType}
|
||||
and status = 'ENABLED'
|
||||
and is_default = '1'
|
||||
and (effective_start is null or effective_start <= #{effectiveDate})
|
||||
and (effective_end is null or effective_end >= #{effectiveDate})
|
||||
order by effective_start desc, template_id desc limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -4,6 +4,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.price.mapper.PrcOrderBillMapper">
|
||||
|
||||
<!-- 应收账单生成依赖的来源计费订单查询;本项目的 prc_bill 需求表映射为 prc_order_bill。 -->
|
||||
|
||||
<resultMap type="PrcOrderBill" id="PrcOrderBillResult">
|
||||
<id property="billId" column="bill_id" />
|
||||
<result property="billKey" column="bill_key" />
|
||||
@@ -155,21 +157,107 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by create_time desc, bill_id desc
|
||||
</select>
|
||||
|
||||
<!-- The repository's rename_bill_tables.sql maps the requirement's prc_bill to prc_order_bill. -->
|
||||
<!-- rename_bill_tables.sql 已将需求文档中的 prc_bill 映射为本项目的 prc_order_bill。 -->
|
||||
<!-- 生成弹窗预览:按客户、截止日、币种和订单/运单号 OR 条件分页查询未入账订单。 -->
|
||||
<select id="selectPrcOrderBillByCustomerPeriod" resultMap="PrcOrderBillResult">
|
||||
<include refid="selectPrcOrderBillVo"/>
|
||||
where customer_id = #{customerId}
|
||||
<if test="customerCode != null and customerCode != ''">
|
||||
and customer_code like concat('%', #{customerCode}, '%')
|
||||
</if>
|
||||
<if test="orderOrTrackingNo != null and orderOrTrackingNo != ''">
|
||||
and (order_no like concat('%', #{orderOrTrackingNo}, '%')
|
||||
or tracking_no like concat('%', #{orderOrTrackingNo}, '%'))
|
||||
</if>
|
||||
<if test="excludeOrderOrTrackingNo != null and excludeOrderOrTrackingNo != ''">
|
||||
and (order_no like concat('%', #{excludeOrderOrTrackingNo}, '%')
|
||||
or tracking_no like concat('%', #{excludeOrderOrTrackingNo}, '%'))
|
||||
</if>
|
||||
and biz_date <= #{cutoffDate}
|
||||
and ar_bill_status = #{arBillStatus}
|
||||
<if test="currency != null and currency != ''">
|
||||
and currency = #{currency}
|
||||
</if>
|
||||
<if test="excludedBillIds != null and excludedBillIds.size() > 0">
|
||||
and bill_id not in
|
||||
<foreach collection="excludedBillIds" item="excludedBillId" open="(" separator="," close=")">
|
||||
#{excludedBillId}
|
||||
</foreach>
|
||||
</if>
|
||||
order by biz_date, order_no, bill_id
|
||||
</select>
|
||||
|
||||
<select id="sumPrcOrderBillIncomeByCustomerPeriod" resultType="java.math.BigDecimal">
|
||||
select coalesce(sum(income_total), 0)
|
||||
from prc_order_bill
|
||||
where customer_id = #{customerId}
|
||||
<if test="customerCode != null and customerCode != ''">
|
||||
and customer_code like concat('%', #{customerCode}, '%')
|
||||
</if>
|
||||
<if test="orderOrTrackingNo != null and orderOrTrackingNo != ''">
|
||||
and (order_no like concat('%', #{orderOrTrackingNo}, '%')
|
||||
or tracking_no like concat('%', #{orderOrTrackingNo}, '%'))
|
||||
</if>
|
||||
<if test="excludeOrderOrTrackingNo != null and excludeOrderOrTrackingNo != ''">
|
||||
and (order_no like concat('%', #{excludeOrderOrTrackingNo}, '%')
|
||||
or tracking_no like concat('%', #{excludeOrderOrTrackingNo}, '%'))
|
||||
</if>
|
||||
and biz_date <= #{cutoffDate}
|
||||
and ar_bill_status = #{arBillStatus}
|
||||
<if test="currency != null and currency != ''">
|
||||
and currency = #{currency}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<sql id="customerPeriodConditions">
|
||||
where customer_id = #{customerId}
|
||||
<if test="customerCode != null and customerCode != ''">
|
||||
and customer_code like concat('%', #{customerCode}, '%')
|
||||
</if>
|
||||
<if test="orderOrTrackingNo != null and orderOrTrackingNo != ''">
|
||||
and (order_no like concat('%', #{orderOrTrackingNo}, '%')
|
||||
or tracking_no like concat('%', #{orderOrTrackingNo}, '%'))
|
||||
</if>
|
||||
and biz_date <= #{cutoffDate}
|
||||
and ar_bill_status = #{arBillStatus}
|
||||
<if test="currency != null and currency != ''">
|
||||
and currency = #{currency}
|
||||
</if>
|
||||
<if test="snapshotCreateTime != null">
|
||||
and (create_time is null or create_time <= #{snapshotCreateTime})
|
||||
</if>
|
||||
<if test="billIds != null and billIds.size() > 0">
|
||||
and bill_id in
|
||||
<foreach collection="billIds" item="billId" open="(" separator="," close=")">
|
||||
#{billId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="excludedBillIds != null and excludedBillIds.size() > 0">
|
||||
and bill_id not in
|
||||
<foreach collection="excludedBillIds" item="excludedBillId" open="(" separator="," close=")">
|
||||
#{excludedBillId}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 异步生成使用 bill_id 游标批量读取,避免深分页和一次加载全量订单。 -->
|
||||
<select id="selectPrcOrderBillByCustomerPeriodCursor" resultMap="PrcOrderBillResult">
|
||||
<include refid="selectPrcOrderBillVo"/>
|
||||
<include refid="customerPeriodConditions"/>
|
||||
<if test="lastSourceBillId != null and lastSourceBillId != ''">
|
||||
and bill_id > #{lastSourceBillId}
|
||||
</if>
|
||||
order by bill_id
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<!-- 全选模式先统计总数,用于任务进度和空范围校验。 -->
|
||||
<select id="countPrcOrderBillByCustomerPeriod" resultType="int">
|
||||
select count(1)
|
||||
from prc_order_bill
|
||||
<include refid="customerPeriodConditions"/>
|
||||
</select>
|
||||
|
||||
<select id="selectPrcOrderBillByCustomerCutoffAndIds" resultMap="PrcOrderBillResult">
|
||||
<include refid="selectPrcOrderBillVo"/>
|
||||
where customer_id = #{customerId}
|
||||
@@ -182,6 +270,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="customerCode != null and customerCode != ''">
|
||||
and customer_code like concat('%', #{customerCode}, '%')
|
||||
</if>
|
||||
<if test="orderOrTrackingNo != null and orderOrTrackingNo != ''">
|
||||
and (order_no like concat('%', #{orderOrTrackingNo}, '%')
|
||||
or tracking_no like concat('%', #{orderOrTrackingNo}, '%'))
|
||||
</if>
|
||||
<if test="currency != null and currency != ''">
|
||||
and currency = #{currency}
|
||||
</if>
|
||||
@@ -280,6 +372,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<!-- 抢占来源订单:只有未入账订单可以变更为已入账,防止重复生成。 -->
|
||||
<update id="claimArBillOrders">
|
||||
update prc_order_bill
|
||||
set ar_bill_status = #{toStatus}, updated_by = #{operator}, update_time = sysdate()
|
||||
@@ -299,4 +392,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{billId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="releaseArBillOrdersByArBillId">
|
||||
update prc_order_bill p
|
||||
inner join ar_bill_detail d on d.prc_order_bill_id = p.bill_id
|
||||
set p.ar_bill_status = #{toStatus}, p.updated_by = #{operator}, p.update_time = sysdate()
|
||||
where d.ar_bill_id = #{arBillId}
|
||||
and p.ar_bill_status = #{fromStatus}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user