1.自定义报表模板调整

This commit is contained in:
2025-11-26 14:41:23 +08:00
parent 61c8656fd9
commit ea54b2b907
6 changed files with 100 additions and 27 deletions

View File

@@ -61,8 +61,12 @@ public class DataGroupEventVO {
@ApiModelProperty("暂降幅值")
private Float featureAmplitude;
@ApiModelProperty("映射数据库暂降幅值")
private Double amplitude;
@ApiModelProperty("严重度")
private String severity;
@ApiModelProperty("波形路径")
private String wavePath;

View File

@@ -11,7 +11,7 @@ public enum CsTransientEnum {
EVT_SYS_DIPSTR("Evt_Sys_DipStr","电压暂降"),
EVT_SYS_INTRSTRr("Evt_Sys_IntrStr","电压中断"),
EVT_SYS_INTRSTR("Evt_Sys_IntrStr","电压中断"),
EVT_SYS_SWLSTR("Evt_Sys_SwlStr","电压暂升"),
TRANSIENT("Transient","录波"),
UN_KNOW("Un_Know","未知")
@@ -27,4 +27,26 @@ public enum CsTransientEnum {
this.code = code;
this.name = name;
}
/**
* 根据code获取对应的name
* @param code 枚举编码
* @return 匹配的名称,未匹配时返回"未知"code为null时返回"未知"
*/
public static String getNameByCode(String code) {
// 处理code为null的情况
if (code == null) {
return UN_KNOW.getName();
}
// 遍历所有枚举常量匹配code
for (CsTransientEnum transientEnum : CsTransientEnum.values()) {
if (transientEnum.getCode().equals(code)) {
return transientEnum.getName();
}
}
// 未找到匹配的code时返回未知名称
return UN_KNOW.getName();
}
}

View File

@@ -52,10 +52,6 @@
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
WHERE
a.activation = 1
and b.dept_id in
<foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
#{item}
</foreach>
order by a.sort asc
</select>
</mapper>

View File

@@ -20,6 +20,7 @@ import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.enums.CsEventEnum;
import com.njcn.csharmonic.enums.CsTransientEnum;
import com.njcn.csharmonic.mapper.CsEventPOMapper;
import com.njcn.csharmonic.param.CldEventParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage;
@@ -67,7 +68,10 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@@ -179,7 +183,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
List<String> EVENT_TAGS = Arrays.asList(
EVT_SYS_DIPSTR.getCode(),
EVT_SYS_INTRSTRr.getCode(),
EVT_SYS_INTRSTR.getCode(),
EVT_SYS_SWLSTR.getCode()
);
@@ -197,13 +201,46 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
Map<String,String> linePOMap = csLinePOList.stream().collect(Collectors.toMap(CsLinePO::getLineId, CsLinePO::getName));
List<DataGroupEventVO> dataGroupEventVOList = BeanUtil.copyToList(page.getRecords(),DataGroupEventVO.class);
dataGroupEventVOList.forEach(item->item.setLineName(linePOMap.getOrDefault(item.getLineId(),"/")));
dataGroupEventVOList.forEach(item->{
item.setLineName(linePOMap.getOrDefault(item.getLineId(),"/"));
if(CsTransientEnum.EVT_SYS_SWLSTR.getCode().equals(item.getTag())){
item.setSeverity("/");
}else {
item.setSeverity(getYzd(item.getPersistTime()*1000,item.getAmplitude()/100.0));
}
item.setTag(CsTransientEnum.getNameByCode(item.getTag()));
item.setPersistTime(BigDecimal.valueOf(item.getPersistTime()).setScale(3, RoundingMode.HALF_UP).doubleValue());
});
result.setRecords(dataGroupEventVOList);
result.setTotal(page.getTotal());
}
return result;
}
/**
* 获取该事件的严重度
*
* @param persistTime 持续时间 ms单位
* @param eventValue 暂降、暂升幅值
*/
public String getYzd(Double persistTime, Double eventValue) {
Double yzd;
// 格式化小数
DecimalFormat df = new DecimalFormat("0.000");
if (persistTime <= 20) {
yzd = 1.0 - eventValue;
} else if (persistTime > 20 && persistTime <= 200) {
yzd = 2.0 * (1 - eventValue);
} else if (persistTime > 200 && persistTime <= 500) {
yzd = 3.3 * (1 - eventValue);
} else if (persistTime > 500 && persistTime <= 10000) {
yzd = 5.0 * (1 - eventValue);
} else {
yzd = 10.0 * (1 - eventValue);
}
return df.format(yzd);
}
@Override
@Transactional
public void saveBatchEventList(List<CsEventPO> csEventPOS) {

View File

@@ -12,6 +12,7 @@ import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONTokener;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.njcn.common.pojo.enums.common.DataStateEnum;
@@ -112,6 +113,7 @@ public class CustomReportServiceImpl implements CustomReportService {
private final String STR_TWO = "$";
private final String STR_THREE = "&";
private final String STR_FOUR = "%";
private final String limitTable = "pq_overlimit";
@Override
public void getCustomReport(ReportSearchParam reportSearchParam, HttpServletResponse response) {
@@ -191,9 +193,10 @@ public class CustomReportServiceImpl implements CustomReportService {
}
@Override
@DS("sjzx")
public List<ReportTemplateVO> getTemplateByDept(String id) {
List<String> deptIds = deptFeignClient.getDepSonIdtByDeptId(id).getData();
return excelRptTempMapper.getReportTemplateByDept(deptIds);
//List<String> deptIds = deptFeignClient.getDepSonIdtByDeptId(id).getData();
return excelRptTempMapper.getReportTemplateByDept(new ArrayList<>());
}
@Override
@@ -246,15 +249,23 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override
public List<ReportTreeVO> reportChooseTree() {
DictData dic = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.CS_DATA_TYPE.getName(), DicDataEnum.EPD.getName()).getData();
List<EleEpdPqd> list = epdFeignClient.dictMarkByDataType(dic.getId()).getData();
list.sort(Comparator.comparingInt(EleEpdPqd::getSort));
Map<String, List<EleEpdPqd>> map = list.stream().collect(Collectors.groupingBy(EleEpdPqd::getName, LinkedHashMap::new, Collectors.toList()));
List<ReportTreeVO> tree = new ArrayList<>();
map.forEach((key, value) -> {
DictData dic = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.CS_DATA_TYPE.getName(), DicDataEnum.PQD.getName()).getData();
List<EleEpdPqd> epdList = epdFeignClient.dictMarkByDataType(dic.getId()).getData();
epdList = epdList.stream().filter(it->StrUtil.isNotBlank(it.getResourcesId())).collect(Collectors.toList());
if(CollUtil.isEmpty(epdList)){
return tree;
}
List<DictData> dayTableList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DATA_DAY.getCode()).getData();
Map<String,String> dayTableMap = dayTableList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
epdList.forEach(item->item.setResourcesId(dayTableMap.get(item.getResourcesId())));
epdList.sort(Comparator.comparingInt(EleEpdPqd::getSort));
Map<String, List<EleEpdPqd>> map = epdList.stream().collect(Collectors.groupingBy(EleEpdPqd::getName, LinkedHashMap::new, Collectors.toList()));
map.forEach((key, value) -> {
ReportTreeVO reportTreeVO = new ReportTreeVO();
reportTreeVO.setName(value.get(0).getOtherName());
reportTreeVO.setShowName(value.get(0).getShowName());
@@ -282,10 +293,12 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override
public List<ReportTreeVO> targetLimitChooseTree() {
List<ReportTreeVO> result = new ArrayList<>();
DictData dic = dicDataFeignClient.getDicDataByCode(DicDataEnum.EPD.getCode()).getData();
DictData dic = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
List<EleEpdPqd> list = epdFeignClient.dictMarkByDataType(dic.getId()).getData()
.stream().filter(eleEpdPqd -> eleEpdPqd.getLimitTable().equals("pq_overlimit")).collect(Collectors.toList());
list.sort(Comparator.comparingInt(EleEpdPqd::getSort));
.stream().filter(eleEpdPqd -> limitTable.equals(eleEpdPqd.getLimitTable()))
.sorted(Comparator.comparingInt(EleEpdPqd::getSort)).collect(Collectors.toList());
Map<String, List<EleEpdPqd>> map = list.stream().collect(Collectors.groupingBy(EleEpdPqd::getLimitName));
map.forEach((key, val) -> {
ReportTreeVO reportTreeVO = new ReportTreeVO();
@@ -364,7 +377,7 @@ public class CustomReportServiceImpl implements CustomReportService {
private void assStatMethod(EleEpdPqd item, List<ReportTreeVO> statTree, String oneKey, String twoKey) {
//存在别为M但是Stat_Method不为空
//存在别为M但是Stat_Method不为空
if (StrUtil.isNotBlank(item.getStatMethod())) {
String[] arr = item.getStatMethod().split(",");
List<String> stat = Stream.of(arr).collect(Collectors.toList());

View File

@@ -44,7 +44,7 @@ import static com.njcn.csharmonic.enums.CsTransientEnum.*;
public class EventOverviewServiceImpl implements EventOverviewService {
private static final List<String> EVENT_TAGS = Arrays.asList(
EVT_SYS_DIPSTR.getCode(),
EVT_SYS_INTRSTRr.getCode(),
EVT_SYS_INTRSTR.getCode(),
EVT_SYS_SWLSTR.getCode()
);
@@ -75,7 +75,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
}
Map<String, Long> eventCountByTag = csEventPOList.stream().collect(Collectors.groupingBy(CsEventPO::getTag, Collectors.counting()));
result.setEventDown(eventCountByTag.getOrDefault(EVT_SYS_DIPSTR.getCode(), 0L).intValue());
result.setEventOff(eventCountByTag.getOrDefault(EVT_SYS_INTRSTRr.getCode(), 0L).intValue());
result.setEventOff(eventCountByTag.getOrDefault(EVT_SYS_INTRSTR.getCode(), 0L).intValue());
result.setEventUp(eventCountByTag.getOrDefault(EVT_SYS_SWLSTR.getCode(), 0L).intValue());
result.setAllNum(csEventPOList.size());
return result;
@@ -115,6 +115,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
.map(line -> {
EventStatisticVO vo = new EventStatisticVO();
vo.setName(line.getName());
vo.setId(line.getLineId());
return vo;
})
.collect(Collectors.toList());
@@ -134,10 +135,10 @@ public class EventOverviewServiceImpl implements EventOverviewService {
.map(line -> {
EventStatisticVO vo = new EventStatisticVO();
vo.setName(line.getName());
vo.setId(line.getLineId());
Map<String, Long> lineEvents = eventCountByLineAndTag.getOrDefault(line.getLineId(), Collections.emptyMap());
vo.setEventDown(lineEvents.getOrDefault(EVT_SYS_DIPSTR.getCode(), 0L).intValue());
vo.setEventOff(lineEvents.getOrDefault(EVT_SYS_INTRSTRr.getCode(), 0L).intValue());
vo.setEventOff(lineEvents.getOrDefault(EVT_SYS_INTRSTR.getCode(), 0L).intValue());
vo.setEventUp(lineEvents.getOrDefault(EVT_SYS_SWLSTR.getCode(), 0L).intValue());
return vo;
@@ -216,7 +217,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
Map<String,Long> itemMap = map.getOrDefault(day,Collections.emptyMap());
eventStatisticVO.setEventDown(itemMap.getOrDefault(EVT_SYS_DIPSTR.getCode(), 0L).intValue());
eventStatisticVO.setEventOff(itemMap.getOrDefault(EVT_SYS_INTRSTRr.getCode(), 0L).intValue());
eventStatisticVO.setEventOff(itemMap.getOrDefault(EVT_SYS_INTRSTR.getCode(), 0L).intValue());
eventStatisticVO.setEventUp(itemMap.getOrDefault(EVT_SYS_SWLSTR.getCode(), 0L).intValue());
return eventStatisticVO;
}).collect(Collectors.toList());
@@ -316,7 +317,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
String tag = event.getTag();
if (EVT_SYS_DIPSTR.getCode().equals(tag)) {
timeSegmentStats[0].set(startTimeGroup, timeSegmentStats[0].get(startTimeGroup) + 1);
} else if (EVT_SYS_INTRSTRr.getCode().equals(tag)) {
} else if (EVT_SYS_INTRSTR.getCode().equals(tag)) {
timeSegmentStats[1].set(startTimeGroup, timeSegmentStats[1].get(startTimeGroup) + 1);
} else if (EVT_SYS_SWLSTR.getCode().equals(tag)) {
timeSegmentStats[2].set(startTimeGroup, timeSegmentStats[2].get(startTimeGroup) + 1);
@@ -328,7 +329,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
List<EventCoordsVO.TagObj> trendList = Arrays.asList(
new EventCoordsVO.TagObj(EVT_SYS_DIPSTR.getCode(),
timeSegmentStats[0]),
new EventCoordsVO.TagObj(EVT_SYS_INTRSTRr.getCode(),
new EventCoordsVO.TagObj(EVT_SYS_INTRSTR.getCode(),
timeSegmentStats[1]),
new EventCoordsVO.TagObj(EVT_SYS_SWLSTR.getCode(),
timeSegmentStats[2])