♻️ 调整应收账单来源 ID 为 bigint
This commit is contained in:
+3
-2
@@ -34,6 +34,7 @@ import com.bms.receivable.domain.vo.ArBillGenerateQuery;
|
|||||||
import com.bms.receivable.domain.vo.ArBillGenerateRequest;
|
import com.bms.receivable.domain.vo.ArBillGenerateRequest;
|
||||||
import com.bms.receivable.domain.vo.ArBillListExportRow;
|
import com.bms.receivable.domain.vo.ArBillListExportRow;
|
||||||
import com.bms.receivable.domain.vo.ArBillQuery;
|
import com.bms.receivable.domain.vo.ArBillQuery;
|
||||||
|
import com.bms.receivable.domain.vo.ArBillPreviewOrder;
|
||||||
import com.bms.receivable.service.IArBillService;
|
import com.bms.receivable.service.IArBillService;
|
||||||
import com.bms.receivable.service.ArBillVoidTaskService;
|
import com.bms.receivable.service.ArBillVoidTaskService;
|
||||||
import com.bms.receivable.security.ArBillScopeResolver;
|
import com.bms.receivable.security.ArBillScopeResolver;
|
||||||
@@ -175,7 +176,7 @@ public class ArBillController extends BaseController {
|
|||||||
List<PrcOrderBill> list = billService.previewBill(query);
|
List<PrcOrderBill> list = billService.previewBill(query);
|
||||||
TableDataInfo pageData = getDataTable(list);
|
TableDataInfo pageData = getDataTable(list);
|
||||||
AjaxResult result = success();
|
AjaxResult result = success();
|
||||||
result.put("rows", pageData.getRows());
|
result.put("rows", list.stream().map(ArBillPreviewOrder::from).toList());
|
||||||
result.put("total", pageData.getTotal());
|
result.put("total", pageData.getTotal());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -219,7 +220,7 @@ public class ArBillController extends BaseController {
|
|||||||
List<PrcOrderBill> list = billService.previewExcludedBill(query);
|
List<PrcOrderBill> list = billService.previewExcludedBill(query);
|
||||||
TableDataInfo pageData = getDataTable(list);
|
TableDataInfo pageData = getDataTable(list);
|
||||||
AjaxResult result = success();
|
AjaxResult result = success();
|
||||||
result.put("rows", pageData.getRows());
|
result.put("rows", list.stream().map(ArBillPreviewOrder::from).toList());
|
||||||
result.put("total", pageData.getTotal());
|
result.put("total", pageData.getTotal());
|
||||||
result.put("totalAmount", billService.sumPreviewBill(query));
|
result.put("totalAmount", billService.sumPreviewBill(query));
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ public class ArBillDetail implements Serializable {
|
|||||||
|
|
||||||
private Long detailId;
|
private Long detailId;
|
||||||
private Long arBillId;
|
private Long arBillId;
|
||||||
private String prcOrderBillId;
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long prcOrderBillId;
|
||||||
private Integer detailNo;
|
private Integer detailNo;
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
private String trackingNo;
|
private String trackingNo;
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class ArBillDetailFee implements Serializable {
|
|||||||
|
|
||||||
private Long detailFeeId;
|
private Long detailFeeId;
|
||||||
private Long detailId;
|
private Long detailId;
|
||||||
private String prcIncomeBillFeeId;
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long prcIncomeBillFeeId;
|
||||||
private Integer feeNo;
|
private Integer feeNo;
|
||||||
private String feeType;
|
private String feeType;
|
||||||
private String feeName;
|
private String feeName;
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ public class ArBillGenerateTask implements Serializable {
|
|||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date snapshotCreateTime;
|
private Date snapshotCreateTime;
|
||||||
/**
|
/**
|
||||||
* 按 bill_id 字典序处理的游标。
|
* 按 bill_id 数值顺序处理的游标。
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
private Long lastSourceBillId;
|
private Long lastSourceBillId;
|
||||||
/**
|
/**
|
||||||
* 待处理总数;全选模式统计完成前使用 -1。
|
* 待处理总数;全选模式统计完成前使用 -1。
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.bms.receivable.domain.vo;
|
||||||
|
|
||||||
|
import com.bms.price.domain.PrcOrderBill;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
/** 应收生成预览中,订单 ID 以字符串传递,避免浏览器整数精度丢失。 */
|
||||||
|
public class ArBillPreviewOrder extends PrcOrderBill {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static ArBillPreviewOrder from(PrcOrderBill source) {
|
||||||
|
ArBillPreviewOrder result = new ArBillPreviewOrder();
|
||||||
|
BeanUtils.copyProperties(source, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
public Long getBillId() {
|
||||||
|
return super.getBillId();
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
@@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import com.bms.receivable.domain.ArBillGenerateTask;
|
import com.bms.receivable.domain.ArBillGenerateTask;
|
||||||
|
import com.bms.price.migration.domain.UuidToNewIdHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应收账单异步生成任务 Mapper。
|
* 应收账单异步生成任务 Mapper。
|
||||||
@@ -21,6 +22,9 @@ public interface ArBillGenerateTaskMapper {
|
|||||||
|
|
||||||
List<ArBillGenerateTask> selectWaiting(@Param("limit") int limit);
|
List<ArBillGenerateTask> selectWaiting(@Param("limit") int limit);
|
||||||
|
|
||||||
|
/** 历史失败任务重试时,将请求快照中的旧订单 UUID 转为新 ID。 */
|
||||||
|
List<UuidToNewIdHolder> selectMigratedOrderIds(@Param("oldIds") List<String> oldIds);
|
||||||
|
|
||||||
int insert(ArBillGenerateTask task);
|
int insert(ArBillGenerateTask task);
|
||||||
|
|
||||||
int markRunning(@Param("taskId") Long taskId, @Param("startedAt") Date startedAt);
|
int markRunning(@Param("taskId") Long taskId, @Param("startedAt") Date startedAt);
|
||||||
|
|||||||
+55
-5
@@ -19,6 +19,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -45,6 +46,8 @@ import org.springframework.transaction.support.TransactionTemplate;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.bms.receivable.domain.ArBill;
|
import com.bms.receivable.domain.ArBill;
|
||||||
import com.bms.receivable.domain.ArBankAccount;
|
import com.bms.receivable.domain.ArBankAccount;
|
||||||
import com.bms.receivable.domain.ArBillDetail;
|
import com.bms.receivable.domain.ArBillDetail;
|
||||||
@@ -105,6 +108,7 @@ import com.bms.price.enums.BillBillingFailStatus;
|
|||||||
import com.bms.price.mapper.PrcIncomeBillMapper;
|
import com.bms.price.mapper.PrcIncomeBillMapper;
|
||||||
import com.bms.price.mapper.PrcIncomeBillFeeMapper;
|
import com.bms.price.mapper.PrcIncomeBillFeeMapper;
|
||||||
import com.bms.price.mapper.PrcOrderBillMapper;
|
import com.bms.price.mapper.PrcOrderBillMapper;
|
||||||
|
import com.bms.price.migration.domain.UuidToNewIdHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应收账单核心业务实现。
|
* 应收账单核心业务实现。
|
||||||
@@ -605,7 +609,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
if (!ArBillGenerateTaskStatus.FAILED.equals(task.getStatus())) {
|
if (!ArBillGenerateTaskStatus.FAILED.equals(task.getStatus())) {
|
||||||
throw new ServiceException("只有失败的账单生成任务可以重试");
|
throw new ServiceException("只有失败的账单生成任务可以重试");
|
||||||
}
|
}
|
||||||
ArBillGenerateRequest request = JSON.parseObject(task.getRequestPayload(), ArBillGenerateRequest.class);
|
ArBillGenerateRequest request = parseRetryRequest(task.getRequestPayload());
|
||||||
request.setRequestId(requestId);
|
request.setRequestId(requestId);
|
||||||
ArBillGenerateTask retried = generateBill(request, operator, requestId);
|
ArBillGenerateTask retried = generateBill(request, operator, requestId);
|
||||||
log.info("应收账单生成任务重试请求已处理,operator={}, requestId={}, sourceTaskId={}, newTaskId={}, status={}, costMs={}",
|
log.info("应收账单生成任务重试请求已处理,operator={}, requestId={}, sourceTaskId={}, newTaskId={}, status={}, costMs={}",
|
||||||
@@ -614,6 +618,52 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
return retried;
|
return retried;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 旧失败任务的选择快照可能保留 UUID;新任务始终使用 bigint ID。 */
|
||||||
|
private ArBillGenerateRequest parseRetryRequest(String payload) {
|
||||||
|
JSONObject data = JSON.parseObject(payload);
|
||||||
|
Set<String> oldIds = new LinkedHashSet<>();
|
||||||
|
for (String field : List.of("sourceBillIds", "excludedSourceBillIds")) {
|
||||||
|
JSONArray ids = data.getJSONArray(field);
|
||||||
|
if (ids == null) continue;
|
||||||
|
for (Object value : ids) {
|
||||||
|
if (value instanceof String text && !isLongId(text)) oldIds.add(text.toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!oldIds.isEmpty()) {
|
||||||
|
List<String> ids = new ArrayList<>(oldIds);
|
||||||
|
Map<String, Long> mapping = new HashMap<>();
|
||||||
|
for (int start = 0; start < ids.size(); start += 500) {
|
||||||
|
for (UuidToNewIdHolder row : generateTaskMapper.selectMigratedOrderIds(
|
||||||
|
ids.subList(start, Math.min(start + 500, ids.size())))) {
|
||||||
|
mapping.put(row.getOldBillId().toLowerCase(Locale.ROOT), row.getNewBillId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mapping.size() != oldIds.size()) {
|
||||||
|
throw new ServiceException("历史任务的部分订单尚未完成 ID 映射,请重新选择订单生成账单");
|
||||||
|
}
|
||||||
|
for (String field : List.of("sourceBillIds", "excludedSourceBillIds")) {
|
||||||
|
JSONArray values = data.getJSONArray(field);
|
||||||
|
if (values == null) continue;
|
||||||
|
for (int i = 0; i < values.size(); i++) {
|
||||||
|
Object value = values.get(i);
|
||||||
|
if (value instanceof String text && mapping.containsKey(text.toLowerCase(Locale.ROOT))) {
|
||||||
|
values.set(i, mapping.get(text.toLowerCase(Locale.ROOT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JSON.parseObject(data.toJSONString(), ArBillGenerateRequest.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLongId(String value) {
|
||||||
|
try {
|
||||||
|
Long.parseLong(value);
|
||||||
|
return true;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行异步生成任务。每个批次使用短事务,事务内完成来源订单占用、明细落库、
|
* 执行异步生成任务。每个批次使用短事务,事务内完成来源订单占用、明细落库、
|
||||||
* 费用落库和任务游标更新;异常统一进入独立事务清理,避免任务永久卡在运行中。
|
* 费用落库和任务游标更新;异常统一进入独立事务清理,避免任务永久卡在运行中。
|
||||||
@@ -853,7 +903,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
// 失败订单先落快照,再汇总占用状态,避免无费用订单被错误恢复为 UNBILLED。
|
// 失败订单先落快照,再汇总占用状态,避免无费用订单被错误恢复为 UNBILLED。
|
||||||
sourceBillMapper.refreshArBillStatusByBillIds(currentSourceBillIds);
|
sourceBillMapper.refreshArBillStatusByBillIds(currentSourceBillIds);
|
||||||
|
|
||||||
Map<String, ArBillDetail> detailsBySourceBill = new HashMap<>();
|
Map<Long, ArBillDetail> detailsBySourceBill = new HashMap<>();
|
||||||
for (ArBillDetail detail : detailMapper.selectByBillIdAndSourceIds(bill.getArBillId(), currentSourceBillIds)) {
|
for (ArBillDetail detail : detailMapper.selectByBillIdAndSourceIds(bill.getArBillId(), currentSourceBillIds)) {
|
||||||
detailsBySourceBill.put(detail.getPrcOrderBillId(), detail);
|
detailsBySourceBill.put(detail.getPrcOrderBillId(), detail);
|
||||||
}
|
}
|
||||||
@@ -865,7 +915,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
Map<Long, Integer> feeNumbers = new HashMap<>();
|
Map<Long, Integer> feeNumbers = new HashMap<>();
|
||||||
if (sourceFees != null) {
|
if (sourceFees != null) {
|
||||||
for (PrcIncomeBillFee sourceFee : sourceFees) {
|
for (PrcIncomeBillFee sourceFee : sourceFees) {
|
||||||
ArBillDetail detail = detailsBySourceBill.get(String.valueOf(sourceFee.getBillId()));
|
ArBillDetail detail = detailsBySourceBill.get(sourceFee.getBillId());
|
||||||
if (detail == null) {
|
if (detail == null) {
|
||||||
throw new ServiceException("来源费用找不到对应的账单明细:" + sourceFee.getBillId());
|
throw new ServiceException("来源费用找不到对应的账单明细:" + sourceFee.getBillId());
|
||||||
}
|
}
|
||||||
@@ -1268,7 +1318,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
int detailNo, String operator) {
|
int detailNo, String operator) {
|
||||||
ArBillDetail detail = new ArBillDetail();
|
ArBillDetail detail = new ArBillDetail();
|
||||||
detail.setArBillId(bill.getArBillId());
|
detail.setArBillId(bill.getArBillId());
|
||||||
detail.setPrcOrderBillId(String.valueOf(source.getBillId()));
|
detail.setPrcOrderBillId(source.getBillId());
|
||||||
detail.setDetailNo(detailNo);
|
detail.setDetailNo(detailNo);
|
||||||
detail.setOrderNo(source.getOrderNo());
|
detail.setOrderNo(source.getOrderNo());
|
||||||
detail.setTrackingNo(source.getTrackingNo());
|
detail.setTrackingNo(source.getTrackingNo());
|
||||||
@@ -1304,7 +1354,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
private ArBillDetailFee toDetailFee(ArBillDetail detail, PrcIncomeBillFee source, int feeNo, String operator) {
|
private ArBillDetailFee toDetailFee(ArBillDetail detail, PrcIncomeBillFee source, int feeNo, String operator) {
|
||||||
ArBillDetailFee fee = new ArBillDetailFee();
|
ArBillDetailFee fee = new ArBillDetailFee();
|
||||||
fee.setDetailId(detail.getDetailId());
|
fee.setDetailId(detail.getDetailId());
|
||||||
fee.setPrcIncomeBillFeeId(String.valueOf(source.getFeeId()));
|
fee.setPrcIncomeBillFeeId(source.getFeeId());
|
||||||
fee.setFeeNo(feeNo);
|
fee.setFeeNo(feeNo);
|
||||||
fee.setFeeType(source.getFeeType());
|
fee.setFeeType(source.getFeeType());
|
||||||
fee.setFeeName(source.getFeeName());
|
fee.setFeeName(source.getFeeName());
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectPrcOrderBillByCustomerPeriodCursor" resultMap="PrcOrderBillArSourceResult">
|
<select id="selectPrcOrderBillByCustomerPeriodCursor" resultMap="PrcOrderBillArSourceResult">
|
||||||
<include refid="selectArBillSourceVo"/>
|
<include refid="selectArBillSourceVo"/>
|
||||||
<include refid="customerPeriodConditions"/>
|
<include refid="customerPeriodConditions"/>
|
||||||
<if test="lastSourceBillId != null and lastSourceBillId != ''">
|
<if test="lastSourceBillId != null">
|
||||||
and p.bill_id > #{lastSourceBillId}
|
and p.bill_id > #{lastSourceBillId}
|
||||||
</if>
|
</if>
|
||||||
order by p.bill_id
|
order by p.bill_id
|
||||||
|
|||||||
@@ -56,6 +56,15 @@
|
|||||||
where task_id = #{taskId}
|
where task_id = #{taskId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectMigratedOrderIds" resultType="com.bms.price.migration.domain.UuidToNewIdHolder">
|
||||||
|
select old_bill_id as oldBillId, new_bill_id as newBillId
|
||||||
|
from mig_bi_order_done
|
||||||
|
where status = 'SUCCESS' and old_bill_id in
|
||||||
|
<foreach collection="oldIds" item="oldId" open="(" separator="," close=")">
|
||||||
|
#{oldId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectByRequestToken" parameterType="string" resultMap="ArBillGenerateTaskResult">
|
<select id="selectByRequestToken" parameterType="string" resultMap="ArBillGenerateTaskResult">
|
||||||
<include refid="columns"/>
|
<include refid="columns"/>
|
||||||
where request_token = #{requestToken}
|
where request_token = #{requestToken}
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
-- 应收账单 bigint 字段重命名 v2(MySQL 5.7)
|
||||||
|
-- 适用:三个表已分别存在旧 UUID 字段及 order_id / income_fee_id bigint 字段。
|
||||||
|
-- 将旧 UUID 字段改名为 *_bak,将 bigint 字段改为原业务字段名。
|
||||||
|
-- *_bak 允许 NULL,以便切换后新增账单可以不再写入历史 UUID。
|
||||||
|
-- bigint 字段保持可空;现有字段值、索引及其归属保留,不做数据补齐或映射检查。
|
||||||
|
-- 使用支持 DELIMITER 的客户端执行完整文件;失败后核对报错,再重新运行完整文件。
|
||||||
|
-- MySQL DDL 隐式提交,每张表独立执行;脚本支持已完成表的重跑。
|
||||||
|
-- 成功标识:AR_BIGINT_RENAME_OK。
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
DROP PROCEDURE IF EXISTS mig_ar_bigint_cutover_20261116;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE mig_ar_bigint_cutover_20261116()
|
||||||
|
BEGIN
|
||||||
|
DECLARE v_detail INT DEFAULT 0;
|
||||||
|
DECLARE v_fee INT DEFAULT 0;
|
||||||
|
DECLARE v_task INT DEFAULT 0;
|
||||||
|
DECLARE v_count INT DEFAULT 0;
|
||||||
|
DECLARE v_old_type VARCHAR(64);
|
||||||
|
DECLARE v_old_charset VARCHAR(64);
|
||||||
|
DECLARE v_old_collation VARCHAR(64);
|
||||||
|
DECLARE v_new_type VARCHAR(64);
|
||||||
|
|
||||||
|
-- 先检查三张表的切换状态;只有完整的切换前或切换后结构可以继续。
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail'
|
||||||
|
AND ((column_name='prc_order_bill_id' AND data_type IN ('varchar','char'))
|
||||||
|
OR (column_name='order_id' AND data_type='bigint' AND is_nullable='YES' AND column_default IS NULL));
|
||||||
|
IF v_count=2 THEN
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail' AND column_name='prc_order_bill_id_bak';
|
||||||
|
IF v_count<>0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_detail 已存在备份列,请检查结构'; END IF;
|
||||||
|
SET v_detail=0;
|
||||||
|
ELSE
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail'
|
||||||
|
AND ((column_name='prc_order_bill_id_bak' AND data_type IN ('varchar','char') AND is_nullable='YES')
|
||||||
|
OR (column_name='prc_order_bill_id' AND data_type='bigint' AND is_nullable='YES'));
|
||||||
|
IF v_count<>2 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_detail 字段结构不符合预期'; END IF;
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail' AND column_name='order_id';
|
||||||
|
IF v_count<>0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_detail 切换后仍存在 order_id'; END IF;
|
||||||
|
SET v_detail=1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail_fee'
|
||||||
|
AND ((column_name='prc_income_bill_fee_id' AND data_type IN ('varchar','char'))
|
||||||
|
OR (column_name='income_fee_id' AND data_type='bigint' AND is_nullable='YES' AND column_default IS NULL));
|
||||||
|
IF v_count=2 THEN
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail_fee' AND column_name='prc_income_bill_fee_id_bak';
|
||||||
|
IF v_count<>0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_detail_fee 已存在备份列,请检查结构'; END IF;
|
||||||
|
SET v_fee=0;
|
||||||
|
ELSE
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail_fee'
|
||||||
|
AND ((column_name='prc_income_bill_fee_id_bak' AND data_type IN ('varchar','char') AND is_nullable='YES')
|
||||||
|
OR (column_name='prc_income_bill_fee_id' AND data_type='bigint' AND is_nullable='YES'));
|
||||||
|
IF v_count<>2 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_detail_fee 字段结构不符合预期'; END IF;
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail_fee' AND column_name='income_fee_id';
|
||||||
|
IF v_count<>0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_detail_fee 切换后仍存在 income_fee_id'; END IF;
|
||||||
|
SET v_fee=1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_generate_task'
|
||||||
|
AND ((column_name='last_source_bill_id' AND data_type IN ('varchar','char'))
|
||||||
|
OR (column_name='order_id' AND data_type='bigint' AND is_nullable='YES' AND column_default IS NULL));
|
||||||
|
IF v_count=2 THEN
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_generate_task' AND column_name='last_source_bill_id_bak';
|
||||||
|
IF v_count<>0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_generate_task 已存在备份列,请检查结构'; END IF;
|
||||||
|
SET v_task=0;
|
||||||
|
ELSE
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_generate_task'
|
||||||
|
AND ((column_name='last_source_bill_id_bak' AND data_type IN ('varchar','char') AND is_nullable='YES')
|
||||||
|
OR (column_name='last_source_bill_id' AND data_type='bigint' AND is_nullable='YES'));
|
||||||
|
IF v_count<>2 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_generate_task 字段结构不符合预期'; END IF;
|
||||||
|
SELECT COUNT(*) INTO v_count FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_generate_task' AND column_name='order_id';
|
||||||
|
IF v_count<>0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='ar_bill_generate_task 切换后仍存在 order_id'; END IF;
|
||||||
|
SET v_task=1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- MySQL 5.7 的 CHANGE COLUMN 要求完整类型;从原列读取类型和字符集以保留原结构。
|
||||||
|
IF v_detail=0 THEN
|
||||||
|
SELECT column_type, character_set_name, collation_name INTO v_old_type, v_old_charset, v_old_collation
|
||||||
|
FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='ar_bill_detail' AND column_name='prc_order_bill_id';
|
||||||
|
SELECT column_type INTO v_new_type FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail' AND column_name='order_id';
|
||||||
|
SET @ar_rename_ddl=CONCAT('ALTER TABLE `ar_bill_detail` CHANGE COLUMN `prc_order_bill_id` `prc_order_bill_id_bak` ',
|
||||||
|
v_old_type,' CHARACTER SET `',v_old_charset,'` COLLATE `',v_old_collation,'` DEFAULT NULL COMMENT ''历史来源订单 UUID'', ',
|
||||||
|
'CHANGE COLUMN `order_id` `prc_order_bill_id` ',v_new_type,' DEFAULT NULL COMMENT ''来源计费订单ID''');
|
||||||
|
PREPARE ar_stmt FROM @ar_rename_ddl;
|
||||||
|
EXECUTE ar_stmt;
|
||||||
|
DEALLOCATE PREPARE ar_stmt;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF v_fee=0 THEN
|
||||||
|
SELECT column_type, character_set_name, collation_name INTO v_old_type, v_old_charset, v_old_collation
|
||||||
|
FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='ar_bill_detail_fee' AND column_name='prc_income_bill_fee_id';
|
||||||
|
SELECT column_type INTO v_new_type FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_detail_fee' AND column_name='income_fee_id';
|
||||||
|
SET @ar_rename_ddl=CONCAT('ALTER TABLE `ar_bill_detail_fee` CHANGE COLUMN `prc_income_bill_fee_id` `prc_income_bill_fee_id_bak` ',
|
||||||
|
v_old_type,' CHARACTER SET `',v_old_charset,'` COLLATE `',v_old_collation,'` DEFAULT NULL COMMENT ''历史来源费用 UUID'', ',
|
||||||
|
'CHANGE COLUMN `income_fee_id` `prc_income_bill_fee_id` ',v_new_type,' DEFAULT NULL COMMENT ''来源收入费用ID''');
|
||||||
|
PREPARE ar_stmt FROM @ar_rename_ddl;
|
||||||
|
EXECUTE ar_stmt;
|
||||||
|
DEALLOCATE PREPARE ar_stmt;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF v_task=0 THEN
|
||||||
|
SELECT column_type, character_set_name, collation_name INTO v_old_type, v_old_charset, v_old_collation
|
||||||
|
FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='ar_bill_generate_task' AND column_name='last_source_bill_id';
|
||||||
|
SELECT column_type INTO v_new_type FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ar_bill_generate_task' AND column_name='order_id';
|
||||||
|
SET @ar_rename_ddl=CONCAT('ALTER TABLE `ar_bill_generate_task` CHANGE COLUMN `last_source_bill_id` `last_source_bill_id_bak` ',
|
||||||
|
v_old_type,' CHARACTER SET `',v_old_charset,'` COLLATE `',v_old_collation,'` DEFAULT NULL COMMENT ''历史来源订单游标 UUID'', ',
|
||||||
|
'CHANGE COLUMN `order_id` `last_source_bill_id` ',v_new_type,' DEFAULT NULL COMMENT ''来源订单游标''');
|
||||||
|
PREPARE ar_stmt FROM @ar_rename_ddl;
|
||||||
|
EXECUTE ar_stmt;
|
||||||
|
DEALLOCATE PREPARE ar_stmt;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT 'AR_BIGINT_RENAME_OK' AS result;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
CALL mig_ar_bigint_cutover_20261116();
|
||||||
@@ -364,7 +364,7 @@ function buildGenerateRequest(requestId) {
|
|||||||
...(previewQuery.value || buildGenerateQuery()),
|
...(previewQuery.value || buildGenerateQuery()),
|
||||||
billName: billNameForm.billName.trim(),
|
billName: billNameForm.billName.trim(),
|
||||||
selectionMode: selectionMode.value,
|
selectionMode: selectionMode.value,
|
||||||
sourceBillIds: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED ? [] : selectedRows.value.map(row => row.billId),
|
sourceBillIds: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED ? [] : selectedRows.value.map(row => String(row.billId)),
|
||||||
excludedSourceBillIds: [],
|
excludedSourceBillIds: [],
|
||||||
excludedOrderOrTrackingNo: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED
|
excludedOrderOrTrackingNo: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED
|
||||||
? confirmedExcludeKeyword.value || undefined : undefined,
|
? confirmedExcludeKeyword.value || undefined : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user