Merge remote-tracking branch 'origin/master'
| | |
| | | @Operation(summary = "修改调度模型配置") |
| | | Boolean updateScheduleModelSetting(@RequestParam("modelCode") String modelCode, @RequestParam("key") String key, @RequestParam("value") String value); |
| | | |
| | | @GetMapping(PREFIX + "/schedule/adjust/config-list") |
| | | @Operation(summary = "获取模拟调整配置") |
| | | List<StAdjustConfigDetDTO> getAdjustConfigListByModelId(@RequestParam("modelId") String modelId); |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | @Schema(description = "RPC 模型 - 模拟调整配置详情 DTO") |
| | | @Data |
| | | public class StAdjustConfigDetDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "ID") |
| | | private String id; |
| | | |
| | | @Schema(description = "配置ID") |
| | | private String configId; |
| | | |
| | | @Schema(description = "预测项类型") |
| | | private String itemTypeId; |
| | | |
| | | @Schema(description = "预测项ID") |
| | | private String predictItemId; |
| | | |
| | | @Schema(description = "输出KEY") |
| | | private String outKey; |
| | | |
| | | @Schema(description = "输出名称") |
| | | private String outName; |
| | | |
| | | @Schema(description = "参数排序") |
| | | private Integer modelParamOrder; |
| | | |
| | | @Schema(description = "输入排序") |
| | | private Integer modelParamPortOrder; |
| | | |
| | | @Schema(description = "执行顺序") |
| | | private Integer sort; |
| | | } |
| | |
| | | |
| | | alter table t_mm_item_output add column `iscumulant` tinyint default false COMMENT '是否累计'; |
| | | alter table t_mm_item_output add column `cumuldivisor` int DEFAULT NULL COMMENT '累计除数'; |
| | | alter table t_mm_item_output add column `cumulpoint` varchar(36) DEFAULT NULL, COMMENT '累计测点'; |
| | | alter table t_mm_item_output add column `cumulpoint` varchar(36) DEFAULT NULL, COMMENT '累计测点'; |
| | | |
| | | |
| | | CREATE TABLE `t_st_adjust_config` ( |
| | | `id` varchar(36) NOT NULL COMMENT 'ID', |
| | | `schedule_model_id` varchar(36) DEFAULT NULL COMMENT '调度模型ID', |
| | | `remark` varchar(200) DEFAULT NULL COMMENT '备注', |
| | | `status` tinyint DEFAULT 1 COMMENT '状态', |
| | | create_time datetime default current_timestamp, |
| | | update_time datetime default current_timestamp, |
| | | PRIMARY KEY (`id`) USING BTREE, |
| | | INDEX `idx_schedule_model_id`(`schedule_model_id` ASC) USING BTREE |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模拟调整配置表'; |
| | | |
| | | CREATE TABLE `t_st_adjust_config_det` ( |
| | | `id` varchar(36) NOT NULL COMMENT 'ID', |
| | | `config_id` varchar(36) DEFAULT NULL COMMENT '配置ID', |
| | | `item_type_id` varchar(36) DEFAULT NULL COMMENT '预测项类型', |
| | | `predict_item_id` varchar(36) DEFAULT NULL COMMENT '预测项ID', |
| | | `out_key` varchar(50) DEFAULT NULL COMMENT '输出KEY', |
| | | `out_name` varchar(50) DEFAULT NULL COMMENT '输出名称', |
| | | `model_param_order` integer DEFAULT NULL COMMENT '参数排序', |
| | | `model_param_port_order` integer DEFAULT NULL COMMENT '输入排序', |
| | | `sort` integer COMMENT '执行顺序', |
| | | PRIMARY KEY (`id`) USING BTREE, |
| | | INDEX `idx_config_id`(`config_id` ASC) USING BTREE |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模拟调整配置详细表'; |
| | | |
| | | CREATE TABLE `t_st_adjust_result` ( |
| | | `id` varchar(36) NOT NULL COMMENT 'ID', |
| | | `predict_item_id` varchar(36) DEFAULT NULL COMMENT '预测项ID', |
| | | `schedule_model_id` varchar(36) DEFAULT NULL COMMENT '调度模型ID', |
| | | `adjust_time` datetime NULL DEFAULT NULL COMMENT '模拟调整时间', |
| | | `adjust_value` varchar(500) DEFAULT NULL COMMENT '模拟调整值', |
| | | `json_value` varchar(1000) DEFAULT NULL COMMENT '模拟调整结果', |
| | | PRIMARY KEY (`id`) USING BTREE, |
| | | INDEX `idx_predict_item_id`(`predict_item_id` ASC) USING BTREE, |
| | | INDEX `idx_schedule_model_id`(`schedule_model_id` ASC) USING BTREE |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模拟调整结果表'; |
| | | |
| | |
| | | import com.iailab.module.model.mcs.pre.vo.MmItemOutputRespVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity; |
| | | import com.iailab.module.model.mcs.sche.service.*; |
| | |
| | | @Autowired |
| | | private StScheduleModelSettingService stScheduleModelSettingService; |
| | | |
| | | @Autowired |
| | | private StAdjustConfigService stAdjustConfigService; |
| | | |
| | | private int HOUR_MINS = 60; |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<StAdjustConfigDetDTO> getAdjustConfigListByModelId(String modelId) { |
| | | List<StAdjustConfigDetEntity> list = stAdjustConfigService.getDetByModelId(modelId); |
| | | return ConvertUtils.sourceToTarget(list, StAdjustConfigDetDTO.class); |
| | | } |
| | | |
| | | /** |
| | | * 计算功率因数 p²/(根号:p²+Q²) |
| | | **/ |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.dao; |
| | | |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | @TenantDS |
| | | @Mapper |
| | | public interface StAdjustConfigDao extends BaseMapperX<StAdjustConfigEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.dao; |
| | | |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | @TenantDS |
| | | @Mapper |
| | | public interface StAdjustConfigDetDao extends BaseMapperX<StAdjustConfigDetEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.dao; |
| | | |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustResultEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | @TenantDS |
| | | @Mapper |
| | | public interface StAdjustResultDao extends BaseMapperX<StAdjustResultEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月20日 |
| | | */ |
| | | @Data |
| | | @TableName("t_st_adjust_config_det") |
| | | public class StAdjustConfigDetEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 配置ID |
| | | */ |
| | | private String configId; |
| | | |
| | | /** |
| | | * 预测项类型 |
| | | */ |
| | | private String itemTypeId; |
| | | |
| | | /** |
| | | * 预测项ID |
| | | */ |
| | | private String predictItemId; |
| | | |
| | | /** |
| | | * 输出KEY |
| | | */ |
| | | private String outKey; |
| | | |
| | | /** |
| | | * 输出名称 |
| | | */ |
| | | private String outName; |
| | | |
| | | /** |
| | | * 参数排序 |
| | | */ |
| | | private Integer modelParamOrder; |
| | | |
| | | /** |
| | | * 输入排序 |
| | | */ |
| | | private Integer modelParamPortOrder; |
| | | |
| | | /** |
| | | * 执行顺序 |
| | | */ |
| | | private Integer sort; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月20日 |
| | | */ |
| | | @Data |
| | | @TableName("t_st_adjust_config") |
| | | public class StAdjustConfigEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 调度模型ID |
| | | */ |
| | | private String scheduleModelId; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月20日 |
| | | */ |
| | | @Data |
| | | @TableName("t_st_adjust_result") |
| | | public class StAdjustResultEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 预测项ID |
| | | */ |
| | | private String predictItemId; |
| | | |
| | | /** |
| | | * 调度模型ID |
| | | */ |
| | | private String scheduleModelId; |
| | | |
| | | /** |
| | | * 模拟调整时间 |
| | | */ |
| | | private Date adjustTime; |
| | | |
| | | /** |
| | | * 模拟调整值 |
| | | */ |
| | | private String adjustValue; |
| | | |
| | | /** |
| | | * 模拟调整结果 |
| | | */ |
| | | private String jsonValue; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.service; |
| | | |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | public interface StAdjustConfigDetService extends BaseService<StAdjustConfigDetEntity> { |
| | | |
| | | List<StAdjustConfigDetEntity> getListByConfigId(String configId); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.service; |
| | | |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigEntity; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | public interface StAdjustConfigService extends BaseService<StAdjustConfigEntity> { |
| | | |
| | | StAdjustConfigEntity getByModelId(String modelId); |
| | | |
| | | List<StAdjustConfigDetEntity> getDetByModelId(String modelId); |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.service; |
| | | |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustResultEntity; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | public interface StAdjustResultService extends BaseService<StAdjustResultEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.model.mcs.sche.dao.StAdjustConfigDetDao; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity; |
| | | import com.iailab.module.model.mcs.sche.service.StAdjustConfigDetService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class StAdjustConfigDetServiceImpl extends BaseServiceImpl<StAdjustConfigDetDao, StAdjustConfigDetEntity> implements StAdjustConfigDetService { |
| | | |
| | | public List<StAdjustConfigDetEntity> getListByConfigId(String configId) { |
| | | QueryWrapper<StAdjustConfigDetEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("config_id", configId); |
| | | queryWrapper.orderByAsc("sort"); |
| | | return baseDao.selectList(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.service.impl; |
| | | |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.model.mcs.sche.dao.StAdjustConfigDao; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustConfigEntity; |
| | | import com.iailab.module.model.mcs.sche.service.StAdjustConfigDetService; |
| | | import com.iailab.module.model.mcs.sche.service.StAdjustConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class StAdjustConfigServiceImpl extends BaseServiceImpl<StAdjustConfigDao, StAdjustConfigEntity> implements StAdjustConfigService { |
| | | |
| | | @Autowired |
| | | private StAdjustConfigDetService stAdjustConfigDetService; |
| | | |
| | | public StAdjustConfigEntity getByModelId(String modelId) { |
| | | return baseDao.selectOne("schedule_model_id", modelId); |
| | | } |
| | | |
| | | |
| | | public List<StAdjustConfigDetEntity> getDetByModelId(String modelId) { |
| | | StAdjustConfigEntity configEntity = getByModelId(modelId); |
| | | return stAdjustConfigDetService.getListByConfigId(configEntity.getId()); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.service.impl; |
| | | |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.model.mcs.sche.dao.StAdjustResultDao; |
| | | import com.iailab.module.model.mcs.sche.entity.StAdjustResultEntity; |
| | | import com.iailab.module.model.mcs.sche.service.StAdjustResultService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class StAdjustResultServiceImpl extends BaseServiceImpl<StAdjustResultDao, StAdjustResultEntity> implements StAdjustResultService { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.vo; |
| | | |
| | | import com.iailab.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月20日 |
| | | */ |
| | | @Schema(description = "模型服务 - 调度模型分页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class StAdjustConfigDetPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "配置ID", example = "") |
| | | private String configId; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.vo; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | public class StAdjustConfigDetRespVO { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.vo; |
| | | |
| | | import com.iailab.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月20日 |
| | | */ |
| | | @Schema(description = "模型服务 - 调度模型分页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class StAdjustConfigPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "模型编号,模糊匹配", example = "") |
| | | private String modelCode; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.vo; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | public class StAdjustConfigRespVO { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.vo; |
| | | |
| | | import com.iailab.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月20日 |
| | | */ |
| | | @Schema(description = "模型服务 - 调度模型分页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class StAdjustResultPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "开始时间", example = "") |
| | | private String startTime; |
| | | |
| | | @Schema(description = "结束时间", example = "") |
| | | private String endTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.sche.vo; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年02月23日 |
| | | */ |
| | | public class StAdjustResultRespVO { |
| | | } |
| | |
| | | * @throws ModelInvokeException |
| | | */ |
| | | PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName,String itemNo) throws ModelInvokeException; |
| | | |
| | | /** |
| | | * 预测,模拟调整 |
| | | * |
| | | * @param predictTime |
| | | * @param predictModel |
| | | * @param itemName |
| | | * @param itemNo |
| | | * @param deviation |
| | | * @return |
| | | */ |
| | | PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName,String itemNo, double[][] deviation) throws ModelInvokeException; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 预测,模拟调整 |
| | | * |
| | | * @param predictTime |
| | | * @param predictModel |
| | | * @param itemName |
| | | * @param itemNo |
| | | * @return |
| | | * @throws ModelInvokeException |
| | | */ |
| | | @Override |
| | | public synchronized PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName,String itemNo, double[][] deviation) throws ModelInvokeException { |
| | | PredictResultVO result = new PredictResultVO(); |
| | | if (predictModel == null) { |
| | | throw new ModelInvokeException("modelEntity is null"); |
| | | } |
| | | String modelId = predictModel.getId(); |
| | | try { |
| | | List<SampleData> sampleDataList = sampleConstructor.constructSample(TypeA.Predict.name(), modelId, predictTime, itemName, new HashMap<>()); |
| | | String modelPath = predictModel.getModelpath(); |
| | | if (modelPath == null) { |
| | | log.info("模型路径不存在,modelId=" + modelId); |
| | | return null; |
| | | } |
| | | IAILModel newModelBean = composeNewModelBean(predictModel); |
| | | HashMap<String, Object> settings = getPredictSettingsByModelId(modelId); |
| | | // 校验setting必须有pyFile,否则可能导致程序崩溃 |
| | | if (!settings.containsKey(MdkConstant.PY_FILE_KEY)) { |
| | | throw new RuntimeException("模型设置参数缺少必要信息【" + MdkConstant.PY_FILE_KEY + "】,请重新上传模型!"); |
| | | } |
| | | |
| | | if (settings == null) { |
| | | log.error("模型setting不存在,modelId=" + modelId); |
| | | return null; |
| | | } |
| | | int portLength = sampleDataList.size(); |
| | | Object[] param2Values = new Object[portLength + 2]; |
| | | for (int i = 0; i < portLength; i++) { |
| | | param2Values[i] = sampleDataList.get(i).getMatrix(); |
| | | } |
| | | param2Values[portLength] = newModelBean.getDataMap().get("models"); |
| | | param2Values[portLength + 1] = settings; |
| | | |
| | | log.info("####################### 模拟调整 "+ "【itemId:" + predictModel.getItemid() + ",itemName:" + itemName + ",itemNo:" + itemNo + "】 ##########################"); |
| | | log.info("参数: " + JSON.toJSONString(param2Values)); |
| | | |
| | | //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); |
| | | |
| | | List<MmItemOutputEntity> itemOutputList = mmItemOutputService.getByItemid(predictModel.getItemid()); |
| | | Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>(); |
| | | for (MmItemOutputEntity output : itemOutputList) { |
| | | if (!modelResult.containsKey(output.getResultstr())) { |
| | | continue; |
| | | } |
| | | OutResultType outResultType = OutResultType.getEumByCode(output.getResultType()); |
| | | switch (outResultType) { |
| | | case D1: |
| | | double[] temp1 = (double[]) modelResult.get(output.getResultstr()); |
| | | predictMatrixs.put(output, temp1); |
| | | break; |
| | | case D2: |
| | | double[][] temp2 = (double[][]) modelResult.get(output.getResultstr()); |
| | | double[] tempColumn = new double[temp2.length]; |
| | | for (int i = 0; i < tempColumn.length; i++) { |
| | | tempColumn[i] = temp2[i][output.getResultIndex()]; |
| | | } |
| | | predictMatrixs.put(output, tempColumn); |
| | | break; |
| | | case D: |
| | | Double temp3 = (Double) modelResult.get(output.getResultstr()); |
| | | predictMatrixs.put(output, new double[]{temp3}); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | result.setPredictMatrixs(predictMatrixs); |
| | | result.setModelResult(modelResult); |
| | | result.setPredictTime(predictTime); |
| | | } catch (ModelResultErrorException ex) { |
| | | log.error("模型结果异常", ex); |
| | | throw ex; |
| | | } catch (Exception ex) { |
| | | log.error("调用发生异常,异常信息为:{0}", ex.getMessage()); |
| | | throw new ModelInvokeException(ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | * 构造IAILMDK.run()方法的newModelBean参数 |
| | | * |
| | | * @param predictModel |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | int deviationIndex = 0; |
| | | |
| | | //对每个爪分别进行计算 |
| | | for (ColumnItemPort entry : sampleInfo.getColumnInfo()) { |
| | | double[][] matrix = new double[0][0]; |
| | |
| | | } |
| | | } |
| | | |
| | | //找出对应的调整值 |
| | | double[] 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), pointMap, planMap,indMap); |
| | | |
| | | //设置调整值 |
| | | if (deviationItem != null && deviationItem.length > 0) { |
| | | logger.info("设置调整值, i = " + i); |
| | | if (deviationItem[i] <= 0) { |
| | | continue; |
| | | } |
| | | for(int dataKey = 1; dataKey < dataEntityList.size(); dataKey ++) { |
| | | DataValueVO item = dataEntityList.get(dataKey); |
| | | item.setDataValue(item.getDataValue() + deviationItem[i]); |
| | | } |
| | | } |
| | | |
| | | //补全数据 |
| | | ColumnItem columnItem = entry.getColumnItemList().get(i); |
| | | dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime, columnItem.getParamType(),columnItem.getGranularity()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | SampleData sampleData = new SampleData(); |
| | | sampleData.setMatrix(matrix); |
| | | sampleDataList.add(sampleData); |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | public List<SampleData> constructSample(String typeA, String modelId, Date runTime,String itemName, |
| | | Map<Integer, Integer> dynamicDataLength, double[][] deviation) throws ModelInvokeException { |
| | | try { |
| | | SampleInfoConstructor sampleInfoConstructor = sampleFactory.createSampleInfo(typeA, modelId); |
| | | SampleInfo sampleInfo = sampleInfoConstructor.prepareSampleInfo(modelId, runTime, dynamicDataLength); |
| | | sampleInfo.setDeviation(deviation); |
| | | SampleDataConstructor sampleDataConstructor = sampleFactory.createSampleData(typeA); |
| | | return sampleDataConstructor.prepareSampleData(sampleInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("获取模型的算法参数异常",e); |
| | | throw new ModelInvokeException(MessageFormat.format("{0},Name:{1}", |
| | | ModelInvokeException.errorGetModelArithParam, itemName)); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | private Integer sampleCycle; |
| | | |
| | | private BigDecimal[][] deviation; |
| | | // 调整值 |
| | | private double[][] deviation; |
| | | // 所有测点信息,避免重复查询 |
| | | private Map<String, ApiPointDTO> pointMap; |
| | | // 所有计划数据信息,避免重复查询 |
| | |
| | | |
| | | influx-db: |
| | | org: iailab |
| | | token: NloIinwybvMwKlJ8SGOAqboXH72EhdQEsnnV7kwtstVu6sbt24LNJ0bVICepeAtl2pxpd1Hj8gDLj9m4hnB7Fw== |
| | | url: http://127.0.0.1:8086 |
| | | username: dzd |
| | | password: qwer1234 |
| | | token: _338h4Kbu2KQaes5QwAyOz9pTUueXoSF9XmPi8N9oTS1SrhTZVj4J9JfSraUyWA0PfWMZOlf9QWax-USkJQR_A== |
| | | url: http://172.16.8.200:8086 |
| | | username: iailab |
| | | password: iailab2019 |