|
@@ -16,6 +16,8 @@
|
|
|
*/
|
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import io.swagger.annotations.*;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
@@ -26,20 +28,26 @@ import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
+import org.springblade.manager.entity.ContractInfo;
|
|
|
import org.springblade.manager.entity.ProjectInfo;
|
|
|
+import org.springblade.manager.service.IContractInfoService;
|
|
|
import org.springblade.manager.service.IProjectInfoService;
|
|
|
-import org.springblade.manager.vo.SingPfxManagementVO;
|
|
|
+import org.springblade.manager.service.SaveUserInfoByProjectService;
|
|
|
+import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.vo.RoleVO;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springblade.manager.entity.SignPfxFile;
|
|
|
-import org.springblade.manager.vo.SignPfxFileVO;
|
|
|
import org.springblade.manager.service.ISignPfxFileService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 个人/企业证书信息表 控制器
|
|
@@ -57,16 +65,96 @@ public class SignPfxFileController extends BladeController {
|
|
|
|
|
|
private final IProjectInfoService projectInfoService;
|
|
|
|
|
|
+ private final IContractInfoService contractInfoService;
|
|
|
+
|
|
|
+ private final SaveUserInfoByProjectService saveUserInfoByProjectService;
|
|
|
+
|
|
|
private final ISysClient sysClient;
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取当前项目及其所有合同段
|
|
|
+ * @return 项目及合同段列表
|
|
|
+ */
|
|
|
+ @GetMapping("/queryProjectAndContract")
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
+ @ApiOperation(value = "获取当前项目及其所有合同段")
|
|
|
+ public R<List<ProjectInfoVO>> queryProjectAndContract(){
|
|
|
+ List<ProjectInfoVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取项目列表
|
|
|
+ List<ProjectInfo> projectResult = this.projectInfoService.list(Wrappers.<ProjectInfo>lambdaQuery().eq(ProjectInfo::getIsDeleted, 0));
|
|
|
+ if(projectResult != null && projectResult.size() > 0){
|
|
|
+ String projectIds = String.join(",", JSONArray.parseArray(JSONObject.toJSONString(projectResult.stream().map(ProjectInfo::getId).distinct().collect(Collectors.toList())), String.class));
|
|
|
+ //获取合同段
|
|
|
+ List<ContractInfo> contractInfos = this.contractInfoService.findContractInProject(projectIds);
|
|
|
+ if(contractInfos != null && contractInfos.size() > 0){
|
|
|
+ //转换实体
|
|
|
+ result = JSONArray.parseArray(JSONObject.toJSONString(projectResult), ProjectInfoVO.class);
|
|
|
+ List<ContractInfoVO> contractInfoVOS = JSONArray.parseArray(JSONObject.toJSONString(contractInfos), ContractInfoVO.class);
|
|
|
+ //设置合同段信息
|
|
|
+ result.forEach(project -> {
|
|
|
+ project.setName(project.getProjectName());
|
|
|
+ //获取合同段
|
|
|
+ Iterator<ContractInfoVO> iterator = contractInfoVOS.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ ContractInfoVO next = iterator.next();
|
|
|
+ next.setName(next.getContractName());
|
|
|
+ if(project.getId().toString().equals(next.getPId())){
|
|
|
+ project.getContractInfoList().add(next);
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(result);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取系统所有角色划分
|
|
|
*/
|
|
|
@GetMapping("/queryAllRoleList")
|
|
|
@ApiOperationSupport(order = 9)
|
|
|
@ApiOperation(value = "获取系统所有角色划分")
|
|
|
- public R<List<RoleVO>> queryAllRoleList(){
|
|
|
- return this.sysClient.search(null, null);
|
|
|
+ public R<List<RoleSignPfxUserVO>> queryAllRoleList(@RequestParam String contractId){
|
|
|
+ //获取当前系统配置的角色划分
|
|
|
+ List<RoleVO> roleVOS = this.sysClient.search().getData();
|
|
|
+ //获取项目人员
|
|
|
+ List<SaveUserInfoByProjectDTO> contractUserList = this.saveUserInfoByProjectService.list(Wrappers.<SaveUserInfoByProjectDTO>lambdaQuery().eq(SaveUserInfoByProjectDTO::getContractId, contractId).eq(SaveUserInfoByProjectDTO::getIsDeleted, 0));
|
|
|
+
|
|
|
+ //返回结果
|
|
|
+ List<RoleSignPfxUserVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ //循环角色,对项目人员进行分组
|
|
|
+ for(RoleVO vo : roleVOS){
|
|
|
+ //设置实体
|
|
|
+ RoleSignPfxUserVO pfxUserVo = new RoleSignPfxUserVO();
|
|
|
+ pfxUserVo.setRoleId(vo.getId());
|
|
|
+ pfxUserVo.setRoleName(vo.getRoleName());
|
|
|
+
|
|
|
+ //循环项目人员,获取个人证书,如果没有个人证书则删除
|
|
|
+ Iterator<SaveUserInfoByProjectDTO> iterator = contractUserList.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ SaveUserInfoByProjectDTO next = iterator.next();
|
|
|
+
|
|
|
+ if(next.getRoleId().equals(vo.getId().toString())){
|
|
|
+ //角色相符
|
|
|
+ SignPfxFile userSignPfx = this.signPfxFileService.getOne(Wrappers.<SignPfxFile>lambdaQuery().eq(SignPfxFile::getCertificateUserId, next.getUserId()));
|
|
|
+ if(userSignPfx == null){
|
|
|
+ iterator.remove();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //存在证书则设置进结果对象的证书集合中
|
|
|
+ pfxUserVo.getSignPfxFileList().add(userSignPfx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置结果
|
|
|
+ result.add(pfxUserVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(result);
|
|
|
}
|
|
|
|
|
|
/**
|