mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 11:19:52 +08:00
Merge branch 'dev' of https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web into dev
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -34,3 +34,6 @@ build/
|
|||||||
.mvn/
|
.mvn/
|
||||||
/.claude/
|
/.claude/
|
||||||
.ace-tool/
|
.ace-tool/
|
||||||
|
opt/app/spring/logs/sys-error.log
|
||||||
|
opt/app/spring/logs/sys-info.log
|
||||||
|
opt/app/spring/logs/sys-user.log
|
||||||
|
|||||||
92070
docs/万车充小程序-未分账明细20260526.csv
Normal file
92070
docs/万车充小程序-未分账明细20260526.csv
Normal file
File diff suppressed because it is too large
Load Diff
@@ -35,5 +35,7 @@ public interface AdapayUnsplitRecordMapper {
|
|||||||
|
|
||||||
List<AdapayUnsplitRecord> queryUnsplitOrders(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
List<AdapayUnsplitRecord> queryUnsplitOrders(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||||
|
|
||||||
|
List<AdapayUnsplitRecord> selectByPaymentIds(@Param("list") List<String> paymentIds);
|
||||||
|
|
||||||
List<AdapayUnsplitRecordVO> queryList();
|
List<AdapayUnsplitRecordVO> queryList();
|
||||||
}
|
}
|
||||||
@@ -32,5 +32,7 @@ public interface AdapayUnsplitRecordService{
|
|||||||
|
|
||||||
List<AdapayUnsplitRecord> queryUnsplitOrders(String startTime, String endTime);
|
List<AdapayUnsplitRecord> queryUnsplitOrders(String startTime, String endTime);
|
||||||
|
|
||||||
|
List<AdapayUnsplitRecord> selectByPaymentIds(List<String> paymentIds);
|
||||||
|
|
||||||
List<AdapayUnsplitRecordVO> queryList();
|
List<AdapayUnsplitRecordVO> queryList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,14 @@ public class AdapayUnsplitRecordServiceImpl implements AdapayUnsplitRecordServic
|
|||||||
return adapayUnsplitRecordMapper.queryUnsplitOrders(startTime, endTime);
|
return adapayUnsplitRecordMapper.queryUnsplitOrders(startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AdapayUnsplitRecord> selectByPaymentIds(List<String> paymentIds) {
|
||||||
|
if (paymentIds == null || paymentIds.isEmpty()) {
|
||||||
|
return java.util.Collections.emptyList();
|
||||||
|
}
|
||||||
|
return adapayUnsplitRecordMapper.selectByPaymentIds(paymentIds);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AdapayUnsplitRecordVO> queryList() {
|
public List<AdapayUnsplitRecordVO> queryList() {
|
||||||
return adapayUnsplitRecordMapper.queryList();
|
return adapayUnsplitRecordMapper.queryList();
|
||||||
|
|||||||
@@ -733,6 +733,16 @@
|
|||||||
<!--and order_code like 'C%'-->
|
<!--and order_code like 'C%'-->
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByPaymentIds" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from adapay_unsplit_record
|
||||||
|
where payment_id in
|
||||||
|
<foreach close=")" collection="list" item="item" open="(" separator=",">
|
||||||
|
#{item,jdbcType=VARCHAR}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="queryList" resultType="com.jsowell.pile.vo.AdapayUnsplitRecordVO">
|
<select id="queryList" resultType="com.jsowell.pile.vo.AdapayUnsplitRecordVO">
|
||||||
SELECT
|
SELECT
|
||||||
order_code as orderCode,
|
order_code as orderCode,
|
||||||
|
|||||||
@@ -632,7 +632,8 @@ public class JsowellTask {
|
|||||||
* 从Excel导入adapay_unsplit_record,并补齐缺失字段
|
* 从Excel导入adapay_unsplit_record,并补齐缺失字段
|
||||||
* 流程:
|
* 流程:
|
||||||
* 1. 校验文件路径(相对路径自动拼接工作目录转为绝对路径)
|
* 1. 校验文件路径(相对路径自动拼接工作目录转为绝对路径)
|
||||||
* 2. 解析Excel,逐行转换为 AdapayUnsplitRecord,调用 insertOrUpdateSelective 写入数据库
|
* 2. 解析Excel,逐行转换为 AdapayUnsplitRecord;
|
||||||
|
* 以 paymentId 为业务唯一键,已存在则按主键更新,不存在则新增
|
||||||
* 3. 以导入数据的支付时间范围为条件,分页查询已入库记录,补齐 orderCode/退款金额/结算金额/桩类型等缺失字段
|
* 3. 以导入数据的支付时间范围为条件,分页查询已入库记录,补齐 orderCode/退款金额/结算金额/桩类型等缺失字段
|
||||||
* jsowellTask.importAdapayUnsplitRecordAndCompleteFields(文件路径)
|
* jsowellTask.importAdapayUnsplitRecordAndCompleteFields(文件路径)
|
||||||
*/
|
*/
|
||||||
@@ -721,7 +722,7 @@ public class JsowellTask {
|
|||||||
|
|
||||||
// 达到批量大小时执行一次批量写入
|
// 达到批量大小时执行一次批量写入
|
||||||
if (batch.size() >= IMPORT_BATCH_SIZE) {
|
if (batch.size() >= IMPORT_BATCH_SIZE) {
|
||||||
adapayUnsplitRecordService.batchInsertOrUpdateSelective(batch);
|
flushImportBatch(batch);
|
||||||
summary.successRows += batch.size();
|
summary.successRows += batch.size();
|
||||||
batch.clear();
|
batch.clear();
|
||||||
}
|
}
|
||||||
@@ -737,7 +738,7 @@ public class JsowellTask {
|
|||||||
}
|
}
|
||||||
// 处理剩余不足一批的记录
|
// 处理剩余不足一批的记录
|
||||||
if (!batch.isEmpty()) {
|
if (!batch.isEmpty()) {
|
||||||
adapayUnsplitRecordService.batchInsertOrUpdateSelective(batch);
|
flushImportBatch(batch);
|
||||||
summary.successRows += batch.size();
|
summary.successRows += batch.size();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -747,6 +748,57 @@ public class JsowellTask {
|
|||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写入一批导入数据:以 paymentId 为业务唯一键,
|
||||||
|
* - 数据库已存在相同 paymentId 的记录 -> 沿用其主键 id 走 updateBatchSelective 更新
|
||||||
|
* - 数据库不存在的 -> 走 batchInsert 新增
|
||||||
|
* 同一批内若出现重复 paymentId,仅保留最后一条(与文件读取顺序一致)
|
||||||
|
*/
|
||||||
|
private void flushImportBatch(List<AdapayUnsplitRecord> batch) {
|
||||||
|
if (CollectionUtils.isEmpty(batch)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同批内按 paymentId 去重,保留最后一条
|
||||||
|
Map<String, AdapayUnsplitRecord> uniqueByPaymentId = new LinkedHashMap<>();
|
||||||
|
for (AdapayUnsplitRecord record : batch) {
|
||||||
|
if (StringUtils.isNotBlank(record.getPaymentId())) {
|
||||||
|
uniqueByPaymentId.put(record.getPaymentId(), record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uniqueByPaymentId.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> paymentIds = new ArrayList<>(uniqueByPaymentId.keySet());
|
||||||
|
List<AdapayUnsplitRecord> existingList = adapayUnsplitRecordService.selectByPaymentIds(paymentIds);
|
||||||
|
Map<String, Integer> existingIdMap = new HashMap<>();
|
||||||
|
if (CollectionUtils.isNotEmpty(existingList)) {
|
||||||
|
for (AdapayUnsplitRecord existing : existingList) {
|
||||||
|
existingIdMap.put(existing.getPaymentId(), existing.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AdapayUnsplitRecord> insertList = new ArrayList<>();
|
||||||
|
List<AdapayUnsplitRecord> updateList = new ArrayList<>();
|
||||||
|
for (AdapayUnsplitRecord record : uniqueByPaymentId.values()) {
|
||||||
|
Integer existingId = existingIdMap.get(record.getPaymentId());
|
||||||
|
if (existingId != null) {
|
||||||
|
record.setId(existingId);
|
||||||
|
updateList.add(record);
|
||||||
|
} else {
|
||||||
|
insertList.add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!insertList.isEmpty()) {
|
||||||
|
adapayUnsplitRecordService.batchInsert(insertList);
|
||||||
|
}
|
||||||
|
if (!updateList.isEmpty()) {
|
||||||
|
adapayUnsplitRecordService.updateBatchSelective(updateList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int completeUnsplitRecordMissingFields(String startTime, String endTime, int pageSize) {
|
private int completeUnsplitRecordMissingFields(String startTime, String endTime, int pageSize) {
|
||||||
int pageNum = 1;
|
int pageNum = 1;
|
||||||
int updatedCount = 0;
|
int updatedCount = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user