lvjs дней назад: 3
Родитель
Сommit
d047edf21f

+ 129 - 0
src/main/java/com/malk/eastar/schedule/ScheduleTask2.java

@@ -34,6 +34,135 @@ public class ScheduleTask2 {
     private YidaService yidaService;
 
 
+    /**
+     * 易思达系统客户数据清洗
+     * 已离职业务员的私海客户退回公海
+     */
+//    @Scheduled(cron = "0 10 16 * * ?")
+    public void cleanCustomerData20260730() {
+        log.info("已离职业务员的私海客户退回公海任务开始");
+        /*
+            查询易思达系统所有业务员档案
+         */
+        log.info("查询易思达系统所有业务员档案");
+        List<Map> ltcBusinessUserData = new ArrayList<>();
+        List<String> userIdList = new ArrayList<>();
+        String employmentStatus;    //在职情况
+        try {
+            ltcBusinessUserData = yidaService.queryLtcAllBusinessUserData();
+            log.info("所有业务员档案数量="+ltcBusinessUserData.size());
+            log.info("未在职业务员:");
+            for (Map ltcBusinessUserRecord : ltcBusinessUserData){
+                employmentStatus = ltcBusinessUserRecord.get("employmentStatus").toString();
+                if ("在职".equals(employmentStatus)){
+                    userIdList.add(ltcBusinessUserRecord.get("userId").toString());
+                }else{
+                    System.out.println(ltcBusinessUserRecord.get("businessUserName").toString()+":"+ltcBusinessUserRecord.get("userId").toString());
+                }
+            }
+        } catch (Exception e) {
+            log.error("查询所有业务员档案异常",e);
+        }
+
+        /*
+            查询易思达系统所有客户记录
+         */
+        log.info("查询易思达系统所有客户记录");
+        List<Map> ltcCustomerData = new ArrayList<>();
+        try {
+            ltcCustomerData = yidaService.queryLtcAllCustomerData();
+            log.info("所有客户记录数量="+ltcCustomerData.size());
+        } catch (Exception e) {
+            log.error("查询易思达系统所有客户记录异常",e);
+        }
+
+        /*
+            筛选所有未在职业务员的客户,并按业务员ID进行分组
+         */
+        log.info("筛选所有未在职业务员的客户,并按业务员ID进行分组");
+        String businessUserId;
+        String seaType; //公海/私海
+        String testUseFlag; //测试使用
+        Map<String, List<Map>> leaveBusinessUserCustomersMap = new HashMap<>();
+        List<Map> customers = new ArrayList<>();
+        for (Map ltcCustomerRecord : ltcCustomerData){
+            testUseFlag = "";
+            if(ltcCustomerRecord.get("testUseFlag") != null){
+                testUseFlag = ltcCustomerRecord.get("testUseFlag").toString();
+            }
+            if(!"否".equals(testUseFlag)){
+                //忽略测试使用的客户
+                continue;
+            }
+            seaType = "";
+            if(ltcCustomerRecord.get("seaType") != null){
+                seaType = ltcCustomerRecord.get("seaType").toString();
+            }
+            if(!"私".equals(seaType)){
+                //忽略非私海客户
+                continue;
+            }
+            businessUserId = ltcCustomerRecord.get("userId").toString();
+            if (!userIdList.contains(businessUserId)){
+                if(leaveBusinessUserCustomersMap.containsKey(businessUserId)){
+                    customers = leaveBusinessUserCustomersMap.get(businessUserId);
+                }else{
+                    customers = new ArrayList<>();
+                }
+                customers.add(ltcCustomerRecord);
+                leaveBusinessUserCustomersMap.put(businessUserId, customers);
+            }
+        }
+
+        /*
+            退回公海
+         */
+        String businessUserName;
+        String formInstId;
+        int numOfPrivateCustomer;
+        for (String userId : leaveBusinessUserCustomersMap.keySet()){
+            businessUserName = "";
+            try {
+                businessUserName = ddCoreClient.getNameByUserId(userId);
+            } catch (Exception e) {
+                businessUserName = "未知";
+            }
+            System.out.println("未在职业务员:" + businessUserName + " " + userId);
+            customers = leaveBusinessUserCustomersMap.get(userId);
+            System.out.println("私海客户数量=" + customers.size());
+            for (Map customer : customers){
+                try {
+                    System.out.println("退回公海客户:"+customer.get("customerName").toString());
+                    formInstId = customer.get("formInstId").toString();
+                    yidaService.updateLtcCustomerBackToPublicSea(formInstId);
+                } catch (Exception e) {
+                    log.error("退回公海异常",e);
+                }
+            }
+            System.out.println("更新各业务员私海客户数量");
+            numOfPrivateCustomer = 0;
+            try {
+                for (Map ltcBusinessUserRecord : ltcBusinessUserData){
+                    if(userId.equals(ltcBusinessUserRecord.get("userId").toString())){
+                        formInstId = ltcBusinessUserRecord.get("formInstId").toString();
+                        if(ltcBusinessUserRecord.get("numOfPrivateCustomer") != null){
+                            numOfPrivateCustomer = Integer.parseInt(ltcBusinessUserRecord.get("numOfPrivateCustomer").toString());
+                        }
+                        System.out.println("退回公海前私海客户数量:" + numOfPrivateCustomer);
+                        numOfPrivateCustomer = numOfPrivateCustomer - customers.size();
+                        System.out.println("退回公海后私海客户数量:" + numOfPrivateCustomer);
+                        yidaService.updateLtcBusinessUserPrivateCustomerNum(formInstId, numOfPrivateCustomer);
+                        break;
+                    }
+                }
+            } catch (Exception e) {
+                log.error("更新各业务员私海客户数量异常",e);
+            }
+
+        }
+
+        log.info("已离职业务员的私海客户退回公海任务完成");
+    }
 
 
 

+ 0 - 100
src/main/java/com/malk/eastar/schedule/ScheduleTask4.java

@@ -41,106 +41,6 @@ public class ScheduleTask4 {
     @Autowired
     private DDCoreClient ddCoreClient;
 
-    /**
-     * 清洗业务员档案(私海客户数量)数据
-     */
-//    @Scheduled(cron = "0 24 17 * * ?")
-    public void cleanBusinessUserPrivateCustomerNum20260728() {
-        log.info("清洗业务员档案(私海客户数量)数据开始");
-
-        /*
-            查询(易思达)客户名册所有记录
-         */
-        log.info("查询(易思达)客户名册所有记录");
-        List<Map> ltcCustomerData = new ArrayList<>();
-        try {
-            ltcCustomerData = yidaService.queryLtcAllCustomerData();
-            log.info("易思达系统客户数量="+ltcCustomerData.size());
-        } catch (Exception e) {
-            log.error("查询(易思达)客户名册异常",e);
-        }
-
-        /*
-            查询(易思达)业务员档案所有记录
-         */
-        List<Map> ltcBusinessUserData = new ArrayList<>();
-        try {
-            ltcBusinessUserData = yidaService.queryLtcAllBusinessUserData();
-            log.info("易思达系统业务员数量="+ltcBusinessUserData.size());
-        } catch (Exception e) {
-            log.error("查询业务员档案中的成员信息异常",e);
-        }
-
-        /*
-            1、匹配客户名册表业务员与业务员档案表业务员
-            2、统计私海客户数量
-         */
-        boolean isMatch;
-        Map<String, Integer> privateCustomerNumMap = new HashMap<>();
-        String businessUserId;
-        for(Map ltcCustomerRecord : ltcCustomerData){
-            try {
-                if(ltcCustomerRecord.get("testUseFlag").equals("否")){ //正式使用客户
-                    if(ltcCustomerRecord.get("userId") != null && StringUtils.isNotEmpty(ltcCustomerRecord.get("userId").toString())){
-                        isMatch = false;
-                        businessUserId = ltcCustomerRecord.get("userId").toString();
-                        for (int i = 0; i < ltcBusinessUserData.size(); i++) {
-                            if(ltcBusinessUserData.get(i).get("userId").equals(businessUserId)){
-                                isMatch = true;
-                                break;
-                            }
-                        }
-                        if(isMatch){
-                            if(privateCustomerNumMap.containsKey(businessUserId)){
-                                privateCustomerNumMap.put(businessUserId, privateCustomerNumMap.get(businessUserId) + 1);
-                            }else{
-                                privateCustomerNumMap.put(businessUserId, 1);
-                            }
-                        }else{
-                            System.out.println("未匹配到业务员:" + businessUserId + " " + ddCoreClient.getNameByUserId(businessUserId));
-                        }
-                    }
-                }
-            } catch (Exception e) {
-                log.error("匹配客户名册表业务员与业务员档案表业务员异常",e);
-            }
-        }
-
-        /*
-            更新各业务员私海客户数量
-         */
-        String formInstId;
-        String businessUserName;
-        int numOfPrivateCustomer;
-        for (Map.Entry<String, Integer> entry : privateCustomerNumMap.entrySet()) {
-            businessUserId = entry.getKey();
-            numOfPrivateCustomer = entry.getValue();
-            try {
-                businessUserName = ddCoreClient.getNameByUserId(businessUserId);
-                if(businessUserName != null){
-                    System.out.println(businessUserName + " " + numOfPrivateCustomer);
-                }else{
-                    System.out.println(businessUserId + " " + numOfPrivateCustomer);
-                }
-            } catch (Exception e) {
-                System.out.println(businessUserId + " " + numOfPrivateCustomer);
-            }
-            try {
-                for (int i = 0; i < ltcBusinessUserData.size(); i++) {
-                    if(ltcBusinessUserData.get(i).get("userId").equals(businessUserId)){
-                        formInstId = ltcBusinessUserData.get(i).get("formInstId").toString();
-                        System.out.println("更新各业务员私海客户数量:" + formInstId + " " + numOfPrivateCustomer);
-                        yidaService.updateLtcBusinessUserPrivateCustomerNum(formInstId, numOfPrivateCustomer);
-                        break;
-                    }
-                }
-            } catch (Exception e) {
-                log.error("更新各业务员私海客户数量异常",e);
-            }
-        }
-
-        log.info("清洗业务员档案(私海客户数量)数据结束");
-    }
 
     /**
      * 清洗客户(客户验重)数据

+ 3 - 0
src/main/java/com/malk/eastar/schedule/ScheduleTask5.java

@@ -3628,4 +3628,7 @@ public class ScheduleTask5 {
     }
 
 
+
+
+
 }

+ 161 - 3
src/main/java/com/malk/eastar/schedule/ScheduleTask6.java

@@ -6,6 +6,7 @@ import com.malk.eastar.service.DDCoreClient;
 import com.malk.eastar.service.YidaService;
 import com.malk.utils.UtilMap;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Configuration;
@@ -29,6 +30,158 @@ public class ScheduleTask6 {
     @Autowired
     private DDCoreClient ddCoreClient;
 
+    /**
+     * 纠正销售项目的业务员,使其与客户的业务员保持一致
+     */
+    @Scheduled(cron = "0 11 7 1/1 * ?")
+    public void rectifyCustomerAndSaleProjectBusinessUser() {
+        log.info("纠正销售项目的业务员,使其与客户的业务员保持一致开始");
+
+        /*
+            查询易思达系统所有业务员档案
+         */
+        log.info("查询易思达系统所有在职业务员档案");
+        List<Map> ltcBusinessUserData = new ArrayList<>();
+        try {
+            ltcBusinessUserData = yidaService.queryEmployedBusinessUserData();
+            log.info("所有在职业务员档案数量="+ltcBusinessUserData.size());
+        } catch (Exception e) {
+            log.error("查询易思达系统所有在职业务员档案异常",e);
+        }
+
+        /*
+            查询(易思达)客户名册所有记录
+         */
+        log.info("查询(易思达)客户名册所有记录");
+        List<Map> ltcCustomerData = new ArrayList<>();
+        try {
+            ltcCustomerData = yidaService.queryLtcAllCustomerData();
+            log.info("客户名册记录数量="+ltcCustomerData.size());
+        } catch (Exception e) {
+            log.error("查询(易思达)客户名册异常",e);
+        }
+
+        /*
+            筛选正式私海客户
+         */
+        List<Map> privateCustomerList = new ArrayList<>();
+        String testUseFlag; //测试使用
+        String seaType; //公海/私海
+        for (Map ltcCustomerRecord : ltcCustomerData){
+            testUseFlag = "";
+            if(ltcCustomerRecord.get("testUseFlag") != null){
+                testUseFlag = ltcCustomerRecord.get("testUseFlag").toString();
+            }
+            if(!"否".equals(testUseFlag)){
+                //忽略测试使用的客户
+                continue;
+            }
+            seaType = "";
+            if(ltcCustomerRecord.get("seaType") != null){
+                seaType = ltcCustomerRecord.get("seaType").toString();
+            }
+            if(!"私".equals(seaType)){
+                //忽略非私海客户
+                continue;
+            }
+            privateCustomerList.add(ltcCustomerRecord);
+        }
+        log.info("私海客户数量="+privateCustomerList.size());
+
+        /*
+            查询易思达系统销售项目数据
+         */
+        log.info("查询易思达系统销售项目数据");
+        List<Map> ltcSaleProjectList = new ArrayList<>();
+        try {
+            ltcSaleProjectList = yidaService.queryLtcAllSaleProjectData();
+            log.info("易思达系统销售项目记录数量="+ltcSaleProjectList.size());
+        } catch (Exception e) {
+            log.error("查询易思达系统销售项目数据异常",e);
+        }
+
+        /*
+            匹配销售项目的业务员与关联客户的业务员
+         */
+        boolean isNotMatch;
+        String saleProjectBusinessUserId;
+        String saleProjectBusinessUserId2;
+        String customerBusinessUserId;
+        String customerBusinessUserId2;
+        String customerCode;
+        for(Map ltcSaleProjectRecord : ltcSaleProjectList){
+            testUseFlag = "";
+            if(ltcSaleProjectRecord.get("testFlag") != null){
+                testUseFlag = ltcSaleProjectRecord.get("testFlag").toString();
+            }
+            if(!"否".equals(testUseFlag)){
+                //忽略测试使用的销售项目
+                continue;
+            }
+//            System.out.println("销售项目["+ ltcSaleProjectRecord.get("projectName") +"]");
+            customerCode = ltcSaleProjectRecord.get("customerCode").toString();
+            saleProjectBusinessUserId = ltcSaleProjectRecord.get("businessUserId").toString();
+            saleProjectBusinessUserId2 = ltcSaleProjectRecord.get("businessUserIdText").toString();
+            if(StringUtils.isNotBlank(customerCode)){
+                try {
+                    isNotMatch = false;
+                    for (int i = 0; i < privateCustomerList.size(); i++) {
+                        if(privateCustomerList.get(i).get("customerCode").toString().equals(customerCode)){
+//                            System.out.println("关联客户["+ privateCustomerList.get(i).get("customerName") +"]");
+                            if(privateCustomerList.get(i).get("userId") != null){
+                                customerBusinessUserId = privateCustomerList.get(i).get("userId").toString();
+                                if (StringUtils.isNotEmpty(customerBusinessUserId) && !saleProjectBusinessUserId.equals(customerBusinessUserId)){
+                                    log.info("销售项目业务员与关联客户业务员不一致,销售项目["+ ltcSaleProjectRecord.get("projectName")
+                                            +"]业务员ID="+saleProjectBusinessUserId+",关联客户["+ privateCustomerList.get(i).get("customerName") +"]业务员ID="+customerBusinessUserId);
+                                    isNotMatch = true;
+                                    for (int j = 0; j < ltcBusinessUserData.size(); j++) {
+                                        if(ltcBusinessUserData.get(j).get("userId").toString().equals(customerBusinessUserId)){
+                                            yidaService.updateLtcSaleProjectBusinessUser(
+                                                    ltcSaleProjectRecord.get("formInstId").toString(),
+                                                    customerBusinessUserId,
+                                                    ltcBusinessUserData.get(j).get("businessLeaderUserId").toString(),
+                                                    ltcBusinessUserData.get(j).get("businessGroup").toString()
+                                            );
+                                            break;
+                                        }
+                                    }
+
+                                }
+                            }
+                            if(!isNotMatch && privateCustomerList.get(i).get("userIdText") != null){
+                                customerBusinessUserId2 = privateCustomerList.get(i).get("userIdText").toString();
+                                if (StringUtils.isNotEmpty(customerBusinessUserId2) && !saleProjectBusinessUserId2.equals(customerBusinessUserId2)){
+                                    log.info("销售项目业务员userId与关联客户业务员userId不一致,销售项目["+ ltcSaleProjectRecord.get("projectName")
+                                            +"]业务员ID="+saleProjectBusinessUserId2+",关联客户["+ privateCustomerList.get(i).get("customerName") +"]业务员ID="+customerBusinessUserId2);
+                                    for (int j = 0; j < ltcBusinessUserData.size(); j++) {
+                                        if(ltcBusinessUserData.get(j).get("userId").toString().equals(customerBusinessUserId2)){
+                                            yidaService.updateLtcSaleProjectBusinessUser(
+                                                    ltcSaleProjectRecord.get("formInstId").toString(),
+                                                    customerBusinessUserId2,
+                                                    ltcBusinessUserData.get(j).get("businessLeaderUserId").toString(),
+                                                    ltcBusinessUserData.get(j).get("businessGroup").toString()
+                                            );
+                                            break;
+                                        }
+                                    }
+
+                                }
+                            }
+                            break;
+                        }
+                    }
+                } catch (Exception e) {
+                    log.error("匹配销售项目的业务员与关联客户业务员异常",e);
+                }
+
+            }
+        }
+
+        log.info("纠正销售项目的业务员,使其与客户的业务员保持一致结束");
+    }
+
+
+
     /**
      * 计算试用期业务员RFQ数量和成单额
      * ABC级客户的RFQ量+DE级客户3W美金以上的RFQ量≥6个,自主开发,不含公司分配
@@ -165,13 +318,15 @@ public class ScheduleTask6 {
     public void updateEmployeeStatus() {
         log.info("更新员工在职情况开始");
         /*
-            查询业务小组档案中的成员信息
+            查询所有在职业务员档案
          */
+        log.info("查询所有在职业务员档案");
         List<Map> ltcBusinessUserData = new ArrayList<>();
         try {
-            ltcBusinessUserData = yidaService.queryLtcAllBusinessUserData();
+            ltcBusinessUserData = yidaService.queryEmployedBusinessUserData();
+            log.info("在职业务员数量="+ltcBusinessUserData.size());
         } catch (Exception e) {
-            log.error("查询业务小组档案中的成员信息异常",e);
+            log.error("查询所有在职业务员档案异常",e);
         }
 
         /*
@@ -212,4 +367,7 @@ public class ScheduleTask6 {
         log.info("更新员工在职情况完成");
     }
 
+
+
+
 }

+ 235 - 4
src/main/java/com/malk/eastar/schedule/ScheduleTask8.java

@@ -1,7 +1,9 @@
 package com.malk.eastar.schedule;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 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.apache.commons.lang3.StringUtils;
@@ -11,10 +13,7 @@ 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.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 易思达系统数据同步定时任务(易思达系统 → 项目总表)
@@ -31,6 +30,238 @@ public class ScheduleTask8 {
     @Autowired
     private AitableService aitableService;
 
+    @Autowired
+    private DDCoreClient ddCoreClient;
+
+
+    /**
+     * 同步客户数据到项目总表
+     * 业务员
+     */
+    @Scheduled(cron = "0 15 2 * * ?")
+    public void syncCustomerBusinessUser() {
+        log.info("同步客户数据到项目总表(业务员)开始");
+        /*
+            查询易思达系统所有业务员档案
+         */
+        log.info("查询易思达系统所有在职业务员档案");
+        List<Map> ltcBusinessUserData = new ArrayList<>();
+        try {
+            ltcBusinessUserData = yidaService.queryEmployedBusinessUserData();
+            log.info("所有在职业务员档案数量="+ltcBusinessUserData.size());
+        } catch (Exception e) {
+            log.error("查询易思达系统所有在职业务员档案异常",e);
+            return;
+        }
+
+        /*
+            获取userId和unionId映射关系
+         */
+        log.info("获取userId和unionId映射关系");
+        Map<String,String> userIdUnionIdMap = new HashMap<>();
+        String userId;
+        String unionId;
+        for(Map ltcBusinessUserRecord : ltcBusinessUserData){
+            try {
+                userId = ltcBusinessUserRecord.get("userId").toString();
+                if(userId == null || StringUtils.isEmpty(userId)){
+                    log.info("userId为空!");
+                    continue;
+                }
+                unionId = ddCoreClient.getUnionIdByUserId(userId);
+                if(unionId == null || StringUtils.isEmpty(unionId)){
+                    log.info("userId="+userId+",unionId为空!");
+                    continue;
+                }
+                userIdUnionIdMap.put(userId,unionId);
+                log.info("userName=" + ltcBusinessUserRecord.get("businessUserName").toString() +",userId="+userId+",unionId="+unionId);
+            } catch (Exception e) {
+                log.error("获取userId和unionId映射关系异常");
+                return;
+            }
+
+        }
+
+        /*
+            查询(易思达)客户名册所有记录
+         */
+        log.info("查询(易思达)客户名册所有记录");
+        List<Map> ltcCustomerData = new ArrayList<>();
+        try {
+            ltcCustomerData = yidaService.queryLtcAllCustomerData();
+            log.info("易思达系统客户数量="+ltcCustomerData.size());
+        } catch (Exception e) {
+            log.error("查询(易思达)客户名册异常",e);
+            return;
+        }
+
+        /*
+            从项目总表(系统1)获取客户数据
+         */
+        log.info("查询项目总表客户名册所有记录");
+        List<Map> sys1CustomerData = new ArrayList<>();
+        try {
+            sys1CustomerData = aitableService.querySys1CustomerData();
+            log.info("项目总表客户数量="+sys1CustomerData.size());
+        } catch (Exception e) {
+            log.error("查询项目总表客户数据异常",e);
+            return;
+        }
+
+        /*
+            找到业务员不一致的客户
+         */
+        boolean isNotMatch = false; //是否不一致
+        String unionId1; //易思达系统客户业务员userId对应的unionId
+        String unionId2; //项目总表客户业务员的unionId
+        Map<String,Object> fields = new HashMap<>();
+        JSONArray userJSONArray = new JSONArray();
+        JSONObject userJSONObject = new JSONObject();
+        String formInstId;
+        String aitableId;
+        String customerName; //客户名称
+        String testUseFlag; //测试使用
+        String seaType; //公海/私海
+        String newOrOld; //新老客户
+        List<String> productTypes; //主要品类
+        boolean isExist; //是否存在
+        int notExistCount = 0; //不存在数量
+        for(Map ltcCustomerRecord : ltcCustomerData){
+            testUseFlag = "";
+            isExist = false;
+            if(ltcCustomerRecord.get("testUseFlag") != null){
+                testUseFlag = ltcCustomerRecord.get("testUseFlag").toString();
+            }
+            if(!"否".equals(testUseFlag)){
+                //忽略测试使用的客户
+                continue;
+            }
+            seaType = "";
+            if(ltcCustomerRecord.get("seaType") != null){
+                seaType = ltcCustomerRecord.get("seaType").toString();
+            }
+            if(!"私".equals(seaType)){
+                //忽略非私海客户
+                continue;
+            }
+            formInstId = ltcCustomerRecord.get("formInstId").toString();
+            customerName = ltcCustomerRecord.get("customerName").toString();
+            for (int i = 0; i < sys1CustomerData.size(); i++) {
+                aitableId = sys1CustomerData.get(i).get("aiTableId").toString();
+                if(aitableId.equals(ltcCustomerRecord.get("aiTableId"))){
+                    isExist = true;
+                    unionId1 = "";
+                    unionId2 = "";
+
+                    if(ltcCustomerRecord.get("userId") != null){
+                        userId = ltcCustomerRecord.get("userId").toString();
+                        if(userIdUnionIdMap.containsKey(userId)){
+                            unionId1 = userIdUnionIdMap.get(userId);
+                        }
+                    }
+
+                    if(sys1CustomerData.get(i).get("businessUserUnionId") != null){
+                        unionId2 = sys1CustomerData.get(i).get("businessUserUnionId").toString();
+                    }
+
+                    //判断业务员是否一致
+                    if(StringUtils.isEmpty(unionId1) && StringUtils.isEmpty(unionId2)){
+                        isNotMatch = false;
+                    } else if(StringUtils.isEmpty(unionId1) && StringUtils.isNotEmpty(unionId2)){
+                        isNotMatch = true;
+                    } else if(StringUtils.isNotEmpty(unionId1) && StringUtils.isEmpty(unionId2)){
+                        isNotMatch = true;
+                    } else {
+                        if(unionId1.equals(unionId2)){
+                            isNotMatch = false;
+                        }else{
+                            isNotMatch = true;
+                        }
+                    }
+                    if(isNotMatch){
+                        log.info("客户名="+customerName+",业务员不一致:"+unionId1+" "+unionId2);
+                        /*
+                            变更业务员(以新系统为准)
+                         */
+                        log.info("变更项目总表客户业务员(以新系统为准)");
+                        try {
+                            fields = new HashMap<>();
+                            userJSONArray = new JSONArray();
+                            userJSONObject = new JSONObject();
+                            userJSONObject.put("unionId",unionId1);
+                            userJSONArray.add(userJSONObject);
+                            fields.put("ynNC3Kq",JSONObject.toJSONString(userJSONArray));  //业务【人事】
+                            aitableService.updateSys1CustomerData(aitableId,fields);
+                        } catch (Exception e) {
+                            log.error("变更项目总表客户业务员异常",e);
+                        }
+                    }
+                    break;
+                }
+            }
+            if(!isExist){
+                notExistCount++;
+                log.info("发现未同步成功的私海客户:"+customerName);
+                fields = new HashMap<>();
+                fields.put("20rO7zS",customerName);   //客户公司名【基础】
+                fields.put("qgOhsh1",ltcCustomerRecord.get("customerLevel"));   //客户分级【客户】
+                newOrOld = "";
+                if(ltcCustomerRecord.get("newOrOld") != null){
+                    newOrOld = ltcCustomerRecord.get("newOrOld")+"客户";
+                }
+                fields.put("3Y796Wb",newOrOld);  //新老客户?【客户】
+                fields.put("jIS3Gbd",ltcCustomerRecord.get("establishStatus"));  //客户情况
+                fields.put("JjVfpWO",ltcCustomerRecord.get("countryOrRegion"));  //客户国家/地区【客户】
+                productTypes = new ArrayList<>();
+                if(ltcCustomerRecord.get("productTypes") != null){
+                    //主要品类
+                    if(ltcCustomerRecord.get("productTypes") != null){
+                        productTypes = (List<String>)ltcCustomerRecord.get("productTypes");
+                    }else{
+                        productTypes.add("unknown");
+                    }
+                }
+                fields.put("6rCZkSN",productTypes);  //客户标签【客户】
+                if(ltcCustomerRecord.get("userId") != null){
+                    userId = ltcCustomerRecord.get("userId").toString();
+                    if(userIdUnionIdMap.containsKey(userId)){
+                        unionId = userIdUnionIdMap.get(userId);
+                        userJSONArray = new JSONArray();
+                        userJSONObject = new JSONObject();
+                        userJSONObject.put("unionId",unionId);
+                        userJSONArray.add(userJSONObject);
+                        fields.put("ynNC3Kq",JSONObject.toJSONString(userJSONArray));  //业务【人事】
+                    }
+                }
+                try {
+                    aitableId = aitableService.querySys1CustomerIdByName(customerName);
+                    if(aitableId == null || aitableId.isEmpty()){
+                        aitableId = aitableService.addSys1CustomerData(fields);
+                    }else{
+                        log.info("客户["+customerName+"]在项目总表已存在,不再新增");
+                        System.out.println("客户["+customerName+"]在项目总表已存在,不再新增");
+                    }
+                    yidaService.updateCustomerRelatedAitableId(formInstId, aitableId);
+                } catch (Exception e) {
+                    log.error("新增项目总表客户名册异常",e);
+                }
+            }
+        }
+
+        log.info("新同步的私海客户数量="+notExistCount);
+
+        log.info("同步客户数据到项目总表(业务员)结束");
+    }
+
+    /**
+     * 同步销售项目数据到项目总表
+     * 业务员
+     */
+//    @Scheduled(cron = "0 37 11 * * ?")
+    public void syncSaleProjectBusinessUser() {
+
+    }
+
 
     /**
      * 同步销售项目数据到项目总表

+ 240 - 0
src/main/java/com/malk/eastar/schedule/ScheduleTask9.java

@@ -0,0 +1,240 @@
+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.apache.commons.lang3.StringUtils;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 多系统数据计算定时任务
+ */
+@Slf4j
+@Configuration
+@EnableScheduling
+@ConditionalOnProperty(name = {"enable.scheduling"})
+public class ScheduleTask9 {
+
+    @Autowired
+    private AitableService aitableService;
+
+    @Autowired
+    private YidaService yidaService;
+
+    @Autowired
+    private DDCoreClient ddCoreClient;
+
+    /**
+     * 计算业务员私海客户数量
+     */
+    @Scheduled(cron = "0 30 10,16 * * ?")
+    public void calculateusinessUserPrivateCustomerNum() {
+        log.info("计算业务员私海客户数量开始");
+
+        /*
+            查询易思达系统所有在职业务员档案
+         */
+        log.info("查询易思达系统所有在职业务员档案");
+        List<Map> ltcBusinessUserData = new ArrayList<>();
+        try {
+            ltcBusinessUserData = yidaService.queryEmployedBusinessUserData();
+            log.info("所有在职业务员档案数量="+ltcBusinessUserData.size());
+        } catch (Exception e) {
+            log.error("查询易思达系统所有在职业务员档案异常",e);
+        }
+
+        /*
+            1、获取userId列表和unionId列表
+            2、获取userId与formInstId映射
+            3、获取unionId与formInstId映射
+         */
+        List<String> userIdList = new ArrayList<>();
+        List<String> unionIdList = new ArrayList<>();
+        Map<String, String> userIdFormInstIdMap = new HashMap<>();
+        Map<String, String> unionIdFormInstIdMap = new HashMap<>();
+        String userId;
+        String unionId;
+        String formInstId;
+        for(Map ltcBusinessUserRecord : ltcBusinessUserData){
+            userId = "";
+            unionId = "";
+            formInstId = "";
+            try {
+                userId = ltcBusinessUserRecord.get("userId").toString();
+                if(userId == null || StringUtils.isEmpty(userId)){
+                    System.out.println("userId为空!");
+                    continue;
+                }
+                unionId = ddCoreClient.getUnionIdByUserId(userId);
+                if(unionId == null || StringUtils.isEmpty(unionId)){
+                    System.out.println("userId="+userId+",unionId为空!");
+                    continue;
+                }
+                userIdList.add(userId);
+                unionIdList.add(unionId);
+                formInstId = ltcBusinessUserRecord.get("formInstId").toString();
+                userIdFormInstIdMap.put(userId, formInstId);
+                unionIdFormInstIdMap.put(unionId, formInstId);
+            } catch (Exception e) {
+                log.error("获取userId和unionId映射关系异常");
+            }
+
+        }
+
+        /*
+            查询(易思达)客户名册所有记录
+         */
+        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);
+        }
+
+        String testUseFlag; //测试使用
+        String seaType; //公海/私海
+        String businessUserId; //业务员userId
+        String businessUnionId; //业务员unionId
+        Map<String, Integer> privateCustomerNumMap; //业务员私海客户数量
+        int numOfPrivateCustomer;
+
+        /*
+            统计易思达系统私海客户数量
+            按新老客户统计todo
+         */
+        privateCustomerNumMap = new HashMap<>();
+        for(Map ltcCustomerRecord : ltcCustomerData){
+            try {
+                testUseFlag = "";
+                if(ltcCustomerRecord.get("testUseFlag") != null){
+                    testUseFlag = ltcCustomerRecord.get("testUseFlag").toString();
+                }
+                if(!"否".equals(testUseFlag)){
+                    //忽略测试使用的客户
+                    continue;
+                }
+                seaType = "";
+                if(ltcCustomerRecord.get("seaType") != null){
+                    seaType = ltcCustomerRecord.get("seaType").toString();
+                }
+                if(!"私".equals(seaType)){
+                    //忽略非私海客户
+                    continue;
+                }
+                if(ltcCustomerRecord.get("userId") != null && StringUtils.isNotEmpty(ltcCustomerRecord.get("userId").toString())){
+                    businessUserId = ltcCustomerRecord.get("userId").toString();
+                    if(userIdList.contains(businessUserId)){
+                        if(privateCustomerNumMap.containsKey(businessUserId)){
+                            privateCustomerNumMap.put(businessUserId, privateCustomerNumMap.get(businessUserId) + 1);
+                        }else{
+                            privateCustomerNumMap.put(businessUserId, 1);
+                        }
+                    }else{
+                        log.info("未匹配到在职业务员:" + businessUserId + " " + ddCoreClient.getNameByUserId(businessUserId));
+                    }
+                }else{
+                    log.info("私海客户["+ltcCustomerRecord.get("customerName")+"]业务员为空");
+                }
+            } catch (Exception e) {
+                log.error("匹配客户名册表业务员与业务员档案表业务员异常",e);
+            }
+        }
+
+        /*
+            更新各业务员私海客户数量
+         */
+//        for (String userIdKey : userIdList){
+//            if(privateCustomerNumMap.containsKey(userIdKey)){
+//                numOfPrivateCustomer = privateCustomerNumMap.get(userIdKey);
+//            }else{
+//                //私海客户归0
+//                numOfPrivateCustomer = 0;
+//            }
+//            try {
+//                formInstId = userIdFormInstIdMap.get(userIdKey);
+//                log.info("更新各业务员私海客户数量:" + formInstId + " " + numOfPrivateCustomer);
+//                yidaService.updateLtcBusinessUserPrivateCustomerNum(formInstId, numOfPrivateCustomer);
+//            } catch (Exception e) {
+//                log.error("更新各业务员私海客户数量异常",e);
+//            }
+//        }
+
+        /*
+            统计项目总表私海客户数量
+            私海客户总数
+            按新老客户统计todo
+         */
+        privateCustomerNumMap = new HashMap<>();
+        for(Map sys1CustomerRecord : sys1CustomerData){
+            try {
+                testUseFlag = "";
+                if(sys1CustomerRecord.get("testUseFlag") != null){
+                    testUseFlag = sys1CustomerRecord.get("testUseFlag").toString();
+                }
+                if(!"否".equals(testUseFlag)){
+                    //忽略测试使用的客户
+                    continue;
+                }
+                if(sys1CustomerRecord.get("businessUserUnionId") != null && StringUtils.isNotEmpty(sys1CustomerRecord.get("businessUserUnionId").toString())){
+                    businessUnionId = sys1CustomerRecord.get("businessUserUnionId").toString();
+                    if(unionIdList.contains(businessUnionId)){
+                        if(privateCustomerNumMap.containsKey(businessUnionId)){
+                            privateCustomerNumMap.put(businessUnionId, privateCustomerNumMap.get(businessUnionId) + 1);
+                        }else{
+                            privateCustomerNumMap.put(businessUnionId, 1);
+                        }
+                    }
+                }
+            } catch (Exception e) {
+                log.error("匹配项目总表客户名册表业务员与业务员档案表业务员异常",e);
+            }
+        }
+
+
+        /*
+            更新各业务员私海客户数量(项目总表)
+         */
+        for (String unionIdKey : unionIdList){
+            if(privateCustomerNumMap.containsKey(unionIdKey)){
+                numOfPrivateCustomer = privateCustomerNumMap.get(unionIdKey);
+            }else{
+                //私海客户归0
+                numOfPrivateCustomer = 0;
+            }
+            try {
+                formInstId = unionIdFormInstIdMap.get(unionIdKey);
+                log.info("更新各业务员私海客户数量(项目总表):" + formInstId + " " + numOfPrivateCustomer);
+                yidaService.updateLtcBusinessUserPrivateCustomerNum2(formInstId, numOfPrivateCustomer);
+            } catch (Exception e) {
+                log.error("更新各业务员私海客户数量(项目总表)异常",e);
+            }
+        }
+
+        log.info("计算业务员私海客户数量结束");
+    }
+
+}

