|
@@ -299,6 +299,7 @@ public class MaterialProgressController extends BladeController {
|
|
|
if (countList.size() > 0) {
|
|
|
//设置参数
|
|
|
this.setTaskParameter(reVO, countList, classifyType);
|
|
|
+ filtetDataByRole(contract, reVO,2);
|
|
|
return R.data(reVO);
|
|
|
}
|
|
|
}
|
|
@@ -307,6 +308,7 @@ public class MaterialProgressController extends BladeController {
|
|
|
List<WbsTreeContract> submitNodeList = this.wbsTreeContractClient.queryContractSubmitWbsTreeByContractId(contractId);
|
|
|
if (submitNodeList != null && submitNodeList.size() > 0) {
|
|
|
this.setTaskParameter(reVO, submitNodeList, classifyType);
|
|
|
+ filtetDataByRole(contract, reVO,2);
|
|
|
return R.data(reVO);
|
|
|
}
|
|
|
}
|
|
@@ -314,50 +316,95 @@ public class MaterialProgressController extends BladeController {
|
|
|
return R.data(200, null, "未找到数据");
|
|
|
}
|
|
|
|
|
|
- private void filtetDataByRole(String contractId, ContractInfo contract, MaterialProgressVO reVO) {
|
|
|
+ private void filtetDataByRole(ContractInfo contract, MaterialProgressVO reVO,int type) {
|
|
|
//获取该用户的该合同段角色
|
|
|
Long userId = AuthUtil.getUserId();
|
|
|
String projectId = contract.getPId();
|
|
|
- String sql1 = "select role_id from m_project_assignment_user where user_id = " + userId + " and project_id = " + projectId + " and contract_id=" + contractId;
|
|
|
- SaveUserInfoByProjectDTO saveUserInfoByProjectDTO = jdbcTemplate.queryForObject(sql1, new BeanPropertyRowMapper<>(SaveUserInfoByProjectDTO.class));
|
|
|
- String userRoleId = saveUserInfoByProjectDTO.getRoleId();
|
|
|
+ SaveUserInfoByProjectDTO saveUserInfoByProjectDTO = jdbcTemplate.queryForObject("select role_id from m_project_assignment_user where user_id = " + userId + " and project_id = " + projectId + " and contract_id=" + contract.getId(), new BeanPropertyRowMapper<>(SaveUserInfoByProjectDTO.class));
|
|
|
//获取该用户的所有菜单权限
|
|
|
- String sql2 = "select * from blade_role_menu where role_id = " + userRoleId;
|
|
|
- List<RoleMenu> roleMenuList = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(RoleMenu.class));
|
|
|
+ List<RoleMenu> roleMenuList = jdbcTemplate.query("select * from blade_role_menu where role_id = " + saveUserInfoByProjectDTO.getRoleId(), new BeanPropertyRowMapper<>(RoleMenu.class));
|
|
|
Map<Long, String> havaMenusMap = roleMenuList.stream().filter(roleMenu -> roleMenu != null && roleMenu.getMenuId() != null && roleMenu.getStatus() != null)
|
|
|
- .collect(Collectors.toMap(roleMenu -> roleMenu.getMenuId(), roleMenu -> roleMenu.getStatus()));
|
|
|
- //获取系统所有表单权限
|
|
|
- String sql3 = "select id,parent_id,code,name from blade_menu";
|
|
|
- List<Menu> menuList = jdbcTemplate.query(sql3, new BeanPropertyRowMapper<>(Menu.class));
|
|
|
- Map<Long, Menu> allMenuMap = menuList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ roleMenu -> roleMenu.getMenuId(),
|
|
|
+ roleMenu -> roleMenu.getStatus(),
|
|
|
+ (existingValue, newValue) -> existingValue
|
|
|
+ ));
|
|
|
+ //获取系统所有表单权限 这里只有质检需要所以系统写死 如果后续其他地方需要相同的方法 sys_id根据前端请求头种的参数动态配置
|
|
|
+ List<Menu> menuList = jdbcTemplate.query("select id,parent_id,code,name from blade_menu where is_deleted = 0 and sys_id=1528578177090609154", new BeanPropertyRowMapper<>(Menu.class));
|
|
|
+ Map<String, Menu> allMenuMap = menuList.stream()
|
|
|
.filter(roleMenu -> roleMenu != null && roleMenu.getId() != null) // 过滤掉 null 值
|
|
|
.collect(Collectors.toMap(
|
|
|
- Menu::getId,
|
|
|
- Menu -> Menu// 处理重复键,保留第一个值
|
|
|
+ Menu::getCode,
|
|
|
+ Menu -> Menu,
|
|
|
+ (existingValue, newValue) -> existingValue
|
|
|
));
|
|
|
|
|
|
//根据合同段角色id过滤出当前角色能看到的数据
|
|
|
- List<MaterialProgressVO.ProcessMaterial> processMaterialList = reVO.getProcessMaterialList();
|
|
|
- for (int i = 0; i < processMaterialList.size(); i++) {
|
|
|
- String title = processMaterialList.get(i).getTitle();
|
|
|
- String code = "";
|
|
|
- switch (title){
|
|
|
- case "开工报告":code = "schedule-data-chart-1";break;
|
|
|
- case "工序资料":code = "schedule-data-chart-2";break;
|
|
|
- case "评定资料":code = "schedule-data-chart-3";break;
|
|
|
- case "中间交工":code = "schedule-data-chart-4";break;
|
|
|
+ if(type == 1){//控制不同的页面数据 1.顶部环形图 2.左下柱状图
|
|
|
+ filterProcessMaterials(reVO.getProcessMaterialList(), allMenuMap, havaMenusMap);
|
|
|
+ }else {
|
|
|
+ filterProcessMaterialStatuses(reVO.getProcessMaterialStatusList(), allMenuMap, havaMenusMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void filterProcessMaterials(List<MaterialProgressVO.ProcessMaterial> processMaterialList, Map<String, Menu> allMenuMap, Map<Long, String> haveMenusMap) {
|
|
|
+ Iterator<MaterialProgressVO.ProcessMaterial> iterator = processMaterialList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ MaterialProgressVO.ProcessMaterial processMaterial = iterator.next();
|
|
|
+ String title = processMaterial.getTitle();
|
|
|
+ String code = getCodeFromTitle(title);
|
|
|
+ Menu menu = allMenuMap.get(code);
|
|
|
+ boolean b = checkPermissions(menu, haveMenusMap);
|
|
|
+ if (!b) {
|
|
|
+ iterator.remove();
|
|
|
}
|
|
|
- //当前code的菜单
|
|
|
- String sql4 ="select id from blade_menu where code = " + "'"+code+"'";
|
|
|
- Menu menu= jdbcTemplate.queryForObject(sql4, new BeanPropertyRowMapper<>(Menu.class));
|
|
|
- boolean b = checkPermissions(menu, havaMenusMap, allMenuMap);
|
|
|
- if(!b){
|
|
|
- //删除数据
|
|
|
- processMaterialList.remove(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void filterProcessMaterialStatuses(List<MaterialProgressVO.ProcessMaterialStatus> processMaterialStatusList, Map<String, Menu> allMenuMap, Map<Long, String> haveMenusMap) {
|
|
|
+ Iterator<MaterialProgressVO.ProcessMaterialStatus> iterator = processMaterialStatusList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ MaterialProgressVO.ProcessMaterialStatus processMaterialStatus = iterator.next();
|
|
|
+ String title = processMaterialStatus.getTitle();
|
|
|
+ String code = getCodeFromTitle(title);
|
|
|
+ Menu menu = allMenuMap.get(code);
|
|
|
+ boolean b = checkPermissions(menu, haveMenusMap);
|
|
|
+ if (!b) {
|
|
|
+ iterator.remove();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private String getCodeFromTitle(String title) {
|
|
|
+ switch (title) {
|
|
|
+ case "开工报告":
|
|
|
+ return "schedule-data-chart-1";
|
|
|
+ case "工序资料":
|
|
|
+ return "schedule-data-chart-2";
|
|
|
+ case "评定资料":
|
|
|
+ return "schedule-data-chart-3";
|
|
|
+ case "中间交工":
|
|
|
+ return "schedule-data-chart-4";
|
|
|
+ default:
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private boolean checkPermissions(Menu menu ,Map<Long, String> havaMenusMap){
|
|
|
+ String status = havaMenusMap.get(menu.getId());
|
|
|
+ return ObjectUtil.isEmpty(status) ? false : true;
|
|
|
+ /*全选半选会精确到最小权限 不需要去寻找父权限
|
|
|
+ if(ObjectUtil.isEmpty(status)){
|
|
|
+ Long parentId = menu.getParentId();
|
|
|
+ if(ObjectUtil.isEmpty(parentId)){
|
|
|
+ return false;
|
|
|
+ }else {
|
|
|
+ Menu menu1 = allMenuMap.get(parentId);
|
|
|
+ return checkPermissions(menu1,havaMenusMap,allMenuMap);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return true;
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+
|
|
|
private void setTaskParameter(MaterialProgressVO reVO, List<WbsTreeContract> submitNodeList, String classifyType) {
|
|
|
classifyType = StringUtils.isEmpty(classifyType) ? "1" : classifyType;
|
|
|
|
|
@@ -445,7 +492,7 @@ public class MaterialProgressController extends BladeController {
|
|
|
//设置参数
|
|
|
this.setParameter(countList, reVO, classifyType);
|
|
|
}
|
|
|
- filtetDataByRole(contractId, contract, reVO);
|
|
|
+ filtetDataByRole(contract, reVO,1);
|
|
|
return R.data(reVO);
|
|
|
}
|
|
|
} else {
|
|
@@ -455,27 +502,13 @@ public class MaterialProgressController extends BladeController {
|
|
|
if (submitNodeList != null && submitNodeList.size() > 0) {
|
|
|
//设置参数
|
|
|
this.setParameter(submitNodeList, reVO, classifyType);
|
|
|
- filtetDataByRole(contractId, contract, reVO);
|
|
|
+ filtetDataByRole(contract, reVO,1);
|
|
|
return R.data(reVO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return R.data(200, null, "未找到数据");
|
|
|
}
|
|
|
- public static boolean checkPermissions(Menu menu ,Map<Long, String> havaMenusMap,Map<Long, Menu> allMenuMap){
|
|
|
- String status = havaMenusMap.get(menu.getId());
|
|
|
- if(ObjectUtil.isEmpty(status)){
|
|
|
- Long parentId = menu.getParentId();
|
|
|
- if(ObjectUtil.isEmpty(parentId)){
|
|
|
- return false;
|
|
|
- }else {
|
|
|
- Menu menu1 = allMenuMap.get(parentId);
|
|
|
- return checkPermissions(menu1,havaMenusMap,allMenuMap);
|
|
|
- }
|
|
|
- }else {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 设置参数
|