|
|
@@ -5,6 +5,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.u9cloud.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -22,8 +23,40 @@ import java.util.function.Supplier;
|
|
|
public class U9CloudTaskJob {
|
|
|
|
|
|
// 注入Feign客户端
|
|
|
+// @Autowired
|
|
|
+// private U9CloudFeignClient u9CloudFeignClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewCustomerSelService zcrmViewCustomerSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewDepartmentSelService zcrmViewDepartmentSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewItemSelService zcrmViewItemSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewOperatorsSelService zcrmViewOperatorsSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewShipSelService zcrmViewShipSelService;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private U9CloudFeignClient u9CloudFeignClient;
|
|
|
+ private final ZcrmViewSupplierSelService zcrmViewSupplierSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewWhqohSelService zcrmViewWhqohSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewSalePriceSelService zcrmViewSalePriceSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewRecBillHeadSelService zcrmViewRecBillHeadSelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final ZcrmViewARBillHeadSelService zcrmViewARBillHeadSelService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 同步客户数据(单独任务)
|
|
|
@@ -31,11 +64,12 @@ public class U9CloudTaskJob {
|
|
|
@XxlJob("syncCustomerDataHandler")
|
|
|
public ReturnT<String> syncCustomerData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行客户数据同步任务,参数: {}", param);
|
|
|
+ System.err.println("XXL-JOB: 开始执行客户数据同步任务");
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncCustomerData(),
|
|
|
- "客户数据"
|
|
|
- );
|
|
|
+ boolean res1 = zcrmViewCustomerSelService.insertBatchCustomers();
|
|
|
+ if (!res1) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 客户数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -52,10 +86,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncDepartmentData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行部门数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncDepartmentData(),
|
|
|
- "部门数据"
|
|
|
- );
|
|
|
+ boolean res2 = zcrmViewDepartmentSelService.insertBatchDepartments();
|
|
|
+ if (!res2) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 部门数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -72,10 +106,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncItemData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行物料数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncItemData(),
|
|
|
- "物料数据"
|
|
|
- );
|
|
|
+ boolean res3 = zcrmViewItemSelService.insertBatchItems();
|
|
|
+ if (!res3) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 物料数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -92,10 +126,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncOperatorsData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行操作员数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncOperatorsData(),
|
|
|
- "操作员数据"
|
|
|
- );
|
|
|
+ boolean res4 = zcrmViewOperatorsSelService.insertBatchOperators();
|
|
|
+ if (!res4) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 操作员数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -112,10 +146,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncShipData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行物流数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncShipData(),
|
|
|
- "物流数据"
|
|
|
- );
|
|
|
+ boolean res5 = zcrmViewShipSelService.insertBatchShips();
|
|
|
+ if (!res5) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 物流数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -133,10 +167,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncSupplierData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行供应商数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncSupplierData(),
|
|
|
- "供应商数据"
|
|
|
- );
|
|
|
+ boolean res6 = zcrmViewSupplierSelService.insertBatchSuppliers();
|
|
|
+ if (!res6) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 供应商数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -153,10 +187,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncWhqohData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行库存数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncWhqohData(),
|
|
|
- "库存数据" // 修复了这里的注释,原来是"部门数据"
|
|
|
- );
|
|
|
+ boolean res7 = zcrmViewWhqohSelService.insertBatchWhqohs();
|
|
|
+ if (!res7) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 库存数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -174,10 +208,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncARBillData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行应收单数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncARBillData(),
|
|
|
- "应收单数据" // 修复了这里的注释,原来是"部门数据"
|
|
|
- );
|
|
|
+ boolean res8 = zcrmViewARBillHeadSelService.insertBatchCustomers();
|
|
|
+ if (!res8) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 应收单数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -194,10 +228,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncRecBillData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行收款单数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncRecBillData(),
|
|
|
- "收款单数据"
|
|
|
- );
|
|
|
+ boolean res9 = zcrmViewRecBillHeadSelService.insertBatchOperators();
|
|
|
+ if (!res9) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 收款单数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -214,10 +248,10 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncSalepriceData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: 开始执行销售价目表数据同步任务,参数: {}", param);
|
|
|
try {
|
|
|
- executeSyncTask(
|
|
|
- () -> u9CloudFeignClient.syncSalepriceData(),
|
|
|
- "销售价目表数据"
|
|
|
- );
|
|
|
+ boolean res10 = zcrmViewSalePriceSelService.insertBatchOperators();
|
|
|
+ if (!res10) {
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
log.info("XXL-JOB: 销售价目表数据同步任务执行完成");
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e)
|
|
|
@@ -234,43 +268,67 @@ public class U9CloudTaskJob {
|
|
|
public ReturnT<String> syncAllData(String param) throws Exception {
|
|
|
log.info("XXL-JOB: ===== 开始执行U9数据完整同步,参数: {} =====", param);
|
|
|
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
-
|
|
|
try {
|
|
|
- // 按业务顺序执行同步
|
|
|
- log.info("XXL-JOB: 开始同步部门数据");
|
|
|
- syncDepartmentData(null);
|
|
|
-
|
|
|
- log.info("XXL-JOB: 开始同步客户数据");
|
|
|
- syncCustomerData(null);
|
|
|
+ // 1. 执行各服务的数据同步方法,任一方法返回false则抛出异常触发回滚
|
|
|
+ boolean res1 = zcrmViewCustomerSelService.insertBatchCustomers();
|
|
|
+ if (!res1) {
|
|
|
+ System.out.println("客户数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步物料数据");
|
|
|
- syncItemData(null);
|
|
|
+ boolean res2 = zcrmViewDepartmentSelService.insertBatchDepartments();
|
|
|
+ if (!res2) {
|
|
|
+ System.out.println("部门数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步操作员数据");
|
|
|
- syncOperatorsData(null);
|
|
|
+ boolean res3 = zcrmViewItemSelService.insertBatchItems();
|
|
|
+ if (!res3) {
|
|
|
+ System.out.println("物料数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步供应商数据");
|
|
|
- syncSupplierData(null);
|
|
|
+ boolean res4 = zcrmViewOperatorsSelService.insertBatchOperators();
|
|
|
+ if (!res4) {
|
|
|
+ System.out.println("操作员数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步物流数据");
|
|
|
- syncShipData(null);
|
|
|
+ boolean res5 = zcrmViewShipSelService.insertBatchShips();
|
|
|
+ if (!res5) {
|
|
|
+ System.out.println("物流数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步库存数据");
|
|
|
- syncWhqohData(null);
|
|
|
+ boolean res6 = zcrmViewSupplierSelService.insertBatchSuppliers();
|
|
|
+ if (!res6) {
|
|
|
+ System.out.println("供应商数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步应收单数据");
|
|
|
- syncARBillData(null);
|
|
|
+ boolean res7 = zcrmViewWhqohSelService.insertBatchWhqohs();
|
|
|
+ if (!res7) {
|
|
|
+ System.out.println("库存数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步收款单数据");
|
|
|
- syncRecBillData(null);
|
|
|
+ boolean res8 = zcrmViewARBillHeadSelService.insertBatchCustomers();
|
|
|
+ if (!res8) {
|
|
|
+ System.out.println("应收单数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- log.info("XXL-JOB: 开始同步销售价目表数据");
|
|
|
- syncSalepriceData(null);
|
|
|
+ boolean res9 = zcrmViewRecBillHeadSelService.insertBatchOperators();
|
|
|
+ if (!res9) {
|
|
|
+ System.out.println("收款单数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
- String successMsg = String.format("XXL-JOB: ===== U9数据完整同步完成,耗时:%s ms =====", (endTime - startTime));
|
|
|
- log.info(successMsg);
|
|
|
+ boolean res10 = zcrmViewSalePriceSelService.insertBatchOperators();
|
|
|
+ if (!res10) {
|
|
|
+ System.out.println("销售价目表数据批量插入失败");
|
|
|
+ return ReturnT.FAIL;
|
|
|
+ }
|
|
|
|
|
|
return ReturnT.SUCCESS;
|
|
|
} catch (Exception e) {
|