sql优化
This commit is contained in:
@@ -53,8 +53,20 @@
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceDTOPage" resultType="com.njcn.gather.event.devcie.pojo.dto.DeviceDTO">
|
||||
select
|
||||
DISTINCT pq_device.dev_index devId,
|
||||
WITH temp AS(
|
||||
SELECT DISTINCT
|
||||
PQ_LINE.DEV_INDEX,
|
||||
PQS_DEPTS.DEPTSNAME
|
||||
FROM
|
||||
PQ_LINE,
|
||||
PQS_DEPTSLINE,
|
||||
PQS_DEPTS
|
||||
WHERE
|
||||
PQ_LINE.LINE_INDEX = PQS_DEPTSLINE.LINE_INDEX
|
||||
AND PQS_DEPTS.DEPTS_INDEX = PQS_DEPTSLINE.DEPTS_INDEX
|
||||
)
|
||||
SELECT DISTINCT
|
||||
pq_device.dev_index devId,
|
||||
pq_device.name devName,
|
||||
pq_device.UpdateTime updateTime,
|
||||
pq_device.DevFlag devFlag,
|
||||
@@ -67,24 +79,15 @@
|
||||
PQ_DEVICEDETAIL.ThisTimeCheck thisTimeCheck,
|
||||
PQ_DEVICEDETAIL.NextTimeCheck nextTimeCheck,
|
||||
pq_device.LogonTime logonTime,
|
||||
PQS_DEPTS.DEPTSNAME deptName
|
||||
from
|
||||
PQ_DEVICE,
|
||||
PQ_SUBSTATION,
|
||||
PQ_GDINFORMATION,
|
||||
PQ_DEVICEDETAIL,
|
||||
PQS_DICDATA,
|
||||
PQ_LINE,
|
||||
PQS_DEPTS,
|
||||
PQS_DEPTSLINE
|
||||
where
|
||||
pq_device.SUB_INDEX = PQ_SUBSTATION.SUB_INDEX
|
||||
and pq_device.GD_INDEX =PQ_GDINFORMATION.GD_INDEX
|
||||
and PQ_DEVICEDETAIL.dev_index =pq_device.dev_index
|
||||
and PQ_DEVICEDETAIL.MANUFACTURER = PQS_DICDATA.DIC_INDEX
|
||||
and PQ_LINE.DEV_INDEX = PQ_DEVICE.DEV_INDEX
|
||||
and PQ_LINE.LINE_INDEX = PQS_DEPTSLINE.LINE_INDEX
|
||||
and PQS_DEPTSLINE.DEPTS_INDEX=PQS_DEPTS.DEPTS_INDEX
|
||||
temp.DEPTSNAME deptName
|
||||
FROM
|
||||
pq_device
|
||||
LEFT JOIN PQ_SUBSTATION ON pq_device.SUB_INDEX = PQ_SUBSTATION.SUB_INDEX
|
||||
LEFT JOIN PQ_GDINFORMATION ON pq_device.GD_INDEX = PQ_GDINFORMATION.GD_INDEX
|
||||
LEFT JOIN PQ_DEVICEDETAIL ON PQ_DEVICEDETAIL.dev_index = pq_device.dev_index
|
||||
LEFT JOIN PQS_DICDATA on PQ_DEVICEDETAIL.MANUFACTURER = PQS_DICDATA.DIC_INDEX
|
||||
LEFT JOIN temp on temp.DEV_INDEX = pq_device.dev_index
|
||||
where 1=1
|
||||
<if test="searchValue!= null and searchValue!= ''">
|
||||
AND (
|
||||
pq_device.name LIKE '%' || #{searchValue} || '%'
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package com.njcn.gather.event.transientes.pojo.vo;
|
||||
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsEventdetail;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.sound.sampled.Line;
|
||||
import javax.sound.sampled.LineEvent;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
@@ -16,8 +23,40 @@ public class SubStationCountVO {
|
||||
private String gdName;
|
||||
private double longitude;
|
||||
private double latitude;
|
||||
|
||||
private Integer lineCount;
|
||||
private Integer eventCount;
|
||||
|
||||
private List<LineEventDetail> lineEventDetails;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class LineEventDetail {
|
||||
private String gdName;
|
||||
private String gdIndex;
|
||||
|
||||
private Integer lineId;
|
||||
|
||||
private String lineName;
|
||||
|
||||
private Integer busBarId;
|
||||
|
||||
private String busBarName;
|
||||
|
||||
private Integer devId;
|
||||
|
||||
private String devName;
|
||||
|
||||
private String objName;
|
||||
|
||||
private Integer stationId;
|
||||
|
||||
private String stationName;
|
||||
//通讯状态
|
||||
private Integer runFlag=0;
|
||||
|
||||
private List<PqsEventdetail> pqsEventdetails;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -986,7 +986,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
List<SubStationCountVO> subStationCountVOS = new ArrayList<>();
|
||||
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<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = pqLineService.getBaseLineInfo(deptslineIds);
|
||||
Map<Integer,LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
|
||||
|
||||
pqLineList = pqLineList.stream().filter(temp->deptslineIds.contains(temp.getLineIndex())).collect(Collectors.toList());
|
||||
List<Integer> subIndexs = pqLineList.stream().map(PqLine::getSubIndex).collect(Collectors.toList());
|
||||
@@ -1031,9 +1032,19 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
subStationCountVO.setEventCount(0);
|
||||
return;
|
||||
|
||||
}else {
|
||||
subStationCountVO.setEventCount(tempEventList.size());
|
||||
}
|
||||
subStationCountVO.setEventCount(tempEventList.size());
|
||||
Map<Integer, List<PqsEventdetail>> collect = tempEventList.stream().collect(Collectors.groupingBy(PqsEventdetail::getLineid));
|
||||
List<SubStationCountVO.LineEventDetail> lineEventDetails = new ArrayList<>();
|
||||
collect.forEach((k1,v1)->{
|
||||
SubStationCountVO.LineEventDetail lineEventDetail = new SubStationCountVO.LineEventDetail();
|
||||
LedgerBaseInfoDTO ledgerBaseInfoDTO = ledgerBaseInfoDTOMap.get(k1);
|
||||
BeanUtils.copyProperties(ledgerBaseInfoDTO,lineEventDetail);
|
||||
|
||||
lineEventDetail.setPqsEventdetails(v1);
|
||||
lineEventDetails.add(lineEventDetail);
|
||||
});
|
||||
subStationCountVO.setLineEventDetails(lineEventDetails);
|
||||
subStationCountVOS.add(subStationCountVO);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user