|
@@ -5,19 +5,25 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
+import com.fasterxml.jackson.databind.SerializationFeature;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
|
+import com.google.gson.JsonArray;
|
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
|
import com.kingdee.bos.webapi.entity.IdentifyInfo;
|
|
import com.kingdee.bos.webapi.entity.IdentifyInfo;
|
|
|
import com.kingdee.bos.webapi.entity.RepoRet;
|
|
import com.kingdee.bos.webapi.entity.RepoRet;
|
|
|
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
|
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.common.McException;
|
|
|
import com.malk.server.common.McR;
|
|
import com.malk.server.common.McR;
|
|
|
import com.malk.server.common.VenR;
|
|
import com.malk.server.common.VenR;
|
|
|
import com.malk.server.dingtalk.DDConf;
|
|
import com.malk.server.dingtalk.DDConf;
|
|
|
import com.malk.server.dingtalk.DDR;
|
|
import com.malk.server.dingtalk.DDR;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
import com.malk.service.dingtalk.DDClient;
|
|
import com.malk.service.dingtalk.DDClient;
|
|
|
|
|
+import com.malk.service.dingtalk.DDClient_Extension;
|
|
|
import com.malk.utils.PublicUtil;
|
|
import com.malk.utils.PublicUtil;
|
|
|
import com.malk.utils.UtilHttp;
|
|
import com.malk.utils.UtilHttp;
|
|
|
import com.malk.utils.UtilMap;
|
|
import com.malk.utils.UtilMap;
|
|
@@ -30,10 +36,18 @@ import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.time.Instant;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+import com.malk.zhiwei.test.DingTalkUtil;
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class ZwServiceImpl implements ZwService {
|
|
public class ZwServiceImpl implements ZwService {
|
|
@@ -256,7 +270,7 @@ public class ZwServiceImpl implements ZwService {
|
|
|
BillQuery billQuery = new BillQuery();
|
|
BillQuery billQuery = new BillQuery();
|
|
|
billQuery.setFormId("BD_MATERIAL");//产品信息
|
|
billQuery.setFormId("BD_MATERIAL");//产品信息
|
|
|
//编码 名称 规格型号 旧物料编码 物料分组 物料属性 基本单位 长 宽 高 体积 面积 密度 标准工时
|
|
//编码 名称 规格型号 旧物料编码 物料分组 物料属性 基本单位 长 宽 高 体积 面积 密度 标准工时
|
|
|
- billQuery.setFieldKeys("FCreateOrgId.FNumber,FApproveDate,FNumber,FName,FSpecification,FOldNumber,FMaterialGroup,FErpClsID,FBaseUnitId,FLENGTH,FWIDTH,FHEIGHT,FVOLUME,F_UNW_Qty_r03,F_UNW_Qty_6yt,FPerUnitStandHour");
|
|
|
|
|
|
|
+ billQuery.setFieldKeys("FCreateOrgId.FNumber,FApproveDate,FNumber,FName,FSpecification,FOldNumber,FMaterialGroup.FName,FErpClsID.FName,FBaseUnitId,FLENGTH,FWIDTH,FHEIGHT,FVOLUME,F_UNW_Qty_r03,F_UNW_Qty_6yt,FPerUnitStandHour");
|
|
|
List<Map> filterString = new ArrayList<>();
|
|
List<Map> filterString = new ArrayList<>();
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",3,"","","0"));//审核日期在今天之前N天以后
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",3,"","","0"));//审核日期在今天之前N天以后
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FCreateOrgId.FNumber","67","101","","","0"));//创建组织为101 研发中心
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FCreateOrgId.FNumber","67","101","","","0"));//创建组织为101 研发中心
|
|
@@ -274,8 +288,8 @@ public class ZwServiceImpl implements ZwService {
|
|
|
String name = item.getString("FName");
|
|
String name = item.getString("FName");
|
|
|
String spec = item.getString("FSpecification");
|
|
String spec = item.getString("FSpecification");
|
|
|
String oldNumber = item.getString("FOldNumber");
|
|
String oldNumber = item.getString("FOldNumber");
|
|
|
- Integer materialGroup = item.getInteger("FMaterialGroup");
|
|
|
|
|
- String erpClsId = item.getString("FErpClsID");
|
|
|
|
|
|
|
+ Integer materialGroup = item.getInteger("FMaterialGroup.FName");
|
|
|
|
|
+ String erpClsId = item.getString("FErpClsID.FName");
|
|
|
Integer baseUnitId = item.getInteger("FBaseUnitId");
|
|
Integer baseUnitId = item.getInteger("FBaseUnitId");
|
|
|
Double length = item.getDouble("FLENGTH");
|
|
Double length = item.getDouble("FLENGTH");
|
|
|
Double width = item.getDouble("FWIDTH");
|
|
Double width = item.getDouble("FWIDTH");
|
|
@@ -958,6 +972,306 @@ public class ZwServiceImpl implements ZwService {
|
|
|
log.info("客户已同步");
|
|
log.info("客户已同步");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void kehugenjin() throws JsonProcessingException {
|
|
|
|
|
+ //todo:1、遍历客户查询对应的系统创建的跟进时间
|
|
|
|
|
+ List<Map> list = (List<Map>) ydClient.queryData(YDParam.builder()
|
|
|
|
|
+ .formUuid("FORM-CF2DBE5A6A5941739BF7A05C82B361C48V5J")
|
|
|
|
|
+ .build()
|
|
|
|
|
+ ,YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ long time1;//最后跟进时间
|
|
|
|
|
+ long time2;//跟进时间
|
|
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
|
|
+ long tenDaysMillis = 10L * 24 * 3600 * 1000; // 10天毫秒数
|
|
|
|
|
+ for (Map li : list){
|
|
|
|
|
+ Object formDataObj = li.get("formData");
|
|
|
|
|
+ JsonNode formData = mapper.readTree(mapper.writeValueAsString(formDataObj)); // 统一转JsonNode
|
|
|
|
|
+ // 提取日期字段并转为可读格式
|
|
|
|
|
+ time1 = formData.get("dateField_l3tw3kfn").asLong();
|
|
|
|
|
+ System.out.println("最后跟进时间: " + sdf.format(new Date(time1)));
|
|
|
|
|
+ if(formData.has("dateField_mouumxhe")){
|
|
|
|
|
+ time2 = formData.get("dateField_mouumxhe").asLong();
|
|
|
|
|
+ System.out.println("跟进时间: " + sdf.format(new Date(time2)));
|
|
|
|
|
+ }else {//todo:2、超过10天,跟进时间字段没有值的话就发送通知给负责人和协同人
|
|
|
|
|
+ System.out.println("跟进时间字段为空");
|
|
|
|
|
+ // 检查是否超过10天
|
|
|
|
|
+ long diff = now - time1;
|
|
|
|
|
+ if (diff > tenDaysMillis) {
|
|
|
|
|
+ log.info("{},超过10天未填写跟进时间,发送通知",formData.get("textField_lqanqe6j"));
|
|
|
|
|
+ // 获取负责人ID和协同人ID
|
|
|
|
|
+ String responsiblePerson = getEmployeeId(formData, "employeeField_lqanqe6n_id");
|
|
|
|
|
+ System.out.println("负责人:" + responsiblePerson);
|
|
|
|
|
+ String collaborator = getEmployeeId(formData, "employeeField_lqanqe6o_id");
|
|
|
|
|
+ System.out.println("协同人:" + collaborator);
|
|
|
|
|
+ //todo:3、组装数据卡片推送
|
|
|
|
|
+ JSONObject cardData = new JSONObject();
|
|
|
|
|
+ System.out.println("customer:" +formData.get("textField_lqanqe6j") );
|
|
|
|
|
+ cardData.put("customer", formData.get("textField_lqanqe6j").asText());//客户
|
|
|
|
|
+ cardData.put("hangye", formData.get("selectField_lqanqe6t").asText());//行业
|
|
|
|
|
+ cardData.put("fuzeren", DingTalkUtil.getUserName(responsiblePerson));//负责人
|
|
|
|
|
+ cardData.put("xiezuoren", DingTalkUtil.getUserName(collaborator));//协同人
|
|
|
|
|
+ cardData.put("link","https://yae2gb.aliwork.com/APP_G0JV4FGIR0EOSBD0K7XV/formDetail/FORM-CF2DBE5A6A5941739BF7A05C82B361C48V5J?formInstId="+formData.get("textField_mo82diej"));//链接
|
|
|
|
|
+ JSONObject message = new JSONObject();
|
|
|
|
|
+ message.put("cardData", cardData);
|
|
|
|
|
+ message.put("outTrackId", String.valueOf(System.currentTimeMillis()));
|
|
|
|
|
+ message.put("openSpaceId", "dtv1.card//IM_ROBOT." + collaborator);//IM机器人单聊(协同人)
|
|
|
|
|
+ message.put("cardTemplateId", "bcaaaf36-32a3-405b-b7a4-940f3dd846aa.schema");
|
|
|
|
|
+ message.put("robotCode", "ding2ru5r5d2vtaqf67m");
|
|
|
|
|
+ createAndDeliverCard(message);//调用卡片推送
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("10天内未填写,暂不通知");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("-----------------------------------");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void customerfollow_up() throws JsonProcessingException {
|
|
|
|
|
+ //todo:1、遍历客户查询对应的系统创建的跟进时间
|
|
|
|
|
+ List<Map> list = (List<Map>) ydClient.queryData(YDParam.builder()
|
|
|
|
|
+ .formUuid("FORM-CF2DBE5A6A5941739BF7A05C82B361C48V5J")
|
|
|
|
|
+ .build()
|
|
|
|
|
+ ,YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ long time1;//最后跟进时间
|
|
|
|
|
+ long time2;//跟进时间
|
|
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
|
|
+ long tenDaysMillis = 10L * 24 * 3600 * 1000; // 10天毫秒数
|
|
|
|
|
+ for (Map li : list){
|
|
|
|
|
+ Object formDataObj = li.get("formData");
|
|
|
|
|
+ JsonNode formData = mapper.readTree(mapper.writeValueAsString(formDataObj)); // 统一转JsonNode
|
|
|
|
|
+ // 提取日期字段并转为可读格式
|
|
|
|
|
+ time1 = formData.get("dateField_l3tw3kfn").asLong();
|
|
|
|
|
+ System.out.println("最后跟进时间: " + sdf.format(new Date(time1)));
|
|
|
|
|
+ if(formData.has("dateField_mouumxhe")){
|
|
|
|
|
+ time2 = formData.get("dateField_mouumxhe").asLong();
|
|
|
|
|
+ System.out.println("跟进时间: " + sdf.format(new Date(time2)));
|
|
|
|
|
+ }else {//todo:2、超过10天,跟进时间字段没有值的话就发送通知给负责人和协同人
|
|
|
|
|
+ System.out.println("跟进时间字段为空");
|
|
|
|
|
+ // 检查是否超过10天
|
|
|
|
|
+ long diff = now - time1;
|
|
|
|
|
+ if (diff > tenDaysMillis) {
|
|
|
|
|
+ log.info("{},超过10天未填写跟进时间,发送通知",formData.get("textField_lqanqe6j"));
|
|
|
|
|
+ // 获取负责人ID和协同人ID
|
|
|
|
|
+ String responsiblePerson = getEmployeeId(formData, "employeeField_lqanqe6n_id");
|
|
|
|
|
+ System.out.println("负责人:" + responsiblePerson);
|
|
|
|
|
+ String collaborator = getEmployeeId(formData, "employeeField_lqanqe6o_id");
|
|
|
|
|
+ System.out.println("协同人:" + collaborator);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ HashMap param = new HashMap();
|
|
|
|
|
+ param.put("access_token",ddClient.getAccessToken());
|
|
|
|
|
+ HashMap body = new HashMap();
|
|
|
|
|
+ body.put("agent_id", 4457395865L);
|
|
|
|
|
+ body.put("userid_list", collaborator);//加上负责人
|
|
|
|
|
+ // 构建 msg 对象
|
|
|
|
|
+ HashMap<String, Object> msg = new HashMap<>();
|
|
|
|
|
+ msg.put("msgtype", "link");
|
|
|
|
|
+ // text 部分(注意:原 JSON 中同时包含 text 和 link,这里按原样保留)
|
|
|
|
|
+ HashMap<String, String> text = new HashMap<>();
|
|
|
|
|
+ text.put("content", "请及时跟进客户");
|
|
|
|
|
+ msg.put("text", text);
|
|
|
|
|
+ // link 部分
|
|
|
|
|
+ HashMap<String, String> link = new HashMap<>();
|
|
|
|
|
+ link.put("picUrl", "https://wwww.baidu.com");
|
|
|
|
|
+ link.put("messageUrl", "https://yae2gb.aliwork.com/APP_G0JV4FGIR0EOSBD0K7XV/formDetail/FORM-CF2DBE5A6A5941739BF7A05C82B361C48V5J?formInstId=" + formData.get("textField_mo82diej"));
|
|
|
|
|
+ link.put("text", "10天内未跟进,请及时跟进" + formData.get("textField_lqanqe6j"));
|
|
|
|
|
+ link.put("title", "[请跟进客户]");
|
|
|
|
|
+ msg.put("link", link);
|
|
|
|
|
+ body.put("msg", msg);
|
|
|
|
|
+ String doPost = UtilHttp.doPost("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", null, param, body);
|
|
|
|
|
+ System.out.println("[返回结果:]" + doPost);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("10天内未填写,暂不通知");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @SneakyThrows
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void kehugenjinxin() throws JsonProcessingException {
|
|
|
|
|
+ //todo:①、查询下销售订单中有多少的客户,需要去重计数下(分页查询下)
|
|
|
|
|
+ String instanceId = "FORM-7B112A3733EC412FB27D56D8AC242E5BHIL4";
|
|
|
|
|
+ YDParam ydParam = YDParam.builder().formUuid(instanceId).build();
|
|
|
|
|
+ ydParam.setPageSize(1);
|
|
|
|
|
+ long totalCount = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
|
|
+
|
|
|
|
|
+ // 定义去重集合(LinkedHashSet保证插入顺序)
|
|
|
|
|
+ Set<String> uniqueCustomerSet = new LinkedHashSet<>();
|
|
|
|
|
+ ydParam.setCurrentPage(1);
|
|
|
|
|
+ ydParam.setPageSize(100);
|
|
|
|
|
+ for (int page = 1; page <= (Math.ceil(totalCount / 100)!=0?Math.ceil(totalCount / 100):1) + 1; page++) {
|
|
|
|
|
+ List<Map> dataList = new ArrayList<>();
|
|
|
|
|
+ ydParam.setCurrentPage(page);
|
|
|
|
|
+ dataList.addAll((List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData());
|
|
|
|
|
+ for (Map li :dataList){
|
|
|
|
|
+ Map map = (Map)li.get("formData");
|
|
|
|
|
+ String kehu = map.get("textField_mniksrqb").toString();
|
|
|
|
|
+ System.out.println("客户:" + kehu);
|
|
|
|
|
+ uniqueCustomerSet.add(kehu); // Set自动去重
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //todo:②、查询下客户信息表
|
|
|
|
|
+ String instanceId_A = "FORM-A4C9F5F35B48419A9C607D3408ECAB02A7FL";
|
|
|
|
|
+ YDParam ydParam_A = YDParam.builder().formUuid(instanceId_A).build();
|
|
|
|
|
+ ydParam_A.setPageSize(1);
|
|
|
|
|
+ long totalCount_A = ydClient.queryData(ydParam_A, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
|
|
+ ydParam_A.setCurrentPage(1);
|
|
|
|
|
+ ydParam_A.setPageSize(100);
|
|
|
|
|
+ for (int page = 1; page <= (Math.ceil(totalCount_A / 100)!=0?Math.ceil(totalCount_A / 100):1) + 1; page++) {
|
|
|
|
|
+ List<Map> dataList = new ArrayList<>();
|
|
|
|
|
+ ydParam_A.setCurrentPage(page);
|
|
|
|
|
+ dataList.addAll((List<Map>) ydClient.queryData(ydParam_A, YDConf.FORM_QUERY.retrieve_search_form).getData());
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+ for (Map li :dataList){
|
|
|
|
|
+ Object formDataObj = li.get("formData");
|
|
|
|
|
+ JsonNode formData = mapper.readTree(mapper.writeValueAsString(formDataObj)); // 统一转JsonNode
|
|
|
|
|
+
|
|
|
|
|
+ Map map = (Map)li.get("formData");
|
|
|
|
|
+ String IStixing = map.get("selectField_mp3r6ad3").toString();//是否已经发送提醒
|
|
|
|
|
+ String ISpush = map.get("selectField_mp3s339j").toString();//是否推送公海池
|
|
|
|
|
+ String kehu = map.get("textField_lqanqe6j").toString();
|
|
|
|
|
+ String hangye = map.get("selectField_lqanqe6t").toString();
|
|
|
|
|
+ String responsiblePerson = getEmployeeId(formData, "employeeField_lqanqe6n_id");
|
|
|
|
|
+ System.out.println("负责人:" + responsiblePerson);
|
|
|
|
|
+ String collaborator = getEmployeeId(formData, "employeeField_lqanqe6o_id");
|
|
|
|
|
+ System.out.println("协同人:" + collaborator);
|
|
|
|
|
+ //todo:③、是否是成交客户
|
|
|
|
|
+ if (uniqueCustomerSet.contains(kehu)) {
|
|
|
|
|
+ // 成交客户:不做任何处理
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 非成交客户:需要检查以客户表单中的跟进时间为基准,往后3周内是否有第三个表单的提交记录
|
|
|
|
|
+ Object genjinObj = map.get("dateField_l3tw3kfn");
|
|
|
|
|
+ if (genjinObj == null) continue;
|
|
|
|
|
+ LocalDate followUpDate;
|
|
|
|
|
+ long timestamp = Long.parseLong(genjinObj.toString());
|
|
|
|
|
+ followUpDate = Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
|
|
+ // 检查第三个表单中是否有 [跟进时间, 跟进时间+3周] 内的记录
|
|
|
|
|
+ boolean hasRecordIn3Weeks = checkCustomerFollowUpRecord(kehu, followUpDate, followUpDate.plusWeeks(3));
|
|
|
|
|
+ if (!hasRecordIn3Weeks) {
|
|
|
|
|
+ //发送提醒(注意:只发送一次提醒所以提前判断)
|
|
|
|
|
+ if("否".equals(IStixing)) {
|
|
|
|
|
+ //todo:3、组装数据卡片推送
|
|
|
|
|
+ JSONObject cardData = new JSONObject();
|
|
|
|
|
+ cardData.put("customer", kehu);//客户
|
|
|
|
|
+ cardData.put("hangye", hangye);//行业
|
|
|
|
|
+ cardData.put("fuzeren", DingTalkUtil.getUserName(responsiblePerson));//负责人
|
|
|
|
|
+ cardData.put("xiezuoren", DingTalkUtil.getUserName(collaborator));//协同人
|
|
|
|
|
+ cardData.put("link", "https://yae2gb.aliwork.com/APP_G0JV4FGIR0EOSBD0K7XV/formDetail/FORM-FORM-A4C9F5F35B48419A9C607D3408ECAB02A7FL?formInstId=" + map.get("textField_mo82diej").toString());//链接
|
|
|
|
|
+ /*协同人*/
|
|
|
|
|
+ JSONObject message = new JSONObject();
|
|
|
|
|
+ message.put("cardData", cardData);
|
|
|
|
|
+ message.put("outTrackId", String.valueOf(System.currentTimeMillis()));
|
|
|
|
|
+ message.put("openSpaceId", "dtv1.card//IM_ROBOT." + collaborator);//IM机器人单聊(协同人)
|
|
|
|
|
+ message.put("cardTemplateId", "bcaaaf36-32a3-405b-b7a4-940f3dd846aa.schema");
|
|
|
|
|
+ message.put("robotCode", "ding2ru5r5d2vtaqf67m");
|
|
|
|
|
+ createAndDeliverCard(message);//调用卡片推送
|
|
|
|
|
+ /*负责人*/
|
|
|
|
|
+ JSONObject message_A = new JSONObject();
|
|
|
|
|
+ message_A.put("cardData", cardData);
|
|
|
|
|
+ message_A.put("outTrackId", String.valueOf(System.currentTimeMillis()));
|
|
|
|
|
+ message_A.put("openSpaceId", "dtv1.card//IM_ROBOT." + responsiblePerson);//IM机器人单聊(负责人)
|
|
|
|
|
+ message_A.put("cardTemplateId", "bcaaaf36-32a3-405b-b7a4-940f3dd846aa.schema");
|
|
|
|
|
+ message_A.put("robotCode", "ding2ru5r5d2vtaqf67m");
|
|
|
|
|
+ createAndDeliverCard(message_A);//调用卡片推送
|
|
|
|
|
+ /*更新已提醒字段*/
|
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
|
+ .appType("APP_G0JV4FGIR0EOSBD0K7XV")
|
|
|
|
|
+ .systemToken("F2766O91DH8WNHHUD63KBDP3B5GE234U4ZSBMBS1")
|
|
|
|
|
+ .formInstanceId(map.get("textField_mo82diej").toString())
|
|
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("selectField_mp3r6ad3","是")))
|
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean hasRecordIn4Weeks = checkCustomerFollowUpRecord(kehu, followUpDate, followUpDate.plusWeeks(4));
|
|
|
|
|
+ if (!hasRecordIn4Weeks) {
|
|
|
|
|
+ // 4周仍无跟进 → 推送公海池
|
|
|
|
|
+ if("否".equals(ISpush)){
|
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
|
+ .appType("APP_G0JV4FGIR0EOSBD0K7XV")
|
|
|
|
|
+ .systemToken("F2766O91DH8WNHHUD63KBDP3B5GE234U4ZSBMBS1")
|
|
|
|
|
+ .formInstanceId(map.get("textField_mo82diej").toString())
|
|
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("employeeField_lqanqe6n, selectField_mp3s339j","","是")))
|
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);//删除负责人信息
|
|
|
|
|
+ log.info("{},客户4周内未跟进客户,已推送到公海池",kehu);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查指定客户在第三个表单 FORM-16B6995591BA44FFAB07D6115E27F8C3JWXV 中,
|
|
|
|
|
+ * 是否在 [startDate, endDate] 范围内有提交记录
|
|
|
|
|
+ * @param customerName 客户名称
|
|
|
|
|
+ * @param startDate 开始日期(包含)
|
|
|
|
|
+ * @param endDate 结束日期(包含)
|
|
|
|
|
+ * @return true-存在记录,false-不存在
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean checkCustomerFollowUpRecord(String customerName, LocalDate startDate, LocalDate endDate) {
|
|
|
|
|
+ // todo: 请根据实际 API 实现查询逻辑
|
|
|
|
|
+ // 示例:构造查询参数查询表单 FORM-16B6995591BA44FFAB07D6115E27F8C3JWXV
|
|
|
|
|
+ // 过滤条件:客户名字段等于 customerName,提交日期字段 >= startDate 且 <= endDate
|
|
|
|
|
+ // 如果查询结果条数 > 0 则返回 true,否则返回 false
|
|
|
|
|
+ boolean panduan = false;
|
|
|
|
|
+ boolean IShanyou = false;//true——有跟进记录 false——无跟进记录
|
|
|
|
|
+ LocalDate currentDate = LocalDate.now(); // 获取当前系统日期
|
|
|
|
|
+ String instanceId_B = "FORM-16B6995591BA44FFAB07D6115E27F8C3JWXV";
|
|
|
|
|
+ YDParam ydParam_B = YDParam.builder().formUuid(instanceId_B).build();
|
|
|
|
|
+ ydParam_B.setPageSize(1);
|
|
|
|
|
+ long totalCount_B = ydClient.queryData(ydParam_B, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
|
|
+ ydParam_B.setCurrentPage(1);
|
|
|
|
|
+ ydParam_B.setPageSize(100);
|
|
|
|
|
+ for (int page = 1; page <= (Math.ceil(totalCount_B / 100) != 0 ? Math.ceil(totalCount_B / 100) : 1) + 1; page++) {
|
|
|
|
|
+ List<Map> dataList = new ArrayList<>();
|
|
|
|
|
+ ydParam_B.setCurrentPage(page);
|
|
|
|
|
+ dataList.addAll((List<Map>) ydClient.queryData(ydParam_B, YDConf.FORM_QUERY.retrieve_search_form).getData());
|
|
|
|
|
+ for (Map li : dataList) {
|
|
|
|
|
+ Map map = (Map) li.get("formData");
|
|
|
|
|
+ String kehuName = map.get("textField_lqbo4rw0").toString();
|
|
|
|
|
+ if(kehuName.contains(customerName)){
|
|
|
|
|
+ Object dateObj = map.get("dateField_lqbo4rw1"); // 需要替换为实际字段名
|
|
|
|
|
+ LocalDate recordDate;
|
|
|
|
|
+ long timestamp = Long.parseLong(dateObj.toString());
|
|
|
|
|
+ recordDate = Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
|
|
+ // 判断是否在 [startDate, endDate] 区间内(包含边界)
|
|
|
|
|
+ if (!recordDate.isBefore(startDate) && !recordDate.isAfter(endDate)) {
|
|
|
|
|
+ panduan =true;
|
|
|
|
|
+ IShanyou = true;
|
|
|
|
|
+ return panduan; // 找到一条记录即满足条件
|
|
|
|
|
+ }else {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ /*虽然没有提交跟进 但是在规定周内,则不需要返回true 超过规定时间内则返回false*/
|
|
|
|
|
+ if(!IShanyou){
|
|
|
|
|
+ if (!currentDate.isBefore(startDate) && !currentDate.isAfter(endDate)){
|
|
|
|
|
+ panduan = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return panduan;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private McR saveToAudit(String formid, Object object) throws Exception {
|
|
private McR saveToAudit(String formid, Object object) throws Exception {
|
|
|
JSONObject resultObj = new JSONObject();
|
|
JSONObject resultObj = new JSONObject();
|
|
@@ -1005,8 +1319,8 @@ public class ZwServiceImpl implements ZwService {
|
|
|
/*TODO:钉钉获取应用token*/
|
|
/*TODO:钉钉获取应用token*/
|
|
|
public McR Accesstoken() throws JsonProcessingException{
|
|
public McR Accesstoken() throws JsonProcessingException{
|
|
|
HashMap body = new HashMap();
|
|
HashMap body = new HashMap();
|
|
|
- body.put("appKey","dinga81qkwb0sqxqnviw");
|
|
|
|
|
- body.put("appSecret","IvePeLbMMxAzIr228RaGcOxgSSOuJ0trbenX3BbahjeLFA2YeaFv0W9F_6Ar5G0P");
|
|
|
|
|
|
|
+ body.put("appKey","ding2ru5r5d2vtaqf67m");
|
|
|
|
|
+ body.put("appSecret","nuxuhb23-XX26_P5fP8Kbv43R3SzCiEhxkt4hQ_p44XA8r6hR3UkgLrTeXxRH_RA");
|
|
|
String doGet = UtilHttp.doPost("https://oapi.dingtalk.com/v1.0/oauth2/accessToken", null, null,body);
|
|
String doGet = UtilHttp.doPost("https://oapi.dingtalk.com/v1.0/oauth2/accessToken", null, null,body);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(doGet);
|
|
JSONObject jsonObject = JSONObject.parseObject(doGet);
|
|
|
String accessToken = jsonObject.getString("access_token");
|
|
String accessToken = jsonObject.getString("access_token");
|
|
@@ -1014,4 +1328,38 @@ public class ZwServiceImpl implements ZwService {
|
|
|
return McR.success(accessToken);
|
|
return McR.success(accessToken);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 从JsonNode中获取员工ID(取数组第一个值)
|
|
|
|
|
+ */
|
|
|
|
|
+ private String getEmployeeId(JsonNode formData, String fieldName) {
|
|
|
|
|
+ JsonNode node = formData.get(fieldName);
|
|
|
|
|
+ if (node != null && node.isArray() && node.size() > 0) {
|
|
|
|
|
+ return node.get(0).asText();
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果没有_id字段,尝试取名字字段
|
|
|
|
|
+ String nameField = fieldName.replace("_id", "");
|
|
|
|
|
+ JsonNode nameNode = formData.get(nameField);
|
|
|
|
|
+ if (nameNode != null && nameNode.isArray() && nameNode.size() > 0) {
|
|
|
|
|
+ return nameNode.get(0).asText();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient_Extension ddClientExtension;
|
|
|
|
|
+ /*群消息卡片推送*/
|
|
|
|
|
+ public McR createAndDeliverCard(@RequestBody JSONObject param){
|
|
|
|
|
+ log.info("推送消息:{}",param);
|
|
|
|
|
+ McException.assertParamException_Null(param,"cardData","outTrackId","openSpaceId","robotCode","cardTemplateId");
|
|
|
|
|
+ Map<String,Object> data = new HashMap();
|
|
|
|
|
+ data.put("imRobotOpenDeliverModel", UtilMap.map("robotCode, spaceType",param.getString("robotCode"),"IM_ROBOT"));
|
|
|
|
|
+ data.put("imRobotOpenSpaceModel",UtilMap.map("supportForward",true));
|
|
|
|
|
+ if(param.containsKey("extInfo")){
|
|
|
|
|
+ data.putAll(param.getJSONObject("extInfo"));
|
|
|
|
|
+ }
|
|
|
|
|
+ Map map = ddClientExtension.createAndDeliverCards(ddClient.getAccessToken(),param.getString("cardTemplateId"),param.getString("outTrackId"),
|
|
|
|
|
+ UtilMap.map("cardParamMap",param.getJSONObject("cardData")),param.getString("openSpaceId"),data);
|
|
|
|
|
+ return McR.success(map);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|