From 7f0bcd00c556889ba890e5e68c681f1b5d4267e1 Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期四, 19 十二月 2024 18:07:20 +0800
Subject: [PATCH] 预测项状态添加模型结果异常

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java |  400 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 313 insertions(+), 87 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
index 57ff47b..b9742f0 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -1,141 +1,241 @@
 package com.iailab.module.data.point.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.iailab.framework.common.constant.Constant;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.iailab.framework.common.pojo.PageResult;
+import com.iailab.framework.common.util.object.BeanUtils;
+import com.iailab.framework.common.util.object.ConvertUtils;
+import com.iailab.module.data.api.point.dto.ApiPointDTO;
+import com.iailab.module.data.channel.common.service.ChannelSourceService;
 import com.iailab.module.data.common.enums.CommonConstant;
 import com.iailab.module.data.common.enums.IsEnableEnum;
-import com.iailab.framework.common.page.PageData;
-import com.iailab.framework.common.service.impl.BaseServiceImpl;
-import com.iailab.framework.common.util.object.ConvertUtils;
-import com.iailab.module.data.point.common.IncreaseCodeEnum;
-import com.iailab.module.data.point.dao.DaPointDao;
-import com.iailab.module.data.point.service.DaMeasurePointService;
+import com.iailab.module.data.common.enums.IncreaseCodeEnum;
 import com.iailab.module.data.point.common.PointTypeEnum;
+import com.iailab.module.data.point.dao.DaPointDao;
+import com.iailab.module.data.point.dto.DaCumulatePointDTO;
+import com.iailab.module.data.point.dto.DaMathPointDTO;
 import com.iailab.module.data.point.dto.DaMeasurePointDTO;
 import com.iailab.module.data.point.dto.DaPointDTO;
+import com.iailab.module.data.point.entity.DaMeasurePointEntity;
 import com.iailab.module.data.point.entity.DaPointEntity;
-import com.iailab.module.data.point.service.DaMathPointService;
-import com.iailab.module.data.point.service.DaPointService;
-import com.iailab.module.data.point.service.DaSequenceNumService;
-import org.apache.commons.lang3.StringUtils;
-import javax.annotation.Resource;
+import com.iailab.module.data.point.service.*;
+import com.iailab.module.data.point.vo.DaPointPageReqVO;
+import com.iailab.module.data.point.vo.PointImportExcelVO;
+import com.iailab.module.data.point.vo.PointImportRespVO;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_EXISTS;
+import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_IMPORT_LIST_IS_EMPTY;
 
 /**
- * @author PanZhibao
+ * @author lirm
  * @Description
- * @createTime 2024年05月12日
+ * @createTime 2024年09月2日
  */
 @Service
