|
@@ -26,6 +26,7 @@ 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.CommonUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -47,9 +48,11 @@ import org.springblade.flow.core.vo.SendPageVO;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
import org.springblade.manager.entity.ContractRelationJlyz;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
|
+import org.springblade.manager.feign.ExcelTabClient;
|
|
|
import org.springblade.resource.feign.CommonFileClient;
|
|
|
import org.springblade.resource.feign.NewISmsClient;
|
|
|
import org.springblade.system.entity.DictBiz;
|
|
|
+import org.springblade.system.entity.Role;
|
|
|
import org.springblade.system.feign.IDictBizClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -60,6 +63,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.Duration;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
@@ -92,6 +96,7 @@ public class TaskController extends BladeController {
|
|
|
private final ContractClient contractClient;
|
|
|
private final IInformationQueryService informationQueryService;
|
|
|
private final EVisaClient eVisaClient;
|
|
|
+ private final ExcelTabClient excelTabClient;
|
|
|
|
|
|
/**
|
|
|
* 记录短信验证码超时时间
|
|
@@ -1147,7 +1152,6 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
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());
|
|
@@ -1276,7 +1280,7 @@ public class TaskController extends BladeController {
|
|
|
taskPa.setEVisaStatus(2);
|
|
|
} else if (taskPa.getStatus() == 3 && taskPa.getTaskUser().equals(SecureUtil.getUserId().toString())) {
|
|
|
taskPa.setEVisaStatus(3);
|
|
|
- } else if (taskPa.getStatus() == 999) {
|
|
|
+ } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
taskPa.setEVisaStatus(999);
|
|
|
} else {
|
|
|
taskPa.setEVisaStatus(1);
|
|
@@ -1336,5 +1340,207 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 任务管理-电签失败分页查询
|
|
|
+ */
|
|
|
+ @PostMapping("/eVisaFailedPage")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "任务管理-电签失败分页查询", notes = "传入BusinessTaskFailedDTO")
|
|
|
+ public R<IPage<BusinessTaskFailedPageVO>> eVisaFailedPage(@RequestBody BusinessTaskFailedDTO dto) {
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
|
+ throw new ServiceException("未获取到当前登陆的用户信息");
|
|
|
+ } else {
|
|
|
+ if (!SecureUtil.getUser().getRoleName().contains("administrator")) {
|
|
|
+ return R.data(200, null, "当前用户不是超管角色,未查询到信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(dto.getContractId())) {
|
|
|
+ throw new ServiceException("合同段不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(dto.getCurrent()) || ObjectUtil.isEmpty(dto.getSize())) {
|
|
|
+ throw new ServiceException("分页current或size不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 status = 1 AND approval_type != 4 AND contract_id = " + dto.getContractId()); //approval_type != 4 非档案的任务就是1填报资料,2工程文件,3日志资料
|
|
|
+
|
|
|
+ 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 (StringUtils.isNotBlank(dto.getEVisaUserName())) {
|
|
|
+ sqlString.append(" AND EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.e_visa_status = 99 AND u_task_parallel.status != 3 AND u_task_parallel.task_user_name LIKE ?)");
|
|
|
+ params.add("%" + dto.getEVisaUserName() + "%");
|
|
|
+ } else {
|
|
|
+ sqlString.append(" AND EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.e_visa_status = 99 AND u_task_parallel.status != 3)");
|
|
|
+ }
|
|
|
+
|
|
|
+ //总数量
|
|
|
+ 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) {
|
|
|
+ String resultIds = processInstanceIds.stream()
|
|
|
+ .map(id -> "'" + id + "'")
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ taskParallelGroupMap = jdbcTemplate.query("select update_time,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<BusinessTaskFailedPageVO> page = new Page<>(current, size);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List<BusinessTaskFailedPageVO> pageList = resultList.stream()
|
|
|
+ .map(task -> {
|
|
|
+ BusinessTaskFailedPageVO vo = new BusinessTaskFailedPageVO();
|
|
|
+ vo.setId(task.getId());
|
|
|
+ vo.setTaskName(task.getTaskName());
|
|
|
+ vo.setTaskStatusName(task.getStatus().equals(1) ? "待审批" : task.getStatus().equals(2) ? "已审批" : "已废除");
|
|
|
+ vo.setEVisaStatusName("电签失败");
|
|
|
+ vo.setTaskReportUserName(nameMap.get(Long.parseLong(task.getReportUser())));
|
|
|
+ List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
+ if (taskParallelList != null && taskParallelList.size() > 0) {
|
|
|
+ //判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色
|
|
|
+ List<TaskParallel> statList = new ArrayList<>();
|
|
|
+ String formatDate = "";
|
|
|
+ String eVisaFailedInfo = "";
|
|
|
+ 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);
|
|
|
+ if (ObjectUtil.isEmpty(formatDate)) {
|
|
|
+ formatDate = simpleDateFormat.format(taskPa.getUpdateTime());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(eVisaFailedInfo)) {
|
|
|
+ eVisaFailedInfo = taskPa.getEVisaContent();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ taskPa.setEVisaStatus(1);
|
|
|
+ }
|
|
|
+ statList.add(taskPa);
|
|
|
+ }
|
|
|
+ vo.setTaskApproveUserNamesList(statList);
|
|
|
+ vo.setEVisaUpdateDate(formatDate);
|
|
|
+ vo.setEVisaFailedInfo(eVisaFailedInfo);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ page.setRecords(pageList);
|
|
|
+ page.setTotal(totalCount);
|
|
|
+ return R.data(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 资料填报-任务管理-一键重签
|
|
|
+ */
|
|
|
+ @PostMapping("/reSigningEVisa")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "任务管理-一键重签", notes = "传入taskIds、下拉框的contractId、projectId")
|
|
|
+ public R<Object> reSigningEVisa(@RequestParam String taskIds, @RequestParam String contractId, @RequestParam String projectId) {
|
|
|
+ if (ObjectUtil.isEmpty(taskIds)) {
|
|
|
+ throw new ServiceException("请选择至少一条任务进行重签");
|
|
|
+ }
|
|
|
+ List<Task> taskList = jdbcTemplate.query("select * from u_task where id in(" + taskIds + ")", new BeanPropertyRowMapper<>(Task.class));
|
|
|
+ if (taskList.size() > 0) {
|
|
|
+ List<String> dataIdList = taskList.stream().map(Task::getFormDataId).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
|
|
+ List<InformationQuery> informationQueryList = jdbcTemplate.query("select * from u_information_query where id in(" + StringUtils.join(dataIdList, ",") + ")", new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
+ if (informationQueryList.size() > 0) {
|
|
|
+ List<Long> nodePKeyIdList = informationQueryList.stream().map(InformationQuery::getWbsId).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
|
|
+ if (nodePKeyIdList.size() > 0) {
|
|
|
+ try {
|
|
|
+ //重新保存
|
|
|
+ long startTime_1 = System.currentTimeMillis();
|
|
|
+ R result = this.saveNodePdf(StringUtils.join(nodePKeyIdList, ","), contractId, projectId);
|
|
|
+ long endTime_1 = System.currentTimeMillis();
|
|
|
+ long executionTime_1 = endTime_1 - startTime_1;
|
|
|
+ log.info("saveNodePdf执行时间:" + executionTime_1 + " 毫秒");
|
|
|
+
|
|
|
+ //重新电签
|
|
|
+ if (result != null && "成功".equals(result.getData())) {
|
|
|
+ List<TaskApprovalVO> taskApprovalVOS = new ArrayList<>();
|
|
|
+ //获取任务详情信息Map
|
|
|
+ Set<String> processInstanceIds = taskList.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 parallel_process_instance_id,process_instance_id 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;
|
|
|
+
|
|
|
+ for (Task task : taskList) {
|
|
|
+ List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
+ for (TaskParallel taskParallel : taskParallelList) {
|
|
|
+ TaskApprovalVO approvalVO = new TaskApprovalVO();
|
|
|
+ approvalVO.setTaskId(task.getId().toString());
|
|
|
+ approvalVO.setFlag("OK");
|
|
|
+ approvalVO.setComment("重新发起电签");
|
|
|
+ approvalVO.setApprovalType(1);
|
|
|
+ approvalVO.setFormDataId(task.getFormDataId());
|
|
|
+ approvalVO.setParallelProcessInstanceId(taskParallel.getParallelProcessInstanceId());
|
|
|
+ taskApprovalVOS.add(approvalVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ long startTime_2 = System.currentTimeMillis();
|
|
|
+ taskService.batchCompleteApprovalTask(taskApprovalVOS);
|
|
|
+ long endTime_2 = System.currentTimeMillis();
|
|
|
+ long executionTime_2 = endTime_2 - startTime_2;
|
|
|
+ log.info("batchCompleteApprovalTask执行时间:" + executionTime_2 + " 毫秒");
|
|
|
+
|
|
|
+ return R.success("任务已经成功提交重签,请耐心等待!");
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("重新保存PDF信息失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ServiceException("重新保存PDF信息失败,原因:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("未获取到任务信息,操作失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ R saveNodePdf(String nodePKeyIds, String contractId, String projectId) throws Exception {
|
|
|
+ return excelTabClient.synPDFInfo(contractId, nodePKeyIds, "1", projectId);
|
|
|
+ }
|
|
|
|
|
|
}
|