|
|
@@ -0,0 +1,114 @@
|
|
|
+package com.malk.eastar.schedule;
|
|
|
+
|
|
|
+import com.malk.eastar.service.AitableService;
|
|
|
+import com.malk.eastar.service.DDCoreClient;
|
|
|
+import com.malk.eastar.service.YidaService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 新的定时任务
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Configuration
|
|
|
+@EnableScheduling
|
|
|
+@ConditionalOnProperty(name = {"enable.scheduling"})
|
|
|
+public class ScheduleTask4 {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YidaService yidaService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AitableService aitableService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DDCoreClient ddCoreClient;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找易思达系统和项目总表中业务员不一致的客户
|
|
|
+ */
|
|
|
+// @Scheduled(cron = "0 42 11 * * ?")
|
|
|
+ public void syncCustomerBusinessUser20260708() {
|
|
|
+ /*
|
|
|
+ 查询(易思达)客户名册所有记录
|
|
|
+ */
|
|
|
+ log.info("查询(易思达)客户名册所有记录");
|
|
|
+ List<Map> ltcCustomerData = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ ltcCustomerData = yidaService.queryLtcAllCustomerData();
|
|
|
+ log.info("易思达系统客户数量="+ltcCustomerData.size());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询(易思达)客户名册异常",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 从项目总表(系统1)获取客户数据
|
|
|
+ */
|
|
|
+ log.info("查询项目总表客户名册所有记录");
|
|
|
+ List<Map> sys1CustomerData = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ sys1CustomerData = aitableService.querySys1CustomerData();
|
|
|
+ log.info("项目总表客户数量="+sys1CustomerData.size());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询项目总表客户数据异常",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 找到业务员不一致的客户
|
|
|
+ */
|
|
|
+ boolean isExist = false; //是否存在
|
|
|
+ boolean isTest = false; //是否测试使用
|
|
|
+ boolean isNotMatch = false; //是否不一致
|
|
|
+ String businessUserId1;
|
|
|
+ Object businessUserUnionId;
|
|
|
+ String businessUserId2;
|
|
|
+ for(Map<String,String> ltcCustomer : ltcCustomerData){
|
|
|
+ isExist = false;
|
|
|
+ isTest = false;
|
|
|
+ isNotMatch = false;
|
|
|
+ businessUserId1 = null;
|
|
|
+ businessUserId2 = null;
|
|
|
+ for (int i = 0; i < sys1CustomerData.size(); i++) {
|
|
|
+ if(ltcCustomer.get("aiTableId").equals(sys1CustomerData.get(i).get("aiTableId"))){
|
|
|
+ isExist = true;
|
|
|
+ if(ltcCustomer.get("testUseFlag").equals("是")){
|
|
|
+ isTest = true;
|
|
|
+ }else{
|
|
|
+ businessUserId1 = ltcCustomer.get("userId");
|
|
|
+ businessUserUnionId = sys1CustomerData.get(i).get("businessUserUnionId");
|
|
|
+ if (businessUserUnionId != null) {
|
|
|
+ try {
|
|
|
+ businessUserId2 = ddCoreClient.getUserIdByUnionId(businessUserUnionId.toString());
|
|
|
+ if(businessUserId2.isEmpty()){
|
|
|
+ //忽略
|
|
|
+ }else{
|
|
|
+ if(!businessUserId1.equals(businessUserId2)){
|
|
|
+ //不一致
|
|
|
+ isNotMatch = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("没有找到业务员unionId["+businessUserUnionId+"]对应的userId");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isExist&&!isTest&&isNotMatch){
|
|
|
+ System.out.println(ltcCustomer.get("customerName")+" "+businessUserId1+" "+businessUserId2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|