| | |
| | | package com.iailab.module.ansteel.plant.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.module.ansteel.common.enums.ProcessConfDataTypeEnum; |
| | | import com.iailab.module.ansteel.plant.dao.PlantConfDao; |
| | | import com.iailab.module.ansteel.plant.entity.PlantConfEntity; |
| | | import com.iailab.module.ansteel.plant.service.PlantConfService; |
| | | import com.iailab.module.data.api.arc.ArcDataApi; |
| | | import com.iailab.module.data.api.arc.dto.ApiArcDataDTO; |
| | | import com.iailab.module.data.api.ind.IndItemApi; |
| | | import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | |
| | | @Resource |
| | | private PlantConfDao plantConfDao; |
| | | @Resource |
| | | private DataPointApi dataPointApi; |
| | | @Resource |
| | | private IndItemApi indItemApi; |
| | | @Resource |
| | | private ArcDataApi arcDataApi; |
| | | |
| | | private BigDecimal badValue = new BigDecimal(-2); |
| | | |
| | | @Override |
| | | public List<PlantConfEntity> list(Map<String, Object> params) { |
| | |
| | | queryWrapper.eq(StringUtils.isNotBlank(businessType), "business_type", businessType); |
| | | return plantConfDao.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, BigDecimal> getPlantData(String businessType) { |
| | | QueryWrapper<PlantConfEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("business_type",businessType); |
| | | List<PlantConfEntity> plantConfList = plantConfDao.selectList(queryWrapper); |
| | | // 筛选DATAPOINT一次性查询出全部 |
| | | List<String> pointNos = plantConfList.stream().filter(e -> e.getDataType().equals(ProcessConfDataTypeEnum.DATAPOINT.getCode())).map(PlantConfEntity::getDataNo).collect(Collectors.toList()); |
| | | Map<String, Object> pointValues = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(pointNos)) { |
| | | pointValues = dataPointApi.queryPointsRealValue(pointNos); |
| | | } |
| | | Map<String, BigDecimal> result = new HashMap<>(plantConfList.size()); |
| | | for (PlantConfEntity plantConf : plantConfList) { |
| | | String dataNo = plantConf.getDataNo(); |
| | | String dataType = plantConf.getDataType(); |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(dataType)) { |
| | | case DATAPOINT: |
| | | if (pointValues.containsKey(dataNo)) { |
| | | result.put(dataNo,new BigDecimal(pointValues.get(dataNo).toString())); |
| | | }else { |
| | | result.put(dataNo,badValue); |
| | | } |
| | | break; |
| | | case IND: |
| | | List<ApiIndItemValueDTO> indValues = indItemApi.queryIndItemDefaultValue(dataNo); |
| | | if (!CollectionUtils.isEmpty(indValues)) { |
| | | result.put(dataNo,new BigDecimal(indValues.get(0).getDataValue().toString())); |
| | | }else { |
| | | result.put(dataNo,badValue); |
| | | } |
| | | break; |
| | | case ARC: |
| | | ApiArcDataDTO apiArcDataDTO = arcDataApi.queryArcLastValue(dataNo); |
| | | if (apiArcDataDTO != null) { |
| | | result.put(dataNo,apiArcDataDTO.getArcValue()); |
| | | }else { |
| | | result.put(dataNo,badValue); |
| | | } |
| | | break; |
| | | default: |
| | | result.put(dataNo,badValue); |
| | | break; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |