|
@@ -1282,6 +1282,327 @@ public class TaskController extends BladeController {
|
|
|
return this.taskService.startApproval(taskVO) ? R.data(200, true, "操作成功") : R.data(200, false, "操作失败,请联系管理员");
|
|
|
}
|
|
|
|
|
|
+// /**
|
|
|
+// * 资料填报-任务管理-任务查看分页查询
|
|
|
+// */
|
|
|
+// @PostMapping("/page")
|
|
|
+// @ApiOperationSupport(order = 1)
|
|
|
+// @ApiOperation(value = "资料填报-任务管理-任务查看分页查询", notes = "传入BusinessTaskDTO")
|
|
|
+// public R<IPage<BusinessTaskPageVO>> page(@RequestBody BusinessTaskDTO dto) throws IOException {
|
|
|
+// if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
|
+// throw new ServiceException("未获取到当前用户信息,请联系管理员");
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isEmpty(dto.getProjectIdValue())) {
|
|
|
+// throw new ServiceException("未获取到当前用户所在的项目信息,请联系管理员");
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isEmpty(dto.getCurrentContractId())) {
|
|
|
+// throw new ServiceException("未获取到当前用户所在的合同段信息,请联系管理员");
|
|
|
+// }
|
|
|
+// ProjectInfo projectInfo = jdbcTemplate.query("select approval_type from m_project_info where id = " + dto.getProjectIdValue(), new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().findAny().orElse(null);
|
|
|
+// int current = dto.getCurrent();
|
|
|
+// int size = dto.getSize();
|
|
|
+// //封装入参SQL
|
|
|
+// List<Object> params = new ArrayList<>();
|
|
|
+// String sqlResult = "SELECT * ";
|
|
|
+// StringBuilder sqlString = new StringBuilder(" FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in(1,3,4,8,9,10)");
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
|
|
|
+// sqlString.append(" AND type = ?");
|
|
|
+// params.add(dto.getTypeValue());
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getStatusValue())) {
|
|
|
+// sqlString.append(" AND status = ?");
|
|
|
+// params.add(dto.getStatusValue());
|
|
|
+// }
|
|
|
+//
|
|
|
+// ContractInfo contractInfo = jdbcTemplate.queryForObject("select contract_type from m_contract_info where id = " + dto.getCurrentContractId(), new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
+// if (contractInfo != null && contractInfo.getContractType().equals(1)) {
|
|
|
+// //施工合同段正常查询
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getContractIdValue())) {
|
|
|
+// sqlString.append(" AND contract_id = ?");
|
|
|
+// params.add(dto.getContractIdValue());
|
|
|
+// } else {
|
|
|
+// //如果合同段id=null,那么查询当前项目下所有合同段任务
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getProjectIdValue())) {
|
|
|
+// sqlString.append(" AND project_id = ?");
|
|
|
+// params.add(dto.getProjectIdValue());
|
|
|
+// } else {
|
|
|
+// throw new ServiceException("未获取到当前用户所在的项目信息,请联系管理员");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else if (contractInfo != null && (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3))) {
|
|
|
+// if (ObjectUtil.isEmpty(dto.getOrdType())) { //Web端根据合同段查询
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getContractIdValue())) {
|
|
|
+// if (dto.getContractIdValue().equals(dto.getCurrentContractId())) {
|
|
|
+// //如果下拉框合同段选择框合同段=当前用户登陆合同段,那么查询全部合同段的数据
|
|
|
+// List<ContractRelationJlyz> contractRelationJLYZ = jdbcTemplate.query("select contract_id_sg from m_contract_relation_jlyz where contract_id_jlyz = " + dto.getCurrentContractId(), new BeanPropertyRowMapper<>(ContractRelationJlyz.class));
|
|
|
+// Set<Long> ids = contractRelationJLYZ.stream().map(ContractRelationJlyz::getContractIdSg).collect(Collectors.toSet());
|
|
|
+// ids.add(dto.getCurrentContractId()); //把监理本身也加入查询
|
|
|
+// sqlString.append(" AND contract_id in(").append(StringUtils.join(ids, ",")).append(")");
|
|
|
+//
|
|
|
+// // 排除监理创建的数据
|
|
|
+// sqlString.append(" AND form_data_id not in( SELECT id from u_information_query where type=1 and contract_id='"+dto.getCurrentContractId()+"' )");
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// //如果下拉框合同段选择框合同段!=当前用户登陆合同段,那么查询下拉框合同段数据
|
|
|
+// sqlString.append(" AND contract_id = ?");
|
|
|
+// params.add(dto.getContractIdValue());
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// //如果下拉框合同段id=null,那么查询当前整个项目的数据
|
|
|
+// sqlString.append(" AND project_id = ?");
|
|
|
+// params.add(dto.getProjectIdValue());
|
|
|
+// }
|
|
|
+// } else { //App直接查询全部合同段,整个项目
|
|
|
+// sqlString.append(" AND project_id = ?");
|
|
|
+// params.add(dto.getProjectIdValue());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getBatchValue())) {
|
|
|
+// sqlString.append(" AND batch = ?");
|
|
|
+// params.add(dto.getBatchValue());
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(dto.getStartTimeValue()) && StringUtils.isNotBlank(dto.getEndTimeValue())) {
|
|
|
+// sqlString.append(" AND start_time >= ?")
|
|
|
+// .append(" AND end_time <= ?");
|
|
|
+// params.add(dto.getStartTimeValue());
|
|
|
+// params.add(dto.getEndTimeValue());
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(dto.getQueryValue())) {
|
|
|
+// sqlString.append(" AND task_name LIKE ?");
|
|
|
+// params.add("%" + dto.getQueryValue() + "%");
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getSelectedType())) {
|
|
|
+// sqlString.append(" AND (");
|
|
|
+// if (dto.getSelectedType().equals(1)) { //待办页面
|
|
|
+//
|
|
|
+// //如果是待办页面,且 任务状态下拉框 选择的是 待审批状态 的任务,那么才查询数据
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && dto.getStatusValue().equals(1)) {
|
|
|
+// 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());
|
|
|
+// sqlResult = "SELECT *, (SELECT ifnull(e_visa_status, -1) FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.STATUS = 1 " +
|
|
|
+// "AND u_task_parallel.task_user = " + SecureUtil.getUserId() + " and is_deleted = 0 order by id desc limit 1) as e_status";
|
|
|
+// //如果是待办页面,且 任务状态下拉框 选择的不是 待审批状态 的任务,那么直接返回null
|
|
|
+// } else if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && !dto.getStatusValue().equals(1)) {
|
|
|
+// return null;
|
|
|
+//
|
|
|
+// //如果是待办页面,没选择 任务状态下拉框,那么就默认查询 待审批状态 任务
|
|
|
+// } else if (ObjectUtil.isEmpty(dto.getStatusValue())) {
|
|
|
+// 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(" AND status = 1");
|
|
|
+// sqlResult = "SELECT *, (SELECT ifnull(e_visa_status, -1) FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.STATUS = 1 " +
|
|
|
+// "AND u_task_parallel.task_user = " + SecureUtil.getUserId() + " and is_deleted = 0 order by id desc limit 1) as e_status";
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else if (dto.getSelectedType().equals(2)) { //已办页面
|
|
|
+// 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 in(2,3) AND u_task_parallel.task_user = ?)");
|
|
|
+// //当前自己的任务必须是已审批、已废除 status = 2,3 ,才视为已办
|
|
|
+// params.add(SecureUtil.getUserId());
|
|
|
+//
|
|
|
+// } else if (dto.getSelectedType().equals(3)) { //我发起页面
|
|
|
+// sqlString.append("report_user = ?");
|
|
|
+// params.add(SecureUtil.getUserId());
|
|
|
+// }
|
|
|
+// sqlString.append(")");
|
|
|
+// }
|
|
|
+// //是否填报过
|
|
|
+//// sqlString.append(" AND (SELECT COUNT(1) FROM u_information_query WHERE u_task.form_data_id = id and is_deleted=0) > 0");
|
|
|
+//
|
|
|
+// //总数量
|
|
|
+// String sqlCount = "select count(1) " + sqlString;
|
|
|
+// Optional<Integer> totalCountOptional = Optional.ofNullable(jdbcTemplate.queryForObject(sqlCount, Integer.class, params.toArray()));
|
|
|
+// int totalCount = totalCountOptional.orElse(0);
|
|
|
+//
|
|
|
+// //分页
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getOrdType())) {
|
|
|
+// //App端排序
|
|
|
+// if (dto.getOrdType() == 1) {
|
|
|
+// sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?");
|
|
|
+// } else if (dto.getOrdType() == 2) {
|
|
|
+// sqlString.append(" ORDER BY create_time ASC LIMIT ? OFFSET ?");
|
|
|
+// } else {
|
|
|
+// sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// //Web端默认倒叙
|
|
|
+// if (!sqlResult.equals("SELECT * ")) {
|
|
|
+// sqlString.append(" ORDER BY e_status asc, create_time DESC LIMIT ? OFFSET ?");
|
|
|
+// } else {
|
|
|
+// sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// params.add(size);
|
|
|
+// params.add((current - 1) * size);
|
|
|
+//
|
|
|
+// //执行SQL获取数据
|
|
|
+// String sqlPage = sqlResult + sqlString;
|
|
|
+// 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,parallel_process_instance_id,status from u_task_parallel where process_instance_id in(" + resultIds + ") order by id", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+// }
|
|
|
+//
|
|
|
+// Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
|
|
|
+// //获取用户信息Map
|
|
|
+// Map<Long, String> nameMap = jdbcTemplate.query("select id,name from blade_user where is_deleted = 0", new BeanPropertyRowMapper<>(User.class)).stream().collect(Collectors.toMap(User::getId, User::getName, (key1, key2) -> key1));
|
|
|
+//
|
|
|
+// //解析page分页数据
|
|
|
+// IPage<BusinessTaskPageVO> page = new Page<>(current, size);
|
|
|
+// List<BusinessTaskPageVO> pageList = resultList.stream()
|
|
|
+// .map(task -> {
|
|
|
+// BusinessTaskPageVO vo = new BusinessTaskPageVO();
|
|
|
+// vo.setId(task.getId());
|
|
|
+// vo.setTaskId(task.getId());
|
|
|
+// vo.setTaskName(task.getTaskName());
|
|
|
+// vo.setTaskTypeName(task.getType().equals(1) ? "普通任务" : task.getType().equals(2) ? "验收任务" : "移交任务");
|
|
|
+// vo.setTaskStatusName(task.getStatus().equals(1) ? "待审批" : task.getStatus().equals(2) ? "已审批" : "已废除");
|
|
|
+// vo.setStartTime(task.getStartTime());
|
|
|
+// vo.setEndTime(task.getEndTime());
|
|
|
+// vo.setTaskDesc(task.getTaskContent());
|
|
|
+// vo.setTaskReportUserName(nameMap.get(Long.parseLong(task.getReportUser())));
|
|
|
+// vo.setApprovalType(task.getApprovalType());
|
|
|
+// vo.setFormDataId(task.getFormDataId());
|
|
|
+// vo.setProcessInstanceId(task.getProcessInstanceId());
|
|
|
+// vo.setEStatus(task.getEStatus());
|
|
|
+// List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
+// if (taskParallelList != null && taskParallelList.size() > 0) {
|
|
|
+// //如果是垂直签,且是待办页面,判断是否是当前用户审批轮次,不是当前用户审批轮次就不显示该任务
|
|
|
+// if (projectInfo != null && projectInfo.getApprovalType() == 1 && dto.getSelectedType() == 1) {
|
|
|
+// boolean shouldDisplayTask = false; //标记是否显示当前任务
|
|
|
+// for (TaskParallel taskParallel : taskParallelList) {
|
|
|
+// if (SecureUtil.getUserId().equals(Long.parseLong(taskParallel.getTaskUser()))) {
|
|
|
+// shouldDisplayTask = true; //当前用户是审批人,需要显示任务
|
|
|
+// break;
|
|
|
+// } else if (taskParallel.getStatus() != 2) {
|
|
|
+// //之前的审批人员任务未完成,不显示任务
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (!shouldDisplayTask) {
|
|
|
+// //跳过当前任务
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<String> names = taskParallelList.stream().map(TaskParallel::getTaskUserName).collect(Collectors.toList());
|
|
|
+// if (names.size() > 0) {
|
|
|
+// vo.setTaskApproveUserNames(StringUtils.join(names, ","));
|
|
|
+// }
|
|
|
+//
|
|
|
+// //电签状态(始终只获取自己的电签任务状态信息)
|
|
|
+// TaskParallel taskParallel = taskParallelList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getTaskUser()) && f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
|
|
|
+// if (taskParallel != null) {
|
|
|
+// vo.setEVisaStatus(taskParallel.getEVisaContent() != null ? taskParallel.getEVisaContent() : "");
|
|
|
+// vo.setParallelProcessInstanceId(taskParallel.getParallelProcessInstanceId());
|
|
|
+// } else {
|
|
|
+// taskParallel = taskParallelList.get(0);
|
|
|
+// vo.setEVisaStatus(taskParallel.getEVisaContent() != null ? taskParallel.getEVisaContent() : "");
|
|
|
+// }
|
|
|
+// if (vo.getTaskStatusName().equals("已废除")) {
|
|
|
+// if (!"撤回成功".equals(vo.getEVisaStatus()) && !"驳回成功".equals(vo.getEVisaStatus())) {
|
|
|
+// vo.setEVisaStatus("废除成功");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// //判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色
|
|
|
+// List<TaskParallel> statList = new ArrayList<>();
|
|
|
+// for (TaskParallel taskPa : taskParallelList) {
|
|
|
+// if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
|
+// taskPa.setEVisaStatus(2);
|
|
|
+// } else if (taskPa.getStatus() == 3 && taskPa.getTaskUser().equals(SecureUtil.getUserId().toString())) {
|
|
|
+// taskPa.setEVisaStatus(3);
|
|
|
+// } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
+// taskPa.setEVisaStatus(999);
|
|
|
+// } else {
|
|
|
+// taskPa.setEVisaStatus(1);
|
|
|
+// }
|
|
|
+// statList.add(taskPa);
|
|
|
+// }
|
|
|
+// vo.setTaskApproveUserNamesList(statList);
|
|
|
+// }
|
|
|
+// return vo;
|
|
|
+// })
|
|
|
+// .filter(Objects::nonNull) //过滤掉为null的任务
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// //所有满足条件的任务 转map
|
|
|
+// Map<Long, Task> taskMap = new HashMap<>();
|
|
|
+// Map<String, List<OperationLog>> operationLogMap = new HashMap<>();
|
|
|
+// List<Long> taskIds = pageList.stream().filter(b -> "已废除".equals(b.getTaskStatusName())).map(BusinessTaskPageVO::getTaskId).collect(Collectors.toList());
|
|
|
+// if (ObjectUtil.isNotEmpty(taskIds)){
|
|
|
+// String joinTaskIds = StringUtils.join(taskIds, ",");
|
|
|
+// List<Task> tasks = jdbcTemplate.query("select id, create_time,form_data_id from u_task where id in ( " + joinTaskIds+")", new BeanPropertyRowMapper<>(Task.class));
|
|
|
+// taskMap = tasks.stream()
|
|
|
+// .collect(Collectors.toMap(
|
|
|
+// Task::getId,
|
|
|
+// task -> task));
|
|
|
+// }
|
|
|
+// if(CollectionUtil.isNotEmpty(pageList)){
|
|
|
+// //所有满足条件的日志 转map
|
|
|
+// Set<String> collect = pageList.stream().map(BusinessTaskPageVO::getFormDataId).collect(Collectors.toSet());
|
|
|
+// String logQuery = "select business_id,create_user_name ,create_time, operation_type, save_data from u_operation_log where business_id in (" + StringUtil.join(collect) + ") and operation_type in (6,9,12,15,18,21,24,26,61,62)";
|
|
|
+// List<OperationLog> operationLogs = jdbcTemplate.query(logQuery, new BeanPropertyRowMapper<>(OperationLog.class));
|
|
|
+// if(ObjectUtil.isNotEmpty(operationLogs)){
|
|
|
+// operationLogMap = operationLogs.stream().collect(Collectors.groupingBy(OperationLog::getBusinessId));
|
|
|
+// }
|
|
|
+// for (BusinessTaskPageVO businessTaskPageVO : pageList) {
|
|
|
+// if("已废除".equals(businessTaskPageVO.getTaskStatusName())){
|
|
|
+// Long taskId = businessTaskPageVO.getTaskId();
|
|
|
+// Task task = taskMap.get(taskId);
|
|
|
+// if (ObjectUtil.isEmpty(task)){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// //任务创建时间
|
|
|
+// Date createTime = task.getCreateTime();
|
|
|
+// //废除时间肯定在任务创建时间之后 选择距离当前任务创建时间最近的一条数据
|
|
|
+// List<OperationLog> operationLogsF = operationLogMap.get(task.getFormDataId());
|
|
|
+//
|
|
|
+// if(ObjectUtil.isNotEmpty(operationLogsF)){
|
|
|
+// Optional<OperationLog> min = operationLogsF.stream().filter(o -> o.getCreateTime().compareTo(createTime) >= 0)
|
|
|
+// .min(Comparator.comparing(t -> t.getCreateTime().getTime() - createTime.getTime()));
|
|
|
+// if (min.isPresent()){
|
|
|
+// OperationLog operationLog = min.get();
|
|
|
+// String createUserName = operationLog.getCreateUserName();
|
|
|
+// String date = DateUtil.formatDateTime(operationLog.getCreateTime());
|
|
|
+// if (operationLog.getOperationType() != null && operationLog.getOperationType() == 61) {
|
|
|
+// businessTaskPageVO.setEVisaStatus("驳回成功:"+ createUserName +"-"+ date);
|
|
|
+// String saveData = operationLog.getSaveData();
|
|
|
+// if (saveData != null && !saveData.isEmpty()) {
|
|
|
+// try {
|
|
|
+// JSONObject data = JSONObject.parseObject(saveData);
|
|
|
+// if (data != null && data.containsKey("comment")) {
|
|
|
+// businessTaskPageVO.setEVisaStatus("驳回成功:"+ createUserName +"-"+ date + ";驳回原因:"+data.getString("comment"));
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else if (operationLog.getOperationType() != null && operationLog.getOperationType() == 62) {
|
|
|
+// businessTaskPageVO.setEVisaStatus("撤回成功:"+ createUserName +"-"+ date);
|
|
|
+// } else {
|
|
|
+// businessTaskPageVO.setEVisaStatus(businessTaskPageVO.getEVisaStatus()+":"+ createUserName +"-"+ date);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// page.setRecords(pageList);
|
|
|
+// page.setTotal(totalCount);
|
|
|
+// return R.data(page);
|
|
|
+// }
|
|
|
+
|
|
|
/**
|
|
|
* 资料填报-任务管理-任务查看分页查询
|
|
|
*/
|
|
@@ -1289,6 +1610,7 @@ public class TaskController extends BladeController {
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "资料填报-任务管理-任务查看分页查询", notes = "传入BusinessTaskDTO")
|
|
|
public R<IPage<BusinessTaskPageVO>> page(@RequestBody BusinessTaskDTO dto) throws IOException {
|
|
|
+ // 1. 基础参数校验
|
|
|
if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
|
throw new ServiceException("未获取到当前用户信息,请联系管理员");
|
|
|
}
|
|
@@ -1298,96 +1620,109 @@ public class TaskController extends BladeController {
|
|
|
if (ObjectUtil.isEmpty(dto.getCurrentContractId())) {
|
|
|
throw new ServiceException("未获取到当前用户所在的合同段信息,请联系管理员");
|
|
|
}
|
|
|
- ProjectInfo projectInfo = jdbcTemplate.query("select approval_type from m_project_info where id = " + dto.getProjectIdValue(), new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().findAny().orElse(null);
|
|
|
- int current = dto.getCurrent();
|
|
|
- int size = dto.getSize();
|
|
|
- //封装入参SQL
|
|
|
+
|
|
|
+ // 2. 查询项目审批类型、合同类型(复用原逻辑)
|
|
|
+ ProjectInfo projectInfo = jdbcTemplate.query(
|
|
|
+ "select approval_type from m_project_info where id = " + dto.getProjectIdValue(),
|
|
|
+ new BeanPropertyRowMapper<>(ProjectInfo.class)
|
|
|
+ ).stream().findAny().orElse(null);
|
|
|
+
|
|
|
+ ContractInfo contractInfo = jdbcTemplate.queryForObject(
|
|
|
+ "select contract_type from m_contract_info where id = " + dto.getCurrentContractId(),
|
|
|
+ new BeanPropertyRowMapper<>(ContractInfo.class)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 3. 构建SQL查询条件(不含分页LIMIT/OFFSET)
|
|
|
List<Object> params = new ArrayList<>();
|
|
|
String sqlResult = "SELECT * ";
|
|
|
StringBuilder sqlString = new StringBuilder(" FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in(1,3,4,8,9,10)");
|
|
|
+
|
|
|
+ // 3.1 任务类型过滤
|
|
|
if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
|
|
|
sqlString.append(" AND type = ?");
|
|
|
params.add(dto.getTypeValue());
|
|
|
}
|
|
|
+ // 3.2 任务状态过滤
|
|
|
if (ObjectUtil.isNotEmpty(dto.getStatusValue())) {
|
|
|
sqlString.append(" AND status = ?");
|
|
|
params.add(dto.getStatusValue());
|
|
|
}
|
|
|
-
|
|
|
- ContractInfo contractInfo = jdbcTemplate.queryForObject("select contract_type from m_contract_info where id = " + dto.getCurrentContractId(), new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
+ // 3.3 合同段过滤(区分合同类型)
|
|
|
if (contractInfo != null && contractInfo.getContractType().equals(1)) {
|
|
|
- //施工合同段正常查询
|
|
|
+ // 施工合同段逻辑
|
|
|
if (ObjectUtil.isNotEmpty(dto.getContractIdValue())) {
|
|
|
sqlString.append(" AND contract_id = ?");
|
|
|
params.add(dto.getContractIdValue());
|
|
|
} else {
|
|
|
- //如果合同段id=null,那么查询当前项目下所有合同段任务
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getProjectIdValue())) {
|
|
|
- sqlString.append(" AND project_id = ?");
|
|
|
- params.add(dto.getProjectIdValue());
|
|
|
- } else {
|
|
|
- throw new ServiceException("未获取到当前用户所在的项目信息,请联系管理员");
|
|
|
- }
|
|
|
+ sqlString.append(" AND project_id = ?");
|
|
|
+ params.add(dto.getProjectIdValue());
|
|
|
}
|
|
|
} else if (contractInfo != null && (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3))) {
|
|
|
- if (ObjectUtil.isEmpty(dto.getOrdType())) { //Web端根据合同段查询
|
|
|
+ // 监理/其他合同段逻辑
|
|
|
+ if (ObjectUtil.isEmpty(dto.getOrdType())) {
|
|
|
+ // Web端逻辑
|
|
|
if (ObjectUtil.isNotEmpty(dto.getContractIdValue())) {
|
|
|
if (dto.getContractIdValue().equals(dto.getCurrentContractId())) {
|
|
|
- //如果下拉框合同段选择框合同段=当前用户登陆合同段,那么查询全部合同段的数据
|
|
|
- List<ContractRelationJlyz> contractRelationJLYZ = jdbcTemplate.query("select contract_id_sg from m_contract_relation_jlyz where contract_id_jlyz = " + dto.getCurrentContractId(), new BeanPropertyRowMapper<>(ContractRelationJlyz.class));
|
|
|
- Set<Long> ids = contractRelationJLYZ.stream().map(ContractRelationJlyz::getContractIdSg).collect(Collectors.toSet());
|
|
|
- ids.add(dto.getCurrentContractId()); //把监理本身也加入查询
|
|
|
- sqlString.append(" AND contract_id in(").append(StringUtils.join(ids, ",")).append(")");
|
|
|
-
|
|
|
- // 排除监理创建的数据
|
|
|
- sqlString.append(" AND form_data_id not in( SELECT id from u_information_query where type=1 and contract_id='"+dto.getCurrentContractId()+"' )");
|
|
|
-
|
|
|
+ // 查关联合同段+自身
|
|
|
+ List<ContractRelationJlyz> relationList = jdbcTemplate.query(
|
|
|
+ "select contract_id_sg from m_contract_relation_jlyz where contract_id_jlyz = " + dto.getCurrentContractId(),
|
|
|
+ new BeanPropertyRowMapper<>(ContractRelationJlyz.class)
|
|
|
+ );
|
|
|
+ Set<Long> ids = relationList.stream().map(ContractRelationJlyz::getContractIdSg).collect(Collectors.toSet());
|
|
|
+ ids.add(dto.getCurrentContractId());
|
|
|
+ sqlString.append(" AND contract_id in(").append(StringUtils.join(ids,",")).append(")");
|
|
|
+ // 排除监理创建数据
|
|
|
+ sqlString.append(" AND form_data_id not in( SELECT id from u_information_query where type=1 and contract_id='").append(dto.getCurrentContractId()).append("' )");
|
|
|
} else {
|
|
|
- //如果下拉框合同段选择框合同段!=当前用户登陆合同段,那么查询下拉框合同段数据
|
|
|
sqlString.append(" AND contract_id = ?");
|
|
|
params.add(dto.getContractIdValue());
|
|
|
}
|
|
|
} else {
|
|
|
- //如果下拉框合同段id=null,那么查询当前整个项目的数据
|
|
|
sqlString.append(" AND project_id = ?");
|
|
|
params.add(dto.getProjectIdValue());
|
|
|
}
|
|
|
- } else { //App直接查询全部合同段,整个项目
|
|
|
+ } else {
|
|
|
+ // App端逻辑(查整个项目)
|
|
|
sqlString.append(" AND project_id = ?");
|
|
|
params.add(dto.getProjectIdValue());
|
|
|
}
|
|
|
}
|
|
|
+ // 3.4 批次过滤
|
|
|
if (ObjectUtil.isNotEmpty(dto.getBatchValue())) {
|
|
|
sqlString.append(" AND batch = ?");
|
|
|
params.add(dto.getBatchValue());
|
|
|
}
|
|
|
+ // 3.5 时间范围过滤
|
|
|
if (StringUtils.isNotBlank(dto.getStartTimeValue()) && StringUtils.isNotBlank(dto.getEndTimeValue())) {
|
|
|
- sqlString.append(" AND start_time >= ?")
|
|
|
- .append(" AND end_time <= ?");
|
|
|
+ sqlString.append(" AND start_time >= ? AND end_time <= ?");
|
|
|
params.add(dto.getStartTimeValue());
|
|
|
params.add(dto.getEndTimeValue());
|
|
|
}
|
|
|
+ // 3.6 任务名称模糊查询
|
|
|
if (StringUtils.isNotBlank(dto.getQueryValue())) {
|
|
|
sqlString.append(" AND task_name LIKE ?");
|
|
|
params.add("%" + dto.getQueryValue() + "%");
|
|
|
}
|
|
|
+ // 3.7 页面类型过滤(待办/已办/我发起)
|
|
|
if (ObjectUtil.isNotEmpty(dto.getSelectedType())) {
|
|
|
sqlString.append(" AND (");
|
|
|
- if (dto.getSelectedType().equals(1)) { //待办页面
|
|
|
-
|
|
|
- //如果是待办页面,且 任务状态下拉框 选择的是 待审批状态 的任务,那么才查询数据
|
|
|
+ if (dto.getSelectedType().equals(1)) {
|
|
|
+ // 待办页面逻辑
|
|
|
if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && dto.getStatusValue().equals(1)) {
|
|
|
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());
|
|
|
+ // 关联电签状态字段
|
|
|
sqlResult = "SELECT *, (SELECT ifnull(e_visa_status, -1) FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.STATUS = 1 " +
|
|
|
"AND u_task_parallel.task_user = " + SecureUtil.getUserId() + " and is_deleted = 0 order by id desc limit 1) as e_status";
|
|
|
- //如果是待办页面,且 任务状态下拉框 选择的不是 待审批状态 的任务,那么直接返回null
|
|
|
} else if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && !dto.getStatusValue().equals(1)) {
|
|
|
- return null;
|
|
|
-
|
|
|
- //如果是待办页面,没选择 任务状态下拉框,那么就默认查询 待审批状态 任务
|
|
|
- } else if (ObjectUtil.isEmpty(dto.getStatusValue())) {
|
|
|
+ // 待办页选非待审批状态:直接返回空分页
|
|
|
+ IPage<BusinessTaskPageVO> emptyPage = new Page<>(dto.getCurrent(), dto.getSize());
|
|
|
+ emptyPage.setTotal(0);
|
|
|
+ emptyPage.setRecords(Collections.emptyList());
|
|
|
+ return R.data(emptyPage);
|
|
|
+ } else {
|
|
|
+ // 待办页未选状态:默认查待审批
|
|
|
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());
|
|
@@ -1395,74 +1730,122 @@ public class TaskController extends BladeController {
|
|
|
sqlResult = "SELECT *, (SELECT ifnull(e_visa_status, -1) FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.STATUS = 1 " +
|
|
|
"AND u_task_parallel.task_user = " + SecureUtil.getUserId() + " and is_deleted = 0 order by id desc limit 1) as e_status";
|
|
|
}
|
|
|
-
|
|
|
- } else if (dto.getSelectedType().equals(2)) { //已办页面
|
|
|
+ } else if (dto.getSelectedType().equals(2)) {
|
|
|
+ // 已办页面逻辑
|
|
|
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 in(2,3) AND u_task_parallel.task_user = ?)");
|
|
|
- //当前自己的任务必须是已审批、已废除 status = 2,3 ,才视为已办
|
|
|
params.add(SecureUtil.getUserId());
|
|
|
-
|
|
|
- } else if (dto.getSelectedType().equals(3)) { //我发起页面
|
|
|
+ } else if (dto.getSelectedType().equals(3)) {
|
|
|
+ // 我发起页面逻辑
|
|
|
sqlString.append("report_user = ?");
|
|
|
params.add(SecureUtil.getUserId());
|
|
|
}
|
|
|
sqlString.append(")");
|
|
|
}
|
|
|
- //是否填报过
|
|
|
-// sqlString.append(" AND (SELECT COUNT(1) FROM u_information_query WHERE u_task.form_data_id = id and is_deleted=0) > 0");
|
|
|
|
|
|
- //总数量
|
|
|
- String sqlCount = "select count(1) " + sqlString;
|
|
|
- Optional<Integer> totalCountOptional = Optional.ofNullable(jdbcTemplate.queryForObject(sqlCount, Integer.class, params.toArray()));
|
|
|
- int totalCount = totalCountOptional.orElse(0);
|
|
|
-
|
|
|
- //分页
|
|
|
+ // 4. 执行完整SQL查询(获取所有符合条件的原始数据,不含分页)
|
|
|
+ String sqlFull = sqlResult + sqlString;
|
|
|
+ // 处理排序(复用原逻辑,不含LIMIT/OFFSET)
|
|
|
if (ObjectUtil.isNotEmpty(dto.getOrdType())) {
|
|
|
- //App端排序
|
|
|
+ // App端排序
|
|
|
if (dto.getOrdType() == 1) {
|
|
|
- sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?");
|
|
|
+ sqlFull += " ORDER BY create_time DESC";
|
|
|
} else if (dto.getOrdType() == 2) {
|
|
|
- sqlString.append(" ORDER BY create_time ASC LIMIT ? OFFSET ?");
|
|
|
+ sqlFull += " ORDER BY create_time ASC";
|
|
|
} else {
|
|
|
- sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?");
|
|
|
+ sqlFull += " ORDER BY create_time DESC";
|
|
|
}
|
|
|
} else {
|
|
|
- //Web端默认倒叙
|
|
|
- if (!sqlResult.equals("SELECT * ")) {
|
|
|
- sqlString.append(" ORDER BY e_status asc, create_time DESC LIMIT ? OFFSET ?");
|
|
|
+ // Web端排序
|
|
|
+ if (!"SELECT * ".equals(sqlResult)) {
|
|
|
+ sqlFull += " ORDER BY e_status asc, create_time DESC";
|
|
|
} else {
|
|
|
- sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?");
|
|
|
+ sqlFull += " ORDER BY create_time DESC";
|
|
|
}
|
|
|
}
|
|
|
- params.add(size);
|
|
|
- params.add((current - 1) * size);
|
|
|
-
|
|
|
- //执行SQL获取数据
|
|
|
- String sqlPage = sqlResult + sqlString;
|
|
|
- List<Task> resultList = jdbcTemplate.query(
|
|
|
- sqlPage,
|
|
|
+ List<Task> allResultList = jdbcTemplate.query(
|
|
|
+ sqlFull,
|
|
|
new BeanPropertyRowMapper<>(Task.class),
|
|
|
params.toArray()
|
|
|
);
|
|
|
|
|
|
- //获取任务详情信息Map
|
|
|
- Set<String> processInstanceIds = resultList.stream().map(Task::getProcessInstanceId).collect(Collectors.toSet());
|
|
|
+ // 5. 预查询关联数据(任务并行信息、用户信息、操作日志,复用原逻辑)
|
|
|
+ // 5.1 任务并行信息Map
|
|
|
+ Set<String> processInstanceIds = allResultList.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,parallel_process_instance_id,status from u_task_parallel where process_instance_id in(" + resultIds + ") order by id", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ if (CollectionUtil.isNotEmpty(processInstanceIds)) {
|
|
|
+ String idsStr = 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,parallel_process_instance_id,status from u_task_parallel where process_instance_id in(" + idsStr + ") order by id",
|
|
|
+ new BeanPropertyRowMapper<>(TaskParallel.class)
|
|
|
+ ).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ }
|
|
|
+ // 5.2 用户姓名Map
|
|
|
+ Map<Long, String> nameMap = jdbcTemplate.query(
|
|
|
+ "select id,name from blade_user where is_deleted = 0",
|
|
|
+ new BeanPropertyRowMapper<>(User.class)
|
|
|
+ ).stream().collect(Collectors.toMap(User::getId, User::getName, (k1, k2) -> k1));
|
|
|
+ // 5.3 操作日志Map(后续用于已废除任务状态补充)
|
|
|
+ Map<String, List<OperationLog>> operationLogMap = new HashMap<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(allResultList)) {
|
|
|
+ Set<String> formDataIds = allResultList.stream().map(Task::getFormDataId).collect(Collectors.toSet());
|
|
|
+ if (CollectionUtil.isNotEmpty(formDataIds)) {
|
|
|
+ String logSql = "select business_id,create_user_name ,create_time, operation_type, save_data from u_operation_log where business_id in (" + StringUtils.join(formDataIds,",") + ") and operation_type in (6,9,12,15,18,21,24,26,61,62)";
|
|
|
+ List<OperationLog> logs = jdbcTemplate.query(logSql, new BeanPropertyRowMapper<>(OperationLog.class));
|
|
|
+ if (CollectionUtil.isNotEmpty(logs)) {
|
|
|
+ operationLogMap = logs.stream().collect(Collectors.groupingBy(OperationLog::getBusinessId));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // 6. 对原始数据执行业务过滤(核心:垂直签待办任务可见性判断)
|
|
|
Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
|
|
|
- //获取用户信息Map
|
|
|
- Map<Long, String> nameMap = jdbcTemplate.query("select id,name from blade_user where is_deleted = 0", new BeanPropertyRowMapper<>(User.class)).stream().collect(Collectors.toMap(User::getId, User::getName, (key1, key2) -> key1));
|
|
|
+ List<Task> filteredList = allResultList.stream()
|
|
|
+ .filter(task -> {
|
|
|
+ // 仅处理垂直签+待办页面的过滤逻辑
|
|
|
+ if (projectInfo != null && projectInfo.getApprovalType() == 1 && dto.getSelectedType() == 1) {
|
|
|
+ List<TaskParallel> parallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
+ if (CollectionUtil.isEmpty(parallelList)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ boolean shouldDisplay = false;
|
|
|
+ for (TaskParallel tp : parallelList) {
|
|
|
+ // 当前用户是审批人:显示
|
|
|
+ if (SecureUtil.getUserId().equals(Long.parseLong(tp.getTaskUser()))) {
|
|
|
+ shouldDisplay = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // 前序审批未完成:不显示
|
|
|
+ if (tp.getStatus() != 2) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return shouldDisplay;
|
|
|
+ }
|
|
|
+ // 其他场景:直接保留
|
|
|
+ return true;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- //解析page分页数据
|
|
|
- IPage<BusinessTaskPageVO> page = new Page<>(current, size);
|
|
|
- List<BusinessTaskPageVO> pageList = resultList.stream()
|
|
|
+ // 7. 基于过滤后的数据计算分页
|
|
|
+ int current = dto.getCurrent();
|
|
|
+ int size = dto.getSize();
|
|
|
+ int totalCount = filteredList.size();
|
|
|
+ // 计算分页截取范围(避免索引越界)
|
|
|
+ int startIndex = Math.max((current - 1) * size, 0);
|
|
|
+ int endIndex = Math.min(startIndex + size, totalCount);
|
|
|
+ // 截取当前页数据(subList左闭右开,需处理startIndex >= endIndex的空页场景)
|
|
|
+ List<Task> currentPageTaskList = new ArrayList<>();
|
|
|
+ if (startIndex < endIndex && CollectionUtil.isNotEmpty(filteredList)) {
|
|
|
+ currentPageTaskList = filteredList.subList(startIndex, endIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 8. 转换当前页数据为VO(复用原逻辑,补充已废除任务日志信息)
|
|
|
+ Map<String, List<TaskParallel>> finalTaskParallelGroupMap1 = taskParallelGroupMap;
|
|
|
+ Map<String, List<OperationLog>> finalOperationLogMap = operationLogMap;
|
|
|
+ List<BusinessTaskPageVO> pageList = currentPageTaskList.stream()
|
|
|
.map(task -> {
|
|
|
BusinessTaskPageVO vo = new BusinessTaskPageVO();
|
|
|
+ // 基础字段赋值
|
|
|
vo.setId(task.getId());
|
|
|
vo.setTaskId(task.getId());
|
|
|
vo.setTaskName(task.getTaskName());
|
|
@@ -1476,128 +1859,91 @@ public class TaskController extends BladeController {
|
|
|
vo.setFormDataId(task.getFormDataId());
|
|
|
vo.setProcessInstanceId(task.getProcessInstanceId());
|
|
|
vo.setEStatus(task.getEStatus());
|
|
|
- List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
- if (taskParallelList != null && taskParallelList.size() > 0) {
|
|
|
- //如果是垂直签,且是待办页面,判断是否是当前用户审批轮次,不是当前用户审批轮次就不显示该任务
|
|
|
- if (projectInfo != null && projectInfo.getApprovalType() == 1 && dto.getSelectedType() == 1) {
|
|
|
- boolean shouldDisplayTask = false; //标记是否显示当前任务
|
|
|
- for (TaskParallel taskParallel : taskParallelList) {
|
|
|
- if (SecureUtil.getUserId().equals(Long.parseLong(taskParallel.getTaskUser()))) {
|
|
|
- shouldDisplayTask = true; //当前用户是审批人,需要显示任务
|
|
|
- break;
|
|
|
- } else if (taskParallel.getStatus() != 2) {
|
|
|
- //之前的审批人员任务未完成,不显示任务
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!shouldDisplayTask) {
|
|
|
- //跳过当前任务
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<String> names = taskParallelList.stream().map(TaskParallel::getTaskUserName).collect(Collectors.toList());
|
|
|
- if (names.size() > 0) {
|
|
|
- vo.setTaskApproveUserNames(StringUtils.join(names, ","));
|
|
|
- }
|
|
|
|
|
|
- //电签状态(始终只获取自己的电签任务状态信息)
|
|
|
- TaskParallel taskParallel = taskParallelList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getTaskUser()) && f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
|
|
|
- if (taskParallel != null) {
|
|
|
- vo.setEVisaStatus(taskParallel.getEVisaContent() != null ? taskParallel.getEVisaContent() : "");
|
|
|
- vo.setParallelProcessInstanceId(taskParallel.getParallelProcessInstanceId());
|
|
|
- } else {
|
|
|
- taskParallel = taskParallelList.get(0);
|
|
|
- vo.setEVisaStatus(taskParallel.getEVisaContent() != null ? taskParallel.getEVisaContent() : "");
|
|
|
- }
|
|
|
- if (vo.getTaskStatusName().equals("已废除")) {
|
|
|
- if (!"撤回成功".equals(vo.getEVisaStatus()) && !"驳回成功".equals(vo.getEVisaStatus())) {
|
|
|
- vo.setEVisaStatus("废除成功");
|
|
|
+ // 任务并行信息处理
|
|
|
+ List<TaskParallel> parallelList = finalTaskParallelGroupMap1.get(task.getProcessInstanceId());
|
|
|
+ if (CollectionUtil.isNotEmpty(parallelList)) {
|
|
|
+ // 审批人姓名拼接
|
|
|
+ List<String> approveNames = parallelList.stream().map(TaskParallel::getTaskUserName).collect(Collectors.toList());
|
|
|
+ vo.setTaskApproveUserNames(StringUtils.join(approveNames,","));
|
|
|
+
|
|
|
+ // 电签状态处理(优先当前用户)
|
|
|
+ TaskParallel currentUserParallel = parallelList.stream()
|
|
|
+ .filter(tp -> ObjectUtil.isNotEmpty(tp.getTaskUser()) && tp.getTaskUser().equals(SecureUtil.getUserId().toString()))
|
|
|
+ .findAny().orElse(parallelList.get(0));
|
|
|
+ vo.setEVisaStatus(ObjectUtil.isNotEmpty(currentUserParallel.getEVisaContent()) ? currentUserParallel.getEVisaContent() : "");
|
|
|
+ vo.setParallelProcessInstanceId(currentUserParallel.getParallelProcessInstanceId());
|
|
|
+
|
|
|
+ // 已废除任务:补充操作日志信息
|
|
|
+ if ("已废除".equals(vo.getTaskStatusName())) {
|
|
|
+ List<OperationLog> logs = finalOperationLogMap.get(task.getFormDataId());
|
|
|
+ if (CollectionUtil.isNotEmpty(logs)) {
|
|
|
+ // 筛选任务创建时间之后的日志,取最近一条
|
|
|
+ Optional<OperationLog> nearestLog = logs.stream()
|
|
|
+ .filter(log -> log.getCreateTime().compareTo(task.getCreateTime()) >= 0)
|
|
|
+ .min(Comparator.comparing(log -> log.getCreateTime().getTime() - task.getCreateTime().getTime()));
|
|
|
+ if (nearestLog.isPresent()) {
|
|
|
+ OperationLog log = nearestLog.get();
|
|
|
+ String logTime = DateUtil.formatDateTime(log.getCreateTime());
|
|
|
+ String operator = log.getCreateUserName();
|
|
|
+ if (log.getOperationType() != null && log.getOperationType() == 61) {
|
|
|
+ // 驳回日志
|
|
|
+ vo.setEVisaStatus("驳回成功:" + operator + "-" + logTime);
|
|
|
+ // 解析驳回原因
|
|
|
+ if (StringUtils.isNotBlank(log.getSaveData())) {
|
|
|
+ try {
|
|
|
+ JSONObject data = JSONObject.parseObject(log.getSaveData());
|
|
|
+ if (data.containsKey("comment")) {
|
|
|
+ vo.setEVisaStatus(vo.getEVisaStatus() + ";驳回原因:" + data.getString("comment"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (log.getOperationType() != null && log.getOperationType() == 62) {
|
|
|
+ // 撤回日志
|
|
|
+ vo.setEVisaStatus("撤回成功:" + operator + "-" + logTime);
|
|
|
+ } else {
|
|
|
+ // 其他废除日志
|
|
|
+ vo.setEVisaStatus(vo.getEVisaStatus() + ":" + operator + "-" + logTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色
|
|
|
- List<TaskParallel> statList = new ArrayList<>();
|
|
|
- for (TaskParallel taskPa : taskParallelList) {
|
|
|
- if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
|
- taskPa.setEVisaStatus(2);
|
|
|
- } else if (taskPa.getStatus() == 3 && taskPa.getTaskUser().equals(SecureUtil.getUserId().toString())) {
|
|
|
- taskPa.setEVisaStatus(3);
|
|
|
- } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
- taskPa.setEVisaStatus(999);
|
|
|
- } else {
|
|
|
- taskPa.setEVisaStatus(1);
|
|
|
- }
|
|
|
- statList.add(taskPa);
|
|
|
- }
|
|
|
- vo.setTaskApproveUserNamesList(statList);
|
|
|
+ // 审批人状态标记(2=绿/3=黄/999=红/1=灰)
|
|
|
+ List<TaskParallel> statusList = parallelList.stream()
|
|
|
+ .map(tp -> {
|
|
|
+ TaskParallel newTp = new TaskParallel();
|
|
|
+ newTp.setProcessInstanceId(tp.getProcessInstanceId());
|
|
|
+ newTp.setTaskUser(tp.getTaskUser());
|
|
|
+ newTp.setTaskUserName(tp.getTaskUserName());
|
|
|
+ newTp.setEVisaContent(tp.getEVisaContent());
|
|
|
+ newTp.setParallelProcessInstanceId(tp.getParallelProcessInstanceId());
|
|
|
+ newTp.setStatus(tp.getStatus());
|
|
|
+
|
|
|
+ if (tp.getStatus() == 2 && ObjectUtil.isNotEmpty(tp.getEVisaStatus()) && tp.getEVisaStatus() == 1) {
|
|
|
+ newTp.setEVisaStatus(2);
|
|
|
+ } else if (tp.getStatus() == 3 && tp.getTaskUser().equals(SecureUtil.getUserId().toString())) {
|
|
|
+ newTp.setEVisaStatus(3);
|
|
|
+ } else if (ObjectUtil.isNotEmpty(tp.getEVisaStatus()) && tp.getEVisaStatus() == 99) {
|
|
|
+ newTp.setEVisaStatus(999);
|
|
|
+ } else {
|
|
|
+ newTp.setEVisaStatus(1);
|
|
|
+ }
|
|
|
+ return newTp;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setTaskApproveUserNamesList(statusList);
|
|
|
}
|
|
|
+
|
|
|
return vo;
|
|
|
})
|
|
|
- .filter(Objects::nonNull) //过滤掉为null的任务
|
|
|
+ .filter(Objects::nonNull) // 兜底过滤null(理论上已提前过滤)
|
|
|
.collect(Collectors.toList());
|
|
|
- //所有满足条件的任务 转map
|
|
|
- Map<Long, Task> taskMap = new HashMap<>();
|
|
|
- Map<String, List<OperationLog>> operationLogMap = new HashMap<>();
|
|
|
- List<Long> taskIds = pageList.stream().filter(b -> "已废除".equals(b.getTaskStatusName())).map(BusinessTaskPageVO::getTaskId).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isNotEmpty(taskIds)){
|
|
|
- String joinTaskIds = StringUtils.join(taskIds, ",");
|
|
|
- List<Task> tasks = jdbcTemplate.query("select id, create_time,form_data_id from u_task where id in ( " + joinTaskIds+")", new BeanPropertyRowMapper<>(Task.class));
|
|
|
- taskMap = tasks.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- Task::getId,
|
|
|
- task -> task));
|
|
|
- }
|
|
|
- if(CollectionUtil.isNotEmpty(pageList)){
|
|
|
- //所有满足条件的日志 转map
|
|
|
- Set<String> collect = pageList.stream().map(BusinessTaskPageVO::getFormDataId).collect(Collectors.toSet());
|
|
|
- String logQuery = "select business_id,create_user_name ,create_time, operation_type, save_data from u_operation_log where business_id in (" + StringUtil.join(collect) + ") and operation_type in (6,9,12,15,18,21,24,26,61,62)";
|
|
|
- List<OperationLog> operationLogs = jdbcTemplate.query(logQuery, new BeanPropertyRowMapper<>(OperationLog.class));
|
|
|
- if(ObjectUtil.isNotEmpty(operationLogs)){
|
|
|
- operationLogMap = operationLogs.stream().collect(Collectors.groupingBy(OperationLog::getBusinessId));
|
|
|
- }
|
|
|
- for (BusinessTaskPageVO businessTaskPageVO : pageList) {
|
|
|
- if("已废除".equals(businessTaskPageVO.getTaskStatusName())){
|
|
|
- Long taskId = businessTaskPageVO.getTaskId();
|
|
|
- Task task = taskMap.get(taskId);
|
|
|
- if (ObjectUtil.isEmpty(task)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- //任务创建时间
|
|
|
- Date createTime = task.getCreateTime();
|
|
|
- //废除时间肯定在任务创建时间之后 选择距离当前任务创建时间最近的一条数据
|
|
|
- List<OperationLog> operationLogsF = operationLogMap.get(task.getFormDataId());
|
|
|
-
|
|
|
- if(ObjectUtil.isNotEmpty(operationLogsF)){
|
|
|
- Optional<OperationLog> min = operationLogsF.stream().filter(o -> o.getCreateTime().compareTo(createTime) >= 0)
|
|
|
- .min(Comparator.comparing(t -> t.getCreateTime().getTime() - createTime.getTime()));
|
|
|
- if (min.isPresent()){
|
|
|
- OperationLog operationLog = min.get();
|
|
|
- String createUserName = operationLog.getCreateUserName();
|
|
|
- String date = DateUtil.formatDateTime(operationLog.getCreateTime());
|
|
|
- if (operationLog.getOperationType() != null && operationLog.getOperationType() == 61) {
|
|
|
- businessTaskPageVO.setEVisaStatus("驳回成功:"+ createUserName +"-"+ date);
|
|
|
- String saveData = operationLog.getSaveData();
|
|
|
- if (saveData != null && !saveData.isEmpty()) {
|
|
|
- try {
|
|
|
- JSONObject data = JSONObject.parseObject(saveData);
|
|
|
- if (data != null && data.containsKey("comment")) {
|
|
|
- businessTaskPageVO.setEVisaStatus("驳回成功:"+ createUserName +"-"+ date + ";驳回原因:"+data.getString("comment"));
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (operationLog.getOperationType() != null && operationLog.getOperationType() == 62) {
|
|
|
- businessTaskPageVO.setEVisaStatus("撤回成功:"+ createUserName +"-"+ date);
|
|
|
- } else {
|
|
|
- businessTaskPageVO.setEVisaStatus(businessTaskPageVO.getEVisaStatus()+":"+ createUserName +"-"+ date);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ // 9. 组装分页结果并返回
|
|
|
+ IPage<BusinessTaskPageVO> page = new Page<>(current, size);
|
|
|
page.setRecords(pageList);
|
|
|
page.setTotal(totalCount);
|
|
|
return R.data(page);
|