预处理模块添加异步处理

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: default:
break; 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("'"); stringBuilder.append(" and ").append(InfluxDBPublicParam.VALUETYPE + "='").append(valueTypeName).append("'");
} }
String sql = ""; 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") @XxlJob("harmCustomReportHandler")
public void harmCustomReportHandler(){ public void harmCustomReportHandler(){
long a = System.currentTimeMillis();
String command = XxlJobHelper.getJobParam(); String command = XxlJobHelper.getJobParam();
LineParam lineParam = new LineParam(); LineParam lineParam = new LineParam();
@@ -38,8 +37,6 @@ public class HarmCustomReportJob {
//date = "2022-10-26"; //date = "2022-10-26";
lineParam.setDataDate(date); lineParam.setDataDate(date);
coustmReportFeignClient.batchReport(lineParam); 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
/** /**
* @author denghuajun * @author denghuajun
* @version 1.0.0 * @version 1.0.0
@@ -37,12 +39,7 @@ public class NormalLimitController extends BaseController {
@ApiOperation("告警数据预处理") @ApiOperation("告警数据预处理")
public HttpResult<String> getNormLimitData(@RequestBody LineParam lineParam) { public HttpResult<String> getNormLimitData(@RequestBody LineParam lineParam) {
String methodDescribe = getMethodDescribe("getNormLimitData"); String methodDescribe = getMethodDescribe("getNormLimitData");
try {
normLimitService.AbnormalLineData(lineParam); normLimitService.AbnormalLineData(lineParam);
}catch (Exception e){
e.printStackTrace();
log.error("告警数据预处理异常:"+e.getMessage());
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); 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.BeanUtils;
import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.BeanWrapperImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -72,6 +73,7 @@ public class DayDataServiceImpl implements DayDataService {
@Transactional( @Transactional(
rollbackFor = {Exception.class} rollbackFor = {Exception.class}
) )
@Async("asyncExecutor")
public void dayDataJobHandler(List<String> indexLists, String startTime, String endTime) { public void dayDataJobHandler(List<String> indexLists, String startTime, String endTime) {

View File

@@ -13,6 +13,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -39,6 +40,7 @@ public class DistortionRateServiceImpl implements DistortionRateService {
private final RMpVThdMapper rMpVThdMapper; private final RMpVThdMapper rMpVThdMapper;
@Override @Override
@Async("asyncExecutor")
public void distortionRate(LineParam lineParam) { public void distortionRate(LineParam lineParam) {
List<String> lineIdOutList; List<String> lineIdOutList;
if (CollUtil.isEmpty(lineParam.getLineIds())){ 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.Point;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -40,6 +41,7 @@ public class HarmonicGeneralServiceImpl implements HarmonicGeneralService {
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
@Override @Override
@Async("asyncExecutor")
public void generalData(LineParam lineParam) { public void generalData(LineParam lineParam) {
List<String> lineIdOutList; List<String> lineIdOutList;
if (CollUtil.isEmpty(lineParam.getLineIds())){ 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.Point;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
@@ -38,6 +39,7 @@ public class HarmonicMetricServiceImpl implements HarmonicMetricService {
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
@Override @Override
@Async("asyncExecutor")
public void metricData(LineParam lineParam) { public void metricData(LineParam lineParam) {
List<String> lineIdList; List<String> lineIdList;
if (CollUtil.isEmpty(lineParam.getLineIds())){ 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.Point;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
@@ -42,6 +43,7 @@ public class IntegrityServiceImpl implements IntegrityService {
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
@Override @Override
@Async("asyncExecutor")
public String computeDataIntegrity(LineParam lineParam) { public String computeDataIntegrity(LineParam lineParam) {
List<LineDetail> lineDetailList; List<LineDetail> lineDetailList;
if (CollUtil.isEmpty(lineParam.getLineIds())){ if (CollUtil.isEmpty(lineParam.getLineIds())){

View File

@@ -19,6 +19,7 @@ import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -64,6 +65,7 @@ public class LimitRateService extends MppServiceImpl<LimitRatePOMapper, LimitRa
rollbackFor = {Exception.class} rollbackFor = {Exception.class}
) )
@SneakyThrows @SneakyThrows
@Async("asyncExecutor")
public List<LimitRatePO> limitRateJobHandler(List<String> lineList, String startTime, String endTime) { public List<LimitRatePO> limitRateJobHandler(List<String> lineList, String startTime, String endTime) {
List<LimitRatePO> limitRates = new ArrayList<> (); List<LimitRatePO> limitRates = new ArrayList<> ();
List<LimitRate> limitRateList = new ArrayList<> (); List<LimitRate> limitRateList = new ArrayList<> ();

View File

@@ -14,6 +14,7 @@ import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point; import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
@@ -34,6 +35,7 @@ public class LimitTargetServiceImpl implements LimitTargetService {
private final InfluxDbUtils influxDbUtils; private final InfluxDbUtils influxDbUtils;
@Override @Override
@Async("asyncExecutor")
public void getLimitTargetData(LineParam lineParam) { public void getLimitTargetData(LineParam lineParam) {
List<String> records; List<String> records;
Date dateOut = DateUtil.parse(lineParam.getDataDate()); 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 com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -1187,6 +1188,7 @@ public class NormalLimitServiceImpl extends ServiceImpl<AbnormalMapper, MpSurplu
@Override @Override
@Async("asyncExecutor")
public Boolean AbnormalLineData(LineParam lineParam) { public Boolean AbnormalLineData(LineParam lineParam) {
List<String> lineIds = new ArrayList<>(); 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.Point;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -44,6 +45,7 @@ public class OnlineRateServiceImpl implements OnlineRateService {
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
@Override @Override
@Async("asyncExecutor")
public void getOnlineRateData(LineParam lineParam) { public void getOnlineRateData(LineParam lineParam) {
List<String> lineIdList = lineParam.getLineIds(); List<String> lineIdList = lineParam.getLineIds();
if (CollUtil.isEmpty(lineParam.getLineIds())){ if (CollUtil.isEmpty(lineParam.getLineIds())){

View File

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

View File

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