已修改26个文件
已删除4个文件
已添加10个文件
| | |
| | | package com.iailab.module.model.api.mcs; |
| | | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.model.api.mcs.dto.*; |
| | | import com.iailab.module.model.enums.ApiConstants; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | * @createTime 2024年08月26日 |
| | | */ |
| | | @FeignClient(name = ApiConstants.NAME) |
| | | @Tag(name = "RPC 服务 - 模型配置接口") |
| | | @Tag(name = "RPC 服务 - 模型配置信息接口") |
| | | public interface McsApi { |
| | | |
| | | String PREFIX = ApiConstants.PREFIX + "/mcs"; |
| | | |
| | | @GetMapping(PREFIX + "/predict-item-tree") |
| | | @GetMapping(PREFIX + "/predict-item/tree") |
| | | @Operation(summary = "预测项树") |
| | | CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(); |
| | | List<PredictItemTreeDTO> getPredictItemTree(); |
| | | |
| | | @GetMapping(PREFIX + "/predict-item-info") |
| | | @Operation(summary = "预测项详情") |
| | | CommonResult<PredictItemInfoDTO> getPredictItemInfo(@RequestParam Map<String, Object> params); |
| | | @PostMapping(PREFIX + "/predict-data/charts") |
| | | PreDataBarLineRespVO getPreDataCharts(@RequestBody PreDataBarLineReqVO reqVO); |
| | | |
| | | @PostMapping(PREFIX + "/alarm-message/create") |
| | | @Operation(summary = "添加预警信息") |
| | | CommonResult<Boolean> createAlarmMessage(@RequestBody AlarmMessageRespDTO dto); |
| | | Boolean createAlarmMessage(@RequestBody AlarmMessageRespDTO dto); |
| | | |
| | | @GetMapping(PREFIX + "/alarm-message/list") |
| | | @Operation(summary = "获取预警信息列表") |
| | | CommonResult<AlarmMessageRespDTO> listAlarmMessage(@RequestParam Map<String, Object> params); |
| | | List<AlarmMessageRespDTO> listAlarmMessage(@RequestParam Map<String, Object> params); |
| | | |
| | | @PostMapping(PREFIX + "/schedule-suggest/create") |
| | | @Operation(summary = "添加调度建议") |
| | | CommonResult<Boolean> createScheduleSuggest(@RequestBody ScheduleSuggestRespDTO dto); |
| | | Boolean createScheduleSuggest(@RequestBody ScheduleSuggestRespDTO dto); |
| | | |
| | | @GetMapping(PREFIX + "/alarm-message/list") |
| | | @Operation(summary = "获取调度建议列表") |
| | | CommonResult<ScheduleSuggestRespDTO> listScheduleSuggest(@RequestParam ScheduleSuggestReqDTO params); |
| | | List<ScheduleSuggestRespDTO> listScheduleSuggest(@RequestParam ScheduleSuggestReqDTO params); |
| | | |
| | | @PostMapping(PREFIX + "/predict-model-setting/modify") |
| | | @Operation(summary = "修改预测模型设置参数") |
| | | CommonResult<Boolean> modifyPredictModelSetting(@RequestBody List<PredictModelSettingReqDTO> dtos); |
| | | Boolean modifyPredictModelSetting(@RequestBody List<PredictModelSettingReqDTO> dtos); |
| | | |
| | | @PostMapping(PREFIX + "/schedule-model-setting/modify") |
| | | @Operation(summary = "修改调度模型设置参数") |
| | | CommonResult<Boolean> modifyScheduleModelSetting(@RequestBody List<ScheduleModelSettingReqDTO> dtos); |
| | | Boolean modifyScheduleModelSetting(@RequestBody List<ScheduleModelSettingReqDTO> dtos); |
| | | } |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | |
| | | private String itemId; |
| | | |
| | | @Schema(description = "预警时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date alarmTime; |
| | | |
| | | @Schema(description = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date startTime; |
| | | |
| | | @Schema(description = "结束时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date endTime; |
| | | } |
| | |
| | | * @createTime 2024年08月29日 |
| | | */ |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | |
| | | private BigDecimal currentValue; |
| | | |
| | | @Schema(description = "超出时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date outTime; |
| | | |
| | | @Schema(description = "超出值") |
| | | private BigDecimal outValue; |
| | | |
| | | @Schema(description = "预警类型") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private String alarmType; |
| | | |
| | | @Schema(description = "预警时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date alarmTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月13日 |
| | | */ |
| | | @Data |
| | | public class PreDataBarLineReqVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "查询ID列表") |
| | | private List<String[]> queryIds; |
| | | |
| | | @Schema(description = "预测时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date predictTime; |
| | | |
| | | @Schema(description = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date startTime; |
| | | |
| | | @Schema(description = "结束时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date endTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月13日 |
| | | */ |
| | | @Data |
| | | public class PreDataBarLineRespVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "预测时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date predictTime; |
| | | |
| | | @Schema(description = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date startTime; |
| | | |
| | | @Schema(description = "结束时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date endTime; |
| | | |
| | | @Schema(description = "图例") |
| | | private List<String> legend; |
| | | |
| | | @Schema(description = "X轴数据") |
| | | private List<String> categories; |
| | | |
| | | @Schema(description = "图表数据") |
| | | private List<PreDataViewRespDTO> dataViewList; |
| | | } |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Schema(description = "RPC 模型 - 预测数据 DTO") |
| | | @Data |
| | | public class PreDataViewReqDTO { |
| | | public class PreDataViewReqDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "预测项ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private String itemId; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private String startTime; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private String endTime; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date predictTime; |
| | | } |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | */ |
| | | @Schema(description = "RPC 模型 - 预测数据 DTO") |
| | | @Data |
| | | public class PreDataViewRespDTO { |
| | | public class PreDataViewRespDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "预测项ID") |
| | | private String itemId; |
| | |
| | | private String itemName; |
| | | |
| | | @Schema(description = "预测时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date predictTime; |
| | | |
| | | @Schema(description = "量程上限") |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 预测项信息 |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年07月31日 |
| | |
| | | public class PredictItemInfoDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "预测项ID") |
| | | private String itemId; |
| | | |
| | | @Schema(description = "预测项编号") |
| | | private String itemNo; |
| | | |
| | | @Schema(description = "预测项名称") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "预测项长度") |
| | | private BigDecimal predictLength; |
| | | } |
| | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | |
| | | public class PredictModelSettingReqDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "模型ID") |
| | | private String modelid; |
| | | |
| | | /** |
| | | * 键 |
| | | */ |
| | | @Schema(description = "键") |
| | | private String key; |
| | | |
| | | /** |
| | | * 值 |
| | | */ |
| | | @Schema(description = "值") |
| | | private String value; |
| | | } |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | |
| | | public class ScheduleModelSettingReqDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "模型ID") |
| | | private String modelid; |
| | | |
| | | /** |
| | | * 键 |
| | | */ |
| | | @Schema(description = "键") |
| | | private String key; |
| | | |
| | | /** |
| | | * 值 |
| | | */ |
| | | @Schema(description = "值") |
| | | private String value; |
| | | } |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | |
| | | private String adjustObj; |
| | | |
| | | @Schema(description = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date startTime; |
| | | |
| | | @Schema(description = "结束时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date endTime; |
| | | |
| | | } |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | |
| | | private BigDecimal adjustTimes; |
| | | |
| | | @Schema(description = "调整开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date adjustStart; |
| | | |
| | | @Schema(description = "调整结束时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date adjustEnd; |
| | | |
| | | @Schema(description = "建议时间") |
| | |
| | | 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; |
| | | |
| | |
| | | @Data |
| | | public class MdkPredictDataDTO { |
| | | |
| | | @Schema(description = "数据时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date dataTime; |
| | | |
| | | @Schema(description = "数据值") |
| | | private Double dataValue; |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | @Data |
| | | public class MdkPredictItemRespDTO { |
| | | |
| | | @Schema(description = "预测时间") |
| | | private String itemId; |
| | | |
| | | @Schema(description = "预测时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date predictTime; |
| | | |
| | | @Schema(description = "单个预测项预测结果,KEY为预测项目编码") |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | private String scheduleCode; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date scheduleTime; |
| | | |
| | | private Map<String, Object> result; |
| | |
| | | INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (644, '模型结果数据类型', 'model_result_type', 0, '', '141', '2024-11-11 15:16:58', '141', '2024-11-11 15:16:58', b'0', '1970-01-01 00:00:00'); |
| | | INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1628, 1, 'double[]', '1', 'model_result_type', 0, '', '', '', '141', '2024-11-11 15:21:05', '141', '2024-11-11 15:21:05', b'0'); |
| | | INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1629, 2, 'double[][]', '2', 'model_result_type', 0, '', '', '', '141', '2024-11-11 15:21:17', '141', '2024-11-11 15:21:17', b'0'); |
| | | |
| | | |
| | | alter table t_mm_item_output add column `result_name` varchar(50) DEFAULT NULL; |
对比新文件 |
| | |
| | | package com.iailab.module.model.api; |
| | | |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.*; |
| | | import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.service.*; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月13日 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @Validated |
| | | public class McsApiImpl implements McsApi { |
| | | |
| | | @Autowired |
| | | private DmModuleService dmModuleService; |
| | | |
| | | @Autowired |
| | | private MmPredictItemService mmPredictItemService; |
| | | |
| | | @Autowired |
| | | private MmItemOutputService mmItemOutputService; |
| | | |
| | | @Autowired |
| | | private MmItemResultService mmItemResultService; |
| | | |
| | | @Autowired |
| | | private MmItemResultLastPointService mmItemResultLastPointService; |
| | | |
| | | @Autowired |
| | | private DataPointApi dataPointApi; |
| | | |
| | | private int HOUR_MINS = 60; |
| | | |
| | | @Override |
| | | public List<PredictItemTreeDTO> getPredictItemTree() { |
| | | List<PredictItemTreeDTO> result = new ArrayList<>(); |
| | | |
| | | List<DmModuleEntity> moduleList = dmModuleService.list(new HashMap<>()); |
| | | if (CollectionUtils.isEmpty(moduleList)) { |
| | | return result; |
| | | } |
| | | moduleList.forEach(item -> { |
| | | PredictItemTreeDTO moduleOpt = new PredictItemTreeDTO(); |
| | | moduleOpt.setId(item.getId()); |
| | | moduleOpt.setLabel(item.getModulename()); |
| | | List<PredictItemTreeDTO> children = new ArrayList<>(); |
| | | Map<String, Object> params = new HashMap<>(2); |
| | | params.put("status", 1); |
| | | params.put("moduleid", item.getId()); |
| | | List<MmPredictItemRespVO> itemList = mmPredictItemService.list(params); |
| | | itemList.forEach(item1 -> { |
| | | PredictItemTreeDTO chd = new PredictItemTreeDTO(); |
| | | chd.setLabel(item1.getItemname()); |
| | | chd.setId(item1.getId()); |
| | | children.add(chd); |
| | | }); |
| | | moduleOpt.setChildren(children); |
| | | result.add(moduleOpt); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public PreDataBarLineRespVO getPreDataCharts(PreDataBarLineReqVO reqVO) { |
| | | PreDataBarLineRespVO result = new PreDataBarLineRespVO(); |
| | | List<String[]> queryIds = reqVO.getQueryIds(); |
| | | List<String> legends = new ArrayList<>(); |
| | | List<PreDataViewRespDTO> dataViewList = new ArrayList<>(); |
| | | if (CollectionUtils.isEmpty(reqVO.getQueryIds())) { |
| | | return result; |
| | | } |
| | | Date predictTime = reqVO.getPredictTime(); |
| | | if (predictTime == null) { |
| | | DmModuleEntity dmModule = dmModuleService.getModuleByItemId(queryIds.get(0)[0]); |
| | | if (dmModule != null) { |
| | | predictTime = dmModule.getPredicttime(); |
| | | } else { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | predictTime = calendar.getTime(); |
| | | } |
| | | } |
| | | Date startTime = reqVO.getStartTime(); |
| | | if (startTime == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictTime); |
| | | calendar.add(Calendar.HOUR_OF_DAY, -1); |
| | | startTime = calendar.getTime(); |
| | | } |
| | | Date endTime = reqVO.getEndTime(); |
| | | if (endTime == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictTime); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 1); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | |
| | | for (int i = 0; i < queryIds.size(); i++) { |
| | | PreDataViewRespDTO viewDto = new PreDataViewRespDTO(); |
| | | String itemId = queryIds.get(i)[0]; |
| | | String outKey = queryIds.get(i)[1]; |
| | | MmItemOutputEntity output = mmItemOutputService.getByItemid(itemId, outKey); |
| | | if (output == null) { |
| | | continue; |
| | | } |
| | | legends.add(output.getResultstr()); |
| | | viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime)); |
| | | viewDto.setPreDataN(mmItemResultService.getData(output.getId(), startTime, endTime)); |
| | | viewDto.setPreDataL(mmItemResultLastPointService.getData(output.getId(), startTime, endTime)); |
| | | |
| | | List<Double> values = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(viewDto.getRealData())) { |
| | | List<Double> hisValues = new ArrayList<>(); |
| | | viewDto.getRealData().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | hisValues.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | viewDto.setHisMax(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | viewDto.setHisMin(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | viewDto.setHisAvg(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | viewDto.setHisCumulant(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).sum()) |
| | | .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getPreDataN())) { |
| | | viewDto.getPreDataN().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getPreDataL())) { |
| | | List<Double> preValues = new ArrayList<>(); |
| | | viewDto.getPreDataL().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | preValues.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | viewDto.setPreMax(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | viewDto.setPreMin(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | viewDto.setPreAvg(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getCurData())) { |
| | | List<Double> preValues = new ArrayList<>(); |
| | | viewDto.getCurData().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | preValues.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | viewDto.setPreCumulant(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).sum()) |
| | | .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getAdjData())) { |
| | | viewDto.getAdjData().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | } |
| | | if (!CollectionUtils.isEmpty(values)) { |
| | | viewDto.setMaxValue(new BigDecimal(values.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | viewDto.setMinValue(new BigDecimal(values.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | dataViewList.add(viewDto); |
| | | } |
| | | result.setStartTime(startTime); |
| | | result.setEndTime(endTime); |
| | | result.setPredictTime(predictTime); |
| | | result.setCategories(DateUtils.getTimeScale(startTime, endTime, 60)); |
| | | result.setLegend(legends); |
| | | result.setDataViewList(dataViewList); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取真实值 |
| | | * |
| | | * @param pointId |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | private List<Object[]> getHisData(String pointId, Date startTime, Date endTime) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | ApiPointDTO pointDTO = dataPointApi.getInfoById(pointId); |
| | | ApiPointValueQueryDTO queryPointDto = new ApiPointValueQueryDTO(); |
| | | queryPointDto.setPointNo(pointDTO.getPointNo()); |
| | | queryPointDto.setStart(startTime); |
| | | queryPointDto.setEnd(endTime); |
| | | List<ApiPointValueDTO> valueDTOS = dataPointApi.queryPointHistoryValue(queryPointDto); |
| | | if (CollectionUtils.isEmpty(valueDTOS)) { |
| | | return result; |
| | | } |
| | | valueDTOS.forEach(item -> { |
| | | Object[] values = new Object[2]; |
| | | values[0] = DateUtils.format(item.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | values[1] = item.getDataValue(); |
| | | result.add(values); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean createAlarmMessage(AlarmMessageRespDTO dto) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<AlarmMessageRespDTO> listAlarmMessage(Map<String, Object> params) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean createScheduleSuggest(ScheduleSuggestRespDTO dto) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<ScheduleSuggestRespDTO> listScheduleSuggest(ScheduleSuggestReqDTO params) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean modifyPredictModelSetting(List<PredictModelSettingReqDTO> dtos) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean modifyScheduleModelSetting(List<ScheduleModelSettingReqDTO> dtos) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | 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.framework.common.pojo.CommonResult; |
| | | 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.baomidou.dynamic.datasource.annotation.DSTransactional; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.model.common.enums.CommonConstant; |
| | | import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO; |
| | | import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity; |
| | | import com.iailab.module.model.mcs.pre.service.DmModuleService; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemOutputService; |
| | | import com.iailab.module.model.mcs.pre.service.MmPredictItemService; |
| | | import com.iailab.module.model.mcs.pre.vo.*; |
| | | import com.iailab.module.model.mpk.common.utils.IAILModelUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.security.PermitAll; |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | |
| | | @Autowired |
| | | private MmPredictItemService mmPredictItemService; |
| | | |
| | | @Autowired |
| | | private DmModuleService dmModuleService; |
| | | |
| | | @Autowired |
| | | private MmItemOutputService mmItemOutputService; |
| | | |
| | | private int HOUR_MINS = 60; |
| | | /** |
| | | * 预测项列表 |
| | | */ |
| | |
| | | file.transferTo(new File(uploadDir)); |
| | | Map<String, Object> result = iAILModelUtil.parseModel(uploadDir); |
| | | result.put("originalFilename", file.getOriginalFilename().replace(CommonConstant.MDK_SUFFIX, "")); |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/tree") |
| | | public CommonResult<List<PreItemOptionVO>> itemTree() { |
| | | List<PreItemOptionVO> result = new ArrayList<>(); |
| | | |
| | | List<DmModuleEntity> moduleList = dmModuleService.list(new HashMap<>()); |
| | | if (CollectionUtils.isEmpty(moduleList)) { |
| | | return success(result); |
| | | } |
| | | moduleList.forEach(item -> { |
| | | PreItemOptionVO moduleOpt = new PreItemOptionVO(); |
| | | moduleOpt.setId(item.getId()); |
| | | moduleOpt.setLabel(item.getModulename()); |
| | | List<PreItemOptionVO> children = new ArrayList<>(); |
| | | Map<String, Object> params = new HashMap<>(2); |
| | | params.put("status", 1); |
| | | params.put("moduleid", item.getId()); |
| | | List<MmPredictItemRespVO> itemList = mmPredictItemService.list(params); |
| | | itemList.forEach(item1 -> { |
| | | PreItemOptionVO chd = new PreItemOptionVO(); |
| | | chd.setLabel(item1.getItemname()); |
| | | chd.setId(item1.getId()); |
| | | children.add(chd); |
| | | }); |
| | | moduleOpt.setChildren(children); |
| | | result.add(moduleOpt); |
| | | }); |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/view-charts") |
| | | public CommonResult<PreDataBarLineVO> viewCharts(@RequestParam Map<String, Object> params) { |
| | | PreDataBarLineVO result = new PreDataBarLineVO(); |
| | | List<String> legends = new ArrayList<>(); |
| | | List<PreDataViewVO> dataViewList = new ArrayList<>(); |
| | | if (params.get("itemIds") == null) { |
| | | return success(result); |
| | | } |
| | | List<String> itemIdList = Arrays.asList(params.get("itemIds").toString().split(",")); |
| | | |
| | | Date predictTime; |
| | | if (StringUtils.isBlank((String) params.get("predictTime"))) { |
| | | DmModuleEntity dmModule = dmModuleService.getModuleByItemId(itemIdList.get(0)); |
| | | if (dmModule != null) { |
| | | predictTime = dmModule.getPredicttime(); |
| | | } else { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | predictTime = calendar.getTime(); |
| | | } |
| | | } else { |
| | | predictTime = DateUtils.parse(params.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | } |
| | | Date startTime; |
| | | if (StringUtils.isBlank((String) params.get("startTime"))) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictTime); |
| | | calendar.add(Calendar.HOUR_OF_DAY, -1); |
| | | startTime = calendar.getTime(); |
| | | } else { |
| | | startTime = DateUtils.parse(params.get("startTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | } |
| | | Date endTime = null; |
| | | if (StringUtils.isBlank((String) params.get("endTime"))) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictTime); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 1); |
| | | endTime = calendar.getTime(); |
| | | } else { |
| | | endTime = DateUtils.parse(params.get("endTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | } |
| | | |
| | | for (int i = 0; i < itemIdList.size(); i++) { |
| | | PreDataViewVO viewDto = new PreDataViewVO(); |
| | | String itemId = itemIdList.get(i); |
| | | // MmItemOutputEntity mmItemOutput = mmItemOutputService.getByItemid(itemId); |
| | | MmPredictItemEntity predictItem = mmPredictItemService.getById(itemId); |
| | | if (predictItem == null) { |
| | | log.info("itemId=" + itemId + "; is null"); |
| | | continue; |
| | | } |
| | | try { |
| | | viewDto.setItemId(itemId); |
| | | viewDto.setItemName(predictItem.getItemname()); |
| | | viewDto.setRealData(mmPredictItemService.getHisData(itemId, startTime, endTime)); |
| | | // viewDto.setPreDataN(mmItemResultService.getData(mmItemOutput.getId(), startTime, endTime)); |
| | | // viewDto.setPreDataL(mmItemResultLastPointService.getData(mmItemOutput.getId(), startTime, endTime)); |
| | | // viewDto.setCurData(mmItemResultJsonService.getData(mmItemOutput.getId(), predictTime)); |
| | | // viewDto.setAdjData(scheduleAdjustResultService.getData(itemId, predictTime)); |
| | | legends.add(predictItem.getItemname()); |
| | | List<Double> values = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(viewDto.getRealData())) { |
| | | List<Double> hisValues = new ArrayList<>(); |
| | | viewDto.getRealData().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | hisValues.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | viewDto.setHisMax(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | viewDto.setHisMin(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | viewDto.setHisAvg(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | viewDto.setHisCumulant(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).sum()) |
| | | .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getPreDataN())) { |
| | | viewDto.getPreDataN().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getPreDataL())) { |
| | | List<Double> preValues = new ArrayList<>(); |
| | | viewDto.getPreDataL().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | preValues.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | viewDto.setPreMax(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | viewDto.setPreMin(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | viewDto.setPreAvg(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getCurData())) { |
| | | List<Double> preValues = new ArrayList<>(); |
| | | viewDto.getCurData().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | preValues.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | viewDto.setPreCumulant(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).sum()) |
| | | .divide(new BigDecimal(HOUR_MINS), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(viewDto.getAdjData())) { |
| | | viewDto.getAdjData().forEach(item -> { |
| | | values.add(Double.parseDouble(item[1].toString())); |
| | | }); |
| | | } |
| | | if (!CollectionUtils.isEmpty(values)) { |
| | | viewDto.setMaxValue(BigDecimal.valueOf(values.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | viewDto.setMinValue(BigDecimal.valueOf(values.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | |
| | | dataViewList.add(viewDto); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | result.setStartTime(startTime); |
| | | result.setEndTime(endTime); |
| | | result.setPredictTime(predictTime); |
| | | result.setCategories(DateUtils.getTimeScale(startTime, endTime, 60)); |
| | | result.setLegend(legends); |
| | | result.setDataViewList(dataViewList); |
| | | return success(result); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.dao; |
| | | |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月14日 |
| | | */ |
| | | @TenantDS |
| | | @Mapper |
| | | public interface MmItemResultJsonDao extends BaseMapperX<MmItemResultJsonEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.dao; |
| | | |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月14日 |
| | | */ |
| | | @TenantDS |
| | | @Mapper |
| | | public interface MmItemResultLastPointDao extends BaseMapperX<MmItemResultLastPointEntity> { |
| | | } |
| | |
| | | * 排序(默认值1) |
| | | */ |
| | | private BigDecimal outputorder; |
| | | |
| | | /** |
| | | * 结果名称 |
| | | */ |
| | | private String resultName; |
| | | } |
| | |
| | | * @createTime 2024年09月02日 |
| | | */ |
| | | @Data |
| | | @TableName("T_MM_ITEM_RESULT") |
| | | @TableName("t_mm_item_result_json") |
| | | public class MmItemResultJsonEntity implements Serializable { |
| | | |
| | | @TableId(value = "id",type = IdType.INPUT) |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.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.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月14日 |
| | | */ |
| | | @Data |
| | | @TableName("t_mm_item_result_last_point") |
| | | public class MmItemResultLastPointEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 输出ID |
| | | */ |
| | | private String outputid; |
| | | |
| | | /** |
| | | * 预测时间 |
| | | */ |
| | | private Date datatime; |
| | | |
| | | /** |
| | | * 预测值 |
| | | */ |
| | | private BigDecimal datavalue; |
| | | } |
| | |
| | | |
| | | List<MmItemOutputEntity> getByItemid(String itemid); |
| | | |
| | | MmItemOutputEntity getByItemid(String itemid, String resultstr); |
| | | |
| | | void deleteByItemId(String itemId); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.service; |
| | | |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月14日 |
| | | */ |
| | | public interface MmItemResultJsonService extends BaseService<MmItemResultJsonEntity> { |
| | | |
| | | List<Object[]> getData(String outputId, Date predictTime); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.service; |
| | | |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月14日 |
| | | */ |
| | | public interface MmItemResultLastPointService extends BaseService<MmItemResultLastPointEntity> { |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime); |
| | | } |
| | |
| | | void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime); |
| | | |
| | | List<DataValueVO> getPredictValue(String outputid, Date startTime, Date endTime); |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime); |
| | | } |
| | |
| | | List<MmPredictItemRespVO> list(Map<String, Object> params); |
| | | |
| | | MmPredictItemEntity getById(String id); |
| | | |
| | | List<Object[]> getHisData(String itemId, Date startTime, Date endTime); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<MmItemOutputEntity> getByItemid(String itemid) { |
| | | QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("itemid", itemid); |
| | | queryWrapper.orderByAsc("outputorder"); |
| | | QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("itemid", itemid).orderByAsc("outputorder"); |
| | | List<MmItemOutputEntity> list = mmItemOutputDao.selectList(queryWrapper); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public MmItemOutputEntity getByItemid(String itemid, String resultstr) { |
| | | QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("itemid", itemid).eq("resultstr", resultstr); |
| | | return mmItemOutputDao.selectOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByItemId(String itemId) { |
| | | QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("itemid", itemId); |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.model.mcs.pre.dao.MmItemResultJsonDao; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月14日 |
| | | */ |
| | | @Service |
| | | public class MmItemResultJsonServiceImpl extends BaseServiceImpl<MmItemResultJsonDao, MmItemResultJsonEntity> |
| | | implements MmItemResultJsonService { |
| | | |
| | | @Override |
| | | public List<Object[]> getData(String outputId, Date predictTime) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("outputid", outputId) |
| | | .eq("predicttime", predictTime); |
| | | MmItemResultJsonEntity data = baseDao.selectOne(wrapper); |
| | | if (data == null || StringUtils.isBlank(data.getJsonvalue())) { |
| | | return result; |
| | | } |
| | | result = JSONArray.parseArray(data.getJsonvalue(), Object[].class); |
| | | result.forEach(item -> { |
| | | item[0] = new Date(Long.parseLong(item[0].toString())); |
| | | }); |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.model.mcs.pre.dao.MmItemResultLastPointDao; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemResultLastPointService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月14日 |
| | | */ |
| | | @Service |
| | | public class MmItemResultLastPointServiceImpl extends BaseServiceImpl<MmItemResultLastPointDao, MmItemResultLastPointEntity> |
| | | implements MmItemResultLastPointService { |
| | | |
| | | @Override |
| | | public List<Object[]> getData(String outputid, Date startTime, Date endTime) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | QueryWrapper<MmItemResultLastPointEntity> queryWrapper = new QueryWrapper<MmItemResultLastPointEntity>() |
| | | .eq("outputid", outputid) |
| | | .between("datatime", startTime, endTime) |
| | | .orderByAsc("datatime"); |
| | | List<MmItemResultLastPointEntity> list = baseDao.selectList(queryWrapper); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return result; |
| | | } |
| | | list.forEach(item -> { |
| | | Object[] dataItem = new Object[2]; |
| | | dataItem[0] = DateUtils.format(item.getDatatime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | dataItem[1] = item.getDatavalue(); |
| | | result.add(dataItem); |
| | | }); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.model.mcs.pre.dao.MmItemResultDao; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; |
| | |
| | | }).collect(Collectors.toList()); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<Object[]> getData(String outputid, Date startTime, Date endTime) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | QueryWrapper<MmItemResultEntity> queryWrapper = new QueryWrapper<MmItemResultEntity>() |
| | | .eq("outputid", outputid) |
| | | .between("datatime", startTime, endTime) |
| | | .orderByAsc("datatime"); |
| | | List<MmItemResultEntity> list = mmItemResultDao.selectList(queryWrapper); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return result; |
| | | } |
| | | list.forEach(item -> { |
| | | Object[] dataItem = new Object[2]; |
| | | dataItem[0] = DateUtils.format(item.getDatatime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | dataItem[1] = item.getDatavalue(); |
| | | result.add(dataItem); |
| | | }); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | return mmPredictItemDao.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<Object[]> getHisData(String itemId, Date startTime, Date endTime) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | return result; |
| | | } |
| | | |
| | | @DSTransactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void add(MmPredictItemDTO mmPredictItemDto) { |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | |
| | | * 项目id |
| | | */ |
| | | private String mpkProjectId; |
| | | |
| | | /** |
| | | * 最后运行时间 |
| | | */ |
| | | private Date lastTime; |
| | | } |
| | |
| | | <result property="isFuse" column="ISFUSE"/> |
| | | <result property="predictPhase" column="PREDICTPHASE"/> |
| | | <result property="workChecked" column="WORKCHECKED"/> |
| | | <result property="lastTime" column="last_time"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="MergeItemVO" type="com.iailab.module.model.mdk.vo.MergeItemVO"> |
| | |
| | | t1.status, |
| | | t1.isfuse, |
| | | t1.predictphase, |
| | | t1.workchecked |
| | | t1.workchecked, |
| | | t3.last_time |
| | | FROM |
| | | t_mm_predict_item t1, |
| | | t_mm_item_type t2 |
| | | WHERE t1.itemtypeid=t2.id |
| | | <if test="ITEMID != null and ITEMID != ''"> |
| | | AND t1.id=#{ITEMID} |
| | | </if> |
| | | <if test="ITEMNO != null and ITEMNO != ''"> |
| | | t1.itemno=#{ITEMNO} |
| | | </if> |
| | | t_mm_predict_item t1 |
| | | LEFT JOIN t_mm_item_type t2 on t2.id = t1.itemtypeid |
| | | LEFT JOIN t_mm_item_status t3 on t3.item_id = t1.id |
| | | <where> |
| | | <if test="ITEMID != null and ITEMID != ''"> |
| | | AND t1.id=#{ITEMID} |
| | | </if> |
| | | <if test="ITEMNO != null and ITEMNO != ''"> |
| | | t1.itemno=#{ITEMNO} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="getMergeItemByItemId" parameterType="map" resultMap="MergeItemVO"> |
| | | SELECT t1.id, |