-public class DaPointServiceImpl extends BaseServiceImpl<DaPointDao, DaPointEntity> implements DaPointService {
+public class DaPointServiceImpl extends ServiceImpl<DaPointDao, DaPointEntity> implements DaPointService {
 
-    @Resource
+    @Autowired
     private DaMeasurePointService daMeasurePointService;
 
-    @Resource
+    @Autowired
     private DaMathPointService daMathPointService;
 
-    @Resource
+    @Autowired
+    private DaCumulatePointService daCumulatePointService;
+
+    @Autowired
     private DaSequenceNumService daSequenceNumService;
+    
+    @Resource
+    private DaPointDao daPointDao;
+
+    @Resource
+    private ChannelSourceService channelSourceService;
+
+    @Resource
+    private DaPointCollectStatusService daPointCollectStatusService;
+
+    private static Map<String, ApiPointDTO> pointIdMap = new ConcurrentHashMap<>();
+
+    private static Map<String, DaPointDTO> pointNoMap = new ConcurrentHashMap<>();
 
     @Override
-    public PageData<DaPointDTO> page(Map<String, Object> params) {
-        IPage<DaPointDTO> page = baseDao.getPageList(
-                getPage(params, Constant.CREATE_TIME, false),
-                params
-        );
-        return getPageData(page, DaPointDTO.class);
+    public PageResult<DaPointDTO> queryPage(DaPointPageReqVO reqVO) {
+        IPage<DaPointDTO> page = daPointDao.selectPageList(reqVO);
+        return new PageResult<>(page.getRecords(), page.getTotal());
+    }
+
+    private void clearCache() {
+        pointIdMap.clear();
+        pointNoMap.clear();
     }
 
     @Override
-    public DaPointDTO get(String id) {
-        DaPointEntity entity = baseDao.selectById(id);
+    public DaPointDTO info(String id) {
+        DaPointEntity entity = daPointDao.selectById(id);
         DaPointDTO result = ConvertUtils.sourceToTarget(entity, DaPointDTO.class);
-        if (PointTypeEnum.MEASURE_POINT.getCode().equals(result.getPointType())) {
-            DaMeasurePointDTO measurePoint = daMeasurePointService.getByPoint(id);
-            result.setMeasurePoint(measurePoint);
-            List<String> sourceOption = new ArrayList<>();
-            sourceOption.add(measurePoint.getSourceType());
-            sourceOption.add(measurePoint.getSourceId());
-            sourceOption.add(measurePoint.getTagNo());
-            result.setSourceOption(sourceOption);
-        } else if (PointTypeEnum.CALCULATE_POINT.getCode().equals(result.getPointType())) {
-            result.setMathPoint(daMathPointService.getByPoint(id));
+        result.setMeasurePoint(new DaMeasurePointDTO());
+        result.setMathPoint(new DaMathPointDTO());
+        result.setCumulatePoint(new DaCumulatePointDTO());
+        switch (PointTypeEnum.getEumByCode(result.getPointType())) {
+            case MEASURE_POINT:
+                DaMeasurePointDTO measurePoint = daMeasurePointService.getByPoint(id);
+                result.setMeasurePoint(measurePoint);
+                List<String> sourceOption = new ArrayList<>();
+                sourceOption.add(measurePoint.getSourceType());
+                sourceOption.add(measurePoint.getSourceId());
+                sourceOption.add(measurePoint.getTagNo());
+                result.setSourceOption(sourceOption);
+                break;
+            case CALCULATE_POINT:
+                result.setMathPoint(daMathPointService.getByPoint(id));
+                break;
+            case CUMULATE:
+                result.setCumulatePoint(daCumulatePointService.getByPoint(id));
+                break;
+            default:
+                break;
         }
         return result;
     }
 
     @Override
+    public ApiPointDTO getSimpleInfoById(String id) {
+        if (pointIdMap.containsKey(id)) {
+            return pointIdMap.get(id);
+        }
+        ApiPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), ApiPointDTO.class);
+        if (dto == null) {
+            return null;
+        }
+        pointIdMap.put(id, dto);
+        return dto;
+    }
+
+    @Override
+    public DaPointDTO getSimpleInfoByNo(String no) {
+        QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("point_no", no);
+        return ConvertUtils.sourceToTarget(daPointDao.selectOne(queryWrapper), DaPointDTO.class);
+    }
+
+    @Override
     public List<DaPointDTO> list(Map<String, Object> params) {
-        String page = (String) params.get("page");
-        String limit = (String) params.get("limit");
-        String pointType = (String)params.get("pointType");
+        Object pointType = params.get("pointType");
         List<String> pointNos = new ArrayList<>();
         if (params.get("pointNos") != null) {
             pointNos = JSONArray.parseArray(JSONArray.toJSONString(params.get("pointNos")), String.class);
         }
-        String pointNoLike = (String)params.get("pointNoLike");
+        List<String> pointTypes = new ArrayList<>();
+        if (params.get("pointTypes") != null) {
+            pointTypes = Arrays.asList(params.get("pointTypes").toString().split(","));
+        }
+
+        Object pointNoLike = params.get("pointNoLike");
         QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper();
-        queryWrapper.eq(StringUtils.isNotBlank(pointType), "point_type", pointType)
-        .in(!CollectionUtils.isEmpty(pointNos),"point_no", pointNos)
-        .like(StringUtils.isNotBlank(pointNoLike), "point_no", pointNoLike)
-                .last("limit 1, 10");
-        List<DaPointEntity> list = baseDao.selectList(queryWrapper);
+        queryWrapper.eq(!ObjectUtils.isEmpty(pointType), "point_type", pointType);
+        queryWrapper.in(pointNos.size() != 0,"point_no", pointNos);
+        queryWrapper.like(!ObjectUtils.isEmpty(pointNoLike), "point_no", pointNoLike);
+        queryWrapper.in(pointTypes.size() != 0,"point_type", pointTypes);
+        List<DaPointEntity> list = daPointDao.selectList(queryWrapper);
         return ConvertUtils.sourceToTarget(list, DaPointDTO.class);
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    @DSTransactional(rollbackFor = Exception.class)
     public void add(DaPointDTO dataPoint) {
         DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class);
         daPointEntity.setId(UUID.randomUUID().toString());
-        if (PointTypeEnum.MEASURE_POINT.getName().equals(dataPoint.getPointType())) {
-            DaMeasurePointDTO measurePoint = new DaMeasurePointDTO();
-            measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
-            measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
-            measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
-            daMeasurePointService.add(measurePoint, daPointEntity.getId());
-            daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name()));
-        } else if (PointTypeEnum.CALCULATE_POINT.getName().equals(dataPoint.getPointType())) {
-            daMathPointService.add(dataPoint.getMathPoint(), daPointEntity.getId());
-            daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name()));
-        } else if (PointTypeEnum.CONSTANT.getName().equals(dataPoint.getPointType())) {
-            daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name()));
+        switch (PointTypeEnum.getEumByCode(dataPoint.getPointType())) {
+            case MEASURE_POINT:
+                DaMeasurePointDTO measurePoint = new DaMeasurePointDTO();
+                measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
+                measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
+                measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
+                daMeasurePointService.add(measurePoint, daPointEntity.getId());
+                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name()));
+                break;
+            case CALCULATE_POINT:
+                daMathPointService.add(dataPoint.getMathPoint(), daPointEntity.getId());
+                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name()));
+                break;
+            case CONSTANT:
+                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name()));
+                break;
+            case CUMULATE:
+                daCumulatePointService.add(dataPoint.getCumulatePoint(), daPointEntity.getId());
+                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name()));
+                break;
+            default:
+                break;
         }
         daPointEntity.setIsEnable(CommonConstant.IS_ENABLE);
         daPointEntity.setCreateTime(new Date());
