| | |
| | | import com.iailab.module.data.point.vo.PointImportExcelVO; |
| | | import com.iailab.module.data.point.vo.PointImportRespVO; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<ApiPointDTO> getPointPage(HashMap map) { |
| | | IPage<ApiPointDTO> page = daPointDao.getPointPage(getPage(map, Constant.CREATE_TIME, false),map); |
| | | return new PageResult<>(page.getRecords(), page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public List<DaPointDTO> getMathPoint(String freq) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); |
| | |
| | | PointImportRespVO respVO = PointImportRespVO.builder().createPointnames(new ArrayList<>()) |
| | | .updatePointnames(new ArrayList<>()).failurePointnames(new LinkedHashMap<>()).build(); |
| | | importPoints.forEach(importPoint -> { |
| | | |
| | | // 判断如果不存在,再进行插入 |
| | | DaPointEntity existPoint = baseDao.selectByPointName(importPoint.getPointName()); |
| | | DaPointEntity existPoint = null; |
| | | if (StringUtils.isNotBlank(importPoint.getPointNo())) { |
| | | existPoint = baseDao.selectByPointNo(importPoint.getPointNo()); |
| | | } |
| | | |
| | | if (existPoint == null) { |
| | | DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(importPoint, DaPointEntity.class); |
| | | daPointEntity.setId(UUID.randomUUID().toString()); |
| | |
| | | DaPointEntity updatePoint = BeanUtils.toBean(importPoint, DaPointEntity.class); |
| | | updatePoint.setId(existPoint.getId()); |
| | | baseDao.updateById(updatePoint); |
| | | DaMeasurePointEntity measurePoint = new DaMeasurePointEntity(); |
| | | measurePoint.setSourceType(importPoint.getSourceType()); |
| | | measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName())); |
| | | measurePoint.setTagNo(importPoint.getTagNo()); |
| | | daMeasurePointService.update(measurePoint, new QueryWrapper<DaMeasurePointEntity>().eq("point_id",updatePoint.getId())); |
| | | switch (PointTypeEnum.getEumByCode(updatePoint.getPointType())) { |
| | | case MEASURE_POINT: |
| | | DaMeasurePointEntity measurePoint = new DaMeasurePointEntity(); |
| | | measurePoint.setSourceType(importPoint.getSourceType()); |
| | | measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName())); |
| | | measurePoint.setTagNo(importPoint.getTagNo()); |
| | | daMeasurePointService.update(measurePoint, new QueryWrapper<DaMeasurePointEntity>().eq("point_id",updatePoint.getId())); |
| | | |
| | | |
| | | break; |
| | | case CALCULATE_POINT: |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | respVO.getUpdatePointnames().add(importPoint.getPointName()); |
| | | }); |
| | | return respVO; |