已添加1个文件
已修改23个文件
256 ■■■■ 文件已修改
iailab-module-data/iailab-module-data-biz/src/main/resources/application.yaml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/db/mysql.sql 5 ●●●● 补丁 | 查看 | 原始文档 | 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 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/OutResultType.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/controller/admin/StScheduleRecordController.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/controller/admin/StScheduleSchemeController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleRecordDao.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleRecordEntity.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleRecordService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleRecordServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleRecordPageReqVO.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleRecordRespVO.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/ScheduleResultVO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/logback-spring.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/application.yaml
@@ -61,7 +61,7 @@
logging:
  file:
    name: @log.path@/iailab-data/log/${spring.application.name}.log # 日志文件名,全路径
    name: @log.path@/log/${spring.application.name}.log # 日志文件名,全路径
  level:
    org:
      springframework:
iailab-module-model/iailab-module-model-biz/db/mysql.sql
@@ -878,4 +878,7 @@
alter table t_mm_item_output add column `result_name` varchar(50) DEFAULT NULL;
alter table t_st_schedule_scheme add column `mpkprojectid` varchar(36) DEFAULT NULL;
alter table t_st_schedule_scheme add column `mpkprojectid` varchar(36) DEFAULT NULL;
alter table t_st_schedule_record add column `result_code` varchar(10) DEFAULT NULL;
alter table t_st_schedule_record add column `result_data` varchar(1000) DEFAULT NULL;
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
@@ -336,7 +336,11 @@
        dataView.setRangeL(rangeL);
        dataView.setLimitH(limitH);
        dataView.setLimitL(limitL);
        dataView.setRealData(getHisData(outPut.getPointid(), startTime, endTime, timeFormat));
        if (StringUtils.isNotBlank(outPut.getPointid())) {
            dataView.setRealData(getHisData(outPut.getPointid(), startTime, endTime, timeFormat));
        } else {
            dataView.setRealData(new ArrayList<>());
        }
        dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat));
        switch (lineType) {
            case TN:
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java
@@ -1,15 +1,15 @@
package com.iailab.module.model.api;
import com.alibaba.fastjson.JSON;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.model.api.mdk.MdkApi;
import com.iailab.module.model.api.mdk.dto.*;
import com.iailab.module.model.mcs.pre.entity.DmModuleEntity;
import com.iailab.module.model.mcs.pre.service.DmModuleService;
import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
import com.iailab.module.model.mcs.sche.service.StScheduleRecordService;
import com.iailab.module.model.mcs.sche.service.StScheduleSchemeService;
import com.iailab.module.model.mdk.factory.ItemEntityFactory;
import com.iailab.module.model.mdk.factory.PredictItemFactory;
import com.iailab.module.model.mdk.predict.PredictItemHandler;
import com.iailab.module.model.mdk.predict.PredictModuleHandler;
import com.iailab.module.model.mdk.predict.PredictResultHandler;
import com.iailab.module.model.mdk.schedule.ScheduleModelHandler;
@@ -25,9 +25,6 @@
import java.util.*;
import java.util.stream.Collectors;
import static com.iailab.framework.common.pojo.CommonResult.error;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
 * @author PanZhibao
@@ -49,16 +46,16 @@
    private PredictModuleHandler predictModuleHandler;
    @Autowired
    private ItemEntityFactory itemEntityFactory;
    @Autowired
    private PredictItemFactory predictItemFactory;
    @Autowired
    private PredictResultHandler predictResultHandler;
    @Autowired
    private ScheduleModelHandler scheduleModelHandler;
    @Autowired
    private StScheduleRecordService stScheduleRecordService;
    @Autowired
    private StScheduleSchemeService stScheduleSchemeService;
    /**
     * 按模块预测
@@ -101,10 +98,10 @@
                // 分组,先运行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);
                    predictModuleHandler.predict(normalItems, reqDTO.getPredictTime(), intervalTime, predictResultMap);
                    List<ItemVO> mergeItems = predictItemList.stream().filter(e -> e.getItemType().equals("MergeItem")).collect(Collectors.toList());
                    if (!CollectionUtils.isEmpty(mergeItems)) {
                        predictModuleHandler.predict(mergeItems, reqDTO.getPredictTime(), intervalTime,predictResultMap);
                        predictModuleHandler.predict(mergeItems, reqDTO.getPredictTime(), intervalTime, predictResultMap);
                    }
                }
                // 更新Module时间
@@ -156,7 +153,7 @@
            List<ItemVO> predictItemList = new ArrayList<>();
            predictItemList.add(itemByItemNo);
            Map<String, PredictResultVO> predictResultMap = new HashMap<>(predictItemList.size());
            predictModuleHandler.predict(predictItemList, reqDTO.getPredictTime(), 0,predictResultMap);
            predictModuleHandler.predict(predictItemList, reqDTO.getPredictTime(), 0, predictResultMap);
            Map<String, List<MdkPredictDataDTO>> itemPredictData = new HashMap<>();
@@ -208,10 +205,12 @@
            log.info("调度计算开始: " + System.currentTimeMillis());
            ScheduleResultVO scheduleResult = scheduleModelHandler.doSchedule(reqDTO.getScheduleCode(), reqDTO.getScheduleTime());
            resp.setResult(scheduleResult.getResult());
            stScheduleRecordService.create(scheduleResult);
            stScheduleSchemeService.updateTime(scheduleResult.getSchemeId(), scheduleResult.getScheduleTime());
            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/common/enums/OutResultType.java
@@ -13,7 +13,7 @@
public enum OutResultType {
    D1(1, "一维数组"),
    D2(2, "二维数组"),
    D(3, "二维数组");
    D(3, "double");
    private Integer code;
    private String desc;
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java
@@ -14,4 +14,6 @@
public interface MmItemResultJsonService extends BaseService<MmItemResultJsonEntity> {
    List<Object[]> getData(String outputId, Date predictTime, String timeFormat);
    String getDoubleData(String outputId, Date predictTime);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
@@ -48,4 +48,13 @@
        });
        return result;
    }
    @Override
    public String getDoubleData(String outputId, Date predictTime) {
        QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("outputid", outputId)
                .eq("predicttime", predictTime);
        MmItemResultJsonEntity mmItemResultJsonEntity = baseDao.selectOne(wrapper);
        return null == mmItemResultJsonEntity ? null : mmItemResultJsonEntity.getCumulant();
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/controller/admin/StScheduleRecordController.java
对比新文件
@@ -0,0 +1,53 @@
package com.iailab.module.model.mcs.sche.controller.admin;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordRespVO;
import com.iailab.module.model.mcs.sche.service.StScheduleRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年12月25日
 */
@Tag(name = "模型服务 - 调度记录")
@RestController
@RequestMapping("/model/sche/record")
public class StScheduleRecordController {
    @Autowired
    private StScheduleRecordService stScheduleRecordService;
    @GetMapping("/get")
    @Operation(summary = "获得调度记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('sche:record:query')")
    public CommonResult<StScheduleRecordRespVO> getInfo(@RequestParam("id") String id) {
        StScheduleRecordRespVO respVO = stScheduleRecordService.getInfo(id);
        return success(respVO);
    }
    @GetMapping("/page")
    @Operation(summary = "获得调度记录分页")
    @PreAuthorize("@ss.hasPermission('sche:record:query')")
    public CommonResult<PageResult<StScheduleRecordRespVO>> getPage(@Valid StScheduleRecordPageReqVO pageVO) {
        PageResult<StScheduleRecordEntity> pageResult = stScheduleRecordService.page(pageVO);
        return success(BeanUtils.toBean(pageResult, StScheduleRecordRespVO.class));
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/controller/admin/StScheduleSchemeController.java
@@ -76,7 +76,7 @@
    @GetMapping("/page")
    @Operation(summary = "获得调度方案分页")
    @PreAuthorize("@ss.hasPermission('sche:scheme:query')")
    public CommonResult<PageResult<StScheduleSchemeRespVO>> getTenantPage(@Valid StScheduleSchemePageReqVO pageVO) {
    public CommonResult<PageResult<StScheduleSchemeRespVO>> getPage(@Valid StScheduleSchemePageReqVO pageVO) {
        PageResult<StScheduleSchemeEntity> pageResult = stScheduleSchemeService.page(pageVO);
        return success(BeanUtils.toBean(pageResult, StScheduleSchemeRespVO.class));
    }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleRecordDao.java
@@ -19,6 +19,7 @@
    default PageResult<StScheduleRecordEntity> selectPage(StScheduleRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StScheduleRecordEntity>()
                .eqIfPresent(StScheduleRecordEntity::getSchemeId, reqVO.getSchemeId())
                .likeIfPresent(StScheduleRecordEntity::getModelName, reqVO.getModelName())
                .geIfPresent(StScheduleRecordEntity::getScheduleTime, reqVO.getStartTime())
                .leIfPresent(StScheduleRecordEntity::getScheduleTime, reqVO.getEndTime())
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleRecordEntity.java
@@ -49,4 +49,14 @@
     */
    private Date createTime;
    /**
     * 结果code
     */
    private String resultCode;
    /**
     * 结果数据
     */
    private String resultData;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleRecordService.java
@@ -4,7 +4,7 @@
import com.iailab.framework.common.service.BaseService;
import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordSaveReqVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordRespVO;
import com.iailab.module.model.mdk.vo.ScheduleResultVO;
/**
@@ -16,5 +16,7 @@
    PageResult<StScheduleRecordEntity> page(StScheduleRecordPageReqVO reqVO);
    StScheduleRecordRespVO getInfo(String id);
    void create(ScheduleResultVO resultVO);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleRecordServiceImpl.java
@@ -1,18 +1,24 @@
package com.iailab.module.model.mcs.sche.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.model.mcs.sche.dao.StScheduleRecordDao;
import com.iailab.module.model.mcs.sche.entity.StScheduleRecordDetailEntity;
import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity;
import com.iailab.module.model.mcs.sche.service.StScheduleRecordDetailService;
import com.iailab.module.model.mcs.sche.service.StScheduleRecordService;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordDetailRespVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordRespVO;
import com.iailab.module.model.mdk.vo.ScheduleResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
@@ -33,6 +39,15 @@
    }
    @Override
    public StScheduleRecordRespVO getInfo(String id) {
        StScheduleRecordEntity entity = baseDao.selectById(id);
        StScheduleRecordRespVO respVO = ConvertUtils.sourceToTarget(entity, StScheduleRecordRespVO.class);
        List<StScheduleRecordDetailEntity> list = stScheduleRecordDetailService.getByRecordId(id);
        respVO.setDetailList(ConvertUtils.sourceToTarget(list, StScheduleRecordDetailRespVO.class));
        return respVO;
    }
    @Override
    @DSTransactional(rollbackFor = Exception.class)
    public void create(ScheduleResultVO resultVO) {
        StScheduleRecordEntity entity = new StScheduleRecordEntity();
@@ -41,6 +56,8 @@
        entity.setSchemeId(resultVO.getSchemeId());
        entity.setScheduleTime(resultVO.getScheduleTime());
        entity.setModelId(resultVO.getModelId());
        entity.setResultCode(resultVO.getResultCode());
        entity.setResultData(JSON.toJSONString(resultVO.getResult()));
        baseDao.insert(entity);
        stScheduleRecordDetailService.create(entity.getId(), resultVO);
    }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleRecordPageReqVO.java
@@ -1,12 +1,17 @@
package com.iailab.module.model.mcs.sche.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.iailab.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Date;
import static com.iailab.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
 * @author PanZhibao
@@ -26,8 +31,10 @@
    private String modelName;
    @Schema(description = "开始时间")
    private Date startTime;
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime startTime;
    @Schema(description = "结束时间")
    private Date endTime;
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime endTime;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleRecordRespVO.java
@@ -5,6 +5,7 @@
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
 * @author PanZhibao
@@ -33,4 +34,13 @@
    @Schema(description = "创建时间")
    private Date createTime;
    @Schema(description = "结果状态")
    private String resultCode;
    @Schema(description = "结果数据")
    private String resultData;
    @Schema(description = "详情")
    private List<StScheduleRecordDetailRespVO> detailList;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java
@@ -99,15 +99,14 @@
            //IAILMDK.run
            HashMap<String, Object> modelResult = DllUtils.run(newModelBean, param2Values, predictModel.getMpkprojectid());
            //打印结果
            log.info("预测模型计算完成:modelId=" + modelId + ",modelName=" + predictModel.getMethodname() + ",modelResult=" + JSON.toJSONString(modelResult));
            //判断模型结果
            if (!modelResult.containsKey(CommonConstant.MDK_STATUS_CODE) || !modelResult.containsKey(CommonConstant.MDK_RESULT) ||
                    !modelResult.get(CommonConstant.MDK_STATUS_CODE).toString().equals(CommonConstant.MDK_STATUS_100)) {
                throw new ModelResultErrorException("模型结果异常:" + modelResult);
            }
            modelResult = (HashMap<String, Object>) modelResult.get(CommonConstant.MDK_RESULT);
            //打印结果
            JSONObject jsonObjResult = new JSONObject();
            jsonObjResult.put("result", modelResult);
            log.info("预测模型计算完成:modelId=" + modelId + ",modelName=" + predictModel.getMethodname() + ",modelResult=" + String.valueOf(jsonObjResult));
            List<MmItemOutputEntity> itemOutputList = mmItemOutputService.getByItemid(predictModel.getItemid());
            Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>();
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
@@ -8,8 +8,10 @@
import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO;
import com.iailab.module.data.common.ApiDataQueryDTO;
import com.iailab.module.data.common.ApiDataValueDTO;
import com.iailab.module.model.common.enums.OutResultType;
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.MmItemResultJsonService;
import com.iailab.module.model.mcs.pre.service.MmItemResultService;
import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
import com.iailab.module.model.mdk.common.enums.ModelParamType;
@@ -19,6 +21,7 @@
import com.iailab.module.model.mdk.sample.dto.SampleInfo;
import com.iailab.module.model.mdk.vo.DataValueVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +48,9 @@
    @Autowired
    private MmItemResultService mmItemResultService;
    @Autowired
    private MmItemResultJsonService mmItemResultJsonService;
    @Autowired
    private MmItemTypeService mmItemTypeService;
@@ -142,7 +148,23 @@
            case NORMALITEM:
            case MERGEITEM:
                MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(columnItem.getParamId());
                List<DataValueVO> predictValue = mmItemResultService.getPredictValue(outPut.getId(), columnItem.getStartTime(), columnItem.getEndTime());
                OutResultType outResultType = OutResultType.getEumByCode(outPut.getResultType());
                List<DataValueVO> predictValue = new ArrayList<>();
                // double类型特殊处理
                if (outResultType.equals(OutResultType.D)) {
                    // columnItem.getStartTime()就是预测时间
                    String doubleData = mmItemResultJsonService.getDoubleData(outPut.getId(), columnItem.getStartTime());
                    if (StringUtils.isNotBlank(doubleData)) {
                        DataValueVO dataValueVO = new DataValueVO();
                        dataValueVO.setDataTime(columnItem.getStartTime());
                        dataValueVO.setDataValue(Double.valueOf(doubleData));
                        predictValue.add(dataValueVO);
                    }
                } else {
                    predictValue = mmItemResultService.getPredictValue(outPut.getId(), columnItem.getStartTime(), columnItem.getEndTime());
                }
                if (CollectionUtils.isEmpty(predictValue)) {
                    break;
                }
@@ -166,7 +188,9 @@
            default:
                break;
        }
        log.info("数据获取,columnItem:" + columnItem + ",dataList" + dataList);
        // 避免生产环境日志过多,分级打印
        log.debug("数据获取,columnItem:" + columnItem + ",dataList:" + dataList);
        log.info("数据获取,columnItem:" + columnItem + ",dataListLength:" + dataList.size());
        return dataList;
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java
@@ -65,9 +65,9 @@
            case MERGEITEM:
                // 预测值
                oneMin = PredGranularityEnum.MIN1.getCode() * 1000L;
                start = start - (start % oneMin) + oneMin;
                end = end - (end % oneMin) + oneMin;
                mins = ((end - start) / oneMin);
                start = start - (start % oneMin);
                end = end - (end % oneMin);
                mins = ((end - start) / oneMin) + 1;
                break;
            case DATAPOINT:
                // 测点值
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
@@ -100,7 +100,7 @@
                break;
            case NORMALITEM:
            case MERGEITEM:
                dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60);
                dateTime = calendar.getTime();
                break;
            case IND:
                dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60);
@@ -132,25 +132,17 @@
        calendar.setTime(originalTime);
        switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
            case DATAPOINT:
                ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId());
                if (dataPoint == null) {
                    return null;
                }
                dateTime = calendar.getTime();
                break;
            case NORMALITEM:
            case MERGEITEM:
                dateTime = calendar.getTime();
                dateTime = calculateTime(originalTime, false, columnItem.getDataLength(), 60);
                break;
            case IND:
                dateTime = calendar.getTime();
                break;
            case PLAN:
                ApiPlanItemDTO apiPlanItemDTO = planMap.get(columnItem.getParamId());
                if (apiPlanItemDTO == null) {
                    return null;
                }
                dateTime = calculateDate(originalTime, false, columnItem.getDataLength(), TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue());
                dateTime = calendar.getTime();
                break;
            default:
                break;
@@ -213,22 +205,6 @@
        calendar.set(Calendar.MILLISECOND, 0);
        // 数据长度 * 粒度
        calendar.add(Calendar.SECOND, timeLength * granularity);
        return calendar.getTime();
    }
    public Date calculateDate(Date originalTime, Boolean backward, int dataLength, int field) {
        int timeLength;
        if (backward) {
            timeLength = (-1) * dataLength;
        } else {
            timeLength = dataLength - 1;
        }
        Date desTime = originalTime;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(desTime);
        calendar.set(Calendar.MILLISECOND, 0);
        // 数据长度 * 粒度
        calendar.add(Calendar.SECOND, timeLength);
        return calendar.getTime();
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java
@@ -103,13 +103,14 @@
                throw new RuntimeException("模型结果异常:" + modelResult);
            }
            modelResult = (HashMap<String, Object>) modelResult.get(CommonConstant.MDK_RESULT);
            String statusCode = modelResult.get(CommonConstant.MDK_STATUS_CODE).toString();
            //打印结果
            JSONObject jsonObjResult = new JSONObject();
            jsonObjResult.put("result", modelResult);
            log.info(String.valueOf(jsonObjResult));
            //5.返回调度结果
            scheduleResult.setResultCode(statusCode);
            scheduleResult.setResult(modelResult);
            scheduleResult.setModelId(modelId);
            scheduleResult.setSchemeId(scheduleScheme.getId());
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/ScheduleResultVO.java
@@ -42,6 +42,11 @@
    private Date scheduleTime;
    /**
     * resultCode
     */
    private String resultCode;
    /**
     * 模型结果
     */
    private Map<String, Object> result;
iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml
@@ -58,7 +58,7 @@
logging:
  file:
    name: @log.path@/iailab-model/log/${spring.application.name}.log # 日志文件名,全路径
    name: @log.path@/log/${spring.application.name}.log # 日志文件名,全路径
  level:
    org:
      springframework:
iailab-module-model/iailab-module-model-biz/src/main/resources/logback-spring.xml
@@ -31,11 +31,11 @@
            <!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
            <cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
            <!-- 日志文件,到达多少容量,进行滚动 -->
            <maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
            <maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-100MB}</maxFileSize>
            <!-- 日志文件的总大小,0 表示不限制 -->
            <totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
            <!-- 日志文件的保留天数 -->
            <maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
            <maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
        </rollingPolicy>
    </appender>
    <!-- 异步写入日志,提升性能 -->
pom.xml
@@ -120,9 +120,9 @@
                <nacos.username>nacos</nacos.username>
                <nacos.password>nacos</nacos.password>
                <nacos.metadata.version>1.0.0</nacos.metadata.version>
                <log.path>D:\DLUT\iailab-plat</log.path>
                <log.path>D:/DLUT/iailab-plat</log.path>
                <logstash.address>127.0.0.1:4560</logstash.address>
                <deploy.server>172.16.216.132</deploy.server>
                <deploy.server>127.0.0.1</deploy.server>
            </properties>
            <activation>
                <!-- 默认环境 -->
@@ -140,7 +140,7 @@
                <nacos.username>nacos</nacos.username>
                <nacos.password>nacos</nacos.password>
                <nacos.metadata.version>1.0.0</nacos.metadata.version>
                <log.path>/home/iailab</log.path>
                <log.path>.</log.path>
                <logstash.address>127.0.0.1:4560</logstash.address>
                <deploy.server>172.16.59.105</deploy.server>
            </properties>
@@ -156,7 +156,7 @@
                <nacos.username>nacos</nacos.username>
                <nacos.password>nacos</nacos.password>
                <nacos.metadata.version>1.0.0</nacos.metadata.version>
                <log.path>D:\iailab</log.path>
                <log.path>.</log.path>
                <logstash.address>127.0.0.1:4560</logstash.address>
                <deploy.server>10.88.4.131</deploy.server>
            </properties>