-        baseDao.insert(daPointEntity);
+        daPointDao.insert(daPointEntity);
+
+        daPointCollectStatusService.add(daPointEntity.getPointNo());
+        // 清空缓存
+        clearCache();
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    @DSTransactional(rollbackFor = Exception.class)
     public void update(DaPointDTO dataPoint) {
         DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class);
         daPointEntity.setUpdateTime(new Date());
-        baseDao.updateById(daPointEntity);
-        if (PointTypeEnum.MEASURE_POINT.getName().equals(dataPoint.getPointType())) {
-            DaMeasurePointDTO measurePoint = dataPoint.getMeasurePoint();
-            measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
-            measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
-            measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
-            daMeasurePointService.update(measurePoint);
-        } else if (PointTypeEnum.CALCULATE_POINT.equals(dataPoint.getPointType())) {
-            daMathPointService.update(dataPoint.getMathPoint());
+        daPointDao.updateById(daPointEntity);
+        switch (PointTypeEnum.getEumByCode(dataPoint.getPointType())) {
+            case MEASURE_POINT:
+                DaMeasurePointDTO measurePoint = dataPoint.getMeasurePoint();
+                measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
+                measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
+                measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
+                daMeasurePointService.update(measurePoint);
+                break;
+            case CALCULATE_POINT:
+                daMathPointService.update(dataPoint.getMathPoint());
+                break;
+            case CUMULATE:
+                daCumulatePointService.update(dataPoint.getCumulatePoint());
+                break;
+            default:
+                break;
         }
+        // 清空缓存
+        clearCache();
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    @DSTransactional(rollbackFor = Exception.class)
     public void delete(String[] ids) {
-        baseDao.deleteBatchIds(Arrays.asList(ids));
+        daPointDao.deleteBatchIds(Arrays.asList(ids));
         daMeasurePointService.deleteByPoint(ids);
         daMathPointService.deleteByPoint(ids);
+        daCumulatePointService.deleteByPoint(ids);
+        // 清空缓存
+        clearCache();
+    }
+
+    @Override
+    public List<DaPointDTO> getConstantPoint(DaPointPageReqVO reqVO) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("pointType", PointTypeEnum.CONSTANT.getCode());
+        params.put("pointNo", reqVO.getPointNo());
+        params.put("pointName", reqVO.getPointName());
+        return daPointDao.getConstantPoint(params);
     }
 
     @Override
@@ -144,7 +244,7 @@
         params.put("pointType", PointTypeEnum.CONSTANT.getCode());
         params.put("isEnable", CommonConstant.IS_ENABLE);
         params.put("minfreqid", freq);
-        return baseDao.getConstantPoint(params);
+        return daPointDao.getConstantPoint(params);
     }
 
     @Override
@@ -153,7 +253,17 @@
         params.put("pointType", PointTypeEnum.CONSTANT.getCode());
         params.put("isEnable", CommonConstant.IS_ENABLE);
         params.put("pointNos", pointNos);
