|
@@ -1,6 +1,7 @@
|
|
|
package com.malk.eastar.service.impl;
|
|
package com.malk.eastar.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.malk.eastar.conf.EastarParam;
|
|
import com.malk.eastar.conf.EastarParam;
|
|
|
import com.malk.eastar.service.YidaService;
|
|
import com.malk.eastar.service.YidaService;
|
|
@@ -8,6 +9,7 @@ import com.malk.eastar.util.ConfigDataProcessor;
|
|
|
import com.malk.server.aliwork.YDConf;
|
|
import com.malk.server.aliwork.YDConf;
|
|
|
import com.malk.server.aliwork.YDParam;
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
import com.malk.server.aliwork.YDSearch;
|
|
import com.malk.server.aliwork.YDSearch;
|
|
|
|
|
+import com.malk.server.dingtalk.DDR_New;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
import com.malk.service.aliwork.YDService;
|
|
import com.malk.service.aliwork.YDService;
|
|
|
import com.malk.utils.PublicUtil;
|
|
import com.malk.utils.PublicUtil;
|
|
@@ -458,6 +460,7 @@ public class YidaServiceImpl implements YidaService {
|
|
|
return Collections.emptyMap();
|
|
return Collections.emptyMap();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取所有配件记录
|
|
* 获取所有配件记录
|
|
|
*/
|
|
*/
|
|
@@ -694,5 +697,531 @@ public class YidaServiceImpl implements YidaService {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Map> queryLtcBusinessUserData() throws Exception {
|
|
|
|
|
+ /*
|
|
|
|
|
+ 参数定义
|
|
|
|
|
+ */
|
|
|
|
|
+ List<Map> businessUserData = new ArrayList<>(); // 业务人员数据
|
|
|
|
|
+ Map<String,String> businessUserRecord; //业务人员记录
|
|
|
|
|
+ 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)
|
|
|
|
|
+ JSONObject fields; //字段数据
|
|
|
|
|
+ String formInstId; //表单实例ID
|
|
|
|
|
+ JSONArray businessUserIdJSONArray; //业务员userId
|
|
|
|
|
+ String userId; //用户userId
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 初始化参数值
|
|
|
|
|
+ */
|
|
|
|
|
+ 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);
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 翻页获取数据
|
|
|
|
|
+ */
|
|
|
|
|
+ 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());
|
|
|
|
|
+ userId = "";
|
|
|
|
|
+ for (Map record : allRecords){
|
|
|
|
|
+ businessUserRecord = new HashMap<>();
|
|
|
|
|
+ //获取表单实例ID
|
|
|
|
|
+ formInstId = String.valueOf(record.get("formInstanceId"));
|
|
|
|
|
+ //解析字段数据
|
|
|
|
|
+ fields = JSONObject.parseObject(JSONObject.toJSONString(record.get("formData")));
|
|
|
|
|
+ /*
|
|
|
|
|
+ 获取成员数据
|
|
|
|
|
+ */
|
|
|
|
|
+ if(fields.get("employeeField_mdfaff58_id") != null){
|
|
|
|
|
+ businessUserIdJSONArray = fields.getJSONArray("employeeField_mdfaff58_id");
|
|
|
|
|
+ if(!businessUserIdJSONArray.isEmpty()){
|
|
|
|
|
+ userId = String.valueOf(businessUserIdJSONArray.get(0));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!formInstId.isEmpty() && !userId.isEmpty()){
|
|
|
|
|
+ businessUserRecord.put("formInstId",formInstId);
|
|
|
|
|
+ businessUserRecord.put("userId",userId);
|
|
|
|
|
+ businessUserData.add(businessUserRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return businessUserData;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setLtcBusinessUserLeave(String formInstId) throws Exception {
|
|
|
|
|
+ /*
|
|
|
|
|
+ 参数定义
|
|
|
|
|
+ */
|
|
|
|
|
+ YDParam yidaParam; //HTTP请求体
|
|
|
|
|
+ YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
|
|
|
|
|
+ String updateFormDataJson; //更新内容
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 初始化参数值
|
|
|
|
|
+ */
|
|
|
|
|
+ updateFormDataJson = JSONObject.toJSONString(UtilMap.map("radioField_mn48qynm","已离职")); //在职情况
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 更新数据
|
|
|
|
|
+ */
|
|
|
|
|
+ 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> querySys2CustomerData() throws Exception {
|
|
|
|
|
+ /*
|
|
|
|
|
+ 参数定义
|
|
|
|
|
+ */
|
|
|
|
|
+ List<Map> customerData = new ArrayList<>(); // 客户数据
|
|
|
|
|
+ List<Map> customerDataDeduplicate = new ArrayList<>(); // 客户数据(去重)
|
|
|
|
|
+ String appType; //宜搭应用编码
|
|
|
|
|
+ String formUuid; //表单编码
|
|
|
|
|
+ String systemToken; //宜搭应用密钥
|
|
|
|
|
+ String userId; //用户userId
|
|
|
|
|
+ String createToTimeGMT; //需要创建时间小于的时间
|
|
|
|
|
+ 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)
|
|
|
|
|
+ JSONObject fields; //字段数据
|
|
|
|
|
+ String customerName; //客户名称
|
|
|
|
|
+ JSONArray businessUserJSONArray; //对接业务员
|
|
|
|
|
+ List<String> businessUserList; //对接业务员(文本)
|
|
|
|
|
+ String businessUserId; //业务员userId
|
|
|
|
|
+ String businessUserName; //业务员姓名
|
|
|
|
|
+ List<Map> kpRecords; //KP明细
|
|
|
|
|
+ String kp; //KP
|
|
|
|
|
+ boolean isCustomerNameEmpty; //客户名称是否为空
|
|
|
|
|
+ boolean isBusinessUserEmpty; //业务员是否为空
|
|
|
|
|
+ boolean isKpEmpty; //KP是否为空
|
|
|
|
|
+ boolean isBusinessUserMulti; //业务员是否有多个
|
|
|
|
|
+ boolean isKpMulti; //KP是否有多个
|
|
|
|
|
+ int customerEmptyCount = 0; //客户名称为空的记录数
|
|
|
|
|
+ Map<String,String> customerRecord; //客户记录
|
|
|
|
|
+ Map<String, Long> customerNameCountMap = new HashMap<>(); //客户名称与出现的次数映射
|
|
|
|
|
+ String formInstId; //表单实例ID
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ EASTAR业务数字化
|
|
|
|
|
+ */
|
|
|
|
|
+ appType = "APP_BPEHQO5P5YSJ7GMIU9ST";
|
|
|
|
|
+ systemToken = "6Q666BA1SP89K86O7K41AAQ1NS1228S93GJFL5P2";
|
|
|
|
|
+ formUuid = "FORM-YZ9664D10Q89BB9CEYN3P8LQBRDQ34Y45GJFL6";
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 初始化参数值
|
|
|
|
|
+ */
|
|
|
|
|
+ userId = "02322511193621446331"; //操作人(Jason)的userId
|
|
|
|
|
+ createToTimeGMT = "2026-04-09 09:15:44";
|
|
|
|
|
+ hasMore = true; //第一页默认有数据
|
|
|
|
|
+ pageNo = 1;
|
|
|
|
|
+ pageSize = 100;
|
|
|
|
|
+ ydParamBuilder = YDParam.builder();
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.appType(appType);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.systemToken(systemToken);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formUuid(formUuid);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.userId(userId);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.createToTimeGMT(createToTimeGMT);
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 翻页获取数据
|
|
|
|
|
+ */
|
|
|
|
|
+ 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());
|
|
|
|
|
+ customerName = "";
|
|
|
|
|
+ businessUserId = "";
|
|
|
|
|
+ businessUserName = "";
|
|
|
|
|
+ kp = "";
|
|
|
|
|
+ formInstId = "";
|
|
|
|
|
+ for(int i=0;i<allRecords.size();i++){
|
|
|
|
|
+ /*
|
|
|
|
|
+ 重置是否为空标识
|
|
|
|
|
+ */
|
|
|
|
|
+ isCustomerNameEmpty = false;
|
|
|
|
|
+ isBusinessUserEmpty = false;
|
|
|
|
|
+ isKpEmpty = false;
|
|
|
|
|
+ isBusinessUserMulti = false;
|
|
|
|
|
+ isKpMulti = false;
|
|
|
|
|
+
|
|
|
|
|
+ //解析字段数据
|
|
|
|
|
+ fields = JSONObject.parseObject(JSONObject.toJSONString(allRecords.get(i).get("formData")));
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 获取客户名称数据
|
|
|
|
|
+ */
|
|
|
|
|
+ if(fields.get("textField_lfjg60xp") == null){
|
|
|
|
|
+ isCustomerNameEmpty = true;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ customerName = fields.getString("textField_lfjg60xp");
|
|
|
|
|
+ customerName = customerName.replace("\n",""); //去除换行符
|
|
|
|
|
+ customerName = customerName.trim(); //去除空格
|
|
|
|
|
+ if(StringUtils.isEmpty(customerName)){
|
|
|
|
|
+ isCustomerNameEmpty = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(isCustomerNameEmpty){
|
|
|
|
|
+ customerEmptyCount++;
|
|
|
|
|
+// throw new RuntimeException("客户公司名字段为空");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }else{
|
|
|
|
|
+// System.out.println("客户名称="+customerName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 获取业务员数据
|
|
|
|
|
+ */
|
|
|
|
|
+ if(fields.get("employeeField_lfjg60xx") == null){
|
|
|
|
|
+ isBusinessUserEmpty = true;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ businessUserJSONArray = fields.getJSONArray("employeeField_lfjg60xx");
|
|
|
|
|
+ if(businessUserJSONArray.isEmpty()){
|
|
|
|
|
+ isBusinessUserEmpty = true;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if(businessUserJSONArray.size()>1){ //一个客户有多个业务员负责对接
|
|
|
|
|
+ isBusinessUserMulti = true;
|
|
|
|
|
+ log.info("客户名称="+customerName+",业务员数量="+businessUserJSONArray.size());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(isBusinessUserMulti){
|
|
|
|
|
+ businessUserList = new ArrayList<>();
|
|
|
|
|
+ for (int j = 0; j < businessUserJSONArray.size(); j++) {
|
|
|
|
|
+ if (businessUserJSONArray.get(j) != null) {
|
|
|
|
|
+ businessUserList.add(String.valueOf(businessUserJSONArray.get(j)));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ businessUserName = String.join(",", businessUserList);
|
|
|
|
|
+// System.out.println("业务员="+businessUser);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ businessUserName = String.valueOf(businessUserJSONArray.get(0));
|
|
|
|
|
+ businessUserJSONArray = fields.getJSONArray("employeeField_lfjg60xx_id");
|
|
|
|
|
+ businessUserId = String.valueOf(businessUserJSONArray.get(0));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// System.out.println("业务员是否为空="+isBusinessUserEmpty);
|
|
|
|
|
+ if(isBusinessUserEmpty){
|
|
|
|
|
+// throw new RuntimeException("对接业务员为空");
|
|
|
|
|
+ }else{
|
|
|
|
|
+// System.out.println("业务员="+businessUser);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 获取KP数据
|
|
|
|
|
+ */
|
|
|
|
|
+ /*
|
|
|
|
|
+ if(allRecords.get(i).get("formInstanceId") != null){
|
|
|
|
|
+ formInstId = String.valueOf(allRecords.get(i).get("formInstanceId"));
|
|
|
|
|
+ ydParamBuilder = YDParam.builder();
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.appType(appType);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.systemToken(systemToken);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formUuid(formUuid);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.userId(userId);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formInstanceId(formInstId);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.tableFieldId("tableField_m6yfc2c2"); //【新建客户】子表单【客户KP信息】
|
|
|
|
|
+ yidaParam = ydParamBuilder.build();
|
|
|
|
|
+ kpRecords = ydService.queryDetails(yidaParam);
|
|
|
|
|
+ if(kpRecords == null || kpRecords.isEmpty()){
|
|
|
|
|
+ isKpEmpty = true;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if(kpRecords.size() == 1){ //单个KP
|
|
|
|
|
+ if(kpRecords.get(0).get("textField_m6yfc2c3") == null
|
|
|
|
|
+ || "".equals(String.valueOf(kpRecords.get(0).get("textField_m6yfc2c3")))){ //KP姓名为空
|
|
|
|
|
+ isKpEmpty = true;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ kp = String.valueOf(kpRecords.get(0).get("textField_m6yfc2c3"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{ //多个KP
|
|
|
|
|
+ isKpEmpty = true; //先假设所有记录KP为空
|
|
|
|
|
+ for (int j=0; j<kpRecords.size(); j++) {
|
|
|
|
|
+ if(kpRecords.get(j).get("textField_m6yfc2c3") == null
|
|
|
|
|
+ || "".equals(String.valueOf(kpRecords.get(j).get("textField_m6yfc2c3")))){ //KP姓名为空
|
|
|
|
|
+ //忽略
|
|
|
|
|
+ }else{
|
|
|
|
|
+ isKpMulti = true;
|
|
|
|
|
+ isKpEmpty = false; //只要有1条记录KP不为空,则更新标识
|
|
|
|
|
+ if(j == 0){
|
|
|
|
|
+ kp = String.valueOf(kpRecords.get(j).get("textField_m6yfc2c3"));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ kp += "," + String.valueOf(kpRecords.get(j).get("textField_m6yfc2c3"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isKpMulti) {
|
|
|
|
|
+ log.info("客户名称="+customerName+",KP数量="+kp.split(",").length);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+// System.out.println("KP是否为空="+isKpEmpty);
|
|
|
|
|
+ if(isKpEmpty){
|
|
|
|
|
+// throw new RuntimeException("KP姓名字段为空");
|
|
|
|
|
+ }else{
|
|
|
|
|
+// System.out.println("KP="+kp);
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 汇总客户数据
|
|
|
|
|
+ */
|
|
|
|
|
+ customerRecord = new HashMap<>();
|
|
|
|
|
+ customerRecord.put("customerName",customerName);
|
|
|
|
|
+ customerRecord.put("businessUserName",businessUserName);
|
|
|
|
|
+ customerRecord.put("businessUserId",businessUserId);
|
|
|
|
|
+// customerRecord.put("kp",kp);
|
|
|
|
|
+// System.out.println(JSONObject.toJSONString(customerRecord));
|
|
|
|
|
+ customerData.add(customerRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("客户名称为空的记录数="+customerEmptyCount);
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 排除有重复的客户
|
|
|
|
|
+ */
|
|
|
|
|
+ for (Map<String, String> record : customerData) {
|
|
|
|
|
+ customerName = record.get("customerName");
|
|
|
|
|
+ customerNameCountMap.merge(customerName, 1L, Long::sum);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (Map.Entry<String, Long> entry : customerNameCountMap.entrySet()) {
|
|
|
|
|
+ if (entry.getValue() > 1) {
|
|
|
|
|
+ System.out.println("客户名称="+entry.getKey()+",重复次数="+ entry.getValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (Map<String, String> record : customerData) {
|
|
|
|
|
+ customerName = record.get("customerName");
|
|
|
|
|
+ if(customerNameCountMap.get(customerName)==1){
|
|
|
|
|
+ customerDataDeduplicate.add(record);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return customerDataDeduplicate;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void updateSys1Sys2CustomerPart2Data(List<Map> sys2CustomerData) throws Exception {
|
|
|
|
|
+ /*
|
|
|
|
|
+ 参数定义
|
|
|
|
|
+ */
|
|
|
|
|
+ String appType; //宜搭应用编码
|
|
|
|
|
+ String formUuid; //表单编码
|
|
|
|
|
+ String systemToken; //宜搭应用密钥
|
|
|
|
|
+ String userId; //用户userId
|
|
|
|
|
+ YDSearch ydSearch; //检索条件(单个)
|
|
|
|
|
+ String searchCondition; //检索条件
|
|
|
|
|
+ YDParam yidaParam; //HTTP请求体
|
|
|
|
|
+ YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
|
|
|
|
|
+ String customerName; //客户名称
|
|
|
|
|
+ String kp; //KP
|
|
|
|
|
+ DDR_New yidaResult; //请求返回内容
|
|
|
|
|
+ List<Map> records; //记录数据
|
|
|
|
|
+ JSONObject fields; //字段数据
|
|
|
|
|
+ String formInstId; //表单实例ID
|
|
|
|
|
+ String updateFormDataJson; //更新内容
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 客户数据清洗
|
|
|
|
|
+ */
|
|
|
|
|
+ appType = "APP_IL6UN1IETFL3GATLFU0Z";
|
|
|
|
|
+ systemToken = "2MA66S71ZRH4FN2FJKW985LDOEBT30F3D7INMGMT";
|
|
|
|
|
+ formUuid = "FORM-30D3F6A5F4E34B459810BBB53619BDB8LX5I"; //客户名册part2
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 初始化参数值
|
|
|
|
|
+ */
|
|
|
|
|
+ userId = "02322511193621446331"; //操作人(Jason)的userId
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 遍历所有客户记录,通过客户名称去(客户数据清洗)找到对应记录,并更新KP姓名
|
|
|
|
|
+ */
|
|
|
|
|
+ for (Map<String, String> customerRecord : sys2CustomerData) {
|
|
|
|
|
+ /*
|
|
|
|
|
+ 通过客户名称去(客户数据清洗)找到对应记录
|
|
|
|
|
+ */
|
|
|
|
|
+ customerName = customerRecord.get("customerName");
|
|
|
|
|
+ kp = customerRecord.get("kp");
|
|
|
|
|
+ System.out.println("customerName="+customerName+",kp="+kp);
|
|
|
|
|
+ ydParamBuilder = YDParam.builder();
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.appType(appType);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.systemToken(systemToken);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formUuid(formUuid);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.userId(userId);
|
|
|
|
|
+ ydSearch = new YDSearch(
|
|
|
|
|
+ "textField_3utukqf",
|
|
|
|
|
+ customerName,
|
|
|
|
|
+ "客户公司名",
|
|
|
|
|
+ YDSearch.Type.TEXT_FIELD,
|
|
|
|
|
+ YDSearch.Operator.EQ
|
|
|
|
|
+ );
|
|
|
|
|
+ searchCondition = JSONObject.toJSONString(Arrays.asList(ydSearch));
|
|
|
|
|
+ ydParamBuilder.searchCondition(searchCondition);
|
|
|
|
|
+ yidaParam = ydParamBuilder.build();
|
|
|
|
|
+ yidaResult = ydClient.queryData(yidaParam,YDConf.FORM_QUERY.retrieve_list);
|
|
|
|
|
+ records = (List<Map>) yidaResult.getData();
|
|
|
|
|
+// fields = JSONObject.parseObject(JSONObject.toJSONString(records.get(0).get("formData")));
|
|
|
|
|
+ if(!records.isEmpty() && records.get(0) != null){
|
|
|
|
|
+ formInstId = String.valueOf(records.get(0).get("formInstanceId"));
|
|
|
|
|
+// System.out.println("formInstId="+formInstId);
|
|
|
|
|
+ /*
|
|
|
|
|
+ 更新KP姓名
|
|
|
|
|
+ */
|
|
|
|
|
+ updateFormDataJson = JSONObject.toJSONString(UtilMap.map("textField_h1e7kac",kp)); //KP姓名
|
|
|
|
|
+ ydParamBuilder = YDParam.builder();
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.appType(appType);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.systemToken(systemToken);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formUuid(formUuid);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.userId(userId);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formInstId(formInstId);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.updateFormDataJson(updateFormDataJson);
|
|
|
|
|
+ yidaParam = ydParamBuilder.build();
|
|
|
|
|
+ ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.update);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("更新所有KP完成");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void insertSys1Sys2CustomerAllData(List<Map> sys1Sys2CustomerData) throws Exception {
|
|
|
|
|
+ /*
|
|
|
|
|
+ 参数定义
|
|
|
|
|
+ */
|
|
|
|
|
+ String appType; //宜搭应用编码
|
|
|
|
|
+ String formUuid; //表单编码
|
|
|
|
|
+ String systemToken; //宜搭应用密钥
|
|
|
|
|
+ String userId; //用户userId
|
|
|
|
|
+ YDParam yidaParam; //HTTP请求体
|
|
|
|
|
+ YDParam.YDParamBuilder ydParamBuilder; //宜搭参数构建
|
|
|
|
|
+ Map<String,Object> customerRecord; //待插入记录
|
|
|
|
|
+ int customerRecordCount; //操作客户记录数
|
|
|
|
|
+ String insertFormDataJson; //新增内容
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 客户数据清洗
|
|
|
|
|
+ */
|
|
|
|
|
+ appType = "APP_IL6UN1IETFL3GATLFU0Z";
|
|
|
|
|
+ systemToken = "2MA66S71ZRH4FN2FJKW985LDOEBT30F3D7INMGMT";
|
|
|
|
|
+ formUuid = "FORM-300D7134EEB446AE82A6FDF330FAD006Q4HO"; //客户名册all
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 初始化参数值
|
|
|
|
|
+ */
|
|
|
|
|
+ userId = "02322511193621446331"; //操作人(Jason)的userId
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 遍历所有客户记录,通过客户名称去(客户数据清洗)找到对应记录,并更新KP姓名
|
|
|
|
|
+ */
|
|
|
|
|
+ customerRecordCount = 0;
|
|
|
|
|
+ for (Map<String, String> sys1Sys2CustomerRecord : sys1Sys2CustomerData) {
|
|
|
|
|
+ customerRecord = UtilMap.map(
|
|
|
|
|
+ "textField_mnwhxldz, " //客户名称
|
|
|
|
|
+ +"textField_mnwl12wu, " //业务(项目总表)
|
|
|
|
|
+ +"textField_mnwl12wv, " //业务(EASTAR业务数字化)
|
|
|
|
|
+ +"textField_mnwl12ww, " //sys1unionid
|
|
|
|
|
+ +"textField_mnwl12wx, " //sys1userid
|
|
|
|
|
+ +"textField_mnwl12wy, " //sys2userid
|
|
|
|
|
+ +"selectField_mnx00f7g, " //数据来源标记
|
|
|
|
|
+ +"selectField_mnwt8opl", //是否有差异
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("customerName"),
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("sys1BusinessUserName"),
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("sys2BusinessUserName"),
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("sys1unionid"),
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("sys1userid"),
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("sys2userid"),
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("source"),
|
|
|
|
|
+ sys1Sys2CustomerRecord.get("isAnyDifference")
|
|
|
|
|
+ );
|
|
|
|
|
+ insertFormDataJson = JSONObject.toJSONString(customerRecord); //KP姓名
|
|
|
|
|
+ ydParamBuilder = YDParam.builder();
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.appType(appType);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.systemToken(systemToken);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formUuid(formUuid);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.userId(userId);
|
|
|
|
|
+ ydParamBuilder = ydParamBuilder.formDataJson(insertFormDataJson);
|
|
|
|
|
+ yidaParam = ydParamBuilder.build();
|
|
|
|
|
+ ydClient.operateData(yidaParam,YDConf.FORM_OPERATION.create);
|
|
|
|
|
+ customerRecordCount++;
|
|
|
|
|
+ if(customerRecordCount % 100 == 0){
|
|
|
|
|
+ System.out.println("已处理"+customerRecordCount+"条客户数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(customerRecordCount % 100 != 0){
|
|
|
|
|
+ System.out.println("已处理"+customerRecordCount+"条客户数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("新增客户名册完成");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|