| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | // 2. 遍历,逐个创建 or 更新 |
| | | PointImportRespVO respVO = PointImportRespVO.builder().createPointnames(new ArrayList<>()) |
| | | .updatePointnames(new ArrayList<>()).failurePointnames(new LinkedHashMap<>()).build(); |
| | | importPoints.forEach(importPoint -> { |
| | | for(PointImportExcelVO importPoint : importPoints) { |
| | | // 判断如果不存在,再进行插入 |
| | | DaPointEntity existPoint = null; |
| | | if (StringUtils.isNotBlank(importPoint.getPointNo())) { |
| | |
| | | daPointEntity.setId(UUID.randomUUID().toString()); |
| | | daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); |
| | | daPointEntity.setCreateTime(new Date()); |
| | | if(PointTypeEnum.getEumByCode(daPointEntity.getPointType()) == null) { |
| | | continue; |
| | | } |
| | | switch (PointTypeEnum.getEumByCode(daPointEntity.getPointType())) { |
| | | case MEASURE_POINT: |
| | | DaMeasurePointDTO measurePoint = new DaMeasurePointDTO(); |
| | |
| | | cumulatePoint.setMomentPoint(importPoint.getMomentPoint()); |
| | | cumulatePoint.setLength(importPoint.getLength()); |
| | | cumulatePoint.setDivisor(importPoint.getDivisor()); |
| | | cumulatePoint.setIsCumuNeg(importPoint.getIsCumuNeg()); |
| | | daCumulatePointService.add(cumulatePoint, daPointEntity.getId()); |
| | | daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name())); |
| | | default: |
| | |
| | | daPointDao.insert(daPointEntity); |
| | | daPointCollectStatusService.add(daPointEntity.getPointNo()); |
| | | respVO.getCreatePointnames().add(importPoint.getPointName()); |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | // 如果存在,判断是否允许更新 |
| | | if (!isUpdateSupport) { |
| | | respVO.getFailurePointnames().put(importPoint.getPointName(), POINT_EXISTS.getMsg()); |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | DaPointEntity updatePoint = BeanUtils.toBean(importPoint, DaPointEntity.class); |
| | |
| | | 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; |
| | |
| | | break; |
| | | } |
| | | respVO.getUpdatePointnames().add(importPoint.getPointName()); |
| | | }); |
| | | } |
| | | return respVO; |
| | | } |
| | | |