-        return baseDao.getConstantPoint(params);
+        return daPointDao.getConstantPoint(params);
+    }
+
+    @Override
+    public List<DaPointDTO> getMeasurePoint(DaPointPageReqVO reqVO) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
+        params.put("pointNo", reqVO.getPointNo());
+        params.put("pointName", reqVO.getPointName());
+        params.put("sourceName", reqVO.getSourceName());
+        return daPointDao.getMeasurePoint(params);
     }
 
     @Override
@@ -162,7 +272,7 @@
         params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
         params.put("isEnable", CommonConstant.IS_ENABLE);
         params.put("minfreqid", freq);
-        return baseDao.getMeasurePoint(params);
+        return daPointDao.getMeasurePoint(params);
     }
 
     @Override
@@ -171,7 +281,7 @@
         params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
         params.put("isEnable", CommonConstant.IS_ENABLE);
         params.put("pointNos", pointNos);
-        return baseDao.getMeasurePoint(params);
+        return daPointDao.getMeasurePoint(params);
     }
 
     @Override
@@ -179,11 +289,20 @@
         Map<String, Object> params = new HashMap<>();
         params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
         params.put("pointNo", pointNo);
-        List<DaPointDTO> list = baseDao.getMeasurePoint(params);
+        List<DaPointDTO> list = daPointDao.getMeasurePoint(params);
         if (CollectionUtils.isEmpty(list)) {
             return null;
         }
         return list.get(0);
+    }
+
+    @Override
+    public List<DaPointDTO> getMathPoint(DaPointPageReqVO reqVO) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode());
+        params.put("pointNo", reqVO.getPointNo());
+        params.put("pointName", reqVO.getPointName());
+        return daPointDao.getMathPoint(params);
     }
 
     @Override
@@ -192,7 +311,7 @@
         params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode());
         params.put("isEnable", CommonConstant.IS_ENABLE);
         params.put("minfreqid", freq);
-        return baseDao.getMathPoint(params);
+        return daPointDao.getMathPoint(params);
     }
 
     @Override
@@ -201,22 +320,45 @@
         params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode());
         params.put("isEnable", CommonConstant.IS_ENABLE);
         params.put("pointNos", pointNos);
-        return baseDao.getMathPoint(params);
+        return daPointDao.getMathPoint(params);
+    }
+
+    @Override
+    public List<DaPointDTO> getCumulatePoint(String freq) {
+        Map<String, Object> params = new HashMap<>(3);
+        params.put("pointType", PointTypeEnum.CUMULATE.getCode());
+        params.put("isEnable", CommonConstant.IS_ENABLE);
+        params.put("minfreqid", freq);
+        return daPointDao.getCumulatePoint(params);
+    }
+
+    @Override
+    public List<DaPointDTO> getCumulatePoint(DaPointPageReqVO reqVO) {
+        Map<String, Object> params = new HashMap<>(3);
+        params.put("pointType", PointTypeEnum.CUMULATE.getCode());
+        params.put("pointNo", reqVO.getPointNo());
+        params.put("pointName", reqVO.getPointName());
+        return daPointDao.getCumulatePoint(params);
     }
 
     @Override
     public DaPointDTO getByNo(String pointNo) {
+        if (pointNoMap.containsKey(pointNo)) {
+            return pointNoMap.get(pointNo);
+        }
         QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>();
         wrapper.eq("point_no", pointNo);
-        DaPointEntity entity = baseDao.selectOne(wrapper);
-        return ConvertUtils.sourceToTarget(entity, DaPointDTO.class);
+        DaPointEntity entity = daPointDao.selectOne(wrapper);
+        DaPointDTO dto = ConvertUtils.sourceToTarget(entity, DaPointDTO.class);
+        pointNoMap.put(pointNo, dto);
+        return dto;
     }
 
     @Override
     public List<DaPointDTO> getByNos(List<String> pointNos) {
         QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>();
         wrapper.in("point_no", pointNos);
-        List<DaPointEntity> list = baseDao.selectList(wrapper);
+        List<DaPointEntity> list = daPointDao.selectList(wrapper);
         return ConvertUtils.sourceToTarget(list, DaPointDTO.class);
     }
 
@@ -226,10 +368,91 @@
         wrapper.eq("point_no", dto.getPointNo());
         DaPointEntity entity = new DaPointEntity();
         entity.setDefaultValue(dto.getDefaultValue());
-        baseDao.update(entity, wrapper);
+        daPointDao.update(entity, wrapper);
     }
 
     @Override
