|
@@ -14,18 +14,19 @@ import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
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.business.dto.ArchiveTaskBatchRepealDTO;
|
|
|
+import org.springblade.business.dto.ArchiveTaskBatchReportDTO;
|
|
|
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.entity.*;
|
|
|
import org.springblade.business.service.*;
|
|
|
import org.springblade.business.socket.WebSocket;
|
|
|
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;
|
|
@@ -48,6 +49,7 @@ 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;
|
|
@@ -355,6 +357,132 @@ 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) {
|
|
|
+ if (ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getUserIds())
|
|
|
+ || ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getDataIds())
|
|
|
+ || ObjectUtil.isEmpty(archiveTaskBatchReportDTO.getTaskName())
|
|
|
+ || 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));
|
|
|
+ String[] archiveIds = archiveTaskBatchReportDTO.getDataIds().split(",");
|
|
|
+ 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(archiveTaskBatchReportDTO.getTaskName());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ return R.success("上报成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.fail(400, "上报失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量撤销(废除)-档案
|
|
|
+ */
|
|
|
+ @PostMapping("/batch-repeal-task-archive")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "批量撤销(废除)-档案")
|
|
|
+ public R<Object> batchRepealTaskArchive(@RequestBody ArchiveTaskBatchRepealDTO repealDTO) {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail(400, "操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批量审批(档案 垂直审批)
|
|
|
*/
|
|
@@ -365,64 +493,103 @@ public class TaskController extends BladeController {
|
|
|
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());
|
|
|
+
|
|
|
+ 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());
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //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);
|
|
|
|
|
|
- //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));
|
|
|
+ } 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.getTaskCount(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(true);
|
|
|
+ return R.data(false);
|
|
|
}
|
|
|
|
|
|
|