| | |
| | | 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.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemResultService; |
| | |
| | | |
| | | @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) { |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Object[]> getData(String outputid, Date startTime, Date endTime) { |
| | | 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) |
| | |
| | | } |
| | | list.forEach(item -> { |
| | | Object[] dataItem = new Object[2]; |
| | | dataItem[0] = DateUtils.format(item.getDatatime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | dataItem[0] = DateUtils.format(item.getDatatime(), timeFormat); |
| | | dataItem[1] = item.getDatavalue().setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | result.add(dataItem); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void savePredictValue(Map<MmItemOutputEntity, Double> predictDoubleValues, Date predictTime) { |
| | | for (Map.Entry<MmItemOutputEntity, Double> entry : predictDoubleValues.entrySet()) { |
| | | MmItemResultJsonEntity resultJson = new MmItemResultJsonEntity(); |
| | | resultJson.setId(UUID.randomUUID().toString()); |
| | | resultJson.setOutputid(entry.getKey().getId()); |
| | | resultJson.setPredicttime(predictTime); |
| | | resultJson.setCumulant(String.valueOf(entry.getValue())); |
| | | Map<String, Object> map4 = new HashMap(2); |
| | | map4.put("TABLENAME", "T_MM_ITEM_RESULT_JSON"); |
| | | map4.put("entity", resultJson); |
| | | mmItemResultDao.savePredictJsonValue(map4); |
| | | } |
| | | } |
| | | } |