预处理模块添加异步处理

This commit is contained in:
2022-11-11 14:56:01 +08:00
parent 0cf030f502
commit 17c1a99f12
16 changed files with 129 additions and 40 deletions

View File

@@ -233,7 +233,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
default:
break;
}
if (Integer.parseInt(contion) != 60 || Integer.parseInt(contion) != 61 || Integer.parseInt(contion) != 62) {
if (!Integer.valueOf(contion).equals(60) && !Integer.valueOf(contion).equals(61) && !Integer.valueOf(contion).equals(62)) {
stringBuilder.append(" and ").append(InfluxDBPublicParam.VALUETYPE + "='").append(valueTypeName).append("'");
}
String sql = "";

View File

@@ -0,0 +1,36 @@
package com.njcn.executor.handler;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.executor.utils.CommonExecutorUtils;
import com.njcn.prepare.harmonic.api.line.HarmonicGeneralFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* pqs
* 稳态综合评估
* @author cdf
* @date 2022/11/11
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class HarmComprehensiveAssessJob {
private final HarmonicGeneralFeignClient harmonicGeneralFeignClient;
@XxlJob("comprehensiveAssessHandler")
public void comprehensiveAssessHandler(){
LineParam lineParam = new LineParam();
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
//下面测试数据部署需删除
//lineParam.setDataDate("2022-10-27");
harmonicGeneralFeignClient.generalData(lineParam);
}
}

View File

@@ -28,7 +28,6 @@ public class HarmCustomReportJob {
@XxlJob("harmCustomReportHandler")
public void harmCustomReportHandler(){
long a = System.currentTimeMillis();
String command = XxlJobHelper.getJobParam();
LineParam lineParam = new LineParam();
@@ -38,8 +37,6 @@ public class HarmCustomReportJob {
//date = "2022-10-26";
lineParam.setDataDate(date);
coustmReportFeignClient.batchReport(lineParam);
long b = System.currentTimeMillis();
System.out.println("时间"+(b-a)/1000);
}

View File

@@ -0,0 +1,37 @@
package com.njcn.executor.handler;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.executor.utils.CommonExecutorUtils;
import com.njcn.prepare.harmonic.api.line.HarmonicGeneralFeignClient;
import com.njcn.prepare.harmonic.api.line.HarmonicMetricFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* pqs
* 稳态指标评估
* @author cdf
* @date 2022/11/11
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class HarmKpiAssessJob {
private final HarmonicMetricFeignClient harmonicMetricFeignClient;
@XxlJob("kpiAssessHandler")
public void kpiAssessHandler(){
LineParam lineParam = new LineParam();
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
//下面测试数据部署需删除
//lineParam.setDataDate("2022-10-27");
harmonicMetricFeignClient.metricData(lineParam);
}
}

View File

@@ -18,6 +18,8 @@ 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;
/**
* @author denghuajun
* @version 1.0.0
@@ -37,12 +39,7 @@ public class NormalLimitController extends BaseController {
@ApiOperation("告警数据预处理")
public HttpResult<String> getNormLimitData(@RequestBody LineParam lineParam) {
String methodDescribe = getMethodDescribe("getNormLimitData");
try {
normLimitService.AbnormalLineData(lineParam);
}catch (Exception e){
e.printStackTrace();
log.error("告警数据预处理异常:"+e.getMessage());
}
normLimitService.AbnormalLineData(lineParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -20,6 +20,7 @@ import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@@ -72,6 +73,7 @@ public class DayDataServiceImpl implements DayDataService {
@Transactional(
rollbackFor = {Exception.class}
)
@Async("asyncExecutor")
public void dayDataJobHandler(List<String> indexLists, String startTime, String endTime) {
@@ -3071,13 +3073,13 @@ public class DayDataServiceImpl implements DayDataService {
return result ;
}
/**
* @Description: packageRMpInharmonicIRateReportDPO
* @Param: [dataInHarmRateIPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpInharmonicIRateReportDPO
/**
* @Description: packageRMpInharmonicIRateReportDPO
* @Param: [dataInHarmRateIPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpInharmonicIRateReportDPO
* @Author: clam
* @Date: 2022/10/26
*/
* @Date: 2022/10/26
*/
private RMpInharmonicIRateReportDPO packageRMpInharmonicIRateReportDPO(List<DataInHarmRateIPO> dataInHarmRateIPO, String PhaseType) {
RMpInharmonicIRateReportDPO result = null;
@@ -3117,13 +3119,13 @@ public class DayDataServiceImpl implements DayDataService {
return result ;
}
/**
/**
* @Description: packageRMpInharmonicIMagReportDPO
* @Param: [dataInHarmIPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpInharmonicIMagReportDPO
* @Param: [dataInHarmIPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpInharmonicIMagReportDPO
* @Author: clam
* @Date: 2022/10/27
*/
* @Date: 2022/10/27
*/
private RMpInharmonicIMagReportDPO packageRMpInharmonicIMagReportDPO(List<DataInHarmIPO> dataInHarmIPO, String PhaseType) {
RMpInharmonicIMagReportDPO result = null;
@@ -3164,14 +3166,14 @@ public class DayDataServiceImpl implements DayDataService {
return result ;
}
/**
* @Description: packageRMpInharmonicVRateReportDPO
* @Param: [dataInHarmRateVPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpInharmonicVRateReportDPO
/**
* @Description: packageRMpInharmonicVRateReportDPO
* @Param: [dataInHarmRateVPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpInharmonicVRateReportDPO
* @Author: clam
* @Date: 2022/10/27
*/
* @Date: 2022/10/27
*/
private RMpInharmonicVRateReportDPO packageRMpInharmonicVRateReportDPO(List<DataInHarmRateVPO> dataInHarmRateVPO, String PhaseType) {
RMpInharmonicVRateReportDPO result = null ;
@@ -3212,13 +3214,13 @@ public class DayDataServiceImpl implements DayDataService {
return result ;
}
/**
* @Description: packageRMpHarmonicPReportDPO
* @Param: [dataHarmPowerPPO, dataHarmPowerQPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpHarmonicPReportDPO
/**
* @Description: packageRMpHarmonicPReportDPO
* @Param: [dataHarmPowerPPO, dataHarmPowerQPO, PhaseType]
* @return: com.njcn.prepare.harmonic.pojo.po.line.RMpHarmonicPReportDPO
* @Author: clam
* @Date: 2022/10/28
*/
* @Date: 2022/10/28
*/
private RMpHarmonicPReportDPO packageRMpHarmonicPReportDPO(List<DataHarmPowerPPO> dataHarmPowerPPO, List<DataHarmPowerQPO> dataHarmPowerQPO, String PhaseType) {
RMpHarmonicPReportDPO result = null ;

View File

@@ -13,6 +13,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@@ -39,6 +40,7 @@ public class DistortionRateServiceImpl implements DistortionRateService {
private final RMpVThdMapper rMpVThdMapper;
@Override
@Async("asyncExecutor")
public void distortionRate(LineParam lineParam) {
List<String> lineIdOutList;
if (CollUtil.isEmpty(lineParam.getLineIds())){

View File

@@ -16,6 +16,7 @@ import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -40,6 +41,7 @@ public class HarmonicGeneralServiceImpl implements HarmonicGeneralService {
private final LineFeignClient lineFeignClient;
@Override
@Async("asyncExecutor")
public void generalData(LineParam lineParam) {
List<String> lineIdOutList;
if (CollUtil.isEmpty(lineParam.getLineIds())){

View File

@@ -16,6 +16,7 @@ import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.*;
@@ -38,6 +39,7 @@ public class HarmonicMetricServiceImpl implements HarmonicMetricService {
private final LineFeignClient lineFeignClient;
@Override
@Async("asyncExecutor")
public void metricData(LineParam lineParam) {
List<String> lineIdList;
if (CollUtil.isEmpty(lineParam.getLineIds())){
@@ -85,4 +87,4 @@ public class HarmonicMetricServiceImpl implements HarmonicMetricService {
private List<Overlimit> getAllLineData() {
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
}
}
}

View File

@@ -16,6 +16,7 @@ import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.*;
@@ -42,6 +43,7 @@ public class IntegrityServiceImpl implements IntegrityService {
private final LineFeignClient lineFeignClient;
@Override
@Async("asyncExecutor")
public String computeDataIntegrity(LineParam lineParam) {
List<LineDetail> lineDetailList;
if (CollUtil.isEmpty(lineParam.getLineIds())){

View File

@@ -19,6 +19,7 @@ import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@@ -64,6 +65,7 @@ public class LimitRateService extends MppServiceImpl<LimitRatePOMapper, LimitRa
rollbackFor = {Exception.class}
)
@SneakyThrows
@Async("asyncExecutor")
public List<LimitRatePO> limitRateJobHandler(List<String> lineList, String startTime, String endTime) {
List<LimitRatePO> limitRates = new ArrayList<> ();
List<LimitRate> limitRateList = new ArrayList<> ();
@@ -1199,13 +1201,13 @@ public class LimitRateService extends MppServiceImpl<LimitRatePOMapper, LimitRa
}
/**
/**
* @Description: 插入influxdb
* @Param: [list, time]
* @return: void
* @Param: [list, time]
* @return: void
* @Author: clam
* @Date: 2022/10/21
*/
* @Date: 2022/10/21
*/
private void insert(List<LimitRate> list, long time){
List<String> records = new ArrayList<>();
list.forEach(item->{

View File

@@ -14,6 +14,7 @@ import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.*;
@@ -34,6 +35,7 @@ public class LimitTargetServiceImpl implements LimitTargetService {
private final InfluxDbUtils influxDbUtils;
@Override
@Async("asyncExecutor")
public void getLimitTargetData(LineParam lineParam) {
List<String> records;
Date dateOut = DateUtil.parse(lineParam.getDataDate());

View File

@@ -23,6 +23,7 @@ import com.njcn.prepare.harmonic.service.line.NormalLimitService;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import org.influxdb.dto.QueryResult;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -1187,6 +1188,7 @@ public class NormalLimitServiceImpl extends ServiceImpl<AbnormalMapper, MpSurplu
@Override
@Async("asyncExecutor")
public Boolean AbnormalLineData(LineParam lineParam) {
List<String> lineIds = new ArrayList<>();

View File

@@ -18,6 +18,7 @@ import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -44,6 +45,7 @@ public class OnlineRateServiceImpl implements OnlineRateService {
private final LineFeignClient lineFeignClient;
@Override
@Async("asyncExecutor")
public void getOnlineRateData(LineParam lineParam) {
List<String> lineIdList = lineParam.getLineIds();
if (CollUtil.isEmpty(lineParam.getLineIds())){

View File

@@ -26,6 +26,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -76,6 +77,7 @@ public class PollutionServiceImpl implements PollutionService {
private final RMpPollutionDMapper rMpPollutionDMapper;
@Override
@Async("asyncExecutor")
public void processPollutionData(LineParam lineParam) {
TimeInterval timer = new TimeInterval();
List<PollutionDTO> pollutionList;

View File

@@ -34,6 +34,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.io.IOUtils;
import org.influxdb.dto.QueryResult;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
@@ -72,6 +73,7 @@ public class ReportServiceImpl implements ReportService {
@Override
@Async("asyncExecutor")
public boolean batchReport(LineParam reportParam) {
//查询所有已激活模板