✅ 金蝶客商定时同步补充执行日志并新增手动触发测试类
This commit is contained in:
@@ -47,6 +47,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
|
||||
-10
@@ -193,16 +193,6 @@ public class CustomerArchiveController extends BladeController {
|
||||
return R.data(customerArchiveService.syncKingdee(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 金蝶客商数据定时同步测试入口:手动触发 syncKingdeeCustomerData 定时任务逻辑,便于联调验证
|
||||
*/
|
||||
@PostMapping("/sync-kingdee-data-test")
|
||||
@ApiOperationSupport(order = 13)
|
||||
@Operation(summary = "金蝶客商数据同步测试", description = "手动触发定时任务逻辑:自动推送待推送客商(approved 且 none/failed),并联动已同步客商的金蝶使用状态")
|
||||
public R<String> syncKingdeeCustomerDataTest() {
|
||||
return R.data(customerArchiveService.syncKingdeeCustomerData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 评分明细模板
|
||||
*/
|
||||
|
||||
+16
-4
@@ -37,7 +37,7 @@ import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.system.pojo.entity.UserCustomerScope;
|
||||
import org.springblade.thirdparty.bfi.constant.BfiConstant;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiCustomerQueryDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiBillSaveResultErrorVO;
|
||||
@@ -76,17 +76,16 @@ import org.springblade.transport.pojo.entity.CustomerInvoiceContact;
|
||||
import org.springblade.transport.pojo.entity.CustomerInvoiceInfo;
|
||||
import org.springblade.transport.pojo.entity.CustomerReceiptAccount;
|
||||
import org.springblade.transport.pojo.entity.PaymentApplication;
|
||||
import org.springblade.transport.pojo.vo.CreditRatingStandardVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerArchiveVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerChangeRecordVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerContactVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerCreditScoreDetailVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerCreditScoreVO;
|
||||
import org.springblade.transport.pojo.vo.CreditRatingStandardVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerInvoiceContactVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerInvoiceInfoVO;
|
||||
import org.springblade.transport.pojo.vo.CustomerReceiptAccountVO;
|
||||
import org.springblade.transport.service.ICustomerArchiveService;
|
||||
import org.springblade.system.pojo.entity.UserCustomerScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -456,11 +455,13 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
|
||||
@Override
|
||||
public String syncKingdeeCustomerData() {
|
||||
log.info("金蝶客商数据定时同步开始");
|
||||
// ① 待推送客商:审批通过且未推送/推送失败,复用单条推送(A902-1 复查 + A902-2 保存),单条失败不中断批次
|
||||
List<CustomerArchive> pendingList = list(Wrappers.<CustomerArchive>lambdaQuery()
|
||||
.eq(CustomerArchive::getApprovalStatus, APPROVAL_APPROVED)
|
||||
.in(CustomerArchive::getKingdeeStatus, KINGDEE_STATUS_NONE, KINGDEE_STATUS_FAILED)
|
||||
.orderByAsc(CustomerArchive::getId));
|
||||
log.info("金蝶客商数据定时同步查询到待推送客商 {} 条", pendingList.size());
|
||||
ICustomerArchiveService proxy = self();
|
||||
int pushed = 0;
|
||||
int existed = 0;
|
||||
@@ -470,10 +471,16 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
CustomerArchive after = proxy.syncKingdee(customer.getId());
|
||||
if (Objects.equals(after.getKingdeeStatus(), KINGDEE_STATUS_SYNCED)) {
|
||||
pushed++;
|
||||
log.info("金蝶客商数据定时同步推送成功,id={},unifiedCreditCode={}",
|
||||
customer.getId(), customer.getUnifiedCreditCode());
|
||||
} else if (Objects.equals(after.getKingdeeStatus(), KINGDEE_STATUS_EXIST)) {
|
||||
existed++;
|
||||
log.info("金蝶客商数据定时同步金蝶已有档案跳过推送,id={},unifiedCreditCode={}",
|
||||
customer.getId(), customer.getUnifiedCreditCode());
|
||||
} else {
|
||||
pushFailed++;
|
||||
log.warn("金蝶客商数据定时同步推送失败,id={},unifiedCreditCode={},kingdeeStatus={},failReason={}",
|
||||
customer.getId(), customer.getUnifiedCreditCode(), after.getKingdeeStatus(), after.getKingdeeFailReason());
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
pushFailed++;
|
||||
@@ -490,6 +497,7 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
int disabled = 0;
|
||||
int disableFailed = 0;
|
||||
if (!enabledList.isEmpty()) {
|
||||
log.info("金蝶客商数据定时同步查询到已同步可用客商 {} 条,开始联动金蝶使用状态", enabledList.size());
|
||||
List<String> creditCodes = enabledList.stream()
|
||||
.map(CustomerArchive::getUnifiedCreditCode)
|
||||
.filter(Func::isNotEmpty)
|
||||
@@ -505,6 +513,8 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
try {
|
||||
if (proxy.disableCustomerFromKingdee(customer.getId())) {
|
||||
disabled++;
|
||||
log.info("金蝶侧客商已停用,联动停用客商档案成功,id={},unifiedCreditCode={}",
|
||||
customer.getId(), customer.getUnifiedCreditCode());
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
disableFailed++;
|
||||
@@ -513,8 +523,10 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
}
|
||||
}
|
||||
}
|
||||
return "待推送 " + pendingList.size() + " 条(推送成功 " + pushed + ",金蝶已有 " + existed
|
||||
String summary = "待推送 " + pendingList.size() + " 条(推送成功 " + pushed + ",金蝶已有 " + existed
|
||||
+ ",失败 " + pushFailed + "),停用联动 " + disabled + " 条(失败 " + disableFailed + ")";
|
||||
log.info("金蝶客商数据定时同步结束:{}", summary);
|
||||
return summary;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.transport;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springblade.transport.service.ICustomerArchiveService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* 客商档案金蝶客商数据定时同步测试:手动触发 syncKingdeeCustomerData 定时任务逻辑
|
||||
* <p>
|
||||
* 依赖本地环境(Nacos / 数据库 / Redis),需先启动对应中间件再执行;
|
||||
* 该逻辑与定时任务 CustomerKingdeeSyncTask 共用,开关默认关闭时可通过本测试手动触发联调。
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@SpringBootTest(classes = TransportApplication.class, properties = {
|
||||
"spring.profiles.active=dev",
|
||||
"spring.main.allow-bean-definition-overriding=true"
|
||||
})
|
||||
class CustomerArchiveSyncKingdeeDataTest {
|
||||
|
||||
@Autowired
|
||||
private ICustomerArchiveService customerArchiveService;
|
||||
|
||||
@Test
|
||||
void syncKingdeeCustomerData() {
|
||||
String result = customerArchiveService.syncKingdeeCustomerData();
|
||||
System.out.println("金蝶客商数据定时同步执行结果:" + result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user