|
@@ -16,17 +16,23 @@ import org.springblade.business.service.IFixedFlowService;
|
|
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.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.SaveFixedFlowDTO;
|
|
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 +40,12 @@ 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.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 +73,14 @@ public class FixedFlowController extends BladeController {
|
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
+ private final ProjectClient projectClient;
|
|
/**
|
|
/**
|
|
* 获取系统所有角色划分
|
|
* 获取系统所有角色划分
|
|
*/
|
|
*/
|
|
@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 +101,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 +144,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 +192,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("_")));
|
|
|
|
+ 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 +321,151 @@ 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<Boolean> 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<>();
|
|
|
|
+ fixedFlowList.forEach(fixedFlow -> {
|
|
|
|
+ //生成主表主键
|
|
|
|
+ long fixedFlowId = SnowFlakeUtil.getId();
|
|
|
|
+ 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) {
|
|
|
|
+ number = this.fixedFlowService.count(Wrappers.<FixedFlow>lambdaQuery().likeRight(FixedFlow::getFixedFlowName, fixedFlow.getFixedFlowName()).eq(FixedFlow::getContractId, fixedFlow.getContractId()).ne(FixedFlow::getId, fixedFlow.getId()));
|
|
|
|
+ }
|
|
|
|
+ nameCountMap.put(fixedFlow.getFixedFlowName(), number + 1);
|
|
|
|
+ fixedFlow.setId(fixedFlowId);
|
|
|
|
+ fixedFlow.setFixedFlowName(fixedFlow.getFixedFlowName() + "_" + (number + 1));
|
|
|
|
+ fixedFlow.setCreateTime(new Date());
|
|
|
|
+ fixedFlow.setUpdateTime(new Date());
|
|
|
|
+ fixedFlow.setCreateUser(AuthUtil.getUserId());
|
|
|
|
+ });
|
|
|
|
+ boolean flow = this.fixedFlowService.saveBatch(fixedFlowList);
|
|
|
|
+ if (flow && !newFixedFolwLinkList.isEmpty()) {
|
|
|
|
+ flow = this.fixedFlowLinkService.saveBatch(newFixedFolwLinkList);
|
|
|
|
+ }
|
|
|
|
+ return R.data(flow);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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) {
|
|
|
|
+ List<SignPfxFile> userPfxList = collect.get(userId);
|
|
|
|
+ if (userPfxList == null || userPfxList.isEmpty()) {
|
|
|
|
+ notCertificateUserInfoSet.add(userId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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.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();
|
|
|
|
+ }
|
|
|
|
+ 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(dto.getFixedName());
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.fail("操作失败");
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|