houzhongjian
2024-11-15 12d96beabf4e1c96deb7c379a7421a89178734be
Merge remote-tracking branch 'origin/master'
已修改31个文件
已删除7个文件
751 ■■■■ 文件已修改
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/point/dto/ApiPointValueDTO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/controller/admin/PlanItemController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/PlanItemService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/impl/PlanItemServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemRespVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java 37 ●●●● 补丁 | 查看 | 原始文档 | 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-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewRespDTO.java 9 ●●●●● 补丁 | 查看 | 原始文档 | 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 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java 2 ●●● 补丁 | 查看 | 原始文档 | 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 28 ●●●●● 补丁 | 查看 | 原始文档 | 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/MmModelArithSettingsServiceImpl.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | 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 52 ●●●●● 补丁 | 查看 | 原始文档 | 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-api/src/main/java/com/iailab/module/data/api/point/dto/ApiPointValueDTO.java
@@ -16,7 +16,7 @@
    private static final long serialVersionUID = 1L;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date dataTime;
    private Date t;
    private double dataValue;
    private double v;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java
@@ -151,8 +151,8 @@
                queryDto.setPointNo(item.getPointNo());
                List<ApiPointValueDTO> list = dataPointApi.queryPointHistoryValue(queryDto);
                List<Object[]> sData = list.stream().map(dataItem -> {
                    Object[] valueArray = new Object[]{DateUtils.format(dataItem.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND),
                            getFormatValue(item.getDataType(), dataItem.getDataValue())};
                    Object[] valueArray = new Object[]{DateUtils.format(dataItem.getT(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND),
                            getFormatValue(item.getDataType(), dataItem.getV())};
                    return valueArray;
                }).collect(Collectors.toList());
                seriesItem.setData(sData);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java
@@ -88,8 +88,8 @@
        List<ApiPointValueDTO> pointValueList = new ArrayList<>();
        for (int i = 0; list.size() - i >= 1; i++) {
            ApiPointValueDTO pointValue = new ApiPointValueDTO();
            pointValue.setDataValue(Double.parseDouble(list.get(i).get(InfluxDBServiceImpl.VALUE).toString()));
            pointValue.setDataTime(DateUtils.parse(list.get(i).get(InfluxDBServiceImpl.TIME).toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
            pointValue.setV(Double.parseDouble(list.get(i).get(InfluxDBServiceImpl.VALUE).toString()));
            pointValue.setT(DateUtils.parse(list.get(i).get(InfluxDBServiceImpl.TIME).toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
            pointValueList.add(pointValue);
        }
        return pointValueList;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/controller/admin/PlanItemController.java
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
@@ -94,8 +95,8 @@
    @GetMapping("/list")
    @Operation(summary = "获取计划项列表", description = "用于【计划项】界面")
    @PreAuthorize("@ss.hasPermission('data:plan-item:query')")
    public CommonResult<List<PlanItemRespVO>> getList(PlanItemPageReqVO reqVO) {
        List<PlanItemEntity> list = planItemService.list();
    public CommonResult<List<PlanItemRespVO>> getList(@RequestParam Map<String, Object> params) {
        List<PlanItemEntity> list = planItemService.list(params);
        return success(ConvertUtils.sourceToTarget(list, PlanItemRespVO.class));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/PlanItemService.java
@@ -19,7 +19,7 @@
    PageResult<PlanItemEntity> page(PlanItemPageReqVO reqVO);
    List<PlanItemEntity> list();
    List<PlanItemEntity> list(Map<String, Object> params);
    void create(PlanItemSaveReqVO createReqVO);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/impl/PlanItemServiceImpl.java
@@ -34,8 +34,9 @@
    }
    @Override
    public List<PlanItemEntity> list() {
    public List<PlanItemEntity> list(Map<String, Object> params) {
        QueryWrapper<PlanItemEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(params.get("status") != null, "status", params.get("status"));
        queryWrapper.orderByDesc("create_time");
        return baseDao.selectList(queryWrapper);
    }
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemRespVO.java
@@ -2,9 +2,6 @@
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.module.data.ind.item.vo.IndItemAtomVO;
import com.iailab.module.data.ind.item.vo.IndItemCalVO;
import com.iailab.module.data.ind.item.vo.IndItemDerVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -26,13 +26,13 @@
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 com.iailab.module.infra.api.config.ConfigApi;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
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;
@@ -59,15 +59,21 @@
    private DaPointDao daPointDao;
    @Resource
    private ConfigApi configApi;
    @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
@@ -90,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
@@ -149,6 +160,9 @@
        daPointEntity.setIsEnable(CommonConstant.IS_ENABLE);
        daPointEntity.setCreateTime(new Date());
        daPointDao.insert(daPointEntity);
        // 清空缓存
        clearCache();
    }
    @Override
@@ -171,6 +185,8 @@
            default:
                break;
        }
        // 清空缓存
        clearCache();
    }
    @Override
@@ -179,6 +195,8 @@
        daPointDao.deleteBatchIds(Arrays.asList(id));
        daMeasurePointService.deleteByPoint(id);
        daMathPointService.deleteByPoint(id);
        // 清空缓存
        clearCache();
    }
    @Override
@@ -277,10 +295,15 @@
    @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 = daPointDao.selectOne(wrapper);
        return ConvertUtils.sourceToTarget(entity, DaPointDTO.class);
        DaPointDTO dto = ConvertUtils.sourceToTarget(entity, DaPointDTO.class);
        pointNoMap.put(pointNo, dto);
        return dto;
    }
    @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-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewRespDTO.java
@@ -26,6 +26,15 @@
    @Schema(description = "预测项名称")
    private String itemName;
    @Schema(description = "输出ID")
    private String outId;
    @Schema(description = "输出结果")
    private String resultstr;
    @Schema(description = "输出结果")
    private String resultName;
    @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
@@ -10,7 +10,6 @@
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.service.*;
import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO;
import com.iailab.module.model.mdk.vo.ItemVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,14 +63,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,17 +90,18 @@
    @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())) {
        if (CollectionUtils.isEmpty(outIds)) {
            return result;
        }
        Date predictTime = reqVO.getPredictTime();
        if (predictTime == null) {
            DmModuleEntity dmModule = dmModuleService.getModuleByItemId(queryIds.get(0)[0]);
            if (dmModule != null) {
                predictTime = dmModule.getPredicttime();
            MmItemOutputEntity output = mmItemOutputService.getOutPutById(reqVO.getOutIds().get(0));
            ItemVO predictItem = mmPredictItemService.getItemById(output.getItemid());
            if (predictItem.getLastTime() != null) {
                predictTime = predictItem.getLastTime();
            } else {
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.MILLISECOND, 0);
@@ -116,15 +124,17 @@
            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;
                continue;
            }
            legends.add(output.getResultstr());
            viewDto.setItemId(output.getItemid());
            viewDto.setOutId(outId);
            viewDto.setResultstr(output.getResultstr());
            viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime));
            viewDto.setPreDataN(mmItemResultService.getData(output.getId(), startTime, endTime));
            viewDto.setPreDataL(mmItemResultLastPointService.getData(output.getId(), startTime, endTime));
