lvjs недель назад: 2
Родитель
Сommit
5e9cc8b2bc

+ 2 - 0
src/main/java/com/malk/eastar/conf/EastarParam.java

@@ -29,6 +29,8 @@ public class EastarParam {
 
     public static String YD_FORMUUID_RFQ = "FORM-F977D3892160410CAC56C323DDA63CA9GCSF";    //询价与报价,add by Jason 20260707
 
+    public static String YD_FORMUUID_NEW_BUSINESS_USER = "FORM-CF878D21E36542DB91C3A9E7289D9752RCXP";    //新业务员培养,add by Jason 20260722
+
     static {
         CUSTFIELD_ACCE.put("配件名","textField_me2f7tvo");
         CUSTFIELD_ACCE.put("系列名称","selectField_me2f7tw4");

+ 14 - 9
src/main/java/com/malk/eastar/controller/AitableController.java

@@ -225,6 +225,7 @@ public class AitableController {
         String aitableId = UtilMap.getString(data, "aitableId");
         String yidaSaleProjectStatus = UtilMap.getString(data, "yidaSaleProjectStatus");  //销售项目状态
         String yidaOrderAmount = UtilMap.getString(data, "yidaOrderAmount"); //预计项目金额
+        String yidaEstimatedOrderDate = UtilMap.getString(data, "yidaEstimatedOrderDate"); //预计成单日期
         String yidaActualOrderDate = UtilMap.getString(data, "yidaActualOrderDate"); //实际成单日期
         String yidaSaleProjectName = UtilMap.getString(data, "yidaSaleProjectName");  //项目名称
         String yidaGetRfqDate = UtilMap.getString(data, "yidaGetRfqDate"); //询报价日期或者客户跟进RFQ日期
@@ -266,22 +267,26 @@ public class AitableController {
                 if(StringUtils.isNotEmpty(aiTableOpportunityStage)){
                     fields.put("LQF6OWD",aiTableOpportunityStage);   //商机阶段 - S1~3【商机进度】
                 }
-                if(StringUtils.isNotEmpty(yidaActualOrderDate)){
-                    fields.put("VBsHxPE",Long.parseLong(yidaActualOrderDate));  //实际成单日期 - S3【销售数据】
-                }
-                if(StringUtils.isNotEmpty(yidaOrderAmount)){
-                    fields.put("MYBeHPG",Double.parseDouble(yidaOrderAmount));  //订单金额 - S2~3【销售数据】
-                }
                 aitableService.updateSys1SaleData(aitableId,fields);
             }
 
-            if(yidaOrderAmount != null && !yidaOrderAmount.isEmpty()){    //成单预测
+            if(yidaSaleProjectName != null && !yidaSaleProjectName.isEmpty()){    //项目名称
+                fields.put("P3XtfD8",yidaSaleProjectName);  //项目名称 - S1【基础】
+                aitableService.updateSys1SaleData(aitableId,fields);
+            }
+
+            if(yidaOrderAmount != null && !yidaOrderAmount.isEmpty()){    //预计项目金额不为空
                 fields.put("MYBeHPG",Double.parseDouble(yidaOrderAmount));  //订单金额 - S2~3【销售数据】
                 aitableService.updateSys1SaleData(aitableId,fields);
             }
 
-            if(yidaSaleProjectName != null && !yidaSaleProjectName.isEmpty()){    //项目名称
-                fields.put("P3XtfD8",yidaSaleProjectName);  //项目名称 - S1【基础】
+            if(yidaEstimatedOrderDate != null && !yidaEstimatedOrderDate.isEmpty()){    //预计成单日期不为空
+                fields.put("m34IbuX",Long.parseLong(yidaEstimatedOrderDate));  //预计成单日期 - S1~2【商机进度】
+                aitableService.updateSys1SaleData(aitableId,fields);
+            }
+
+            if(yidaActualOrderDate != null && !yidaActualOrderDate.isEmpty()){    //实际成单日期不为空
+                fields.put("VBsHxPE",Long.parseLong(yidaActualOrderDate));  //实际成单日期 - S3【销售数据】
                 aitableService.updateSys1SaleData(aitableId,fields);
             }
 

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

@@ -0,0 +1,75 @@
+package com.malk.eastar.schedule;
+
+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;
+import java.util.regex.Pattern;
+
+/**
+ * 易思达系统数据清洗定时任务
+ */
+@Slf4j
+@Configuration
+@EnableScheduling
+@ConditionalOnProperty(name = {"enable.scheduling"})
+public class ScheduleTask5 {
+
+    @Autowired
+    private YidaService yidaService;
+
+    /**
+     * 客户数据清洗
+     * 客户验重字段值去除空格
+     */
+//    @Scheduled(cron = "0 26 14 * * ?")
+    public void cleanCustomerData20260721() {
+        /*
+            查询(易思达)客户名册所有记录
+         */
+        log.info("查询(易思达)客户名册所有记录");
+        List<Map> ltcCustomerData = new ArrayList<>();
+        try {
+            ltcCustomerData = yidaService.queryLtcAllCustomerData();
+        } catch (Exception e) {
+            log.error("查询(易思达)客户名册异常",e);
+        }
+
+        /*
+            筛选客户验重字段值中包含不间断空格的记录
+         */
+        System.out.println("以下记录客户验重字段值中包含不间断空格");
+        String formInstId;
+        String customerNameUnique;
+        int count = 0;
+        for(Map ltcCustomerRecord : ltcCustomerData){
+            formInstId = ltcCustomerRecord.get("formInstId").toString();
+            customerNameUnique = ltcCustomerRecord.get("customerNameUnique").toString();
+            if(customerNameUnique.matches(".*[ \u00A0].*")){ //是否包含不间断空格
+                count++;
+                System.out.println(ltcCustomerRecord.get("customerName").toString());
+                System.out.println("包含不间断空格的客户验重字符串:"+customerNameUnique);
+                customerNameUnique = customerNameUnique.replaceAll("[ \u00A0]", "");
+                System.out.println("矫正后的客户验重字符串:"+customerNameUnique);
+                try {
+                    System.out.println("更新客户验重字段值");
+//                    yidaService.updateLtcCustomerNameUnique(formInstId, customerNameUnique);
+                } catch (Exception e) {
+                    log.error("更新客户验重字段值异常",e);
+                }
+            }
+        }
+        System.out.println("共" + count + "条记录");
+
+        log.info("客户数据清洗(客户验重字段值去除空格)完成");
+    }
+
+
+}

+ 88 - 0
src/main/java/com/malk/eastar/schedule/ScheduleTask6.java

@@ -0,0 +1,88 @@
+package com.malk.eastar.schedule;
+
+import com.alibaba.fastjson.JSONObject;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 易思达系统数据计算定时任务
+ */
+@Slf4j
+@Configuration
+@EnableScheduling
+@ConditionalOnProperty(name = {"enable.scheduling"})
+public class ScheduleTask6 {
+
+    @Autowired
+    private YidaService yidaService;
+
+    @Autowired
+    private DDCoreClient ddCoreClient;
+
+    /**
+     * 计算试用期业务员前3个月RFQ数量
+     * ABC级客户的RFQ量+DE级客户3W美金以上的RFQ量≥6个,自主开发,不含公司分配
+     */
+//    @Scheduled(cron = "0 46 17 * * ?")
+    public void calculateNumOfRFQ() {
+        /*
+            查询新业务员培养记录
+         */
+        List<Map> newBusinessUserData = new ArrayList<>();
+        try {
+            newBusinessUserData = yidaService.queryLtcNewBusinessUserData();
+            log.info("新业务员培养记录数量="+newBusinessUserData.size());
+        } catch (Exception e) {
+            log.error("查询新业务员培养记录异常",e);
+        }
+
+        //筛选销售项目数据
+        Map params = new HashMap<>();
+        String formInstId = "";
+        String newBusinessUserId = "";
+        List<Map> ltcSaleProjectData = new ArrayList<>();
+        int numOfRFQ = 0;
+        for(Map newBusinessUserRecord : newBusinessUserData){
+            try {
+                formInstId = newBusinessUserRecord.get("formInstId").toString();
+                newBusinessUserId = newBusinessUserRecord.get("newBusinessUserId").toString();
+                params = new HashMap<>();
+                params.put("businessUserId",newBusinessUserId);
+                params.put("rfqDateAfter",newBusinessUserRecord.get("employmentDate"));
+                params.put("deadline",newBusinessUserRecord.get("deadline"));
+                params.put("testUse","否");
+                params.put("rfqFrom","自主开发");
+                log.info("筛选销售项目数据");
+                ltcSaleProjectData = yidaService.queryLtcSaleProjectData(params);
+                if(ltcSaleProjectData.size()>0){
+                    System.out.println(JSONObject.toJSONString(ltcSaleProjectData));
+                    numOfRFQ = ltcSaleProjectData.size();
+                    log.info("新业务员ID:"+newBusinessUserId);
+                    log.info("新业务员姓名:"+ddCoreClient.getNameByUserId(newBusinessUserId));
+                    log.info("入职日期:"+newBusinessUserRecord.get("employmentDate"));
+                    log.info("3个月考核截止日期:"+newBusinessUserRecord.get("deadline"));
+                    log.info("RFQ数量="+numOfRFQ);
+                    log.info("更新前3个月RFQ数量");
+                    yidaService.updateLtcNewBusinessUserRecord(formInstId,numOfRFQ);
+                    Thread.sleep(3000);
+                }
+            } catch (Exception e) {
+                log.error("计算RFQ数量异常",e);
+            }
+        }
+
+        log.info("计算试用期业务员前3个月RFQ数量完成");
+    }
+
+}

+ 14 - 0
src/main/java/com/malk/eastar/service/YidaService.java

@@ -68,6 +68,16 @@ public interface YidaService {
      */
     List<Map> queryLtcRFQData() throws Exception;
 
+    /**
+     * 获取易思达系统中的新业务员培养记录
+     */
+    List<Map> queryLtcNewBusinessUserData() throws Exception;
+
+    /**
+     * 更新易思达系统中的新业务员培养记录
+     */
+    void updateLtcNewBusinessUserRecord(String formInstId, int numOfRFQ) throws Exception;
+
     /**
      * 获取易思达系统中的项目编号
      * @param formInstId
@@ -76,6 +86,10 @@ public interface YidaService {
      */
     String queryProjectCode(String formInstId) throws Exception;
 
+    /**
+     * 更新易思达系统客户客户验重(客户名册)
+     */
+    void updateLtcCustomerNameUnique(String formInstId, String customerNameUnique) throws Exception;
 
     /**
      * 更新易思达系统客户测试使用标识(客户名册)

+ 251 - 3
src/main/java/com/malk/eastar/service/impl/YidaServiceImpl.java

@@ -1033,9 +1033,10 @@ public class YidaServiceImpl implements YidaService {
 
             //生成客户数据
             customerRecord = UtilMap.map(
-                    "formInstId, customerName, customerCode, userId, userIdText, customerLevel, customerPotentialLevel, newOrOld, testUseFlag, aiTableId",
+                    "formInstId, customerName, customerNameUnique, customerCode, userId, userIdText, customerLevel, customerPotentialLevel, newOrOld, testUseFlag, aiTableId",
                     formInstId, //表单实例ID
                     customerName, //客户公司名(英文名)
+                    fields.getString("textField_meks6pjp"),    //客户验重
                     customerCode,   //客户编号
                     userId,  //业务
                     userIdText,
@@ -1148,6 +1149,9 @@ public class YidaServiceImpl implements YidaService {
         JSONObject fields;  //字段数据
         String formInstId;  //表单实例ID
         Map saleProjectRecord;  //销售项目记录
+        JSONArray businessUserIdJSONArray;  //业务员字段值
+        String businessUserId; //业务员userId
+        Double projectAmount; //预计销售项目金额(美元)
 
         /*
             初始化参数值
@@ -1161,9 +1165,65 @@ public class YidaServiceImpl implements YidaService {
                     YDSearch.Operator.LIKE
             );
             ydSearchList.add(ydSearch);
-            searchCondition = JSONObject.toJSONString(ydSearchList);
         }
 
+        if(params.containsKey("businessUserId")){
+            ydSearch = new YDSearch(
+                    "textField_mnctph7f",
+                    params.get("businessUserId").toString(),
+                    "业务员userId",
+                    YDSearch.Type.TEXT_FIELD,
+                    YDSearch.Operator.EQ
+            );
+            ydSearchList.add(ydSearch);
+        }
+
+        if(params.containsKey("rfqDateAfter")){
+            ydSearch = new YDSearch(
+                    "dateField_mrizpls3",
+                    Long.parseLong(params.get("rfqDateAfter").toString()),
+                    "初次询价日期",
+                    YDSearch.Type.DATE_FIELD,
+                    YDSearch.Operator.GE
+            );
+            ydSearchList.add(ydSearch);
+        }
+
+        if(params.containsKey("deadline")){
+            ydSearch = new YDSearch(
+                    "dateField_mrizpls3",
+                    Long.parseLong(params.get("deadline").toString()),
+                    "初次询价日期",
+                    YDSearch.Type.DATE_FIELD,
+                    YDSearch.Operator.LE
+            );
+            ydSearchList.add(ydSearch);
+        }
+
+        if(params.containsKey("rfqFrom")){
+            ydSearch = new YDSearch(
+                    "radioField_mrle8vw0",
+                    params.get("rfqFrom").toString(),
+                    "RFQ来源",
+                    YDSearch.Type.RADIO_FIELD,
+                    YDSearch.Operator.EQ
+            );
+            ydSearchList.add(ydSearch);
+        }
+
+        if(params.containsKey("testUse")){
+            ydSearch = new YDSearch(
+                    "radioField_mnppbub6",
+                    params.get("testUse").toString(),
+                    "测试使用",
+                    YDSearch.Type.RADIO_FIELD,
+                    YDSearch.Operator.EQ
+            );
+            ydSearchList.add(ydSearch);
+        }
+
+        searchCondition = JSONObject.toJSONString(ydSearchList);
+
         hasMore = true; //第一页默认有数据
         pageNo = 1;
         pageSize = 100;
@@ -1204,19 +1264,42 @@ public class YidaServiceImpl implements YidaService {
          */
         log.info("所有记录数量="+allRecords.size());
         for (Map ltcSaleProjectRecord : allRecords){
+            businessUserId = "";
+            projectAmount = 0.0;
+
             //获取表单实例ID
             formInstId = String.valueOf(ltcSaleProjectRecord.get("formInstanceId"));
+
             //解析字段数据
             fields = JSONObject.parseObject(JSONObject.toJSONString(ltcSaleProjectRecord.get("formData")));
 
+            /*
+                获取成员数据
+             */
+            if(fields.get("employeeField_mdf997x2_id") != null){
+                businessUserIdJSONArray = fields.getJSONArray("employeeField_mdf997x2_id");
+                if(!businessUserIdJSONArray.isEmpty()){
+                    businessUserId = String.valueOf(businessUserIdJSONArray.get(0));
+                }
+            }
+
+            if(fields.get("numberField_mdf997x6") != null){ //预计销售项目金额(美元)
+                projectAmount = Double.parseDouble(fields.getString("numberField_mdf997x6"));
+            }
+
             saleProjectRecord = UtilMap.map(
-                    "formInstId, projectCode, projectName, projectStage, customer, piCode, aiTableId",
+                    "formInstId, projectCode, projectName, projectStage, projectAmount, customer, customerCode, businessUserId, piCode, rfqFrom, testUse, aiTableId",
                     formInstId, //表单实例ID
                     fields.getString("serialNumberField_mdf997w0"), //项目编号
                     fields.getString("textField_mdf997vz"), //项目名称
                     fields.getString("selectField_mdf997wp"), //整体项目阶段
+                    projectAmount, //预计销售项目金额(美元)
                     fields.getString("associationFormField_mdf997wc_id"), //客户
+                    fields.getString("textField_mdpb1gh1"), //客户编号
+                    businessUserId, //业务员
                     fields.getString("textField_mhlrjdz2"), //原系统PI号
+                    fields.getString("radioField_mrle8vw0"), //RFQ来源
+                    fields.getString("radioField_mnppbub6"), //测试使用
                     fields.getString("textField_mno9p0lf")  //AI表格映射ID
             );
             saleProjectData.add(saleProjectRecord);
@@ -1453,6 +1536,7 @@ public class YidaServiceImpl implements YidaService {
         ydParamBuilder = YDParam.builder();
         ydParamBuilder = ydParamBuilder.formUuid(EastarParam.YD_FORMUUID_RFQ);
 
+
         /*
             翻页获取数据
          */
@@ -1506,6 +1590,146 @@ public class YidaServiceImpl implements YidaService {
         return rfqData;
     }
 
+    @Override
+    public List<Map> queryLtcNewBusinessUserData() throws Exception {
+        /*
+            参数定义
+         */
+        List<Map> newBusinessUserData = new ArrayList<>();  //新业务员培养数据
+        YDSearch ydSearch; //检索条件(单个)
+        String searchCondition; //检索条件
+        YDParam yidaParam;  //HTTP请求体
+        YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
+        DDR_New yidaResult; //请求返回内容
+        List<Map> records;  //每页记录数据
+        List<Map> allRecords = new ArrayList<>();  //所有记录数据
+        boolean hasMore; //是否还有下一页
+        int pageNo; //当前页码
+        int pageSize;   //每页获取的数据量(上限100)
+        String formInstId; //表单实例ID
+        JSONObject fields;  //字段数据
+        Map newBusinessUserRecord;  //新业务员培养记录
+        JSONArray businessUserIdJSONArray;  //新业务员字段值
+        String newBusinessUserId; //新业务员userId
+        Long employmentDate;  //入职日期
+        Long deadline;  //3个月考核截止日期
+
+        /*
+            初始化参数值
+         */
+        ydSearch = new YDSearch(
+                "radioField_mrmt1pdv",
+                "在职",
+                "是否在职",
+                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_NEW_BUSINESS_USER);
+        ydParamBuilder = ydParamBuilder.searchCondition(searchCondition);
+
+        /*
+            翻页获取数据
+         */
+        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);
+            Thread.sleep(3000);
+        }
+
+        /*
+            请求记录数据处理
+         */
+        log.info("所有记录数量="+allRecords.size());
+        for (Map record : allRecords){
+            newBusinessUserId = "";
+            deadline = null;
+
+            //获取表单实例ID
+            formInstId = String.valueOf(record.get("formInstanceId"));
+
+            //解析字段数据
+            fields = JSONObject.parseObject(JSONObject.toJSONString(record.get("formData")));
+
+            /*
+                获取业务员userId
+             */
+            if(fields.get("employeeField_mrlv718s_id") != null){
+                businessUserIdJSONArray = fields.getJSONArray("employeeField_mrlv718s_id");
+                if(!businessUserIdJSONArray.isEmpty()){
+                    newBusinessUserId = String.valueOf(businessUserIdJSONArray.get(0));
+                }
+            }
+
+            //入职日期
+            employmentDate = fields.getLong("dateField_mrmt1pdt");
+
+            //获取3个月考核截止日期
+            deadline = fields.getLong("dateField_mrtylxl4");
+
+
+            //添加客户建联跟进记录
+            newBusinessUserRecord = UtilMap.map(
+                    "formInstId, newBusinessUserId, employmentDate, deadline",
+                    formInstId, //表单实例ID
+                    newBusinessUserId, //新业务员userId
+                    employmentDate, //入职日期
+                    deadline  //3个月考核截止日期
+            );
+            newBusinessUserData.add(newBusinessUserRecord);
+        }
+
+        return newBusinessUserData;
+    }
+
+    @Override
+    public void updateLtcNewBusinessUserRecord(String formInstId, int numOfRFQ) throws Exception {
+        /*
+            参数定义
+         */
+        YDParam yidaParam;  //HTTP请求体
+        YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
+        String updateFormDataJson;  //更新内容
+
+        /*
+            初始化参数值
+         */
+        updateFormDataJson = JSONObject.toJSONString(
+                UtilMap.map(
+                        "numberField_mrtylxl7, dateField_mrtylxld",
+                        numOfRFQ,   //3个月RFQ量
+                        DateUtil.current()  //RFQ数据更新时间
+                )
+        );
+
+        /*
+            更新数据
+         */
+        ydParamBuilder = YDParam.builder();
+        ydParamBuilder = ydParamBuilder.formInstId(formInstId);
+        ydParamBuilder = ydParamBuilder.updateFormDataJson(updateFormDataJson);
+        yidaParam = ydParamBuilder.build();
+        ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
+    }
+
     @Override
     public String queryProjectCode(String formInstId) throws Exception {
         Map leadsData = ydClient.queryData(
@@ -1515,6 +1739,30 @@ public class YidaServiceImpl implements YidaService {
         return UtilMap.getString(leadsData,"serialNumberField_mdf997w0");   //项目编号
     }
 
+    @Override
+    public void updateLtcCustomerNameUnique(String formInstId, String customerNameUnique) throws Exception {
+        /*
+            参数定义
+         */
+        YDParam yidaParam;  //HTTP请求体
+        YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
+        String updateFormDataJson;  //更新内容
+
+        /*
+            初始化参数值
+         */
+        updateFormDataJson = JSONObject.toJSONString(UtilMap.map("textField_meks6pjp",customerNameUnique));  //客户验重
+
+        /*
+            更新数据
+         */
+        ydParamBuilder = YDParam.builder();
+        ydParamBuilder = ydParamBuilder.formInstId(formInstId);
+        ydParamBuilder = ydParamBuilder.updateFormDataJson(updateFormDataJson);
+        yidaParam = ydParamBuilder.build();
+        ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
+    }
+
     @Override
     public void updateLtcCustomerTestFlag(String formInstId) throws Exception {
         /*