+    @DSTransactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
+    public PointImportRespVO importPointList(List<PointImportExcelVO> importPoints, boolean isUpdateSupport) {
+        // 1.1 参数校验
+        if (CollUtil.isEmpty(importPoints)) {
+            throw exception(POINT_IMPORT_LIST_IS_EMPTY);
+        }
+
+        Map<String, Map<String, String>> sourcesIdMap = channelSourceService.getSourcesId();
+        // 2. 遍历,逐个创建 or 更新
+        PointImportRespVO respVO = PointImportRespVO.builder().createPointnames(new ArrayList<>())
+                .updatePointnames(new ArrayList<>()).failurePointnames(new LinkedHashMap<>()).build();
+        importPoints.forEach(importPoint -> {
+
+            // 判断如果不存在,再进行插入
+            DaPointEntity existPoint = baseMapper.selectByPointName(importPoint.getPointName());
+            if (existPoint == null) {
+                DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(importPoint, DaPointEntity.class);
+                daPointEntity.setId(UUID.randomUUID().toString());
+                daPointEntity.setIsEnable(CommonConstant.IS_ENABLE);
+                daPointEntity.setCreateTime(new Date());
+                switch (PointTypeEnum.getEumByCode(daPointEntity.getPointType())) {
+                    case MEASURE_POINT:
+                        DaMeasurePointDTO measurePoint = new DaMeasurePointDTO();
+                        measurePoint.setSourceType(importPoint.getSourceType());
+                        measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName()));
+                        measurePoint.setTagNo(importPoint.getTagNo());
+                        measurePoint.setValueType(importPoint.getValueType());
+                        measurePoint.setDimension(importPoint.getDimension());
+                        daMeasurePointService.add(measurePoint, daPointEntity.getId());
+                        daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name()));
+                        break;
+                    case CALCULATE_POINT:
+                        daMathPointService.add(importPoint.getExpression(), daPointEntity.getId());
+                        daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name()));
+                        break;
+                    case CONSTANT:
+                        daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name()));
+                        break;
+                    case CUMULATE:
+                        DaCumulatePointDTO cumulatePoint = new DaCumulatePointDTO();
+                        cumulatePoint.setMomentPoint(importPoint.getMomentPoint());
+                        cumulatePoint.setLength(importPoint.getLength());
+                        cumulatePoint.setDivisor(importPoint.getDivisor());
+                        daCumulatePointService.add(cumulatePoint, daPointEntity.getId());
+                        daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name()));
+                    default:
+                        break;
+                }
+
+                daPointDao.insert(daPointEntity);
+                daPointCollectStatusService.add(daPointEntity.getPointNo());
+                respVO.getCreatePointnames().add(importPoint.getPointName());
+                return;
+            }
+
+            // 如果存在,判断是否允许更新
+            if (!isUpdateSupport) {
+                respVO.getFailurePointnames().put(importPoint.getPointName(), POINT_EXISTS.getMsg());
+                return;
+            }
+
+            DaPointEntity updatePoint = BeanUtils.toBean(importPoint, DaPointEntity.class);
+            updatePoint.setId(existPoint.getId());
+            baseMapper.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()));
+            respVO.getUpdatePointnames().add(importPoint.getPointName());
+        });
+        return respVO;
+    }
+
+    @Override
+    public List<DaPointDTO> getList(DaPointPageReqVO exportReqVO) {
+        return daPointDao.getList(exportReqVO);
+    }
+
+    @Override
+    @DSTransactional(rollbackFor = Exception.class)
     public void enableByIds(String[] ids) {
         if (CollectionUtils.isEmpty(Arrays.asList(ids))) {
             return;
@@ -237,12 +460,14 @@
         Arrays.asList(ids).forEach(item -> {
             DaPointEntity entity = new DaPointEntity();
             entity.setId(item);
-            entity.setIsEnable(IsEnableEnum.ENABLE.value());
-            baseDao.updateById(entity);
+            entity.setIsEnable(IsEnableEnum.ENABLE.getCode());
+            entity.setUpdateTime(new Date());
+            daPointDao.updateById(entity);
         });
     }
 
     @Override
+    @DSTransactional(rollbackFor = Exception.class)
     public void disableByIds(String[] ids) {
         if (CollectionUtils.isEmpty(Arrays.asList(ids))) {
             return;
@@ -250,8 +475,9 @@
         Arrays.asList(ids).forEach(item -> {
             DaPointEntity entity = new DaPointEntity();
             entity.setId(item);
-            entity.setIsEnable(IsEnableEnum.DISABLE.value());
-            baseDao.updateById(entity);
+            entity.setIsEnable(IsEnableEnum.DISABLE.getCode());
+            entity.setUpdateTime(new Date());
+            daPointDao.updateById(entity);
         });
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3