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.*;
@RequestMapping(value = "/kafkaAnalyse")
public class KafkaAnalyseController {
public final DecimalFormat df = new DecimalFormat("0.0");
@Autowired
FanConditionVariablesMessage fanConditionVariablesMessage;
@Autowired
RedisUtils redisUtils;
@Autowired
IPermissionService permissionService;
@Autowired
IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper;
@Autowired
IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanConditionVariables")
......@@ -74,7 +75,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse("开始计算");
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanConditionVariablesGKHF")
@ApiOperation(httpMethod = "POST", value = "工况划分 - 风电 - 新", notes = "工况划分 - 风电 - 新")
......@@ -99,7 +99,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse("开始计算");
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanConditionVariablesZXZ")
@ApiOperation(httpMethod = "POST", value = "中心值 - 风电 - 新", notes = "中心值 - 风电 - 新")
......@@ -127,24 +126,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse("开始计算");
}
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/getAddressInfo")
@ApiOperation(httpMethod = "GET", value = "getAddressInfo", notes = "getAddressInfo")
......@@ -156,8 +137,6 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse(indicatorData);
}
public final DecimalFormat df = new DecimalFormat("0.0");
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全景诊断回溯")
@GetMapping("/getFullViewRecall")
......@@ -344,6 +323,7 @@ public class KafkaAnalyseController {
}
List<FullViewRecallInfoDTO> resultList = new ArrayList<>();
resultList.add(allMapDto);
resultList = getFullViewRecallResultByCurrentUser(resultList);
return ResponseHelper.buildResponse(resultList);
}
......@@ -393,4 +373,27 @@ public class KafkaAnalyseController {
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;
public interface IPermissionService {
List<String> getCurrentUserPermissions();
List<String> getCurrentUserProjectOrgCodes();
String getCurrentUserPersmissions();
}
......@@ -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.amosprojectmapper.UserEmpowerMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
@Service
public class IPermissionServiceImpl implements IPermissionService {
@Autowired
@Autowired
private RedisUtils redisUtils;
@Autowired
......@@ -61,40 +62,70 @@ public class IPermissionServiceImpl implements IPermissionService {
return result;
}
@Override
public List<String> getCurrentUserProjectOrgCodes() {
List<String> result = new ArrayList<>();
ReginParams reginParams = JSONObject.parseObject(redisUtils
.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(),
ReginParams.class);
@Override
public List<String> getCurrentUserProjectOrgCodes() {
List<String> result = new ArrayList<>();
ReginParams reginParams = JSONObject.parseObject(redisUtils
.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(),
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();
StdUserEmpower stdUserEmpower = userEmpowerMapper
.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
return null;
return rootNodeName;
} else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
String companyLevel = companyInfo.get("level");
String companyLevel = companyInfo.get("level").toString();
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;
return rootNodeName;
}
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;
List<StationBasic> stationBasics = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
if(stationBasics.size()>0){
return stationBasics.get(0).getAreaName();
}
}
if (companyLevel.equals("station")) {
StationBasic stationBasic = stationBasicMapper
.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode));
result.add(stationBasic.getProjectOrgCode());
return result;
StationBasic stationBasic = stationBasicMapper
.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode));
return stationBasic.getStationName();
}
}
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