北京暂降平台调整

This commit is contained in:
cdf
2025-08-19 08:42:45 +08:00
parent e1872d030a
commit cd7ae5d06c
19 changed files with 687 additions and 94 deletions

View File

@@ -20,7 +20,7 @@ public interface PqLineMapper extends BaseMapper<PqLine> {
List<LedgerBaseInfoDTO> getBaseLineInfo(@Param("ids")List<Integer> ids);
List<LedgerBaseInfoDTO> getBaseLedger(@Param("ids")List<Integer> ids);
List<LedgerBaseInfoDTO> getBaseLedger(@Param("ids")List<Integer> ids,@Param("searchValue")String searchValue);
List<Integer> getRunMonitorIds(@Param("ids")List<Integer> ids);

View File

@@ -80,11 +80,19 @@ where 1=1
inner JOIN pq_device on PQ_SUBVOLTAGE.DEV_INDEX = pq_device.DEV_INDEX
inner JOIN PQ_SUBSTATION on pq_device.SUB_INDEX = PQ_SUBSTATION.SUB_INDEX
inner JOIN PQ_GDINFORMATION on pq_line.GD_INDEX =PQ_GDINFORMATION.GD_INDEX
where 1=1
<where>
and pq_line.line_index in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="searchValue!=null and searchValue!=''">
and (
PQ_GDINFORMATION.name LIKE '%' || #{searchValue} || '%'
or PQ_SUBSTATION.name LIKE '%' || #{searchValue} || '%'
or pq_line.name LIKE '%' || #{searchValue} || '%'
)
</if>
</where>
</select>
<select id="getRunMonitorIds" resultType="integer">

View File

@@ -4,6 +4,7 @@ import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.devcie.pojo.po.PqLine;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -20,5 +21,5 @@ public interface PqLineService extends IService<PqLine>{
List<LedgerBaseInfoDTO> getBaseLineInfo(List<Integer> ids);
List<LedgerBaseInfoDTO> getBaseLedger(List<Integer> ids);
List<LedgerBaseInfoDTO> getBaseLedger(@Param("ids") List<Integer> ids, @Param("searchValue") String searchValue);
}

View File

@@ -47,7 +47,7 @@ public class PqLineServiceImpl extends ServiceImpl<PqLineMapper, PqLine> impleme
}
@Override
public List<LedgerBaseInfoDTO> getBaseLedger(List<Integer> ids) {
public List<LedgerBaseInfoDTO> getBaseLedger(List<Integer> ids,String searchValue) {
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = new ArrayList<>();
if(CollectionUtils.isEmpty(ids)){
@@ -56,11 +56,11 @@ public class PqLineServiceImpl extends ServiceImpl<PqLineMapper, PqLine> impleme
if(ids.size()>1000){
List<List<Integer>> listIds = CollUtil.split(ids,1000);
for(List<Integer> itemIds : listIds){
List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLedger(itemIds);
List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLedger(itemIds,searchValue);
ledgerBaseInfoDTOS.addAll(temp);
}
}else {
List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLedger(ids);
List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLedger(ids,searchValue);
ledgerBaseInfoDTOS.addAll(temp);
}
return ledgerBaseInfoDTOS;

View File

@@ -82,8 +82,6 @@ public class EventGateController extends BaseController {
private final MsgEventConfigService msgEventConfigService;
private final PqsEventdetailService pqsEventdetailService;
private final MsgEventInfoService msgEventInfoService;
private final RedisUtil redisUtil;
@@ -104,7 +102,7 @@ public class EventGateController extends BaseController {
//下面一行代码正式环境需要放开
//jsonObject = test();
if (msgEventConfigService.getEventType().contains(jsonObject.get("wavetype").toString())) {
if (msgEventConfigService.getEventType().contains(jsonObject.get("wavetype").toString()) &&Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue()) {
//过滤重要暂降事件
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getLineIndex,lineId));
@@ -171,7 +169,7 @@ public class EventGateController extends BaseController {
//下面一行代码正式环境需要放开
jsonObject = test();
if (msgEventConfigService.getEventType().contains(jsonObject.get("wavetype").toString())) {
if (msgEventConfigService.getEventType().contains(jsonObject.get("wavetype").toString()) &&Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue()) {
webSocketServer.sendMessageToAll(jsonObject.toString());
//开始发送短信

View File

@@ -17,6 +17,7 @@ import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.devcie.pojo.po.PqGdCompany;
import com.njcn.gather.event.devcie.pojo.po.PqLine;
import com.njcn.gather.event.devcie.pojo.po.PqSubstation;
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
import com.njcn.gather.event.devcie.service.PqsDeptslineService;
import com.njcn.gather.event.transientes.pojo.param.LargeScreenCountParam;
@@ -68,7 +69,7 @@ public class EventRightController extends BaseController {
@ApiImplicitParam(name = "largeScreenCountParam", value = "", required = true)
public HttpResult<Object> rightEvent(@RequestBody LargeScreenCountParam largeScreenCountParam) {
String methodDescribe = getMethodDescribe("rightEvent");
UserLedgerStatisticVO userLedgerStatisticVO = eventRightService.userLedgerStatistic(largeScreenCountParam);
UserLedgerStatisticVO userLedgerStatisticVO = eventRightService.userLedgerStatisticClone(largeScreenCountParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userLedgerStatisticVO, methodDescribe);
}
@@ -89,10 +90,31 @@ public class EventRightController extends BaseController {
@ApiImplicitParam(name = "largeScreenCountParam", value = "", required = true)
public HttpResult<Object> rightEventOpen(@RequestBody LargeScreenCountParam largeScreenCountParam) {
String methodDescribe = getMethodDescribe("rightEventOpen");
Page<PqUserLedgerPO> page = eventRightService.rightEventOpenClone(largeScreenCountParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo
@PostMapping("/rightEventOpenClone")
@ApiOperation("右侧表头点击事件")
@ApiImplicitParam(name = "largeScreenCountParam", value = "", required = true)
public HttpResult<Object> rightEventOpenClone(@RequestBody LargeScreenCountParam largeScreenCountParam) {
String methodDescribe = getMethodDescribe("rightEventOpenClone");
Page<EventDetailVO> page = eventRightService.rightEventOpen(largeScreenCountParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo
@PostMapping("/rightEventOpenForDetail")
@ApiOperation("右侧表头点击事件")
@ApiImplicitParam(name = "largeScreenCountParam", value = "", required = true)
public HttpResult<Object> rightEventOpenForDetail(@RequestBody LargeScreenCountParam largeScreenCountParam) {
String methodDescribe = getMethodDescribe("rightEventOpenForDetail");
Page<EventDetailVO> page = eventRightService.rightEventOpenForDetail(largeScreenCountParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo
@PostMapping("/rightEventDevOpen")
@@ -105,6 +127,17 @@ public class EventRightController extends BaseController {
}
@OperateInfo
@PostMapping("/rightImportOpenDetail")
@ApiOperation("右侧表头终端点击事件")
@ApiImplicitParam(name = "largeScreenCountParam", value = "", required = true)
public HttpResult<Object> rightImportOpenDetail(@RequestBody LargeScreenCountParam largeScreenCountParam) {
String methodDescribe = getMethodDescribe("rightImportOpenDetail");
PqUserLedgerPO po = eventRightService.rightImportOpenDetail(largeScreenCountParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@GetMapping("gdSelect")
public HttpResult<List<PqGdCompany>> gdSelect() {
String methodDescribe = getMethodDescribe("gdSelect");
@@ -112,4 +145,12 @@ public class EventRightController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@GetMapping("bdSelect")
public HttpResult<List<PqSubstation>> bdSelect() {
String methodDescribe = getMethodDescribe("bdSelect");
List<PqSubstation> list = eventRightService.bdSelect();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -36,35 +36,35 @@ public class JwtRequestFilter extends OncePerRequestFilter {
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
// final String authorizationHeader = request.getHeader("Authorization");
// String username = null;
// String jwt = null;
// if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
// jwt = authorizationHeader.substring(7);
// try {
// username = jwtUtil.extractUsername(jwt);
// } catch (ExpiredJwtException e) {
// log.error(e.getMessage());
// sendErrorResponse(response,CommonResponseEnum.TOKEN_EXPIRE_JWT);
// return;
// } catch (Exception e) {
// log.error(e.getMessage());
// sendErrorResponse(response,CommonResponseEnum.PARSE_TOKEN_ERROR);
// return;
// }
// }
//
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
// UserDetails userDetails = this.userDetailsService.loadUserByUsername(username);
//
// if (jwtUtil.validateToken(jwt, userDetails)) {
// UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
// new UsernamePasswordAuthenticationToken(
// userDetails, null, userDetails.getAuthorities());
// usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
// SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
// }
// }
/* final String authorizationHeader = request.getHeader("Authorization");
String username = null;
String jwt = null;
if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
jwt = authorizationHeader.substring(7);
try {
username = jwtUtil.extractUsername(jwt);
} catch (ExpiredJwtException e) {
log.error(e.getMessage());
sendErrorResponse(response,CommonResponseEnum.TOKEN_EXPIRE_JWT);
return;
} catch (Exception e) {
log.error(e.getMessage());
sendErrorResponse(response,CommonResponseEnum.PARSE_TOKEN_ERROR);
return;
}
}
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
UserDetails userDetails = this.userDetailsService.loadUserByUsername(username);
if (jwtUtil.validateToken(jwt, userDetails)) {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(
userDetails, null, userDetails.getAuthorities());
usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
}
}*/
chain.doFilter(request, response);
}

View File

@@ -2,6 +2,13 @@ package com.njcn.gather.event.transientes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.gather.event.transientes.pojo.po.PqUserLedgerPO;
import com.njcn.gather.event.transientes.pojo.po.PqUserLineAssPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface PqUserLedgerMapper extends BaseMapper<PqUserLedgerPO> {
List<PqUserLineAssPO> getUserByParam(@Param("lineIds") List<Integer> lineIds, @Param("searchValue")String searchValue);
}

View File

@@ -0,0 +1,17 @@
<?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.gather.event.transientes.mapper.PqUserLedgerMapper">
<select id="getUserByParam" resultType="PqUserLineAssPO">
select distinct b.line_index,a.CUSTOMER_NAME userName
from pq_user_ledger a inner join PQ_USER_LINE_ASS b on a.id = b.user_index
where b.line_index in
<foreach collection="lineIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
<if test="searchValue!=null and searchValue!=''">
and a.CUSTOMER_NAME LIKE '%' || #{searchValue} || '%'
</if>
</select>
</mapper>

View File

@@ -47,5 +47,17 @@ public class LargeScreenCountParam extends BaseParam {
private Integer gdIndex;
private Integer bdId;
private String devName;
private Float eventValueMin;
private Float eventValueMax;
private Float eventDurationMin;
private Float eventDurationMax;
}

View File

@@ -12,6 +12,7 @@ import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
@@ -22,6 +23,7 @@ import javax.validation.constraints.NotNull;
*/
@Data
@TableName("MSG_EVENT_CONFIG")
@ToString
public class MsgEventConfig implements Serializable {
private static final long serialVersionUID = 1L;
@@ -59,9 +61,25 @@ public class MsgEventConfig implements Serializable {
@NotNull(message = "屏幕通知标识不可为空")
private Integer screenNotic;
/**
* 暂降类型,以逗号隔开
*/
private String eventType;
/**
* 暂降残余电压告警阈值
*/
private Float eventValue;
/**
* 暂降持续时间告警阈值
*/
private Integer eventDuration;
@NotEmpty(message = "事件类型不可为空")
@TableField(exist = false)
private List<String> eventTypeList;
}

View File

@@ -8,6 +8,7 @@ import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
* @Author: cdf
@@ -87,6 +88,18 @@ public class PqUserLedgerPO implements Serializable {
@TableField(exist = false)
private Integer eventCount = 0;
@TableField(exist = false)
private List<String> eventIds;
@TableField(exist = false)
private String deptName;
@TableField(exist = false)
private String gdName;
@TableField(exist = false)
private String station;
@TableField(exist = false)
private String info;

View File

@@ -19,4 +19,8 @@ public class PqUserLineAssPO {
@TableField(value = "LINE_INDEX")
private Integer lineIndex;
@TableField(exist = false)
private String userName;
}

View File

@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.po.PqGdCompany;
import com.njcn.gather.event.devcie.pojo.po.PqSubstation;
import com.njcn.gather.event.transientes.pojo.param.LargeScreenCountParam;
import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam;
import com.njcn.gather.event.transientes.pojo.param.PqUserLedgerParam;
import com.njcn.gather.event.transientes.pojo.po.PqUserLedgerPO;
import com.njcn.gather.event.transientes.pojo.po.PqsDepts;
import com.njcn.gather.event.transientes.pojo.vo.EventDetailVO;
import com.njcn.gather.event.transientes.pojo.vo.UserLedgerStatisticVO;
@@ -21,6 +23,8 @@ public interface EventRightService {
Page<EventDetailVO> rightEventOpen(LargeScreenCountParam param);
Page<EventDetailVO> rightEventOpenForDetail(LargeScreenCountParam param);
Page<PqUserLedgerPO> rightEventDevOpen(LargeScreenCountParam param);
@@ -30,5 +34,20 @@ public interface EventRightService {
List<UserLedgerStatisticVO.Inner> rightImportUser(LargeScreenCountParam param);
PqUserLedgerPO rightImportOpenDetail(LargeScreenCountParam param);
List<PqGdCompany> gdSelect();
List<PqSubstation> bdSelect();
/*-------------------------------------------------------*/
UserLedgerStatisticVO userLedgerStatisticClone(LargeScreenCountParam param);
Page<PqUserLedgerPO> rightEventOpenClone(LargeScreenCountParam param);
}

View File

@@ -13,4 +13,8 @@ public interface MsgEventConfigService extends IService<MsgEventConfig> {
MsgEventConfig queryConfig();
List<String> getEventType();
Float getEventValue();
Integer getEventDuration();
}

View File

@@ -14,11 +14,9 @@ import com.njcn.gather.event.devcie.mapper.PqGdCompanyMapper;
import com.njcn.gather.event.devcie.mapper.PqSubstationMapper;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.devcie.pojo.po.PqDevice;
import com.njcn.gather.event.devcie.pojo.po.PqGdCompany;
import com.njcn.gather.event.devcie.pojo.po.PqLine;
import com.njcn.gather.event.devcie.pojo.po.PqSubstation;
import com.njcn.gather.event.devcie.pojo.po.*;
import com.njcn.gather.event.devcie.service.PqLineService;
import com.njcn.gather.event.devcie.service.PqsDeptslineService;
import com.njcn.gather.event.transientes.mapper.PqUserLedgerMapper;
import com.njcn.gather.event.transientes.mapper.PqUserLineAssMapper;
import com.njcn.gather.event.transientes.mapper.PqsDicTreeMapper;
@@ -34,6 +32,7 @@ import com.njcn.web.factory.PageFactory;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -73,6 +72,11 @@ public class EventRightServiceImpl implements EventRightService {
private final PqGdCompanyMapper pqGdCompanyMapper;
private final PqsDeptslineService pqsDeptslineService;
private final PqsDeptsService pqsDeptsService;
@Value("${SYS_TYPE_ZT}")
private String sysTypeZt;
@@ -146,7 +150,7 @@ public class EventRightServiceImpl implements EventRightService {
private List<PqUserLineAssPO> getUserLineAssociations(List<Integer> lineIds){
LambdaQueryWrapper<PqUserLineAssPO> assQuery = new LambdaQueryWrapper<>();
assQuery.in(PqUserLineAssPO::getLineIndex, lineIds);
// assQuery.in(PqUserLineAssPO::getLineIndex, lineIds);
if(lineIds.size()>1000){
List<List<Integer>> lineList = CollUtil.split(lineIds, 1000);
@@ -166,7 +170,9 @@ public class EventRightServiceImpl implements EventRightService {
//查询时间段的暂降事件
LambdaQueryWrapper<PqsEventdetail> eventQuery = new LambdaQueryWrapper<>();
eventQuery.between(PqsEventdetail::getTimeid, DateUtil.parse(param.getSearchBeginTime()), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType());
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration());
if (lineIds.size() > 1000) {
List<List<Integer>> listLineIds = CollUtil.split(lineIds, 1000);
eventQuery.and(w -> {
@@ -208,6 +214,9 @@ public class EventRightServiceImpl implements EventRightService {
if(Objects.nonNull(param.getGdIndex())){
userWrapper.eq(PqUserLedgerPO::getPowerSupplyArea,param.getGdIndex());
}
if(StrUtil.isNotBlank(param.getSearchValue())){
userWrapper.like(PqUserLedgerPO::getCustomerName,param.getSearchValue());
}
}
return pqUserLedgerMapper.selectList(userWrapper);
}
@@ -237,15 +246,15 @@ public class EventRightServiceImpl implements EventRightService {
List<PqUserLedgerPO> oneList = userMap.get(obj.getId());
if (tree.equals(DicTreeEnum.BJ_USER.getCode())) {
Integer[] count = getEventCount(oneList, assList, eventdetailList, lineList,true);
Integer[] count = getEventCount(oneList, assList, eventdetailList,true);
result.setImportNum(count[0]);
result.setImportDevNum(count[1]);
} else if (tree.equals(DicTreeEnum.OI_USER.getCode())) {
Integer[] count = getEventCount(oneList, assList, eventdetailList, lineList,true);
Integer[] count = getEventCount(oneList, assList, eventdetailList,true);
result.setOtherImportNum(count[0]);
result.setOtherImportDevNum(count[1]);
} else if (tree.equals(DicTreeEnum.OT_USER.getCode())) {
Integer[] count = getEventCount(oneList, assList, eventdetailList, lineList,true);
Integer[] count = getEventCount(oneList, assList, eventdetailList,true);
result.setOtherNum(count[0]);
result.setOtherDevNum(count[1]);
}
@@ -260,7 +269,56 @@ public class EventRightServiceImpl implements EventRightService {
Map<String, List<PqUserLedgerPO>> smallMap = oneList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getSmallObjType));
smallMap.forEach((key, userList) -> {
UserLedgerStatisticVO.Inner item = new UserLedgerStatisticVO.Inner();
Integer[] count = getEventCount(userList, assList, eventdetailList, lineList, false);
Integer[] count = getEventCount(userList, assList, eventdetailList, false);
item.setCount(count[0]);
item.setTreeId(key);
item.setParentId(obj.getId());
item.setName(allTreeMap.containsKey(key) ? allTreeMap.get(key).getName() : "/");
childrenList.add(item);
});
inner.setChildren(childrenList);
innerList.add(inner);
}
});
result.setInnerList(innerList);
}
private void buildResultClone(UserLedgerStatisticVO result,Map<String, PqsDicTreePO> treeMap,Map<String, List<PqUserLedgerPO>> userMap,List<PqUserLineAssPO> assList,List<PqsEventdetail> eventdetailList, List<PqLine> lineList,List<PqsDicTreePO> dicTreePOList){
List<UserLedgerStatisticVO.Inner> innerList = new ArrayList<>();
Map<String,PqsDicTreePO> allTreeMap = dicTreePOList.stream().collect(Collectors.toMap(PqsDicTreePO::getId,dept->dept));
treeMap.forEach((tree, obj) -> {
//获取对象大类的用户
List<PqUserLedgerPO> oneList = userMap.get(obj.getId());
if (tree.equals(DicTreeEnum.BJ_USER.getCode())) {
Integer[] count = getEventCount(oneList, assList, eventdetailList,true);
result.setImportNum(oneList.size());
result.setImportDevNum(count[1]);
} else if (tree.equals(DicTreeEnum.OI_USER.getCode())) {
Integer[] count = getEventCount(oneList, assList, eventdetailList,true);
result.setOtherImportNum(oneList.size());
result.setOtherImportDevNum(count[1]);
} else if (tree.equals(DicTreeEnum.OT_USER.getCode())) {
Integer[] count = getEventCount(oneList, assList, eventdetailList,true);
result.setOtherNum(oneList.size());
result.setOtherDevNum(count[1]);
}
UserLedgerStatisticVO.Inner inner = new UserLedgerStatisticVO.Inner();
inner.setName(obj.getName());
inner.setCount(0);
List<UserLedgerStatisticVO.Inner> childrenList = new ArrayList<>();
if(CollUtil.isNotEmpty(oneList)) {
Map<String, List<PqUserLedgerPO>> smallMap = oneList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getSmallObjType));
smallMap.forEach((key, userList) -> {
UserLedgerStatisticVO.Inner item = new UserLedgerStatisticVO.Inner();
Integer[] count = getEventCount(userList, assList, eventdetailList, false);
item.setCount(count[0]);
item.setTreeId(key);
item.setParentId(obj.getId());
@@ -325,6 +383,19 @@ public class EventRightServiceImpl implements EventRightService {
if(CollUtil.isEmpty(deptLineIds)){
return result;
}
if(Objects.nonNull(param.getBdId())){
List<PqSubstation> pqSubstationList = pqSubstationMapper.selectList(new LambdaQueryWrapper<PqSubstation>().like(PqSubstation::getSubIndex,param.getBdId()));
if(CollUtil.isEmpty(pqSubstationList)){
return result;
}
List<Integer> subIds = pqSubstationList.stream().map(PqSubstation::getSubIndex).collect(Collectors.toList());
List<PqLine> pqLineList = pqLineService.list(new LambdaQueryWrapper<PqLine>().in(PqLine::getSubIndex,subIds));
deptLineIds = pqLineList.stream().map(PqLine::getLineIndex).distinct().collect(Collectors.toList());
}
//获取用户监测点关系符合部门监测点的
List<PqUserLineAssPO> assList = getUserLineAssociations(deptLineIds);
if(CollUtil.isEmpty(assList)){
@@ -348,7 +419,9 @@ public class EventRightServiceImpl implements EventRightService {
//查询时间段的暂降事件
LambdaQueryWrapper<PqsEventdetail> eventQuery = new LambdaQueryWrapper<>();
eventQuery.between(PqsEventdetail::getTimeid, DateUtil.parse(param.getSearchBeginTime()), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType()).orderByDesc(PqsEventdetail::getTimeid);
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType()).orderByDesc(PqsEventdetail::getTimeid)
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration());
if (lineUseList.size() > 1000) {
List<List<Integer>> listLineIds = CollUtil.split(lineUseList, 1000);
@@ -394,6 +467,72 @@ public class EventRightServiceImpl implements EventRightService {
return result;
}
@Override
public Page<EventDetailVO> rightEventOpenForDetail(LargeScreenCountParam param) {
Page<EventDetailVO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param));
//查询时间段的暂降事件
LambdaQueryWrapper<PqsEventdetail> eventQuery = new LambdaQueryWrapper<>();
eventQuery.between(PqsEventdetail::getTimeid, DateUtil.parse(param.getSearchBeginTime()), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType()).orderByDesc(PqsEventdetail::getTimeid)
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getEventdetailIndex,param.getEventIds());
Page<PqsEventdetail> page = pqsEventdetailService.page(new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param)),eventQuery);
List<PqsEventdetail> temResultList = page.getRecords();
if(CollUtil.isEmpty(temResultList)){
return result;
}
List<Integer> ids = temResultList.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
List<LedgerBaseInfoDTO> dtoList = pqLineService.getBaseLineInfo(ids);
Map<Integer,LedgerBaseInfoDTO> lineMap = dtoList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId,Function.identity()));
//获取用户监测点关系符合部门监测点的
List<PqUserLineAssPO> assList = getUserLineAssociations(ids);
if(CollUtil.isEmpty(assList)){
return result;
}
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
if(CollUtil.isEmpty(userIds)){
return result;
}
Map<Integer,List<String>> temMap = assList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getLineIndex,Collectors.mapping(PqUserLineAssPO::getUserIndex,Collectors.toList())));
//获取符合条件的用户
List<PqUserLedgerPO> pqUserLedgerPOList =getUserLedgers(userIds,param,true);
if(CollUtil.isEmpty(pqUserLedgerPOList)){
return result;
}
Map<String,PqUserLedgerPO> pqMap = pqUserLedgerPOList.stream().collect(Collectors.toMap(PqUserLedgerPO::getId,Function.identity()));
List<EventDetailVO> resultList = new ArrayList<>();
for(PqsEventdetail pqsEventdetail : temResultList){
EventDetailVO eventDetailVO = new EventDetailVO();
BeanUtil.copyProperties(pqsEventdetail,eventDetailVO);
List<String> userTemIds = temMap.get(pqsEventdetail.getLineid());
String objName = userTemIds.stream().map(it->pqMap.get(it).getCustomerName()).collect(Collectors.joining("; "));
eventDetailVO.setObjName(objName);
LedgerBaseInfoDTO dto = lineMap.get(pqsEventdetail.getLineid());
eventDetailVO.setBdname(dto.getStationName());
eventDetailVO.setGdName(dto.getGdName());
eventDetailVO.setBusName(dto.getBusBarName());
eventDetailVO.setLineid(dto.getLineId());
eventDetailVO.setPointname(dto.getLineName());
eventDetailVO.setEventdetail_index(pqsEventdetail.getEventdetailIndex());
eventDetailVO.setDevName(dto.getDevName());
eventDetailVO.setPersisttime(BigDecimal.valueOf(pqsEventdetail.getPersisttime() / 1000).setScale(3,RoundingMode.HALF_UP).toString());
resultList.add(eventDetailVO);
}
result.setTotal(page.getTotal());
result.setRecords(resultList);
return result;
}
@Override
public Page<PqUserLedgerPO> rightEventDevOpen(LargeScreenCountParam param) {
Page<PqUserLedgerPO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param));
@@ -401,6 +540,18 @@ public class EventRightServiceImpl implements EventRightService {
if(CollUtil.isEmpty(lineIds)){
return result;
}
if(Objects.nonNull(param.getBdId())){
List<PqSubstation> pqSubstationList = pqSubstationMapper.selectList(new LambdaQueryWrapper<PqSubstation>().like(PqSubstation::getSubIndex,param.getBdId()));
if(CollUtil.isEmpty(pqSubstationList)){
return result;
}
List<Integer> subIds = pqSubstationList.stream().map(PqSubstation::getSubIndex).collect(Collectors.toList());
List<PqLine> pqLineList = pqLineService.list(new LambdaQueryWrapper<PqLine>().in(PqLine::getSubIndex,subIds));
lineIds = pqLineList.stream().map(PqLine::getLineIndex).distinct().collect(Collectors.toList());
}
List<PqUserLineAssPO> assPOList =getUserLineAssociations(lineIds);
if(CollUtil.isEmpty(assPOList)){
return result;
@@ -433,6 +584,10 @@ public class EventRightServiceImpl implements EventRightService {
lambdaQueryWrapper.eq(PqUserLedgerPO::getPowerSupplyArea,param.getGdIndex());
}
if(StrUtil.isNotBlank(param.getSearchValue())){
lambdaQueryWrapper.eq(PqUserLedgerPO::getCustomerName,param.getSearchValue());
}
List<PqUserLedgerPO> userList = pqUserLedgerMapper.selectList(lambdaQueryWrapper);
if(CollUtil.isEmpty(userList)){
return result;
@@ -470,8 +625,9 @@ public class EventRightServiceImpl implements EventRightService {
});
page.getRecords().forEach(item-> {
if(objMap.containsKey(item.getId())){
long count = eventdetailList.stream().filter(it->objMap.get(item.getId()).contains(it.getLineid())).count();
item.setEventCount((int)count);;
List<PqsEventdetail> countObj = eventdetailList.stream().filter(it->objMap.get(item.getId()).contains(it.getLineid())).collect(Collectors.toList());
item.setEventCount(countObj.size());
item.setEventIds(countObj.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList()));
}
if(lastMap.containsKey(item.getId())){
List<PqLine> abList = lastMap.get(item.getId());
@@ -524,6 +680,8 @@ public class EventRightServiceImpl implements EventRightService {
List<PqsEventdetail> eventList = pqsEventdetailService.lambdaQuery().
in(PqsEventdetail::getLineid,lineIds)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.between(PqsEventdetail::getTimeid,DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()))).list();
if(CollUtil.isEmpty(eventList)){
poList.forEach(item->{
@@ -550,12 +708,37 @@ public class EventRightServiceImpl implements EventRightService {
return result;
}
@Override
public PqUserLedgerPO rightImportOpenDetail(LargeScreenCountParam param) {
List<Integer> deptLineIds = commGeneralService.getLineIdsByRedis(param.getDeptId());
if(CollUtil.isEmpty(deptLineIds)){
return null;
}
PqUserLedgerPO po = pqUserLedgerMapper.selectOne(new LambdaQueryWrapper<PqUserLedgerPO>().eq(PqUserLedgerPO::getId,param.getSearchValue()));
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getUserIndex,po.getId()));
List<PqUserLineAssPO> lastAss = pqUserLineAssPOS.stream().filter(it->deptLineIds.contains(it.getLineIndex())).collect(Collectors.toList());
List<Integer> lineIds = lastAss.stream().map(PqUserLineAssPO::getLineIndex).collect(Collectors.toList());
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOList = pqLineService.getBaseLedger(lineIds,null);
po.setGdName(ledgerBaseInfoDTOList.stream().map(LedgerBaseInfoDTO::getGdName).distinct().collect(Collectors.joining(";")));
po.setSubstationName(ledgerBaseInfoDTOList.stream().map(LedgerBaseInfoDTO::getStationName).distinct().collect(Collectors.joining(";")));
po.setBusbarName(ledgerBaseInfoDTOList.stream().map(it->it.getStationName()+"_"+it.getBusBarName()).distinct().collect(Collectors.joining(";")));
return po;
}
@Override
public List<PqGdCompany> gdSelect() {
return pqGdCompanyMapper.selectList(null);
}
private Integer[] getEventCount(List<PqUserLedgerPO> oneList, List<PqUserLineAssPO> assList, List<PqsEventdetail> pqsEventdetailList, List<PqLine> lineList,boolean devFlag) {
@Override
public List<PqSubstation> bdSelect() {
return pqSubstationMapper.selectList(null);
}
private Integer[] getEventCount(List<PqUserLedgerPO> oneList, List<PqUserLineAssPO> assList, List<PqsEventdetail> pqsEventdetailList,boolean devFlag) {
Integer[] count = new Integer[]{0, 0};
//用户的id
if(CollUtil.isNotEmpty(oneList)){
@@ -575,6 +758,157 @@ public class EventRightServiceImpl implements EventRightService {
return count;
}
@Override
public UserLedgerStatisticVO userLedgerStatisticClone(LargeScreenCountParam param) {
UserLedgerStatisticVO result = new UserLedgerStatisticVO();
// 1. 获取字典树数据
List<PqsDicTreePO> dicTreeList = getAllDicTrees();
Map<String, PqsDicTreePO> treeMap = getDicTreeMap(dicTreeList);
setResultIds(result, treeMap);
// 2. 获取线路ID列表
List<Integer> lineIds = commGeneralService.getLineIdsByDept(param);
if (CollUtil.isEmpty(lineIds)) {
return result;
}
// 3. 获取用户线路关联数据
List<PqUserLineAssPO> assList = getUserLineAssociations(lineIds);
if (CollUtil.isEmpty(assList)) {
return result;
}
// 4. 获取用户台账信息
Set<String> assUserIds = assList.stream()
.map(PqUserLineAssPO::getUserIndex)
.collect(Collectors.toSet());
List<PqUserLedgerPO> userLedgers = getUserLedgers(new ArrayList<>(assUserIds),null,false);
if (CollUtil.isEmpty(userLedgers)) {
return result;
}
// 5. 获取事件和线路数据
List<PqsEventdetail> events = getEventsInTimeRange(param, lineIds);
List<PqLine> lines = getLines(lineIds);
// 6. 按用户类型分组处理
Map<String, List<PqUserLedgerPO>> userMap = userLedgers.stream()
.collect(Collectors.groupingBy(PqUserLedgerPO::getBigObjType));
// 7. 构建结果
buildResultClone(result, treeMap, userMap, assList, events, lines,dicTreeList);
return result;
}
@Override
public Page<PqUserLedgerPO> rightEventOpenClone(LargeScreenCountParam param) {
Page<PqUserLedgerPO> result = new Page<>();
// 2. 获取线路ID列表
List<Integer> lineIds = commGeneralService.getLineIdsByDept(param);
if (CollUtil.isEmpty(lineIds)) {
return result;
}
LambdaQueryWrapper<PqLine> queryWrapper = new LambdaQueryWrapper<>();
PqSubstation pqSubstation = null;
if(Objects.nonNull(param.getBdId())){
pqSubstation = pqSubstationMapper.selectOne(new LambdaQueryWrapper<PqSubstation>().eq(PqSubstation::getSubIndex,param.getBdId()));
if(Objects.isNull(pqSubstation)){
return result;
}
queryWrapper.in(PqLine::getSubIndex, pqSubstation.getSubIndex());
}
PqGdCompany pqGdCompany = null;
if(Objects.nonNull(param.getGdIndex())){
pqGdCompany = pqGdCompanyMapper.selectOne(new LambdaQueryWrapper<PqGdCompany>().eq(PqGdCompany::getGdIndex,param.getGdIndex()));
if(Objects.isNull(pqGdCompany)){
return result;
}
queryWrapper.in(PqLine::getGdIndex, pqGdCompany.getGdIndex());
}
if(Objects.nonNull(param.getBdId()) || Objects.nonNull(param.getGdIndex())) {
List<PqLine> pqLineList = pqLineService.list(queryWrapper);
lineIds = pqLineList.stream().map(PqLine::getLineIndex).distinct().collect(Collectors.toList());
}
if(CollUtil.isEmpty(lineIds)){
return result;
}
// 3. 获取用户线路关联数据
List<PqUserLineAssPO> assList = getUserLineAssociations(lineIds);
if (CollUtil.isEmpty(assList)) {
return result;
}
LambdaQueryWrapper<PqUserLedgerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if(StrUtil.isNotBlank(param.getBigObjType())){
//对象大类不为空
lambdaQueryWrapper.eq(PqUserLedgerPO::getBigObjType,param.getBigObjType());
}
if(StrUtil.isNotBlank(param.getSmallObjType())){
//对象大类不为空
lambdaQueryWrapper.eq(PqUserLedgerPO::getSmallObjType,param.getSmallObjType());
}
if(Objects.nonNull(param.getGdIndex())){
lambdaQueryWrapper.eq(PqUserLedgerPO::getPowerSupplyArea,param.getGdIndex());
}
if(StrUtil.isNotBlank(param.getSearchValue())){
lambdaQueryWrapper.like(PqUserLedgerPO::getCustomerName,param.getSearchValue());
}
List<String> assIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
if(assIds.size()>1000){
List<List<String>> userIds = CollUtil.split(assIds, 1000);
lambdaQueryWrapper.and(w -> {
for (List<String> ids : userIds) {
w.or(wIn -> wIn.in(PqUserLedgerPO::getId, ids));
}
});
}else {
lambdaQueryWrapper.in(PqUserLedgerPO::getId, assIds);
}
Page<PqUserLedgerPO> page = pqUserLedgerMapper.selectPage(new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param)),lambdaQueryWrapper);
if(CollUtil.isEmpty(page.getRecords())){
return result;
}
List<String> userIds = page.getRecords().stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
List<PqUserLineAssPO> assPOList = assList.stream().filter(it->userIds.contains(it.getUserIndex())).collect(Collectors.toList());
List<Integer> lineTemIds = assPOList.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
List<LedgerBaseInfoDTO> ledgerList = pqLineService.getBaseLedger(lineTemIds,null);
List<PqsDeptsline> pqsDeptslineList = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getLineIndex,lineTemIds).eq(PqsDeptsline::getSystype,sysTypeZt).list();
Map<Integer,PqsDeptsline> deptLineMap = pqsDeptslineList.stream().collect(Collectors.toMap(PqsDeptsline::getLineIndex,dept->dept));
Map<Integer,String> deptTemMap = new HashMap<>();
List<PqsDepts> pqsDeptsList = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState,1).list();
Map<String,PqsDepts> deptMap = pqsDeptsList.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex,dept->dept));
deptLineMap.forEach((k,v)->{
deptTemMap.put(k,deptMap.get(v.getDeptsIndex()).getDeptsname());
});
Map<String,List<Integer>> assMap = assPOList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getUserIndex,Collectors.mapping(PqUserLineAssPO::getLineIndex,Collectors.toList())));
for(PqUserLedgerPO po :page.getRecords()){
if(assMap.containsKey(po.getId())){
List<Integer> temIds = assMap.get(po.getId());
List<LedgerBaseInfoDTO> temList = ledgerList.stream().filter(it->temIds.contains(it.getLineId())).collect(Collectors.toList());
po.setGdName(temList.stream().map(LedgerBaseInfoDTO::getGdName).distinct().collect(Collectors.joining(";")));
po.setStation(temList.stream().map(LedgerBaseInfoDTO::getStationName).distinct().collect(Collectors.joining(";")));
po.setInfo(temList.stream().map(it->it.getStationName()+"_"+it.getBusBarName()).distinct().collect(Collectors.joining(";")));
po.setDeptName(temList.stream().map(LedgerBaseInfoDTO::getLineId).distinct().map(deptTemMap::get).distinct().collect(Collectors.joining(";")));
}
}
return page;
}
}

View File

@@ -205,6 +205,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid,startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,listIds)
.orderByDesc(PqsEventdetail::getTimeid).list()
;
@@ -214,6 +216,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,lineIds)
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
@@ -302,6 +306,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,listIds)
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
@@ -310,6 +316,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,lineIds)
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
@@ -388,6 +396,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
queryWrapper.lambda()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.and(ew->{
for(List<Integer> pList: idPartitions){
ew.or(w->w.in(PqsEventdetail::getLineid, pList));
@@ -400,6 +410,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getLineid, lineIds)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.orderByDesc(PqsEventdetail::getTimeid);
}
//查询需要发送短息处理的部门反推监测点
@@ -483,6 +495,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
lambdaQueryWrapper.clear();
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.in(PqsEventdetail::getLineid, ids)
.and(wrapper -> wrapper.eq(PqsEventdetail::getLookFlag, 0).or().isNull(PqsEventdetail::getLookFlag));
if (Objects.nonNull(largeScreenCountParam.getEventDeep())) {
@@ -498,6 +512,9 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
}else {
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid, deptslineIds)
.and(wrapper -> wrapper.eq(PqsEventdetail::getLookFlag, 0).or().isNull(PqsEventdetail::getLookFlag));
if (Objects.nonNull(largeScreenCountParam.getEventDeep())) {
@@ -619,6 +636,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> eventdetails = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.in(PqsEventdetail::getLineid, deptslineIds).list();
mapCountVO.setEventCount(eventdetails.size());
@@ -760,6 +779,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid,startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,listIds)
.orderByDesc(PqsEventdetail::getTimeid).list()
;
@@ -769,6 +790,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,lineIds)
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
@@ -909,8 +932,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
DeviceCountVO deviceCountVO = new DeviceCountVO();
List<PqLine> pqLineList = (List<PqLine>) redisUtil.getObjectByKey( NAME_KEY+ StrUtil.DASHED+"pqLineList");
List<Integer> deptslineIds = (List<Integer>) redisUtil.getObjectByKey( NAME_KEY+ StrUtil.DASHED+largeScreenCountParam.getDeptId());
// List<PqsDeptsline> deptslines = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getDeptsIndex, deptAndChildren).eq(PqsDeptsline::getSystype, sysTypeZt).list();
// List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
pqLineList = pqLineList.stream().filter(temp->deptslineIds.contains(temp.getLineIndex())).collect(Collectors.toList());
List<Integer> devIndexs = pqLineList.stream().map(PqLine::getDevIndex).collect(Collectors.toList());
@@ -920,8 +941,12 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
long onLine = list.stream().filter(temp -> Objects.equals(temp.getStatus(), 1)).count();
long Offline = list.stream().filter(temp -> Objects.equals(temp.getStatus(), 0)).count();
deviceCountVO.setAllCount(list.size());
deviceCountVO.setOnLine((int) onLine);
deviceCountVO.setOffLine((int) Offline);
// deviceCountVO.setOnLine((int) onLine);
// deviceCountVO.setOffLine((int) Offline);
//临时调整
deviceCountVO.setOnLine(list.size());
deviceCountVO.setOffLine(0);
return deviceCountVO;
}
@@ -1026,6 +1051,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid,startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,itemIds)
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
@@ -1034,6 +1061,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> temp = pqsEventdetailService.lambdaQuery()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid,deptslineIds)
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
@@ -1055,7 +1084,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqUserLedgerPO> pqUserLedgerPOList = getUserLedgers(userIds);
List<SubStationCountVO> subStationCountVOS = new ArrayList<>();
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = pqLineService.getBaseLedger(lineIds);
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = pqLineService.getBaseLedger(lineIds,null);
//Map<Integer,LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
List<Integer> subIndexs = ledgerBaseInfoDTOS.stream().map(LedgerBaseInfoDTO::getStationId).collect(Collectors.toList());
@@ -1077,13 +1106,9 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
subStationCountVO.setLatitude(pqsStationMap.getLatItude());
List<Integer> tempLineIds = v.stream().map(LedgerBaseInfoDTO::getLineId).collect(Collectors.toList());
subStationCountVO.setLineCount(tempLineIds.size());
List<PqsEventdetail> tempEventList = eventdetails.stream().filter(temp -> tempLineIds.contains(temp.getLineid())).collect(Collectors.toList());
subStationCountVO.setEventCount(tempEventList.size());
v.forEach(item->{
String obj = "";
if(lineAssMap.containsKey(item.getLineId())){
@@ -1105,35 +1130,87 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
LocalDateTime startTime = largeScreenCountParam.getStartTime().atStartOfDay();
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(largeScreenCountParam.getEndTime().atStartOfDay());
List<Integer> deptslineIds = (List<Integer>) redisUtil.getObjectByKey( NAME_KEY+ StrUtil.DASHED+largeScreenCountParam.getDeptId());
List<Integer> deptslineIds = commGeneralService.getLineIdsByRedis(largeScreenCountParam.getDeptId());
List<LedgerBaseInfoDTO> pqLineList = pqLineService.getBaseLineInfo(deptslineIds);
Map<Integer,LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pqLineList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
QueryWrapper<PqsEventdetail> queryWrapper = new QueryWrapper<>();
if (deptslineIds.size()>1000) {
List<List<Integer>> idPartitions = CollUtil.split(deptslineIds,1000);
queryWrapper.lambda()
List<LedgerBaseInfoDTO> ledgerList = new ArrayList<>();
List<PqUserLedgerPO> pqUserLedgerPOList = new ArrayList<>();
List<PqUserLineAssPO> assList = new ArrayList<>();
LambdaQueryWrapper<PqsEventdetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.and(ew->{
.gt(PqsEventdetail::getPersisttime,msgEventConfigService.getEventDuration())
.le(PqsEventdetail::getEventvalue,msgEventConfigService.getEventValue())
.orderByDesc(PqsEventdetail::getTimeid);
if(Objects.nonNull(largeScreenCountParam.getEventtype())){
queryWrapper.eq(PqsEventdetail::getWavetype,largeScreenCountParam.getEventtype());
}else {
queryWrapper.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType());
}
if(Objects.nonNull(largeScreenCountParam.getEventDurationMin()) ||Objects.nonNull(largeScreenCountParam.getEventDurationMax())){
queryWrapper.gt(Objects.nonNull(largeScreenCountParam.getEventDurationMin()),PqsEventdetail::getPersisttime,largeScreenCountParam.getEventDurationMin());
queryWrapper.lt(Objects.nonNull(largeScreenCountParam.getEventDurationMax()),PqsEventdetail::getPersisttime,largeScreenCountParam.getEventDurationMax());
}
if(Objects.nonNull(largeScreenCountParam.getEventValueMin()) ||Objects.nonNull(largeScreenCountParam.getEventValueMax())){
queryWrapper.gt(Objects.nonNull(largeScreenCountParam.getEventValueMin()),PqsEventdetail::getEventvalue,largeScreenCountParam.getEventValueMin());
queryWrapper.lt(Objects.nonNull(largeScreenCountParam.getEventValueMax()),PqsEventdetail::getEventvalue,largeScreenCountParam.getEventValueMax());
}
if(StrUtil.isNotBlank(largeScreenCountParam.getSearchValue())){
LambdaQueryWrapper<PqUserLedgerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(PqUserLedgerPO::getId,PqUserLedgerPO::getCustomerName);
lambdaQueryWrapper.like(PqUserLedgerPO::getCustomerName,largeScreenCountParam.getSearchValue());
List<Integer> lineTemUserIds = new ArrayList<>();
pqUserLedgerPOList = pqUserLedgerMapper.selectList(lambdaQueryWrapper);
if(CollUtil.isNotEmpty(pqUserLedgerPOList)) {
List<String> userIds = pqUserLedgerPOList.stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getUserIndex, userIds));
List<Integer> assIds = assList.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
lineTemUserIds = deptslineIds.stream().filter(assIds::contains).collect(Collectors.toList());
}
ledgerList = pqLineService.getBaseLedger(deptslineIds,largeScreenCountParam.getSearchValue());
lineTemUserIds.addAll(ledgerList.stream().map(LedgerBaseInfoDTO::getLineId).collect(Collectors.toList()));
if(CollUtil.isEmpty(lineTemUserIds)){
return new Page<>();
}
if (lineTemUserIds.size()>1000) {
List<List<Integer>> idPartitions = CollUtil.split(lineTemUserIds,1000);
queryWrapper.and(ew->{
for(List<Integer> pList: idPartitions){
ew.or(w->w.in(PqsEventdetail::getLineid, pList));
}
}).orderByDesc(PqsEventdetail::getTimeid);
});
} else {
queryWrapper.lambda()
.between(PqsEventdetail::getTimeid, startTime, endTime)
.in(PqsEventdetail::getLineid, deptslineIds)
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
.orderByDesc(PqsEventdetail::getTimeid);
queryWrapper.in(PqsEventdetail::getLineid, lineTemUserIds);
}
}else {
if (deptslineIds.size()>1000) {
List<List<Integer>> idPartitions = CollUtil.split(deptslineIds,1000);
queryWrapper.and(ew->{
for(List<Integer> pList: idPartitions){
ew.or(w->w.in(PqsEventdetail::getLineid, pList));
}
});
} else {
queryWrapper.in(PqsEventdetail::getLineid, deptslineIds);
}
}
IPage<PqsEventdetail> list = pqsEventdetailService.getBaseMapper().selectPage(pqsEventdetailPage,queryWrapper);
if(CollUtil.isEmpty(list.getRecords())){
return new Page<>();
}
List<Integer> pageLineIds = list.getRecords().stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
List<LedgerBaseInfoDTO> pageLedger = pqLineService.getBaseLedger(pageLineIds,null);
Map<Integer,LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pageLedger.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
List<PqUserLineAssPO> assLastList = pqUserLedgerMapper.getUserByParam(pageLineIds,null);
Map<Integer,List<String>> mapObj = assLastList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getLineIndex,Collectors.mapping(PqUserLineAssPO::getUserName,Collectors.toList())));
List<EventDetailVO> collect = list.getRecords().stream().map(temp -> {
EventDetailVO eventDetailVO = new EventDetailVO();
eventDetailVO.setEventdetail_index(temp.getEventdetailIndex());
@@ -1153,6 +1230,11 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
eventDetailVO.setBusName(ledgerBaseInfoDTO.getBusBarName());
eventDetailVO.setObjName(ledgerBaseInfoDTO.getObjName());
}
String objName ="/";
if(mapObj.containsKey(eventDetailVO.getLineid())){
objName = String.join(";", mapObj.get(eventDetailVO.getLineid()));
}
eventDetailVO.setObjName(objName);
return eventDetailVO;
}).collect(Collectors.toList());
Page<EventDetailVO> returnpage = new Page<>(largeScreenCountParam.getPageNum(), largeScreenCountParam.getPageSize());
@@ -1188,7 +1270,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
LambdaQueryWrapper<PqDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if(StrUtil.isNotBlank(largeScreenCountParam.getState())){
lambdaQueryWrapper.eq(PqDevice::getStatus,Integer.valueOf(largeScreenCountParam.getState()));
// lambdaQueryWrapper.eq(PqDevice::getStatus,Integer.valueOf(largeScreenCountParam.getState()));
}
if(StrUtil.isNotBlank(largeScreenCountParam.getDevName())){
lambdaQueryWrapper.like(StrUtil.isNotEmpty(largeScreenCountParam.getDevName()),PqDevice::getName,largeScreenCountParam.getDevName());
@@ -1220,6 +1302,10 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqDevice> deviceDTOList = page.getRecords();
if(!CollectionUtils.isEmpty(deviceDTOList)){
//临时处理
deviceDTOList.forEach(it->it.setStatus(1));
List<Integer> devIds = deviceDTOList.stream().map(PqDevice::getDevIndex).collect(Collectors.toList());
log.info("在线率查询sql开始"+timeInterval.intervalMs()+"ms; "+timeInterval.intervalSecond()+"s");
List<PqsOnlinerate> onlineList = pqsOnlinerateService.lambdaQuery().in(PqsOnlinerate::getDevIndex,devIds).between(PqsOnlinerate::getTimeid, startTime, endTime).list();

View File

@@ -14,6 +14,7 @@ import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -27,8 +28,21 @@ import java.util.stream.Stream;
@Lazy(false) // 确保服务在启动时立即初始化
public class MsgEventConfigServiceImpl extends ServiceImpl<MsgEventConfigMapper, MsgEventConfig> implements MsgEventConfigService {
/**
* 暂降类型
*/
public List<String> eventType = Stream.of("1","3").collect(Collectors.toList());
/**
* 暂降残余电压阈值 只查询小于0.7的暂降事件
*/
public Float eventValue = 0.7f;
/**
* 暂降残余电压阈值 只查询大于50ms的暂降事件
*/
public Integer eventDuration = 50;
@Transactional(rollbackFor = Exception.class)
@@ -40,6 +54,8 @@ public class MsgEventConfigServiceImpl extends ServiceImpl<MsgEventConfigMapper
msgEventConfig.setEventType(tem);
this.save(msgEventConfig);
eventType = msgEventConfig.getEventTypeList();
eventValue = msgEventConfig.getEventValue();
eventDuration= msgEventConfig.getEventDuration();
return true;
}
@@ -55,12 +71,18 @@ public class MsgEventConfigServiceImpl extends ServiceImpl<MsgEventConfigMapper
public void init() {
System.out.println("------------------------------------------------------------------------------");
MsgEventConfig config = this.getOne(new LambdaQueryWrapper<>());
if (config != null && StrUtil.isNotBlank(config.getEventType())) {
if(Objects.nonNull(config)){
if (StrUtil.isNotBlank(config.getEventType())) {
eventType = Arrays.asList(config.getEventType().split(StrUtil.COMMA));
} else {
eventType = Collections.emptyList();
}
System.out.println(eventType);
if(Objects.nonNull(config.getEventValue())){
eventValue = config.getEventValue();
}
if(Objects.nonNull(config.getEventDuration())){
eventDuration = config.getEventDuration();
}
}
System.out.println(config);
}
@@ -69,6 +91,15 @@ public class MsgEventConfigServiceImpl extends ServiceImpl<MsgEventConfigMapper
return eventType;
}
@Override
public Float getEventValue() {
return eventValue;
}
@Override
public Integer getEventDuration() {
return eventDuration;
}
}