潘志宝
2024-11-15 a4891a78db2d8ac9d17ff01d79e72e8aab38785d
预测数据查询
已修改20个文件
已删除7个文件
641 ■■■■ 文件已修改
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineReqVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/db/mysql.sql 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemOutputDao.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmResultTableDao.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmResultTableEntity.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemOutputService.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmResultTableService.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemTypeImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmResultTableServiceImpl.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmItemOutputRespVO.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmResultTablePageReqVO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmResultTableRespVO.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ItemEntityFactory.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/PredictItemFactory.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/MmItemOutputVO.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmItemOutputDao.xml 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -61,12 +61,19 @@
    @Resource
    private ChannelSourceService channelSourceService;
    private static Map<String, DaPointDTO> pointIdMap = new ConcurrentHashMap<>();
    private static Map<String, DaPointDTO> pointNoMap = new ConcurrentHashMap<>();
    @Override
    public PageResult<DaPointDTO> queryPage(DaPointPageReqVO reqVO) {
        IPage<DaPointDTO> page = daPointDao.selectPageList(reqVO);
        return new PageResult<DaPointDTO>(page.getRecords(), page.getTotal());
        return new PageResult<>(page.getRecords(), page.getTotal());
    }
    private void clearCache() {
        pointIdMap.clear();
        pointNoMap.clear();
    }
    @Override
@@ -89,7 +96,12 @@
    @Override
    public DaPointDTO getSimpleInfoById(String id) {
        return ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class);
        if (pointIdMap.containsKey(id)) {
            return pointIdMap.get(id);
        }
        DaPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class);
        pointIdMap.put(id, dto);
        return dto;
    }
    @Override
@@ -150,7 +162,7 @@
        daPointDao.insert(daPointEntity);
        // 清空缓存
        pointNoMap.clear();
        clearCache();
    }
    @Override
@@ -174,7 +186,7 @@
                break;
        }
        // 清空缓存
        pointNoMap.clear();
        clearCache();
    }
    @Override
@@ -184,7 +196,7 @@
        daMeasurePointService.deleteByPoint(id);
        daMathPointService.deleteByPoint(id);
        // 清空缓存
        pointNoMap.clear();
        clearCache();
    }
    @Override
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml
@@ -65,7 +65,7 @@
                and t1.is_enable = #{params.isEnable}
            </if>
        </where>
        order by t1.create_time desc
        order by t1.create_time desc, t1.point_no desc
    </select>
    <select id="getList" resultType="com.iailab.module.data.point.dto.DaPointDTO">
@@ -130,7 +130,7 @@
                and t1.is_enable = #{isEnable}
            </if>
        </where>
        order by t1.create_time desc
        order by t1.create_time desc, t1.point_no desc
    </select>
    <select id="getConstantPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO">
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineReqVO.java
@@ -20,6 +20,9 @@
    @Schema(description = "查询ID列表")
    private List<String[]> queryIds;
    @Schema(description = "输出ID列表")
    private List<String> outIds;
    @Schema(description = "预测时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date predictTime;
iailab-module-model/iailab-module-model-biz/db/mysql.sql
@@ -160,14 +160,6 @@
) engine = innodb
  default character set utf8mb4 COMMENT = '预测项模型表';
