已修改20个文件
267 ■■■■■ 文件已修改
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/point/DataPointApi.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/point/dto/ApiPointDTO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleReqDTO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/enums/ItemRunStatusEnum.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictItemHandler.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictModelHandler.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictModuleHandler.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java 95 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/PredictResultVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/point/DataPointApi.java
@@ -30,6 +30,10 @@
    @Operation(summary = "根据测点ID查询测点信息")
    ApiPointDTO getInfoById(@PathVariable("pointId") String pointId);
    @PostMapping(PREFIX + "/info/ids")
    @Operation(summary = "根据多个测点ID查询测点信息")
    List<ApiPointDTO> getInfoByIds(@RequestParam("pointNos") List<String> pointIds);
    @PostMapping(PREFIX + "/query-points/real-value")
    @Operation(summary = "查询多个测点当前值")
    Map<String, Object> queryPointsRealValue(@RequestParam("pointNos") List<String> pointNos);
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/point/dto/ApiPointDTO.java
@@ -15,6 +15,9 @@
public class ApiPointDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    @Schema(description = "id", required = true)
    private String id;
    @Schema(description = "测点编码", required = true)
    private String pointNo;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java
@@ -38,7 +38,16 @@
    @Override
    public ApiPointDTO getInfoById(String pointId) {
        return ConvertUtils.sourceToTarget(daPointService.getSimpleInfoById(pointId), ApiPointDTO.class);
        return daPointService.getSimpleInfoById(pointId);
    }
    @Override
    public List<ApiPointDTO> getInfoByIds(List<String> pointIds) {
        List<ApiPointDTO> result = new ArrayList<>(pointIds.size());
        for (String pointId : pointIds) {
            result.add(daPointService.getSimpleInfoById(pointId));
        }
        return result;
    }
    @Override
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java
@@ -1,6 +1,7 @@
package com.iailab.module.data.point.service;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.data.api.point.dto.ApiPointDTO;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.vo.*;
@@ -17,7 +18,7 @@
    DaPointDTO info(String id);
    DaPointDTO getSimpleInfoById(String id);
    ApiPointDTO getSimpleInfoById(String id);
    DaPointDTO getSimpleInfoByNo(String no);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -9,6 +9,7 @@
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.api.point.dto.ApiPointDTO;
import com.iailab.module.data.channel.common.service.ChannelSourceService;
import com.iailab.module.data.common.enums.CommonConstant;
import com.iailab.module.data.common.enums.IsEnableEnum;
@@ -67,7 +68,7 @@
    @Resource
    private DaPointCollectStatusService daPointCollectStatusService;
    private static Map<String, DaPointDTO> pointIdMap = new ConcurrentHashMap<>();
    private static Map<String, ApiPointDTO> pointIdMap = new ConcurrentHashMap<>();
    private static Map<String, DaPointDTO> pointNoMap = new ConcurrentHashMap<>();
