|
@@ -1,7 +1,9 @@
|
|
package org.springblade.business.controller;
|
|
package org.springblade.business.controller;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -13,20 +15,30 @@ import org.springblade.business.entity.FixedFlowLink;
|
|
import org.springblade.business.entity.Task;
|
|
import org.springblade.business.entity.Task;
|
|
import org.springblade.business.service.IFixedFlowLinkService;
|
|
import org.springblade.business.service.IFixedFlowLinkService;
|
|
import org.springblade.business.service.IFixedFlowService;
|
|
import org.springblade.business.service.IFixedFlowService;
|
|
|
|
+import org.springblade.business.service.impl.TaskServiceImpl;
|
|
import org.springblade.business.vo.FixedFlowVO;
|
|
import org.springblade.business.vo.FixedFlowVO;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
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.manager.dto.SaveUserInfoByProjectDTO;
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
|
+import org.springblade.manager.entity.ProjectInfo;
|
|
import org.springblade.manager.entity.SignPfxFile;
|
|
import org.springblade.manager.entity.SignPfxFile;
|
|
import org.springblade.manager.feign.ContractClient;
|
|
import org.springblade.manager.feign.ContractClient;
|
|
import org.springblade.manager.feign.ProjectAssignmentUserClient;
|
|
import org.springblade.manager.feign.ProjectAssignmentUserClient;
|
|
|
|
+import org.springblade.manager.feign.ProjectClient;
|
|
|
|
+import org.springblade.manager.feign.SignPfxClient;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO1;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO1;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO2;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO2;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO3;
|
|
import org.springblade.manager.vo.RoleSignPfxUserVO3;
|
|
|
|
+import org.springblade.meter.dto.PageFixedFlowDTO;
|
|
|
|
+import org.springblade.meter.dto.SaveFixedFlowDTO;
|
|
|
|
+import org.springblade.meter.dto.UpdateFixedFlowDTO;
|
|
import org.springblade.system.feign.ISysClient;
|
|
import org.springblade.system.feign.ISysClient;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
@@ -34,12 +46,13 @@ import org.springblade.system.vo.RoleVO;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 控制器
|
|
* 控制器
|
|
@@ -67,14 +80,16 @@ public class FixedFlowController extends BladeController {
|
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
+ private final ProjectClient projectClient;
|
|
|
|
+
|
|
|
|
+ private final TaskServiceImpl taskServiceImpl;
|
|
/**
|
|
/**
|
|
* 获取系统所有角色划分
|
|
* 获取系统所有角色划分
|
|
*/
|
|
*/
|
|
@GetMapping("/queryAllRoleList")
|
|
@GetMapping("/queryAllRoleList")
|
|
@ApiOperationSupport(order = 9)
|
|
@ApiOperationSupport(order = 9)
|
|
@ApiOperation(value = "获取系统所有角色划分")
|
|
@ApiOperation(value = "获取系统所有角色划分")
|
|
- public R<List<RoleSignPfxUserVO>> queryAllRoleList(@RequestParam String contractId) {
|
|
|
|
- RoleSignPfxUserVO1 vo1 = new RoleSignPfxUserVO1();
|
|
|
|
|
|
+ public R<List<RoleSignPfxUserVO>> queryAllRoleList(@RequestParam String contractId, @RequestParam(required = false, defaultValue = "0") Integer type) {
|
|
//获取当前系统配置的角色划分
|
|
//获取当前系统配置的角色划分
|
|
List<RoleVO> roleVOS = this.sysClient.search().getData();
|
|
List<RoleVO> roleVOS = this.sysClient.search().getData();
|
|
//获取项目人员
|
|
//获取项目人员
|
|
@@ -95,6 +110,15 @@ public class FixedFlowController extends BladeController {
|
|
//返回结果
|
|
//返回结果
|
|
List<RoleSignPfxUserVO> result = new ArrayList<>();
|
|
List<RoleSignPfxUserVO> result = new ArrayList<>();
|
|
for (RoleVO vo : roleVOS) {
|
|
for (RoleVO vo : roleVOS) {
|
|
|
|
+ if (type != null && type == 1) {
|
|
|
|
+ // 除“超级管理员”外,其余只展示“业主方”、“监理方”、“施工方”。“超级管理员”只有用户角色为“超级管理员”时才展示。其余角色均不展示;
|
|
|
|
+ if (vo.getRoleName() == null || (!vo.getRoleName().contains("管理员") && !vo.getRoleName().contains("业主方") && !vo.getRoleName().contains("施工方") && !vo.getRoleName().contains("监理方"))) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (!"administrator".equals(AuthUtil.getUserRole()) && vo.getRoleName() != null && "administrator".equals(vo.getRoleAlias())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//设置实体
|
|
//设置实体
|
|
RoleSignPfxUserVO pfxUserVo = new RoleSignPfxUserVO();
|
|
RoleSignPfxUserVO pfxUserVo = new RoleSignPfxUserVO();
|
|
pfxUserVo.setRoleId(vo.getId());
|
|
pfxUserVo.setRoleId(vo.getId());
|
|
@@ -129,6 +153,9 @@ public class FixedFlowController extends BladeController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//设置子集
|
|
//设置子集
|
|
|
|
+ if (childPfxUserVo.getSignPfxFileList() == null || childPfxUserVo.getSignPfxFileList().isEmpty()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
pfxUserVo.getChildRoleList().add(childPfxUserVo);
|
|
pfxUserVo.getChildRoleList().add(childPfxUserVo);
|
|
pfxUserVo.getSignPfxFileList().addAll(childPfxUserVo.getSignPfxFileList());
|
|
pfxUserVo.getSignPfxFileList().addAll(childPfxUserVo.getSignPfxFileList());
|
|
}
|
|
}
|
|
@@ -174,7 +201,28 @@ public class FixedFlowController extends BladeController {
|
|
if (vo.getCurrent() == null || vo.getSize() == null) {
|
|
if (vo.getCurrent() == null || vo.getSize() == null) {
|
|
return R.data(-1, null, "缺少size或current参数");
|
|
return R.data(-1, null, "缺少size或current参数");
|
|
}
|
|
}
|
|
- return R.data(this.fixedFlowService.selectFixedFlowPage(vo));
|
|
|
|
|
|
+ IPage<FixedFlowVO> page = this.fixedFlowService.selectFixedFlowPage(vo);
|
|
|
|
+ List<FixedFlowVO> records = page.getRecords();
|
|
|
|
+ if (records != null && !records.isEmpty()) {
|
|
|
|
+ Map<Boolean, List<FixedFlowVO>> groupMap = records.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName() != null && record.getFixedFlowName().contains("_") && record.getSort() == null));
|
|
|
|
+ List<FixedFlowVO> copyFixedFlowVOS = groupMap.get(true);
|
|
|
|
+ List<FixedFlowVO> fixedFlowVOS = groupMap.get(false);
|
|
|
|
+ if (copyFixedFlowVOS == null || copyFixedFlowVOS.isEmpty() || fixedFlowVOS == null || fixedFlowVOS.isEmpty()) {
|
|
|
|
+ return R.data(page);
|
|
|
|
+ }
|
|
|
|
+ Map<String, List<FixedFlowVO>> nameMap = copyFixedFlowVOS.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName().split("_")[0]));
|
|
|
|
+ List<FixedFlowVO> newData = new ArrayList<>();
|
|
|
|
+ for (FixedFlowVO flowVO : fixedFlowVOS) {
|
|
|
|
+ newData.add(flowVO);
|
|
|
|
+ List<FixedFlowVO> flowVOS = nameMap.get(flowVO.getFixedFlowName());
|
|
|
|
+ if (flowVOS != null && !flowVOS.isEmpty()) {
|
|
|
|
+ flowVOS.sort(Comparator.comparing(FixedFlow::getFixedFlowName));
|
|
|
|
+ newData.addAll(flowVOS);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ page.setRecords(newData);
|
|
|
|
+ }
|
|
|
|
+ return R.data(page);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -282,5 +330,442 @@ public class FixedFlowController extends BladeController {
|
|
return R.status(false);
|
|
return R.status(false);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 复制
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/copy")
|
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
|
+ @ApiOperation(value = "复制", notes = "传入fixedFlow id")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public R<String> copy(String ids) {
|
|
|
|
+ if (StringUtils.isBlank(ids)) {
|
|
|
|
+ return R.fail("请选择要复制的流程");
|
|
|
|
+ }
|
|
|
|
+ List<Long> idList = Func.toLongList(ids);
|
|
|
|
+ List<FixedFlow> fixedFlowList = this.fixedFlowService.listByIds(idList);
|
|
|
|
+ if (fixedFlowList.isEmpty()) {
|
|
|
|
+ return R.fail("选择的流程不存在");
|
|
|
|
+ }
|
|
|
|
+ List<FixedFlowLink> fixedFlowLinkList = this.fixedFlowLinkService.list(Wrappers.<FixedFlowLink>lambdaQuery().in(FixedFlowLink::getFixedFlowId, idList));
|
|
|
|
+ Map<Long, List<FixedFlowLink>> linkMap = fixedFlowLinkList.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
|
|
|
|
+ List<FixedFlowLink> newFixedFolwLinkList = new ArrayList<>();
|
|
|
|
+ Map<String, Long> nameCountMap = new HashMap<>();
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ fixedFlowList.forEach(fixedFlow -> {
|
|
|
|
+ //生成主表主键
|
|
|
|
+ long fixedFlowId = SnowFlakeUtil.getId();
|
|
|
|
+ sb.append(fixedFlowId).append( ",");
|
|
|
|
+ List<FixedFlowLink> sourceFixedFolwLinkList = linkMap.get(fixedFlow.getId());
|
|
|
|
+ if (sourceFixedFolwLinkList != null && !sourceFixedFolwLinkList.isEmpty()) {
|
|
|
|
+ for (FixedFlowLink fixedFlowLink : sourceFixedFolwLinkList) {
|
|
|
|
+ FixedFlowLink newLink = new FixedFlowLink();
|
|
|
|
+ BeanUtils.copyProperties(fixedFlowLink, newLink);
|
|
|
|
+ newLink.setId(SnowFlakeUtil.getId());
|
|
|
|
+ newLink.setFixedFlowId(fixedFlowId);
|
|
|
|
+ newLink.setCreateUser(AuthUtil.getUserId());
|
|
|
|
+ newLink.setCreateTime(new Date());
|
|
|
|
+ newFixedFolwLinkList.add(newLink);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Long number = nameCountMap.get(fixedFlow.getFixedFlowName());
|
|
|
|
+ if (number == null) {
|
|
|
|
+ List<FixedFlow> list = this.fixedFlowService.list(Wrappers.<FixedFlow>lambdaQuery().select(FixedFlow::getFixedFlowName).likeRight(FixedFlow::getFixedFlowName, fixedFlow.getFixedFlowName())
|
|
|
|
+ .eq(FixedFlow::getContractId, fixedFlow.getContractId()).ne(FixedFlow::getId, fixedFlow.getId()));
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ number = 0L;
|
|
|
|
+ } else {
|
|
|
|
+ int length = fixedFlow.getFixedFlowName().split("_").length;
|
|
|
|
+ number = list.stream().filter(item -> item.getFixedFlowName().split("_").length == length + 1).count();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ nameCountMap.put(fixedFlow.getFixedFlowName(), number + 1);
|
|
|
|
+ fixedFlow.setId(fixedFlowId);
|
|
|
|
+ fixedFlow.setFixedFlowName(fixedFlow.getFixedFlowName() + "_" + (number + 1));
|
|
|
|
+ fixedFlow.setCreateTime(new Date());
|
|
|
|
+ fixedFlow.setCreateDept(fixedFlow.getId());
|
|
|
|
+ fixedFlow.setUpdateTime(new Date());
|
|
|
|
+ fixedFlow.setCreateUser(AuthUtil.getUserId());
|
|
|
|
+ });
|
|
|
|
+ boolean flow = this.fixedFlowService.saveBatch(fixedFlowList);
|
|
|
|
+ if (flow && !newFixedFolwLinkList.isEmpty()) {
|
|
|
|
+ flow = this.fixedFlowLinkService.saveBatch(newFixedFolwLinkList);
|
|
|
|
+ }
|
|
|
|
+ if (flow) {
|
|
|
|
+ return R.data(sb.deleteCharAt(sb.length() - 1).toString());
|
|
|
|
+ }
|
|
|
|
+ return R.status(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/saveFixedFlow")
|
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
|
+ @ApiOperation(value = "新增任务流程", notes = "传入dto")
|
|
|
|
+ public R<Object> saveFixedFlow(@RequestBody SaveFixedFlowDTO dto) {
|
|
|
|
+ if (ObjectUtil.isEmpty(dto.getFixedBranchList())) {
|
|
|
|
+ return R.fail("请选择任务流程人员");
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getFixedName()) && ObjectUtil.isNotEmpty(dto.getProjectId()) && ObjectUtil.isNotEmpty(dto.getContractId())) {
|
|
|
|
+ ProjectInfo projectInfo = projectClient.getById(dto.getProjectId() + "");
|
|
|
|
+ if (projectInfo == null) {
|
|
|
|
+ return R.fail("暂未找到项目信息,请稍后再试");
|
|
|
|
+ }
|
|
|
|
+ List<String> userIds = dto.getFixedBranchList().stream().map(SaveFixedFlowDTO.FixedBranch::getUserIds).collect(Collectors.toList());
|
|
|
|
+ List<User> users = jdbcTemplate.query("select id,name,acc_code,real_name from blade_user where is_deleted = 0 and id in (" + StringUtils.join(userIds, ",") + ")", new BeanPropertyRowMapper<>(User.class));
|
|
|
|
+ Map<Long, User> userMap = users.stream().collect(Collectors.toMap(User::getId, item -> item));
|
|
|
|
+ if (ObjectUtil.isEmpty( users)) {
|
|
|
|
+ return R.fail("请选择任务流程人员");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.equals(projectInfo.getRemarkType(), 1)) {
|
|
|
|
+ //安心签,校验证书 检查签字证书信息
|
|
|
|
+ Set<String> notCertificateUserInfoSet = new HashSet<>();
|
|
|
|
+ //获取用户的证书信息
|
|
|
|
+ String ids = users.stream().map(user -> user.getId() + "").collect(Collectors.joining(","));
|
|
|
|
+ List<SignPfxFile> signPfxFiles = jdbcTemplate.query("select * from m_sign_pfx_file where is_register = 1 and certificate_user_id in ( " + ids + " )", new BeanPropertyRowMapper<>(SignPfxFile.class));
|
|
|
|
+ Map<String, List<SignPfxFile>> collect = signPfxFiles.stream().collect(Collectors.groupingBy(signPfxFile -> signPfxFile.getCertificateUserId() + ""));
|
|
|
|
+ for (String userId : userIds) {
|
|
|
|
+ String[] split = userId.split(",");
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ if (StringUtils.isNumeric( s)) {
|
|
|
|
+ List<SignPfxFile> userPfxList = collect.get(s);
|
|
|
|
+ if (userPfxList == null || userPfxList.isEmpty()) {
|
|
|
|
+ notCertificateUserInfoSet.add(s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!notCertificateUserInfoSet.isEmpty()) {
|
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
|
+ for (String userId : notCertificateUserInfoSet) {
|
|
|
|
+ User user = userMap.get(Long.parseLong(userId));
|
|
|
|
+ if (user != null && user.getName() != null && !user.getName().isEmpty()) {
|
|
|
|
+ names.add(user.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ throw new ServiceException("未获取到用户【" + StringUtils.join(names, "、") + "】的签字证书信息");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 东方中讯,校验用户 accCode
|
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
|
+ for (User user : users) {
|
|
|
|
+ if (user.getAccCode() == null || user.getAccCode().isEmpty() || user.getAccCode().equals("null")) {
|
|
|
|
+ names.add(user.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!names.isEmpty()) {
|
|
|
|
+ throw new ServiceException("未获取到用户【" + StringUtils.join(names, "、") + "】的签字证书信息");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Long fixedFlowId = SnowFlakeUtil.getId();
|
|
|
|
+ FixedFlow fixedFlow = new FixedFlow();
|
|
|
|
+ fixedFlow.setId(fixedFlowId);
|
|
|
|
+ fixedFlow.setFixedFlowName(dto.getFixedName());
|
|
|
|
+ fixedFlow.setProjectId(dto.getProjectId());
|
|
|
|
+ fixedFlow.setContractId(dto.getContractId());
|
|
|
|
+ fixedFlow.setStatus(1);
|
|
|
|
+ fixedFlow.setIsMeter(0);
|
|
|
|
+ fixedFlow.setSort(0);
|
|
|
|
+ fixedFlow.setCreateTime(new Date());
|
|
|
|
+ boolean save = fixedFlowService.save(fixedFlow);
|
|
|
|
+ if (save) {
|
|
|
|
+ int userSort = 0;
|
|
|
|
+ for (int i = 0; i < dto.getFixedBranchList().size(); i++) {
|
|
|
|
+ SaveFixedFlowDTO.FixedBranch fixedBranch = dto.getFixedBranchList().get(i);
|
|
|
|
+ if(i>0){
|
|
|
|
+ userSort += Func.toLongList(dto.getFixedBranchList().get(i-1).getUserIds()).size();
|
|
|
|
+ }
|
|
|
|
+ List<FixedFlowLink> saveList = new ArrayList<>();
|
|
|
|
+ if (fixedBranch.getUserIds() == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ for (String userId : fixedBranch.getUserIds().split(",")) {
|
|
|
|
+ User user = userMap.get(Long.parseLong(userId));
|
|
|
|
+ if (user == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ FixedFlowLink fixedFlowLink = new FixedFlowLink();
|
|
|
|
+ fixedFlowLink.setFixedFlowId(fixedFlowId);
|
|
|
|
+ fixedFlowLink.setFixedFlowLink(fixedBranch.getName() == null ? dto.getFixedName() : fixedBranch.getName());
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkType(projectInfo.getApprovalType());
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkUser(Long.parseLong(userId));
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkUserName(user.getRealName());
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkSort(i+1);
|
|
|
|
+ fixedFlowLink.setProjectId(dto.getProjectId());
|
|
|
|
+ fixedFlowLink.setContractId(dto.getContractId());
|
|
|
|
+ fixedFlowLink.setFixedFlowBranchSort(userSort+=1);
|
|
|
|
+ fixedFlowLink.setFlowTaskType(fixedBranch.getFlowTaskType());
|
|
|
|
+ saveList.add(fixedFlowLink);
|
|
|
|
+ }
|
|
|
|
+ if (!saveList.isEmpty()) {
|
|
|
|
+ fixedFlowLinkService.saveBatch(saveList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.fail("操作失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 自定义分页
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getFixedFlowPage")
|
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
|
+ @ApiOperation(value = "分页", notes = "传入fixedFlow")
|
|
|
|
+ public R<Page<FixedFlowVO>> getFixedFlowPage(PageFixedFlowDTO dto) {
|
|
|
|
+ if (dto.getCurrent() == null || dto.getSize() == null) {
|
|
|
|
+ return R.data(-1, null, "缺少size或current参数");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<FixedFlow> page = new Page<>(dto.getCurrent(), dto.getSize());
|
|
|
|
+ IPage<FixedFlow> fixedFlowsPage = fixedFlowService.getBaseMapper().selectPage(page,
|
|
|
|
+ Wrappers.<FixedFlow>lambdaQuery()
|
|
|
|
+ .eq(FixedFlow::getContractId, dto.getContractId())
|
|
|
|
+ .eq(FixedFlow::getProjectId, dto.getProjectId()).last(" and (is_meter is null or is_meter != 1) order by sort, fixed_flow_name, create_time desc"));
|
|
|
|
+ List<FixedFlow> fixedFlows = fixedFlowsPage.getRecords();
|
|
|
|
+ List<Long> collect = fixedFlows.stream().map(FixedFlow::getId).collect(Collectors.toList());
|
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
|
+ List<FixedFlowLink> fixedFlowLinkList = fixedFlowLinkService.getBaseMapper().selectList(
|
|
|
|
+ Wrappers.<FixedFlowLink>lambdaQuery()
|
|
|
|
+ .in(FixedFlowLink::getFixedFlowId, collect)
|
|
|
|
+ .orderByAsc(FixedFlowLink::getFixedFlowBranchSort)
|
|
|
|
+ .orderByAsc(FixedFlowLink::getFixedFlowLinkSort)
|
|
|
|
+ );
|
|
|
|
+ Map<Long, List<FixedFlowLink>> group = fixedFlowLinkList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId,
|
|
|
|
+ LinkedHashMap::new,
|
|
|
|
+ Collectors.toList()));
|
|
|
|
+ //获取当前任务中所有的流程,并且去重,如果该流程已经存在,那么则不允许编辑和删除
|
|
|
|
+ List<Long> ids = taskServiceImpl.list(new LambdaQueryWrapper<Task>()
|
|
|
|
+ .select(Task::getFixedFlowId)
|
|
|
|
+ .eq(Task::getContractId, dto.getContractId())
|
|
|
|
+ .isNotNull(Task::getFixedFlowId)
|
|
|
|
+ .groupBy(Task::getFixedFlowId)).stream().map(Task::getFixedFlowId).collect(Collectors.toList());
|
|
|
|
+ List<FixedFlowVO> fixedFlowVOList = new ArrayList<>();
|
|
|
|
+ for (FixedFlow fixedFlow : fixedFlows) {
|
|
|
|
+ List<FixedFlowLink> one = group.getOrDefault(fixedFlow.getId(), null);
|
|
|
|
+ FixedFlowVO vo = new FixedFlowVO();
|
|
|
|
+ BeanUtil.copyProperties(fixedFlow, vo);
|
|
|
|
+ fixedFlowVOList.add(vo);
|
|
|
|
+ vo.setFixedFlowLinkList( one);
|
|
|
|
+ if (one != null) {
|
|
|
|
+ /** 上面方法会去除同名流程*/
|
|
|
|
+ for (FixedFlowLink link : one) {
|
|
|
|
+ if (link.getFixedFlowBranchSort() == null ) {
|
|
|
|
+ link.setFixedFlowBranchSort(link.getFixedFlowLinkSort());
|
|
|
|
+ link.setFixedFlowLinkSort(1);
|
|
|
|
+ }
|
|
|
|
+ if (link.getFixedFlowLink() == null || link.getFixedFlowLink().isEmpty()) {
|
|
|
|
+ link.setFixedFlowLink(fixedFlow.getFixedFlowName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<String> names = one.stream().filter(l->l.getFixedFlowLinkSort() != null).collect(Collectors.groupingBy(
|
|
|
|
+ FixedFlowLink::getFixedFlowLinkSort,
|
|
|
|
+ Collectors.collectingAndThen(
|
|
|
|
+ Collectors.toList(),
|
|
|
|
+ l -> l.isEmpty() ? null : l.get(0)
|
|
|
|
+ )
|
|
|
|
+ )).values().stream().map(FixedFlowLink::getFixedFlowLink).collect(Collectors.toList());
|
|
|
|
+ vo.setDeletedIs(!ids.contains(fixedFlow.getId()));
|
|
|
|
+ vo.setLinkUserJoinString(StringUtils.join(names, ","));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Page<FixedFlowVO> resultMap = new Page<>();
|
|
|
|
+ resultMap.setCurrent(fixedFlowsPage.getCurrent());
|
|
|
|
+ resultMap.setSize(fixedFlowsPage.getSize());
|
|
|
|
+ resultMap.setTotal(fixedFlowsPage.getTotal());
|
|
|
|
+ resultMap.setRecords(fixedFlowVOList);
|
|
|
|
+// Map<Boolean, List<FixedFlowVO>> groupMap = fixedFlowVOList.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName() != null && record.getFixedFlowName().contains("_") && record.getSort() == null));
|
|
|
|
+// List<FixedFlowVO> copyFixedFlowVOS = groupMap.get(true);
|
|
|
|
+// List<FixedFlowVO> fixedFlowVOS = groupMap.get(false);
|
|
|
|
+// if (copyFixedFlowVOS == null || copyFixedFlowVOS.isEmpty() || fixedFlowVOS == null || fixedFlowVOS.isEmpty()) {
|
|
|
|
+// return R.data(resultMap);
|
|
|
|
+// }
|
|
|
|
+// Map<String, List<FixedFlowVO>> nameMap = copyFixedFlowVOS.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName().split("_")[0]));
|
|
|
|
+// List<FixedFlowVO> newData = new ArrayList<>(fixedFlowVOList);
|
|
|
|
+// for (FixedFlowVO flowVO : fixedFlowVOS) {
|
|
|
|
+//// newData.add(flowVO);
|
|
|
|
+// List<FixedFlowVO> flowVOS = nameMap.get(flowVO.getFixedFlowName());
|
|
|
|
+// if (flowVOS != null && !flowVOS.isEmpty()) {
|
|
|
|
+// flowVOS.sort(Comparator.comparing(FixedFlow::getFixedFlowName));
|
|
|
|
+// newData.addAll(flowVOS);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// resultMap.setRecords(newData);
|
|
|
|
+ return R.data(resultMap);
|
|
|
|
+ }
|
|
|
|
+ return R.fail("暂无数据");
|
|
|
|
+ }
|
|
|
|
+ @GetMapping("/getFixedFlow")
|
|
|
|
+ @ApiOperationSupport(order = 25)
|
|
|
|
+ @ApiOperation(value = "获取预设流程信息", notes = "传入预设流程id")
|
|
|
|
+ public R<org.springblade.meter.vo.FixedFlowVO> getFixedFlow(@RequestParam String id) {
|
|
|
|
+ FixedFlow fixedFlow = jdbcTemplate.query("SELECT * FROM u_fixed_flow WHERE is_deleted = 0 AND id = ?", new Object[]{id}, new BeanPropertyRowMapper<>(FixedFlow.class)).stream().findAny().orElse(null);
|
|
|
|
+ if (fixedFlow != null) {
|
|
|
|
+ ProjectInfo projectInfo = projectClient.getById(fixedFlow.getProjectId() + "");
|
|
|
|
+ List<FixedFlowLink> fixedFlowLinkList = jdbcTemplate.query("SELECT * FROM u_fixed_flow_link WHERE is_deleted = 0 AND fixed_flow_id = ? ORDER BY fixed_flow_branch_sort,fixed_flow_link_sort", new Object[]{fixedFlow.getId()}, new BeanPropertyRowMapper<>(FixedFlowLink.class));
|
|
|
|
+ if (!fixedFlowLinkList.isEmpty()) {
|
|
|
|
+ for (FixedFlowLink link : fixedFlowLinkList) {
|
|
|
|
+ if (link.getFixedFlowBranchSort() == null ) {
|
|
|
|
+ link.setFixedFlowBranchSort(link.getFixedFlowLinkSort());
|
|
|
|
+ link.setFixedFlowLinkSort(1);
|
|
|
|
+ }
|
|
|
|
+ if (link.getFixedFlowLink() == null || link.getFixedFlowLink().isEmpty()) {
|
|
|
|
+ link.setFixedFlowLink(fixedFlow.getFixedFlowName());
|
|
|
|
+ }
|
|
|
|
+ if (link.getFixedFlowLinkType() == null) {
|
|
|
|
+ link.setFixedFlowLinkType(projectInfo == null ? (link.getFlowTaskType() == null ? 2 : link.getFlowTaskType()) : projectInfo.getApprovalType());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Map<String, List<FixedFlowLink>> group = fixedFlowLinkList.stream().collect(Collectors.groupingBy(
|
|
|
|
+ obj -> obj.getFixedFlowLink() + "@@@" + obj.getFixedFlowLinkType() + "@@@"+obj.getFlowTaskType() + "@@@"+obj.getFixedFlowLinkSort(),
|
|
|
|
+ LinkedHashMap::new,
|
|
|
|
+ Collectors.toList())
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ org.springblade.meter.vo.FixedFlowVO vo = new org.springblade.meter.vo.FixedFlowVO();
|
|
|
|
+ vo.setFixedFlowId(fixedFlow.getId());
|
|
|
|
+ vo.setFixedFlowName(fixedFlow.getFixedFlowName());
|
|
|
|
+
|
|
|
|
+ List<org.springblade.meter.vo.FixedFlowVO.FixedBranchVO> fixedBranchVOList = new LinkedList<>();
|
|
|
|
+ for (Map.Entry<String, List<FixedFlowLink>> listEntry : group.entrySet()) {
|
|
|
|
+
|
|
|
|
+ String nameAndType = listEntry.getKey();
|
|
|
|
+ String name = nameAndType.split("@@@")[0];
|
|
|
|
+ String type = nameAndType.split("@@@")[1];
|
|
|
|
+ String flowTaskType = nameAndType.split("@@@")[2];
|
|
|
|
+
|
|
|
|
+ org.springblade.meter.vo.FixedFlowVO.FixedBranchVO fixedBranchVO = new org.springblade.meter.vo.FixedFlowVO.FixedBranchVO();
|
|
|
|
+ fixedBranchVO.setName(name);
|
|
|
|
+ fixedBranchVO.setType(Integer.parseInt(type));
|
|
|
|
+ fixedBranchVO.setFlowTaskType(Integer.valueOf(flowTaskType));
|
|
|
|
+
|
|
|
|
+ List<org.springblade.meter.vo.FixedFlowVO.FixedBranchVO.User> userListResult = new LinkedList<>();
|
|
|
|
+ List<FixedFlowLink> userList = listEntry.getValue();
|
|
|
|
+ for (FixedFlowLink fixedFlowLink : userList) {
|
|
|
|
+ org.springblade.meter.vo.FixedFlowVO.FixedBranchVO.User user = new org.springblade.meter.vo.FixedFlowVO.FixedBranchVO.User();
|
|
|
|
+ user.setUserId(fixedFlowLink.getFixedFlowLinkUser());
|
|
|
|
+ user.setUserName(fixedFlowLink.getFixedFlowLinkUserName());
|
|
|
|
+ user.setSort(ObjectUtil.isNotEmpty(fixedFlowLink.getFixedFlowLinkSort()) ? fixedFlowLink.getFixedFlowLinkSort() : null);
|
|
|
|
+ userListResult.add(user);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fixedBranchVO.setUserList(userListResult);
|
|
|
|
+ fixedBranchVO.setUserIds(userListResult.stream().map(l->l.getUserId()+"").collect(Collectors.joining(",")));
|
|
|
|
+ fixedBranchVOList.add(fixedBranchVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ vo.setFixedBranchVOList(fixedBranchVOList);
|
|
|
|
+ return R.data(vo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.data(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/updateFixedFlow")
|
|
|
|
+ @ApiOperationSupport(order = 26)
|
|
|
|
+ @ApiOperation(value = "修改预设流程", notes = "传入dto")
|
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED)
|
|
|
|
+ public R<Object> updateFixedFlow(@RequestBody UpdateFixedFlowDTO dto) {
|
|
|
|
+ if (ObjectUtil.isEmpty(dto.getFixedBranchList()) || dto.getFixedBranchList().isEmpty()) {
|
|
|
|
+ return R.fail("请选择任务流程人员");
|
|
|
|
+ }
|
|
|
|
+ //校验是否被使用过
|
|
|
|
+ List<Task> tasks = jdbcTemplate.query("SELECT * FROM u_task WHERE contract_id = ? and is_deleted = 0 and status != 3 AND fixed_flow_id = ? ", new Object[]{dto.getContractId(), dto.getFixedFlowId()}, new BeanPropertyRowMapper<>(Task.class));
|
|
|
|
+ if (!tasks.isEmpty()) {
|
|
|
|
+ return R.fail("当前流程已经使用,不能修改");
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getFixedName())) {
|
|
|
|
+ ProjectInfo projectInfo = projectClient.getById(dto.getProjectId() + "");
|
|
|
|
+ if (projectInfo == null) {
|
|
|
|
+ return R.fail("暂未找到项目信息,请稍后再试");
|
|
|
|
+ }
|
|
|
|
+ /*检查签字证书信息*/
|
|
|
|
+ List<String> userIds = dto.getFixedBranchList().stream().map(UpdateFixedFlowDTO.FixedBranch::getUserIds).collect(Collectors.toList());
|
|
|
|
+ List<User> users = jdbcTemplate.query("select id,name,acc_code,real_name from blade_user where is_deleted = 0 and id in (" + StringUtils.join(userIds, ",") + ")", new BeanPropertyRowMapper<>(User.class));
|
|
|
|
+ Map<Long, User> userMap = users.stream().collect(Collectors.toMap(User::getId, item -> item));
|
|
|
|
+ if (ObjectUtil.isEmpty( users)) {
|
|
|
|
+ return R.fail("请选择任务流程人员");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.equals(projectInfo.getRemarkType(), 1)) {
|
|
|
|
+ //安心签,校验证书 检查签字证书信息
|
|
|
|
+ Set<String> notCertificateUserInfoSet = new HashSet<>();
|
|
|
|
+ //获取用户的证书信息
|
|
|
|
+ String ids = users.stream().map(user -> user.getId() + "").collect(Collectors.joining(","));
|
|
|
|
+ List<SignPfxFile> signPfxFiles = jdbcTemplate.query("select * from m_sign_pfx_file where is_register = 1 and certificate_user_id in ( " + ids + " )", new BeanPropertyRowMapper<>(SignPfxFile.class));
|
|
|
|
+ Map<String, List<SignPfxFile>> collect = signPfxFiles.stream().collect(Collectors.groupingBy(signPfxFile -> signPfxFile.getCertificateUserId() + ""));
|
|
|
|
+ for (User user : users) {
|
|
|
|
+ List<SignPfxFile> userPfxList = collect.get(user.getId() + "");
|
|
|
|
+ if (userPfxList == null || userPfxList.isEmpty()) {
|
|
|
|
+ notCertificateUserInfoSet.add(user.getId() + "");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!notCertificateUserInfoSet.isEmpty()) {
|
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
|
+ for (String userId : notCertificateUserInfoSet) {
|
|
|
|
+ User user = userMap.get(Long.parseLong(userId));
|
|
|
|
+ if (user != null && user.getName() != null && !user.getName().isEmpty()) {
|
|
|
|
+ names.add(user.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ throw new ServiceException("未获取到用户【" + StringUtils.join(names, "、") + "】的签字证书信息");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 东方中讯,校验用户 accCode
|
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
|
+ for (User user : users) {
|
|
|
|
+ if (user.getAccCode() == null || user.getAccCode().isEmpty() || user.getAccCode().equals("null")) {
|
|
|
|
+ names.add(user.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!names.isEmpty()) {
|
|
|
|
+ throw new ServiceException("未获取到用户【" + StringUtils.join(names, "、") + "】的签字证书信息");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ jdbcTemplate.update("DELETE FROM u_fixed_flow_link WHERE fixed_flow_id = ? ", dto.getFixedFlowId());
|
|
|
|
+ int userSort = 0;
|
|
|
|
+ for (int i = 0; i < dto.getFixedBranchList().size(); i++) {
|
|
|
|
+ UpdateFixedFlowDTO.FixedBranch fixedBranch = dto.getFixedBranchList().get(i);
|
|
|
|
+ if (i > 0) {
|
|
|
|
+ userSort += Func.toLongList(dto.getFixedBranchList().get(i - 1).getUserIds()).size();
|
|
|
|
+ }
|
|
|
|
+ if (fixedBranch.getUserIds() == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ List<FixedFlowLink> saveList = new ArrayList<>();
|
|
|
|
+ for (String userId : fixedBranch.getUserIds().split(",")) {
|
|
|
|
+ FixedFlowLink fixedFlowLink = new FixedFlowLink();
|
|
|
|
+ fixedFlowLink.setFixedFlowId(dto.getFixedFlowId());
|
|
|
|
+ fixedFlowLink.setFixedFlowLink(fixedBranch.getName());
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkType(fixedBranch.getType());
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkUser(Long.parseLong(userId));
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkUserName(userMap.get(Long.parseLong(userId)).getRealName());
|
|
|
|
+ fixedFlowLink.setFixedFlowLinkSort(i + 1);
|
|
|
|
+ fixedFlowLink.setProjectId(dto.getProjectId());
|
|
|
|
+ fixedFlowLink.setContractId(dto.getContractId());
|
|
|
|
+ fixedFlowLink.setFixedFlowBranchSort(userSort+=1);
|
|
|
|
+ fixedFlowLink.setFlowTaskType(fixedBranch.getFlowTaskType());
|
|
|
|
+ saveList.add(fixedFlowLink);
|
|
|
|
+ }
|
|
|
|
+ if (!saveList.isEmpty()) {
|
|
|
|
+ fixedFlowLinkService.saveBatch(saveList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fixedFlowService.update(Wrappers.<FixedFlow>lambdaUpdate().set(FixedFlow::getFixedFlowName, dto.getFixedName()).eq(FixedFlow::getId, dto.getFixedFlowId()));
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }
|
|
|
|
+ return R.fail("操作失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/deleteFixedFlow")
|
|
|
|
+ @ApiOperationSupport(order = 27)
|
|
|
|
+ @ApiOperation(value = "刪除预设流程", notes = "传入预设流程id")
|
|
|
|
+ public R<Object> deleteFixedFlow(@RequestParam String id) {
|
|
|
|
+ List<Task> tasks = jdbcTemplate.query("SELECT * FROM u_task WHERE is_deleted = 0 and status != 3 AND fixed_flow_id = ? ", new Object[]{id}, new BeanPropertyRowMapper<>(Task.class));
|
|
|
|
+ if (tasks.size() > 0) {
|
|
|
|
+ return R.fail("当前流程已经使用,不能删除");
|
|
|
|
+ }
|
|
|
|
+ jdbcTemplate.update("DELETE FROM u_fixed_flow WHERE id = ?", new Object[]{id});
|
|
|
|
+ jdbcTemplate.update("DELETE FROM u_fixed_flow_link WHERE fixed_flow_id = ?", new Object[]{id});
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|