|
@@ -5,22 +5,30 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
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.extension.plugins.pagination.Page;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springblade.archive.dto.ArchiveTaskDTO;
|
|
|
+import org.springblade.archive.vo.ArchiveTaskPageVO;
|
|
|
+import org.springblade.business.dto.*;
|
|
|
import org.springblade.business.entity.*;
|
|
|
import org.springblade.business.service.*;
|
|
|
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.common.utils.SnowFlakeUtil;
|
|
|
+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.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
@@ -32,6 +40,7 @@ import org.springblade.core.tool.jackson.JsonUtil;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
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.feign.NewFlowClient;
|
|
|
import org.springblade.flow.core.vo.SendPageVO;
|
|
@@ -42,22 +51,17 @@ import org.springblade.resource.feign.CommonFileClient;
|
|
|
import org.springblade.resource.feign.NewISmsClient;
|
|
|
import org.springblade.system.entity.DictBiz;
|
|
|
import org.springblade.system.feign.IDictBizClient;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
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.IOException;
|
|
|
import java.time.Duration;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
-import java.util.concurrent.ThreadPoolExecutor;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -73,31 +77,21 @@ import java.util.stream.Collectors;
|
|
|
@Api(value = "任务审核主表", tags = "任务审核主表接口")
|
|
|
public class TaskController extends BladeController {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(TaskController.class);
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
-
|
|
|
private final ITaskService taskService;
|
|
|
-
|
|
|
private final ITaskParallelService taskParallelService;
|
|
|
-
|
|
|
private final NewFlowClient newFlowClient;
|
|
|
-
|
|
|
private final IDictBizClient dictBizClient;
|
|
|
-
|
|
|
private final NewISmsClient newSmsClient;
|
|
|
-
|
|
|
private final IDefaultConfigService defaultConfigService;
|
|
|
-
|
|
|
private final ITaskBatchService taskBatchService;
|
|
|
-
|
|
|
private final ITaskService iTaskService;
|
|
|
-
|
|
|
private final WebSocket webSocket;
|
|
|
-
|
|
|
private final CommonFileClient commonFileClient;
|
|
|
-
|
|
|
private final ContractClient contractClient;
|
|
|
-
|
|
|
private final IInformationQueryService informationQueryService;
|
|
|
+ private final EVisaClient eVisaClient;
|
|
|
|
|
|
/**
|
|
|
* 记录短信验证码超时时间
|
|
@@ -302,7 +296,7 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 批量审批
|
|
|
+ * 批量审批(质检、试验 平行审批)
|
|
|
*/
|
|
|
@PostMapping("/batch-complete-approval-task")
|
|
|
@ApiOperationSupport(order = 8)
|
|
@@ -365,6 +359,359 @@ public class TaskController extends BladeController {
|
|
|
return R.data(false);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量上报-档案
|
|
|
+ */
|
|
|
+ @PostMapping("/batch-report-task-archive")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "批量上报-档案")
|
|
|
+ public R<Object> batchReportTaskArchive(@RequestBody ArchiveTaskBatchReportDTO archiveTaskBatchReportDTO) throws IOException {
|
|
|
+ if (ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getUserIds())
|
|
|
+ || ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getDataIds())
|
|
|
+ || ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getBatch())
|
|
|
+ || ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getProjectId())
|
|
|
+ || ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getContractId())
|
|
|
+ || ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getRestrictDay())) {
|
|
|
+ throw new ServiceException("请求入参数据为空,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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));
|
|
|
+ Map<Long, String> fileNameMaps = jdbcTemplate.query("select id,file_name from u_archive_file where file_name is not null and id in (" + archiveTaskBatchReportDTO.getDataIds() + ")", new BeanPropertyRowMapper<>(ArchiveFile.class)).stream().collect(Collectors.toMap(ArchiveFile::getId, ArchiveFile::getFileName, (obj1, obj2) -> obj1));
|
|
|
+ String[] archiveIds = archiveTaskBatchReportDTO.getDataIds().split(",");
|
|
|
+ if (archiveIds.length > 0) {
|
|
|
+ for (String archiveId : archiveIds) {
|
|
|
+ //创建task审批任务
|
|
|
+ Long processInstanceId = SnowFlakeUtil.getId();
|
|
|
+ Task task = new Task();
|
|
|
+ task.setId(SnowFlakeUtil.getId());
|
|
|
+ Date nowTime = new Date();
|
|
|
+ task.setStartTime(DateUtil.format(nowTime, "yyyy-MM-dd"));
|
|
|
+ task.setEndTime(DateUtil.format(DateUtils.addDays(nowTime, archiveTaskBatchReportDTO.getRestrictDay()), "yyyy-MM-dd"));
|
|
|
+
|
|
|
+ task.setProcessDefinitionId(SnowFlakeUtil.getId().toString());
|
|
|
+ task.setProcessInstanceId(processInstanceId.toString()); //实例id
|
|
|
+
|
|
|
+ task.setReportUser(AuthUtil.getUserId().toString());
|
|
|
+ task.setReportUserName(AuthUtil.getNickName());
|
|
|
+
|
|
|
+ task.setCreateUser(AuthUtil.getUserId());
|
|
|
+ task.setCreateTime(nowTime);
|
|
|
+ task.setUpdateTime(nowTime);
|
|
|
+ task.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ task.setCreateDept(null);
|
|
|
+
|
|
|
+ task.setTaskContent(ObjectUtil.isNotEmpty(archiveTaskBatchReportDTO.getTaskContent()) ? archiveTaskBatchReportDTO.getTaskContent() : null);
|
|
|
+ task.setTaskUser(null);
|
|
|
+ task.setFormDataId(archiveId); //数据指向
|
|
|
+ task.setTaskName(ObjectUtil.isNotEmpty(fileNameMaps.get(Long.parseLong(archiveId))) ? fileNameMaps.get(Long.parseLong(archiveId)) : "未获取到档案文件任务名");
|
|
|
+ task.setContractId(archiveTaskBatchReportDTO.getContractId());
|
|
|
+ task.setProjectId(archiveTaskBatchReportDTO.getProjectId());
|
|
|
+ task.setBatch(archiveTaskBatchReportDTO.getBatch());
|
|
|
+ task.setType(1);
|
|
|
+ task.setApprovalType(4); //档案审批
|
|
|
+ task.setFixedFlowId(0L);
|
|
|
+ task.setStatus(1); //待审批
|
|
|
+ task.setIsDeleted(0);
|
|
|
+ task.setTrialSelfInspectionRecordId(null);
|
|
|
+
|
|
|
+ taskService.save(task);
|
|
|
+
|
|
|
+ //创建任务相关信息
|
|
|
+ String[] userIds = archiveTaskBatchReportDTO.getUserIds().split(",");
|
|
|
+ for (String userId : userIds) {
|
|
|
+ TaskParallel taskParallel = new TaskParallel();
|
|
|
+ taskParallel.setId(SnowFlakeUtil.getId());
|
|
|
+ taskParallel.setProcessInstanceId(processInstanceId.toString());
|
|
|
+ taskParallel.setParallelProcessInstanceId(SnowFlakeUtil.getId().toString());
|
|
|
+ taskParallel.setTaskUser(userId);
|
|
|
+ if (nameMap.get(Long.parseLong(userId)) != null) {
|
|
|
+ taskParallel.setTaskUserName(nameMap.get(Long.parseLong(userId)));
|
|
|
+ }
|
|
|
+ taskParallel.setInitiative(1);
|
|
|
+ taskParallel.setCreateUser(AuthUtil.getUserId());
|
|
|
+ taskParallel.setCreateTime(nowTime);
|
|
|
+ taskParallel.setUpdateTime(nowTime);
|
|
|
+ taskParallel.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ taskParallel.setCreateDept(null);
|
|
|
+ taskParallel.setStatus(1);
|
|
|
+ taskParallel.setIsDeleted(0);
|
|
|
+ taskParallelService.save(taskParallel);
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改档案业务数据任务状态为待审批
|
|
|
+ jdbcTemplate.execute("update u_archive_file set status = 1 where id = " + archiveId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //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.getTaskCountArchive(projectId, contractId, userId);
|
|
|
+ webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.success("上报成功");
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量撤销(废除)-档案
|
|
|
+ */
|
|
|
+ @PostMapping("/batch-repeal-task-archive")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "批量撤销(废除)-档案")
|
|
|
+ public R<Object> batchRepealTaskArchive(@RequestBody ArchiveTaskBatchRepealDTO repealDTO) throws IOException {
|
|
|
+ if (repealDTO.getType().equals(1)) { //文件收集废除
|
|
|
+ String[] archiveIds = repealDTO.getIds().split(",");
|
|
|
+ for (String archiveId : archiveIds) {
|
|
|
+ //判断现在的数据是否是待审批数据,只有待审批数据才能撤销
|
|
|
+ ArchiveFile archiveFile = jdbcTemplate.queryForObject("select * from u_archive_file where id = " + archiveId, new BeanPropertyRowMapper<>(ArchiveFile.class));
|
|
|
+ if (archiveFile != null && archiveFile.getStatus().equals(1)) {
|
|
|
+ //修改档案文件收集业务数据状态=已废除
|
|
|
+ jdbcTemplate.execute("update u_archive_file set status = 3 where id = " + archiveId);
|
|
|
+ Task task = jdbcTemplate.queryForObject("select id,status,process_instance_id from u_task where form_data_id = " + archiveId, new BeanPropertyRowMapper<>(Task.class));
|
|
|
+ if (task != null && task.getStatus().equals(1)) {
|
|
|
+ //待审批审批任务=已废除
|
|
|
+ jdbcTemplate.execute("update u_task set status = 3 where id = " + task.getId());
|
|
|
+ //审批任务详情=已废除
|
|
|
+ jdbcTemplate.execute("update u_task_parallel set status = 3 where process_instance_id = " + task.getProcessInstanceId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //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.getTaskCountArchive(projectId, contractId, userId);
|
|
|
+ webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ } else if (repealDTO.getType().equals(2)) { //任务审批废除
|
|
|
+ String[] taskIds = repealDTO.getIds().split(",");
|
|
|
+ for (String taskId : taskIds) {
|
|
|
+ Task task = jdbcTemplate.queryForObject("select id,status,process_instance_id,form_data_id from u_task where id = " + taskId, new BeanPropertyRowMapper<>(Task.class));
|
|
|
+ if (task != null && task.getStatus().equals(1)) {
|
|
|
+ //待审批审批任务=已废除
|
|
|
+ jdbcTemplate.execute("update u_task set status = 3 where id = " + task.getId());
|
|
|
+ //审批任务详情=已废除
|
|
|
+ jdbcTemplate.execute("update u_task_parallel set status = 3 where process_instance_id = " + task.getProcessInstanceId());
|
|
|
+ //修改档案文件收集业务数据状态
|
|
|
+ jdbcTemplate.execute("update u_archive_file set status = 3 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.getTaskCountArchive(projectId, contractId, userId);
|
|
|
+ webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail(400, "操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量审批(档案 垂直审批)
|
|
|
+ */
|
|
|
+ @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("未获取到当前登陆的用户信息,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ String flag = taskArchiveOuterLayerDTO.getTaskArchiveDtoList().stream().map(TaskArchiveDTO::getFlag).findAny().orElse(null);
|
|
|
+ if (StringUtils.isEmpty(flag)) {
|
|
|
+ throw new ServiceException("请选择审批操作类型,【同意】或【废除任务】");
|
|
|
+ }
|
|
|
+
|
|
|
+ //同意审批
|
|
|
+ if (flag.equals("OK")) {
|
|
|
+ //检查审批人是否符合顺序
|
|
|
+ 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.getTaskCountArchive(projectId, contractId, userId);
|
|
|
+ webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(true);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //废除任务
|
|
|
+ List<String> taskIds = taskArchiveOuterLayerDTO.getTaskArchiveDtoList().stream().map(TaskArchiveDTO::getTaskId).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
|
|
+ ArchiveTaskBatchRepealDTO dto = new ArchiveTaskBatchRepealDTO();
|
|
|
+ dto.setType(2);
|
|
|
+ dto.setIds(StringUtils.join(taskIds, ","));
|
|
|
+ R<Object> objectR = this.batchRepealTaskArchive(dto);
|
|
|
+ if (objectR.getCode() == 200) {
|
|
|
+ //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.getTaskCountArchive(projectId, contractId, userId);
|
|
|
+ webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(true);
|
|
|
+ } else if (objectR.getCode() == 400) {
|
|
|
+ return R.data(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量审批-获取档案审批任务对应业务数据的pdf信息
|
|
|
+ */
|
|
|
+ @PostMapping("/getArchiveFileTaskPdfs")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "批量审批-获取档案审批任务对应业务数据的pdf信息", notes = "传入任务id,封装成taskIds,字符串逗号分割拼接")
|
|
|
+ public R<List<ArchiveFileTaskPDFVO>> getArchiveFileTaskPdfs(@RequestParam String taskIds) {
|
|
|
+ if (StringUtils.isNotEmpty(taskIds)) {
|
|
|
+ List<Task> taskList = jdbcTemplate.query("select form_data_id from u_task where approval_type = 4 and id in(" + taskIds + ")", new BeanPropertyRowMapper<>(Task.class));
|
|
|
+ Set<String> formDataIds = taskList.stream().map(Task::getFormDataId).collect(Collectors.toSet());
|
|
|
+ if (formDataIds.size() > 0) {
|
|
|
+ List<ArchiveFile> archiveFiles = jdbcTemplate.query("select id,file_name,pdf_file_url,e_visa_file from u_archive_file where id in(" + StringUtils.join(formDataIds, ",") + ")", new BeanPropertyRowMapper<>(ArchiveFile.class));
|
|
|
+ List<ArchiveFileTaskPDFVO> collect = archiveFiles.stream()
|
|
|
+ .map(obj -> {
|
|
|
+ ArchiveFileTaskPDFVO vo = new ArchiveFileTaskPDFVO();
|
|
|
+ vo.setId(obj.getId());
|
|
|
+ vo.setPdfUrl(ObjectUtil.isNotEmpty(obj.getEVisaFile()) ? obj.getEVisaFile() : obj.getPdfFileUrl());
|
|
|
+ vo.setFileName(obj.getFileName());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return R.data(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查档案审批是否按照顺序审批
|
|
|
+ *
|
|
|
+ * @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 + "】未完成审批,请您稍后再试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前合同段的上报批次
|
|
|
*
|
|
@@ -413,7 +760,7 @@ public class TaskController extends BladeController {
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "获取任务类型或任务状态")
|
|
|
public R<List<DictBiz>> queryTaskTypeOrStatus(String typeOrStatus, BladeUser bladeUser) {
|
|
|
- return R.data(jdbcTemplate.query("select dict_key, dict_value from blade_dict_biz where code = '" + typeOrStatus + "' and tenant_id="+bladeUser.getTenantId()+" and parent_id > 0 and is_sealed = 0 and is_deleted = 0 order by sort", new BeanPropertyRowMapper<>(DictBiz.class)));
|
|
|
+ return R.data(jdbcTemplate.query("select dict_key, dict_value from blade_dict_biz where code = '" + typeOrStatus + "' and tenant_id=" + bladeUser.getTenantId() + " and parent_id > 0 and is_sealed = 0 and is_deleted = 0 order by sort", new BeanPropertyRowMapper<>(DictBiz.class)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -483,7 +830,7 @@ public class TaskController extends BladeController {
|
|
|
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);
|
|
|
return R.data(null);
|
|
|
}
|
|
@@ -495,9 +842,9 @@ public class TaskController extends BladeController {
|
|
|
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);
|
|
|
- } else {
|
|
|
+ } else if (ObjectUtil.isNotEmpty(queryVO.getContractId()) && ObjectUtil.isNotEmpty(queryVO.getProjectId())) {
|
|
|
this.sendsWebSocketCount(null, 2, queryVO);
|
|
|
}
|
|
|
return iPageR;
|
|
@@ -513,6 +860,10 @@ public class TaskController extends BladeController {
|
|
|
*/
|
|
|
@Async
|
|
|
public void sendsWebSocketCount(R<IPage<TaskVO>> iPageR, int type, TaskQueryVO queryVO) throws IOException {
|
|
|
+ if (ObjectUtil.isEmpty(queryVO.getCurrentContractId())) {
|
|
|
+ //如果getCurrentContractId=null,那么表示是APP的待办查询(web端不为null)
|
|
|
+ queryVO.setCurrentContractId(queryVO.getContractId());
|
|
|
+ }
|
|
|
if (type == 1) {
|
|
|
Map<String, String> stringMap = iTaskService.getTaskCount(queryVO.getProjectId(), queryVO.getCurrentContractId(), SecureUtil.getUserId().toString());
|
|
|
stringMap.put("taskCount", String.valueOf(iPageR.getData().getTotal()));
|
|
@@ -716,4 +1067,170 @@ 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) {
|
|
|
+ int current = dto.getCurrent();
|
|
|
+ int size = dto.getSize();
|
|
|
+ //封装入参SQL
|
|
|
+ List<Object> params = new ArrayList<>();
|
|
|
+ StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND approval_type != 4"); //approval_type != 4 非档案的任务就是1填报资料,2工程文件,3日志资料
|
|
|
+ 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))) {
|
|
|
+ //如果是监理合同段,那么默认查询关联的全部施工合同段+本身任务
|
|
|
+ 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(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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(dto.getStartTimeValue())
|
|
|
+ .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());
|
|
|
+
|
|
|
+ //如果是待办页面,且 任务状态下拉框 选择的不是 待审批状态 的任务,那么直接返回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");
|
|
|
+ }
|
|
|
+
|
|
|
+ } 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 = ? AND u_task_parallel.task_user = ?)");
|
|
|
+ //当前自己的任务必须是已审批,才视为已办
|
|
|
+ params.add(2);
|
|
|
+ params.add(SecureUtil.getUserId());
|
|
|
+
|
|
|
+ } else if (dto.getSelectedType().equals(3)) { //我发起页面
|
|
|
+ sqlString.append("report_user = ?");
|
|
|
+ params.add(SecureUtil.getUserId());
|
|
|
+ }
|
|
|
+ sqlString.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ //总数量
|
|
|
+ String sqlCount = sqlString.toString().replace("*", "count(1)");
|
|
|
+ Optional<Integer> totalCountOptional = Optional.ofNullable(jdbcTemplate.queryForObject(sqlCount, Integer.class, params.toArray()));
|
|
|
+ int totalCount = totalCountOptional.orElse(0);
|
|
|
+
|
|
|
+ //分页
|
|
|
+ sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?");
|
|
|
+ params.add(size);
|
|
|
+ params.add((current - 1) * size);
|
|
|
+
|
|
|
+ //执行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) {
|
|
|
+ StringJoiner joiner = new StringJoiner(",", "'", "'");
|
|
|
+ processInstanceIds.forEach(joiner::add);
|
|
|
+ String joinedIds = joiner.toString();
|
|
|
+ taskParallelGroupMap = jdbcTemplate.query("select process_instance_id,task_user_name,e_visa_status,e_visa_content from u_task_parallel where process_instance_id in(" + joinedIds + ") 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.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());
|
|
|
+ List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
+ if (taskParallelList != null && taskParallelList.size() > 0) {
|
|
|
+ List<String> names = taskParallelList.stream().map(TaskParallel::getTaskUserName).collect(Collectors.toList());
|
|
|
+ if (names.size() > 0) {
|
|
|
+ vo.setTaskApproveUserNames(StringUtils.join(names, ","));
|
|
|
+ }
|
|
|
+ Set<Integer> eVisaStatus = taskParallelList.stream().map(TaskParallel::getEVisaStatus).collect(Collectors.toSet());
|
|
|
+ if (eVisaStatus.size() > 0) {
|
|
|
+ vo.setEVisaStatus(StringUtils.join(eVisaStatus, "、"));
|
|
|
+ }
|
|
|
+ Set<String> eVisaContents = taskParallelList.stream().map(TaskParallel::getEVisaContent).collect(Collectors.toSet());
|
|
|
+ if (eVisaContents.size() > 0) {
|
|
|
+ vo.setEVisaContents(StringUtils.join(eVisaContents, "、"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ page.setRecords(pageList);
|
|
|
+ page.setTotal(totalCount);
|
|
|
+ return R.data(page);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|