|
@@ -16,17 +16,22 @@ import org.springblade.business.service.IDefaultProjectService;
|
|
|
import org.springblade.business.vo.UserVO;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.feign.*;
|
|
|
import org.springblade.manager.vo.ContractInfoVO;
|
|
|
import org.springblade.manager.vo.ProjectInfoVO;
|
|
|
import org.springblade.manager.vo.ProjectInfoWbsTypeVO;
|
|
|
+import org.springblade.system.entity.Role;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -44,6 +49,8 @@ import java.util.stream.Collectors;
|
|
|
@Api(tags = "客户端首页")
|
|
|
public class UserViewProjectContractController {
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
private final ProjectClient projectClient;
|
|
|
|
|
|
private final ContractClient contractClient;
|
|
@@ -129,6 +136,29 @@ public class UserViewProjectContractController {
|
|
|
//获取合同段ID
|
|
|
List<String> contractIds = userDownAll.stream().map(SaveUserInfoByProjectDTO::getContractId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
+ //获取当前用户角色信息(如果是监理,那么将不查看施工合同段的信息) roleId = 1537246384519335938L = 监理方下所有角色信息
|
|
|
+ String roleIds = SecureUtil.getUser().getRoleId();
|
|
|
+ List<Role> roleList = jdbcTemplate.query("select id from blade_role where parent_id = 1537246384519335938 and is_deleted = 0", new BeanPropertyRowMapper<>(Role.class));
|
|
|
+ List<String> roleIdsJL = roleList.stream().map(Role::getId).map(String::valueOf).collect(Collectors.toList());
|
|
|
+ String[] split = roleIds.split(",");
|
|
|
+ boolean var = true;
|
|
|
+ if (split.length == 1) {
|
|
|
+ //当前用户只有一个角色
|
|
|
+ if (!roleIdsJL.contains(roleIds)) {
|
|
|
+ //角色不属于监理
|
|
|
+ var = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //当前用户属于多个角色
|
|
|
+ for (String roleId : split) {
|
|
|
+ if (!roleIdsJL.contains(roleId)) {
|
|
|
+ //角色不属于监理
|
|
|
+ var = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//获取项目列表
|
|
|
List<ProjectInfo> projectInfos = this.projectClient.queryProjectList(projectIds);
|
|
|
if (projectInfos != null && projectInfos.size() != 0) {
|
|
@@ -136,6 +166,11 @@ public class UserViewProjectContractController {
|
|
|
//获取当前所有合同段
|
|
|
List<ContractInfo> contractInfos = this.contractClient.queryContractListByIds(longProjectIds);
|
|
|
|
|
|
+ //如果是监理,那么移除施工合同段信息
|
|
|
+ if (var) {
|
|
|
+ contractInfos.removeIf(next -> next.getContractType() == 1);
|
|
|
+ }
|
|
|
+
|
|
|
//转换VO
|
|
|
List<ProjectInfoVO> projectInfoVOS = JSONArray.parseArray(JSONObject.toJSONString(projectInfos), ProjectInfoVO.class);
|
|
|
if (contractInfos != null && contractInfos.size() != 0) {
|
|
@@ -173,6 +208,10 @@ public class UserViewProjectContractController {
|
|
|
//排序项目
|
|
|
projectInfoVOS.sort(Comparator.comparingInt(ProjectInfoVO::getIsDefault).reversed());
|
|
|
}
|
|
|
+
|
|
|
+ //剔除没有合同段的项目
|
|
|
+ projectInfoVOS.removeIf(next -> next.getContractInfoList().size() == 0);
|
|
|
+
|
|
|
return R.data(projectInfoVOS);
|
|
|
}
|
|
|
return R.data(-1, null, "数据查询失败");
|