+ 25 - 0
src/main/java/com/malk/eastar/schedule/package-info.java

@@ -0,0 +1,25 @@
+package com.malk.eastar.schedule;
+
+/*
+    【每小时执行任务】
+    09:18-22:18 同步售前台账数据到新系统(订单金额、预计成单日期、实际成单日期)   Java
+
+    【每天执行任务】
+    02:15    同步客户数据到项目总表(业务员)  Java
+    05:00    同步销售项目数据到项目总表(销售项目整体阶段)  Java
+    05:30    同步售前台账数据到新系统(AI表格映射ID)   Java
+    06:00    更新员工在职情况   Java
+    06:15    在职和考核剩余天数更新    宜搭
+    07:11    纠正销售项目的业务员,使其与客户的业务员保持一致  Java
+    07:46    同步售前台账数据到新系统(是否计算为通关项目)  Java
+    08:18    计算试用期业务员RFQ数量和成单额  Java
+    09:00/17:00  每日推送报价时效报表   宜搭
+    10:30/16:30  计算业务员私海客户数量  Java
+    10:45/16:45  每日推送项目总表同步失败报表   宜搭
+    09:55    项目总表表2未填写完成统计   Java
+
+    【每周执行任务】
+    每周五
+    19:00   计算月度预计和实际AB客户发展数   Java
+
+ */

