统一修改ruoyi->bms

This commit is contained in:
caojia
2026-09-28 10:02:38 +08:00
parent 341afc4111
commit 0408b6c35e
639 changed files with 2776 additions and 2807 deletions
@@ -0,0 +1,194 @@
<?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.ArBillMapper">
<!-- 账单头查询、状态流转和金额/生成进度更新。带 ForUpdate 的查询用于核销并发控制。 -->
<resultMap id="ArBillResult" type="ArBill">
<id property="arBillId" column="ar_bill_id"/>
<result property="billNo" column="bill_no"/>
<result property="billName" column="bill_name"/>
<result property="customerId" column="customer_id"/>
<result property="customerCode" column="customer_code"/>
<result property="customerName" column="customer_name"/>
<result property="billPeriodStart" column="bill_period_start"/>
<result property="billPeriodEnd" column="bill_period_end"/>
<result property="billDate" column="bill_date"/>
<result property="currency" column="currency"/>
<result property="orderCount" column="order_count"/>
<result property="totalAmount" column="total_amount"/>
<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"/>
<result property="bankName" column="bank_name"/>
<result property="remark" column="remark"/>
<result property="confirmedBy" column="confirmed_by"/>
<result property="confirmedTime" column="confirmed_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</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,
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.bms.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="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>
<if test="billDateStart != null">and bill_date &gt;= #{billDateStart}</if>
<if test="billDateEnd != null">and bill_date &lt;= #{billDateEnd}</if>
<if test="billPeriodEnd != null">and bill_period_end = #{billPeriodEnd}</if>
</where>
order by create_time desc, ar_bill_id desc
</select>
<select id="selectArBillById" parameterType="long" resultMap="ArBillResult">
<include refid="selectArBillColumns"/>
where ar_bill_id = #{arBillId}
</select>
<select id="selectArBillByBillNo" parameterType="string" resultMap="ArBillResult">
<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">
select bill_version
from ar_bill
where customer_id = #{customerId}
and bill_period_end = #{cutoffDate}
and currency = #{currency}
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
</select>
<select id="selectUnsettledByCustomer" resultMap="ArBillResult">
<include refid="selectArBillColumns"/>
where customer_id = #{customerId}
and status in ('CONFIRMED', 'PARTIAL_WRITTEN_OFF')
and (generation_status is null or generation_status = 'READY')
and unwritten_amount &gt; 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, 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,
confirmed_time = case when #{status} = 'CONFIRMED' then sysdate() else confirmed_time end
where ar_bill_id = #{arBillId}
and status = #{fromStatus}
</update>
<update id="updateArBillAmounts">
update ar_bill
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} &lt; 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>