Commit a58f9b8f authored by caotao's avatar caotao

全景回溯权限接口调整。

parent bad05b52
...@@ -35,20 +35,21 @@ import static com.yeejoin.amos.boot.module.jxiop.biz.kafka.Constant.*; ...@@ -35,20 +35,21 @@ import static com.yeejoin.amos.boot.module.jxiop.biz.kafka.Constant.*;
@RequestMapping(value = "/kafkaAnalyse") @RequestMapping(value = "/kafkaAnalyse")
public class KafkaAnalyseController { public class KafkaAnalyseController {
public final DecimalFormat df = new DecimalFormat("0.0");
@Autowired @Autowired
FanConditionVariablesMessage fanConditionVariablesMessage; FanConditionVariablesMessage fanConditionVariablesMessage;
@Autowired @Autowired
RedisUtils redisUtils; RedisUtils redisUtils;
@Autowired @Autowired
IPermissionService permissionService; IPermissionService permissionService;
@Autowired @Autowired
IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper; IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper;
@Autowired @Autowired
IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper; IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanConditionVariables") @PostMapping(value = "/getFanConditionVariables")
...@@ -74,7 +75,6 @@ public class KafkaAnalyseController { ...@@ -74,7 +75,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse("开始计算"); return ResponseHelper.buildResponse("开始计算");
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanConditionVariablesGKHF") @PostMapping(value = "/getFanConditionVariablesGKHF")
@ApiOperation(httpMethod = "POST", value = "工况划分 - 风电 - 新", notes = "工况划分 - 风电 - 新") @ApiOperation(httpMethod = "POST", value = "工况划分 - 风电 - 新", notes = "工况划分 - 风电 - 新")
...@@ -99,7 +99,6 @@ public class KafkaAnalyseController { ...@@ -99,7 +99,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse("开始计算"); return ResponseHelper.buildResponse("开始计算");
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanConditionVariablesZXZ") @PostMapping(value = "/getFanConditionVariablesZXZ")
@ApiOperation(httpMethod = "POST", value = "中心值 - 风电 - 新", notes = "中心值 - 风电 - 新") @ApiOperation(httpMethod = "POST", value = "中心值 - 风电 - 新", notes = "中心值 - 风电 - 新")
...@@ -127,24 +126,6 @@ public class KafkaAnalyseController { ...@@ -127,24 +126,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse("开始计算"); return ResponseHelper.buildResponse("开始计算");
} }
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/getAddressInfo") @GetMapping(value = "/getAddressInfo")
@ApiOperation(httpMethod = "GET", value = "getAddressInfo", notes = "getAddressInfo") @ApiOperation(httpMethod = "GET", value = "getAddressInfo", notes = "getAddressInfo")
...@@ -156,8 +137,6 @@ public class KafkaAnalyseController { ...@@ -156,8 +137,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse(indicatorData); return ResponseHelper.buildResponse(indicatorData);
} }
public final DecimalFormat df = new DecimalFormat("0.0");
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全景诊断回溯") @ApiOperation(value = "全景诊断回溯")
@GetMapping("/getFullViewRecall") @GetMapping("/getFullViewRecall")
...@@ -344,6 +323,7 @@ public class KafkaAnalyseController { ...@@ -344,6 +323,7 @@ public class KafkaAnalyseController {
} }
List<FullViewRecallInfoDTO> resultList = new ArrayList<>(); List<FullViewRecallInfoDTO> resultList = new ArrayList<>();
resultList.add(allMapDto); resultList.add(allMapDto);
resultList = getFullViewRecallResultByCurrentUser(resultList);
return ResponseHelper.buildResponse(resultList); return ResponseHelper.buildResponse(resultList);
} }
...@@ -393,4 +373,27 @@ public class KafkaAnalyseController { ...@@ -393,4 +373,27 @@ public class KafkaAnalyseController {
return permissions; return permissions;
} }
private List<FullViewRecallInfoDTO> getFullViewRecallResultByCurrentUser(List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS) {
List<FullViewRecallInfoDTO> result = new ArrayList<>();
if (fullViewRecallInfoDTOS.size() > 0) {
String rootNodeName = permissionService.getCurrentUserPersmissions();
if (rootNodeName.equals("all")) {
return fullViewRecallInfoDTOS;
} else {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS1 = fullViewRecallInfoDTOS.get(0).getChildren().stream().filter(item -> item.getName().equals(rootNodeName)).collect(Collectors.toList());
if (fullViewRecallInfoDTOS1.size() > 0) {
return fullViewRecallInfoDTOS1;
} else {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS2 = fullViewRecallInfoDTOS.get(0).getChildren();
for (FullViewRecallInfoDTO fullViewRecallInfoDTO : fullViewRecallInfoDTOS2) {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS3=fullViewRecallInfoDTO.getChildren().stream().filter(item -> item.getName().equals(rootNodeName)).collect(Collectors.toList());
if (fullViewRecallInfoDTOS3.size()>0){
return fullViewRecallInfoDTOS3;
}
}
}
}
}
return result;
}
} }
...@@ -6,4 +6,5 @@ import java.util.List; ...@@ -6,4 +6,5 @@ import java.util.List;
public interface IPermissionService { public interface IPermissionService {
List<String> getCurrentUserPermissions(); List<String> getCurrentUserPermissions();
List<String> getCurrentUserProjectOrgCodes(); List<String> getCurrentUserProjectOrgCodes();
String getCurrentUserPersmissions();
} }
...@@ -20,10 +20,11 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; ...@@ -20,10 +20,11 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.amosprojectentity.StdUserEmpower; import com.yeejoin.amos.boot.module.jxiop.biz.amosprojectentity.StdUserEmpower;
import com.yeejoin.amos.boot.module.jxiop.biz.amosprojectmapper.UserEmpowerMapper; import com.yeejoin.amos.boot.module.jxiop.biz.amosprojectmapper.UserEmpowerMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
@Service @Service
public class IPermissionServiceImpl implements IPermissionService { public class IPermissionServiceImpl implements IPermissionService {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
...@@ -61,40 +62,70 @@ public class IPermissionServiceImpl implements IPermissionService { ...@@ -61,40 +62,70 @@ public class IPermissionServiceImpl implements IPermissionService {
return result; return result;
} }
@Override @Override
public List<String> getCurrentUserProjectOrgCodes() { public List<String> getCurrentUserProjectOrgCodes() {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
ReginParams reginParams = JSONObject.parseObject(redisUtils ReginParams reginParams = JSONObject.parseObject(redisUtils
.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), .get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(),
ReginParams.class); ReginParams.class);
String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper
.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
return null;
} else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
String companyLevel = companyInfo.get("level");
if (companyLevel.equals("categroy_leve2")) {
List<StationBasic> stationBasics = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
result = stationBasics.stream().map(StationBasic::getProjectOrgCode).collect(Collectors.toList());
return result;
}
if (companyLevel.equals("area")) {
List<StationBasic> stationBasics = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
result = stationBasics.stream().map(StationBasic::getProjectOrgCode).collect(Collectors.toList());
return result;
}
if (companyLevel.equals("station")) {
StationBasic stationBasic = stationBasicMapper
.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode));
result.add(stationBasic.getProjectOrgCode());
return result;
}
}
return result;
}
@Override
public String getCurrentUserPersmissions() {
String rootNodeName = "all";
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String userId = reginParams.getUserModel().getUserId(); String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) { if (ObjectUtils.isEmpty(stdUserEmpower)) {
return null; return rootNodeName;
} else { } else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0); String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode); Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
String companyLevel = companyInfo.get("level"); String companyLevel = companyInfo.get("level").toString();
if (companyLevel.equals("categroy_leve2")) { if (companyLevel.equals("categroy_leve2")) {
List<StationBasic> stationBasics = stationBasicMapper return rootNodeName;
.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
result = stationBasics.stream().map(StationBasic::getProjectOrgCode).collect(Collectors.toList());
return result;
} }
if (companyLevel.equals("area")) { if (companyLevel.equals("area")) {
List<StationBasic> stationBasics = stationBasicMapper List<StationBasic> stationBasics = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode)); if(stationBasics.size()>0){
result = stationBasics.stream().map(StationBasic::getProjectOrgCode).collect(Collectors.toList()); return stationBasics.get(0).getAreaName();
return result; }
} }
if (companyLevel.equals("station")) { if (companyLevel.equals("station")) {
StationBasic stationBasic = stationBasicMapper StationBasic stationBasic = stationBasicMapper
.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode)); .selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode));
result.add(stationBasic.getProjectOrgCode()); return stationBasic.getStationName();
return result;
} }
} }
return result; return rootNodeName;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment