|
@@ -3,6 +3,7 @@ package com.malk.mc.service.impl;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.crypto.digest.MD5;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
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;
|
|
@@ -23,6 +24,7 @@ import com.malk.service.dingtalk.DDClient_Notice;
|
|
|
import com.malk.service.dingtalk.DDClient_Workflow;
|
|
import com.malk.service.dingtalk.DDClient_Workflow;
|
|
|
import com.malk.utils.*;
|
|
import com.malk.utils.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.slf4j.MDC;
|
|
import org.slf4j.MDC;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -763,6 +765,126 @@ public class McYdServiceImpl implements McYdService {
|
|
|
return McR.success();
|
|
return McR.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public McR syncYdAuth(Map map) {
|
|
|
|
|
+ String matrixId = UtilMap.getString(map, "matrixId");//矩阵id
|
|
|
|
|
+ String corpId = UtilMap.getString(map, "corpId");//corpId
|
|
|
|
|
+ String userId = UtilMap.getString(map, "userId");//userId
|
|
|
|
|
+ String corpToken = UtilMap.getString(map, "corpToken");//corpToken
|
|
|
|
|
+ String formInstId = UtilMap.getString(map, "formInstId");//实例id
|
|
|
|
|
+ String[] conditionColumns = UtilMap.getString(map, "conditionColumns").split(",");//矩阵表条件列(名称)
|
|
|
|
|
+ String[] conditionColumnValues = UtilMap.getString(map, "conditionColumnValues").split(",");;//矩阵表条件列值
|
|
|
|
|
+ String[] resultColumns = UtilMap.getString(map, "resultColumns").split(",");;//矩阵表角色列(名称)
|
|
|
|
|
+ String[] resultColumnFields = UtilMap.getString(map, "resultColumnFields").split(",");;//矩阵表角色列值(表单成员组件唯一标识)
|
|
|
|
|
+
|
|
|
|
|
+ String[] conditionColumnIds = new String[conditionColumns.length];//矩阵表条件列(id)
|
|
|
|
|
+ String[] resultColumnIds = new String[resultColumns.length];//矩阵表角色列(id)
|
|
|
|
|
+ List<List<String>> resultColumnValues = new ArrayList<>();//矩阵表角色列值
|
|
|
|
|
+
|
|
|
|
|
+ //md5加密corpId,userId,corpToken
|
|
|
|
|
+ String token = DigestUtils.md5Hex(corpId + userId + corpToken).toUpperCase();
|
|
|
|
|
+
|
|
|
|
|
+ //查询矩阵明细
|
|
|
|
|
+ Map params = new HashMap();
|
|
|
|
|
+
|
|
|
|
|
+ int pageSize = 10;
|
|
|
|
|
+ int pageNumber = 0;
|
|
|
|
|
+
|
|
|
|
|
+ params.put("pageSize",pageSize);
|
|
|
|
|
+ params.put("matrixId",matrixId);
|
|
|
|
|
+ params.put("corpId",corpId);
|
|
|
|
|
+ params.put("userId",userId);
|
|
|
|
|
+ params.put("token",token);
|
|
|
|
|
+
|
|
|
|
|
+ List<Map> data = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ String rowId = "";
|
|
|
|
|
+
|
|
|
|
|
+ int totalCount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ //查询矩阵所有明细
|
|
|
|
|
+ do {
|
|
|
|
|
+ pageNumber++;
|
|
|
|
|
+ params.put("pageNumber",pageNumber);
|
|
|
|
|
+ DDR_New ddrNew = (DDR_New) UtilHttp.doGet("https://api.dingtalk.com/v2.0/yida/forms/resources/matrices", ddClient.initTokenHeader(), params, DDR_New.class);
|
|
|
|
|
+
|
|
|
|
|
+ Map result = (Map) ddrNew.getResult();
|
|
|
|
|
+
|
|
|
|
|
+ Map matrixData = UtilMap.getMap(result, "matrixData");
|
|
|
|
|
+
|
|
|
|
|
+ data.addAll(UtilMap.getList(matrixData, "data"));
|
|
|
|
|
+
|
|
|
|
|
+ totalCount = UtilMap.getInt(matrixData, "totalCount");
|
|
|
|
|
+
|
|
|
|
|
+ //查询列id
|
|
|
|
|
+ if (pageNumber == 1){
|
|
|
|
|
+ Map matrixTable = UtilMap.getMap(result, "matrixTable");
|
|
|
|
|
+
|
|
|
|
|
+ List<Map> conditionColumnList = UtilMap.getList(matrixTable, "conditionColumn");
|
|
|
|
|
+ List<Map> resultColumnList = UtilMap.getList(matrixTable, "resultColumn");
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < conditionColumns.length; i++) {
|
|
|
|
|
+ int finalI = i;
|
|
|
|
|
+ Map conditionColumn = conditionColumnList.stream().filter(item -> UtilMap.getString(item, "name").equals(conditionColumns[finalI])).findFirst().orElse(null);
|
|
|
|
|
+ conditionColumnIds[i] = UtilMap.getString(conditionColumn, "columnId");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < resultColumns.length; i++) {
|
|
|
|
|
+ int finalI = i;
|
|
|
|
|
+ Map resultColumn = resultColumnList.stream().filter(item -> UtilMap.getString(item, "name").equals(resultColumns[finalI])).findFirst().orElse(null);
|
|
|
|
|
+ resultColumnIds[i] = UtilMap.getString(resultColumn, "columnId");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }while (pageNumber * pageSize < totalCount);
|
|
|
|
|
+
|
|
|
|
|
+ //查询实例详情获取矩阵表角色列值
|
|
|
|
|
+ Map formData = ydClient.queryData(YDParam.builder().formInstId(formInstId).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < resultColumnFields.length; i++) {
|
|
|
|
|
+ List<String> employees = UtilMap.getList(formData, resultColumnFields[i] + "_id");
|
|
|
|
|
+
|
|
|
|
|
+ resultColumnValues.add(employees);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ boolean flag = false;
|
|
|
|
|
+ //查询该矩阵条件是否存在
|
|
|
|
|
+ for (Map datum : data) {
|
|
|
|
|
+ for (int i = 0; i < conditionColumnIds.length; i++) {
|
|
|
|
|
+ if (conditionColumnValues[i].equals(UtilMap.getString(datum, conditionColumnIds[i]))){
|
|
|
|
|
+ flag = true;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ flag = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (flag){
|
|
|
|
|
+ rowId = UtilMap.getString(datum, "rowId");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //更新矩阵明细
|
|
|
|
|
+ Map matrixData = new HashMap();
|
|
|
|
|
+ if (Strings.isBlank(rowId)){
|
|
|
|
|
+ matrixData.put("isNew",1);//新增
|
|
|
|
|
+ }else {
|
|
|
|
|
+ matrixData.put("rowId",rowId);//更新
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < conditionColumnIds.length; i++) {
|
|
|
|
|
+ matrixData.put(conditionColumnIds[i],conditionColumnValues[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < resultColumnIds.length; i++) {
|
|
|
|
|
+ matrixData.put(resultColumnIds[i],resultColumnValues.get(i));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map body = params;
|
|
|
|
|
+ body.put("dataJson",JSONObject.toJSONString(Arrays.asList(matrixData)));
|
|
|
|
|
+
|
|
|
|
|
+ UtilHttp.doPost("https://api.dingtalk.com/v2.0/yida/forms/resources/matrices/upsert", ddClient.initTokenHeader(), null,body, DDR_New.class);
|
|
|
|
|
+
|
|
|
|
|
+ return McR.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public String sendNotification(String access_token, List<String> userid_list, List<String> dept_id_list, boolean to_all_user, Map msg, String agent_id) {
|
|
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});
|
|
Map body = UtilMap.map("agent_id, to_all_user, msg", new Object[]{agent_id, to_all_user, msg});
|
|
|
if (UtilList.isNotEmpty(userid_list)) {
|
|
if (UtilList.isNotEmpty(userid_list)) {
|