package com.moral.api.service.impl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import com.alibaba.fastjson.JSON; import com.moral.api.mapper.HistoryFiveMinutelyMapper; import com.moral.api.service.HistoryFiveMinutelyService; import com.moral.api.service.HistoryMinutelyService; import com.moral.util.DateUtils; @Service public class HistoryFiveMinutelyServiceImpl implements HistoryFiveMinutelyService { @Autowired private HistoryFiveMinutelyMapper historyFiveMinutelyMapper; @Autowired private HistoryMinutelyService historyMinutelyService; @Override public void createTable(String timeUnits) { historyFiveMinutelyMapper.createTable(timeUnits); } @Override public void insertHistoryFiveMinutely() { Map params = new HashMap<>(); //开始时间(分钟) Date start = DateUtils.convertDate(DateUtils.getDateOfMin(-5)); //结束时间(分钟) Date end = DateUtils.convertDate(new Date()); params.put("start", start); params.put("end", end); //分钟表后缀 String timeUnits = DateUtils.dateToDateString(start, DateUtils.yyyyMM_EN); params.put("timeUnits", timeUnits); //因子 params.put("sensorKeys", null); historyMinutelyService.getHistoryFiveMinutelyData(params); /*List> list = new ArrayList<>(); Map map = new HashMap<>(); map.put("mac", "123456"); Date date = new Date(); map.put("time", date); Map value = new HashMap<>(); value.put("e1", 10); value.put("e2", 20); map.put("value", JSON.toJSONString(value)); list.add(map);*/ historyFiveMinutelyMapper.insertHistoryFiveMinutely(null, null); } }