|
@@ -5,22 +5,29 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
-import org.springblade.business.entity.*;
|
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springblade.business.dto.TaskArchiveDTO;
|
|
|
|
+import org.springblade.business.dto.TaskArchiveOuterLayerDTO;
|
|
|
|
+import org.springblade.business.entity.DefaultConfig;
|
|
|
|
+import org.springblade.business.entity.InformationQuery;
|
|
|
|
+import org.springblade.business.entity.Task;
|
|
|
|
+import org.springblade.business.entity.TaskParallel;
|
|
import org.springblade.business.service.*;
|
|
import org.springblade.business.service.*;
|
|
import org.springblade.business.socket.WebSocket;
|
|
import org.springblade.business.socket.WebSocket;
|
|
-import org.springblade.business.vo.BatchTaskVO;
|
|
|
|
-import org.springblade.business.vo.TaskApprovalVO;
|
|
|
|
-import org.springblade.business.vo.TaskQueryVO;
|
|
|
|
-import org.springblade.common.utils.CommonUtil;
|
|
|
|
|
|
+import org.springblade.business.vo.*;
|
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Query;
|
|
import org.springblade.core.mp.support.Query;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
@@ -31,11 +38,11 @@ import org.springblade.core.tool.jackson.JsonUtil;
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
|
+import org.springblade.evisa.feign.EVisaClient;
|
|
import org.springblade.flow.core.entity.BladeFlow;
|
|
import org.springblade.flow.core.entity.BladeFlow;
|
|
import org.springblade.flow.core.feign.NewFlowClient;
|
|
import org.springblade.flow.core.feign.NewFlowClient;
|
|
import org.springblade.flow.core.vo.SendPageVO;
|
|
import org.springblade.flow.core.vo.SendPageVO;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
-import org.springblade.manager.entity.ContractRelationJlyz;
|
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
import org.springblade.manager.feign.ContractClient;
|
|
import org.springblade.resource.feign.CommonFileClient;
|
|
import org.springblade.resource.feign.CommonFileClient;
|
|
import org.springblade.resource.feign.NewISmsClient;
|
|
import org.springblade.resource.feign.NewISmsClient;
|
|
@@ -46,17 +53,11 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import org.springblade.business.vo.TaskVO;
|
|
|
|
-import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.time.Duration;
|
|
import java.time.Duration;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
-import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -72,31 +73,21 @@ import java.util.stream.Collectors;
|
|
@Api(value = "任务审核主表", tags = "任务审核主表接口")
|
|
@Api(value = "任务审核主表", tags = "任务审核主表接口")
|
|
public class TaskController extends BladeController {
|
|
public class TaskController extends BladeController {
|
|
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(TaskController.class);
|
|
private final JdbcTemplate jdbcTemplate;
|
|
private final JdbcTemplate jdbcTemplate;
|
|
-
|
|
|
|
private final ITaskService taskService;
|
|
private final ITaskService taskService;
|
|
-
|
|
|
|
private final ITaskParallelService taskParallelService;
|
|
private final ITaskParallelService taskParallelService;
|
|
-
|
|
|
|
private final NewFlowClient newFlowClient;
|
|
private final NewFlowClient newFlowClient;
|
|
-
|
|
|
|
private final IDictBizClient dictBizClient;
|
|
private final IDictBizClient dictBizClient;
|
|
-
|
|
|
|
private final NewISmsClient newSmsClient;
|
|
private final NewISmsClient newSmsClient;
|
|
-
|
|
|
|
private final IDefaultConfigService defaultConfigService;
|
|
private final IDefaultConfigService defaultConfigService;
|
|
-
|
|
|
|
private final ITaskBatchService taskBatchService;
|
|
private final ITaskBatchService taskBatchService;
|
|
-
|
|
|
|
private final ITaskService iTaskService;
|
|
private final ITaskService iTaskService;
|
|
-
|
|
|
|
private final WebSocket webSocket;
|
|
private final WebSocket webSocket;
|
|
-
|
|
|
|
private final CommonFileClient commonFileClient;
|
|
private final CommonFileClient commonFileClient;
|
|
-
|
|
|
|
private final ContractClient contractClient;
|
|
private final ContractClient contractClient;
|
|
-
|
|
|
|
private final IInformationQueryService informationQueryService;
|
|
private final IInformationQueryService informationQueryService;
|
|
|
|
+ private final EVisaClient eVisaClient;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 记录短信验证码超时时间
|
|
* 记录短信验证码超时时间
|
|
@@ -301,7 +292,7 @@ public class TaskController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 批量审批
|
|
|
|
|
|
+ * 批量审批(质检、试验 平行审批)
|
|
*/
|
|
*/
|
|
@PostMapping("/batch-complete-approval-task")
|
|
@PostMapping("/batch-complete-approval-task")
|
|
@ApiOperationSupport(order = 8)
|
|
@ApiOperationSupport(order = 8)
|
|
@@ -364,6 +355,113 @@ public class TaskController extends BladeController {
|
|
return R.data(false);
|
|
return R.data(false);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 批量审批(档案 垂直审批)
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/batch-complete-approval-task-archive")
|
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
|
+ @ApiOperation(value = "批量审批(档案 垂直审批)")
|
|
|
|
+ public R<Boolean> batchCompleteApprovalTaskArchive(@RequestBody TaskArchiveOuterLayerDTO taskArchiveOuterLayerDTO) throws IOException {
|
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUser()) || ObjectUtil.isEmpty(SecureUtil.getUserId()) || SecureUtil.getUserId().equals(-1L)) {
|
|
|
|
+ throw new ServiceException("未获取到当前登陆的用户信息,操作失败");
|
|
|
|
+ }
|
|
|
|
+ //检查审批人是否符合顺序
|
|
|
|
+ this.checkArchiveTaskUserByCurrent(taskArchiveOuterLayerDTO.getTaskArchiveDtoList());
|
|
|
|
+
|
|
|
|
+ //构造业务数据,修改业务数据
|
|
|
|
+ for (TaskArchiveDTO taskArchiveDTO : taskArchiveOuterLayerDTO.getTaskArchiveDtoList()) {
|
|
|
|
+ if (StringUtils.isNotEmpty(taskArchiveDTO.getTaskId())) {
|
|
|
|
+ //通过checkArchiveTaskUserByCurrent检查,说明当前登陆用户是该条任务的审批人,修改审批任务状态
|
|
|
|
+ Task task = jdbcTemplate.queryForObject("select process_instance_id,form_data_id from u_task where id = " + taskArchiveDTO.getTaskId(), new BeanPropertyRowMapper<>(Task.class));
|
|
|
|
+ if (task != null) {
|
|
|
|
+ //获取审批任务关联用户的详情
|
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query("select id,process_instance_id,task_user,task_user_name from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
|
+ if (taskParallels.size() > 0) {
|
|
|
|
+ //当前用户任务
|
|
|
|
+ TaskParallel taskParallelCurrentUser = taskParallels.stream().filter(f -> f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
|
|
|
|
+ if (taskParallelCurrentUser != null) {
|
|
|
|
+ //修改当前用户任务为已审批
|
|
|
|
+ jdbcTemplate.execute("update u_task_parallel set status = 2 where id = " + taskParallelCurrentUser.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //TODO ============ 档案电签推送(每个人都要电签,按照顺序) ============
|
|
|
|
+ org.springblade.evisa.vo.TaskArchiveDTO eVisaObj = new org.springblade.evisa.vo.TaskArchiveDTO();
|
|
|
|
+ BeanUtils.copyProperties(taskArchiveDTO, eVisaObj);
|
|
|
|
+ eVisaObj.setType(1); //审批
|
|
|
|
+ this.eVisaClient.eVisaCustom(eVisaObj);
|
|
|
|
+
|
|
|
|
+ /*//获取最新任务状态,判断是否存在未完成的审批任务(最后一个人审批完成);如果没有就闭环,修改审批任务状态、业务数据状态
|
|
|
|
+ List<TaskParallel> taskParallelsNow = jdbcTemplate.query("select status from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
|
+ List<TaskParallel> pendingApprovalTask = taskParallelsNow.stream().filter(f -> f.getStatus() != 2).collect(Collectors.toList());
|
|
|
|
+ if (pendingApprovalTask.size() == 0) {
|
|
|
|
+ //修改审批任务状态
|
|
|
|
+ jdbcTemplate.execute("update u_task set status = 2 where id = " + taskArchiveDTO.getTaskId());
|
|
|
|
+ //修改业务数据状态
|
|
|
|
+ jdbcTemplate.execute("update u_archive_file set status = 2 where id = " + task.getFormDataId());
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //WebSocket推送
|
|
|
|
+ if (ObjectUtil.isNotEmpty(AuthUtil.getUserId())) {
|
|
|
|
+ Map<String, String> webSocketMessageMap = WebSocket.getWebSocketMessageMap();
|
|
|
|
+ Set<Map.Entry<String, String>> message = webSocketMessageMap.entrySet();
|
|
|
|
+ for (Map.Entry<String, String> entry : message) {
|
|
|
|
+ String userId = entry.getKey();
|
|
|
|
+ if (userId.equals(AuthUtil.getUserId().toString())) { //只推送当前用户
|
|
|
|
+ String projectAndContractId = entry.getValue();
|
|
|
|
+ if (StringUtils.isNotEmpty(projectAndContractId) && StringUtils.isNotEmpty(userId)) {
|
|
|
|
+ String projectId = projectAndContractId.split(",")[0];
|
|
|
|
+ String contractId = projectAndContractId.split(",")[1];
|
|
|
|
+ Map<String, String> stringMap = iTaskService.getTaskCount(projectId, contractId, userId);
|
|
|
|
+ webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.data(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 检查档案审批是否按照顺序审批
|
|
|
|
+ *
|
|
|
|
+ * @param taskArchiveDTOList
|
|
|
|
+ */
|
|
|
|
+ private void checkArchiveTaskUserByCurrent(List<TaskArchiveDTO> taskArchiveDTOList) {
|
|
|
|
+ for (TaskArchiveDTO taskArchiveDTO : taskArchiveDTOList) {
|
|
|
|
+ if (ObjectUtil.isNotEmpty(taskArchiveDTO.getTaskId())) {
|
|
|
|
+ Task task = jdbcTemplate.queryForObject("select process_instance_id,task_name from u_task where id = '" + taskArchiveDTO.getTaskId() + "'", new BeanPropertyRowMapper<>(Task.class));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(task)) {
|
|
|
|
+ List<TaskParallel> taskParallelList = jdbcTemplate.query("select id,process_instance_id,task_user,task_user_name,status from u_task_parallel where process_instance_id ='" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
|
+ taskParallelList.sort(Comparator.comparing(TaskParallel::getId)); //根据id排序
|
|
|
|
+ Map<String, List<TaskParallel>> taskParallelGroup = taskParallelList.stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
|
+ for (Map.Entry<String, List<TaskParallel>> taskObj : taskParallelGroup.entrySet()) {
|
|
|
|
+ //获取当前审批人前面的审批人信息
|
|
|
|
+ List<TaskParallel> frontTaskUser = new LinkedList<>();
|
|
|
|
+ for (TaskParallel taskParallel : taskObj.getValue()) {
|
|
|
|
+ Long userId = SecureUtil.getUserId();
|
|
|
|
+ if (!userId.toString().equals(taskParallel.getTaskUser())) {
|
|
|
|
+ frontTaskUser.add(taskParallel);
|
|
|
|
+ } else {
|
|
|
|
+ //如果是当前的审批人,那么直接跳过
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<TaskParallel> resultTaskStatus = frontTaskUser.stream().filter(f -> !f.getStatus().equals(2)).collect(Collectors.toList());
|
|
|
|
+ if (resultTaskStatus.size() > 0) {
|
|
|
|
+ String names = resultTaskStatus.stream().map(TaskParallel::getTaskUserName).collect(Collectors.joining("、"));
|
|
|
|
+ throw new ServiceException("当前任务【" + task.getTaskName() + "】还有【" + names + "】未完成审批,请您稍后再试");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取当前合同段的上报批次
|
|
* 获取当前合同段的上报批次
|
|
*
|
|
*
|
|
@@ -482,7 +580,7 @@ public class TaskController extends BladeController {
|
|
this.integrationMethod(queryVO, masterTaskMap, parallelMap, parallelProcessInstanceIds, "1");
|
|
this.integrationMethod(queryVO, masterTaskMap, parallelMap, parallelProcessInstanceIds, "1");
|
|
|
|
|
|
//如果为空直接返回
|
|
//如果为空直接返回
|
|
- if (masterTaskMap.size() == 0 && parallelMap.size() == 0) {
|
|
|
|
|
|
+ if (masterTaskMap.size() == 0 && parallelMap.size() == 0 && ObjectUtil.isNotEmpty(queryVO.getContractId()) && ObjectUtil.isNotEmpty(queryVO.getProjectId())) {
|
|
this.sendsWebSocketCount(null, 2, queryVO);
|
|
this.sendsWebSocketCount(null, 2, queryVO);
|
|
return R.data(null);
|
|
return R.data(null);
|
|
}
|
|
}
|
|
@@ -494,9 +592,9 @@ public class TaskController extends BladeController {
|
|
R<IPage<TaskVO>> iPageR = this.integrationMethod(queryVO, rObject, masterTaskMap, parallelMap, true);
|
|
R<IPage<TaskVO>> iPageR = this.integrationMethod(queryVO, rObject, masterTaskMap, parallelMap, true);
|
|
|
|
|
|
//推送
|
|
//推送
|
|
- if (ObjectUtil.isNotEmpty(iPageR.getData()) && ObjectUtil.isNotEmpty(iPageR.getData().getRecords())) {
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(iPageR.getData()) && ObjectUtil.isNotEmpty(iPageR.getData().getRecords()) && ObjectUtil.isNotEmpty(queryVO.getContractId()) && ObjectUtil.isNotEmpty(queryVO.getProjectId())) {
|
|
this.sendsWebSocketCount(iPageR, 1, queryVO);
|
|
this.sendsWebSocketCount(iPageR, 1, queryVO);
|
|
- } else {
|
|
|
|
|
|
+ } else if (ObjectUtil.isNotEmpty(queryVO.getContractId()) && ObjectUtil.isNotEmpty(queryVO.getProjectId())) {
|
|
this.sendsWebSocketCount(null, 2, queryVO);
|
|
this.sendsWebSocketCount(null, 2, queryVO);
|
|
}
|
|
}
|
|
return iPageR;
|
|
return iPageR;
|