已修改22个文件
已添加6个文件
597 ■■■■■ 文件已修改
iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IncreaseCodeEnum.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java 138 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaCumulatePointDao.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaCumulatePointDTO.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaCumulatePointEntity.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaCumulatePointService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaCumulatePointServiceImpl.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/application-local.yml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/application.yaml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageRespDTO.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictItemRespVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/enums/ModelParamType.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
@@ -386,4 +386,16 @@
                           `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                           PRIMARY KEY (id) USING BTREE,
                           UNIQUE INDEX `uk_item_no` (`item_no`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计划数据项';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计划数据项';
CREATE TABLE t_da_cumulate_point(
                                   `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
                                   `point_id` VARCHAR(36)   COMMENT '测点ID' ,
                                   `moment_point` VARCHAR(36)   COMMENT '瞬时测点' ,
                                   `length` int COMMENT '累计长度',
                                   `divisor` int COMMENT '除数',
                                   PRIMARY KEY (id) USING BTREE,
                                   UNIQUE KEY `uk_point_id` (`point_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '累计点表';
INSERT INTO `iailab_expert_tenant_shasteel`.`t_da_sequence_num` (`id`, `code`, `name`, `sequence_num`, `prefix`) VALUES ('8', 'POINT_L', '累计点编码', 100001, 'L');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1657, 4, '累计点', 'CUMULATE', 'data_point_type', 0, '', '', '', '142', '2024-11-29 10:13:12', '142', '2024-11-29 10:13:12', b'0');
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IncreaseCodeEnum.java
@@ -7,5 +7,5 @@
 * @date 2021年05月24日 9:41
 */
public enum IncreaseCodeEnum {
    POINT_M, POINT_C, POINT_F, IND_A, IND_D, IND_C, PLAN;
    POINT_M, POINT_C, POINT_F, POINT_L, IND_A, IND_D, IND_C, PLAN;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java
@@ -4,6 +4,7 @@
import com.iailab.module.data.common.utils.R;
import com.iailab.module.data.channel.kio.collector.KingIOCollector;
import com.iailab.module.data.point.collection.handler.CalculateHandle;
import com.iailab.module.data.point.collection.handler.CumulateHandle;
import com.iailab.module.data.point.common.PointTypeEnum;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.service.DaPointService;
@@ -55,6 +56,9 @@
    @Resource
    private OpcUaCollector opcUaCollector;
    @Resource
    private CumulateHandle cumulateHandle;
    /**
     * 采集
     *
@@ -78,6 +82,10 @@
            List<DaPointDTO> pointCalculateList = daPointService.getMathPoint(minfreq);
            pointValues.addAll(calculateHandle.handle(collectTime, pointCalculateList, dataMap));
            log.info("读取累计点");
            List<DaPointDTO> pointCumulateList = daPointService.getCumulatePoint(minfreq);
            pointValues.addAll(cumulateHandle.handle(collectTime, pointCumulateList));
            log.info("存入数据库");
            influxDBService.asyncWritePointValues(pointValues);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java
对比新文件
@@ -0,0 +1,138 @@
package com.iailab.module.data.point.collection.handler;
import com.iailab.module.data.api.point.DataPointApi;
import com.iailab.module.data.api.point.dto.ApiPointDTO;
import com.iailab.module.data.api.point.dto.ApiPointValueDTO;
import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO;
import com.iailab.module.data.common.enums.CommonConstant;
import com.iailab.module.data.enums.DataPointFreqEnum;
import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO;
import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils;
import com.iailab.module.data.point.dto.DaPointDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
/**
 * 累计点处理
 *
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月29日
 */
@Slf4j
@Component
public class CumulateHandle {
    @Autowired
    private DataPointApi dataPointApi;
    public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos) {
        List<InfluxPointValuePOJO> result = new ArrayList<>();
        try {
            log.info("累计点处理开始");
            if (CollectionUtils.isEmpty(dtos)) {
                return result;
            }
            dtos.forEach(dto -> {
                try {
                    Object value = singleCompute(dto, collectTime);
                    InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value);
                    pojo.setTimestamp(collectTime.toInstant());
                    result.add(pojo);
                } catch (Exception ex) {
                    ex.printStackTrace();
                    log.info("累计点异常!PointNo=" + dto.getPointNo());
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
            log.info("累计点处理异常!");
        }
        return result;
    }
    private Object singleCompute(DaPointDTO dto, Date collectTime) {
        ApiPointDTO pointDTO = dataPointApi.getInfoByNo(dto.getMomentPoint());
        if (pointDTO == null) {
            return CommonConstant.BAD_VALUE;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(collectTime);
        calendar.add(Calendar.MINUTE, -1);
        Date endTime = calendar.getTime();
        calendar.add(Calendar.MINUTE, dto.getLength() * -1);
        Date startTime = calendar.getTime();
        ApiPointValueQueryDTO queryDto = new ApiPointValueQueryDTO();
        queryDto.setStart(startTime);
        queryDto.setEnd(endTime);
        queryDto.setPointNo(dto.getMomentPoint());
        List<ApiPointValueDTO> dataList = dataPointApi.queryPointHistoryValue(queryDto);
        if (CollectionUtils.isEmpty(dataList)) {
            return BigDecimal.ZERO;
        } else if (dataList.size() < dto.getLength()) {
            // 补全数据
            dataList = completionData(dto.getLength(), dataList, startTime, endTime, pointDTO);
        }
        double total = dataList.stream().mapToDouble(ApiPointValueDTO::getV).sum();
        return new BigDecimal(total).divide(new BigDecimal(dto.getDivisor()), 2, BigDecimal.ROUND_HALF_UP);
    }
    private List<ApiPointValueDTO> completionData(int length, List<ApiPointValueDTO> dataList, Date startTime, Date endTime, ApiPointDTO pointDTO) {
        if (CollectionUtils.isEmpty(dataList) || length == dataList.size()) {
            return dataList;
        } else if (length < dataList.size()) {
            return dataList.subList(dataList.size() - length, dataList.size());
        }
        List<ApiPointValueDTO> result = new ArrayList<>();
        long start = startTime.getTime();
        long end = endTime.getTime();
        long oneMin = 1000L * DataPointFreqEnum.getEumByCode(pointDTO.getMinfreqid()).getValue();
        long mins = (end - start) / oneMin;
        //找出缺少项
        Map<Long, Double> sourceDataMap = new HashMap<>(dataList.size());
        Map<Long, Double> dataMap = new LinkedHashMap<>();
        for (int i = 0; i < mins; i++) {
            Long key = start + oneMin * i;
            Double value = sourceDataMap.get(key);
            dataMap.put(key, value);
        }
        //补充缺少项
        int k = 0;
        Map.Entry<Long, Double> lastItem = null;
        for (Map.Entry<Long, Double> item : dataMap.entrySet()) {
            if (k == 0 && item.getValue() == null) {
                item.setValue(getFirstValue(dataMap));
            } else if (item.getValue() == null) {
                item.setValue(lastItem.getValue());
            }
            k++;
            lastItem = item;
            ApiPointValueDTO dataEntity = new ApiPointValueDTO();
            dataEntity.setT(new Date(item.getKey()));
            dataEntity.setV(item.getValue());
            result.add(dataEntity);
        }
        return result;
    }
    private Double getFirstValue(Map<Long, Double> dataMap) {
        for (Map.Entry<Long, Double> item : dataMap.entrySet()) {
            if (item.getValue() != null) {
                return item.getValue();
            }
        }
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java
@@ -12,7 +12,8 @@
public enum PointTypeEnum {
    MEASURE_POINT("MEASURE", "测量点"),
    CALCULATE_POINT("CALCULATE", "计算点"),
    CONSTANT("CONSTANT", "常量点");
    CONSTANT("CONSTANT", "常量点"),
    CUMULATE("CUMULATE", "累计点");
    private String code;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaCumulatePointDao.java
对比新文件
@@ -0,0 +1,16 @@
package com.iailab.module.data.point.dao;
import com.iailab.framework.common.dao.BaseDao;
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import com.iailab.module.data.point.entity.DaCumulatePointEntity;
import org.apache.ibatis.annotations.Mapper;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月28日
 */
@TenantDS
@Mapper
public interface DaCumulatePointDao extends BaseDao<DaCumulatePointEntity> {
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java
@@ -35,6 +35,8 @@
    List<DaPointDTO> getMathPoint(Map<String, Object> params);
    List<DaPointDTO> getCumulatePoint(Map<String, Object> params);
    default IPage<DaPointDTO> selectPageList(DaPointPageReqVO reqVO) {
        return getPageList(getPage(reqVO), reqVO);
    }
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaCumulatePointDTO.java
对比新文件
@@ -0,0 +1,39 @@
package com.iailab.module.data.point.dto;
import com.iailab.framework.common.validation.group.AddGroup;
import com.iailab.framework.common.validation.group.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月28日
 */
@Data
@Tag(name = "累计点表")
public class DaCumulatePointDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    @Schema(description = "id")
    @Null(message="{id.null}", groups = AddGroup.class)
    @NotNull(message="{id.require}", groups = UpdateGroup.class)
    private String id;
    @Schema(description = "测点ID", required = true)
    private String pointId;
    @Schema(description = "瞬时测点", required = true)
    private String momentPoint;
    @Schema(description = "累计长度", required = true)
    private Integer length;
    @Schema(description = "除数", required = true)
    private Integer divisor;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java
@@ -107,6 +107,15 @@
    @Schema(description = "计算公式", required = true)
    private String expression;
    @Schema(description = "瞬时测点")
    private String momentPoint;
    @Schema(description = "累计长度")
    private Integer length;
    @Schema(description = "除数")
    private Integer divisor;
    @Schema(description = "数据源选项")
    private List<String> sourceOption;
@@ -115,4 +124,7 @@
    @Schema(description = "测量点")
    private DaMeasurePointDTO measurePoint;
    @Schema(description = "累计点")
    private DaCumulatePointDTO cumulatePoint;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaCumulatePointEntity.java
对比新文件
@@ -0,0 +1,47 @@
package com.iailab.module.data.point.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
 * 累计点表
 *
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月28日
 */
@Data
@TableName("t_da_cumulate_point")
public class DaCumulatePointEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;
    /**
     * 测点ID
     */
    private String pointId;
    /**
     * 累计测点
     */
    private String momentPoint;
    /**
     * 累计长度
     */
    private Integer length;
    /**
     * 除数
     */
    private Integer divisor;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaCumulatePointService.java
对比新文件
@@ -0,0 +1,23 @@
package com.iailab.module.data.point.service;
import com.iailab.framework.common.service.BaseService;
import com.iailab.module.data.point.dto.DaCumulatePointDTO;
import com.iailab.module.data.point.entity.DaCumulatePointEntity;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月28日
 */
public interface DaCumulatePointService extends BaseService<DaCumulatePointEntity> {
    void add(DaCumulatePointDTO dto, String pointId);
    DaCumulatePointDTO getByPoint(String pointId);
    void update(DaCumulatePointDTO dto);
    void deleteBatch(String[] ids);
    void deleteByPoint(String[] ids);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java
@@ -1,9 +1,7 @@
package com.iailab.module.data.point.service;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.data.common.utils.PageUtils;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.entity.DaPointEntity;
import com.iailab.module.data.point.vo.*;
import java.util.List;
@@ -45,6 +43,8 @@
    List<DaPointDTO> getMathPoint(List<String> pointNos);
    List<DaPointDTO> getCumulatePoint(String freq);
    DaPointDTO getByNo(String pointNo);
    List<DaPointDTO> getByNos(List<String> pointNos);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaCumulatePointServiceImpl.java
对比新文件
@@ -0,0 +1,55 @@
package com.iailab.module.data.point.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.point.dao.DaCumulatePointDao;
import com.iailab.module.data.point.dto.DaCumulatePointDTO;
import com.iailab.module.data.point.entity.DaCumulatePointEntity;
import com.iailab.module.data.point.service.DaCumulatePointService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月28日
 */
@Service
public class DaCumulatePointServiceImpl extends BaseServiceImpl<DaCumulatePointDao, DaCumulatePointEntity> implements DaCumulatePointService {
    @Override
    public void add(DaCumulatePointDTO dto, String pointId) {
        DaCumulatePointEntity entity = ConvertUtils.sourceToTarget(dto, DaCumulatePointEntity.class);
        entity.setPointId(pointId);
        baseDao.insert(entity);
    }
    @Override
    public DaCumulatePointDTO getByPoint(String pointId) {
        QueryWrapper<DaCumulatePointEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("point_id", pointId);
        DaCumulatePointEntity entity = baseDao.selectOne(wrapper);
        return ConvertUtils.sourceToTarget(entity, DaCumulatePointDTO.class);
    }
    @Override
    public void update(DaCumulatePointDTO dto) {
        DaCumulatePointEntity entity = ConvertUtils.sourceToTarget(dto, DaCumulatePointEntity.class);
        this.updateById(entity);
    }
    @Override
    public void deleteBatch(String[] ids) {
        baseDao.deleteBatchIds(Arrays.asList(ids));
    }
    @Override
    public void deleteByPoint(String[] ids) {
        QueryWrapper<DaCumulatePointEntity> wrapper = new QueryWrapper<>();
        wrapper.in("point_id", Arrays.asList(ids));
        baseDao.delete(wrapper);
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -15,18 +15,18 @@
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.DaMeasurePointService;
import com.iailab.module.data.point.service.DaPointService;
import com.iailab.module.data.point.service.DaSequenceNumService;
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.util.CollectionUtils;
@@ -46,13 +46,16 @@
@Service
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
@@ -80,16 +83,27 @@
    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;
    }
@@ -157,6 +171,10 @@
            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;
        }
@@ -184,6 +202,9 @@
                break;
            case CALCULATE_POINT:
                daMathPointService.update(dataPoint.getMathPoint());
                break;
            case CUMULATE:
                daCumulatePointService.update(dataPoint.getCumulatePoint());
                break;
            default:
                break;
@@ -297,6 +318,15 @@
    }
    @Override
    public List<DaPointDTO> getCumulatePoint(String freq) {
        Map<String, Object> params = new HashMap<>();
        params.put("pointType", PointTypeEnum.CUMULATE.getCode());
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("minfreqid", freq);
        return daPointDao.getCumulatePoint(params);
    }
    @Override
    public DaPointDTO getByNo(String pointNo) {
        if (pointNoMap.containsKey(pointNo)) {
            return pointNoMap.get(pointNo);
iailab-module-data/iailab-module-data-biz/src/main/resources/application-local.yml
@@ -145,9 +145,10 @@
influx-db:
  org: IAILab
  bucket: whs_data
  token: gxhXM4H1VOBv07kYXKWyPag_zJ8_oChP4ooZ3u-BkSae9LS8R1wWzJYlmUjL3Qe9t1hDU3DtoYD5HTgjWoTGOg==
  url: http://localhost:8086
  token: 50m9Kl-7_tvJY9kejwgSwxQpVG258EKKRt4qZeDntRnWetHGpkBhYtOOXrd9gmh85cuikKFZMzkTsw9pm1xlcA==
  url: http://127.0.0.1:8086
  username: root
  password: root123456
iems:
  upload-dir: D:/DLUT/upload/
iailab-module-data/iailab-module-data-biz/src/main/resources/application.yaml
@@ -211,6 +211,7 @@
      - t_plan_data_set
      - t_plan_item_category
      - t_plan_item
      - t_da_cumulate_point
  app:
    app-key: data
    app-secret: 85b0df7edc3df3611913df34ed695011
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml
@@ -236,4 +236,29 @@
        </where>
    </select>
    <select id="getCumulatePoint" resultType="com.iailab.module.data.point.dto.DaPointDTO">
        SELECT
        t1.point_no,
        t1.point_name,
        t1.default_value,
        t1.point_type,
        t1.data_type,
        t1.store_type,
        t1.minfreqid,
        t2.moment_point,
        t2.length,
        t2.divisor
        FROM t_da_point t1
        LEFT JOIN t_da_cumulate_point t2 ON t2.point_id = t1.id
        <where>
            t1.point_type =  #{pointType}
            <if test="isEnable != null">
                AND t1.is_enable = #{isEnable}
            </if>
            <if test="minfreqid != null and minfreqid != ''">
                AND t1.minfreqid = #{minfreqid}
            </if>
        </where>
    </select>
</mapper>
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageRespDTO.java
@@ -28,6 +28,9 @@
    @Schema(description = "ID")
    private String id;
    @Schema(description = "配置ID")
    private String configId;
    @Schema(description = "消息标题")
    private String title;
@@ -54,11 +57,14 @@
    private BigDecimal outValue;
    @Schema(description = "预警类型")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private String alarmType;
    @Schema(description = "预警时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date alarmTime;
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
@@ -30,6 +30,8 @@
    ItemVO getItemById(String itemId);
    ItemVO getItemByOutPutId(String outPutId);
    void clearCatch();
    MergeItemVO getMergeItemByItemId(String itemId);
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java
@@ -30,6 +30,9 @@
    
    @Override
    public void saveMmItemOutput(List<MmItemOutputEntity> mmItemOutput) {
        mmItemOutput.forEach(e -> {
            e.setId(e.getId().replace("+","").replace("-",""));
        });
        mmItemOutputDao.insert(mmItemOutput);
        // 清空缓存
        clearCache();
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -17,6 +17,7 @@
import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO;
import com.iailab.module.model.mdk.vo.ItemVO;
import com.iailab.module.model.mdk.vo.MergeItemVO;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -166,11 +167,17 @@
        }
        mmItemOutputService.deleteByItemId(predictItem.getId());
        List<MmItemOutputEntity> mmItemOutput = mmPredictItemDto.getMmItemOutputList();
        mmItemOutput.forEach(e -> {
            e.setId(UUID.randomUUID().toString());
            e.setItemid(predictItem.getId());
        });
        mmItemOutputService.saveMmItemOutput(mmItemOutput);
        if (!CollectionUtils.isEmpty(mmItemOutput)) {
            mmItemOutput.forEach(e -> {
                // 尽量保存原有id
                if (StringUtils.isBlank(e.getId())) {
                    e.setId(UUID.randomUUID().toString());
                }
                e.setItemid(predictItem.getId());
            });
            mmItemOutputService.saveMmItemOutput(mmItemOutput);
        }
        // 清空缓存
        clearCatch();
@@ -268,6 +275,19 @@
    }
    @Override
    public ItemVO getItemByOutPutId(String outPutId) {
        if (StringUtils.isBlank(outPutId)) {
            return null;
        }
        MmItemOutputEntity outPutById = mmItemOutputService.getOutPutById(outPutId);
        if (ObjectUtils.isEmpty(outPutById)) {
            return null;
        }
        String itemId = outPutById.getItemid();
        return getItemById(itemId);
    }
    @Override
    public MergeItemVO getMergeItemByItemId(String itemId) {
        if (StringUtils.isBlank(itemId)) {
            return null;
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictItemRespVO.java
@@ -103,5 +103,7 @@
    @ExcelProperty("运行耗时")
    private Long duration;
    private List<MmItemOutputRespVO> outPuts;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/enums/ModelParamType.java
@@ -15,7 +15,8 @@
public enum ModelParamType {
    DATAPOINT("DATAPOINT", "测点值"),
    PREDICTITEM("PREDICTITEM", "预测值"),
    NORMALITEM("NormalItem", "预测值(NormalItem)"),
    MERGEITEM("MergeItem", "MergeItem"),
    IND("IND", "指标值"),
    PLAN("PLAN", "计划值");
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java
@@ -4,6 +4,8 @@
import com.iailab.module.data.api.point.dto.ApiPointDTO;
import com.iailab.module.data.enums.DataPointFreqEnum;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
import com.iailab.module.model.mcs.pre.service.MmItemResultService;
import com.iailab.module.model.mdk.common.enums.ItemPredictStatus;
import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException;
import com.iailab.module.model.mdk.factory.ItemEntityFactory;
@@ -41,6 +43,12 @@
    @Autowired
    private PredictResultHandler predictResultHandler;
    @Autowired
    private MmItemResultService mmItemResultService;
    @Autowired
    private MmItemOutputService mmItemOutputService;
    /**
     * MergeItem预测
     *
@@ -60,7 +68,7 @@
            int predictLength = itemEntityFactory.getItemById(itemId).getPredictLength();
            double[][] predictResultMat = new double[predictLength][1];
            Map<String, List<DataValueVO>> predictValueMap = new HashMap<>();
            String[] mathItem = expression.split("[\\+ \\-]");
            String[] mathOutPutId = expression.split("[\\+ \\-]");
            ArrayList<Character> operator = new ArrayList<>();
            for (int i = 0; i < expression.length(); i++) {
                if (expression.charAt(i)=='+' || expression.charAt(i)=='-'){
@@ -69,34 +77,36 @@
            }
            String[] compositionItem = expression.split(String.valueOf("&".toCharArray()));
            //是否为计算预测项
            if (mathItem.length > 1) {
                for (String itemNo : mathItem) {
                    if (itemNo.length() > 4) {
            if (mathOutPutId.length > 1) {
                for (String outPutId : mathOutPutId) {
                    if (outPutId.length() > 4) {
                        Date endTime = predictTime;
                        ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo);
                        List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPutList.get(0).getPointid());
//                        ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo);
//                        List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
                        MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(outPutId);
                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPut.getPointid());
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(endTime);
                        calendar.add(Calendar.SECOND, (predictLength - 1) * DataPointFreqEnum.getEumByCode(pointEntity.getMinfreqid()).getValue());
                        endTime = new Timestamp(calendar.getTime().getTime());
                        List<DataValueVO> predictValueList = predictResultHandler.getPredictValueByItemNo(itemNo, predictTime, endTime);
//                        List<DataValueVO> predictValueList = predictResultHandler.getPredictValueByItemNo(itemNo, predictTime, endTime);
                        List<DataValueVO> predictValueList = mmItemResultService.getPredictValue(outPutId, predictTime, endTime);
                        if (predictValueList.size() != predictLength) {
                            log.debug("merge项融合失败:缺少子项预测数据,对应子项ItemNo=" + itemNo);
                            log.debug("merge项融合失败:缺少子项预测数据,对应子项outPutId=" + outPutId);
                            return null;
                        }
                        predictValueMap.put(itemNo, predictValueList);
                        predictValueMap.put(outPutId, predictValueList);
                    }
                }
                for (Integer i = 0; i < predictLength; i++) {
                    double sum =0.0;
                    sum = predictValueMap.get(mathItem[0]).get(i).getDataValue();
                    for (int j = 1; j < mathItem.length; j++) {
                    sum = predictValueMap.get(mathOutPutId[0]).get(i).getDataValue();
                    for (int j = 1; j < mathOutPutId.length; j++) {
                        if (operator.get(j-1)=='+')
                        {sum += predictValueMap.get(mathItem[j]).get(i).getDataValue();}
                        {sum += predictValueMap.get(mathOutPutId[j]).get(i).getDataValue();}
                        if (operator.get(j-1)=='-')
                        {sum -= predictValueMap.get(mathItem[j]).get(i).getDataValue();}
                        {sum -= predictValueMap.get(mathOutPutId[j]).get(i).getDataValue();}
                    }
                    predictResultMat[i][0] = sum;
                }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
@@ -123,8 +123,9 @@
                    return vo;
                }).collect(Collectors.toList());
                break;
            case PREDICTITEM:
                MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(columnItem.getId());
            case NORMALITEM:
            case MERGEITEM:
                MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(columnItem.getParamId());
                dataList = mmItemResultService.getPredictValue(outPut.getId(),
                        columnItem.getStartTime(), columnItem.getEndTime());
                if (dataList == null) {
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java
@@ -55,7 +55,8 @@
        long mins = 0L;
        switch (ModelParamType.getEumByCode(paramType)) {
            case PREDICTITEM:
            case NORMALITEM:
            case MERGEITEM:
                // 预测值
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(startTime);
@@ -131,7 +132,7 @@
            lastItem = item;
            DataValueVO dataEntity = new DataValueVO();
            dataEntity.setDataTime(new Timestamp(item.getKey()));
            dataEntity.setDataTime(new Date(item.getKey()));
            dataEntity.setDataValue(item.getValue());
            completionDataEntityList.add(dataEntity);
        }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
@@ -85,7 +85,8 @@
                }
                dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue());
                break;
            case PREDICTITEM:
            case NORMALITEM:
            case MERGEITEM:
                dateTime = calendar.getTime();
                break;
            case IND:
@@ -120,7 +121,8 @@
                }
                dateTime = calendar.getTime();
                break;
            case PREDICTITEM:
            case NORMALITEM:
            case MERGEITEM:
                dateTime = calendar.getTime();
                break;
            case IND:
@@ -155,7 +157,10 @@
                ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId());
                granularity = DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue();
                break;
            case PREDICTITEM:
            case NORMALITEM:
                granularity = mmPredictItemService.getItemByOutPutId(columnItem.getParamId()).getGranularity();
                break;
            case MERGEITEM:
                granularity = mmPredictItemService.getItemById(columnItem.getParamId()).getGranularity();
                break;
            case IND:
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml
@@ -66,7 +66,27 @@
        ORDER BY TMPI.CREATE_TIME DESC
    </select>
    <select id="queryList" resultType="com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO" parameterType="map">
    <resultMap id="MmPredictItemRespVO" type="com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO">
        <result property="id" column="ID"/>
        <result property="itemno" column="ITEMNO"/>
        <result property="itemname" column="ITEMNAME"/>
        <result property="itemtypeid" column="ITEMTYPEID"/>
        <result property="itemtypename" column="ITEMTYPENAME"/>
        <result property="granularity" column="GRANULARITY"/>
        <result property="isfuse" column="ISFUSE"/>
        <result property="workchecked" column="WORKCHECKED"/>
        <result property="moduleid" column="MODULEID"/>
        <result property="itemorder" column="ITEMORDER"/>
        <result property="status" column="STATUS"/>
        <result property="categoryid" column="CATEGORYID"/>
        <collection property="outPuts" ofType="com.iailab.module.model.mcs.pre.vo.MmItemOutputRespVO">
            <result property="id" column="out_put_id"/>
            <result property="outputorder" column="out_put_order"/>
            <result property="resultName" column="result_name"/>
        </collection>
    </resultMap>
    <select id="queryList" resultMap="MmPredictItemRespVO" parameterType="map">
        SELECT
        TMPI.ID,
        TMPI.ITEMNO,
@@ -79,10 +99,14 @@
        TDMI.MODULEID,
        TDMI.ITEMORDER,
        TMPI.STATUS,
        TDMI.CATEGORYID
        TDMI.CATEGORYID,
        TMIO.id out_put_id,
        TMIO.outputorder out_put_order,
        TMIO.result_name
        FROM T_MM_PREDICT_ITEM TMPI
        LEFT JOIN T_MM_ITEM_TYPE TMIT ON TMIT.ID = TMPI.ITEMTYPEID
        LEFT JOIN T_DM_MODULE_ITEM TDMI ON TDMI.ITEMID = TMPI.ID
        LEFT JOIN t_mm_item_output TMIO ON TMIO.itemid = TMPI.ID
        WHERE 1 = 1
        <if test="itemno != null and itemno != ''">
            AND TMPI.ITEMNO LIKE CONCAT('%', #{itemno},'%')
@@ -99,7 +123,7 @@
        <if test="status != null and status != ''">
            AND TMPI.STATUS = #{status}
        </if>
        ORDER BY TMPI.CREATE_TIME DESC
        ORDER BY TMPI.CREATE_TIME DESC,TMIO.outputorder
    </select>
    <select id="getByModuleId" parameterType="map" resultMap="ItemVO">