调整预处理模块-监测点暂态指标明细_日统计
This commit is contained in:
@@ -12,11 +12,6 @@
|
||||
<name>预处理对外接口模块</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-db</artifactId>
|
||||
|
||||
@@ -19,32 +19,6 @@
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>user-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>process-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>harmonic-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
@@ -60,7 +34,33 @@
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>prepare-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!--pqs-influx-->
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>pqs-influx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>user-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>process-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>harmonic-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
@@ -77,7 +77,6 @@
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${org.mapstruct.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
@@ -88,7 +87,6 @@
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 要与mapstruct版本匹配,用同一时间的版本,不然会出现各种问题 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
@@ -96,17 +94,12 @@
|
||||
<version>${org.projectlombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>prepare-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 多数据源切换,当数据源为oracle时需要使用 -->
|
||||
<dependency>
|
||||
@@ -115,35 +108,13 @@
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--pqs-influx-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>pqs-influx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <!–oracle驱动–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
|
||||
<!-- <artifactId>ojdbc8</artifactId>-->
|
||||
<!-- <version>21.6.0.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.oracle.database.nls</groupId>-->
|
||||
<!-- <artifactId>orai18n</artifactId>-->
|
||||
<!-- <version>21.1.0.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow-spring-boot-starter</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>-->
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.yomahub</groupId>-->
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.njcn.prepare.harmonic.controller.line;
|
||||
|
||||
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.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.PqsEventdetailHandlerService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/12/28 13:47【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "监测点暂态指标超标明细")
|
||||
@RestController
|
||||
@RequestMapping("/eventdetail")
|
||||
@RequiredArgsConstructor
|
||||
public class PqsEventdetailController extends BaseController {
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
private final PqsEventdetailHandlerService pqsEventdetailHandlerService;
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/eventdetailHandler")
|
||||
@ApiOperation("监测点暂态指标处理")
|
||||
@ApiImplicitParam(name = "lineParam", value = "参数", required = true)
|
||||
public HttpResult<String> eventdetailHandler(@RequestBody @Validated LineParam lineParam){
|
||||
log.info(LocalDateTime.now()+"eventdetailHandler始执行");
|
||||
String methodDescribe = getMethodDescribe("eventdetailHandler");
|
||||
List<String> indexLists = new ArrayList<> ();
|
||||
if(CollectionUtils.isEmpty (lineParam.getLineIds ())){
|
||||
indexLists = commTerminalGeneralClient.getRunMonitorIds ().getData ();
|
||||
}else{
|
||||
indexLists = lineParam.getLineIds ();
|
||||
}
|
||||
lineParam.setLineIds (indexLists);
|
||||
|
||||
pqsEventdetailHandlerService.eventdetailHandler (lineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailService;
|
||||
@@ -40,25 +41,27 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class RMpEventdetailController extends BaseController {
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
private final RMpEventDetailService rMpEventDetailService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/eventdetailHandler")
|
||||
@ApiOperation("监测点暂态指标处理")
|
||||
@ApiImplicitParam(name = "lineParam", value = "参数", required = true)
|
||||
public HttpResult<String> eventdetailHandler(@RequestBody @Validated LineParam lineParam){
|
||||
log.info(LocalDateTime.now()+"eventdetailHandler始执行");
|
||||
public HttpResult<String> eventdetailHandler(@RequestBody @Validated LineParam lineParam) {
|
||||
log.info(LocalDateTime.now() + "eventdetailHandler始执行");
|
||||
String methodDescribe = getMethodDescribe("eventdetailHandler");
|
||||
List<String> indexLists = new ArrayList<> ();
|
||||
if(CollectionUtils.isEmpty (lineParam.getLineIds ())){
|
||||
indexLists = lineFeignClient.getLineList ( ).getData ( );
|
||||
}else{
|
||||
indexLists = lineParam.getLineIds ();
|
||||
List<String> indexLists;
|
||||
if (CollectionUtils.isEmpty(lineParam.getLineIds())) {
|
||||
indexLists = commTerminalGeneralClient.getRunMonitorIds().getData();
|
||||
} else {
|
||||
indexLists = lineParam.getLineIds();
|
||||
}
|
||||
lineParam.setLineIds (indexLists);
|
||||
lineParam.setLineIds(indexLists);
|
||||
|
||||
rMpEventDetailService.eventdetailHandler (lineParam);
|
||||
rMpEventDetailService.eventdetailHandler(lineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.Impl.line;
|
||||
|
||||
import com.njcn.harmonic.pojo.po.RMpEventDetailDPO;
|
||||
import com.njcn.harmonic.pojo.po.RMpEventDetailMPO;
|
||||
import com.njcn.harmonic.pojo.po.RMpEventDetailQPO;
|
||||
import com.njcn.harmonic.pojo.po.RMpEventDetailYPO;
|
||||
import com.njcn.prepare.harmonic.constant.AlgorithmParam;
|
||||
import com.njcn.prepare.harmonic.pojo.oracle.PqLinedetailPO;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.*;
|
||||
import com.njcn.prepare.harmonic.service.oracle.PqLinedetailPOService;
|
||||
import com.njcn.prepare.harmonic.service.oracle.PqsEventdetailService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/12/28 14:11【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PqsEventdetailHandlerServiceImpl implements PqsEventdetailHandlerService {
|
||||
|
||||
private final PqLinedetailPOService pqLinedetailPOService;
|
||||
|
||||
|
||||
private final PqsEventdetailService pqsEventdetailService;
|
||||
|
||||
private final RMpEventDetailDService rMpEventDetailDService;
|
||||
|
||||
private final RMpEventDetailMService rMpEventDetailMService;
|
||||
|
||||
private final RMpEventDetailQService rMpEventDetailQService;
|
||||
|
||||
private final RMpEventDetailYService rMpEventDetailYService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void eventdetailHandler(LineParam lineParam) {
|
||||
/*if (Objects.equals (lineParam.getDataSource ( ), AlgorithmParam.ORACLE_DATA)) {
|
||||
hanlderOracleData (lineParam);
|
||||
} else if (Objects.equals (lineParam.getDataSource ( ), AlgorithmParam.INFLUX_DATA)) {*/
|
||||
hanlderInfludxbData (lineParam);
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* @Description: hanlderInfludxbData
|
||||
* @Param: [lineParam]
|
||||
* @return: void
|
||||
* @Author: clam
|
||||
* @Date: 2022/12/28
|
||||
*/
|
||||
private void hanlderInfludxbData(LineParam lineParam) {
|
||||
}
|
||||
/**
|
||||
* @Description: hanlderOracleData
|
||||
* @Param: [lineParam]
|
||||
* @return: void
|
||||
* @Author: clam
|
||||
* @Date: 2022/12/28
|
||||
*/
|
||||
private void hanlderOracleData(LineParam lineParam) {
|
||||
Integer type = lineParam.getType ( );
|
||||
switch (type) {
|
||||
case 1:
|
||||
this.hanlderOracleYear (lineParam);
|
||||
break;
|
||||
case 2:
|
||||
this.hanlderOracleQtr (lineParam);
|
||||
break;
|
||||
case 3:
|
||||
this.hanlderOracleMonth (lineParam);
|
||||
break;
|
||||
case 5:
|
||||
this.hanlderOracleDay (lineParam);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@SneakyThrows
|
||||
private void hanlderOracleYear(LineParam lineParam) {
|
||||
List<String> lineIds = lineParam.getLineIds ( );
|
||||
String dataDate = lineParam.getDataDate ( );
|
||||
final Date tempDate = new SimpleDateFormat ("yyyy-MM-dd").parse (dataDate);
|
||||
List<RMpEventDetailYPO> rMpEventDetailYPOList = new ArrayList<> ( );
|
||||
|
||||
lineIds.forEach (lineId -> {
|
||||
/*查询月表数据生成年表数据*/
|
||||
List<RMpEventDetailMPO> rMpEventDetailMPOList = rMpEventDetailMService.queryOneYearData(lineId,dataDate);
|
||||
int sagCount = rMpEventDetailMPOList.stream ( ).mapToInt (RMpEventDetailMPO::getSagTimes).sum ( );
|
||||
int riseCount = rMpEventDetailMPOList.stream ( ).mapToInt (RMpEventDetailMPO::getSwellTimes).sum ( );
|
||||
int interruptCount = rMpEventDetailMPOList.stream ( ).mapToInt (RMpEventDetailMPO::getInterruptTimes).sum ( );
|
||||
|
||||
RMpEventDetailYPO rMpEventDetailYPO = new RMpEventDetailYPO();
|
||||
rMpEventDetailYPO.setMeasurementPointId (lineId);
|
||||
rMpEventDetailYPO.setDataDate (tempDate);
|
||||
rMpEventDetailYPO.setSagTimes (sagCount);
|
||||
rMpEventDetailYPO.setSwellTimes (riseCount);
|
||||
rMpEventDetailYPO.setInterruptTimes (interruptCount);
|
||||
rMpEventDetailYPOList.add (rMpEventDetailYPO);
|
||||
|
||||
});
|
||||
|
||||
rMpEventDetailYService.saveOrUpdateBatchByMultiId (rMpEventDetailYPOList,500);
|
||||
|
||||
|
||||
}
|
||||
@SneakyThrows
|
||||
private void hanlderOracleQtr(LineParam lineParam) {
|
||||
List<String> lineIds = lineParam.getLineIds ( );
|
||||
String dataDate = lineParam.getDataDate ( );
|
||||
final Date tempDate = new SimpleDateFormat ("yyyy-MM-dd").parse (dataDate);
|
||||
List<RMpEventDetailQPO> rMpEventDetailQPOList = new ArrayList<> ( );
|
||||
|
||||
lineIds.forEach (lineId -> {
|
||||
/*查询月表数据生成季表数据*/
|
||||
List<RMpEventDetailMPO> rMpEventDetailMPOList = rMpEventDetailMService.queryOneQtrData(lineId,dataDate);
|
||||
int sagCount = rMpEventDetailMPOList.stream ( ).mapToInt (RMpEventDetailMPO::getSagTimes).sum ( );
|
||||
int riseCount = rMpEventDetailMPOList.stream ( ).mapToInt (RMpEventDetailMPO::getSwellTimes).sum ( );
|
||||
int interruptCount = rMpEventDetailMPOList.stream ( ).mapToInt (RMpEventDetailMPO::getInterruptTimes).sum ( );
|
||||
|
||||
RMpEventDetailQPO rMpEventDetailQPO = new RMpEventDetailQPO();
|
||||
rMpEventDetailQPO.setMeasurementPointId (lineId);
|
||||
rMpEventDetailQPO.setDataDate (tempDate);
|
||||
rMpEventDetailQPO.setSagTimes (sagCount);
|
||||
rMpEventDetailQPO.setSwellTimes (riseCount);
|
||||
rMpEventDetailQPO.setInterruptTimes (interruptCount);
|
||||
rMpEventDetailQPOList.add (rMpEventDetailQPO);
|
||||
|
||||
});
|
||||
|
||||
rMpEventDetailQService.saveOrUpdateBatchByMultiId (rMpEventDetailQPOList,500);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private void hanlderOracleMonth(LineParam lineParam) {
|
||||
List<String> lineIds = lineParam.getLineIds ( );
|
||||
String dataDate = lineParam.getDataDate ( );
|
||||
final Date tempDate = new SimpleDateFormat ("yyyy-MM-dd").parse (dataDate);
|
||||
List<RMpEventDetailMPO> rMpEventDetailMPOList = new ArrayList<> ( );
|
||||
|
||||
lineIds.forEach (lineId -> {
|
||||
/*查询day表数据生成月表数据*/
|
||||
List<RMpEventDetailDPO> rMpEventDetailDPOList = rMpEventDetailDService.queryOneMothData(lineId,dataDate);
|
||||
int sagCount = rMpEventDetailDPOList.stream ( ).mapToInt (RMpEventDetailDPO::getSagTimes).sum ( );
|
||||
int riseCount = rMpEventDetailDPOList.stream ( ).mapToInt (RMpEventDetailDPO::getSwellTimes).sum ( );
|
||||
int interruptCount = rMpEventDetailDPOList.stream ( ).mapToInt (RMpEventDetailDPO::getInterruptTimes).sum ( );
|
||||
|
||||
RMpEventDetailMPO rMpEventDetailMPO = new RMpEventDetailMPO();
|
||||
rMpEventDetailMPO.setMeasurementPointId (lineId);
|
||||
rMpEventDetailMPO.setDataDate (tempDate);
|
||||
rMpEventDetailMPO.setSagTimes (sagCount);
|
||||
rMpEventDetailMPO.setSwellTimes (riseCount);
|
||||
rMpEventDetailMPO.setInterruptTimes (interruptCount);
|
||||
rMpEventDetailMPOList.add (rMpEventDetailMPO);
|
||||
|
||||
});
|
||||
|
||||
rMpEventDetailMService.saveOrUpdateBatchByMultiId (rMpEventDetailMPOList,500);
|
||||
|
||||
}
|
||||
@SneakyThrows
|
||||
private void hanlderOracleDay(LineParam lineParam) {
|
||||
|
||||
List<String> lineIds = lineParam.getLineIds ( );
|
||||
String dataDate = lineParam.getDataDate ( );
|
||||
final Date tempDate = new SimpleDateFormat ("yyyy-MM-dd").parse (dataDate);
|
||||
List<RMpEventDetailDPO> rMpEventDetailDPOList = new ArrayList<> ( );
|
||||
|
||||
|
||||
lineIds.forEach (lineId -> {
|
||||
|
||||
/*获取mysql与Oracle监测点id对应关系*/
|
||||
|
||||
PqLinedetailPO oracleIndexIdByMonitorId = pqLinedetailPOService.getOracleIndexIdByMonitorId (lineId);
|
||||
|
||||
Integer sagCount = pqsEventdetailService.queryByCondition (oracleIndexIdByMonitorId.getLineIndex(),dataDate,AlgorithmParam.SAG);
|
||||
Integer riseCount = pqsEventdetailService.queryByCondition (oracleIndexIdByMonitorId.getLineIndex(),dataDate,AlgorithmParam.RISE);
|
||||
Integer interruptCount = pqsEventdetailService.queryByCondition (oracleIndexIdByMonitorId.getLineIndex(),dataDate,AlgorithmParam.INTERRUPT);
|
||||
RMpEventDetailDPO rMpEventDetailDPO = new RMpEventDetailDPO();
|
||||
rMpEventDetailDPO.setMeasurementPointId (lineId);
|
||||
rMpEventDetailDPO.setDataDate (tempDate);
|
||||
rMpEventDetailDPO.setSagTimes (sagCount);
|
||||
rMpEventDetailDPO.setSwellTimes (riseCount);
|
||||
rMpEventDetailDPO.setInterruptTimes (interruptCount);
|
||||
|
||||
rMpEventDetailDPOList.add (rMpEventDetailDPO);
|
||||
});
|
||||
|
||||
rMpEventDetailDService.saveOrUpdateBatchByMultiId (rMpEventDetailDPOList,500);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2023/4/23 13:50【需求编号】
|
||||
@@ -37,7 +36,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RMpEventDetailServiceImpl extends ServiceImpl<RMpEventDetailMapper, RMpEventDetailPO> implements RMpEventDetailService{
|
||||
public class RMpEventDetailServiceImpl extends ServiceImpl<RMpEventDetailMapper, RMpEventDetailPO> implements RMpEventDetailService {
|
||||
|
||||
private final RMpEventDetailDService rMpEventDetailDService;
|
||||
|
||||
@@ -54,18 +53,6 @@ public class RMpEventDetailServiceImpl extends ServiceImpl<RMpEventDetailMapper,
|
||||
this.hanlderData(lineParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryByCondition(String measurementPointId, String dataDate, String eventType) {
|
||||
QueryWrapper<RMpEventDetailPO> queryWrapper = new QueryWrapper ( );
|
||||
queryWrapper.select ("1").
|
||||
eq ("measurement_point_id", measurementPointId).
|
||||
eq ("event_type",eventType).
|
||||
eq("DATE_FORMAT( start_time ,'%Y-%m-%d')",dataDate);
|
||||
|
||||
Integer integer = this.getBaseMapper ().selectCount (queryWrapper);
|
||||
|
||||
return integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: hanlderOracleData
|
||||
@@ -75,7 +62,7 @@ public class RMpEventDetailServiceImpl extends ServiceImpl<RMpEventDetailMapper,
|
||||
* @Date: 2022/12/28
|
||||
*/
|
||||
private void hanlderData(LineParam lineParam) {
|
||||
Integer type = lineParam.getType ( );
|
||||
Integer type = lineParam.getType();
|
||||
switch (type) {
|
||||
// case 1:
|
||||
// this.hanlderYear (lineParam);
|
||||
@@ -84,78 +71,88 @@ public class RMpEventDetailServiceImpl extends ServiceImpl<RMpEventDetailMapper,
|
||||
// this.hanlderQtr (lineParam);
|
||||
// break;
|
||||
case 3:
|
||||
this.hanlderMonth (lineParam);
|
||||
this.hanlderMonth(lineParam);
|
||||
break;
|
||||
case 5:
|
||||
this.hanlderDay (lineParam);
|
||||
this.hanlderDay(lineParam);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private void hanlderMonth(LineParam lineParam) {
|
||||
|
||||
List<String> lineIds = lineParam.getLineIds();
|
||||
String dataDate = lineParam.getDataDate();
|
||||
final Date tempDate = new SimpleDateFormat("yyyy-MM-dd").parse(dataDate);
|
||||
List<RMpEventDetailMPO> rMpEventDetailMPOList = new ArrayList<>();
|
||||
|
||||
List<String> lineIds = lineParam.getLineIds ( );
|
||||
String dataDate = lineParam.getDataDate ( );
|
||||
final Date tempDate = new SimpleDateFormat ("yyyy-MM-dd").parse (dataDate);
|
||||
List<RMpEventDetailMPO> rMpEventDetailMPOList = new ArrayList<> ( );
|
||||
|
||||
lineIds.forEach (measurementPointId -> {
|
||||
lineIds.forEach(measurementPointId -> {
|
||||
/*查询day表数据生成月表数据*/
|
||||
List<RMpEventDetailDPO> rMpEventDetailDPOList = rMpEventDetailDService.queryOneMothData(measurementPointId,dataDate);
|
||||
int sagCount = rMpEventDetailDPOList.stream ( ).mapToInt (RMpEventDetailDPO::getSagTimes).sum ( );
|
||||
int riseCount = rMpEventDetailDPOList.stream ( ).mapToInt (RMpEventDetailDPO::getSwellTimes).sum ( );
|
||||
int interruptCount = rMpEventDetailDPOList.stream ( ).mapToInt (RMpEventDetailDPO::getInterruptTimes).sum ( );
|
||||
List<RMpEventDetailDPO> rMpEventDetailDPOList = rMpEventDetailDService.queryOneMothData(measurementPointId, dataDate);
|
||||
int sagCount = rMpEventDetailDPOList.stream().mapToInt(RMpEventDetailDPO::getSagTimes).sum();
|
||||
int riseCount = rMpEventDetailDPOList.stream().mapToInt(RMpEventDetailDPO::getSwellTimes).sum();
|
||||
int interruptCount = rMpEventDetailDPOList.stream().mapToInt(RMpEventDetailDPO::getInterruptTimes).sum();
|
||||
|
||||
RMpEventDetailMPO rMpEventDetailMPO = new RMpEventDetailMPO();
|
||||
rMpEventDetailMPO.setMeasurementPointId (measurementPointId);
|
||||
rMpEventDetailMPO.setDataDate (tempDate);
|
||||
rMpEventDetailMPO.setSagTimes (sagCount);
|
||||
rMpEventDetailMPO.setSwellTimes (riseCount);
|
||||
rMpEventDetailMPO.setInterruptTimes (interruptCount);
|
||||
rMpEventDetailMPOList.add (rMpEventDetailMPO);
|
||||
rMpEventDetailMPO.setMeasurementPointId(measurementPointId);
|
||||
rMpEventDetailMPO.setDataDate(tempDate);
|
||||
rMpEventDetailMPO.setSagTimes(sagCount);
|
||||
rMpEventDetailMPO.setSwellTimes(riseCount);
|
||||
rMpEventDetailMPO.setInterruptTimes(interruptCount);
|
||||
rMpEventDetailMPOList.add(rMpEventDetailMPO);
|
||||
|
||||
});
|
||||
|
||||
rMpEventDetailMService.saveOrUpdateBatchByMultiId (rMpEventDetailMPOList,500);
|
||||
rMpEventDetailMService.saveOrUpdateBatchByMultiId(rMpEventDetailMPOList, 500);
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
private void hanlderDay(LineParam lineParam) {
|
||||
|
||||
List<String> lineIds = lineParam.getLineIds ( );
|
||||
String dataDate = lineParam.getDataDate ( );
|
||||
final Date tempDate = new SimpleDateFormat ("yyyy-MM-dd").parse (dataDate);
|
||||
List<RMpEventDetailDPO> rMpEventDetailDPOList = new ArrayList<> ( );
|
||||
List<String> lineIds = lineParam.getLineIds();
|
||||
String dataDate = lineParam.getDataDate();
|
||||
final Date tempDate = new SimpleDateFormat("yyyy-MM-dd").parse(dataDate);
|
||||
List<RMpEventDetailDPO> rMpEventDetailDPOList = new ArrayList<>();
|
||||
|
||||
|
||||
lineIds.forEach (measurementPointId -> {
|
||||
Integer sagCount = this.queryByCondition (measurementPointId,dataDate, getEventTypeId(DicDataEnum.VOLTAGE_DIP.getCode ( )));
|
||||
Integer riseCount = this.queryByCondition (measurementPointId,dataDate,getEventTypeId(DicDataEnum.VOLTAGE_RISE.getCode ( )));
|
||||
Integer interruptCount = this.queryByCondition (measurementPointId,dataDate,getEventTypeId(DicDataEnum.SHORT_INTERRUPTIONS.getCode ( )));
|
||||
lineIds.forEach(measurementPointId -> {
|
||||
Integer sagCount = this.queryByCondition(measurementPointId, dataDate, getEventTypeId(DicDataEnum.VOLTAGE_DIP.getCode()));
|
||||
Integer riseCount = this.queryByCondition(measurementPointId, dataDate, getEventTypeId(DicDataEnum.VOLTAGE_RISE.getCode()));
|
||||
Integer interruptCount = this.queryByCondition(measurementPointId, dataDate, getEventTypeId(DicDataEnum.SHORT_INTERRUPTIONS.getCode()));
|
||||
RMpEventDetailDPO rMpEventDetailDPO = new RMpEventDetailDPO();
|
||||
rMpEventDetailDPO.setMeasurementPointId (measurementPointId);
|
||||
rMpEventDetailDPO.setDataDate (tempDate);
|
||||
rMpEventDetailDPO.setSagTimes (sagCount);
|
||||
rMpEventDetailDPO.setSwellTimes (riseCount);
|
||||
rMpEventDetailDPO.setInterruptTimes (interruptCount);
|
||||
rMpEventDetailDPO.setMeasurementPointId(measurementPointId);
|
||||
rMpEventDetailDPO.setDataDate(tempDate);
|
||||
rMpEventDetailDPO.setSagTimes(sagCount);
|
||||
rMpEventDetailDPO.setSwellTimes(riseCount);
|
||||
rMpEventDetailDPO.setInterruptTimes(interruptCount);
|
||||
|
||||
rMpEventDetailDPOList.add (rMpEventDetailDPO);
|
||||
rMpEventDetailDPOList.add(rMpEventDetailDPO);
|
||||
});
|
||||
|
||||
rMpEventDetailDService.saveOrUpdateBatchByMultiId (rMpEventDetailDPOList,500);
|
||||
rMpEventDetailDService.saveOrUpdateBatchByMultiId(rMpEventDetailDPOList, 500);
|
||||
}
|
||||
|
||||
public String getEventTypeId(String code){
|
||||
public Integer queryByCondition(String measurementPointId, String dataDate, String eventType) {
|
||||
QueryWrapper<RMpEventDetailPO> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.select("1").
|
||||
eq("measurement_point_id", measurementPointId).
|
||||
eq("event_type", eventType).
|
||||
eq("DATE_FORMAT( start_time ,'%Y-%m-%d')", dataDate);
|
||||
|
||||
String eventType =redisUtil.getStringByKey (code);
|
||||
eventType = Optional.ofNullable (eventType).orElseGet (() ->{
|
||||
DictData data = dicDataFeignClient.getDicDataByCode (code).getData ( );
|
||||
redisUtil.saveByKey (data.getCode (),data.getId ());
|
||||
return data.getId ();
|
||||
return this.getBaseMapper().selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
public String getEventTypeId(String code) {
|
||||
|
||||
String eventType = redisUtil.getStringByKey(code);
|
||||
eventType = Optional.ofNullable(eventType).orElseGet(() -> {
|
||||
DictData data = dicDataFeignClient.getDicDataByCode(code).getData();
|
||||
redisUtil.saveByKey(data.getCode(), data.getId());
|
||||
return data.getId();
|
||||
});
|
||||
|
||||
return eventType;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.line;
|
||||
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/12/28 13:46【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface PqsEventdetailHandlerService {
|
||||
|
||||
|
||||
void eventdetailHandler(LineParam lineParam);
|
||||
}
|
||||
@@ -24,5 +24,4 @@ public interface RMpEventDetailService extends IService<RMpEventDetailPO>{
|
||||
*/
|
||||
void eventdetailHandler(LineParam lineParam);
|
||||
|
||||
Integer queryByCondition(String lineId, String dataDate, String eventType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user