|
@@ -2,6 +2,7 @@ package com.malk.mc.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -12,15 +13,15 @@ import com.malk.server.aliwork.YDParam;
|
|
|
import com.malk.server.common.McException;
|
|
|
import com.malk.server.common.McR;
|
|
|
import com.malk.server.dingtalk.DDConf;
|
|
|
+import com.malk.server.dingtalk.DDR;
|
|
|
import com.malk.server.dingtalk.DDR_New;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.service.aliwork.YDService;
|
|
|
import com.malk.service.dingtalk.DDClient;
|
|
|
import com.malk.service.dingtalk.DDClient_Contacts;
|
|
|
+import com.malk.service.dingtalk.DDClient_Notice;
|
|
|
import com.malk.service.dingtalk.DDClient_Workflow;
|
|
|
-import com.malk.utils.PublicUtil;
|
|
|
-import com.malk.utils.UtilDateTime;
|
|
|
-import com.malk.utils.UtilHttp;
|
|
|
-import com.malk.utils.UtilMap;
|
|
|
+import com.malk.utils.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.slf4j.MDC;
|
|
@@ -49,6 +50,9 @@ public class McYdServiceImpl implements McYdService {
|
|
|
@Autowired
|
|
|
private DDClient_Workflow ddClientWorkflow;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DDClient_Notice ddClientNotice;
|
|
|
+
|
|
|
@Autowired
|
|
|
private DDClient_Contacts ddClient_contacts;
|
|
|
@Override
|
|
@@ -620,23 +624,32 @@ public class McYdServiceImpl implements McYdService {
|
|
|
String[] dd = McProject.getDd(pid);
|
|
|
String appKey = "";
|
|
|
String appSecret = "";
|
|
|
- if (!PublicUtil.isNull(pid) && dd != null && dd.length >= 2) {
|
|
|
+ String agentId = "";
|
|
|
+ if (!PublicUtil.isNull(pid) && dd != null && dd.length >= 3) {
|
|
|
appKey = dd[0];
|
|
|
appSecret = dd[1];
|
|
|
+ agentId = dd[2];
|
|
|
+ }
|
|
|
+ String[] yida = McProject.getYida(pid);
|
|
|
+ String appType = "";
|
|
|
+ String systemToken = "";
|
|
|
+ if (!PublicUtil.isNull(pid) && dd != null && dd.length >= 2) {
|
|
|
+ appType = yida[0];
|
|
|
+ systemToken = yida[1];
|
|
|
}
|
|
|
|
|
|
// 执行分享逻辑 [ 拼接后的权限组 ]
|
|
|
- McException.assertParamException_Null(data, "compId, userIds, userId, content, atUserId, appUrl, pcUrl");
|
|
|
+ McException.assertParamException_Null(data, "compId, userIds, userId, atUserId, isNotice");
|
|
|
//开始抓取宜搭对应的子表数据
|
|
|
String processInstanceId = data.get("processInstanceId").toString();
|
|
|
- String appUrl = data.get("appUrl").toString();
|
|
|
- String pcUrl = data.get("pcUrl").toString();
|
|
|
List<String> atUserId = (List<String>) data.get("atUserId");
|
|
|
|
|
|
Map map = new HashMap();
|
|
|
map.put(UtilMap.getString(data, "compId"),UtilMap.getList(data, "userIds"));
|
|
|
|
|
|
ydClient.operateData(YDParam.builder()
|
|
|
+ .appType(appType)
|
|
|
+ .systemToken(systemToken)
|
|
|
.formInstId(processInstanceId)
|
|
|
.updateFormDataJson(JSON.toJSONString(map))
|
|
|
.build(), YDConf.FORM_OPERATION.update);
|
|
@@ -652,22 +665,60 @@ public class McYdServiceImpl implements McYdService {
|
|
|
String name = jsonObject.getString("name");
|
|
|
names.add(name);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- data.put("content", names.stream().collect(Collectors.joining(",")) + ":" +UtilMap.getString(data, "content"));
|
|
|
-
|
|
|
+ List<Map> searchCondition = new ArrayList<>();
|
|
|
+ searchCondition.addAll(Arrays.asList(
|
|
|
+ YDConf.searchCondition_TextFiled(data.get("processKey").toString(), data.get("processInstanceId").toString(),"eq")
|
|
|
+ ));
|
|
|
+ String title = UtilMap.getString(data, "content").isEmpty() || !ObjectUtil.isNotNull(UtilMap.getString(data, "content")) ? "单据分享" : UtilMap.getString(data, "content");
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .appType(appType)
|
|
|
+ .systemToken(systemToken)
|
|
|
+ .searchCondition(JSON.toJSONString(searchCondition))
|
|
|
+ .formUuid(data.get("formId").toString())
|
|
|
+ .formDataJson(JSON.toJSONString(UtilMap.map(data.get("processKey").toString()+", "+data.get("empKey").toString()+", "+data.get("titleKey").toString(),
|
|
|
+ data.get("processInstanceId").toString(),UtilMap.getList(data, "userIds"),title)))
|
|
|
+ .useLatestVersion(true)
|
|
|
+ .build(), YDConf.FORM_OPERATION.upsert_v2);
|
|
|
if (UtilMap.getBoolean(data, "isNotice")) {
|
|
|
- /*查询钉钉人员*/
|
|
|
- ddClientWorkflow.createTBTask(ddClient.getAccessToken(appKey,appSecret),UtilMap.getString(data, "userId"),"流程分享:"+UtilMap.getString(data, "content"),UtilMap.getString(data, "content"),
|
|
|
- UtilDateTime.getLocalDateTimeTimeStamp(LocalDate.now().plusDays(7).atTime(LocalTime.MAX)), atUserId,null
|
|
|
- ,UtilMap.map("appUrl, pcUrl",appUrl+"/processDetail"+"?procInsId="+processInstanceId,pcUrl+"/processDetail"+"?procInsId="+processInstanceId),false,30,UtilMap.map("dingNotify","1"));
|
|
|
+// data.put("content", names.stream().collect(Collectors.joining(",")) + UtilMap.getString(data, "content"));
|
|
|
+ String appUrl = data.get("appUrl").toString();
|
|
|
+ String pcUrl = data.get("pcUrl").toString();
|
|
|
+ if ( !ObjectUtil.isNotNull(UtilMap.getString(data,"sendType")) || UtilMap.getString(data,"sendType").isEmpty() || "工作通知".equals(UtilMap.getString(data,"sendType"))){
|
|
|
+ Map<String, String> contentMap = new HashMap<>();
|
|
|
+ contentMap.put("title",title);
|
|
|
+ contentMap.put("text",title);
|
|
|
+ contentMap.put("picUrl",pcUrl+"/processDetail"+"?procInsId="+processInstanceId);
|
|
|
+ contentMap.put("messageUrl",pcUrl+"/processDetail"+"?procInsId="+processInstanceId);
|
|
|
+
|
|
|
+ Map<String, Object> msg = new HashMap<>();
|
|
|
+ msg.put("msgtype","link");
|
|
|
+ msg.put("link",contentMap);
|
|
|
+ sendNotification(ddClient.getAccessToken(appKey,appSecret),atUserId,null,false,msg,agentId);
|
|
|
+
|
|
|
+ } else if ("钉钉代办".equals(UtilMap.getString(data, "sendType"))) {
|
|
|
+ /*查询钉钉人员*/
|
|
|
+ ddClientWorkflow.createTBTask(ddClient.getAccessToken(appKey,appSecret),UtilMap.getString(data, "userId"),"流程分享:"+UtilMap.getString(data, "content"),UtilMap.getString(data, "content"),
|
|
|
+ UtilDateTime.getLocalDateTimeTimeStamp(LocalDate.now().plusDays(7).atTime(LocalTime.MAX)), atUserId,null
|
|
|
+ ,UtilMap.map("appUrl, pcUrl",appUrl+"/processDetail"+"?procInsId="+processInstanceId,pcUrl+"/processDetail"+"?procInsId="+processInstanceId),false,30,UtilMap.map("dingNotify","1"));
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
return McR.success();
|
|
|
}
|
|
|
return McR.errorParam("参数缺失!");
|
|
|
}
|
|
|
+ public String sendNotification(String access_token, List<String> userid_list, List<String> dept_id_list, boolean to_all_user, Map msg, String agent_id) {
|
|
|
+ Map body = UtilMap.map("agent_id, to_all_user, msg", new Object[]{agent_id, to_all_user, msg});
|
|
|
+ if (UtilList.isNotEmpty(userid_list)) {
|
|
|
+ body.put("userid_list", String.join(",", userid_list));
|
|
|
+ }
|
|
|
+ if (UtilList.isNotEmpty(dept_id_list)) {
|
|
|
+ body.put("dept_id_list", String.join(",", dept_id_list));
|
|
|
+ }
|
|
|
|
|
|
+ DDR ddr = DDR.doPost("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", (Map)null, DDConf.initTokenParams(access_token), body);
|
|
|
+ return ddr.getTask_id();
|
|
|
+ }
|
|
|
@Override
|
|
|
public McR batchUpdateSpecifiedQuantityData(Map map) {
|
|
|
String formInstId = UtilMap.getString(map, "formInstId");//当前表实例id
|