| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.module.ansteel.coking.dao.CokingTraceIndDao; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceConfEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceIndEntity; |
| | | import com.iailab.module.ansteel.coking.service.CokingTraceConfService; |
| | | import com.iailab.module.ansteel.coking.service.CokingTraceIndService; |
| | | import com.iailab.module.ansteel.common.enums.ProcessConfDataTypeEnum; |
| | | 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 org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @Resource |
| | | private CokingTraceIndDao cokingTraceIndDao; |
| | | |
| | | @Autowired |
| | | private CokingTraceConfService cokingTraceConfService; |
| | | |
| | | @Autowired |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Autowired |
| | | private IndItemApi indItemApi; |
| | | |
| | | @Override |
| | | public List<CokingTraceIndEntity> list(Map<String, Object> params) { |
| | | String relId = (String) params.get("relId"); |
| | |
| | | public void save(List<CokingTraceIndEntity> entityList) { |
| | | cokingTraceIndDao.insert(entityList); |
| | | } |
| | | |
| | | @Override |
| | | public void saveTraceInd(String relId, String indType, String clock) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("indType", indType); |
| | | List<CokingTraceConfEntity> list = cokingTraceConfService.list(map); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return; |
| | | } |
| | | List<CokingTraceIndEntity> cokingTraceIndEntities = new ArrayList<>(); |
| | | for (CokingTraceConfEntity conf : list) { |
| | | if (StringUtils.isBlank(conf.getDataType())) { |
| | | continue; |
| | | } |
| | | if (StringUtils.isBlank(conf.getPointNo())) { |
| | | continue; |
| | | } |
| | | String value = ""; |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(conf.getDataType())) { |
| | | case DATAPOINT: |
| | | List<String> points = new ArrayList<>(); |
| | | points.add(conf.getPointNo()); |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | value = pointsRealValue.get(conf.getPointNo()).toString(); |
| | | break; |
| | | case IND: |
| | | List<ApiIndItemValueDTO> indValues = indItemApi.queryIndItemDefaultValue(conf.getPointNo()); |
| | | if (!CollectionUtils.isEmpty(indValues)) { |
| | | value = indValues.get(indValues.size() - 1).getDataValue().toString(); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | CokingTraceIndEntity cokingTraceIndEntity = new CokingTraceIndEntity(); |
| | | cokingTraceIndEntity.setRelId(relId); |
| | | cokingTraceIndEntity.setTitle(conf.getIndType()); |
| | | cokingTraceIndEntity.setClock(clock); |
| | | cokingTraceIndEntity.setIndCode(conf.getIndCode()); |
| | | cokingTraceIndEntity.setIndName(conf.getIndName()); |
| | | cokingTraceIndEntity.setIndValue(value); |
| | | cokingTraceIndEntity.setIndUnit(conf.getIndUnit()); |
| | | cokingTraceIndEntities.add(cokingTraceIndEntity); |
| | | } |
| | | cokingTraceIndDao.insert(cokingTraceIndEntities); |
| | | } |
| | | } |