|
@@ -1082,6 +1082,80 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/getTaskCount")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "获取任务数量")
|
|
|
+ public R<Integer> getTaskCount(@RequestParam Long projectId,@RequestParam(required = false) Long contractId){
|
|
|
+ /*封装入参SQL*/
|
|
|
+ List<Object> params = new ArrayList<>();
|
|
|
+ StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in (5,6,7,8) "); //approval_type = 5 计量任务
|
|
|
+ Long userId1 = SecureUtil.getUserId();
|
|
|
+ List<Long> projectIdss = jdbcTemplate.query("select project_id from m_project_assignment_user where user_id=" + userId1, new SingleColumnRowMapper<>(Long.class));
|
|
|
+ sqlString.append(" AND project_id in(").append(StringUtils.join(projectIdss, ",")).append(")");
|
|
|
+ sqlString.append(" AND status = 1");
|
|
|
+ sqlString.append(" AND (");
|
|
|
+ sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status = ? AND u_task_parallel.task_user = ?)");
|
|
|
+ params.add(1);
|
|
|
+ params.add(SecureUtil.getUserId());
|
|
|
+ sqlString.append(")");
|
|
|
+
|
|
|
+ /*执行SQL获取数据*/
|
|
|
+ String sqlPage = sqlString.toString();
|
|
|
+ List<Task> resultList = jdbcTemplate.query(sqlPage, new BeanPropertyRowMapper<>(Task.class), params.toArray());
|
|
|
+
|
|
|
+ /*获取任务详情信息Map*/
|
|
|
+ Set<String> processInstanceIds = resultList.stream().map(Task::getProcessInstanceId).collect(Collectors.toSet());
|
|
|
+ Map<String, List<TaskParallel>> taskParallelGroupMap = new HashMap<>();
|
|
|
+ if (processInstanceIds.size() > 0) {
|
|
|
+ String resultIds = processInstanceIds.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
|
|
|
+ taskParallelGroupMap = jdbcTemplate.query("select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,status,initiative,sort from u_task_parallel where process_instance_id in(" + resultIds + ") order by id", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ }
|
|
|
+ //筛选出可审批的数据
|
|
|
+ if(ObjectUtil.isNotEmpty(resultList)){
|
|
|
+ //获取当前用户id
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+
|
|
|
+ String processIdsStr = resultList.stream().map(task -> task.getProcessInstanceId()).collect(Collectors.joining(","));
|
|
|
+ //查询出所有proccesId的数据转换成map map为processId键为u_task_papallel对象
|
|
|
+ Map<String, List<TaskParallel>> taskParallelMap = jdbcTemplate.query("select * from u_task_parallel where process_instance_id in (" + processIdsStr + ")", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+
|
|
|
+ //根据条件过滤出可审批的数据(流程审批-非自定义流程) flowid为0的是自定义审批的流程
|
|
|
+ Map<Long, List<Task>> flowIdMaps = resultList.stream().filter(task->!"0".equals(task.getFixedFlowId().toString())).collect(Collectors.groupingBy(Task::getFixedFlowId));
|
|
|
+ if(ObjectUtil.isNotEmpty(flowIdMaps)){
|
|
|
+ String join = StringUtils.join(flowIdMaps.keySet(), ",");
|
|
|
+ //结果集所有数据
|
|
|
+ String sql = "select fixed_flow_id ,fixed_flow_branch_sort,fixed_flow_link_type,fixed_flow_link_sort from u_fixed_flow_link where is_deleted = 0 and fixed_flow_id in ( "+join+")";
|
|
|
+ List<FixedFlowLink> fixedFlowLinks = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FixedFlowLink.class));
|
|
|
+ Map<Long, List<FixedFlowLink>> fixedsMap = fixedFlowLinks.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
|
|
|
+ for (Long l : flowIdMaps.keySet()) {
|
|
|
+ List<Task> tasks = flowIdMaps.get(l);
|
|
|
+ for (Task task : tasks) {
|
|
|
+ handleTaskParallel1(task,fixedsMap, taskParallelMap,userId, resultList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //自定义流程判断 查询出所有垂直审批的项目
|
|
|
+ //String sqlForchuizhi = "select id from m_project_info where approval_type = 1 and is_deleted = 0";
|
|
|
+ //目前默认所有项目都是垂直审批 上面的注释掉的是以后要用的内容 1为垂直审批2为流程审批
|
|
|
+ String sqlForchuizhi = "select id from m_project_info where is_deleted = 0";
|
|
|
+ List<Long> projectIds = jdbcTemplate.query(sqlForchuizhi, new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().map(ProjectInfo::getId).collect(Collectors.toList());
|
|
|
+ if(ObjectUtil.isNotEmpty(projectIds)){
|
|
|
+ //所有自定义审批的任务
|
|
|
+ Set<Task> tasks = resultList.stream().filter(task -> "0".equals(task.getFixedFlowId().toString())).collect(Collectors.toSet());
|
|
|
+ if(ObjectUtil.isNotEmpty(tasks)){
|
|
|
+ for (Task task : tasks) {
|
|
|
+ if(projectIds.contains(Long.parseLong(task.getProjectId()))){
|
|
|
+ //是自定义垂直审批
|
|
|
+ handleTaskParallel(task, taskParallelMap,userId, resultList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(resultList.size(),"获取成功");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 分页查询
|
|
|
*/
|
|
@@ -1097,23 +1171,9 @@ public class TaskController extends BladeController {
|
|
|
int size = dto.getSize();
|
|
|
List<Object> params = new ArrayList<>();
|
|
|
StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in (5,6,7,8) "); //approval_type = 5 计量任务
|
|
|
-
|
|
|
- ContractInfo contractInfo = jdbcTemplate.queryForObject("select contract_type from m_contract_info where id = " + dto.getContractId(), new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
- if (contractInfo != null && Arrays.asList(1, 4).contains(contractInfo.getContractType())) {
|
|
|
- /*施工、计量合同段(总承包合同段)按照项目id、合同段id正常查询*/
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getProjectId()) && ObjectUtil.isNotEmpty(dto.getContractId())) {
|
|
|
- sqlString.append(" AND project_id = ? AND contract_id = ?");
|
|
|
- params.add(dto.getProjectId());
|
|
|
- params.add(dto.getContractId());
|
|
|
- }
|
|
|
-
|
|
|
- } else if (contractInfo != null && Arrays.asList(2, 3).contains(contractInfo.getContractType())) {
|
|
|
- /*监理、业主(指挥部)合同段,默认查询当前项目下所有关联的合同段*/
|
|
|
- List<ContractRelationJlyz> contractRelationJLYZ = jdbcTemplate.query("select contract_id_sg from m_contract_relation_jlyz where contract_id_jlyz = " + dto.getContractId(), new BeanPropertyRowMapper<>(ContractRelationJlyz.class));
|
|
|
- Set<Long> ids = contractRelationJLYZ.stream().map(ContractRelationJlyz::getContractIdSg).collect(Collectors.toSet());
|
|
|
- ids.add(Long.parseLong(dto.getContractId())); //把本身合同段也加入查询
|
|
|
- sqlString.append(" AND contract_id in(").append(StringUtils.join(ids, ",")).append(")");
|
|
|
- }
|
|
|
+ Long userId1 = SecureUtil.getUserId();
|
|
|
+ List<Long> projectIdss = jdbcTemplate.query("select project_id from m_project_assignment_user where user_id=" + userId1, new SingleColumnRowMapper<>(Long.class));
|
|
|
+ sqlString.append(" AND project_id in(").append(StringUtils.join(projectIdss, ",")).append(")");
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
|
|
|
sqlString.append(" AND meter_task_type = ?");
|