|
|
@@ -0,0 +1,130 @@
|
|
|
+package com.energy.manage.service.service.homepage.impl;
|
|
|
+
|
|
|
+import com.energy.manage.common.enums.TypeRelationEnum;
|
|
|
+import com.energy.manage.common.po.windrelation.WindRelationPO;
|
|
|
+import com.energy.manage.service.domain.vo.analysis.AnalysisResultVo;
|
|
|
+import com.energy.manage.service.domain.vo.homepage.HomePageVo;
|
|
|
+import com.energy.manage.service.domain.vo.windexceptioncount.WindExceptionCountVo;
|
|
|
+import com.energy.manage.service.domain.vo.windrelation.WindRelationVo;
|
|
|
+import com.energy.manage.service.mappers.analysis.AnalysisResultMapper;
|
|
|
+import com.energy.manage.service.mappers.windexceptioncount.WindExceptionCountMapper;
|
|
|
+import com.energy.manage.service.mappers.windrelation.WindRelationMapper;
|
|
|
+import com.energy.manage.service.service.homepage.HomePageService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author chy
|
|
|
+ * @date 2024/6/13 14:03
|
|
|
+ * @desc
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class HomePageServiceImpl implements HomePageService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WindRelationMapper relationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AnalysisResultMapper analysisResultMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WindExceptionCountMapper exceptionCountMapper;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 驾驶舱首页查询
|
|
|
+ * @param codeNumber
|
|
|
+ * @param codeType
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HomePageVo query(String codeNumber, String codeType) {
|
|
|
+ //返回实体对象
|
|
|
+ HomePageVo homePageVo = new HomePageVo();
|
|
|
+ //风场
|
|
|
+ List<String> fieldCodes = new ArrayList<>();
|
|
|
+ //根据类型判断获取风场code
|
|
|
+ if(codeType.equals(TypeRelationEnum.COMPANY_NUMBER.getCode())){
|
|
|
+ getFieldCodeList(Arrays.asList(codeNumber), fieldCodes);
|
|
|
+ }else{
|
|
|
+ fieldCodes.add(codeNumber);
|
|
|
+ }
|
|
|
+ //如果风场code为空,则不设置
|
|
|
+ if(CollectionUtils.isEmpty(fieldCodes)){
|
|
|
+ return homePageVo;
|
|
|
+ }
|
|
|
+ //设置未分析、分析中、已分析数目
|
|
|
+ setAnalysisCount(homePageVo,fieldCodes);
|
|
|
+ //设置异常数
|
|
|
+ setErrCount(homePageVo,fieldCodes);
|
|
|
+ //设置异常信息
|
|
|
+// setErrInfo(homePageVo,fieldCodes);
|
|
|
+ return homePageVo;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归获取风场code
|
|
|
+ * @param companyCodes
|
|
|
+ * @param fieldCodes
|
|
|
+ */
|
|
|
+ private void getFieldCodeList(List<String> companyCodes, List<String> fieldCodes){
|
|
|
+ if(CollectionUtils.isEmpty(companyCodes)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<WindRelationPO> relationPos = relationMapper.selectByCodeNumber(companyCodes);
|
|
|
+ List<String> companyCodeList = new ArrayList<>();
|
|
|
+ relationPos.parallelStream().forEach(item -> {
|
|
|
+ if(TypeRelationEnum.WIND_FIELD_NUMBER.getCode().equals(item.getType())){
|
|
|
+ fieldCodes.add(item.getCodeNumber());
|
|
|
+ }
|
|
|
+ if(TypeRelationEnum.COMPANY_NUMBER.getCode().equals(item.getType())){
|
|
|
+ companyCodeList.add(item.getCodeNumber());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ getFieldCodeList(companyCodeList,fieldCodes);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分析数设置
|
|
|
+ * @param homePageVo
|
|
|
+ * @param fieldCodes
|
|
|
+ */
|
|
|
+ private void setAnalysisCount(HomePageVo homePageVo,List<String> fieldCodes){
|
|
|
+ List<AnalysisResultVo> resultVos = analysisResultMapper.selectLastBatchResultByFieldCode(fieldCodes);
|
|
|
+ Integer total = fieldCodes.size();
|
|
|
+ if(CollectionUtils.isEmpty(resultVos)){
|
|
|
+ //分析结果为空的时候证明没有风场没有进行分析
|
|
|
+ homePageVo.setNoAnalysisCount(total);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ resultVos.stream().forEach(item -> {
|
|
|
+ Integer analysisState = item.getAnalysisState();
|
|
|
+ //分析中
|
|
|
+ if(item.getAnalysisState().equals(0)){
|
|
|
+ homePageVo.analysisingCountAdd();
|
|
|
+ }
|
|
|
+ //分析完成
|
|
|
+ if(item.getAnalysisState().equals(1)){
|
|
|
+ homePageVo.analysisedCountAdd();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //设置未分析
|
|
|
+ homePageVo.setNoAnalysisCount(total - homePageVo.getAnalysisedCount() - homePageVo.getAnalysisingCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置异常数
|
|
|
+ * @param homePageVo
|
|
|
+ * @param fieldCodes
|
|
|
+ */
|
|
|
+ public void setErrCount(HomePageVo homePageVo, List<String> fieldCodes){
|
|
|
+ List<WindExceptionCountVo> exceptionCounts = exceptionCountMapper.selectByfieldCodes(fieldCodes);
|
|
|
+
|
|
|
+ }
|
|
|
+}
|