1.微调
This commit is contained in:
@@ -10,10 +10,15 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.mapper.PqsDeviceUnitMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.constant.UserType;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -47,6 +52,8 @@ public class CsCommTerminalController extends BaseController {
|
||||
private final CsDeviceUserPOService csDeviceUserPOService;
|
||||
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
|
||||
/**
|
||||
* 根据用户获取设备信息
|
||||
@@ -57,16 +64,8 @@ public class CsCommTerminalController extends BaseController {
|
||||
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
|
||||
public HttpResult<List<String>> getDevIdsByUser(@RequestParam("userId") String userId) {
|
||||
String methodDescribe = getMethodDescribe("getDevIdsByUser");
|
||||
List<String> result;
|
||||
List<CsDeviceUserPO> poList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
||||
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
|
||||
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
|
||||
if(CollUtil.isNotEmpty(poList)){
|
||||
result = poList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
}else {
|
||||
result = Collections.emptyList();
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
List<String> devIds = commGetDevIds(userId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devIds, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,19 +77,16 @@ public class CsCommTerminalController extends BaseController {
|
||||
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
|
||||
public HttpResult<List<String>> getLineIdsByUser(@RequestParam("userId") String userId) {
|
||||
String methodDescribe = getMethodDescribe("getLineIdsByUser");
|
||||
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
||||
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
|
||||
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
|
||||
if(CollUtil.isNotEmpty(devList)){
|
||||
List<String> devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsLinePO> poList = csLinePOService.lambdaQuery().select(CsLinePO::getLineId).in(CsLinePO::getDeviceId,devIds)
|
||||
.eq(CsLinePO::getStatus,DataStateEnum.ENABLE.getCode()).list();
|
||||
if(CollUtil.isEmpty(poList)){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Collections.emptyList(), methodDescribe);
|
||||
}else {
|
||||
List<String> result = poList.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
List<String> devIds = commGetDevIds(userId);
|
||||
if(CollUtil.isNotEmpty(devIds)){
|
||||
List<CsLinePO> poList = csLinePOService.lambdaQuery().select(CsLinePO::getLineId).in(CsLinePO::getDeviceId,devIds)
|
||||
.eq(CsLinePO::getStatus,DataStateEnum.ENABLE.getCode()).list();
|
||||
if(CollUtil.isEmpty(poList)){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Collections.emptyList(), methodDescribe);
|
||||
}else {
|
||||
List<String> result = poList.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Collections.emptyList(), methodDescribe);
|
||||
}
|
||||
@@ -106,11 +102,9 @@ public class CsCommTerminalController extends BaseController {
|
||||
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
|
||||
public HttpResult<List<String>> getPqUserIdsByUser(@RequestParam("userId") String userId) {
|
||||
String methodDescribe = getMethodDescribe("getPqUserIdsByUser");
|
||||
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
||||
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
|
||||
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
|
||||
if(CollUtil.isNotEmpty(devList)){
|
||||
List<String> devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
|
||||
List<String> devIds = commGetDevIds(userId);
|
||||
if(CollUtil.isNotEmpty(devIds)){
|
||||
List<CsLinePO> poList = csLinePOService.lambdaQuery().select(CsLinePO::getLineId,CsLinePO::getMonitorUser).in(CsLinePO::getDeviceId,devIds)
|
||||
.eq(CsLinePO::getStatus,DataStateEnum.ENABLE.getCode()).list();
|
||||
if(CollUtil.isEmpty(poList)){
|
||||
@@ -124,6 +118,21 @@ public class CsCommTerminalController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<String> commGetDevIds(String userId){
|
||||
UserVO userVO = userFeignClient.getUserById(userId).getData();
|
||||
List<String> devIds;
|
||||
if(userVO.getType().equals(UserType.SUPER_ADMINISTRATOR ) || userVO.getType().equals(UserType.ADMINISTRATOR )){
|
||||
devIds = csEquipmentDeliveryService.getAll().stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
||||
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
|
||||
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
|
||||
devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
return devIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过监测点获取监测点数据单位
|
||||
* @author cdf
|
||||
|
||||
Reference in New Issue
Block a user