瀏覽代碼

质检资料查询上报时,检测任务流程中人员权限

qianxb 2 年之前
父節點
當前提交
484159b529

+ 97 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/EVisaTaskCheckController.java

@@ -29,6 +29,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 
+import javax.management.MalformedObjectNameException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -248,6 +249,7 @@ public class EVisaTaskCheckController {
             return R.fail(300, "未找到符合电签配置的相关流程,请联系服务人员处理");
         }
 
+
         //汇总电签配置的审批角色
         List<String> eVisaRoleList = jsonList.stream().map(jsonObject -> jsonObject.getString("sigRoleId")).distinct().collect(Collectors.toList());
 
@@ -294,6 +296,101 @@ public class EVisaTaskCheckController {
         return R.data(flowPage);
     }
 
+    /**
+     * 获取符合条件的预设流程(三大填报页、日志列表的批量上报、首件列表的批量上报)
+     */
+    @PostMapping("/queryFixedFlow2")
+    @ApiOperationSupport(order = 5)
+    @ApiOperation(value = "获取符合条件的预设流程(三大填报页、日志列表的批量上报、首件列表的批量上报)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "contractId", value = "合同段ID", required = true),
+            @ApiImplicitParam(name = "privatePKeyId", value = "表单列表中的isTypePrivatePid字段,集合形式"),
+            @ApiImplicitParam(name = "theLogPrimaryKeyId", value = "日志左侧所选的填报类型ID"),
+            @ApiImplicitParam(name = "firstId", value = "首件记录ID,列表批量上报时传任意一个即可")
+    })
+    public R<IPage<FixedFlowVO>> queryFixedFlow2(@RequestBody JSONObject json) {
+        //获取所有流程
+        FixedFlowVO vo = new FixedFlowVO();
+        vo.setCurrent(1);
+        vo.setSize(100);
+        vo.setContractId(json.getLong("contractId"));
+        vo.setProjectId(json.getLong("projectId"));
+
+        IPage<FixedFlowVO> flowPage = this.fixedFlowService.selectFixedFlowPage(vo);
+        //每个自定义流程
+        List<FixedFlowVO> flowList = flowPage.getRecords();
+
+        //获取电签配置
+        List<String> list = json.getJSONArray("privatePKeyId").toJavaList(String.class);
+        Map<String,List<String>> map = new HashMap<>();
+        for (String nodeId : list) {
+            //获取节点信息
+            WbsTreeContract contract = wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.valueOf(nodeId));
+            //获取节点下每个填报表
+            List<WbsTreeContract> node = wbsTreeContractClient.queryChildByParentId(contract, "", "");
+            List<Long> ids = new ArrayList<>();
+            //获取每个填报表对应的wbs_tree_private的id
+            for (WbsTreeContract treeContract : node) {
+                WbsTreePrivate wbsTreePrivate = wbsTreePrivateClient.queryPeersNodeByProjectIdAndId(treeContract.getProjectId(), treeContract.getId());
+                ids.add(wbsTreePrivate.getPKeyId());
+            }
+            JSONObject object = new JSONObject();
+            object.put("privatePKeyId", ids);
+            List<JSONObject> jsonList = this.queryTableEVisaConfig(object);
+            if (jsonList == null || jsonList.size() <= 0) {
+                return R.data(300, null, contract.getNodeName() + ":有节点下所有表单都没配置电签,请联系服务人员处理");
+            }
+
+            //汇总电签配置的审批角色
+            List<String> eVisaRoleList = jsonList.stream().map(jsonObject -> jsonObject.getString("sigRoleId")).distinct().collect(Collectors.toList());
+            map.put(nodeId,eVisaRoleList);
+        }
+
+
+        //校验这些预设流程哪些是符合条件的
+        for (FixedFlowVO next : flowList) {
+            //先将流程设置为可选
+            next.setDisabled(false);
+
+            //首先找到对应流程下的审批人组
+            List<FixedFlowLink> flowLink = this.fixedFlowLinkService.selectFixedFlowLink(next.getId().toString());
+            List<Long> ids = flowLink.stream().map(l -> l.getFixedFlowLinkUser()).collect(Collectors.toList());
+
+
+            //获取这些人当前合同段下的权限
+            List<JSONObject> userRoleList = this.saveUserInfoByProjectClient.queryUserContractRole(flowLink.stream().map(FixedFlowLink::getFixedFlowLinkUser).distinct().collect(Collectors.toList()), json.getString("contractId"));
+            if (userRoleList == null || userRoleList.size() <= 0) {
+                //查看当前项目下是否有监理合同段关联此合同段
+                Long contractId = jdbcTemplate.queryForObject("SELECT id from m_contract_info mci WHERE contract_type = 2 \n" +
+                        "and id in (SELECT contract_id_jlyz  FROM m_contract_relation_jlyz WHERE contract_id_sg = " + json.getString("contractId")+")",Long.class);
+                if (contractId != null) {
+                    userRoleList = this.saveUserInfoByProjectClient.queryUserContractRole(ids, contractId+"");
+                }
+            }
+            if (userRoleList == null) {
+                next.setDisabled(true);
+            } else {
+                //校验流程
+                //循环审批人的角色集合,并判断电签配置中是否含有这个角色
+                label:
+                for (JSONObject userRole : userRoleList) {
+                    for (String s : map.keySet()) {
+                        if (!map.get(s).contains(userRole.getString("roleId"))) {
+                            //但凡有个不符合条件,禁选
+                            next.setDisabled(true);
+                            break label;
+                        }
+                    }
+                }
+            }
+        }
+
+        //设置流程
+        flowPage.setRecords(flowList);
+
+        return R.data(flowPage);
+    }
+
     /**
      * 检查当前审批人是否存在证书
      */