create table t_mm_result_table
(
    id        varchar(36) not null,
    tablename varchar(30),
    primary key (id)
) engine = innodb default character set utf8mb4 COMMENT = '预测结果存放表';
create table t_mm_item_result_json
(
    id          varchar(36) not null,
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
@@ -9,6 +9,7 @@
import com.iailab.module.model.api.mcs.dto.*;
import com.iailab.module.model.mcs.pre.entity.DmModuleEntity;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.enums.ItemStatus;
import com.iailab.module.model.mcs.pre.service.*;
import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO;
import com.iailab.module.model.mdk.vo.ItemVO;
@@ -64,14 +65,22 @@
            moduleOpt.setId(item.getId());
            moduleOpt.setLabel(item.getModulename());
            List<PredictItemTreeDTO> children = new ArrayList<>();
            Map<String, Object> params = new HashMap<>(2);
            params.put("status", 1);
            params.put("moduleid", item.getId());
            List<MmPredictItemRespVO> itemList = mmPredictItemService.list(params);
            List<ItemVO> itemList = mmPredictItemService.getByModuleId(item.getId());
            itemList.forEach(item1 -> {
                PredictItemTreeDTO chd = new PredictItemTreeDTO();
                chd.setLabel(item1.getItemname());
                chd.setLabel(item1.getItemName());
                chd.setId(item1.getId());
                List<PredictItemTreeDTO> chd1 = new ArrayList<>();
                List<MmItemOutputEntity> outList = mmItemOutputService.getByItemid(item1.getId());
                if (!CollectionUtils.isEmpty(outList)) {
                    outList.forEach(out -> {
                        PredictItemTreeDTO chd2 = new PredictItemTreeDTO();
                        chd2.setId(out.getId());
                        chd2.setLabel(out.getResultstr());
                        chd1.add(chd2);
                    });
                }
                chd.setChildren(chd1);
                children.add(chd);
            });
            moduleOpt.setChildren(children);
@@ -83,7 +92,7 @@
    @Override
    public PreDataBarLineRespVO getPreDataCharts(PreDataBarLineReqVO reqVO) {
        PreDataBarLineRespVO result = new PreDataBarLineRespVO();
        List<String[]> queryIds = reqVO.getQueryIds();
        List<String> outIds = reqVO.getOutIds();
        List<String> legends = new ArrayList<>();
        List<PreDataViewRespDTO> dataViewList = new ArrayList<>();
        if (CollectionUtils.isEmpty(reqVO.getQueryIds())) {
@@ -91,15 +100,10 @@
        }
        Date predictTime = reqVO.getPredictTime();
        if (predictTime == null) {
            DmModuleEntity dmModule = dmModuleService.getModuleByItemId(queryIds.get(0)[0]);
            if (dmModule != null) {
                predictTime = dmModule.getPredicttime();
            } else {
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.MILLISECOND, 0);
                calendar.set(Calendar.SECOND, 0);
                predictTime = calendar.getTime();
            }
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.MILLISECOND, 0);
            calendar.set(Calendar.SECOND, 0);
            predictTime = calendar.getTime();
        }
        Date startTime = reqVO.getStartTime();
        if (startTime == null) {
@@ -116,11 +120,10 @@
            endTime = calendar.getTime();
        }
        for (int i = 0; i < queryIds.size(); i++) {
        for (int i = 0; i < outIds.size(); i++) {
            PreDataViewRespDTO viewDto = new PreDataViewRespDTO();
            String itemId = queryIds.get(i)[0];
            String outKey = queryIds.get(i)[1];
            MmItemOutputEntity output = mmItemOutputService.getByItemid(itemId, outKey);
            String outId = outIds.get(i);
            MmItemOutputEntity output = mmItemOutputService.getOutPutById(outId);
            if (output == null) {
               continue;
            }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
@@ -2,24 +2,19 @@
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.module.model.api.mcs.McsApi;
import com.iailab.module.model.api.mcs.dto.PreDataBarLineReqVO;
import com.iailab.module.model.api.mcs.dto.PreDataBarLineRespVO;
import com.iailab.module.model.api.mcs.dto.PreDataItemChartReqVO;
import com.iailab.module.model.api.mcs.dto.PreDataItemChartRespVO;
import com.iailab.module.model.api.mcs.dto.*;
import com.iailab.module.model.common.utils.ApiSecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * @author PanZhibao
@@ -39,6 +34,16 @@
    private McsApi mcsApi;
    @PermitAll
    @GetMapping("/predict-item/tree")
    @Operation(summary = "预测项树")
    public CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(HttpServletResponse response, HttpServletRequest
            request) throws Exception {
        apiSecurityUtils.validate(request);
        List<PredictItemTreeDTO> list = mcsApi.getPredictItemTree();
        return CommonResult.success(list);
    }
    @PermitAll
    @PostMapping("/predict-data/charts")
    @Operation(summary = "预测数据图表")
    public CommonResult<PreDataBarLineRespVO> getPreDataCharts(HttpServletResponse response, HttpServletRequest
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemOutputDao.java
@@ -4,7 +4,6 @@
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO;
import com.iailab.module.model.mdk.vo.MmItemOutputVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -20,10 +19,4 @@
public interface MmItemOutputDao extends BaseMapperX<MmItemOutputEntity> {
    List<MmItemOutputDTO> queryList(@Param("params") Map<String, Object> params);
    List<MmItemOutputVO> getOutPutById(String outputid);
    List<MmItemOutputVO> getOutPutByItemId(String itemid);
    List<MmItemOutputVO> getOutPutByPointId(String pointid);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmResultTableDao.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmResultTableEntity.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemOutputService.java
@@ -2,7 +2,6 @@
import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mdk.vo.MmItemOutputVO;
import java.util.List;
import java.util.Map;
@@ -19,13 +18,9 @@
    List<MmItemOutputDTO> queryList(Map<String, Object> params);
    MmItemOutputVO getOutPutById(String outputid);
    MmItemOutputEntity getOutPutById(String outputid);
    List<MmItemOutputVO> getOutPutByItemId(String itemid);
    List<MmItemOutputVO> getOutPutByPointId(String pointid);
    List<MmItemOutputEntity> getByItemid(String itemid);
    List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> getByItemid(String itemid);
    MmItemOutputEntity getByItemid(String itemid, String resultstr);
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java
@@ -1,6 +1,5 @@
package com.iailab.module.model.mcs.pre.service;
import com.iailab.module.model.mcs.pre.entity.MmItemResultEntity;
import com.iailab.module.model.mdk.vo.DataValueVO;
import java.util.Date;
@@ -12,8 +11,6 @@
 * @date 2021年05月28日 10:34
 */
public interface MmItemResultService {
    List<MmItemResultEntity> getListByOutputId(String outputid, Map<String, Object> params);
    void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime);
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmResultTableService.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java
@@ -6,14 +6,12 @@
import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
import com.iailab.module.model.mdk.vo.MmItemOutputVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @author PanZhibao
@@ -24,21 +22,29 @@
    @Autowired
    private MmItemOutputDao mmItemOutputDao;
    private static Map<String, MmItemOutputEntity> outputMap = new ConcurrentHashMap<>();
    
    @Override
    public void saveMmItemOutput(List<MmItemOutputEntity> mmItemOutput) {
        mmItemOutputDao.insert(mmItemOutput);
        // 清空缓存
        outputMap.clear();
    }
    @Override
    public void update(MmItemOutputEntity mmItemOutput) {
        mmItemOutputDao.updateById(mmItemOutput);
        // 清空缓存
        outputMap.clear();
    }
    public void deleteBatch(String[] itemIds) {
        QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper();
        queryWrapper.in("itemid", itemIds);
        mmItemOutputDao.delete(queryWrapper);
        // 清空缓存
        outputMap.clear();
    }
    @Override
@@ -69,21 +75,12 @@
    }
    @Override
    public MmItemOutputVO getOutPutById(String outputid) {
        List<MmItemOutputVO> list = mmItemOutputDao.getOutPutById(outputid);
        if (CollectionUtils.isEmpty(list)) {
            return null;
    public MmItemOutputEntity getOutPutById(String outputid) {
        if (outputMap.containsKey(outputid)) {
            return outputMap.get(outputid);
        }
        return list.get(0);
    }
    @Override
    public List<MmItemOutputVO> getOutPutByItemId(String itemid) {
        return mmItemOutputDao.getOutPutByItemId(itemid);
    }
    @Override
    public List<MmItemOutputVO> getOutPutByPointId(String pointid) {
        return mmItemOutputDao.getOutPutByPointId(pointid);
        MmItemOutputEntity entity = mmItemOutputDao.selectById(outputid);
        outputMap.put(outputid, entity);
        return entity;
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java
@@ -32,32 +32,6 @@
    @Autowired
    private MmItemResultDao mmItemResultDao;
    @Override
    public List<MmItemResultEntity> getListByOutputId(String outputid, Map<String, Object> params) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startDateParam = null;
        try {
            startDateParam = sdf.parse((String)params.get("startTime"));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Date endDateParam = null;
        try {
            endDateParam = sdf.parse((String)params.get("endTime"));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        List<MmItemResultEntity> list = mmItemResultDao.selectList(
                new QueryWrapper<MmItemResultEntity>()
                        .eq("outputid", outputid)
                        .between("datatime", startDateParam, endDateParam)
                        .orderByAsc("datatime")
        );
        return list;
    }
    @Override
    public void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime) {
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemTypeImpl.java
@@ -16,6 +16,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @author PanZhibao
@@ -26,6 +27,8 @@
    @Autowired
    private MmItemTypeDao mmItemTypeDao;
    private Map<String, MmItemTypeEntity> typeIdMap = new ConcurrentHashMap<>();
    
    @Override
    public PageResult<MmItemTypeEntity> page(MmItemTypePageReqVO reqVO) {
@@ -36,16 +39,19 @@
    public void saveItemType(MmItemTypeEntity itemType) {
        itemType.setId(UUID.randomUUID().toString());
        mmItemTypeDao.insert(itemType);
        typeIdMap.clear();
    }
    @Override
    public void update(MmItemTypeEntity itemType) {
        mmItemTypeDao.updateById(itemType);
        typeIdMap.clear();
    }
    @Override
    public void deleteBatch(String[] moduleIds) {
        mmItemTypeDao.deleteBatchIds(Arrays.asList(moduleIds));
        typeIdMap.clear();
    }
    @Override
@@ -61,10 +67,14 @@
    @Override
    public MmItemTypeEntity getItemTypeByItemId(String itemId) {
        if (typeIdMap.containsKey(itemId)) {
            return typeIdMap.get(itemId);
        }
        List<MmItemTypeEntity> list = mmItemTypeDao.getItemTypeByItemId(itemId);
        if (CollectionUtils.isAnyEmpty(list)) {
            return null;
        }
        typeIdMap.put(itemId, list.get(0));
        return list.get(0);
    }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmResultTableServiceImpl.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmItemOutputRespVO.java
@@ -2,12 +2,10 @@
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
/**
@@ -18,7 +16,8 @@
@Schema(description = "模型平台 - MmItemOutput Response VO")
@Data
@ExcelIgnoreUnannotated
public class MmItemOutputRespVO {
public class MmItemOutputRespVO implements Serializable {
    private static final long serialVersionUID = 1L;
    @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("ID")
@@ -36,6 +35,10 @@
    @ExcelProperty("存放表ID")
    private String resulttableid;
    @Schema(description = "输出结果")
    @ExcelProperty("输出结果")
    private String resultstr;
    @Schema(description = "数据点名称")
    @ExcelProperty("数据点名称")
    private String tagname;
@@ -43,4 +46,8 @@
    @Schema(description = "排序(默认值1)")
    @ExcelProperty("排序")
    private BigDecimal outputorder;
    @Schema(description = "结果名称")
    @ExcelProperty("结果名称")
    private String resultName;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmResultTablePageReqVO.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmResultTableRespVO.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ItemEntityFactory.java
@@ -1,12 +1,12 @@
package com.iailab.module.model.mdk.factory;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity;
import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
import com.iailab.module.model.mdk.vo.ItemVO;
import com.iailab.module.model.mdk.vo.MergeItemVO;
import com.iailab.module.model.mdk.vo.MmItemOutputVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -23,8 +23,7 @@
    private Map<String, MmItemTypeEntity> itemTypeMap = new HashMap<>();
    private Map<String, MergeItemVO> mergeItemMap = new HashMap<>();
    private Map<String, ItemVO> itemNoEntityMap = new HashMap<>();
    private Map<String, List<MmItemOutputVO>> itemOutPutItemMap = new HashMap<>();
    private Map<String, MmItemOutputVO> itemOutputMap = new HashMap<>();
    private Map<String, List<MmItemOutputEntity>> itemOutPutItemMap = new HashMap<>();
    @Autowired
    private MmPredictItemService mmPredictItemService;
@@ -95,8 +94,8 @@
     * @param itemId
     * @return
     */
    public List<MmItemOutputVO> getOutPutByItemId(String itemId) {
        List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId);
    public List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> getOutPutByItemId(String itemId) {
        List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> list = mmItemOutputService.getByItemid(itemId);
        if (!itemOutPutItemMap.containsKey(itemId)) {
            if (list != null) {
                itemOutPutItemMap.put(itemId, list);
@@ -107,57 +106,4 @@
        return list;
    }
    /**
     * 5.
     *
     * @param outputId
     * @return
     */
    public MmItemOutputVO getItemOutPutById(String outputId) {
        if (!itemOutputMap.containsKey(outputId)) {
            MmItemOutputVO itemOutput = mmItemOutputService.getOutPutById(outputId);
            if (itemOutput != null) {
                itemOutputMap.put(outputId, itemOutput);
            } else {
                return null;
            }
        }
        return itemOutputMap.get(outputId);
    }
    /**
     * 6.根据预测项ID,获取预测项对应的输出参数的维数
     *
     * @param itemId
     * @return
     */
    public Integer getItemOutputCount(String itemId) {
        if (!itemOutPutItemMap.containsKey(itemId)) {
            List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId);
            if (list != null) {
                itemOutPutItemMap.put(itemId, list);
            } else {
                return 0;
            }
        }
        return itemOutPutItemMap.get(itemId).size();
    }
    /**
     * 7.根据预测项ID,获取对应的MmItemTypeEntity实体
     *
     * @param itemId
     * @return
     */
    public MmItemTypeEntity getMmItemTypeEntity(String itemId) {
        if (!itemTypeMap.containsKey(itemId)) {
            MmItemTypeEntity MmItemTypeEntity = mmItemTypeService.getItemTypeByItemId(itemId);
            if (MmItemTypeEntity != null) {
                itemTypeMap.put(itemId, MmItemTypeEntity);
            } else {
                return null;
            }
        }
        return itemTypeMap.get(itemId);
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/PredictItemFactory.java
@@ -1,6 +1,7 @@
package com.iailab.module.model.mdk.factory;
import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity;
import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
import com.iailab.module.model.mdk.predict.PredictItemHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,7 +19,7 @@
    private ApplicationContext applicationContext;
    @Autowired
    private ItemEntityFactory itemEntityFactory;
    private MmItemTypeService mmItemTypeService;
    /**
     * 根据预测项实体创建对应的预测项对象
@@ -27,7 +28,7 @@
     * @return
     */
    public PredictItemHandler create(String itemId) {
        MmItemTypeEntity itemTypeEntity = itemEntityFactory.getMmItemTypeEntity(itemId);
        MmItemTypeEntity itemTypeEntity = mmItemTypeService.getItemTypeByItemId(itemId);
        //获取预测项的预测程序的类
        Object itemObject = null;
        try {
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java
@@ -5,7 +5,6 @@
import com.iailab.module.model.mcs.pre.service.MmItemResultService;
import com.iailab.module.model.mdk.factory.ItemEntityFactory;
import com.iailab.module.model.mdk.vo.DataValueVO;
import com.iailab.module.model.mdk.vo.MmItemOutputVO;
import com.iailab.module.model.mdk.vo.PredictResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
@@ -30,15 +29,15 @@
     */
    public Map<String, List<DataValueVO>> convertToPredictData(PredictResultVO predictResult) {
        Map<String, List<DataValueVO>> resultMap = new HashMap<>();
        List<MmItemOutputVO> itemOutPutList = itemEntityFactory.getOutPutByItemId(predictResult.getPredictId());
        List<MmItemOutputEntity> itemOutPutList = itemEntityFactory.getOutPutByItemId(predictResult.getPredictId());
        if (!CollectionUtils.isEmpty(predictResult.getPredictList())) {
            resultMap.put(itemOutPutList.get(0).getId(), predictResult.getPredictList());
            return resultMap;
        }
        Map<MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs();
        Map<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs();
        HashMap<String,List<DataValueVO>> predictLists = new HashMap<>();
        for (Map.Entry<MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) {
        for (Map.Entry<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) {
            Integer rows = entry.getValue().length;
            List<DataValueVO> predictDataList = new ArrayList<>();
            Calendar calendar = Calendar.getInstance();
@@ -63,8 +62,8 @@
        if (!CollectionUtils.isEmpty(predictResult.getPredictList())) {
            return predictLists;
        }
        Map<MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs();
        for (Map.Entry<MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) {
        Map<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs();
        for (Map.Entry<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) {
            Integer rows = entry.getValue().length;
            List<DataValueVO> predictDataList = new ArrayList<>();
            Calendar calendar = Calendar.getInstance();
@@ -96,12 +95,12 @@
    public List<DataValueVO> getPredictValueByItemNo(String itemNo, Date start, Date end) {
        String itemId = itemEntityFactory.getItemByItemNo(itemNo).getId();
        List<MmItemOutputVO> outputList = itemEntityFactory.getOutPutByItemId(itemId);
        List<MmItemOutputEntity> outputList = itemEntityFactory.getOutPutByItemId(itemId);
        return mmItemResultService.getPredictValue(outputList.get(0).getId(), start, end);
    }
    public List<DataValueVO> getPredictValueByItemId(String itemId, Date start, Date end) {
        List<MmItemOutputVO> outputList = itemEntityFactory.getOutPutByItemId(itemId);
        List<MmItemOutputEntity> outputList = itemEntityFactory.getOutPutByItemId(itemId);
        return mmItemResultService.getPredictValue(outputList.get(0).getId(), start, end);
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java
@@ -3,6 +3,7 @@
import com.iailab.module.data.api.point.DataPointApi;
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.mdk.common.enums.ItemPredictStatus;
import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException;
import com.iailab.module.model.mdk.factory.ItemEntityFactory;
@@ -11,7 +12,6 @@
import com.iailab.module.model.mdk.predict.PredictResultHandler;
import com.iailab.module.model.mdk.vo.DataValueVO;
import com.iailab.module.model.mdk.vo.ItemVO;
import com.iailab.module.model.mdk.vo.MmItemOutputVO;
import com.iailab.module.model.mdk.vo.PredictResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -74,8 +74,8 @@
                    if (itemNo.length() > 4) {
                        Date endTime = predictTime;
                        ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo);
                        List<MmItemOutputVO> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPutList.get(0).getPointId());
                        List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPutList.get(0).getPointid());
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(endTime);
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
@@ -1,18 +1,19 @@
package com.iailab.module.model.mdk.sample;
import com.iailab.framework.common.util.object.ConvertUtils;
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.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.factory.ItemEntityFactory;
import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
import com.iailab.module.model.mdk.common.enums.ModelParamType;
import com.iailab.module.model.mdk.sample.dto.ColumnItem;
import com.iailab.module.model.mdk.sample.dto.ColumnItemPort;
import com.iailab.module.model.mdk.sample.dto.SampleData;
import com.iailab.module.model.mdk.sample.dto.SampleInfo;
import com.iailab.module.model.mdk.vo.DataValueVO;
import com.iailab.module.model.mdk.vo.MmItemOutputVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +38,10 @@
    private MmItemResultService mmItemResultService;
    @Autowired
    private ItemEntityFactory itemEntityFactory;
    private MmItemTypeService mmItemTypeService;
    @Autowired
    private MmItemOutputService mmItemOutputService;
    /**
     * alter by zfc 2020.11.24 修改数据样本构造方案:sampleInfo中数据已按爪子进行分类,但爪内数据为无序的,
@@ -50,7 +54,6 @@
    public List<SampleData> prepareSampleData(SampleInfo sampleInfo) {
        List<SampleData> sampleDataList = new ArrayList<>();
        //对每个爪分别进行计算
        int deviationIndex = 0;
        for (ColumnItemPort entry : sampleInfo.getColumnInfo()) {
            //先依据爪内数据项的modelParamOrder进行排序——重写comparator匿名函数
            Collections.sort(entry.getColumnItemList(), new Comparator<ColumnItem>() {
@@ -68,31 +71,14 @@
                }
            }
            //找出对应的调整值
            BigDecimal[] deviationItem = null;
            if (sampleInfo.getDeviation() != null && sampleInfo.getDeviation().length > 0) {
                deviationItem = sampleInfo.getDeviation()[deviationIndex];
            }
            deviationIndex++;
            //对每一项依次进行数据查询,然后将查询出的值赋给matrix对应的位置
            for (int i = 0; i < entry.getColumnItemList().size(); i++) {
                try {
                    List<DataValueVO> dataEntityList = getData(entry.getColumnItemList().get(i));
                    //设置调整值
                    if (deviationItem != null && deviationItem.length > 0) {
                        logger.info("设置调整值, i = " + i);
                        if (deviationItem[i] != null && deviationItem[i].compareTo(BigDecimal.ZERO) != 0) {
                            for (int dataKey = 1; dataKey < dataEntityList.size(); dataKey++) {
                                DataValueVO item = dataEntityList.get(dataKey);
                                item.setDataValue(item.getDataValue() + deviationItem[i].doubleValue());
                            }
                        }
                    }
                    //补全数据
                    ColumnItem columnItem = entry.getColumnItemList().get(i);
//                    dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.getEndTime(), columnItem.granularity);
                    dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime, columnItem.paramId,columnItem.getParamType());
                    dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime,
                            columnItem.paramId, columnItem.getParamType());
                    /** 如果数据取不满,把缺失的数据点放在后面 */
                    if (dataEntityList != null && dataEntityList.size() != 0) {
@@ -122,31 +108,29 @@
    private List<DataValueVO> getData(ColumnItem columnItem) throws Exception {
        List<DataValueVO> dataList = new ArrayList<>();
        String paramType = columnItem.getParamType();
        switch (paramType) {
            case "DATAPOINT":
        switch (ModelParamType.getEumByCode(paramType)) {
            case DATAPOINT:
                ApiPointDTO point = dataPointApi.getInfoById(columnItem.getParamId());
                ApiPointValueQueryDTO queryDto = new ApiPointValueQueryDTO();
                queryDto.setPointNo(point.getPointNo());
                queryDto.setStart(columnItem.getStartTime());
                queryDto.setEnd(columnItem.getEndTime());
                List<ApiPointValueDTO> pointValueList = dataPointApi.queryPointHistoryValue(queryDto);
                dataList = pointValueList.stream().map( t-> {
                dataList = pointValueList.stream().map(t -> {
                    DataValueVO vo = new DataValueVO();
                    vo.setDataTime(t.getT());
                    vo.setDataValue(t.getV());
                    return vo;
                }).collect(Collectors.toList());
                break;
            case "PREDICTITEM":
                MmItemOutputVO outPut = itemEntityFactory.getItemOutPutById(columnItem.getId());
            case PREDICTITEM:
                MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(columnItem.getId());
                dataList = mmItemResultService.getPredictValue(outPut.getId(),
                        columnItem.getStartTime(), columnItem.getEndTime());
                if (dataList == null) {
                    throw new Exception("没有预测值");
                }
                break;
            default:
                break;
        }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java
@@ -39,11 +39,12 @@
     * @param endTime
     * @return
     */
    public List<DataValueVO> completionData(int length, List<DataValueVO> dataEntityList, Date startTime, Date endTime, String paramId,String paramType) {
    public List<DataValueVO> completionData(int length, List<DataValueVO> dataEntityList, Date startTime, Date endTime,
                                            String paramId, String paramType) {
        if (CollectionUtils.isEmpty(dataEntityList) || length == dataEntityList.size()) {
            return dataEntityList;
        }else if (length < dataEntityList.size()){
            return dataEntityList.subList(dataEntityList.size()-length,dataEntityList.size());
        } else if (length < dataEntityList.size()) {
            return dataEntityList.subList(dataEntityList.size() - length, dataEntityList.size());
        }
        List<DataValueVO> completionDataEntityList = new ArrayList<>();
@@ -58,20 +59,19 @@
                // 预测值
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(startTime);
                calendar.set(Calendar.HOUR_OF_DAY,0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                calendar.add(Calendar.DAY_OF_YEAR,1);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.add(Calendar.DAY_OF_YEAR, 1);
                startTime = calendar.getTime();
                start = startTime.getTime();
                calendar.setTime(endTime);
                calendar.set(Calendar.HOUR_OF_DAY,0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                endTime = calendar.getTime();
                end = endTime.getTime();
                oneMin = 24 * 60 * 60 * 1000;
                mins = ((end - start) / oneMin);
@@ -80,12 +80,9 @@
                // 测点值
                ApiPointDTO dataPoint = dataPointApi.getInfoById(paramId);
                oneMin = 1000L * DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue();
                // 设置时间偏移量
                start = start - (start % oneMin) + oneMin;
                end = end - (end % oneMin) + oneMin;
                mins = ((end - start) / oneMin);
                break;
            case IND:
@@ -93,18 +90,16 @@
                oneMin = 24 * 60 * 60 * 1000;
                Calendar calendar2 = Calendar.getInstance();
                calendar2.setTime(startTime);
                calendar2.set(Calendar.HOUR_OF_DAY,0);
                calendar2.set(Calendar.MINUTE,0);
                calendar2.set(Calendar.SECOND,0);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                start = calendar2.getTime().getTime();
                calendar2.setTime(endTime);
                calendar2.set(Calendar.HOUR_OF_DAY,0);
                calendar2.set(Calendar.MINUTE,0);
                calendar2.set(Calendar.SECOND,0);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                end = calendar2.getTime().getTime();
                mins = ((end - start) / oneMin);
                break;
            default:
@@ -117,7 +112,7 @@
        //找出缺少项
        Map<Long, Double> dataMap = new LinkedHashMap<>();
        for (int i = 0; i < mins; i ++) {
        for (int i = 0; i < mins; i++) {
            Long key = start + oneMin * i;
            Double value = sourceDataMap.get(key);
            dataMap.put(key, value);
@@ -132,7 +127,7 @@
            } else if (item.getValue() == null) {
                item.setValue(lastItem.getValue());
            }
            k ++;
            k++;
            lastItem = item;
            DataValueVO dataEntity = new DataValueVO();
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/MmItemOutputVO.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmItemOutputDao.xml
@@ -3,47 +3,4 @@
<mapper namespace="com.iailab.module.model.mcs.pre.dao.MmItemOutputDao">
    <resultMap id="MmItemOutputVO" type="com.iailab.module.model.mdk.vo.MmItemOutputVO">
        <result property="id" column="ID"/>
        <result property="itemId" column="ITEMID"/>
        <result property="pointId" column="POINTID"/>
        <result property="resultTableName" column="TABLENAME"/>
        <result property="order" column="OUTPUTORDER"/>
    </resultMap>
    <select id="getOutPutById" resultMap="MmItemOutputVO">
        SELECT t1.id,
               t1.itemid,
               t1.pointid,
               t2.tablename,
               t1.outputorder
        FROM t_mm_item_output t1,
             t_mm_result_table t2
        WHERE t1.id = #{value}
          AND t1.resulttableid = t2.id
    </select>
    <select id="getOutPutByItemId" resultMap="MmItemOutputVO">
        SELECT t1.id,
               t1.itemid,
               t1.pointid,
               t2.tablename,
               t1.outputorder
        FROM t_mm_item_output t1,
             t_mm_result_table t2
        WHERE t1.itemid = #{itemid}
          AND t1.resulttableid = t2.id
        ORDER BY t1.outputorder
    </select>
    <select id="getOutPutByPointId" resultMap="MmItemOutputVO">
        SELECT t1.id,
               t1.itemid,
               t1.pointid,
               t2.tablename,
               t1.outputorder
        FROM t_mm_item_output t1,
             t_mm_result_table t2
        WHERE t1.pointid = #{value}
          AND t1.resulttableid = t2.id
        ORDER BY t1.outputorder
    </select>
</mapper>