package com.iailab.module.ansteel.plant.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.module.ansteel.plant.dao.PlantChartConfDao;
|
import com.iailab.module.ansteel.plant.entity.PlantChartConfEntity;
|
import com.iailab.module.ansteel.plant.service.PlantChartConfService;
|
import com.iailab.module.ansteel.plant.vo.PlantChartDataVO;
|
import com.iailab.module.data.api.point.DataPointApi;
|
import com.iailab.module.data.api.point.dto.ApiPointsValueQueryDTO;
|
import lombok.extern.slf4j.Slf4j;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.ObjectUtils;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
import java.util.stream.Stream;
|
|
/**
|
* @description:
|
* @author: lirm
|
* @date: 2025/6/20 13:59
|
**/
|
@Slf4j
|
@Service
|
public class PlantChartConfServiceImpl implements PlantChartConfService {
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
@Resource
|
private PlantChartConfDao plantChartConfDao;
|
@Resource
|
private DataPointApi dataPointApi;
|
|
@Override
|
public PlantChartDataVO getPlantChartData(Map tMap) {
|
PlantChartDataVO result = new PlantChartDataVO();
|
if(ObjectUtils.isEmpty(tMap.get("indType")) || ObjectUtils.isEmpty(tMap.get("indCode"))){
|
logger.info("输入参数为空");
|
return result;
|
}
|
QueryWrapper<PlantChartConfEntity> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("ind_type",tMap.get("indType"));
|
queryWrapper.eq("indCode",tMap.get("indCode"));
|
List<PlantChartConfEntity> plantChartConfList = plantChartConfDao.selectList(queryWrapper);
|
if (CollectionUtils.isEmpty(plantChartConfList)) {
|
log.info("plantChartConfList is null");
|
return result;
|
}
|
PlantChartConfEntity plantChartConfEntity = plantChartConfList.get(0);
|
// 筛选DATAPOINT一次性查询出全部
|
List<String> pointNos = Stream.of(plantChartConfEntity.getIndAvg(),plantChartConfEntity.getIndTheory(),plantChartConfEntity.getIndOptimal(),plantChartConfEntity.getIndReal()).collect(Collectors.toList());
|
if (!CollectionUtils.isEmpty(pointNos)) {
|
ApiPointsValueQueryDTO queryDTO = new ApiPointsValueQueryDTO();
|
queryDTO.setPointNos(pointNos);
|
Map<String, List<Map<String, Object>>> pointsHisValues = dataPointApi.queryPointsHistoryValue(queryDTO);
|
if (CollectionUtils.isEmpty(pointsHisValues)) {
|
log.info("pointsHisValues is null");
|
return result;
|
}
|
result.setIndCode(plantChartConfEntity.getIndCode());
|
result.setIndName(plantChartConfEntity.getIndName());
|
result.setIndAvgHisList(pointsHisValues.get(plantChartConfEntity.getIndAvg()));
|
result.setIndTheoryHisList(pointsHisValues.get(plantChartConfEntity.getIndTheory()));
|
result.setIndOptimalHisList(pointsHisValues.get(plantChartConfEntity.getIndOptimal()));
|
result.setIndRealHisList(pointsHisValues.get(plantChartConfEntity.getIndReal()));
|
result.setIndPowerHisList(pointsHisValues.get(plantChartConfEntity.getIndPower()));
|
}
|
return result;
|
}
|
}
|