@@ -112,16 +113,16 @@
    }
    @Override
    public DaPointDTO getSimpleInfoById(String id) {
    public ApiPointDTO getSimpleInfoById(String id) {
        if (pointIdMap.containsKey(id)) {
            return pointIdMap.get(id);
        }
        DaPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class);
        ApiPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), ApiPointDTO.class);
        if (dto == null) {
            return null;
        }
        pointIdMap.put(id, dto);
        return pointIdMap.get(id);
        return dto;
    }
    @Override
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleReqDTO.java
@@ -1,5 +1,6 @@
package com.iailab.module.model.api.mdk.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -22,5 +23,6 @@
    @Schema(description = "调度方案时间")
    @NotNull(message="调度方案时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date scheduleTime;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
@@ -235,7 +235,7 @@
    @Override
    public PreDataItemChartRespVO getPreDataItemChart(PreDataItemChartReqVO reqVO) {
        PreDataItemChartRespVO result = new PreDataItemChartRespVO();
        ItemVO predictItem = mmPredictItemService.getItemByIdFromCache(reqVO.getItemId());
        ItemVO predictItem = mmPredictItemService.getItemById(reqVO.getItemId());
        if (predictItem == null) {
            return result;
        }
@@ -274,7 +274,9 @@
        for (MmItemOutputEntity out : outs) {
            legend.add(out.getResultName());
            PreDataSampleViewRespDTO viewDto = new PreDataSampleViewRespDTO();
            viewDto.setRealData(getHisData(out.getPointid(), startTime, endTime));
            if (StringUtils.isNotBlank(out.getPointid())) {
                viewDto.setRealData(getHisData(out.getPointid(), startTime, endTime));
            }
            viewDto.setPreDataN(mmItemResultService.getData(out.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
            viewMap.put(out.getResultName(), viewDto);
        }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java
@@ -97,7 +97,16 @@
                    intervalTime = (int) (reqDTO.getPredictTime().getTime() - module.getPredicttime().getTime()) / (1000 * 60);
                }
                List<ItemVO> predictItemList = mmPredictItemService.getByModuleId(module.getId());
                Map<String, PredictResultVO> predictResultMap = predictModuleHandler.predict(predictItemList, reqDTO.getPredictTime(), intervalTime);
                Map<String, PredictResultVO> predictResultMap = new HashMap<>(predictItemList.size());
                // 分组,先运行normal预测项,再将结果传递给merge预测项
                List<ItemVO> normalItems = predictItemList.stream().filter(e -> e.getItemType().equals("NormalItem")).collect(Collectors.toList());
                if (!CollectionUtils.isEmpty(normalItems)) {
                    predictModuleHandler.predict(normalItems, reqDTO.getPredictTime(), intervalTime,predictResultMap);
                    List<ItemVO> mergeItem = predictItemList.stream().filter(e -> e.getItemType().equals("MergeItem")).collect(Collectors.toList());
                    if (!CollectionUtils.isEmpty(mergeItem)) {
                        predictModuleHandler.predict(mergeItem, reqDTO.getPredictTime(), intervalTime,predictResultMap);
                    }
                }
                // 更新Module时间
                dmModuleService.updatePredictTime(module.getId(), reqDTO.getPredictTime());
                if (reqDTO.getIsResult() == null || !reqDTO.getIsResult()) {
@@ -147,7 +156,7 @@
            Map<String, List<MdkPredictDataDTO>> predictData = new HashMap<>();
            ItemVO predictItem = itemEntityFactory.getItemByItemNo(reqDTO.getItemNo());
            PredictItemHandler predictItemHandler = predictItemFactory.create(predictItem.getId());
            PredictResultVO predictResult = predictItemHandler.predict(reqDTO.getPredictTime(), predictItem);
            PredictResultVO predictResult = predictItemHandler.predict(reqDTO.getPredictTime(), predictItem,null,null);
            Map<String, List<DataValueVO>> resultMap = predictResultHandler.convertToPredictData(predictResult);
            if (!CollectionUtils.isEmpty(resultMap)) {
                for (Map.Entry<String, List<DataValueVO>> entry : resultMap.entrySet()) {
@@ -198,7 +207,7 @@
            log.info("预测计算结束: " + System.currentTimeMillis());
        } catch (Exception ex) {
            log.info("调度计算异常: " + System.currentTimeMillis());
            ex.printStackTrace();
//            ex.printStackTrace();
            return resp;
        }
        return resp;
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/enums/ItemRunStatusEnum.java
@@ -13,7 +13,8 @@
public enum ItemRunStatusEnum {
    PROCESSING(1, "处理中"),
    SUCCESS(2, "成功"),
    FAIL(3, "失败");
    FAIL(3, "失败"),
    MODELRESULTERROR(4, "模型结果异常");
    private Integer code;
    private String desc;
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictItemHandler.java
@@ -1,10 +1,12 @@
package com.iailab.module.model.mdk.predict;
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum;
import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException;
import com.iailab.module.model.mdk.vo.ItemVO;
import com.iailab.module.model.mdk.vo.PredictResultVO;
import java.util.Date;
import java.util.Map;
/**
 * @author PanZhibao
@@ -21,5 +23,5 @@
     * @return
     * @throws ItemInvokeException
     */
    PredictResultVO predict(Date predictTime, ItemVO predictItemDto) throws ItemInvokeException;
    PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap, ItemRunStatusEnum itemRunStatusEnum) throws ItemInvokeException;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictModelHandler.java
@@ -1,6 +1,7 @@
package com.iailab.module.model.mdk.predict;
import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity;
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum;
import com.iailab.module.model.mdk.common.exceptions.ModelInvokeException;
import com.iailab.module.model.mdk.vo.PredictResultVO;
@@ -21,5 +22,5 @@
     * @return
     * @throws ModelInvokeException
     */
    PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName) throws ModelInvokeException;
    PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName, ItemRunStatusEnum itemRunStatusEnum) throws ModelInvokeException;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictModuleHandler.java
@@ -1,5 +1,6 @@
package com.iailab.module.model.mdk.predict;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum;
import com.iailab.module.model.mcs.pre.enums.ItemStatus;
import com.iailab.module.model.mcs.pre.service.MmItemStatusService;
@@ -9,6 +10,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.text.MessageFormat;
import java.time.Duration;
@@ -46,26 +48,32 @@
     * @param intervalTime
     * @return
     */
    public Map<String, PredictResultVO> predict(List<ItemVO> predictItemList, Date predictTime, int intervalTime) {
        Map<String, PredictResultVO> result = new HashMap<>();
        PredictResultVO predictResult = new PredictResultVO();
    public void predict(List<ItemVO> predictItemList, Date predictTime, int intervalTime,Map<String, PredictResultVO> predictResultMap) {
        PredictResultVO predictResult;
        Map<String, double[]> predictValueMap = null;
        if (!CollectionUtils.isEmpty(predictResultMap)) {
            // 将predictResultMap处理成Map<outPutId, double[]>
            predictValueMap = new HashMap<>();
            for (Map.Entry<String, PredictResultVO> entry : predictResultMap.entrySet()) {
                for (Map.Entry<MmItemOutputEntity, double[]> mmItemOutputEntityEntry : entry.getValue().getPredictMatrixs().entrySet()) {
                    predictValueMap.put(mmItemOutputEntityEntry.getKey().getId(),mmItemOutputEntityEntry.getValue());
                }
            }
        }
        for (ItemVO predictItem : predictItemList) {
            if (!predictItem.getStatus().equals(ItemStatus.STATUS1.getCode())) {
                continue;
            }
            Long totalDur = 0L;
            ItemRunStatusEnum itemRunStatusEnum = ItemRunStatusEnum.PROCESSING;
            try {
                mmItemStatusService.recordStatus(predictItem.getId(), ItemRunStatusEnum.PROCESSING, totalDur, predictTime);
                mmItemStatusService.recordStatus(predictItem.getId(), itemRunStatusEnum, totalDur, predictTime);
                PredictItemHandler predictItemHandler = predictItemFactory.create(predictItem.getId());
                long start = System.currentTimeMillis();
                try {
                    // 预测项开始预测
                    predictResult = predictItemHandler.predict(predictTime, predictItem);
                    predictResult = predictItemHandler.predict(predictTime, predictItem, predictValueMap,itemRunStatusEnum);
                } catch (Exception e) {
                    e.printStackTrace();
                    log.error(String.valueOf(e));
                    mmItemStatusService.recordStatus(predictItem.getId(), ItemRunStatusEnum.FAIL, totalDur, predictTime);
                    continue;
                }
                long end = System.currentTimeMillis();
@@ -85,15 +93,15 @@
                log.info(MessageFormat.format("预测项:{0},保存时间:{1}ms", predictItem.getItemName(),
                        drtSave));
                totalDur = totalDur + drtSave;
                mmItemStatusService.recordStatus(predictItem.getId(), ItemRunStatusEnum.SUCCESS, totalDur, predictTime);
                result.put(predictItem.getItemNo(), predictResult);
                predictResultMap.put(predictItem.getItemNo(), predictResult);
            } catch (Exception e) {
                e.printStackTrace();
                log.error(MessageFormat.format("预测项编号:{0},预测项名称:{1},预测失败:{2} 预测时刻:{3}",
                        predictItem.getId(), predictItem.getItemName(), e.getMessage(), predictTime));
                mmItemStatusService.recordStatus(predictItem.getId(), ItemRunStatusEnum.FAIL, totalDur, predictTime);
                itemRunStatusEnum = ItemRunStatusEnum.FAIL;
            } finally {
                mmItemStatusService.recordStatus(predictItem.getId(), itemRunStatusEnum, totalDur, predictTime);
            }
        }
        return result;
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java
@@ -4,6 +4,7 @@
import com.iailab.module.data.api.point.dto.ApiPointDTO;
import com.iailab.module.data.enums.DataPointFreqEnum;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum;
import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
import com.iailab.module.model.mcs.pre.service.MmItemResultService;
import com.iailab.module.model.mdk.common.enums.ItemPredictStatus;
@@ -21,6 +22,7 @@
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @author PanZhibao
@@ -58,7 +60,7 @@
     * @throws ItemInvokeException
     */
    @Override
    public PredictResultVO predict(Date predictTime, ItemVO predictItemDto)
    public PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap, ItemRunStatusEnum itemRunStatusEnum)
            throws ItemInvokeException {
        PredictResultVO predictResult = new PredictResultVO();
        ItemPredictStatus itemStatus = ItemPredictStatus.PREDICTING;
@@ -67,7 +69,6 @@
            String expression = itemEntityFactory.getMergeItem(itemId).getExpression();
            int predictLength = itemEntityFactory.getItemById(itemId).getPredictLength();
            double[][] predictResultMat = new double[predictLength][1];
            Map<String, List<DataValueVO>> predictValueMap = new HashMap<>();
            String[] mathOutPutId = expression.split("[\\+ \\-]");
            ArrayList<Character> operator = new ArrayList<>();
            for (int i = 0; i < expression.length(); i++) {
@@ -75,63 +76,65 @@
                    operator.add(expression.charAt(i));
                }
            }
            String[] compositionItem = expression.split(String.valueOf("&".toCharArray()));
//            String[] compositionItem = expression.split(String.valueOf("&".toCharArray()));
            //是否为计算预测项
            if (mathOutPutId.length > 1) {
                for (String outPutId : mathOutPutId) {
                    if (outPutId.length() > 4) {
                        Date endTime = predictTime;
//                        ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo);
//                        List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
                        MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(outPutId);
                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPut.getPointid());
//                Map<String, List<DataValueVO>> predictValueMap = new HashMap<>();
//                for (String outPutId : mathOutPutId) {
//                    if (outPutId.length() > 4) {
//                        Date endTime = predictTime;
////                        ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo);
////                        List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
//                        MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(outPutId);
//                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPut.getPointid());
//
//                        Calendar calendar = Calendar.getInstance();
//                        calendar.setTime(endTime);
//                        calendar.add(Calendar.SECOND, (predictLength - 1) * DataPointFreqEnum.getEumByCode(pointEntity.getMinfreqid()).getValue());
//                        endTime = new Timestamp(calendar.getTime().getTime());
////                        List<DataValueVO> predictValueList = predictResultHandler.getPredictValueByItemNo(itemNo, predictTime, endTime);
//                        List<DataValueVO> predictValueList = mmItemResultService.getPredictValue(outPutId, predictTime, endTime);
//                        if (predictValueList.size() != predictLength) {
//                            log.debug("merge项融合失败:缺少子项预测数据,对应子项outPutId=" + outPutId);
//                            return null;
//                        }
//                        predictValueMap.put(outPutId, predictValueList);
//                    }
//                }
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(endTime);
                        calendar.add(Calendar.SECOND, (predictLength - 1) * DataPointFreqEnum.getEumByCode(pointEntity.getMinfreqid()).getValue());
                        endTime = new Timestamp(calendar.getTime().getTime());
//                        List<DataValueVO> predictValueList = predictResultHandler.getPredictValueByItemNo(itemNo, predictTime, endTime);
                        List<DataValueVO> predictValueList = mmItemResultService.getPredictValue(outPutId, predictTime, endTime);
                        if (predictValueList.size() != predictLength) {
                            log.debug("merge项融合失败:缺少子项预测数据,对应子项outPutId=" + outPutId);
                            return null;
                        }
                        predictValueMap.put(outPutId, predictValueList);
                    }
                }
                for (Integer i = 0; i < predictLength; i++) {
                    double sum =0.0;
                    sum = predictValueMap.get(mathOutPutId[0]).get(i).getDataValue();
                    sum = predictValueMap.get(mathOutPutId[0])[i];
                    for (int j = 1; j < mathOutPutId.length; j++) {
                        if (operator.get(j-1)=='+')
                        {sum += predictValueMap.get(mathOutPutId[j]).get(i).getDataValue();}
                        {sum += predictValueMap.get(mathOutPutId[j])[i];}
                        if (operator.get(j-1)=='-')
                        {sum -= predictValueMap.get(mathOutPutId[j]).get(i).getDataValue();}
                        {sum -= predictValueMap.get(mathOutPutId[j])[i];}
                    }
                    predictResultMat[i][0] = sum;
                }
            }
            //是否为组合预测项
            if (compositionItem.length > 1) {
                Map<String, PredictResultVO> predictResultMap = new HashMap<>();
                Integer columnTotalNumber = 0;
                Integer rowNumber = 0;
                for (String itemNo : compositionItem) {
                    PredictItemHandler predictItem = (PredictItemHandler) predictItemFactory.create(itemEntityFactory.
                            getItemByItemNo(itemNo).getId());
                    predictResult = predictItem.predict(predictTime, predictItemDto);
                    columnTotalNumber += Integer.valueOf(predictResult.getPredictMatrix().length);
                    predictResultMap.put(itemNo, predictItem.predict(predictTime, predictItemDto));
                }
                double[][] matrix = new double[columnTotalNumber][1];
                for (String itemNo : compositionItem) {
                    for (Integer i = 0; i < predictResultMap.get(itemNo).getPredictMatrix().length; i++) {
                        matrix[rowNumber][0] = predictResultMap.get(itemNo).getPredictMatrix()[i][0];
                        rowNumber++;
                    }
                }
                predictResult.setPredictMatrix(matrix);
            }
//            if (compositionItem.length > 1) {
//                Map<String, PredictResultVO> predictResultMap = new HashMap<>();
//                Integer columnTotalNumber = 0;
//                Integer rowNumber = 0;
//                for (String itemNo : compositionItem) {
//                    PredictItemHandler predictItem = (PredictItemHandler) predictItemFactory.create(itemEntityFactory.
//                            getItemByItemNo(itemNo).getId());
//                    predictResult = predictItem.predict(predictTime, predictItemDto);
//                    columnTotalNumber += Integer.valueOf(predictResult.getPredictMatrix().length);
//                    predictResultMap.put(itemNo, predictItem.predict(predictTime, predictItemDto));
//                }
//                double[][] matrix = new double[columnTotalNumber][1];
//                for (String itemNo : compositionItem) {
//                    for (Integer i = 0; i < predictResultMap.get(itemNo).getPredictMatrix().length; i++) {
//                        matrix[rowNumber][0] = predictResultMap.get(itemNo).getPredictMatrix()[i][0];
//                        rowNumber++;
//                    }
//                }
//                predictResult.setPredictMatrix(matrix);
//            }
            predictResult.setPredictId(itemId);
            predictResult.setPredictMatrix(predictResultMat);
            predictResult.setPredictTime(predictTime);
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java
@@ -1,6 +1,7 @@
package com.iailab.module.model.mdk.predict.impl;
import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity;
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum;
import com.iailab.module.model.mcs.pre.service.MmPredictModelService;
import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException;
import com.iailab.module.model.mdk.common.exceptions.ModelInvokeException;
@@ -13,6 +14,7 @@
import java.text.MessageFormat;
import java.util.Date;
import java.util.Map;
/**
 * @author PanZhibao
@@ -37,7 +39,7 @@
     * @throws ItemInvokeException
     */
    @Override
    public PredictResultVO predict(Date predictTime, ItemVO predictItemDto) throws ItemInvokeException {
    public PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap, ItemRunStatusEnum itemRunStatusEnum) throws ItemInvokeException {
        PredictResultVO predictResult = new PredictResultVO();
        String itemId = predictItemDto.getId();
        try {
@@ -46,7 +48,7 @@
                throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}",
                        ModelInvokeException.errorGetModelEntity, itemId));
            }
            predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName());
            predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName(),itemRunStatusEnum);
            predictResult.setPredictId(itemId);
        } catch (Exception ex) {
            throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}",
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java
@@ -9,6 +9,7 @@
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity;
import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity;
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum;
import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService;
import com.iailab.module.model.mdk.common.enums.TypeA;
@@ -55,7 +56,7 @@
     * @throws ModelInvokeException
     */
    @Override
    public synchronized PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName) throws ModelInvokeException {
    public synchronized PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName, ItemRunStatusEnum itemRunStatusEnum) throws ModelInvokeException {
        PredictResultVO result = new PredictResultVO();
        if (predictModel == null) {
            throw new ModelInvokeException("modelEntity is null");
@@ -99,6 +100,7 @@
            HashMap<String, Object> modelResult = DllUtils.run(newModelBean, param2Values, predictModel.getMpkprojectid());
            if (!modelResult.containsKey(CommonConstant.MDK_STATUS_CODE) || !modelResult.containsKey(CommonConstant.MDK_RESULT) ||
                    !modelResult.get(CommonConstant.MDK_STATUS_CODE).toString().equals(CommonConstant.MDK_STATUS_100)) {
                itemRunStatusEnum = ItemRunStatusEnum.MODELRESULTERROR;
                throw new RuntimeException("模型结果异常:" + modelResult);
            }
            modelResult = (HashMap<String, Object>) modelResult.get(CommonConstant.MDK_RESULT);
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
@@ -1,9 +1,12 @@
package com.iailab.module.model.mdk.sample;
import com.iailab.module.data.api.point.DataPointApi;
import com.iailab.module.data.api.point.dto.ApiPointDTO;
import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity;
import com.iailab.module.model.mcs.pre.service.MmModelParamService;
import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
import com.iailab.module.model.mcs.pre.service.MmPredictModelService;
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 org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +16,9 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
 * @author PanZhibao
@@ -30,6 +36,9 @@
    @Autowired
    private MmPredictItemService mmPredictItemService;
    @Autowired
    private DataPointApi dataPointApi;
    /**
     * 返回样本矩阵的列数
@@ -63,14 +72,19 @@
        int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder();
        //设置当前查询数据长度,初始值为最小端口数据长度
        int curDataLength = modelInputParamEntityList.get(0).getDatalength();
        // 统一获取测点的信息
        List<String> pointIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.DATAPOINT)).map(MmModelParamEntity::getModelparamid).collect(Collectors.toList());
        List<ApiPointDTO> points = dataPointApi.getInfoByIds(pointIds);
        Map<String, ApiPointDTO> pointMap = points.stream().collect(Collectors.toMap(ApiPointDTO::getId, Function.identity()));
        for (MmModelParamEntity entry : modelInputParamEntityList) {
            columnInfo.setParamType(entry.getModelparamtype());
            columnInfo.setParamId(entry.getModelparamid());
            columnInfo.setDataLength(entry.getDatalength());
            columnInfo.setModelParamOrder(entry.getModelparamorder());
            columnInfo.setModelParamPortOrder(entry.getModelparamportorder());
            columnInfo.setStartTime(getStartTime(columnInfo, predictTime));
            columnInfo.setEndTime(getEndTime(columnInfo, predictTime));
            columnInfo.setStartTime(getStartTime(columnInfo, predictTime,pointMap));
            columnInfo.setEndTime(getEndTime(columnInfo, predictTime,pointMap));
            columnInfo.setGranularity(super.getGranularity(columnInfo));
            //对每一个爪进行数据项归并
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
@@ -19,6 +19,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author PanZhibao
@@ -91,13 +92,13 @@
     * @return
     * @throws Exception
     */
    protected Date getStartTime(ColumnItem columnItem, Date originalTime) {
    protected Date getStartTime(ColumnItem columnItem, Date originalTime, Map<String, ApiPointDTO> pointMap) {
        Date dateTime = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(originalTime);
        switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
            case DATAPOINT:
                ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId());
                ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId());
                if (dataPoint == null) {
                    return null;
                }
@@ -127,13 +128,13 @@
     * @return
     * @throws Exception
     */
    protected Date getEndTime(ColumnItem columnItem, Date originalTime) {
    protected Date getEndTime(ColumnItem columnItem, Date originalTime,Map<String, ApiPointDTO> pointMap) {
        Date dateTime = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(originalTime);
        switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
            case DATAPOINT:
                ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId());
                ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId());
                if (dataPoint == null) {
                    return null;
                }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java
@@ -1,7 +1,11 @@
package com.iailab.module.model.mdk.sample;
import com.iailab.module.data.api.point.DataPointApi;
import com.iailab.module.data.api.point.dto.ApiPointDTO;
import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity;
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
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 org.springframework.beans.factory.annotation.Autowired;
@@ -11,12 +15,18 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Component
public class ScheduleSampleInfoConstructor extends SampleInfoConstructor {
    @Autowired
    private StScheduleModelParamService stScheduleModelParamService;
    @Autowired
    private DataPointApi dataPointApi;
    @Override
    protected Integer getSampleColumn(String modelId) {
@@ -37,14 +47,19 @@
        int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder();
        //设置当前查询数据长度,初始值为最小端口数据长度
        int curDataLength = modelInputParamEntityList.get(0).getDatalength();
        // 统一获取测点的信息
        List<String> pointIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.DATAPOINT)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toList());
        List<ApiPointDTO> points = dataPointApi.getInfoByIds(pointIds);
        Map<String, ApiPointDTO> pointMap = points.stream().collect(Collectors.toMap(ApiPointDTO::getId, Function.identity()));
        for (StScheduleModelParamEntity entry : modelInputParamEntityList) {
            columnInfo.setParamType(entry.getModelparamtype());
            columnInfo.setParamId(entry.getModelparamid());
            columnInfo.setDataLength(entry.getDatalength());
            columnInfo.setModelParamOrder(entry.getModelparamorder());
            columnInfo.setModelParamPortOrder(entry.getModelparamportorder());
            columnInfo.setStartTime(getStartTime(columnInfo, predictTime));
            columnInfo.setEndTime(getEndTime(columnInfo, predictTime));
            columnInfo.setStartTime(getStartTime(columnInfo, predictTime,pointMap));
            columnInfo.setEndTime(getEndTime(columnInfo, predictTime,pointMap));
            columnInfo.setGranularity(super.getGranularity(columnInfo));
            //对每一个爪进行数据项归并
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java
@@ -1,5 +1,6 @@
package com.iailab.module.model.mdk.schedule.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iail.model.IAILModel;
@@ -61,7 +62,9 @@
        String modelId = scheduleModel.getId();
        try {
            //1.根据模型id构造模型输入样本
            long now = System.currentTimeMillis();
            List<SampleData> sampleDataList = sampleConstructor.constructSample(TypeA.Schedule.name(), modelId, scheduleTime);
            log.info("构造模型输入样本消耗时长:" + (System.currentTimeMillis() - now) / 1000 + "秒");
            if (CollectionUtils.isEmpty(sampleDataList)) {
                log.info("调度模型构造样本失败,schemeCode=" + schemeCode);
                return null;
@@ -86,12 +89,12 @@
            param2Values[portLength] = settings;
            log.info("#######################调度模型 " + scheduleModel.getModelName() + " ##########################");
            JSONObject jsonObjNewModelBean = new JSONObject();
            jsonObjNewModelBean.put("newModelBean", newModelBean);
            log.info(String.valueOf(jsonObjNewModelBean));
            JSONObject jsonObjParam2Values = new JSONObject();
            jsonObjParam2Values.put("param2Values", param2Values);
            log.info(String.valueOf(jsonObjParam2Values));
//            JSONObject jsonObjNewModelBean = new JSONObject();
//            jsonObjNewModelBean.put("newModelBean", newModelBean);
//            log.info(String.valueOf(jsonObjNewModelBean));
//            JSONObject jsonObjParam2Values = new JSONObject();
//            jsonObjParam2Values.put("param2Values", param2Values);
            log.info("参数: " + JSON.toJSONString(param2Values));
            //IAILMDK.run
            HashMap<String, Object> modelResult = DllUtils.run(newModelBean, param2Values, scheduleScheme.getMpkprojectid());
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/PredictResultVO.java
@@ -36,6 +36,10 @@
     * 统一预测入口的预测类型(循环调用、手动调用) Map<MmItemOutputEntity,double[]>
     */
    private Map<MmItemOutputEntity, double[]> predictMatrixs;
    /**
     * double类型的模型输出
     */
    private Map<MmItemOutputEntity, Double> predictDoubleValues;
    /**