tangzy
2022-07-21 a98b1db4392c357304036e8b3cdd01646920300d
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.regionWeight.service.impl;
 
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.modules.regionWeight.entity.PptnR;
import org.springblade.modules.regionWeight.entity.RegionWeight;
import org.springblade.modules.regionWeight.excel.regionExcel;
import org.springblade.modules.regionWeight.vo.RegionWeightVO;
import org.springblade.modules.regionWeight.mapper.RegionWeightMapper;
import org.springblade.modules.regionWeight.service.IRegionWeightService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
 
/**
 *  服务实现类
 *
 * @author BladeX
 * @since 2021-05-12
 */
@Service
@DS("slaves")
public class RegionWeightServiceImpl extends ServiceImpl<RegionWeightMapper, RegionWeight> implements IRegionWeightService {
 
    @Override
    public IPage<RegionWeightVO> selectRegionWeightPage(IPage<RegionWeightVO> page, RegionWeightVO regionWeight,Long deptId) {
        return page.setRecords(baseMapper.selectRegionWeightPage(page, regionWeight,deptId));
    }
    @Override
    public IPage<RegionWeightVO> selectRegionWeights(IPage<RegionWeightVO> page, RegionWeightVO regionWeight,Long deptId) {
        return page.setRecords(baseMapper.selectRegionWeights(page, regionWeight,deptId));
    }
 
    @Override
    public List<RegionWeightVO> lazyTree(String code) {
        return  ForestNodeMerger.merge(baseMapper.lazyTree(code));
    }
 
    @Override
    public List<Map<String, Object>> selectReM(String beginTime,String endTime) {
        return baseMapper.selectReM(beginTime,endTime);
    }
 
    @Override
    public List<Map<String, Object>> selectReL(String beginTime, String endTime, String code) {
        return baseMapper.selectReL(beginTime, endTime,code);
    }
 
    @Override
    public List<Map<String, Object>> selectWeight() {
        return baseMapper.selectWeight();
    }
 
    @Override
    public List<Map<String, Object>> selectWeights() {
        return baseMapper.selectWeights();
    }
 
    @Override
    public List<Map<String, Object>> selectYjs(String beginTime,String endTime) {
        return baseMapper.selectYjs(beginTime,endTime);
    }
 
    @Override
    public List<Map<String, Object>> selectAll(String beginTime, String endTime, String code) {
        return baseMapper.selectAll(beginTime, endTime,code);
    }
 
    @Override
    public List<regionExcel> exportRegion(String beginTime, String endTime) {
        return baseMapper.exportRegion(beginTime, endTime);
    }
 
    @Override
    public List<Map<String, Object>> selectLALL() {
        return baseMapper.selectLALL();
    }
 
    @Override
    public List<Map<String, Object>> selectLNam() {
        return baseMapper.selectLNam();
    }
 
    @Override
    public List<Map<String, Object>> selectppyj(String time, String dateBegin1, String dateBegin3, String dateBegin6, String times) {
        return baseMapper.selectppyj(time, dateBegin1, dateBegin3, dateBegin6, times);
    }
 
    @Override
    public String selectCode() {
        return baseMapper.selectCode();
    }
 
    @Override
    public String selectCodeM() {
        return baseMapper.selectCodeM();
    }
 
    @Override
    public String selectCodeL() {
        return baseMapper.selectCodeL();
    }
 
    @Override
    public List<Map<String, Object>> ss(String beginTime, String endTime, String code) {
        return baseMapper.ss(beginTime, endTime, code);
    }
 
    @Override
    public List<Map<String, Object>> selectReMs(String beginTime, String endTime, String code) {
        return baseMapper.selectReMs(beginTime, endTime, code);
    }
 
    @Override
    public List<PptnR> selectDayStation(String code, String dateBegin, String dateEnd, String sd) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        List<PptnR> returnD = null;
        if (!sd.equals("1")){
            try {
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                long to = 0;
                to = df.parse(dateEnd).getTime();
                long from = df.parse(dateBegin).getTime();
                int sds = Integer.parseInt(sd);
                long jg = (long) Math.ceil((to - from) / (1000 * 60 * 60)/sds) + 1;
 
                for (int i = 0; i < jg; i++) {
                    Map<String, Object> map = new HashMap<String, Object>();
                    long q = from + (long)(60*60*1000)*(i*sds);
                    String qzsj = df.format(new Date(q));      // 时间戳转换成时间
                    long z = from + (long)(60*60*1000)*((i+1)*sds);
                    String zzsj = df.format(new Date(z));      // 时间戳转换成时间
                    map.put("day", qzsj);
                    map.put("nextday", zzsj);
                    map.put("tm",df.format(new Date(z)));
                    list.add(map);
                }
 
            } catch (ParseException e) {
                e.printStackTrace();
            }
            returnD = baseMapper.selectDayStation(code, dateBegin, dateEnd, list);
        }else{
            returnD = baseMapper.selectDayStations(code, dateBegin, dateEnd);
        }
        return returnD;
    }
 
    @Override
    public List<PptnR> selectStation(String code, String dateBegin, String dateEnd) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        try {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            long to = 0;
            to = df.parse(dateEnd).getTime();
            long from = df.parse(dateBegin).getTime();
            long jg = (to - from) / (1000 * 60 * 60 * 24) + 1;
 
            for (int i = 0; i < jg; i++) {
                Map<String, Object> map = new HashMap<String, Object>();
                long q = from + (long)(60*60*24*1000)*i;
                String qzsj = df.format(new Date(q));      // 时间戳转换成时间
                long z = from + (long)(60*60*24*1000)*(i+1);
                String zzsj = df.format(new Date(z));      // 时间戳转换成时间
                map.put("day", qzsj);
                map.put("nextday", zzsj);
                map.put("tm",df.format(new Date(q)));
                list.add(map);
            }
 
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return baseMapper.selectStation(code,dateBegin,dateEnd,list);
    }
 
    @Override
    public String selectPptnTz(String code, String dateBegin, String dateEnd) {
        return baseMapper.selectPptnTz(code, dateBegin, dateEnd);
    }
 
    @Override
    public List<Map<String, Object>> selectLy(String beginTime, String endTime, String code) {
        return baseMapper.selectLy(beginTime, endTime, code);
    }
 
 
}