+ 23 - 1
src/main/java/com/malk/eastar/service/YidaService.java

@@ -32,16 +32,27 @@ public interface YidaService {
      */
     List<Map> queryLtcAllBusinessUserData() throws Exception;
 
+    /**
+     * 获取在职业务员档案
+     * @return
+     */
+    List<Map> queryEmployedBusinessUserData() throws Exception;
+
     /**
      * 更新业务人员在职状态为已离职(业务员档案)
      */
     void setLtcBusinessUserLeave(String formInstId) throws Exception;
 
     /**
-     * 更新业务员私海客户数量(业务员档案)
+     * 更新业务员档案私海客户数量
      */
     void updateLtcBusinessUserPrivateCustomerNum(String formInstId, int numOfPrivateCustomer) throws Exception;
 
+    /**
+     * 更新业务员档案私海客户数量(项目总表)
+     */
+    void updateLtcBusinessUserPrivateCustomerNum2(String formInstId, int numOfPrivateCustomer2) throws Exception;
+
     /**
      * 获取易思达系统中的所有记录(客户名册)
      */
@@ -141,6 +152,12 @@ public interface YidaService {
      */
     void updateLtcCustomerBasicInfo8(String formInstId, long privateSeaTime, long lastContactTime) throws Exception;
 
+
+    /**
+     * 客户退回公海
+     */
+    void updateLtcCustomerBackToPublicSea(String formInstId) throws Exception;
+
     /**
      * 更新易思达系统客户基本信息(客户当前分级)
      */
@@ -186,6 +203,11 @@ public interface YidaService {
      */
     void updateLtcSaleProjectClearLevel(String formInstId, String clearLevelFlag) throws Exception;
 
+    /**
+     * 更新易思达系统销售项目业务员
+     */
+    void updateLtcSaleProjectBusinessUser(String formInstId, String businessUserId, String businessLeaderUserId, String businessGroup) throws Exception;
+
     /**
      * 插入易思达系统中的一行记录(客户名册)
      */

+ 17 - 4
src/main/java/com/malk/eastar/service/impl/AitableServiceImpl.java

@@ -58,6 +58,7 @@ public class AitableServiceImpl implements AitableService {
         Map<String, Long> customerNameCountMap = new HashMap<>();   //客户名称与出现的次数映射
         String customerLevel;   //客户分级
         String newOrOld;    //新老客户
+        String testUseFlag; //测试使用标识
 
         /*
             项目总表
@@ -101,10 +102,6 @@ public class AitableServiceImpl implements AitableService {
             请求记录数据处理
          */
         log.info("所有记录数量="+allRecords.size());
-        customerName = "";
-        businessUserUnionId = "";
-        businessUserName = "";
-        kp = "";
         for(int i=0;i<allRecords.size();i++){
             /*
                 重置是否为空标识
@@ -113,6 +110,13 @@ public class AitableServiceImpl implements AitableService {
             isBusinessUserEmpty = false;
             isKpEmpty = false;
 
+            customerName = "";
+            businessUserUnionId = "";
+            businessUserName = "";
+            kp = "";
+
+            testUseFlag = "";
+
             //获取AI表格ID
             aiTableId = allRecords.getJSONObject(i).getString("id");
 
@@ -222,6 +226,14 @@ public class AitableServiceImpl implements AitableService {
             }
              */
 
+
+            /*
+                获取新老客户
+             */
+            if(fields.get("测试使用") != null){
+                testUseFlag = fields.getJSONObject("测试使用").getString("name");
+            }
+
             /*
                 汇总客户数据
              */
@@ -235,6 +247,7 @@ public class AitableServiceImpl implements AitableService {
             customerRecord.put("customerLevel",customerLevel);
             customerRecord.put("newOrOld",newOrOld);
 //            System.out.println(aiTableId+","+customerLevel+","+newOrOld);
+            customerRecord.put("testUseFlag",testUseFlag);
             customerData.add(customerRecord);
         }
         log.info("客户名称为空的记录数="+customerEmptyCount);

+ 341 - 23
src/main/java/com/malk/eastar/service/impl/YidaServiceImpl.java

@@ -822,6 +822,149 @@ public class YidaServiceImpl implements YidaService {
 
     @Override
     public List<Map> queryLtcAllBusinessUserData() throws Exception {
+        /*
+            参数定义
+         */
+        List<Map> businessUserData = new ArrayList<>(); // 业务人员数据
+        Map<String,String> businessUserRecord;  //业务人员记录
+        YDParam yidaParam;  //HTTP请求体
+        YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
+        DDR_New yidaResult; //请求返回内容
+        List<Map> records;  //每页记录数据
+        List<Map> allRecords = new ArrayList<>();  //所有记录数据
+        boolean hasMore; //是否还有下一页
+        int pageNo; //当前页码
+        int pageSize;   //每页获取的数据量(上限100)
+        JSONObject fields;  //字段数据
+        String formInstId;  //表单实例ID
+        JSONArray businessUserIdJSONArray;  //业务员userId(未解析)
+        String businessUserId;  //业务员userId
+        JSONArray businessUserNameJSONArray;  //业务员name(未解析)
+        String businessUserName;  //业务员name
+        JSONArray businessLeaderUserIdJSONArray;  //业务组长userId(未解析)
+        String businessLeaderUserId;  //业务组长userId
+        String employmentStatus; //在职情况
+        String testUse; //测试使用
+        String numOfPrivateCustomer; //私海客户数
+
+        /*
+            初始化参数值
+         */
+        hasMore = true; //第一页默认有数据
+        pageNo = 1;
+        pageSize = 100;
+        ydParamBuilder = YDParam.builder();
+        ydParamBuilder = ydParamBuilder.formUuid(EastarParam.YD_FORMUUID_BUSINESS_USER);
+
+        /*
+            翻页获取数据
+         */
+        while(hasMore){
+            ydParamBuilder = ydParamBuilder.pageNumber(pageNo);
+            ydParamBuilder = ydParamBuilder.pageSize(pageSize);
+            yidaParam = ydParamBuilder.build();
+            yidaResult = ydClient.queryData(yidaParam,YDConf.FORM_QUERY.retrieve_list);
+            log.info("当前第"+pageNo+"页");
+            records = (List<Map>) yidaResult.getData();
+            log.info("记录数="+records.size());
+            for (Map record : records){
+                allRecords.add(record);
+            }
+            if((pageNo*pageSize) < yidaResult.getTotalCount()){
+                pageNo++;
+            }else{
+                hasMore = false;
+            }
+            log.info("是否有更多数据:"+hasMore);
+        }
+
+        /*
+            请求记录数据处理
+         */
+        log.info("所有记录数量="+allRecords.size());
+        for (Map record : allRecords){
+            businessUserId = "";
+            businessUserName = "";
+            businessLeaderUserId = "";
+            employmentStatus = null;
+            testUse = null;
+            numOfPrivateCustomer = null;
+            businessUserRecord = new HashMap<>();
+
+            //获取表单实例ID
+            formInstId = String.valueOf(record.get("formInstanceId"));
+
+            //解析字段数据
+            fields = JSONObject.parseObject(JSONObject.toJSONString(record.get("formData")));
+
+            /*
+                获取业务员userId
+             */
+            if(fields.get("employeeField_mdfaff58_id") != null){
+                businessUserIdJSONArray = fields.getJSONArray("employeeField_mdfaff58_id");
+                if(!businessUserIdJSONArray.isEmpty()){
+                    businessUserId = String.valueOf(businessUserIdJSONArray.get(0));
+                }
+            }
+
+            /*
+                获取业务员name
+             */
+            if(fields.get("employeeField_mdfaff58") != null){
+                businessUserNameJSONArray = fields.getJSONArray("employeeField_mdfaff58");
+                if(!businessUserNameJSONArray.isEmpty()){
+                    businessUserName = String.valueOf(businessUserNameJSONArray.get(0));
+                }
+            }
+
+            /*
+                获取业务组长数据
+             */
+            if(fields.get("employeeField_mektcwc6_id") != null){
+                businessLeaderUserIdJSONArray = fields.getJSONArray("employeeField_mektcwc6_id");
+                if(!businessLeaderUserIdJSONArray.isEmpty()){
+                    businessLeaderUserId = String.valueOf(businessLeaderUserIdJSONArray.get(0));
+                }
+            }
+
+            /*
+                在职情况
+             */
+            if(fields.get("radioField_mn48qynm") != null){
+                employmentStatus = String.valueOf(fields.get("radioField_mn48qynm"));
+            }
+
+            /*
+                获取测试使用
+             */
+            if(fields.get("radioField_mnxyjnou") != null){
+                testUse = String.valueOf(fields.get("radioField_mnxyjnou"));
+            }
+
+            /*
+                获取私海客户数量
+             */
+            if(fields.get("numberField_ms43nslj") != null){
+                numOfPrivateCustomer = String.valueOf(fields.get("numberField_ms43nslj"));
+            }
+
+            if(!formInstId.isEmpty() && !businessUserId.isEmpty()){
+                businessUserRecord.put("formInstId",formInstId);
+                businessUserRecord.put("userId",businessUserId);
+                businessUserRecord.put("businessUserName",businessUserName);
+                businessUserRecord.put("businessLeaderUserId",businessLeaderUserId);
+                businessUserRecord.put("employmentStatus",employmentStatus);
+                businessUserRecord.put("testUse",testUse);
+                businessUserRecord.put("numOfPrivateCustomer",numOfPrivateCustomer);
+                businessUserData.add(businessUserRecord);
+            }
+        }
+
+        return businessUserData;
+    }
+
+    @Override
+    public List<Map> queryEmployedBusinessUserData() throws Exception {
         /*
             参数定义
          */
@@ -840,28 +983,32 @@ public class YidaServiceImpl implements YidaService {
         JSONObject fields;  //字段数据
         String formInstId;  //表单实例ID
         JSONArray businessUserIdJSONArray;  //业务员userId(未解析)
-        String userId;  //用户userId
+        String businessUserId;  //业务员userId
+        JSONArray businessUserNameJSONArray;  //业务员name(未解析)
+        String businessUserName;  //业务员name
         JSONArray businessLeaderUserIdJSONArray;  //业务组长userId(未解析)
         String businessLeaderUserId;  //业务组长userId
+        String employmentStatus; //在职情况
         String testUse; //测试使用
+        String businessGroup;   //业务小组
 
         /*
             初始化参数值
          */
-//        ydSearch = new YDSearch(
-//                "radioField_mn48qynm",
-//                "在职",
-//                "在职情况",
-//                YDSearch.Type.RADIO_FIELD,
-//                YDSearch.Operator.EQ
-//        );
-//        searchCondition = JSONObject.toJSONString(Arrays.asList(ydSearch));
+        ydSearch = new YDSearch(
+                "radioField_mn48qynm",
+                "在职",
+                "在职情况",
+                YDSearch.Type.RADIO_FIELD,
+                YDSearch.Operator.EQ
+        );
+        searchCondition = JSONObject.toJSONString(Arrays.asList(ydSearch));
         hasMore = true; //第一页默认有数据
         pageNo = 1;
         pageSize = 100;
         ydParamBuilder = YDParam.builder();
         ydParamBuilder = ydParamBuilder.formUuid(EastarParam.YD_FORMUUID_BUSINESS_USER);
-//        ydParamBuilder = ydParamBuilder.searchCondition(searchCondition);
+        ydParamBuilder = ydParamBuilder.searchCondition(searchCondition);
 
         /*
             翻页获取数据
@@ -889,11 +1036,13 @@ public class YidaServiceImpl implements YidaService {
             请求记录数据处理
          */
         log.info("所有记录数量="+allRecords.size());
-        userId = "";
-        businessLeaderUserId = "";
         for (Map record : allRecords){
+            businessUserId = "";
+            businessUserName = "";
+            businessLeaderUserId = "";
+            businessGroup = "";
+            employmentStatus = null;
             testUse = null;
-
             businessUserRecord = new HashMap<>();
 
             //获取表单实例ID
@@ -903,12 +1052,22 @@ public class YidaServiceImpl implements YidaService {
             fields = JSONObject.parseObject(JSONObject.toJSONString(record.get("formData")));
 
             /*
-                获取成员数据
+                获取业务员userId
              */
             if(fields.get("employeeField_mdfaff58_id") != null){
                 businessUserIdJSONArray = fields.getJSONArray("employeeField_mdfaff58_id");
                 if(!businessUserIdJSONArray.isEmpty()){
-                    userId = String.valueOf(businessUserIdJSONArray.get(0));
+                    businessUserId = String.valueOf(businessUserIdJSONArray.get(0));
+                }
+            }
+
+            /*
+                获取业务员name
+             */
+            if(fields.get("employeeField_mdfaff58") != null){
+                businessUserNameJSONArray = fields.getJSONArray("employeeField_mdfaff58");
+                if(!businessUserNameJSONArray.isEmpty()){
+                    businessUserName = String.valueOf(businessUserNameJSONArray.get(0));
                 }
             }
 
@@ -922,6 +1081,13 @@ public class YidaServiceImpl implements YidaService {
                 }
             }
 
+            /*
+                在职情况
+             */
+            if(fields.get("radioField_mn48qynm") != null){
+                employmentStatus = String.valueOf(fields.get("radioField_mn48qynm"));
+            }
+
             /*
                 获取测试使用
              */
@@ -929,10 +1095,20 @@ public class YidaServiceImpl implements YidaService {
                 testUse = String.valueOf(fields.get("radioField_mnxyjnou"));
             }
 
-            if(!formInstId.isEmpty() && !userId.isEmpty()){
+            /*
+                获取业务小组
+             */
+            if(fields.get("textField_mdfaff57") != null){
+                businessGroup = String.valueOf(fields.get("textField_mdfaff57"));
+            }
+
+            if(!formInstId.isEmpty() && !businessUserId.isEmpty()){
                 businessUserRecord.put("formInstId",formInstId);
-                businessUserRecord.put("userId",userId);
+                businessUserRecord.put("userId",businessUserId);
+                businessUserRecord.put("businessUserName",businessUserName);
                 businessUserRecord.put("businessLeaderUserId",businessLeaderUserId);
+                businessUserRecord.put("businessGroup",businessGroup);
+                businessUserRecord.put("employmentStatus",employmentStatus);
                 businessUserRecord.put("testUse",testUse);
                 businessUserData.add(businessUserRecord);
             }
@@ -989,6 +1165,30 @@ public class YidaServiceImpl implements YidaService {
         ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
     }
 
+    @Override
+    public void updateLtcBusinessUserPrivateCustomerNum2(String formInstId, int numOfPrivateCustomer2) throws Exception {
+        /*
+            参数定义
+         */
+        YDParam yidaParam;  //HTTP请求体
+        YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
+        String updateFormDataJson;  //更新内容
+
+        /*
+            初始化参数值
+         */
+        updateFormDataJson = JSONObject.toJSONString(UtilMap.map("numberField_ms8cjcoa",numOfPrivateCustomer2));  //私海客户数量(项目总表)
+
+        /*
+            更新数据
+         */
+        ydParamBuilder = YDParam.builder();
+        ydParamBuilder = ydParamBuilder.formInstId(formInstId);
+        ydParamBuilder = ydParamBuilder.updateFormDataJson(updateFormDataJson);
+        yidaParam = ydParamBuilder.build();
+        ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
+    }
+
     @Override
     public List<Map> queryLtcAllCustomerData() throws Exception {
         /*
@@ -1011,6 +1211,8 @@ public class YidaServiceImpl implements YidaService {
         JSONArray businessUserIdJSONArray;  //业务员userId
         String userId;  //用户userId
         String userIdText;
+        String establishStatus; //建联状态
+        String countryOrRegion; //国家或地区
 
         /*
             初始化参数值
@@ -1050,14 +1252,19 @@ public class YidaServiceImpl implements YidaService {
         log.info("所有记录数量="+allRecords.size());
         for (Map ltcCustomerRecord : allRecords){
             userId = "";
+            userIdText = "";
             customerName = "";
             customerCode = "";
+            establishStatus = null;
+            countryOrRegion = null;
+
             //获取表单实例ID
             formInstId = String.valueOf(ltcCustomerRecord.get("formInstanceId"));
             //解析字段数据
             fields = JSONObject.parseObject(JSONObject.toJSONString(ltcCustomerRecord.get("formData")));
+
             /*
-                获取成员数据
+                获取业务员userId
              */
             businessUserIdJSONArray = null;
             if(fields.get("employeeField_lqanqe6n_id") != null){
@@ -1066,23 +1273,49 @@ public class YidaServiceImpl implements YidaService {
                     userId = String.valueOf(businessUserIdJSONArray.get(0));
                 }
             }
-            userIdText = String.valueOf(ltcCustomerRecord.get("textField_mnchujji"));
+
+            //业务员userId(隐藏字段)
+            if(fields.get("textField_mnchujji") != null){
+                userIdText = fields.get("textField_mnchujji").toString();
+            }
 
             customerName = fields.getString("textField_lqanqe6j");
             customerCode = fields.getString("serialNumberField_lqanqe6i");
 
+            //建联状态
+            if(fields.get("radioField_mrlf08ap") != null){
+                if("已建联".equals(fields.get("radioField_mrlf08ap").toString())){
+                    establishStatus = "已建联";
+                }else{
+                    establishStatus = "未建联";
+                }
+            }else{
+                establishStatus = "未建联";
+            }
+
+            //国家或地区
+            if(fields.get("selectField_mfesniu3") != null){
+                countryOrRegion = fields.get("selectField_mfesniu3").toString();
+            }else{
+                countryOrRegion = "尚不明确";
+            }
+
             //生成客户数据
             customerRecord = UtilMap.map(
-                    "formInstId, customerName, customerNameUnique, customerCode, userId, userIdText, customerLevel, customerPotentialLevel, newOrOld, testUseFlag, aiTableId",
+                    "formInstId, customerName, customerNameUnique, customerCode, userId, userIdText, customerLevel, customerPotentialLevel, newOrOld, seaType, establishStatus, countryOrRegion, productTypes, testUseFlag, aiTableId",
                     formInstId, //表单实例ID
                     customerName, //客户公司名(英文名)
                     fields.getString("textField_meks6pjp"),    //客户验重
                     customerCode,   //客户编号
-                    userId,  //业务
-                    userIdText,
+                    userId,  //业务员userId
+                    userIdText,  //业务员userId(隐藏字段)
                     fields.getString("selectField_mcsoft5i"),    //客户当前分级
                     fields.getString("selectField_mhsvnqsv"),    //客户潜在等级
                     fields.getString("radioField_md6q7ox8"),    //新老客户
+                    fields.getString("radioField_md6q7oxa"),    //公海/私海
+                    establishStatus, //建联状态
+                    countryOrRegion, //国家或地区
+                    fields.get("multiSelectField_md6q7ox7"), //主要品类
                     fields.getString("radioField_mnpdkss9"),    //测试使用
                     fields.getString("textField_mno9nwip")  //AI表格映射ID
             );
@@ -1113,6 +1346,9 @@ public class YidaServiceImpl implements YidaService {
         Long yidaEstimatedOrderDate; //预计成单日期
         Long yidaActualOrderDate; //实际成单日期
         String clearLevelFlag;  //是否计算为通关项目
+        String customerCode;    //客户编号
+        JSONArray businessUserIdJSONArray;  //业务员userId
+        String businessUserId;  //业务员userId
 
         /*
             初始化参数值
@@ -1155,6 +1391,7 @@ public class YidaServiceImpl implements YidaService {
             yidaEstimatedOrderDate = null;
             yidaActualOrderDate = null;
             clearLevelFlag = null;
+            businessUserId = null;
 
             //获取表单实例ID
             formInstId = String.valueOf(ltcSaleProjectRecord.get("formInstanceId"));
@@ -1178,9 +1415,23 @@ public class YidaServiceImpl implements YidaService {
                 clearLevelFlag = fields.getString("radioField_ms2v43hf");
             }
 
+            /*
+                获取业务员userId
+             */
+            businessUserIdJSONArray = null;
+            if(fields.get("employeeField_mdf997x2_id") != null){
+                businessUserIdJSONArray = fields.getJSONArray("employeeField_mdf997x2_id");
+                if(!businessUserIdJSONArray.isEmpty()){
+                    businessUserId = String.valueOf(businessUserIdJSONArray.get(0));
+                }
+            }
+
             saleProjectRecord = UtilMap.map(
-                    "formInstId, projectCode, projectName, projectAmount, yidaEstimatedOrderDate, yidaActualOrderDate, clearLevelFlag, piCode, testFlag, aiTableId",
+                    "formInstId, customerCode, businessUserId, businessUserIdText, projectCode, projectName, projectAmount, yidaEstimatedOrderDate, yidaActualOrderDate, clearLevelFlag, piCode, testFlag, aiTableId",
                     formInstId, //表单实例ID
+                    fields.getString("textField_mdpb1gh1"), //客户编号
+                    businessUserId, //业务员userId
+                    fields.getString("textField_mnctph7f"), //业务员userId隐藏字段
                     fields.getString("serialNumberField_mdf997w0"), //项目编号
                     fields.getString("textField_mdf997vz"), //项目名称
                     projectAmount, //预计销售项目金额(美元)
@@ -2147,6 +2398,40 @@ public class YidaServiceImpl implements YidaService {
         ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
     }
 
+    @Override
+    public void updateLtcCustomerBackToPublicSea(String formInstId) throws Exception {
+        /*
+            参数定义
+         */
+        YDParam yidaParam;  //HTTP请求体
+        YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
+        String updateFormDataJson;  //更新内容
+
+        /*
+            初始化参数值
+         */
+        Map updateFormData = UtilMap.map(
+                "radioField_md6q7oxa, textField_mnchujji, textField_lxa0ko5h, employeeField_lqanqe6n, employeeField_lqx3act6, selectField_moy9v8ve",
+                "公",
+                "",
+                "",
+                new String[]{},
+                new String[]{},
+                ""
+        );
+        updateFormDataJson = JSONObject.toJSONString(updateFormData);
+        System.out.println(updateFormDataJson);
+
+        /*
+            更新数据
+         */
+        ydParamBuilder = YDParam.builder();
+        ydParamBuilder = ydParamBuilder.formInstId(formInstId);
+        ydParamBuilder = ydParamBuilder.updateFormDataJson(updateFormDataJson);
+        yidaParam = ydParamBuilder.build();
+        ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
+    }
+
     @Override
     public void updateCustomerCurrentLevel(String formInstId, String customerCurrentLevel) throws Exception {
         /*
@@ -2401,6 +2686,39 @@ public class YidaServiceImpl implements YidaService {
         ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
     }
 
+    @Override
+    public void updateLtcSaleProjectBusinessUser(String formInstId, String businessUserId, String businessLeaderUserId, String businessGroup) throws Exception {
+        /*
+            参数定义
+         */
+        YDParam yidaParam;  //HTTP请求体
+        YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
+        String updateFormDataJson;  //更新内容
+
+
+        /*
+            初始化参数值
+         */
+        Map updateFormData = UtilMap.map(
+                "employeeField_mdf997x2, employeeField_mdf997x3, selectField_mdf997x4, textField_mnctph7f",
+                businessUserId!=null?new String[]{businessUserId}:new String[]{},   //业务员
+                businessLeaderUserId!=null?new String[]{businessLeaderUserId}:new String[]{}, //业务组长
+                businessGroup, //业务小组
+                businessUserId //业务员userId
+        );
+        updateFormDataJson = JSONObject.toJSONString(updateFormData);
+        System.out.println(updateFormDataJson);
+
+        /*
+            更新数据
+         */
+        ydParamBuilder = YDParam.builder();
+        ydParamBuilder = ydParamBuilder.formInstId(formInstId);
+        ydParamBuilder = ydParamBuilder.updateFormDataJson(updateFormDataJson);
+        yidaParam = ydParamBuilder.build();
+        ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
+    }
+
 
     @Override
     public void insertCustomerData(Map row) throws Exception {