@@ -211,6 +221,13 @@
            calendar.add(Calendar.HOUR_OF_DAY, 1);
            endTime = calendar.getTime();
        }
        if (endTime.getTime() <= startTime.getTime()) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(startTime);
            calendar.add(Calendar.HOUR_OF_DAY, 1);
            endTime = calendar.getTime();
        }
        List<String> categories = DateUtils.getTimeScale(startTime, endTime, predictItem.getGranularity());
        List<String> legend = new ArrayList<>();
        LinkedHashMap<String, PreDataSampleViewRespDTO> viewMap = new LinkedHashMap<>();
@@ -254,8 +271,8 @@
        }
        valueDTOS.forEach(item -> {
            Object[] values = new Object[2];
            values[0] = DateUtils.format(item.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
            values[1] = item.getDataValue();
            values[0] = DateUtils.format(item.getT(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
            values[1] = new BigDecimal(item.getV()).setScale(2, BigDecimal.ROUND_HALF_UP);
            result.add(values);
        });
        return result;
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,12 +34,27 @@
    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
            request, @RequestBody PreDataBarLineReqVO reqVO) throws Exception {
        apiSecurityUtils.validate(request);
        PreDataBarLineRespVO respVO = mcsApi.getPreDataCharts(reqVO);
        PreDataBarLineRespVO respVO = new PreDataBarLineRespVO();
        try {
            respVO = mcsApi.getPreDataCharts(reqVO);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CommonResult.success(respVO);
    }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java
@@ -52,7 +52,7 @@
    }
    @GetMapping("/list")
    public CommonResult<List<MmPredictItemRespVO>> list(Map<String, Object> params) {
    public CommonResult<List<MmPredictItemRespVO>> list(@RequestParam Map<String, Object> params) {
        List<MmPredictItemRespVO> list = mmPredictItemService.list(params);
        return success(list);
    }
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) {
@@ -156,7 +130,7 @@
        list.forEach(item -> {
            Object[] dataItem = new Object[2];
            dataItem[0] = DateUtils.format(item.getDatatime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
            dataItem[1] = item.getDatavalue();
            dataItem[1] = item.getDatavalue().setScale(2, BigDecimal.ROUND_HALF_UP);
            result.add(dataItem);
        });
        return result;
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/MmModelArithSettingsServiceImpl.java
@@ -1,10 +1,7 @@
package com.iailab.module.model.mcs.pre.service.impl;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.module.model.mcs.pre.dao.MmItemTypeDao;
import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao;
import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity;
import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService;
@@ -13,6 +10,7 @@
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @author PanZhibao
@@ -25,6 +23,8 @@
    @Autowired
    private MmModelArithSettingsDao mmModelArithSettingsDao;
    private static Map<String, List<MmModelArithSettingsEntity>> modelIdMap = new ConcurrentHashMap<>();
    @Override
    public void saveList(List<MmModelArithSettingsEntity> list) {
        QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper();
@@ -34,23 +34,23 @@
            item.setId(UUID.randomUUID().toString());
        });
        mmModelArithSettingsDao.insertList(list);
    }
    public List<MmModelArithSettingsEntity> getByModelid(String modelid) {
        Map<String, Object> params = new HashMap<>(1);
        params.put("modelid", modelid);
        List<MmModelArithSettingsEntity> list = mmModelArithSettingsDao.getMmModelArithSettings(params);
        if (CollectionUtils.isEmpty(list)) {
            return new ArrayList<>();
        }
        return list;
        // 清空缓存
        modelIdMap.clear();
    }
    @Override
    public List<MmModelArithSettingsEntity> getByModelId(String modelId) {
        Map<String, Object> params = new HashMap<>();
        if (modelIdMap.containsKey(modelId)) {
            return modelIdMap.get(modelId);
        }
        Map<String, Object> params = new HashMap<>(1);
        params.put("modelid", modelId);
        return mmModelArithSettingsDao.getMmModelArithSettings(params);
        List<MmModelArithSettingsEntity> list =  mmModelArithSettingsDao.getMmModelArithSettings(params);
        if (CollectionUtils.isEmpty(list)) {
            list = new ArrayList<>();
        }
        modelIdMap.put(modelId, list);
        return list;
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -188,7 +188,7 @@
        if (itemType != null && ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) {
            MmPredictModelEntity mmPredictModel = mmPredictModelService.getByItemid(id);
            mmPredictItemDto.setMmPredictModel(mmPredictModel);
            mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelid(mmPredictModel.getId()));
            mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelId(mmPredictModel.getId()));
            mmPredictItemDto.setMmModelParamList(mmModelParamService.getByModelid(mmPredictModel.getId()));
            mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity());
        } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) {
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;
@@ -20,6 +21,7 @@
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 预测样本数据构造
@@ -36,7 +38,10 @@
    private MmItemResultService mmItemResultService;
    @Autowired
    private ItemEntityFactory itemEntityFactory;
    private MmItemTypeService mmItemTypeService;
    @Autowired
    private MmItemOutputService mmItemOutputService;
    /**
     * alter by zfc 2020.11.24 修改数据样本构造方案:sampleInfo中数据已按爪子进行分类,但爪内数据为无序的,
@@ -49,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>() {
@@ -67,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) {
@@ -121,26 +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 = ConvertUtils.sourceToTarget(pointValueList, DataValueVO.class);
                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>