更新UUID到新费用行和阴影同步Mapper的注释,新增关联表回写逻辑
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
/**
|
||||
* 旧费用行:用于逐行插入并建内存 Map
|
||||
* 旧收入费用行:逐行插入 income *_new 并建内存 Map
|
||||
*/
|
||||
public class UuidToNewFeeRow
|
||||
{
|
||||
|
||||
+4
-1
@@ -1,14 +1,17 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
/**
|
||||
* 阴影插入时传参 / 接收自增主键
|
||||
* 阴影插入传参 / 接收自增主键、批次日志
|
||||
*/
|
||||
public class UuidToNewIdHolder
|
||||
{
|
||||
private String oldBillId;
|
||||
private Long newBillId;
|
||||
/** 旧 income_bill_id / fee_id(UUID) */
|
||||
private String oldId;
|
||||
/** 新 income_bill_id / fee_id(bigint) */
|
||||
private Long newId;
|
||||
/** 新 income_bill_id(费用行用) */
|
||||
private Long newIncomeId;
|
||||
private String orderNo;
|
||||
private String status;
|
||||
|
||||
+11
-6
@@ -8,7 +8,7 @@ import com.bms.price.migration.domain.UuidToNewIdHolder;
|
||||
import com.bms.price.migration.domain.UuidToNewProgressVo;
|
||||
|
||||
/**
|
||||
* UUID -> bigint 阴影同步 Mapper
|
||||
* UUID -> bigint 阴影同步 Mapper(订单+income *_new + 关联表 order_id)
|
||||
*/
|
||||
public interface UuidToNewSyncMapper
|
||||
{
|
||||
@@ -39,13 +39,19 @@ public interface UuidToNewSyncMapper
|
||||
|
||||
int insertIncomeFeeNew(UuidToNewIdHolder holder);
|
||||
|
||||
int insertArDetailNew(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
/** 回写现网关联表 order_id(= prc_order_bill_new.bill_id) */
|
||||
|
||||
List<UuidToNewFeeRow> selectArDetailFees(@Param("oldBillId") String oldBillId);
|
||||
int updatePayBillOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int insertArDetailFeeNew(@Param("detailFeeId") Long detailFeeId, @Param("newFeeId") Long newFeeId);
|
||||
int updatePayFeeOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int insertBillingTaskNew(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
int updateArDetailOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updatePayBillLineOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updateBillingTaskOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updateArGenTaskOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int insertJobLogStart(UuidToNewIdHolder holder);
|
||||
|
||||
@@ -55,4 +61,3 @@ public interface UuidToNewSyncMapper
|
||||
|
||||
List<MigBiJobLog> selectJobLogList(MigBiJobLog query);
|
||||
}
|
||||
|
||||
|
||||
+22
-20
@@ -27,7 +27,8 @@ import com.bms.price.migration.mapper.UuidToNewSyncMapper;
|
||||
import com.bms.price.migration.service.IUuidToNewSyncService;
|
||||
|
||||
/**
|
||||
* UUID -> bigint 阴影同步:占坑独立提交;一单一事务;批内可多线程。
|
||||
* UUID -> bigint 阴影同步:订单+income *_new + 关联表回写 order_id。
|
||||
* 占坑独立提交;一单一事务;批内可多线程。
|
||||
*/
|
||||
@Service
|
||||
public class UuidToNewSyncServiceImpl implements IUuidToNewSyncService
|
||||
@@ -293,9 +294,6 @@ public class UuidToNewSyncServiceImpl implements IUuidToNewSyncService
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
Map<String, Long> incomeMap = new HashMap<String, Long>();
|
||||
Map<String, Long> feeMap = new HashMap<String, Long>();
|
||||
|
||||
UuidToNewIdHolder order = new UuidToNewIdHolder();
|
||||
order.setOldBillId(oldBillId);
|
||||
syncMapper.insertOrderBillNew(order);
|
||||
@@ -313,7 +311,17 @@ public class UuidToNewSyncServiceImpl implements IUuidToNewSyncService
|
||||
syncMapper.updateOrderDoneSuccess(done);
|
||||
|
||||
syncMapper.insertOrderExtNew(oldBillId, newBillId);
|
||||
copyIncomeShadow(oldBillId, newBillId);
|
||||
fillRelatedOrderIds(oldBillId, newBillId);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝收入主表/费用到 *_new:income_bill_id、fee_id UUID -> bigint AI
|
||||
*/
|
||||
private void copyIncomeShadow(String oldBillId, Long newBillId)
|
||||
{
|
||||
Map<String, Long> incomeMap = new HashMap<String, Long>();
|
||||
for (String oldIncomeId : syncMapper.selectIncomeIds(oldBillId))
|
||||
{
|
||||
UuidToNewIdHolder h = new UuidToNewIdHolder();
|
||||
@@ -347,23 +355,17 @@ public class UuidToNewSyncServiceImpl implements IUuidToNewSyncService
|
||||
{
|
||||
throw new IllegalStateException("insert income_fee_new no id for " + row.getFeeId());
|
||||
}
|
||||
feeMap.put(row.getFeeId(), h.getNewId());
|
||||
}
|
||||
}
|
||||
|
||||
syncMapper.insertArDetailNew(oldBillId, newBillId);
|
||||
|
||||
for (UuidToNewFeeRow row : syncMapper.selectArDetailFees(oldBillId))
|
||||
{
|
||||
Long newFeeId = feeMap.get(row.getFeeId());
|
||||
if (newFeeId == null)
|
||||
{
|
||||
throw new IllegalStateException("feeMap miss for ar detail fee " + row.getFeeId());
|
||||
}
|
||||
Long detailFeeId = Long.valueOf(row.getParentId());
|
||||
syncMapper.insertArDetailFeeNew(detailFeeId, newFeeId);
|
||||
}
|
||||
|
||||
syncMapper.insertBillingTaskNew(oldBillId, newBillId);
|
||||
return SUCCESS;
|
||||
/** 现网关联表回写 order_id;旧 UUID 列不动 */
|
||||
private void fillRelatedOrderIds(String oldBillId, Long newBillId)
|
||||
{
|
||||
syncMapper.updatePayBillOrderId(oldBillId, newBillId);
|
||||
syncMapper.updatePayFeeOrderId(oldBillId, newBillId);
|
||||
syncMapper.updateArDetailOrderId(oldBillId, newBillId);
|
||||
syncMapper.updatePayBillLineOrderId(oldBillId, newBillId);
|
||||
syncMapper.updateBillingTaskOrderId(oldBillId, newBillId);
|
||||
syncMapper.updateArGenTaskOrderId(oldBillId, newBillId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,71 +234,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where f.fee_id = #{oldId}
|
||||
</insert>
|
||||
|
||||
<insert id="insertArDetailNew">
|
||||
insert into ar_bill_detail_new (
|
||||
detail_id, ar_bill_id, prc_order_bill_id, detail_no,
|
||||
order_no, tracking_no, transfer_no, receive_time,
|
||||
product_code, product_name, goods_description, country_code,
|
||||
country_name, dest_postcode, actual_weight, receive_weight,
|
||||
volume_weight, charge_weight, freight_rate, registration_fee,
|
||||
pkg_length, pkg_width, pkg_height, currency,
|
||||
total_amount, product_amount, redline_amount, billing_fail_status,
|
||||
remark, create_by, create_time
|
||||
)
|
||||
select
|
||||
d.detail_id, d.ar_bill_id, #{newBillId}, d.detail_no,
|
||||
d.order_no, d.tracking_no, d.transfer_no, d.receive_time,
|
||||
d.product_code, d.product_name, d.goods_description, d.country_code,
|
||||
d.country_name, d.dest_postcode, d.actual_weight, d.receive_weight,
|
||||
d.volume_weight, d.charge_weight, d.freight_rate, d.registration_fee,
|
||||
d.pkg_length, d.pkg_width, d.pkg_height, d.currency,
|
||||
d.total_amount, d.product_amount, d.redline_amount, d.billing_fail_status,
|
||||
d.remark, d.create_by, d.create_time
|
||||
from ar_bill_detail d
|
||||
where d.prc_order_bill_id = #{oldBillId}
|
||||
</insert>
|
||||
<!-- 现网关联表回写 order_id(旧 UUID 列不动) -->
|
||||
|
||||
<select id="selectArDetailFees" resultType="com.bms.price.migration.domain.UuidToNewFeeRow">
|
||||
select f.prc_income_bill_fee_id as feeId, cast(f.detail_fee_id as char) as parentId
|
||||
from ar_bill_detail_fee f
|
||||
inner join ar_bill_detail d on d.detail_id = f.detail_id
|
||||
where d.prc_order_bill_id = #{oldBillId}
|
||||
order by f.detail_fee_id
|
||||
</select>
|
||||
<update id="updatePayBillOrderId">
|
||||
update prc_pay_bill
|
||||
set order_id = #{newBillId}
|
||||
where bill_id = #{oldBillId}
|
||||
</update>
|
||||
|
||||
<insert id="insertArDetailFeeNew">
|
||||
insert into ar_bill_detail_fee_new (
|
||||
detail_fee_id, detail_id, prc_income_bill_fee_id, fee_no,
|
||||
fee_type, fee_name, sc_id, quantity,
|
||||
unit, unit_price, amount, product_amount,
|
||||
redline_amount, currency, calculation_formula, round_mode,
|
||||
remark, create_by, create_time
|
||||
)
|
||||
select
|
||||
f.detail_fee_id, f.detail_id, #{newFeeId}, f.fee_no,
|
||||
f.fee_type, f.fee_name, f.sc_id, f.quantity,
|
||||
f.unit, f.unit_price, f.amount, f.product_amount,
|
||||
f.redline_amount, f.currency, f.calculation_formula, f.round_mode,
|
||||
f.remark, f.create_by, f.create_time
|
||||
from ar_bill_detail_fee f
|
||||
where f.detail_fee_id = #{detailFeeId}
|
||||
</insert>
|
||||
<update id="updatePayFeeOrderId">
|
||||
update prc_pay_bill_fee
|
||||
set order_id = #{newBillId}
|
||||
where bill_id = #{oldBillId}
|
||||
</update>
|
||||
|
||||
<insert id="insertBillingTaskNew">
|
||||
insert into prc_billing_task_new (
|
||||
task_id, transfer_no, tracking_no, order_no,
|
||||
customer_code, bill_type, success_status, bill_time,
|
||||
bill_id, fail_code, error_message, create_by,
|
||||
create_time, update_by, update_time
|
||||
)
|
||||
select
|
||||
t.task_id, t.transfer_no, t.tracking_no, t.order_no,
|
||||
t.customer_code, t.bill_type, t.success_status, t.bill_time,
|
||||
#{newBillId}, t.fail_code, t.error_message, t.create_by,
|
||||
t.create_time, t.update_by, t.update_time
|
||||
from prc_billing_task t
|
||||
where t.bill_id = #{oldBillId}
|
||||
</insert>
|
||||
<update id="updateArDetailOrderId">
|
||||
update ar_bill_detail
|
||||
set order_id = #{newBillId}
|
||||
where prc_order_bill_id = #{oldBillId}
|
||||
</update>
|
||||
|
||||
<update id="updatePayBillLineOrderId">
|
||||
update pay_bill_line
|
||||
set order_id = #{newBillId}
|
||||
where order_bill_id = #{oldBillId}
|
||||
</update>
|
||||
|
||||
<update id="updateBillingTaskOrderId">
|
||||
update prc_billing_task
|
||||
set order_id = #{newBillId}
|
||||
where bill_id = #{oldBillId}
|
||||
</update>
|
||||
|
||||
<update id="updateArGenTaskOrderId">
|
||||
update ar_bill_generate_task
|
||||
set order_id = #{newBillId}
|
||||
where last_source_bill_id = #{oldBillId}
|
||||
</update>
|
||||
|
||||
<insert id="insertJobLogStart" useGeneratedKeys="true" keyProperty="jobLogId" keyColumn="id">
|
||||
insert into mig_bi_job_log (batch_no, fetched, success, fail, skip, started_at, remark)
|
||||
|
||||
Reference in New Issue
Block a user