更换git仓库后的提交
This commit is contained in:
33
cn-diagram/.gitignore
vendored
Normal file
33
cn-diagram/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
105
cn-diagram/pom.xml
Normal file
105
cn-diagram/pom.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.njcn.product</groupId>
|
||||
<artifactId>CN_Product</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>cn-diagram</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>cn-diagram</name>
|
||||
<description>cn-diagram</description>
|
||||
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>njcn-common</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>spingboot2.3.12</artifactId>
|
||||
<version>2.3.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.product</groupId>
|
||||
<artifactId>cn-user</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.product</groupId>
|
||||
<artifactId>cn-auth</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.product</groupId>
|
||||
<artifactId>cn-system</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.product</groupId>
|
||||
<artifactId>cn-zutai</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.product</groupId>
|
||||
<artifactId>cn-terminal</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
<version>${websocket.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- 多数据源切换,当数据源为oracle时需要使用 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.product</groupId>
|
||||
<artifactId>cn-advance</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.njcn.product.diagram.LedgerScale.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;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.product.advance.responsility.pojo.dto.CustomerResponsibility;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.dto.EventSourceDTO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventDetailVO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventLedgerVO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerBaseInfo;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalShowVO;
|
||||
import com.njcn.product.diagram.LedgerScale.service.LedgerScaleService;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.param.LargeScreenCountParam;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-01
|
||||
* @Description: 台账规模
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "大屏")
|
||||
@RequestMapping("/scale")
|
||||
@RequiredArgsConstructor
|
||||
public class LedgerScaleController extends BaseController {
|
||||
|
||||
private final LedgerScaleService ledgerScaleService;
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/ledgerScale")
|
||||
@ApiOperation("台账规模")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<LedgerScaleDTO> ledgerScale(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("ledgerScale");
|
||||
LedgerScaleDTO ledgerScaleDTO = ledgerScaleService.ledgerScaleStatistic(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ledgerScaleDTO, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/eventSource")
|
||||
@ApiOperation("暂降溯源统计")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<EventSourceDTO> eventSource(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("eventSource");
|
||||
EventSourceDTO eventSourceDTO = ledgerScaleService.eventSource(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventSourceDTO, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/eventAggregation")
|
||||
@ApiOperation("暂降聚合分析")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<EventSourceDTO> eventAggregation(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("eventAggregation");
|
||||
EventSourceDTO eventSourceDTO = ledgerScaleService.eventAggregation(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventSourceDTO, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/hasEventList")
|
||||
@ApiOperation("一次接线图发生暂降事件的监测点闪烁")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<List<EventLedgerVO>> hasEventList(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("hasEventList");
|
||||
List<EventLedgerVO> result = ledgerScaleService.hasEventList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/hasUpEventList")
|
||||
@ApiOperation("一次接线图发生谐波放大的监测点闪烁")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<List<EventLedgerVO>> hasUpEventList(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("hasUpEventList");
|
||||
List<EventLedgerVO> result = ledgerScaleService.hasUpEventList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/clickImage")
|
||||
@ApiOperation("一次接线图点击事件")
|
||||
@ApiImplicitParam(name = "lineId", value = "查询参数", required = true)
|
||||
public HttpResult<EventLedgerVO> clickImage(@RequestParam("lineId")String lineId) {
|
||||
String methodDescribe = getMethodDescribe("clickImage");
|
||||
EventLedgerVO result = ledgerScaleService.clickImage(lineId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/eventList")
|
||||
@ApiOperation("暂降实时数据")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<EventDetailVO>> eventList(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("eventList");
|
||||
Page<EventDetailVO> result = ledgerScaleService.eventList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/eventListByLineId")
|
||||
@ApiOperation("暂降实时数据")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<EventDetailVO>> eventListByLineId(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("eventListByLineId");
|
||||
Page<EventDetailVO> result = ledgerScaleService.eventListByLineId(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/stationPage")
|
||||
@ApiOperation("电站详情")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<TerminalShowVO>> stationPage(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("stationPage");
|
||||
Page<TerminalShowVO> result = ledgerScaleService.stationPage(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/devPage")
|
||||
@ApiOperation("终端详情")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<TerminalShowVO>> devPage(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("devPage");
|
||||
Page<TerminalShowVO> result = ledgerScaleService.devPage(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/linePage")
|
||||
@ApiOperation("监测点详情")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<TerminalShowVO>> linePage(@RequestBody LargeScreenCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("linePage");
|
||||
Page<TerminalShowVO> result = ledgerScaleService.linePage(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/harmOneImage")
|
||||
@ApiOperation("谐波溯源事件点击关联一次接线图")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<List<CustomerResponsibility>> harmOneImage(@RequestParam("id")String id, @RequestParam("time")Integer time) {
|
||||
String methodDescribe = getMethodDescribe("harmOneImage");
|
||||
List<CustomerResponsibility> result = ledgerScaleService.harmOneImage(id,time);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.product.diagram.LedgerScale.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-01
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class EventSourceDTO {
|
||||
|
||||
private Integer eventCount = 0;
|
||||
|
||||
private List<Inner> innerList = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
public static class Inner{
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer count;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.product.diagram.LedgerScale.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-01
|
||||
* @Description: 台账规模
|
||||
*/
|
||||
@Data
|
||||
public class LedgerScaleDTO {
|
||||
|
||||
private Integer stationAll;
|
||||
|
||||
private Integer stationRun;
|
||||
|
||||
private Integer devAll;
|
||||
|
||||
private Integer devRun;
|
||||
|
||||
private Integer lineAll;
|
||||
|
||||
private Integer lineRun;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.njcn.product.diagram.LedgerScale.pojo.vo;
|
||||
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.RmpEventDetailPO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-03
|
||||
* @Description:
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class EventDetailVO extends RmpEventDetailPO {
|
||||
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
private String lineId;
|
||||
|
||||
/**
|
||||
* 监测点名称
|
||||
*/
|
||||
private String lineName;
|
||||
|
||||
/**
|
||||
* 装置通道
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
/**
|
||||
* 监测点电压等级
|
||||
*/
|
||||
private String voltageLevel;
|
||||
|
||||
/**
|
||||
* 监测点用户
|
||||
*/
|
||||
private String objName;
|
||||
|
||||
/**
|
||||
* 0:通讯中断;1:通讯正常
|
||||
*/
|
||||
private Integer comFlag;
|
||||
|
||||
/**
|
||||
* 0:投运;1:热备用;2:停运
|
||||
*/
|
||||
private Integer runFlag;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private String devId;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String devName;
|
||||
|
||||
/**
|
||||
* 电站id
|
||||
*/
|
||||
private String stationId;
|
||||
|
||||
/**
|
||||
* 电站名称
|
||||
*/
|
||||
private String stationName;
|
||||
|
||||
/**
|
||||
* 供电id
|
||||
*/
|
||||
private String gdId;
|
||||
|
||||
/**
|
||||
* 供电公司
|
||||
*/
|
||||
private String gdName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.product.diagram.LedgerScale.pojo.vo;
|
||||
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerBaseInfo;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.RmpEventDetailPO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-03
|
||||
* @Description:
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class EventLedgerVO extends LedgerBaseInfo {
|
||||
|
||||
private List<String> eventIds;
|
||||
|
||||
private List<RmpEventDetailPO> eventList;
|
||||
|
||||
private Integer isImport;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.product.diagram.LedgerScale.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.product.advance.responsility.pojo.dto.CustomerResponsibility;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.dto.EventSourceDTO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventDetailVO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventLedgerVO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerBaseInfo;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalShowVO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.param.LargeScreenCountParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-01
|
||||
* @Description:
|
||||
*/
|
||||
public interface LedgerScaleService {
|
||||
|
||||
LedgerScaleDTO ledgerScaleStatistic(LargeScreenCountParam param);
|
||||
|
||||
EventSourceDTO eventSource(LargeScreenCountParam param);
|
||||
|
||||
EventSourceDTO eventAggregation(LargeScreenCountParam param);
|
||||
|
||||
List<EventLedgerVO> hasEventList(LargeScreenCountParam param);
|
||||
|
||||
List<EventLedgerVO> hasUpEventList(LargeScreenCountParam param);
|
||||
|
||||
|
||||
EventLedgerVO clickImage(String lineId);
|
||||
|
||||
Page<EventDetailVO> eventList(LargeScreenCountParam param);
|
||||
|
||||
Page<EventDetailVO> eventListByLineId(LargeScreenCountParam param);
|
||||
|
||||
Page<TerminalShowVO> stationPage(LargeScreenCountParam param);
|
||||
|
||||
Page<TerminalShowVO> devPage(LargeScreenCountParam param);
|
||||
|
||||
Page<TerminalShowVO> linePage(LargeScreenCountParam param);
|
||||
|
||||
|
||||
List<CustomerResponsibility> harmOneImage(String id, Integer time);
|
||||
}
|
||||
@@ -0,0 +1,500 @@
|
||||
package com.njcn.product.diagram.LedgerScale.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.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.product.advance.eventSource.mapper.RmpEventDetailAssMapper;
|
||||
import com.njcn.product.advance.eventSource.pojo.po.RmpEventDetailAssPO;
|
||||
import com.njcn.product.advance.harmonicUp.mapper.UpHarmonicDetailMapper;
|
||||
import com.njcn.product.advance.harmonicUp.pojo.po.UpHarmonicDetail;
|
||||
import com.njcn.product.advance.responsility.mapper.RespDataResultMapper;
|
||||
import com.njcn.product.advance.responsility.pojo.dto.CustomerData;
|
||||
import com.njcn.product.advance.responsility.pojo.dto.CustomerResponsibility;
|
||||
import com.njcn.product.advance.responsility.pojo.dto.ResponsibilityResult;
|
||||
import com.njcn.product.advance.responsility.pojo.po.RespDataResult;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.dto.EventSourceDTO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventDetailVO;
|
||||
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventLedgerVO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.mapper.LineMapper;
|
||||
import com.njcn.product.terminal.mysqlTerminal.mapper.UserReportPOMapper;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.UserReportPO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalShowVO;
|
||||
import com.njcn.product.diagram.LedgerScale.service.LedgerScaleService;
|
||||
import com.njcn.product.system.dict.mapper.DictDataMapper;
|
||||
import com.njcn.product.system.dict.pojo.enums.DicDataTypeEnum;
|
||||
import com.njcn.product.system.dict.pojo.po.DictData;
|
||||
import com.njcn.product.terminal.mysqlTerminal.mapper.LedgerScaleMapper;
|
||||
import com.njcn.product.terminal.mysqlTerminal.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerBaseInfo;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.enums.RunFlagEnum;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.param.LargeScreenCountParam;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.service.CommGeneralService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-01
|
||||
* @Description: 台账规模
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class LedgerScaleServiceImpl implements LedgerScaleService {
|
||||
|
||||
private final CommGeneralService commGeneralService;
|
||||
|
||||
private final LedgerScaleMapper ledgerScaleMapper;
|
||||
|
||||
private final RmpEventDetailMapper rmpEventDetailMapper;
|
||||
|
||||
private final RmpEventDetailAssMapper rmpEventDetailAssMapper;
|
||||
private final DictDataMapper dictDataMapper;
|
||||
private final LineMapper lineMapper;
|
||||
|
||||
private final RespDataResultMapper respDataResultMapper;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final UserReportPOMapper userReportPOMapper;
|
||||
private final UpHarmonicDetailMapper upHarmonicDetailMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public LedgerScaleDTO ledgerScaleStatistic(LargeScreenCountParam param) {
|
||||
LedgerScaleDTO ledgerScaleDTO = new LedgerScaleDTO();
|
||||
|
||||
List<String> deptIds = commGeneralService.getAllLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "用户部门没有绑定监测点");
|
||||
}
|
||||
|
||||
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getLedgerBaseInfo(deptIds);
|
||||
|
||||
List<LedgerBaseInfo> runList = ledgerBaseInfoList.stream().filter(it -> Objects.equals(it.getRunFlag(), RunFlagEnum.RUNNING.getStatus())).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<LedgerBaseInfo> onlineList = runList.stream().filter(it -> it.getComFlag() == 1).collect(Collectors.toList());
|
||||
|
||||
ledgerScaleDTO.setLineAll(runList.size());
|
||||
ledgerScaleDTO.setLineRun(onlineList.size());
|
||||
|
||||
long devAll = ledgerBaseInfoList.stream().map(LedgerBaseInfo::getDevId).distinct().count();
|
||||
long devRun = runList.stream().map(LedgerBaseInfo::getDevId).distinct().count();
|
||||
ledgerScaleDTO.setDevAll((int) devAll);
|
||||
ledgerScaleDTO.setDevRun((int) devRun);
|
||||
|
||||
long stationAll = ledgerBaseInfoList.stream().map(LedgerBaseInfo::getStationId).distinct().count();
|
||||
long stationRun = runList.stream().map(LedgerBaseInfo::getStationId).distinct().count();
|
||||
ledgerScaleDTO.setStationAll((int) stationAll);
|
||||
ledgerScaleDTO.setStationRun((int) stationRun);
|
||||
return ledgerScaleDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventSourceDTO eventSource(LargeScreenCountParam param) {
|
||||
EventSourceDTO eventSourceDTO = new EventSourceDTO();
|
||||
List<String> deptIds = commGeneralService.getRunLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return eventSourceDTO;
|
||||
}
|
||||
|
||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()));
|
||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()));
|
||||
|
||||
|
||||
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.between(RmpEventDetailPO::getStartTime, start, end).in(RmpEventDetailPO::getLineId, deptIds);
|
||||
List<RmpEventDetailPO> eventList = rmpEventDetailMapper.selectList(lambdaQueryWrapper);
|
||||
if (CollUtil.isEmpty(eventList)) {
|
||||
return eventSourceDTO;
|
||||
}
|
||||
|
||||
List<String> ids = eventList.stream().map(RmpEventDetailPO::getLineId).distinct().collect(Collectors.toList());
|
||||
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getBaseInfo(ids);
|
||||
Map<String, LedgerBaseInfo> objMap = ledgerBaseInfoList.stream().collect(Collectors.toMap(LedgerBaseInfo::getLineId, Function.identity()));
|
||||
|
||||
Map<String, List<RmpEventDetailPO>> map = eventList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getLineId));
|
||||
|
||||
List<EventSourceDTO.Inner> innerList = new ArrayList<>();
|
||||
map.forEach((k, val) -> {
|
||||
EventSourceDTO.Inner inner = new EventSourceDTO.Inner();
|
||||
LedgerBaseInfo ledgerBaseInfo = objMap.get(k);
|
||||
inner.setName(StrUtil.isNotBlank(ledgerBaseInfo.getObjName()) ? ledgerBaseInfo.getObjName() : ledgerBaseInfo.getLineName());
|
||||
inner.setCount(val.size());
|
||||
inner.setId(ledgerBaseInfo.getLineId());
|
||||
innerList.add(inner);
|
||||
});
|
||||
eventSourceDTO.setEventCount(eventList.size());
|
||||
eventSourceDTO.setInnerList(innerList);
|
||||
|
||||
return eventSourceDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventSourceDTO eventAggregation(LargeScreenCountParam param) {
|
||||
EventSourceDTO eventSourceDTO = new EventSourceDTO();
|
||||
|
||||
|
||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()));
|
||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()));
|
||||
|
||||
LambdaQueryWrapper<RmpEventDetailAssPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.orderByDesc(RmpEventDetailAssPO::getTimeId).between(RmpEventDetailAssPO::getTimeId, start, end);
|
||||
List<RmpEventDetailAssPO> assPOList = rmpEventDetailAssMapper.selectList(lambdaQueryWrapper);
|
||||
if (CollUtil.isEmpty(assPOList)) {
|
||||
return eventSourceDTO;
|
||||
}
|
||||
/* Map<String, RmpEventDetailAssPO> assObjMap = assPOList.stream().collect(Collectors.toMap(RmpEventDetailAssPO::getEventAssId, Function.identity()));
|
||||
|
||||
List<String> assIds = assPOList.stream().map(RmpEventDetailAssPO::getEventAssId).collect(Collectors.toList());
|
||||
List<RmpEventDetailPO> rmpEventDetailPOList = rmpEventDetailMapper.selectList(new LambdaQueryWrapper<RmpEventDetailPO>().in(RmpEventDetailPO::getEventassIndex, assIds));
|
||||
|
||||
|
||||
Map<String, LocalDateTime> assMap = assPOList.stream().collect(Collectors.toMap(RmpEventDetailAssPO::getEventAssId, RmpEventDetailAssPO::getTimeId));
|
||||
rmpEventDetailPOList = rmpEventDetailPOList.stream().filter(it -> {
|
||||
if (!assMap.containsKey(it.getEventassIndex())) {
|
||||
return false;
|
||||
}
|
||||
LocalDateTime localDateTime = assMap.get(it.getEventassIndex());
|
||||
if (it.getStartTime().equals(localDateTime)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}).collect(Collectors.toList());*/
|
||||
|
||||
eventSourceDTO.setEventCount(assPOList.size());
|
||||
|
||||
List<EventSourceDTO.Inner> innerList = new ArrayList<>();
|
||||
for (RmpEventDetailAssPO it : assPOList) {
|
||||
EventSourceDTO.Inner inner = new EventSourceDTO.Inner();
|
||||
inner.setId(it.getEventAssId());
|
||||
inner.setName(it.getContentDes());
|
||||
innerList.add(inner);
|
||||
}
|
||||
eventSourceDTO.setInnerList(innerList);
|
||||
return eventSourceDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventLedgerVO> hasEventList(LargeScreenCountParam param) {
|
||||
List<EventLedgerVO> result = new ArrayList<>();
|
||||
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isBlank(param.getEventAssId())) {
|
||||
List<String> ids = commGeneralService.getRunLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return result;
|
||||
}
|
||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()));
|
||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()));
|
||||
lambdaQueryWrapper.in(RmpEventDetailPO::getLineId, ids).between(RmpEventDetailPO::getStartTime, start, end);
|
||||
} else {
|
||||
lambdaQueryWrapper.eq(RmpEventDetailPO::getEventassIndex, param.getEventAssId());
|
||||
}
|
||||
|
||||
|
||||
List<RmpEventDetailPO> rmpEventDetailPOList = rmpEventDetailMapper.selectList(lambdaQueryWrapper);
|
||||
List<String> lineIds = rmpEventDetailPOList.stream().map(RmpEventDetailPO::getLineId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(lineIds)) {
|
||||
return result;
|
||||
}
|
||||
Map<String, LedgerBaseInfo> ledgerBaseInfoMap = ledgerScaleMapper.getLedgerBaseInfo(lineIds).stream().collect(Collectors.toMap(LedgerBaseInfo::getLineId, Function.identity()));
|
||||
Map<String, List<RmpEventDetailPO>> map = rmpEventDetailPOList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getLineId));
|
||||
|
||||
RmpEventDetailPO minPo = rmpEventDetailPOList.stream().min(Comparator.comparingDouble(RmpEventDetailPO::getFeatureAmplitude)).get();
|
||||
map.forEach((lineId, list) -> {
|
||||
|
||||
|
||||
|
||||
LedgerBaseInfo ledgerBaseInfo = ledgerBaseInfoMap.get(lineId);
|
||||
EventLedgerVO eventLedgerVO = new EventLedgerVO();
|
||||
BeanUtil.copyProperties(ledgerBaseInfo, eventLedgerVO);
|
||||
eventLedgerVO.setEventIds(list.stream().map(RmpEventDetailPO::getEventId).collect(Collectors.toList()));
|
||||
if (StrUtil.isBlank(param.getEventAssId())) {
|
||||
eventLedgerVO.setIsImport(DataStateEnum.DELETED.getCode());
|
||||
}else {
|
||||
if(minPo.getLineId().equals(lineId)){
|
||||
eventLedgerVO.setIsImport(DataStateEnum.ENABLE.getCode());
|
||||
}else {
|
||||
eventLedgerVO.setIsImport(DataStateEnum.DELETED.getCode());
|
||||
}
|
||||
}
|
||||
result.add(eventLedgerVO);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventLedgerVO> hasUpEventList(LargeScreenCountParam param) {
|
||||
List<EventLedgerVO> result = new ArrayList<>();
|
||||
List<String> ids = commGeneralService.getRunLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<UpHarmonicDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()));
|
||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()));
|
||||
lambdaQueryWrapper.in(UpHarmonicDetail::getMonitorId, ids).between(UpHarmonicDetail::getStartTime, start, end);
|
||||
List<UpHarmonicDetail> upHarmonicDetailList = upHarmonicDetailMapper.selectList(lambdaQueryWrapper);
|
||||
if(CollUtil.isEmpty(upHarmonicDetailList)){
|
||||
return result;
|
||||
}
|
||||
|
||||
List<String> monitorIds = upHarmonicDetailList.stream().map(UpHarmonicDetail::getMonitorId).distinct().collect(Collectors.toList());
|
||||
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getLedgerBaseInfo(monitorIds);
|
||||
Map<String,LedgerBaseInfo> ledgerBaseInfoMap = ledgerBaseInfoList.stream().collect(Collectors.toMap(LedgerBaseInfo::getLineId,Function.identity()));
|
||||
|
||||
Map<String,List<UpHarmonicDetail>> map = upHarmonicDetailList.stream().collect(Collectors.groupingBy(UpHarmonicDetail::getMonitorId));
|
||||
map.forEach((lineId,list)->{
|
||||
EventLedgerVO eventLedgerVO = new EventLedgerVO();
|
||||
BeanUtil.copyProperties(ledgerBaseInfoMap.get(lineId),eventLedgerVO);
|
||||
eventLedgerVO.setEventIds(list.stream().map(UpHarmonicDetail::getId).collect(Collectors.toList()));
|
||||
result.add(eventLedgerVO);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventLedgerVO clickImage(String lineId) {
|
||||
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getLedgerBaseInfo(Stream.of(lineId).collect(Collectors.toList()));
|
||||
if (CollUtil.isEmpty(ledgerBaseInfoList)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "当前节点未查询到测点信息");
|
||||
}
|
||||
|
||||
EventLedgerVO eventLedgerVO = new EventLedgerVO();
|
||||
BeanUtil.copyProperties(ledgerBaseInfoList.get(0), eventLedgerVO);
|
||||
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(RmpEventDetailPO::getLineId, lineId);
|
||||
List<RmpEventDetailPO> rmpEventDetailPOList = rmpEventDetailMapper.selectList(lambdaQueryWrapper);
|
||||
|
||||
List<DictData> dictDataList = dictDataMapper.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode());
|
||||
Map<String, DictData> dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
rmpEventDetailPOList.forEach(item-> item.setEventType(dictDataMap.get(item.getEventType()).getName()));
|
||||
eventLedgerVO.setEventList(rmpEventDetailPOList);
|
||||
return eventLedgerVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<EventDetailVO> eventList(LargeScreenCountParam param) {
|
||||
Page<EventDetailVO> result = new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param));
|
||||
|
||||
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isBlank(param.getEventAssId())) {
|
||||
List<String> ids = commGeneralService.getRunLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if(StrUtil.isNotBlank(param.getSearchValue())){
|
||||
ids = ledgerScaleMapper.getQueryLedger(ids,param.getSearchValue());
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()));
|
||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()));
|
||||
lambdaQueryWrapper.in(RmpEventDetailPO::getLineId, ids).between(RmpEventDetailPO::getStartTime, start, end).orderByDesc(RmpEventDetailPO::getStartTime);
|
||||
|
||||
if(StrUtil.isNotBlank(param.getEventType())){
|
||||
lambdaQueryWrapper.eq(RmpEventDetailPO::getEventType,param.getEventType());
|
||||
}
|
||||
|
||||
if(Objects.nonNull(param.getEventDurationMin()) ||Objects.nonNull(param.getEventDurationMax())){
|
||||
lambdaQueryWrapper.gt(Objects.nonNull(param.getEventDurationMin()),RmpEventDetailPO::getDuration,param.getEventDurationMin());
|
||||
lambdaQueryWrapper.lt(Objects.nonNull(param.getEventDurationMax()),RmpEventDetailPO::getDuration,param.getEventDurationMax());
|
||||
}
|
||||
|
||||
if(Objects.nonNull(param.getEventValueMin()) ||Objects.nonNull(param.getEventValueMax())){
|
||||
lambdaQueryWrapper.gt(Objects.nonNull(param.getEventValueMin()),RmpEventDetailPO::getFeatureAmplitude,param.getEventValueMin());
|
||||
lambdaQueryWrapper.lt(Objects.nonNull(param.getEventValueMax()),RmpEventDetailPO::getFeatureAmplitude,param.getEventValueMax());
|
||||
}
|
||||
|
||||
} else {
|
||||
lambdaQueryWrapper.eq(RmpEventDetailPO::getEventassIndex, param.getEventAssId());
|
||||
}
|
||||
|
||||
Page<RmpEventDetailPO> page = rmpEventDetailMapper.selectPage(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), lambdaQueryWrapper);
|
||||
if (CollUtil.isEmpty(page.getRecords())) {
|
||||
return result;
|
||||
}
|
||||
|
||||
List<String> lineIds = page.getRecords().stream().map(RmpEventDetailPO::getLineId).distinct().collect(Collectors.toList());
|
||||
Map<String, LedgerBaseInfo> ledgerBaseInfoMap = ledgerScaleMapper.getLedgerBaseInfo(lineIds).stream().collect(Collectors.toMap(LedgerBaseInfo::getLineId, Function.identity()));
|
||||
|
||||
List<DictData> dictDataList = dictDataMapper.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode());
|
||||
Map<String, DictData> dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
|
||||
List<EventDetailVO> temList = new ArrayList<>();
|
||||
page.getRecords().forEach(item -> {
|
||||
EventDetailVO eventDetailVO = new EventDetailVO();
|
||||
BeanUtil.copyProperties(item, eventDetailVO);
|
||||
|
||||
eventDetailVO.setFeatureAmplitude(BigDecimal.valueOf(item.getFeatureAmplitude()).setScale(5, RoundingMode.HALF_UP).doubleValue());
|
||||
eventDetailVO.setEventType(dictDataMap.get(eventDetailVO.getEventType()).getName());
|
||||
|
||||
if (ledgerBaseInfoMap.containsKey(item.getLineId())) {
|
||||
LedgerBaseInfo ledgerBaseInfo = ledgerBaseInfoMap.get(item.getLineId());
|
||||
BeanUtil.copyProperties(ledgerBaseInfo, eventDetailVO);
|
||||
}
|
||||
temList.add(eventDetailVO);
|
||||
});
|
||||
result.setRecords(temList);
|
||||
result.setTotal(page.getTotal());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<EventDetailVO> eventListByLineId(LargeScreenCountParam param) {
|
||||
Page<EventDetailVO> result = new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param));
|
||||
|
||||
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()));
|
||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()));
|
||||
lambdaQueryWrapper.eq(RmpEventDetailPO::getLineId, param.getLineId()).between(RmpEventDetailPO::getStartTime, start, end).orderByDesc(RmpEventDetailPO::getStartTime);
|
||||
|
||||
Page<RmpEventDetailPO> page = rmpEventDetailMapper.selectPage(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), lambdaQueryWrapper);
|
||||
if (CollUtil.isEmpty(page.getRecords())) {
|
||||
return result;
|
||||
}
|
||||
|
||||
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getLedgerBaseInfo(Collections.singletonList(param.getLineId()));
|
||||
LedgerBaseInfo ledgerBaseInfo = ledgerBaseInfoList.get(0);
|
||||
|
||||
List<DictData> dictDataList = dictDataMapper.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode());
|
||||
Map<String, DictData> dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
|
||||
List<EventDetailVO> temList = new ArrayList<>();
|
||||
page.getRecords().forEach(item -> {
|
||||
EventDetailVO eventDetailVO = new EventDetailVO();
|
||||
BeanUtil.copyProperties(item, eventDetailVO);
|
||||
|
||||
eventDetailVO.setFeatureAmplitude(BigDecimal.valueOf(item.getFeatureAmplitude()).setScale(5, RoundingMode.HALF_UP).doubleValue());
|
||||
eventDetailVO.setEventType(dictDataMap.get(eventDetailVO.getEventType()).getName());
|
||||
BeanUtil.copyProperties(ledgerBaseInfo, eventDetailVO);
|
||||
temList.add(eventDetailVO);
|
||||
});
|
||||
result.setRecords(temList);
|
||||
result.setTotal(page.getTotal());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<TerminalShowVO> stationPage(LargeScreenCountParam param) {
|
||||
List<String> lineIds = commGeneralService.getAllLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(lineIds)) {
|
||||
return new Page<>();
|
||||
}
|
||||
Page<TerminalShowVO> page = lineMapper.getStationList(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), lineIds, param.getRunFlag(), param.getSearchValue());
|
||||
if (CollUtil.isNotEmpty(page.getRecords())) {
|
||||
List<DictData> dictData = dictDataMapper.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode());
|
||||
Map<String, DictData> map = dictData.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
page.getRecords().forEach(it -> {
|
||||
if (map.containsKey(it.getStationVoltageLevel())) {
|
||||
it.setStationVoltageLevel(map.get(it.getStationVoltageLevel()).getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<TerminalShowVO> devPage(LargeScreenCountParam param) {
|
||||
List<String> lineIds = commGeneralService.getAllLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(lineIds)) {
|
||||
return new Page<>();
|
||||
}
|
||||
Page<TerminalShowVO> page = lineMapper.getDevList(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), lineIds, param.getRunFlag(), param.getSearchValue());
|
||||
if (CollUtil.isNotEmpty(page.getRecords())) {
|
||||
List<DictData> dictData = dictDataMapper.getDicDataByTypeCode(DicDataTypeEnum.DEV_MANUFACTURER.getCode());
|
||||
Map<String, DictData> map = dictData.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
page.getRecords().forEach(it -> {
|
||||
if (map.containsKey(it.getManufacturer())) {
|
||||
it.setManufacturer(map.get(it.getManufacturer()).getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TerminalShowVO> linePage(LargeScreenCountParam param) {
|
||||
List<String> lineIds = commGeneralService.getRunLineIdsByDept(param.getDeptId());
|
||||
if (CollUtil.isEmpty(lineIds)) {
|
||||
return new Page<>();
|
||||
}
|
||||
Page<TerminalShowVO> page = lineMapper.getLineList(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), lineIds, param.getComFlag(), param.getSearchValue());
|
||||
if (CollUtil.isNotEmpty(page.getRecords())) {
|
||||
List<DictData> dictData = dictDataMapper.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode());
|
||||
Map<String, DictData> map = dictData.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
page.getRecords().forEach(it -> {
|
||||
if (map.containsKey(it.getVoltageLevel())) {
|
||||
it.setVoltageLevel(map.get(it.getVoltageLevel()).getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomerResponsibility> harmOneImage(String id, Integer time) {
|
||||
LambdaQueryWrapper<RespDataResult> respDataResultLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
respDataResultLambdaQueryWrapper.eq(RespDataResult::getResDataId, id)
|
||||
.eq(RespDataResult::getTime, time).orderByDesc(RespDataResult::getCreateTime);
|
||||
List<RespDataResult> respDataResults = respDataResultMapper.selectList(respDataResultLambdaQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(respDataResults)) {
|
||||
|
||||
RespDataResult respDataResult = respDataResults.get(0);
|
||||
//处理排名前10数据
|
||||
InputStream respStream = fileStorageUtil.getFileStream(respDataResult.getUserResponsibility());
|
||||
String respStr = IoUtil.readUtf8(respStream);
|
||||
List<CustomerResponsibility> respData = JSONArray.parseArray(respStr, CustomerResponsibility.class);
|
||||
List<String> userNos = respData.stream().map(it -> it.getCustomerName().substring(it.getCustomerName().indexOf("(") + 1, it.getCustomerName().indexOf(")"))).collect(Collectors.toList());
|
||||
|
||||
List<LedgerBaseInfo> ledgerBaseInfoList = lineMapper.queryMonitorByUser(userNos);
|
||||
Map<String, LedgerBaseInfo> ledgerBaseInfoMap = ledgerBaseInfoList.stream().collect(Collectors.toMap(LedgerBaseInfo::getUserNo, Function.identity()));
|
||||
respData.forEach(it -> {
|
||||
String tem = it.getCustomerName().substring(it.getCustomerName().indexOf("(") + 1, it.getCustomerName().indexOf(")"));
|
||||
if (ledgerBaseInfoMap.containsKey(tem)) {
|
||||
LedgerBaseInfo ledgerBaseInfo = ledgerBaseInfoMap.get(tem);
|
||||
it.setMonitorId(ledgerBaseInfo.getLineId());
|
||||
}
|
||||
});
|
||||
return respData;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.product.diagram.job;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.njcn.product.advance.harmonicUp.service.HarmonicUpService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-09-19
|
||||
* @Description: 定时任务
|
||||
*/
|
||||
@Component
|
||||
@EnableScheduling
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class CustomJob {
|
||||
|
||||
private final HarmonicUpService harmonicUpService;
|
||||
|
||||
// 每天凌晨4:30执行
|
||||
@Scheduled(cron = "0 30 4 * * ?")
|
||||
public void UpHarmonicJob(){
|
||||
log.info("开始执行谐波放大调度任务--------------------------------");
|
||||
String date = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
||||
harmonicUpService.analyzePreData(date);
|
||||
log.info("执行谐波放大调度任务结束--------------------------------");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.product.diagram.websocket;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/13 15:09【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通信文本消息和二进制缓存区大小
|
||||
* 避免对接 第三方 报文过大时,Websocket 1009 错误
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Bean
|
||||
public ServletServerContainerFactoryBean createWebSocketContainer() {
|
||||
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
|
||||
// 在此处设置bufferSize
|
||||
container.setMaxTextMessageBufferSize(10240000);
|
||||
container.setMaxBinaryMessageBufferSize(10240000);
|
||||
container.setMaxSessionIdleTimeout(15 * 60000L);
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.njcn.product.diagram.websocket;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.product.cnzutai.zutai.pojo.dto.AskRealTimeDataDTO;
|
||||
import com.njcn.product.cnzutai.zutai.pojo.dto.RealTimeDataDTO;
|
||||
import com.njcn.product.cnzutai.zutai.pojo.vo.CsRtDataVO;
|
||||
import com.njcn.product.cnzutai.zutai.service.ILineTargetService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@ServerEndpoint(value = "/ws/{userId}")
|
||||
public class WebSocketServer {
|
||||
|
||||
private static final ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, Long> lastHeartbeatTime = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, ScheduledExecutorService> heartbeatExecutors = new ConcurrentHashMap<>();
|
||||
// 60秒超时
|
||||
private static final long HEARTBEAT_TIMEOUT = 60;
|
||||
|
||||
@Autowired
|
||||
private static ILineTargetService lineTargetService;
|
||||
|
||||
@Autowired
|
||||
public void setDataVQuery( ILineTargetService lineTargetService) {
|
||||
WebSocketServer.lineTargetService = lineTargetService;
|
||||
}
|
||||
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("userId") String userId) {
|
||||
if (StrUtil.isNotBlank(userId)) {
|
||||
sessions.put(userId, session);
|
||||
lastHeartbeatTime.put(userId, System.currentTimeMillis());
|
||||
sendMessage(session, "连接成功");
|
||||
System.out.println("用户 " + userId + " 已连接");
|
||||
|
||||
// 启动心跳检测
|
||||
startHeartbeat(session, userId);
|
||||
} else {
|
||||
try {
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.VIOLATED_POLICY, "用户ID不能为空"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session, @PathParam("userId") String userId) {
|
||||
if ("alive".equalsIgnoreCase(message)) {
|
||||
// 更新最后心跳时间
|
||||
lastHeartbeatTime.put(userId, System.currentTimeMillis());
|
||||
sendMessage(session, "over");
|
||||
} else {
|
||||
System.out.println("收到用户 " + userId + " 的消息: " + message);
|
||||
// TODO: 处理业务逻辑
|
||||
|
||||
AskRealTimeDataDTO param = JSONUtil.toBean(message,AskRealTimeDataDTO.class,true);
|
||||
if(Objects.isNull(message)){
|
||||
RealTimeDataDTO recallReplyDTO = new RealTimeDataDTO(500,"参数有误",1);
|
||||
sendMessage(session, JSONObject.toJSONString(recallReplyDTO));
|
||||
}else {
|
||||
List<CsRtDataVO> lineData = lineTargetService.getLineData(param.getPageId());
|
||||
List<CsRtDataVO> collect = lineData.stream().filter(temp -> (!CollectionUtils.isEmpty(param.getLineIdList())) && param.getLineIdList().contains(temp.getLineId())).collect(Collectors.toList());
|
||||
RealTimeDataDTO recallReplyDTO = new RealTimeDataDTO();
|
||||
recallReplyDTO.setCode(200);
|
||||
recallReplyDTO.setMessage(JSONObject.toJSONString(collect));
|
||||
|
||||
sendMessage(session,JSONObject.toJSONString(recallReplyDTO));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(Session session, CloseReason closeReason, @PathParam("userId") String userId) {
|
||||
// 移除用户并取消心跳检测
|
||||
sessions.remove(userId);
|
||||
lastHeartbeatTime.remove(userId);
|
||||
ScheduledExecutorService executor = heartbeatExecutors.remove(userId);
|
||||
if (executor != null) {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
System.out.println("用户 " + userId + " 已断开连接,状态码: " + closeReason.getCloseCode());
|
||||
}
|
||||
|
||||
@OnError
|
||||
public void onError(Session session, Throwable throwable, @PathParam("userId") String userId) {
|
||||
System.out.println("用户 " + userId + " 发生错误: " + throwable.getMessage());
|
||||
try {
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.UNEXPECTED_CONDITION, "发生错误"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessageToUser(String userId, String message) {
|
||||
Session session = sessions.get(userId);
|
||||
if (session != null && session.isOpen()) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息给用户 " + userId + " 失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
System.out.println("webSocket用户 " + userId + " 不在线或会话已关闭");
|
||||
}
|
||||
}
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
public void sendMessageToAll(String message) {
|
||||
sessions.forEach((userId, session) -> {
|
||||
System.out.println("给用户推送消息" + userId);
|
||||
if (session.isOpen()) {
|
||||
synchronized (lock) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息给用户 " + userId + " 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendMessage(Session session, String message) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void startHeartbeat(Session session, String userId) {
|
||||
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
heartbeatExecutors.put(userId, executor);
|
||||
|
||||
// 定期检查心跳
|
||||
executor.scheduleAtFixedRate(() -> {
|
||||
long lastTime = lastHeartbeatTime.getOrDefault(userId, 0L);
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
// 如果超过30秒没有收到心跳
|
||||
if (currentTime - lastTime > HEARTBEAT_TIMEOUT * 1000) {
|
||||
try {
|
||||
System.out.println("用户 " + userId + " 心跳超时,关闭连接");
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "心跳超时"));
|
||||
} catch (IOException e) {
|
||||
System.out.println("关闭用户 " + userId + " 连接时出错: " + e.getMessage());
|
||||
}
|
||||
executor.shutdown();
|
||||
heartbeatExecutors.remove(userId);
|
||||
}
|
||||
}, 0, 5, TimeUnit.SECONDS); // 每5秒检查一次
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user