From a440ec3bfaa1363f5841100b8948d852971a2eb1 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 10 十二月 2024 13:19:58 +0800 Subject: [PATCH] MmPredictAlarmConfigService --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java | 52 +++++++++++++++++++++++++--------------------------- 1 files changed, 25 insertions(+), 27 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java index 03e3c52..99455b0 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java @@ -3,6 +3,7 @@ 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; @@ -31,32 +32,6 @@ @Autowired private MmItemResultDao mmItemResultDao; - - @Override - public List<MmItemResultEntity> getListByOutputId(String outputid, Map<String, Object> params) { - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date startDateParam = null; - try { - startDateParam = sdf.parse((String)params.get("startTime")); - } catch (ParseException e) { - e.printStackTrace(); - } - Date endDateParam = null; - try { - endDateParam = sdf.parse((String)params.get("endTime")); - } catch (ParseException e) { - e.printStackTrace(); - } - - List<MmItemResultEntity> list = mmItemResultDao.selectList( - new QueryWrapper<MmItemResultEntity>() - .eq("outputid", outputid) - .between("datatime", startDateParam, endDateParam) - .orderByAsc("datatime") - ); - return list; - } @Override public void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime) { @@ -100,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); @@ -140,4 +118,24 @@ }).collect(Collectors.toList()); return result; } + + @Override + public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat) { + 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(), timeFormat); + dataItem[1] = item.getDatavalue().setScale(2, BigDecimal.ROUND_HALF_UP); + result.add(dataItem); + }); + return result; + } } -- Gitblit v1.9.3