|
@@ -0,0 +1,78 @@
|
|
|
+package com.energy.manage.service.test;
|
|
|
+
|
|
|
+import com.energy.manage.common.reponse.ResultResp;
|
|
|
+import com.energy.manage.service.config.annotations.UserLoginToken;
|
|
|
+import com.energy.manage.service.constant.analysis.AnalysisConstants;
|
|
|
+import com.energy.manage.service.controller.base.BaseServiceController;
|
|
|
+import com.energy.manage.service.domain.dto.analysis.AnalysisDto;
|
|
|
+import com.energy.manage.service.domain.vo.analysis.AnalysisTypeVo;
|
|
|
+import com.energy.manage.service.domain.vo.datatransfer.DataTransferVo;
|
|
|
+import com.energy.manage.service.mappers.analysis.AnalysisTypeMapper;
|
|
|
+import com.energy.manage.service.mappers.datatransfer.DataTransferMapper;
|
|
|
+import com.energy.manage.service.service.analysis.AnalysisService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author chy
|
|
|
+ * @date 2024/6/19 11:22
|
|
|
+ * @desc
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/test")
|
|
|
+public class TestController extends BaseServiceController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AnalysisService analysisService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataTransferMapper dataTransferMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AnalysisTypeMapper typeMapper;
|
|
|
+
|
|
|
+ @UserLoginToken
|
|
|
+ @PostMapping("/testAutoAnalysis")
|
|
|
+ public ResultResp autoAnalysis() {
|
|
|
+ log.info("触发自动分析定时任务开始");
|
|
|
+ if(analysisService.checkAnalysising()){
|
|
|
+ log.info("当前有正在分析的数据,自动分析返回");
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ //获取转换完成且未自动分析的的批次号
|
|
|
+ DataTransferVo dataTransferVo = dataTransferMapper.selectBatchCodeForAutoAnaly();
|
|
|
+ if(dataTransferVo == null || StringUtils.isBlank(dataTransferVo.getBatchCode())){
|
|
|
+ log.info("当前没有秒级、分钟级全部转换完成的数据,自动分析返回");
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ //分析调用
|
|
|
+ analysisService.analysis(assignmentAnalysisDto(dataTransferVo));
|
|
|
+ //自动分析调用完成之后更新状态
|
|
|
+ dataTransferMapper.updateCallState(dataTransferVo.getBatchCode());
|
|
|
+ log.info("触发自动分析定时任务结束");
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置分析参数
|
|
|
+ * @param dataTransferVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private AnalysisDto assignmentAnalysisDto(DataTransferVo dataTransferVo){
|
|
|
+ AnalysisDto analysisDto = new AnalysisDto();
|
|
|
+ analysisDto.setAutoOrManual(AnalysisConstants.AUTO_ANALYSIS);
|
|
|
+ analysisDto.setDataBatchNum(dataTransferVo.getBatchCode());
|
|
|
+ analysisDto.setPowerFarmID(dataTransferVo.getFieldCode());
|
|
|
+ List<String> typeCodeList = typeMapper.selectAllVo().parallelStream().map(AnalysisTypeVo::getTypeFlag).collect(Collectors.toList());
|
|
|
+ analysisDto.setConfigAnalysis(typeCodeList);
|
|
|
+ return analysisDto;
|
|
|
+ }
|
|
|
+}
|