diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/ledger/CsCommTerminalController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/ledger/CsCommTerminalController.java index b9dad68..f420624 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/ledger/CsCommTerminalController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/ledger/CsCommTerminalController.java @@ -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> getDevIdsByUser(@RequestParam("userId") String userId) { String methodDescribe = getMethodDescribe("getDevIdsByUser"); - List result; - List 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 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> getLineIdsByUser(@RequestParam("userId") String userId) { String methodDescribe = getMethodDescribe("getLineIdsByUser"); - List 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 devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList()); - List 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 result = poList.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList()); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); - } + List devIds = commGetDevIds(userId); + if(CollUtil.isNotEmpty(devIds)){ + List 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 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> getPqUserIdsByUser(@RequestParam("userId") String userId) { String methodDescribe = getMethodDescribe("getPqUserIdsByUser"); - List 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 devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList()); + + List devIds = commGetDevIds(userId); + if(CollUtil.isNotEmpty(devIds)){ List 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 commGetDevIds(String userId){ + UserVO userVO = userFeignClient.getUserById(userId).getData(); + List 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 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 diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/event/EventOverviewServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/event/EventOverviewServiceImpl.java index a1b8ab9..55d52a9 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/event/EventOverviewServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/event/EventOverviewServiceImpl.java @@ -66,7 +66,7 @@ public class EventOverviewServiceImpl implements EventOverviewService { .between(CsEventPO::getStartTime, start, end) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .in(CsEventPO::getTag, EVENT_TAGS) - // .in(CsEventPO::getLineId,ids) + .in(CsEventPO::getLineId,ids) .list(); @@ -87,7 +87,7 @@ public class EventOverviewServiceImpl implements EventOverviewService { DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())); List lineIds = StrUtil.isBlank(baseParam.getSearchValue()) - ? csLineFeignClient.getAllLine().getData() + ? csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData() : Collections.singletonList(baseParam.getSearchValue()); if(CollUtil.isEmpty(lineIds)){ @@ -152,16 +152,16 @@ public class EventOverviewServiceImpl implements EventOverviewService { DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())); DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())); - /* List ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); + List ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); if(CollUtil.isEmpty(ids)){ return Collections.emptyList(); - }*/ + } List csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getStartTime,CsEventPO::getTag,CsEventPO::getPersistTime,CsEventPO::getAmplitude) .between(CsEventPO::getStartTime, start, end) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .in(CsEventPO::getTag, EVENT_TAGS) - // .in(CsEventPO::getLineId,ids) + .in(CsEventPO::getLineId,ids) .list(); List f47CurveList = csEventPOList.stream().map(item->{ @@ -185,16 +185,16 @@ public class EventOverviewServiceImpl implements EventOverviewService { DateTime start = DateUtil.beginOfMonth(dateTime); DateTime end = DateUtil.endOfMonth(dateTime); - /* List ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); + List ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); if(CollUtil.isEmpty(ids)){ return Collections.emptyList(); - }*/ + } List rangList = DateUtil.rangeToList(start,end, DateField.DAY_OF_MONTH); List csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getTag,CsEventPO::getStartTime,CsEventPO::getPersistTime,CsEventPO::getAmplitude) .between(CsEventPO::getStartTime, start, end) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .in(CsEventPO::getTag, EVENT_TAGS) - // .in(CsEventPO::getLineId,ids) + .in(CsEventPO::getLineId,ids) .list(); if(CollUtil.isEmpty(csEventPOList)){ @@ -233,13 +233,10 @@ public class EventOverviewServiceImpl implements EventOverviewService { result.add(new EventCoordsVO.inner(i, j, 0)); } } - - - - /* List ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); + List ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); if(CollUtil.isEmpty(ids)){ - return result; - }*/ + return eventCoordsVO; + } //查询监测点未处理暂态事件 DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())); @@ -248,7 +245,7 @@ public class EventOverviewServiceImpl implements EventOverviewService { .between(CsEventPO::getStartTime, start, end) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .in(CsEventPO::getTag, EVENT_TAGS) - // .in(CsEventPO::getLineId,ids) + .in(CsEventPO::getLineId,ids) .list(); // 定义幅值和持续时间的分类规则