iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java
@@ -38,7 +38,7 @@ @PostMapping(PREFIX + "/predict-data/single-chart") @Operation(summary = "预测数据图表") PreDataItemChartRespVO getPreDataSingleChart(@RequestBody PreDataSingleChartReqVO reqVO); PreDataSingleChartRespVO getPreDataSingleChart(@RequestBody PreDataSingleChartReqVO reqVO); @PostMapping(PREFIX + "/alarm-message/create") @Operation(summary = "添加预警信息") iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartReqVO.java
@@ -22,4 +22,12 @@ @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; } iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartRespVO.java
对比新文件 @@ -0,0 +1,40 @@ 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月18日 */ @Data public class PreDataSingleChartRespVO 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; private PreDataViewRespDTO dataView; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
@@ -7,10 +7,14 @@ 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.common.enums.CommonConstant; import com.iailab.module.model.common.enums.PreLineTypeEnum; 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.mdk.vo.ItemVO; import com.iailab.module.model.mpk.service.ChartParamService; import com.iailab.module.model.mpk.service.ChartService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; @@ -47,6 +51,12 @@ @Autowired private DataPointApi dataPointApi; @Autowired private MmItemResultJsonService mmItemResultJsonService; @Autowired private ChartService chartService; private int HOUR_MINS = 60; @@ -211,20 +221,20 @@ if (startTime == null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(predictItem.getLastTime()); calendar.add(Calendar.HOUR_OF_DAY, -1); calendar.add(Calendar.MINUTE, -1 * predictItem.getPredictLength()); startTime = calendar.getTime(); } Date endTime = reqVO.getEndTime(); if (endTime == null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(predictItem.getLastTime()); calendar.add(Calendar.HOUR_OF_DAY, 1); calendar.add(Calendar.MINUTE, predictItem.getPredictLength()); endTime = calendar.getTime(); } if (endTime.getTime() <= startTime.getTime()) { Calendar calendar = Calendar.getInstance(); calendar.setTime(startTime); calendar.add(Calendar.HOUR_OF_DAY, 1); calendar.add(Calendar.MINUTE, predictItem.getPredictLength()); endTime = calendar.getTime(); } @@ -251,10 +261,83 @@ } @Override public PreDataItemChartRespVO getPreDataSingleChart(PreDataSingleChartReqVO reqVO) { PreDataItemChartRespVO result = new PreDataItemChartRespVO(); public PreDataSingleChartRespVO getPreDataSingleChart(PreDataSingleChartReqVO reqVO) { PreDataSingleChartRespVO result = new PreDataSingleChartRespVO(); Map<String, String> chartParams = chartService.getByChartCode(reqVO.getChartCode()); if (CollectionUtils.isEmpty(chartParams)) { return result; } String itemCode = chartParams.get(CommonConstant.ITEM_CODE); if (itemCode == null) { return result; } String resultStr = chartParams.get(CommonConstant.RESULT_STR); if (resultStr == null) { return result; } ItemVO predictItem = mmPredictItemService.getItemByItemNo(itemCode); if (predictItem == null || predictItem.getLastTime() == null) { return result; } PreLineTypeEnum lineType = chartParams.get(CommonConstant.LINE_TYPE) == null ? PreLineTypeEnum.TN : PreLineTypeEnum.valueOf(chartParams.get(CommonConstant.LINE_TYPE)); BigDecimal rangeH = chartParams.get(CommonConstant.RANGE_H) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.RANGE_H)); BigDecimal rangeL = chartParams.get(CommonConstant.RANGE_L) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.RANGE_L)); BigDecimal limitH = chartParams.get(CommonConstant.LIMIT_H) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.LIMIT_H)); BigDecimal limitL = chartParams.get(CommonConstant.LIMIT_L) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.LIMIT_L)); int lengthLeft = chartParams.get(CommonConstant.LENGTH_LEFT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_LEFT)).intValue(); int lengthRight = chartParams.get(CommonConstant.LENGTH_RIGHT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_RIGHT)).intValue(); result.setPredictTime(predictItem.getLastTime()); Date predictTime = predictItem.getLastTime(); Date startTime = reqVO.getStartTime(); if (startTime == null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(predictItem.getLastTime()); calendar.add(Calendar.MINUTE, -1 * lengthLeft); startTime = calendar.getTime(); } Date endTime = reqVO.getEndTime(); if (endTime == null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(predictItem.getLastTime()); calendar.add(Calendar.MINUTE, lengthRight); endTime = calendar.getTime(); } if (endTime.getTime() <= startTime.getTime()) { Calendar calendar = Calendar.getInstance(); calendar.setTime(startTime); calendar.add(Calendar.MINUTE, lengthRight); endTime = calendar.getTime(); } List<String> categories = DateUtils.getTimeScale(startTime, endTime, predictItem.getGranularity()); List<String> legend = new ArrayList<>(); MmItemOutputEntity outPut = mmItemOutputService.getByItemid(predictItem.getId(), resultStr); PreDataViewRespDTO dataView = new PreDataViewRespDTO(); dataView.setItemId(predictItem.getId()); dataView.setItemName(predictItem.getItemName()); dataView.setResultstr(resultStr); dataView.setRangeH(rangeH); dataView.setRangeL(rangeL); dataView.setLimitH(limitH); dataView.setLimitL(limitL); dataView.setRealData(getHisData(outPut.getPointid(), startTime, endTime)); dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime)); switch (lineType) { case TN: dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), startTime, endTime)); break; case TL: dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), predictTime, endTime)); dataView.setPreDataL(mmItemResultLastPointService.getData(outPut.getId(), startTime, endTime)); break; default: break; } result.setStartTime(startTime); result.setEndTime(endTime); result.setCategories(categories); result.setLegend(legend); result.setDataView(dataView); return result; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
@@ -82,10 +82,10 @@ @PermitAll @GetMapping("/predict-data/single-chart") @Operation(summary = "预测数据图表") public CommonResult<PreDataItemChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest public CommonResult<PreDataSingleChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception { apiSecurityUtils.validate(request); PreDataItemChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO); PreDataSingleChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO); return CommonResult.success(respVO); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java
@@ -21,4 +21,23 @@ String MDK_STATUS_CODE = "status_code"; String MDK_STATUS_100 = "100"; String RANGE_H = "RANGE_H"; String RANGE_L = "RANGE_L"; String LIMIT_H = "LIMIT_H"; String LIMIT_L = "LIMIT_L"; String ITEM_CODE = "ITEM_CODE"; String RESULT_STR = "RESULT_STR"; String LENGTH_LEFT = "LENGTH_LEFT"; String LENGTH_RIGHT = "LENGTH_RIGHT"; // 趋势预测曲线类型,0:展示T+N,1:展示T+L, String LINE_TYPE = "LINE_TYPE"; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/PreLineTypeEnum.java
对比新文件 @@ -0,0 +1,32 @@ package com.iailab.module.model.common.enums; import lombok.AllArgsConstructor; import lombok.Getter; /** * @author PanZhibao * @Description * @createTime 2024年11月18日 */ @Getter @AllArgsConstructor public enum PreLineTypeEnum { TN("0", "T+N"), TL("1", "T+L"); private String code; private String desc; public static PreLineTypeEnum getEumByCode(String code) { if (code == null) { return null; } for (PreLineTypeEnum statusEnum : PreLineTypeEnum.values()) { if (statusEnum.getCode().equals(code)) { return statusEnum; } } return null; } } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java
@@ -1,5 +1,6 @@ package com.iailab.module.model.framework.rpc.config; import com.iailab.module.data.api.ind.IndItemApi; import com.iailab.module.data.api.plan.PlanItemApi; import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.infra.api.config.ConfigApi; @@ -9,6 +10,6 @@ import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) @EnableFeignClients(clients = {DataPointApi.class, PlanItemApi.class, ConfigApi.class, TenantApi.class, AdminUserApi.class}) @EnableFeignClients(clients = {DataPointApi.class, PlanItemApi.class, IndItemApi.class, ConfigApi.class, TenantApi.class, AdminUserApi.class}) public class RpcConfiguration { } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmModelParamService.java
@@ -12,5 +12,9 @@ void saveList(List<MmModelParamEntity> list); List<MmModelParamEntity> getByModelidFromCatch(String modelId); List<MmModelParamEntity> getByModelid(String modelid); void clearCache(); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
@@ -30,6 +30,8 @@ ItemVO getItemById(String itemId); void clearCatch(); MergeItemVO getMergeItemByItemId(String itemId); PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictModelService.java
@@ -16,6 +16,8 @@ void update(MmPredictModelEntity predictModel); MmPredictModelEntity getInfoFromCatch(String id); MmPredictModelEntity getInfo(String id); BigDecimal getSampleLength(String id); @@ -23,4 +25,6 @@ List<MmPredictModelEntity> getNoSettingmapPredictModel(Map<String, Object> params); List<MmPredictModelEntity> getActiveModelByItemId(String itemId); void clearCache(); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
@@ -8,8 +8,10 @@ import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -32,9 +34,16 @@ 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())); List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class); if (CollectionUtils.isEmpty(valueList)) { return result; } Calendar calendar = Calendar.getInstance(); calendar.setTime(predictTime); valueList.forEach(value -> { Object[] dv = { calendar.getTime(), value}; calendar.add(Calendar.MINUTE, 1); result.add(dv); }); return result; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java
@@ -75,7 +75,10 @@ resultJson.setId(UUID.randomUUID().toString()); resultJson.setOutputid(entry.getKey()); resultJson.setPredicttime(predictTime); resultJson.setJsonvalue(JSONArray.toJSONString(entry.getValue())); List<Double> jsonValueList = entry.getValue().stream().map(valueVO -> { return valueVO.getDataValue(); }).collect(Collectors.toList()); resultJson.setJsonvalue(JSONArray.toJSONString(jsonValueList)); Map<String, Object> map4 = new HashMap(2); map4.put("TABLENAME", "T_MM_ITEM_RESULT_JSON"); map4.put("entity", resultJson); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelParamServiceImpl.java
@@ -2,8 +2,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao; import com.iailab.module.model.mcs.pre.dao.MmModelParamDao; import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity; import com.iailab.module.model.mcs.pre.service.MmModelParamService; @@ -11,9 +9,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.*; import java.util.concurrent.ConcurrentHashMap; /** * @author PanZhibao @@ -24,6 +21,8 @@ @Autowired private MmModelParamDao mmModelParamDao; private static Map<String, List<MmModelParamEntity>> modelInputParamMap = new ConcurrentHashMap<>(); @Override public void saveList(List<MmModelParamEntity> list) { @@ -34,9 +33,31 @@ item.setId(UUID.randomUUID().toString()); mmModelParamDao.insert(item); }); // 清空缓存 clearCache(); } @Override public void clearCache() { modelInputParamMap.clear(); } @Override public List<MmModelParamEntity> getByModelidFromCatch(String modelId) { if (!modelInputParamMap.containsKey(modelId)) { List<MmModelParamEntity> list = getByModelid(modelId); if (list != null) { modelInputParamMap.put(modelId, list); } else { return null; } } return modelInputParamMap.get(modelId); } @Override public List<MmModelParamEntity> getByModelid(String modelid) { QueryWrapper<MmModelParamEntity> queryWrapper = new QueryWrapper(); queryWrapper.eq("modelid", modelid); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -58,6 +58,8 @@ @Autowired private MmPredictItemDao mmPredictItemDao; private static HashMap<String, ItemVO> itemVOHashMap = new HashMap<>(); @Override public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) { IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO); @@ -127,6 +129,9 @@ e.setItemid(predictItem.getId()); }); mmItemOutputService.saveMmItemOutput(mmItemOutput); // 清空缓存 clearCatch(); } @DSTransactional(rollbackFor = Exception.class) @@ -166,6 +171,9 @@ e.setItemid(predictItem.getId()); }); mmItemOutputService.saveMmItemOutput(mmItemOutput); // 清空缓存 clearCatch(); } @DSTransactional(rollbackFor = Exception.class) @@ -175,6 +183,9 @@ mmPredictMergeItemService.deleteBatch(itemIds); mmPredictModelService.deleteBatch(itemIds); mmItemOutputService.deleteBatch(itemIds); // 清空缓存 clearCatch(); } @Override @@ -235,17 +246,25 @@ } @Override public void clearCatch() { itemVOHashMap.clear(); } @Override public ItemVO getItemById(String itemId) { if (StringUtils.isBlank(itemId)) { return null; } Map<String, Object> params = new HashMap(1); params.put("ITEMID", itemId); List<ItemVO> list = mmPredictItemDao.getItem(params); if (CollectionUtils.isEmpty(list)) { return null; if (!itemVOHashMap.containsKey(itemId)) { Map<String, Object> params = new HashMap<>(1); params.put("ITEMID", itemId); List<ItemVO> list = mmPredictItemDao.getItem(params); if (CollectionUtils.isEmpty(list)) { return null; } itemVOHashMap.put(itemId, list.get(0)); } return list.get(0); return itemVOHashMap.get(itemId); } @Override iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java
@@ -12,9 +12,11 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; /** * @author PanZhibao @@ -25,15 +27,36 @@ @Autowired private MmPredictModelDao mmPredictModelDao; private static Map<String, MmPredictModelEntity> modelEntityMap = new ConcurrentHashMap<>(); @Override public void savePredictModel(MmPredictModelEntity predictModel) { predictModel.setId(UUID.randomUUID().toString()); mmPredictModelDao.insert(predictModel); clearCache(); } @Override public void update(MmPredictModelEntity predictModel) { this.updateById(predictModel); clearCache(); } @Override public MmPredictModelEntity getInfoFromCatch(String id) { if (!modelEntityMap.containsKey(id)) { MmPredictModelEntity modelEntity = getInfo(id); if (modelEntity != null) { modelEntityMap.put(id, modelEntity); } } return modelEntityMap.get(id); } @Override public void clearCache() { modelEntityMap.clear(); } @Override @@ -57,6 +80,7 @@ QueryWrapper<MmPredictModelEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.in("itemid", itemIds); mmPredictModelDao.delete(queryWrapper); clearCache(); } public MmPredictModelEntity getByItemid(String itemid) { iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ModelEntityFactory.java
文件已删除 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
@@ -1,9 +1,9 @@ package com.iailab.module.model.mdk.sample; import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity; import com.iailab.module.model.mcs.pre.service.MmModelParamService; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; import com.iailab.module.model.mcs.pre.service.MmPredictModelService; import com.iailab.module.model.mdk.factory.ItemEntityFactory; import com.iailab.module.model.mdk.factory.ModelEntityFactory; import com.iailab.module.model.mdk.sample.dto.ColumnItem; import com.iailab.module.model.mdk.sample.dto.ColumnItemPort; import com.iailab.module.model.mdk.sample.dto.SampleInfo; @@ -27,10 +27,10 @@ private MmPredictModelService mmPredictModelService; @Autowired private ModelEntityFactory modelEntityFactory; private MmModelParamService mmModelParamService; @Autowired private ItemEntityFactory itemEntityFactory; private MmPredictItemService mmPredictItemService; @Override public SampleInfo prepareSampleInfo(String modelId, Date predictTime) { @@ -85,7 +85,7 @@ List<ColumnItem> columnItemList = new ArrayList<>(); ColumnItem columnInfo = new ColumnItem(); ColumnItemPort curPort = new ColumnItemPort(); //当前端口 List<MmModelParamEntity> modelInputParamEntityList = modelEntityFactory.getModelInputParam(modelId); List<MmModelParamEntity> modelInputParamEntityList = mmModelParamService.getByModelidFromCatch(modelId); if (CollectionUtils.isEmpty(modelInputParamEntityList)) { return null; } @@ -135,7 +135,7 @@ */ @Override protected Integer getSampleCycle(String modelId) { return itemEntityFactory.getItemById(modelEntityFactory.getModelEntity(modelId).getItemid()).getGranularity(); return mmPredictItemService.getItemById(mmPredictModelService.getInfoFromCatch(modelId).getItemid()).getGranularity(); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
@@ -1,13 +1,16 @@ package com.iailab.module.model.mdk.sample; import com.iailab.module.data.api.ind.IndItemApi; import com.iailab.module.data.api.ind.dto.ApiIndItemDTO; import com.iailab.module.data.api.plan.PlanItemApi; import com.iailab.module.data.api.plan.dto.ApiPlanItemDTO; import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.data.api.point.dto.ApiPointDTO; import com.iailab.module.data.enums.DataPointFreqEnum; import com.iailab.module.data.enums.TimeGranularityEnum; import com.iailab.module.data.enums.TimeGranularitySecEnum; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; import com.iailab.module.model.mdk.common.enums.ModelParamType; import com.iailab.module.model.mdk.factory.ItemEntityFactory; import com.iailab.module.model.mdk.sample.dto.ColumnItem; import com.iailab.module.model.mdk.sample.dto.ColumnItemPort; import com.iailab.module.model.mdk.sample.dto.SampleInfo; @@ -28,10 +31,13 @@ private DataPointApi dataPointApi; @Autowired private ItemEntityFactory itemEntityFactory; private PlanItemApi planItemApi; @Autowired private PlanItemApi planItemApi; private IndItemApi indItemApi; @Autowired private MmPredictItemService mmPredictItemService; /** * prepareSampleInfo @@ -142,20 +148,23 @@ * @throws Exception */ protected Integer getGranularity(ColumnItem columnItem) { // 默认60s Integer granularity = 60; switch (columnItem.getParamType()) { case "DATAPOINT": switch (ModelParamType.getEumByCode(columnItem.getParamType())) { case DATAPOINT: ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId()); granularity = DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue(); break; case "PREDICTITEM": granularity = itemEntityFactory.getItemById(columnItem.getParamId()).getGranularity(); case PREDICTITEM: granularity = mmPredictItemService.getItemById(columnItem.getParamId()).getGranularity(); break; case "IND-HIS": granularity = 60; case IND: ApiIndItemDTO indItemDTO = indItemApi.getInfoById(columnItem.getParamId()); granularity = TimeGranularitySecEnum.getEumByCode(indItemDTO.getTimeGranularity()).getValue();; break; case "IND-PLAN": granularity = 60; case PLAN: ApiPlanItemDTO apiPlanItemDTO = planItemApi.getInfoById(columnItem.getParamId()); granularity = TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue(); break; default: break; iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/dto/ColumnItem.java
@@ -55,7 +55,7 @@ public Date endTime; /** * 采样粒度,s * 采样粒度 */ public int granularity; public Integer granularity; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java
@@ -26,4 +26,6 @@ ChartParamEntity get(String id); void delete(String id); Map<String, String> getByChartId(String chartId); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java
@@ -22,4 +22,6 @@ ChartEntity get(String id); void delete(String id); Map<String, String> getByChartCode(String chartCode); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java
@@ -13,10 +13,9 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.Date; import java.util.Map; import java.util.UUID; import java.util.*; /** * @description: @@ -56,6 +55,21 @@ } @Override public Map<String, String> getByChartId(String chartId) { Map<String, String> result = new HashMap<>(); Map<String, Object> params = new HashMap<String, Object>(1); params.put("chartId", chartId); List<ChartParamEntity> list = baseDao.selectList(getWrapper(params)); if (CollectionUtils.isEmpty(list)) { return result; } list.forEach(item -> { result.put(item.getParamCode(), item.getParamValue()); }); return result; } @Override public void delete(String id) { baseDao.deleteById(id); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java
@@ -5,20 +5,18 @@ import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.module.model.mpk.dao.ChartDao; import com.iailab.module.model.mpk.dao.ChartParamDao; import com.iailab.module.model.mpk.dto.ChartDTO; import com.iailab.module.model.mpk.dto.ChartParamDTO; import com.iailab.module.model.mpk.entity.ChartEntity; import com.iailab.module.model.mpk.entity.ChartParamEntity; import com.iailab.module.model.mpk.service.ChartParamService; import com.iailab.module.model.mpk.service.ChartService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.Date; import java.util.Map; import java.util.UUID; import java.util.*; /** * @description: @@ -28,6 +26,9 @@ @Slf4j @Service public class ChartServiceImpl extends BaseServiceImpl<ChartDao, ChartEntity> implements ChartService { @Autowired private ChartParamService chartParamService; @Override public PageData<ChartDTO> page(Map<String, Object> params) { @@ -71,4 +72,16 @@ .like(StringUtils.isNotBlank(chartCode), "chart_code", chartCode); return wrapper; } @Override public Map<String, String> getByChartCode(String chartCode) { Map<String, String> result = new HashMap<>(); QueryWrapper<ChartEntity> wrapper = new QueryWrapper<>(); wrapper.eq("chart_code", chartCode); ChartEntity entity = baseDao.selectOne(wrapper); if (entity != null) { return result; } return chartParamService.getByChartId(entity.getId()); } }