kaiyu
2021-06-24 eb51b2364e9a3fbe806fde61fa255660a098fc8b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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<String, Object> 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<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("mac", "123456");
        Date date = new Date();
        map.put("time", date);
        Map<String, Object> value = new HashMap<>();
        value.put("e1", 10);
        value.put("e2", 20);
        map.put("value", JSON.toJSONString(value));
        list.add(map);*/
 
        historyFiveMinutelyMapper.insertHistoryFiveMinutely(null, null);
    }
}