feat(service): 实现分页功能并优化设备权限管理
- 在控制器层添加分页支持,将返回类型从 List 修改为 Page - 实现服务层分页逻辑,集成 MyBatis Plus 分页插件 - 重构设备权限管理逻辑,区分超级管理员、普通用户和游客权限 - 添加营销用户和工程用户的特殊权限处理机制 - 迁移事件查询逻辑到统一的事件用户服务中 - 移除过时的设备用户映射器接口和 XML 查询方法 - 为暂降事件报告添加动态文件名生成功能 - 修复时间范围计算中的日期边界问题 - 优化台账树结构以支持多层级权限过滤 - 统计未读事件数量的查询逻辑优化
This commit is contained in:
@@ -3,6 +3,8 @@ package com.njcn.csdevice.pojo.dto;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/9/6 13:59【需求编号】
|
||||
@@ -37,4 +39,7 @@ public class DevDetailDTO {
|
||||
|
||||
@ApiModelProperty(value = "设备MAC地址")
|
||||
private String devMac;
|
||||
|
||||
@ApiModelProperty(value = "监测点id集合")
|
||||
private List<String> lineList;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.njcn.csdevice.pojo.dto;
|
||||
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -13,7 +15,7 @@ import java.util.List;
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class LineParamDTO {
|
||||
public class LineParamDTO extends BaseParam implements Serializable {
|
||||
@ApiModelProperty(value = "工程id")
|
||||
private String engineerId;
|
||||
|
||||
|
||||
@@ -6,12 +6,13 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.enums.DeviceOperate;
|
||||
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
|
||||
import com.njcn.csdevice.pojo.param.UserDevParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevUserVO;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
@@ -41,7 +42,7 @@ import java.util.Objects;
|
||||
public class DeviceUserController extends BaseController {
|
||||
|
||||
private final CsDeviceUserPOService csDeviceUserPOService;
|
||||
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
|
||||
private final EventUserFeignClient eventUserFeignClient;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@@ -187,10 +188,16 @@ public class DeviceUserController extends BaseController {
|
||||
public HttpResult<List<String>> getIdList(@RequestParam("param") String param){
|
||||
String methodDescribe = getMethodDescribe("getIdList");
|
||||
List<String> list = new ArrayList<>();
|
||||
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
|
||||
param1.setUserId(RequestUtil.getUserIndex());
|
||||
param1.setStartTime(null);
|
||||
param1.setEndTime(null);
|
||||
param1.setEventIds(null);
|
||||
|
||||
if (Objects.equals(param, "1")) {
|
||||
list = csDeviceUserPOMapper.queryTempHarmonic(RequestUtil.getUserIndex(),null,null,null);
|
||||
list = eventUserFeignClient.queryTempHarmonic(param1).getData();
|
||||
} else if (Objects.equals(param, "3")) {
|
||||
list = csDeviceUserPOMapper.queryAlarmEvent(RequestUtil.getUserIndex(),null,null,null);
|
||||
list = eventUserFeignClient.queryAlarmEvent(param1).getData();
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CsTouristDataPOController extends BaseController {
|
||||
@PostMapping("/queryAll")
|
||||
@ApiOperation("查询游客数据")
|
||||
public HttpResult<List<CsTouristDataParmVO>> queryAll(){
|
||||
String methodDescribe = getMethodDescribe("query");
|
||||
String methodDescribe = getMethodDescribe("queryAll");
|
||||
|
||||
List<CsTouristDataParmVO> list = csTouristDataPOService.queryAll();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
|
||||
@@ -2,9 +2,6 @@ package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -15,17 +12,4 @@ import java.util.List;
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsDeviceUserPOMapper extends BaseMapper<CsDeviceUserPO> {
|
||||
|
||||
//查询暂态事件(未读)
|
||||
List<String> queryTempEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询稳态事件(未读)
|
||||
List<String> queryTempHarmonic(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询告警事件(未读)
|
||||
List<String> queryAlarmEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询运行事件(未读)
|
||||
List<String> queryRunEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
}
|
||||
@@ -16,72 +16,4 @@
|
||||
<!--@mbg.generated-->
|
||||
primary_user_id, sub_user_id, device_id, create_by, create_time, update_by, update_time
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="queryTempEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
and t2.type = 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and t2.line_id in
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryAlarmEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_alarm t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and (
|
||||
<foreach collection="ids" item="tag" separator=" OR ">
|
||||
FIND_IN_SET(#{tag}, t2.dev_list) > 0
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryRunEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
and t2.type = 2
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and t2.device_id in
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryTempHarmonic" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_harmonic t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and t2.line_id in
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -93,27 +93,33 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
@Override
|
||||
public List<String> commGetDevIds(String userId) {
|
||||
UserVO userVO = userFeignClient.getUserById(userId).getData();
|
||||
List<String> devIds;
|
||||
List<String> devIds = new ArrayList<>();
|
||||
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());
|
||||
//note 黄是在cs_market_data写入数据,是用户和工程的关系;
|
||||
// 但是权限根据用户和设备来判断会有问题,还需要用户和工程的关系(针对营销 工程用户),所以这边还要添加用户和工程的关系
|
||||
List<CsMarketDataVO> list = csMarketDataService.queryByUseId(userId);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
List<String> engineerIds = list.stream().map(CsMarketDataVO::getEngineerId).distinct().collect(Collectors.toList());
|
||||
List<DevDetailDTO> devs = csLedgerService.getDevInfoByEngineerIds(engineerIds);
|
||||
devIds.addAll(devs.stream().map(DevDetailDTO::getEquipmentId).distinct().collect(Collectors.toList()));
|
||||
// 但是权限根据用户和设备来判断会有问题,还需要用户和工程的关系(针对营销 工程用户),所以这边还要添加用户和工程的关系。
|
||||
// 如果是营销 工程用户 没有配置相关工程,直接返回空的设备列表;如果有数据,也要判断下当前关注的工程里面是否包含主用户的设备,可能出现没有关注该工程,但是因为是设备的主用户导致数据统计错误
|
||||
String roleString = RequestUtil.getUserRole();
|
||||
if (roleString.contains(AppRoleEnum.MARKET_USER.getCode()) || roleString.contains(AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
List<CsMarketDataVO> list = csMarketDataService.queryByUseId(userId);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
List<String> engineerIds = list.stream().map(CsMarketDataVO::getEngineerId).distinct().collect(Collectors.toList());
|
||||
List<DevDetailDTO> devs = csLedgerService.getDevInfoByEngineerIds(engineerIds);
|
||||
devIds = devs.stream().map(DevDetailDTO::getEquipmentId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
//note 如果是游客,则还需要加入系统配置的设备
|
||||
String roleString = RequestUtil.getUserRole();
|
||||
if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
|
||||
else if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
|
||||
devIds.addAll(csTouristDataPOService.queryAll().stream().map(CsTouristDataParmVO::getDeviceId).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
//note 如果是普通用户,则需要根据用户权限来获取设备列表
|
||||
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());
|
||||
}
|
||||
}
|
||||
if (!CollUtil.isEmpty(devIds)) {
|
||||
devIds = devIds.stream().distinct().collect(Collectors.toList());
|
||||
|
||||
@@ -10,14 +10,16 @@ import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
||||
import com.njcn.csdevice.mapper.CsMarketDataMapper;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.param.UserDevParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevUserVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.cssystem.api.FeedBackFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.harmonic.utils.PublicDataUtils;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
@@ -30,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -51,14 +54,12 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
private final CsDevModelRelationService csDevModelRelationService;
|
||||
private final ICsLedgerService iCsLedgerService;
|
||||
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
|
||||
private final RoleEngineerDevService roleEngineerDevService;
|
||||
private final AppLineTopologyDiagramService appLineTopologyDiagramService;
|
||||
private final CsTouristDataPOService csTouristDataPOService;
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final CsMarketDataMapper csMarketDataMapper;
|
||||
private final EventUserFeignClient eventUserFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final FeedBackFeignClient feedBackFeignClient;
|
||||
private final IMqttUserService mqttUserService;
|
||||
|
||||
@Override
|
||||
@@ -122,17 +123,61 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
DevCountVO vo = new DevCountVO();
|
||||
//获取app用户的台账树,包含四个层级 工程、项目、设备、监测点
|
||||
List<CsLedgerVO> appLedger = iCsLedgerService.appLineTree();
|
||||
//判断当前用户,如果是游客,则需要筛选数据,只保留游客的数据
|
||||
String roleString = RequestUtil.getUserRole();
|
||||
if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
|
||||
List<CsTouristDataParmVO> csTouristDataParmVOList = csTouristDataPOService.queryAll();
|
||||
if (CollectionUtil.isNotEmpty(csTouristDataParmVOList)) {
|
||||
List<String> devList = csTouristDataParmVOList.stream().map(CsTouristDataParmVO::getDeviceId).collect(Collectors.toList());
|
||||
// 保留游客有权限的工程、项目、设备、监测点数据
|
||||
appLedger = appLedger.stream()
|
||||
.filter(engineering -> {
|
||||
boolean hasValidProject = false;
|
||||
if (CollectionUtil.isNotEmpty(engineering.getChildren())) {
|
||||
List<CsLedgerVO> validProjects = engineering.getChildren().stream()
|
||||
.filter(project -> {
|
||||
boolean hasValidDevice = false;
|
||||
if (CollectionUtil.isNotEmpty(project.getChildren())) {
|
||||
List<CsLedgerVO> validDevices = project.getChildren().stream()
|
||||
.filter(device -> devList.contains(device.getId()))
|
||||
.collect(Collectors.toList());
|
||||
project.setChildren(validDevices);
|
||||
hasValidDevice = CollectionUtil.isNotEmpty(validDevices);
|
||||
}
|
||||
return hasValidDevice;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
engineering.setChildren(validProjects);
|
||||
hasValidProject = CollectionUtil.isNotEmpty(validProjects);
|
||||
}
|
||||
return hasValidProject;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
// 如果游客没有配置任何数据权限,返回空列表
|
||||
appLedger = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(appLedger)) {
|
||||
//获取第一层项目层级
|
||||
List<CsLedgerVO> firstLevelList = new ArrayList<>();
|
||||
//获取第三层设备层级
|
||||
List<CsLedgerVO> thirdLevelList = new ArrayList<>();
|
||||
//获取第四层设备层级
|
||||
List<CsLedgerVO> forthLevelList = new ArrayList<>();
|
||||
for (CsLedgerVO firstLevel : appLedger) {
|
||||
firstLevelList.add(firstLevel);
|
||||
if (CollectionUtil.isNotEmpty(firstLevel.getChildren())) {
|
||||
for (CsLedgerVO secondLevel : firstLevel.getChildren()) {
|
||||
if (CollectionUtil.isNotEmpty(secondLevel.getChildren())) {
|
||||
thirdLevelList.addAll(secondLevel.getChildren());
|
||||
for (CsLedgerVO threeLevel : secondLevel.getChildren()) {
|
||||
if (CollectionUtil.isNotEmpty(threeLevel.getChildren())) {
|
||||
forthLevelList.addAll(threeLevel.getChildren());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,17 +208,30 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
return vo;
|
||||
}
|
||||
//获取未读事件数量
|
||||
List<String> eventCount = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setEventCount(CollectionUtil.isNotEmpty(eventCount)?eventCount.size():0);
|
||||
if (CollectionUtil.isNotEmpty(forthLevelList)) {
|
||||
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
|
||||
param1.setUserId(RequestUtil.getUserIndex());
|
||||
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
|
||||
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
|
||||
param1.setEventIds(forthLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
|
||||
|
||||
List<String> harmonicCount = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount)?harmonicCount.size():0);
|
||||
List<String> eventCount = eventUserFeignClient.queryTempEvent(param1).getData();
|
||||
vo.setEventCount(CollectionUtil.isNotEmpty(eventCount)?eventCount.size():0);
|
||||
List<String> harmonicCount = eventUserFeignClient.queryTempHarmonic(param1).getData();
|
||||
vo.setHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount)?harmonicCount.size():0);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(thirdLevelList)) {
|
||||
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
|
||||
param1.setUserId(RequestUtil.getUserIndex());
|
||||
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
|
||||
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
|
||||
param1.setEventIds(thirdLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
|
||||
|
||||
List<String> alarmCount = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setAlarmCount(CollectionUtil.isNotEmpty(alarmCount)?alarmCount.size():0);
|
||||
|
||||
List<String> runCount = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setRunCount(CollectionUtil.isNotEmpty(runCount)?runCount.size():0);
|
||||
List<String> alarmCount = eventUserFeignClient.queryAlarmEvent(param1).getData();
|
||||
vo.setAlarmCount(CollectionUtil.isNotEmpty(alarmCount)?alarmCount.size():0);
|
||||
List<String> runCount = eventUserFeignClient.queryRunEvent(param1).getData();
|
||||
vo.setRunCount(CollectionUtil.isNotEmpty(runCount)?runCount.size():0);
|
||||
}
|
||||
|
||||
//note 当前工程数据
|
||||
//当前工程id
|
||||
@@ -228,17 +286,29 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
}
|
||||
//获取未读事件数量
|
||||
if (CollectionUtil.isNotEmpty(currentLineIds)) {
|
||||
List<String> eventCount2 = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
|
||||
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
|
||||
param1.setUserId(RequestUtil.getUserIndex());
|
||||
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
|
||||
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
|
||||
param1.setEventIds(currentLineIds);
|
||||
|
||||
List<String> eventCount2 = eventUserFeignClient.queryTempEvent(param1).getData();
|
||||
vo.setCurrentEventCount(CollectionUtil.isNotEmpty(eventCount2)?eventCount2.size():0);
|
||||
|
||||
List<String> harmonicCount2 = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
|
||||
List<String> harmonicCount2 = eventUserFeignClient.queryTempHarmonic(param1).getData();
|
||||
vo.setCurrentHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount2)?harmonicCount2.size():0);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(currentDevIds)) {
|
||||
List<String> alarmCount2 = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
|
||||
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
|
||||
param1.setUserId(RequestUtil.getUserIndex());
|
||||
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
|
||||
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
|
||||
param1.setEventIds(currentDevIds);
|
||||
|
||||
List<String> alarmCount2 = eventUserFeignClient.queryAlarmEvent(param1).getData();
|
||||
vo.setCurrentAlarmCount(CollectionUtil.isNotEmpty(alarmCount2)?alarmCount2.size():0);
|
||||
|
||||
List<String> runCount2 = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
|
||||
List<String> runCount2 = eventUserFeignClient.queryRunEvent(param1).getData();
|
||||
vo.setCurrentRunCount(CollectionUtil.isNotEmpty(runCount2)?runCount2.size():0);
|
||||
}
|
||||
}
|
||||
@@ -535,6 +605,21 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
result = list.stream().map(CsDeviceUserPO::getSubUserId).collect(Collectors.toList());
|
||||
}
|
||||
//获取关注设备的用户(工程用户、营销用户)
|
||||
List<DevDetailDTO> ledger = iCsLedgerService.getInfoByIds(Collections.singletonList(devId));
|
||||
if (CollectionUtil.isNotEmpty(ledger)) {
|
||||
DevDetailDTO item = ledger.get(0);
|
||||
LambdaQueryWrapper<CsMarketData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsMarketData::getEngineerId, item.getEngineeringid());
|
||||
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(csMarketData)) {
|
||||
List<String> collect = csMarketData.stream().map(CsMarketData::getUserId).collect(Collectors.toList());
|
||||
result.addAll(collect);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result = result.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -996,7 +996,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,id)
|
||||
.in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state);
|
||||
.in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state)
|
||||
.eq(CsEquipmentDeliveryPO::getDevAccessMethod,"CLD");
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -1341,11 +1341,25 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
|
||||
if (CollUtil.isNotEmpty(dev)) {
|
||||
List<String> devIds = dev.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
|
||||
//监测点
|
||||
LambdaQueryWrapper<CsLedger> queryWrapper3 = new LambdaQueryWrapper<>();
|
||||
queryWrapper3.in(CsLedger::getPid, devIds);
|
||||
List<CsLedger> line = this.list(queryWrapper3);
|
||||
Map<String,List<CsLedger>> lineMap = line.stream().collect(Collectors.groupingBy(CsLedger::getPid));
|
||||
|
||||
|
||||
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devIds);
|
||||
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, item -> item));
|
||||
|
||||
dev.forEach(item -> {
|
||||
DevDetailDTO detail = new DevDetailDTO();
|
||||
//监测点
|
||||
List<CsLedger> lines = lineMap.get(item.getId());
|
||||
if (CollUtil.isNotEmpty(lines)) {
|
||||
detail.setLineList(lines.stream().map(CsLedger::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
detail.setEquipmentName(item.getName());
|
||||
detail.setEquipmentId(item.getId());
|
||||
|
||||
|
||||
@@ -132,18 +132,19 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
|
||||
}
|
||||
//fix 新需求 工程用户可以看到关注工程的设备和对应的主用户和子用户的设备
|
||||
//note 这边工程用户不查询主设备,只看关注的工程,做下调整,不然会出现工程用户未关注任何工程,但是有一台主设备,导致界面有数据
|
||||
else if (Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
List<String> sumDevId = new ArrayList<>();
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
|
||||
wq.eq("primary_user_id", userIndex)
|
||||
.or()
|
||||
.eq("sub_user_id",userIndex);
|
||||
});
|
||||
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
|
||||
if(!CollectionUtils.isEmpty(csDeviceUserPOS)){
|
||||
sumDevId = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
// csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
|
||||
// wq.eq("primary_user_id", userIndex)
|
||||
// .or()
|
||||
// .eq("sub_user_id",userIndex);
|
||||
// });
|
||||
// List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
|
||||
// if(!CollectionUtils.isEmpty(csDeviceUserPOS)){
|
||||
// sumDevId = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
|
||||
csMarketDataQueryWrapper.eq("user_id", userIndex);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -27,4 +28,20 @@ public interface EventUserFeignClient {
|
||||
|
||||
@PostMapping("/deleteByIds")
|
||||
HttpResult<Boolean> deleteByIds(@RequestBody List<String> eventList);
|
||||
|
||||
@PostMapping("/queryTempEvent")
|
||||
@ApiOperation("查询暂态事件(未读)")
|
||||
HttpResult<List<String>> queryTempEvent(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@PostMapping("/queryTempHarmonic")
|
||||
@ApiOperation("查询稳态事件(未读)")
|
||||
HttpResult<List<String>> queryTempHarmonic(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@PostMapping("/queryAlarmEvent")
|
||||
@ApiOperation("查询告警事件(未读)")
|
||||
HttpResult<List<String>> queryAlarmEvent(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@PostMapping("/queryRunEvent")
|
||||
@ApiOperation("查询运行事件(未读)")
|
||||
HttpResult<List<String>> queryRunEvent(@RequestBody CsEventUserQueryParam param);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,30 @@ public class EventUserFeignClientFallbackFactory implements FallbackFactory<Even
|
||||
log.error("{}异常,降级处理,异常为:{}","根据id删除数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> queryTempEvent(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询暂态事件(未读)异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> queryTempHarmonic(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询稳态事件(未读)异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> queryAlarmEvent(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询告警事件(未读)异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> queryRunEvent(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询运行事件(未读)异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,10 @@ public class HarmonicVO implements Serializable {
|
||||
@ApiModelProperty(value = "越限监测点数")
|
||||
private Integer overLineNums = 0;
|
||||
|
||||
@ApiModelProperty(value = "越限监测点数")
|
||||
@ApiModelProperty(value = "越限日期")
|
||||
private List<String> overDaysList;
|
||||
|
||||
@ApiModelProperty(value = "越限监测点详情")
|
||||
private List<LineHarmonicDetail> list = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
@@ -59,5 +62,31 @@ public class HarmonicVO implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class LineHarmonicOverDays implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "工程名称")
|
||||
private String engineeringName;
|
||||
|
||||
@ApiModelProperty(value = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String devName;
|
||||
|
||||
@ApiModelProperty(value = "监测点id")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty(value = "监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty(value = "越限日期字符串")
|
||||
private String timeString;
|
||||
|
||||
@ApiModelProperty(value = "越限日期集合")
|
||||
private List<String> timeList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csharmonic.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -42,9 +43,9 @@ public class CsAlarmController extends BaseController {
|
||||
@PostMapping("/queryAlarmList")
|
||||
@ApiOperation("运行告警事件列表(app)")
|
||||
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
|
||||
public HttpResult<List<AlarmVO>> queryAlarmList(@RequestBody LineParamDTO param) {
|
||||
public HttpResult<Page<AlarmVO>> queryAlarmList(@RequestBody LineParamDTO param) {
|
||||
String methodDescribe = getMethodDescribe("queryAlarmList");
|
||||
List<AlarmVO> result = csAlarmService.queryAlarmList(param);
|
||||
Page<AlarmVO> result = csAlarmService.queryAlarmList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csharmonic.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -42,17 +43,17 @@ public class CsHarmonicController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryHarmonicList")
|
||||
@ApiOperation("稳态事件列表(app)")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<HarmonicVO> queryHarmonicList(@RequestBody LineParamDTO param) {
|
||||
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
|
||||
public HttpResult<Page<HarmonicVO.LineHarmonicDetail>> queryHarmonicList(@RequestBody LineParamDTO param) {
|
||||
String methodDescribe = getMethodDescribe("queryHarmonicList");
|
||||
HarmonicVO vo = csHarmonicService.queryAppList(param);
|
||||
Page<HarmonicVO.LineHarmonicDetail> vo = csHarmonicService.queryAppList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryHarmonicDetail")
|
||||
@ApiOperation("稳态事件详情(app)")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
|
||||
public HttpResult<List<HarmonicDetailVO>> queryHarmonicDetail(@RequestBody LineParamDTO param) {
|
||||
String methodDescribe = getMethodDescribe("queryHarmonicDetail");
|
||||
List<HarmonicDetailVO> vo = csHarmonicService.queryHarmonicDetail(param);
|
||||
@@ -62,7 +63,7 @@ public class CsHarmonicController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addList")
|
||||
@ApiOperation("批量写入数据")
|
||||
@ApiImplicitParam(name = "list", value = "暂降事件查询参数", required = true)
|
||||
@ApiImplicitParam(name = "list", value = "事件查询参数", required = true)
|
||||
public HttpResult<Boolean> addList(@RequestBody List<CsHarmonic> list) {
|
||||
String methodDescribe = getMethodDescribe("addList");
|
||||
boolean result = csHarmonicService.saveOrUpdateBatch(list);
|
||||
@@ -93,5 +94,25 @@ public class CsHarmonicController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryAppHarmonicCounts")
|
||||
@ApiOperation("查询App稳态事件总数")
|
||||
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
|
||||
public HttpResult<HarmonicVO> queryAppHarmonicCounts(@RequestBody LineParamDTO param) {
|
||||
String methodDescribe = getMethodDescribe("queryAppHarmonicCounts");
|
||||
HarmonicVO vo = csHarmonicService.queryAppHarmonicCounts(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryAppHarmonicLine")
|
||||
@ApiOperation("查询App稳态越限监测点")
|
||||
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
|
||||
public HttpResult<Page<HarmonicVO.LineHarmonicOverDays>> queryAppHarmonicLine(@RequestBody LineParamDTO param) {
|
||||
String methodDescribe = getMethodDescribe("queryAppHarmonicLine");
|
||||
Page<HarmonicVO.LineHarmonicOverDays> result = csHarmonicService.queryAppHarmonicLine(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csharmonic.mapper.CsEventUserPOMapper;
|
||||
import com.njcn.csharmonic.param.CldWarnParam;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -40,7 +42,10 @@ import java.util.List;
|
||||
@Api(tags = "事件")
|
||||
@AllArgsConstructor
|
||||
public class EventUserController extends BaseController {
|
||||
|
||||
private final CsEventUserPOService csEventUserPOService;
|
||||
private final CsEventUserPOMapper csEventUserPOMapper;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryEvent")
|
||||
@ApiOperation("暂降事件未读消息")
|
||||
@@ -120,4 +125,54 @@ public class EventUserController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryTempEvent")
|
||||
@ApiOperation("查询暂态事件(未读)")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<List<String>> queryTempEvent(@RequestBody CsEventUserQueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("queryTempEvent");
|
||||
List<String> result = csEventUserPOMapper.queryTempEvent(param.getUserId(), param.getStartTime(), param.getEndTime(), param.getEventIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryTempHarmonic")
|
||||
@ApiOperation("查询稳态事件(未读)")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<List<String>> queryTempHarmonic(@RequestBody CsEventUserQueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("queryTempEvent");
|
||||
List<String> result = csEventUserPOMapper.queryTempHarmonic(param.getUserId(), param.getStartTime(), param.getEndTime(), param.getEventIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryAlarmEvent")
|
||||
@ApiOperation("查询告警事件(未读)")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<List<String>> queryAlarmEvent(@RequestBody CsEventUserQueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("queryAlarmEvent");
|
||||
List<String> result = csEventUserPOMapper.queryAlarmEvent(param.getUserId(), param.getStartTime(), param.getEndTime(), param.getEventIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryRunEvent")
|
||||
@ApiOperation("查询运行事件(未读)")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<List<String>> queryRunEvent(@RequestBody CsEventUserQueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("queryRunEvent");
|
||||
List<String> result = csEventUserPOMapper.queryRunEvent(param.getUserId(), param.getStartTime(), param.getEndTime(), param.getEventIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryAppEventCounts")
|
||||
@ApiOperation("查询App暂态事件总数")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<EventStatisticVO> queryAppEventCounts(@RequestBody CsEventUserQueryPage param) {
|
||||
String methodDescribe = getMethodDescribe("queryAppEventCounts");
|
||||
EventStatisticVO result = csEventUserPOService.queryAppEventCounts(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,4 +36,18 @@ public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
|
||||
|
||||
|
||||
Page<EventDetailVO> queryEventPageWeb(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("devIds") List<String> collect);
|
||||
|
||||
//查询暂态事件(未读)
|
||||
List<String> queryTempEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询稳态事件(未读)
|
||||
List<String> queryTempHarmonic(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询告警事件(未读)
|
||||
List<String> queryAlarmEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询运行事件(未读)
|
||||
List<String> queryRunEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
EventStatisticVO getEventCounts(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.njcn.csharmonic.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import com.njcn.csharmonic.pojo.vo.HarmonicVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +18,10 @@ import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
*/
|
||||
public interface CsHarmonicMapper extends BaseMapper<CsHarmonic> {
|
||||
|
||||
HarmonicVO getHarmonicCounts(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
List<String> getOverDays(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
Page<HarmonicVO.LineHarmonicOverDays> getLineHarmonicOverDays(Page<HarmonicVO.LineHarmonicOverDays> page, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
}
|
||||
|
||||
@@ -250,4 +250,89 @@
|
||||
</if>
|
||||
order by b.start_time desc
|
||||
</select>
|
||||
|
||||
<select id="queryTempEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
and t2.type = 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and t2.line_id in
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryAlarmEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_alarm t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and (
|
||||
<foreach collection="ids" item="tag" separator=" OR ">
|
||||
FIND_IN_SET(#{tag}, t2.dev_list) > 0
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryRunEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
and t2.type = 2
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and t2.device_id in
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryTempHarmonic" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_harmonic t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and t2.line_id in
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getEventCounts" resultType="com.njcn.csharmonic.pojo.vo.event.EventStatisticVO">
|
||||
SELECT
|
||||
SUM(CASE WHEN tag = 'Evt_Sys_DipStr' THEN 1 ELSE 0 END) AS eventDown,
|
||||
SUM(CASE WHEN tag = 'Evt_Sys_IntrStr' THEN 1 ELSE 0 END) AS eventOff,
|
||||
SUM(CASE WHEN tag = 'Evt_Sys_SwlStr' THEN 1 ELSE 0 END) AS eventUp,
|
||||
COUNT(*) AS allNum
|
||||
FROM
|
||||
cs_event
|
||||
WHERE
|
||||
type = 0
|
||||
AND start_time BETWEEN #{startTime} AND #{endTime}
|
||||
AND device_id IN
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csharmonic.mapper.CsHarmonicMapper">
|
||||
|
||||
<select id="getHarmonicCounts" resultType="com.njcn.csharmonic.pojo.vo.HarmonicVO">
|
||||
SELECT
|
||||
COUNT(1) AS harmonicNums,
|
||||
COUNT(DISTINCT TIME) AS overDays,
|
||||
COUNT(DISTINCT line_id) AS overLineNums
|
||||
FROM
|
||||
cs_harmonic
|
||||
WHERE
|
||||
TIME BETWEEN #{startTime} AND #{endTime}
|
||||
AND line_id IN
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getOverDays" resultType="java.lang.String">
|
||||
SELECT
|
||||
DISTINCT time
|
||||
FROM
|
||||
cs_harmonic
|
||||
WHERE
|
||||
TIME BETWEEN #{startTime} AND #{endTime}
|
||||
AND line_id IN
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
order by time asc
|
||||
</select>
|
||||
|
||||
<select id="getLineHarmonicOverDays" resultType="com.njcn.csharmonic.pojo.vo.HarmonicVO$LineHarmonicOverDays">
|
||||
SELECT
|
||||
line_id lineId,
|
||||
GROUP_CONCAT(DISTINCT time ORDER BY time SEPARATOR ', ') AS timeString
|
||||
FROM cs_harmonic
|
||||
WHERE TIME BETWEEN #{startTime} AND #{endTime}
|
||||
AND line_id IN
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
GROUP BY line_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -9,6 +9,7 @@ import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
|
||||
import java.util.List;
|
||||
@@ -46,5 +47,6 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
|
||||
*/
|
||||
List<CsEventUserPO> queryEventListByUserId(String userIndex,List<String> eventList);
|
||||
|
||||
EventStatisticVO queryAppEventCounts(CsEventUserQueryPage csEventUserQueryPage);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csharmonic.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||
import com.njcn.csharmonic.pojo.po.CsAlarm;
|
||||
@@ -17,7 +18,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface ICsAlarmService extends IService<CsAlarm> {
|
||||
|
||||
List<AlarmVO> queryAlarmList(LineParamDTO param);
|
||||
Page<AlarmVO> queryAlarmList(LineParamDTO param);
|
||||
|
||||
List<AlarmVO.AlarmDetail> queryAlarmDetail(LineParamDTO.DevParamDTO param);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csharmonic.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
@@ -18,8 +19,12 @@ import java.util.List;
|
||||
*/
|
||||
public interface ICsHarmonicService extends IService<CsHarmonic> {
|
||||
|
||||
HarmonicVO queryAppList(LineParamDTO param);
|
||||
Page<HarmonicVO.LineHarmonicDetail> queryAppList(LineParamDTO param);
|
||||
|
||||
List<HarmonicDetailVO> queryHarmonicDetail(LineParamDTO param);
|
||||
|
||||
HarmonicVO queryAppHarmonicCounts(LineParamDTO param);
|
||||
|
||||
Page<HarmonicVO.LineHarmonicOverDays> queryAppHarmonicLine(LineParamDTO param);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -53,9 +55,9 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
@Override
|
||||
public List<AlarmVO> queryAlarmList(LineParamDTO param) {
|
||||
List<AlarmVO> result = new ArrayList<>();
|
||||
|
||||
public Page<AlarmVO> queryAlarmList(LineParamDTO param) {
|
||||
Page<AlarmVO> page1 = new Page<>();
|
||||
Page<CsAlarm> page2 = new Page<> (param.getPageNum(), param.getPageSize());
|
||||
List<CsLedger> lineLedger = csLedgerFeignClient.queryLine(param).getData();
|
||||
if (CollectionUtil.isNotEmpty(lineLedger)) {
|
||||
List<CsLedger> devLedger = new ArrayList<>();
|
||||
@@ -69,7 +71,6 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
});
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(devLedger)) {
|
||||
|
||||
List<String> ownerDevList = csCommTerminalFeignClient.getDevIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||
List<String> devList = devLedger.stream().map(CsLedger::getPid).distinct().collect(Collectors.toList());
|
||||
|
||||
@@ -87,14 +88,16 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
queryWrapper.ge(StrUtil.isNotBlank(param.getTime()), CsAlarm::getTime, calculateMonthStart(param.getTime()))
|
||||
.le(StrUtil.isNotBlank(param.getTime()), CsAlarm::getTime, calculateMonthEnd(param.getTime()))
|
||||
.orderByDesc(CsAlarm::getTime);
|
||||
//先获取设备通讯数据
|
||||
List<CsAlarm> list = list(queryWrapper);
|
||||
Page<CsAlarm> csAlarmPage = this.baseMapper.selectPage(page2,queryWrapper);
|
||||
BeanUtil.copyProperties(csAlarmPage, page1);
|
||||
List<CsAlarm> list = csAlarmPage.getRecords();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
//获取用户推送事件
|
||||
List<CsEventUserPO> userEvents = csEventUserPOService.queryEventListByUserId(RequestUtil.getUserIndex(), list.stream().map(CsAlarm::getId).collect(Collectors.toList()));
|
||||
|
||||
List<String> finalDevList = devList;
|
||||
result = list.stream()
|
||||
List<AlarmVO> result = list.stream()
|
||||
.map(alarm -> {
|
||||
AlarmVO alarmVO = new AlarmVO();
|
||||
alarmVO.setEventId(alarm.getId());
|
||||
@@ -114,10 +117,11 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
.filter(alarmVO -> alarmVO.getWarnNums() > 0)
|
||||
.sorted((a1, a2) -> a2.getDate().compareTo(a1.getDate()))
|
||||
.collect(Collectors.toList());
|
||||
page1.setRecords(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return page1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -499,13 +499,17 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
}
|
||||
|
||||
public List<String> getEventUser(String devId,boolean isAdmin) {
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
||||
List<String> result = new ArrayList<>(list);
|
||||
if (isAdmin) {
|
||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
||||
adminList.addAll(list);
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
||||
result.addAll(adminList);
|
||||
}
|
||||
return adminList;
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result = result.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,10 +7,10 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.NodeFeignClient;
|
||||
@@ -27,8 +27,8 @@ import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.harmonic.utils.PublicDataUtils;
|
||||
import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
||||
import com.njcn.influx.service.EvtDataService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
@@ -68,6 +68,7 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
private final CsEventPOMapper csEventPOMapper;
|
||||
private final NodeFeignClient nodeFeignClient;
|
||||
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
|
||||
@Override
|
||||
public Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam) {
|
||||
@@ -770,4 +771,99 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
queryWrapper.eq(CsEventUserPO::getUserId, userIndex).in(CsEventUserPO::getEventId, eventList);
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventStatisticVO queryAppEventCounts(CsEventUserQueryPage csEventUserQueryPage) {
|
||||
EventStatisticVO result = new EventStatisticVO();
|
||||
csEventUserQueryPage.setUserId(RequestUtil.getUserIndex());
|
||||
String role = RequestUtil.getUserRole();
|
||||
if(Objects.equals(role, LogInfo.UNKNOWN_ROLE)){
|
||||
return result;
|
||||
}
|
||||
List<String> strings = JSONArray.parseArray(role, String.class);
|
||||
if(CollectionUtils.isEmpty(strings)){
|
||||
return result;
|
||||
}
|
||||
role=strings.get(0);
|
||||
if( Objects.equals(role, AppRoleEnum.APP_VIP_USER.getCode())&&Objects.equals(csEventUserQueryPage.getType(),"3")){
|
||||
csEventUserQueryPage.setLevel("3");
|
||||
}
|
||||
List<CsLedgerVO> data = csLedgerFeignClient.lineTree().getData();
|
||||
if (CollectionUtils.isEmpty(data)) {
|
||||
return result;
|
||||
}
|
||||
// 获取第一层节点(根节点),从第二层开始才是真正的工程
|
||||
List<CsLedgerVO> firstLevelNodes = new ArrayList<>();
|
||||
for (CsLedgerVO rootNode : data) {
|
||||
List<CsLedgerVO> children = rootNode.getChildren();
|
||||
if (CollectionUtil.isNotEmpty(children)) {
|
||||
firstLevelNodes.addAll(children);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(firstLevelNodes)) {
|
||||
return result;
|
||||
}
|
||||
// 缓存查询条件到局部变量
|
||||
String engineeringId = csEventUserQueryPage.getEngineeringid();
|
||||
String projectId = csEventUserQueryPage.getProjectId();
|
||||
String deviceId = csEventUserQueryPage.getDeviceId();
|
||||
String lineId = csEventUserQueryPage.getLineId();
|
||||
|
||||
// 从第二层开始遍历:工程 -> 项目 -> 设备 -> 监测点
|
||||
List<String> collect = new ArrayList<>();
|
||||
for (CsLedgerVO engineering : firstLevelNodes) {
|
||||
// 过滤工程
|
||||
if (StringUtil.isNotBlank(engineeringId)
|
||||
&& !Objects.equals(engineering.getId(), engineeringId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<CsLedgerVO> projects = engineering.getChildren();
|
||||
if (CollectionUtils.isEmpty(projects)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CsLedgerVO project : projects) {
|
||||
// 过滤项目
|
||||
if (StringUtil.isNotBlank(projectId)
|
||||
&& !Objects.equals(project.getId(), projectId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<CsLedgerVO> devices = project.getChildren();
|
||||
if (CollectionUtils.isEmpty(devices)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CsLedgerVO device : devices) {
|
||||
// 过滤设备
|
||||
if (StringUtil.isNotBlank(deviceId)
|
||||
&& !Objects.equals(device.getId(), deviceId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 如果传了监测点 ID,需要进一步过滤
|
||||
if (StringUtil.isNotBlank(lineId)) {
|
||||
List<CsLedgerVO> lines = device.getChildren();
|
||||
if (CollectionUtil.isNotEmpty(lines)) {
|
||||
boolean hasLine = lines.stream()
|
||||
.anyMatch(line -> Objects.equals(line.getId(), lineId));
|
||||
if (hasLine) {
|
||||
collect.add(device.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有传监测点 ID,直接添加设备 ID
|
||||
collect.add(device.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
return result;
|
||||
} else {
|
||||
result = baseMapper.getEventCounts(csEventUserQueryPage.getStartTime(),csEventUserQueryPage.getEndTime(),collect);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -30,7 +32,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -46,13 +47,22 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmonic> implements ICsHarmonicService {
|
||||
|
||||
private static final Map<String, String> VALUE_TYPE_MAP = new HashMap<String, String>() {{
|
||||
put("max", "最大值");
|
||||
put("min", "最小值");
|
||||
put("avg", "平均值");
|
||||
put("cp95", "95%概率值");
|
||||
}};
|
||||
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
private final CsEventUserPOService csEventUserPOService;
|
||||
private final IRStatLimitRateDetailDService rStatLimitRateDetailDService;
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
|
||||
@Override
|
||||
public HarmonicVO queryAppList(LineParamDTO param) {
|
||||
public Page<HarmonicVO.LineHarmonicDetail> queryAppList(LineParamDTO param) {
|
||||
Page<HarmonicVO.LineHarmonicDetail> result = new Page<>();
|
||||
Page<CsHarmonic> page = new Page<> (param.getPageNum(), param.getPageSize());
|
||||
HarmonicVO vo = new HarmonicVO();
|
||||
List<CsLedger> lineLedger = csLedgerFeignClient.queryLine(param).getData();
|
||||
if (CollectionUtil.isNotEmpty(lineLedger)) {
|
||||
@@ -73,23 +83,17 @@ public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmo
|
||||
.ge(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthStart(param.getTime()))
|
||||
.le(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthEnd(param.getTime()))
|
||||
.orderByDesc(CsHarmonic::getTime);
|
||||
list = list(queryWrapper);
|
||||
Page<CsHarmonic> csHarmonicPage = this.baseMapper.selectPage(page,queryWrapper);
|
||||
BeanUtil.copyProperties(csHarmonicPage, result);
|
||||
list = csHarmonicPage.getRecords();
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
//获取所有台账数据
|
||||
List<CsLedgerVO> ledgers = csLedgerFeignClient.getAllLedger().getData();
|
||||
Map<String,CsLedgerVO> ledgerMap = ledgers.stream().collect(Collectors.toMap(CsLedgerVO::getId, item->item));
|
||||
|
||||
List<HarmonicVO.LineHarmonicDetail> lineHarmonicDetails = new ArrayList<>();
|
||||
vo.setHarmonicNums(list.size());
|
||||
//获取越限天数
|
||||
Set<LocalDate> distinctTimes = list.stream().map(CsHarmonic::getTime).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
int overDay = distinctTimes.size();
|
||||
vo.setOverDays(overDay);
|
||||
//获取监测点
|
||||
Set<String> distinctLineIds = list.stream().map(CsHarmonic::getLineId).collect(Collectors.toSet());
|
||||
int overLine = distinctLineIds.size();
|
||||
vo.setOverLineNums(overLine);
|
||||
//获取用户推送事件
|
||||
List<CsEventUserPO> userEvents = csEventUserPOService.queryEventListByUserId(RequestUtil.getUserIndex(), list.stream().map(CsHarmonic::getId).collect(Collectors.toList()));
|
||||
list.forEach(item->{
|
||||
@@ -107,9 +111,10 @@ public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmo
|
||||
lineHarmonicDetails.add(lineHarmonicDetail);
|
||||
});
|
||||
vo.setList(lineHarmonicDetails);
|
||||
result.setRecords(lineHarmonicDetails);
|
||||
}
|
||||
}
|
||||
return vo;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,6 +161,85 @@ public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmo
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarmonicVO queryAppHarmonicCounts(LineParamDTO param) {
|
||||
HarmonicVO vo = new HarmonicVO();
|
||||
List<CsLedger> lineLedger = csLedgerFeignClient.queryLine(param).getData();
|
||||
if (CollectionUtil.isNotEmpty(lineLedger)) {
|
||||
List<String> lineIds = lineLedger.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
//根据用户获取设备数据权限
|
||||
List<String> ownerList = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||
List<String> combinedLineIds = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(ownerList)) {
|
||||
combinedLineIds = lineIds.stream()
|
||||
.filter(ownerList::contains)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(combinedLineIds)) {
|
||||
//查询数量
|
||||
vo = this.baseMapper.getHarmonicCounts(
|
||||
PublicDataUtils.calculateMonthStart(param.getTime())
|
||||
,PublicDataUtils.calculateMonthEnd(param.getTime())
|
||||
,combinedLineIds);
|
||||
//查询日期
|
||||
List<String> overDays = this.baseMapper.getOverDays(
|
||||
PublicDataUtils.calculateMonthStart(param.getTime())
|
||||
,PublicDataUtils.calculateMonthEnd(param.getTime())
|
||||
,combinedLineIds);
|
||||
vo.setOverDaysList(overDays);
|
||||
}
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<HarmonicVO.LineHarmonicOverDays> queryAppHarmonicLine(LineParamDTO param) {
|
||||
Page<HarmonicVO.LineHarmonicOverDays> page = new Page<> (param.getPageNum(), param.getPageSize());
|
||||
List<CsLedger> lineLedger = csLedgerFeignClient.queryLine(param).getData();
|
||||
if (CollectionUtil.isNotEmpty(lineLedger)) {
|
||||
List<String> lineIds = lineLedger.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
//根据用户获取设备数据权限
|
||||
List<String> ownerList = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||
List<String> combinedLineIds = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(ownerList)) {
|
||||
combinedLineIds = lineIds.stream()
|
||||
.filter(ownerList::contains)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(combinedLineIds)) {
|
||||
page = this.baseMapper.getLineHarmonicOverDays(page
|
||||
,PublicDataUtils.calculateMonthStart(param.getTime())
|
||||
,PublicDataUtils.calculateMonthEnd(param.getTime())
|
||||
,combinedLineIds);
|
||||
List<HarmonicVO.LineHarmonicOverDays> lineHarmonicOverDays = page.getRecords();
|
||||
if (CollectionUtil.isNotEmpty(lineHarmonicOverDays)) {
|
||||
//获取所有台账数据
|
||||
List<CsLedgerVO> ledgers = csLedgerFeignClient.getAllLedger().getData();
|
||||
Map<String,CsLedgerVO> ledgerMap = ledgers.stream().collect(Collectors.toMap(CsLedgerVO::getId, item->item));
|
||||
lineHarmonicOverDays.forEach(item->{
|
||||
CsLedger ledger = lineLedger.stream().filter(item1->item1.getId().equals(item.getLineId())).findFirst().orElse(null);
|
||||
item.setEngineeringName(ledgerMap.get(ledger.getPids().split(",")[1]).getName());
|
||||
item.setProjectName(ledgerMap.get(ledger.getPids().split(",")[2]).getName());
|
||||
item.setDevName(ledgerMap.get(ledger.getPids().split(",")[3]).getName());
|
||||
item.setLineId(item.getLineId());
|
||||
item.setLineName(ledger.getName());
|
||||
item.setTimeList(Arrays.asList(item.getTimeString().split(", ")));
|
||||
});
|
||||
//对告警天数进行降序排序
|
||||
lineHarmonicOverDays.sort((item1, item2) -> {
|
||||
int size1 = item1.getTimeList() != null ? item1.getTimeList().size() : 0;
|
||||
int size2 = item2.getTimeList() != null ? item2.getTimeList().size() : 0;
|
||||
return Integer.compare(size2, size1);
|
||||
});
|
||||
page.setRecords(lineHarmonicOverDays);
|
||||
}
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加谐波数据到列表
|
||||
@@ -221,7 +305,7 @@ public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmo
|
||||
detail.setDataB(formatValue(values.get("B")));
|
||||
detail.setDataC(formatValue(values.get("C")));
|
||||
detail.setDataT(formatValue(values.get("T")));
|
||||
detail.setValueType(phaseDataList.get(0).valueType);
|
||||
detail.setValueType(VALUE_TYPE_MAP.get(phaseDataList.get(0).valueType));
|
||||
detail.setOverLimitData(phaseDataList.get(0).overLimitValue);
|
||||
detail.setHasT(values.containsKey("T"));
|
||||
allDetails.add(detail);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
|
||||
import com.njcn.csdevice.pojo.po.CsUserPins;
|
||||
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
|
||||
import com.njcn.csdevice.pojo.vo.EngineeringHomePageVO;
|
||||
import com.njcn.csharmonic.mapper.CsEventUserPOMapper;
|
||||
import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.csharmonic.service.HomePageService;
|
||||
@@ -30,7 +31,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class HomePageServiceImpl implements HomePageService {
|
||||
|
||||
private final CsEventUserPOService csEventUserPOService;
|
||||
private final CsEventUserPOMapper csEventUserPOMapper;
|
||||
private final EngineeringFeignClient engineeringFeignClient;
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
private final CsUserPinsFeignClient csUserPinsFeignClient;
|
||||
@@ -48,11 +49,6 @@ public class HomePageServiceImpl implements HomePageService {
|
||||
Map<String, List<DevDetailDTO>> devMap = Objects.isNull(devList) ? new HashMap<>() :
|
||||
devList.stream().collect(Collectors.groupingBy(DevDetailDTO::getEngineeringid));
|
||||
|
||||
// 获取未读事件
|
||||
List<UnReadEventDto> unReadEventList = csEventUserPOService.queryEngineeringEventCount(RequestUtil.getUserIndex());
|
||||
Map<String, List<UnReadEventDto>> unReadEventMap = Objects.isNull(unReadEventList) ? new HashMap<>() :
|
||||
unReadEventList.stream().collect(Collectors.groupingBy(UnReadEventDto::getDeviceId));
|
||||
|
||||
// 遍历工程列表,从内存中获取设备数据
|
||||
engineeringList.forEach(item -> {
|
||||
EngineeringHomePageVO vo = new EngineeringHomePageVO();
|
||||
@@ -69,19 +65,26 @@ public class HomePageServiceImpl implements HomePageService {
|
||||
vo.setOfflineDevTotal((int) status1Count);
|
||||
vo.setSort(item.getSort());
|
||||
|
||||
// 未读的告警数量
|
||||
int alarmTotal = Objects.isNull(devs) ? 0 : devs.stream()
|
||||
.map(DevDetailDTO::getEquipmentId)
|
||||
.filter(Objects::nonNull)
|
||||
.mapToInt(deviceId -> {
|
||||
List<UnReadEventDto> events = unReadEventMap.get(deviceId);
|
||||
return Objects.isNull(events) ? 0 : events.stream()
|
||||
.mapToInt(UnReadEventDto::getCount)
|
||||
.sum();
|
||||
})
|
||||
.sum();
|
||||
vo.setAlarmTotal(alarmTotal);
|
||||
// 获取项目事件数量
|
||||
int alarmTotal = 0;
|
||||
if (CollectionUtil.isNotEmpty(devs) && !Objects.isNull(devs)) {
|
||||
// 获取暂态未读事件
|
||||
List<String> allLineIds = devs.stream()
|
||||
.filter(dev -> CollectionUtil.isNotEmpty(dev.getLineList()))
|
||||
.flatMap(dev -> dev.getLineList().stream())
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> tempEventList = csEventUserPOMapper.queryTempEvent(RequestUtil.getUserIndex(),"","",allLineIds);
|
||||
alarmTotal = alarmTotal + (CollectionUtil.isNotEmpty(tempEventList)?tempEventList.size():0);
|
||||
|
||||
// 获取稳态未读事件
|
||||
if (CollectionUtil.isNotEmpty(allLineIds)) {
|
||||
List<String> tempHarmonicList = csEventUserPOMapper.queryTempHarmonic(RequestUtil.getUserIndex(),"","",allLineIds);
|
||||
alarmTotal = alarmTotal + (CollectionUtil.isNotEmpty(tempHarmonicList)?tempHarmonicList.size():0);
|
||||
}
|
||||
}
|
||||
vo.setAlarmTotal(alarmTotal);
|
||||
result.add(vo);
|
||||
});
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
//判断设备类型 治理无线设备需要判断mqtt、云前置设备直接判断设备运行状态
|
||||
CsEquipmentDeliveryPO dev = equipmentFeignClient.getDevByLineId(lineId).getData();
|
||||
String devModelCode = dictTreeFeignClient.queryById(dev.getDevType()).getData().getCode();
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode) && Objects.equals(dev.getDevAccessMethod(),"CLD")) {
|
||||
if (dev.getRunStatus() == 1) {
|
||||
throw new BusinessException("装置离线");
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
//获取装置所用模板
|
||||
CsLinePO po = csLineFeignClient.getById(lineId).getData();
|
||||
String modelId = po.getDataModelId();
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode) && Objects.equals(dev.getDevAccessMethod(),"CLD")) {
|
||||
CsDataSet csDataSet = dataSetFeignClient.getBaseDataSet(modelId,1).getData();
|
||||
askDeviceDataFeignClient.askCldRealData(dev.getId(),lineId,dev.getNodeId(),csDataSet.getIdx());
|
||||
updateRedisUserSet("rtDataUserId:" + lineId, RequestUtil.getUserIndex(), 600L);
|
||||
@@ -76,7 +76,7 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
//等待装置响应,获取询问结果
|
||||
Thread.sleep(5000);
|
||||
Object object;
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode) && Objects.equals(dev.getDevAccessMethod(),"CLD")) {
|
||||
object = redisUtil.getObjectByKey("devResponse:" + lineId);
|
||||
} else {
|
||||
object = redisUtil.getObjectByKey("devResponse");
|
||||
@@ -105,7 +105,7 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
//判断设备类型 治理无线设备需要判断mqtt、云前置设备直接判断设备运行状态
|
||||
CsEquipmentDeliveryPO dev = equipmentFeignClient.getDevByLineId(lineId).getData();
|
||||
String devModelCode = dictTreeFeignClient.queryById(dev.getDevType()).getData().getCode();
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode) && Objects.equals(dev.getDevAccessMethod(),"CLD")) {
|
||||
if (dev.getRunStatus() == 1) {
|
||||
throw new BusinessException("装置离线");
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
CsLinePO po = csLineFeignClient.getById(lineId).getData();
|
||||
String modelId = po.getDataModelId();
|
||||
//根据指标来获取不同的数据集
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode) && Objects.equals(dev.getDevAccessMethod(),"CLD")) {
|
||||
CsDataSet csDataSet = dataSetFeignClient.getHarmonicDataSet(modelId,1,target).getData();
|
||||
askDeviceDataFeignClient.askCldRealData(dev.getId(),lineId,dev.getNodeId(),csDataSet.getIdx());
|
||||
} else {
|
||||
@@ -131,7 +131,7 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
//等待装置响应,获取询问结果
|
||||
Thread.sleep(2000);
|
||||
Object object;
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode) && Objects.equals(dev.getDevAccessMethod(),"CLD")) {
|
||||
object = redisUtil.getObjectByKey("devResponse:" + lineId);
|
||||
} else {
|
||||
object = redisUtil.getObjectByKey("devResponse");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csreport.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -71,9 +72,9 @@ public class CsAppReportController extends BaseController {
|
||||
@PostMapping("/getApplicationReport")
|
||||
@ApiOperation("查询暂态报告申请记录")
|
||||
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
|
||||
public HttpResult<List<ReportEventVO>> getApplicationReportList(@RequestBody LineParamDTO param) {
|
||||
public HttpResult<Page<ReportEventVO>> getApplicationReportList(@RequestBody LineParamDTO param) {
|
||||
String methodDescribe = getMethodDescribe("getApplicationReportList");
|
||||
List<ReportEventVO> result = csAppReportService.getApplicationReportList(param);
|
||||
Page<ReportEventVO> result = csAppReportService.getApplicationReportList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csreport.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||
import com.njcn.csreport.pojo.po.CsAppReport;
|
||||
@@ -24,7 +25,7 @@ public interface ICsAppReportService extends IService<CsAppReport> {
|
||||
|
||||
void applicationReport(LineParamDTO param);
|
||||
|
||||
List<ReportEventVO> getApplicationReportList(LineParamDTO param);
|
||||
Page<ReportEventVO> getApplicationReportList(LineParamDTO param);
|
||||
|
||||
Boolean createEventReport(String id);
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.njcn.csreport.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
@@ -22,7 +24,9 @@ import com.njcn.csharmonic.api.SysExcelRelationFeignClient;
|
||||
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
|
||||
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
|
||||
import com.njcn.csharmonic.pojo.vo.HarmonicVO;
|
||||
import com.njcn.csreport.mapper.CsAppReportMapper;
|
||||
import com.njcn.csreport.pojo.po.CsAppReport;
|
||||
import com.njcn.csreport.pojo.vo.ReportEventVO;
|
||||
@@ -52,10 +56,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -97,12 +102,11 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
if (param.getTimeType() == 0) {
|
||||
timeRanges = splitIntoDays(startLocalDate, endLocalDate);
|
||||
} else {
|
||||
timeRanges = splitIntoMonths(startLocalDate, endLocalDate);
|
||||
timeRanges = splitIntoMonthsForCurrentYear(endLocalDate);
|
||||
}
|
||||
|
||||
String queryStartTime = timeRanges.get(timeRanges.size() - 1).end.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
String queryEndTime = timeRanges.get(0).start.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
|
||||
String queryStartTime = timeRanges.get(timeRanges.size() - 1).start.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
String queryEndTime = timeRanges.get(0).end.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
|
||||
StatSubstationBizBaseParam rStatLimitQueryParam = new StatSubstationBizBaseParam();
|
||||
rStatLimitQueryParam.setIds(Collections.singletonList(param.getLineId()));
|
||||
@@ -200,7 +204,11 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportEventVO> getApplicationReportList(LineParamDTO param) {
|
||||
public Page<ReportEventVO> getApplicationReportList(LineParamDTO param) {
|
||||
Page<ReportEventVO> page = new Page<>();
|
||||
Page<CsAppReport> page1 = new Page<> (param.getPageNum(), param.getPageSize());
|
||||
|
||||
|
||||
List<ReportEventVO> result = new ArrayList<>();
|
||||
LambdaQueryWrapper<CsAppReport> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(CsAppReport::getCreateTime, param.getStartTime(), param.getEndTime())
|
||||
@@ -211,7 +219,11 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
if (!userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) && !userVO.getType().equals(UserType.ADMINISTRATOR)) {
|
||||
queryWrapper.eq(CsAppReport::getCreateBy, userVO.getId());
|
||||
}
|
||||
List<CsAppReport> list = this.list(queryWrapper);
|
||||
Page<CsAppReport> page2 = this.baseMapper.selectPage(page1,queryWrapper);
|
||||
BeanUtil.copyProperties(page2, page);
|
||||
List<CsAppReport> list = page2.getRecords();
|
||||
|
||||
// List<CsAppReport> list = this.list(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
list.forEach(item->{
|
||||
ReportEventVO vo = new ReportEventVO();
|
||||
@@ -235,9 +247,10 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
vo.setEngineeringName(devDetailDTO.getEngineeringName());
|
||||
|
||||
result.add(vo);
|
||||
page.setRecords(result);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,6 +284,7 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
List<CsLinePO> lineList = csLineFeignClient.queryLineById(lineIdList).getData();
|
||||
Map<String,CsLinePO> lineMap = lineList.stream().collect(Collectors.toMap(CsLinePO::getLineId, item->item));
|
||||
Map<String, AreaLineInfoVO> map = new HashMap<>();
|
||||
AtomicReference<String> lineName = new AtomicReference<>();
|
||||
eventList.forEach(item->{
|
||||
CsLinePO po = lineMap.get(item.getLineId());
|
||||
AreaLineInfoVO vo = new AreaLineInfoVO();
|
||||
@@ -281,6 +295,7 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
vo.setIp(devDetailDTO.getDevMac());
|
||||
vo.setLineId(po.getLineId());
|
||||
vo.setNum(Objects.isNull(po.getLineNo())?po.getClDid():po.getLineNo());
|
||||
lineName.set(po.getName());
|
||||
vo.setLineName(po.getName());
|
||||
vo.setPt1(po.getPtRatio().intValue());
|
||||
vo.setPt2(Objects.isNull(po.getPt2Ratio())?1:po.getPt2Ratio().intValue());
|
||||
@@ -290,7 +305,8 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
map.put(item.getId(),vo);
|
||||
});
|
||||
//step2: 生成事件报告
|
||||
String filePath = commMonitorEventReportService.saveStableEventReport(eventIdList,map);
|
||||
String fileName = "暂降事件报告_" + lineName.get() + LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN)) + ".docx";
|
||||
String filePath = commMonitorEventReportService.saveStableEventReport(eventIdList,map,fileName);
|
||||
//step3: 存储文件服务器
|
||||
report.setFilePath(filePath);
|
||||
return this.updateById(report);
|
||||
@@ -382,39 +398,27 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
return ranges;
|
||||
}
|
||||
|
||||
private List<TimeRange> splitIntoWeeks(LocalDate startDate, LocalDate endDate) {
|
||||
List<TimeRange> weekRanges = new java.util.ArrayList<>();
|
||||
LocalDate currentStart = startDate;
|
||||
private List<TimeRange> splitIntoMonthsForCurrentYear(LocalDate endDate) {
|
||||
List<TimeRange> timeRanges = new ArrayList<>();
|
||||
LocalDate now = LocalDate.now();
|
||||
int currentYear = now.getYear();
|
||||
|
||||
while (!currentStart.isAfter(endDate)) {
|
||||
LocalDate currentEnd = currentStart.with(DayOfWeek.SUNDAY);
|
||||
if (currentEnd.isAfter(endDate)) {
|
||||
currentEnd = endDate;
|
||||
for (int month = now.getMonthValue(); month >= 1; month--) {
|
||||
LocalDate monthStart = LocalDate.of(currentYear, month, 1);
|
||||
LocalDate monthEnd;
|
||||
|
||||
if (month == now.getMonthValue()) {
|
||||
monthEnd = now;
|
||||
} else {
|
||||
monthEnd = monthStart.withDayOfMonth(monthStart.lengthOfMonth());
|
||||
}
|
||||
weekRanges.add(new TimeRange(currentStart, currentEnd));
|
||||
currentStart = currentEnd.plusDays(1);
|
||||
|
||||
timeRanges.add(new TimeRange(monthStart, monthEnd));
|
||||
}
|
||||
|
||||
return weekRanges;
|
||||
}
|
||||
|
||||
|
||||
private List<TimeRange> splitIntoMonths(LocalDate startDate, LocalDate endDate) {
|
||||
List<TimeRange> timeRanges = new java.util.ArrayList<>();
|
||||
LocalDate currentStart = startDate.withDayOfMonth(1);
|
||||
|
||||
while (!currentStart.isAfter(endDate)) {
|
||||
LocalDate currentEnd = currentStart.withDayOfMonth(currentStart.lengthOfMonth());
|
||||
if (currentEnd.isAfter(endDate)) {
|
||||
currentEnd = endDate;
|
||||
}
|
||||
timeRanges.add(new TimeRange(currentStart, currentEnd));
|
||||
currentStart = currentEnd.plusDays(1);
|
||||
}
|
||||
|
||||
return timeRanges;
|
||||
}
|
||||
|
||||
|
||||
//fixme 代码较为冗余,后期可以采用反射的方式进行优化
|
||||
private String buildOverLimitDesc(List<RStatLimitRateDPO> dataList) {
|
||||
String tag = "";
|
||||
|
||||
Reference in New Issue
Block a user