Bladeren bron

mc删除宜搭权限矩阵

wzy 4 maanden geleden
bovenliggende
commit
2c65fd89fe

+ 6 - 0
mjava-mc/src/main/java/com/malk/mc/controller/McYdController.java

@@ -206,4 +206,10 @@ public class McYdController {
         return mcYdService.syncYdAuth(map);
     }
 
+    //删除宜搭权限矩阵
+    @PostMapping("/delYdAuth")
+    public McR delYdAuth(@RequestBody Map map) {
+        return mcYdService.delYdAuth(map);
+    }
+
 }

+ 2 - 0
mjava-mc/src/main/java/com/malk/mc/service/McYdService.java

@@ -31,4 +31,6 @@ public interface McYdService {
     McR approveTask(Map map);
 
     McR syncYdAuth(Map map);
+
+    McR delYdAuth(Map map);
 }

+ 91 - 1
mjava-mc/src/main/java/com/malk/mc/service/impl/McYdServiceImpl.java

@@ -787,7 +787,7 @@ public class McYdServiceImpl implements McYdService {
         //查询矩阵明细
         Map params = new HashMap();
 
-        int pageSize = 10;
+        int pageSize = 100;
         int pageNumber = 0;
 
         params.put("pageSize",pageSize);
@@ -885,6 +885,96 @@ public class McYdServiceImpl implements McYdService {
         return McR.success();
     }
 
+    @Override
+    public McR delYdAuth(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[] conditionColumns = UtilMap.getString(map, "conditionColumns").split(",");//矩阵表条件列(名称)
+        String[] conditionColumnValues = UtilMap.getString(map, "conditionColumnValues").split(",");;//矩阵表条件列值
+
+        String[] conditionColumnIds = new String[conditionColumns.length];//矩阵表条件列(id)
+
+        //md5加密corpId,userId,corpToken
+        String token = DigestUtils.md5Hex(corpId + userId + corpToken).toUpperCase();
+
+        //查询矩阵明细
+        Map params = new HashMap();
+
+        int pageSize = 100;
+        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");
+
+                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");
+                }
+            }
+        }while (pageNumber * pageSize < totalCount);
+
+        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;
+            }
+        }
+
+        //删除矩阵明细
+        if (Strings.isBlank(rowId)){
+            return McR.errorUnknown("该矩阵条件不存在");
+        }else {
+            Map body = params;
+            body.put("rowIds",rowId);
+
+            UtilHttp.doPost("https://api.dingtalk.com/v2.0/yida/forms/resources/matrices/remove", 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) {
         Map body = UtilMap.map("agent_id, to_all_user, msg", new Object[]{agent_id, to_all_user, msg});
         if (UtilList.isNotEmpty(userid_list)) {