SysCommandCentreController.java
20.2 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
package com.skua.modules.dataAnalysis.controller;
import com.skua.common.constant.ReportConstant;
import com.skua.common.report.vo.ReportItemVO;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.dataAnalysis.service.ICommandCentreService;
import com.skua.modules.algorithm.service.impl.ReportItemvService;
import com.skua.modules.algorithm.vo.DepartLoadRateResultVO;
import com.skua.modules.algorithm.vo.StackedAreaChartDataVO;
import com.skua.modules.algorithm.vo.WaterTreatmentVO;
import com.skua.modules.common.vo.DateVO;
import com.skua.modules.equipment.vo.EquipmentRepairAnalysisVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.report.vo.DepartDrugResult;
import com.skua.modules.report.vo.FRportlCommandCenterVO;
import com.skua.modules.report.vo.ReportDateTrendVO;
import com.skua.modules.report.vo.ReportItemvParam;
import com.skua.modules.report.vo.largeScreen.ResultNumberVO;
import com.skua.modules.system.service.ISysFactoryInfoService;
import com.skua.tool.util.DateUtils;
import com.skua.tool.util.JSUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 统计功能配置表
*/
@Slf4j
@Api(tags="指挥中心")
@RestController
@RequestMapping("/v1/algorithm/commandCentre")
public class SysCommandCentreController {
@Autowired
private ISysFactoryInfoService factoryInfoService;
@Autowired
private ICommandCentreService commandCentreService;
@Autowired
private ReportItemvService reportItemvService;
@Autowired
private IFCustomReportDatasetService reportDatasetService;
/**
* 分页列表查询
* @return
*/
@AutoLog(value = "指挥中心-水量查询")
@ApiOperation(value="指挥中心-水量查询", notes="指挥中心-水量查询")
@GetMapping(value = "/statisticsByWaterData")
public Result<List<FRportlCommandCenterVO>> statisticsByWaterData(ReportItemvParam reportItemvParam) {
Result<List<FRportlCommandCenterVO> > result = new Result<>();
List<FRportlCommandCenterVO> fReportItemvList = new ArrayList<>();//返回集合对象
DateVO dateVO = new DateVO(reportItemvParam.getStartDate());
String departIds = BaseContextHandler.getDeparts();
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
//本月数据
String monthCSL = reportItemvService.getSumCSL(departIds, dateVO.getNowMonthStartDate(), dateVO.getNowMonthEndDate());
//环比 上月数据
String lastMonthCSL = reportItemvService.getSumCSL(departIds, dateVO.getNowMonthStartDate(), dateVO.getNowMonthEndDate());
//同比 去年数据
String lastYearCSL = reportItemvService.getSumCSL(departIds, dateVO.getLastYearMonthStartTime(), dateVO.getLastYearMonthEndTime());
long nowDifferDay = DateUtils.differenceDay(dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
long lastMonthDifferDay = DateUtils.differenceDay(dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
long lastYearDifferDay = DateUtils.differenceDay(dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
//月对象数据 value, valueTb, valueHb
FRportlCommandCenterVO monthDataVO = new FRportlCommandCenterVO("月汇总数据",JSUtils.divide(monthCSL,10000),JSUtils.divide(lastMonthCSL,10000),JSUtils.divide(lastYearCSL,10000));
//日处理对象
FRportlCommandCenterVO avgDayDataVO = new FRportlCommandCenterVO("日均处理水量",JSUtils.divide(monthCSL,nowDifferDay*10000),JSUtils.divide(lastMonthCSL,lastMonthDifferDay*10000),JSUtils.divide(lastYearCSL,lastYearDifferDay*10000));
fReportItemvList.add( monthDataVO);
fReportItemvList.add( avgDayDataVO );
//年数据统计:
String total = factoryInfoService.querySumProScale();
total = String.format("%.2f", Double.parseDouble(total));
fReportItemvList.add( new FRportlCommandCenterVO( total,"0","0"));
result.setSuccess(true);
result.setResult(fReportItemvList);
return result;
}
@AutoLog(value = "指挥中心-运行负荷率分析")
@ApiOperation(value="指挥中心-运行负荷率分析", notes="指挥中心-运行负荷率分析")
//指挥中心-运行负荷率分析
@GetMapping(value = "/statisticsByLoadRate")
public Result<DepartLoadRateResultVO > statisticsByLoadRate(ReportItemvParam reportItemvParam) {
Result<DepartLoadRateResultVO > result = new Result<>();
String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
Integer loadRateType = reportItemvParam.getLoadRateType();
if(loadRateType == null ) loadRateType = 1;
DepartLoadRateResultVO departLoadRateResultVO = reportItemvService.statisticsByLoadRate( departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate(), loadRateType);
result.setSuccess(true);
result.setResult(departLoadRateResultVO);
return result;
}
//指挥中心----运行负荷率分析----处理水量详情
@AutoLog(value = "指挥中心-处理水量详情")
@ApiOperation(value="指挥中心-处理水量详情")
@GetMapping("/getCLSLXQ")
public Result<List<WaterTreatmentVO>> getCLSLXQ(ReportItemvParam reportItemvParam){
Result<List<WaterTreatmentVO>> result = new Result<>();
String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
List<WaterTreatmentVO> waterTrendVOList = commandCentreService.statisticsCLSLXQ(reportItemvParam.getStartDate(),reportItemvParam.getEndDate(), departIds);
result.setResult(waterTrendVOList );
return result;
}
//cement水泥 electricity
@AutoLog(value = "指挥中心-泥量统计")
@ApiOperation(value="指挥中心-泥量统计", notes="指挥中心-泥量统计")
@GetMapping(value = "/statisticsByCement")
public Result<List<FRportlCommandCenterVO>> statisticsByCement(ReportItemvParam reportItemvParam) {
Result<List<FRportlCommandCenterVO>> result = new Result();
String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
List<FRportlCommandCenterVO> dataList = reportItemvService.statisticsByCement(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
result.setResult(dataList );
return result;
}
@AutoLog(value = "指挥中心-泥量统计")
@ApiOperation(value="指挥中心-泥量统计--详情列表", notes="指挥中心-泥量统计--详情列表")
//指挥中心-泥量统计--详情列表
@GetMapping(value = "/statisticsByCementList")
public Result<List<ReportItemVO>> statisticsByCementList(ReportItemvParam reportItemvParam) {
Result<List<ReportItemVO>> result = new Result();
String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
List<ReportItemVO> dataList = reportItemvService.statisticsByCementList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
result.setResult(dataList );
return result;
}
@AutoLog(value = "消减量(同比、环比)")
@ApiOperation(value="消减量(同比、环比)", notes="消减量(同比、环比)")
@GetMapping(value = "/xjlByTbHb")
public Result<List<ResultNumberVO>> queryXjlByTbHb(String departId , String startDate, String endDate) {
Result<List<ResultNumberVO>> result = new Result();
String departIds = departId;
if(StringUtils.isEmpty(departId)){
departIds = BaseContextHandler.getDeparts();
}
List<ResultNumberVO> dataList = reportDatasetService.queryXjlByTbHb(departId,startDate,endDate);
result.setResult(dataList);
return result;
}
@AutoLog(value = "指挥中心-药耗分析")
@ApiOperation(value="指挥中心-药耗分析", notes="指挥中心-药耗分析")
@GetMapping(value = "/statisticsByYhfx")
public Result<List<FRportlCommandCenterVO>> statisticsByYh(ReportItemvParam reportItemvParam) {
Result<List<FRportlCommandCenterVO>> result = new Result();
String departId = BaseContextHandler.getDeparts();
if(reportItemvParam.getDepartIds()!=null){
departId = reportItemvParam.getDepartIds();
}
List<FRportlCommandCenterVO> dataList = reportItemvService.statisticsByYh(departId,reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
result.setResult(dataList);
return result;
}
//cement水泥 electricity
@AutoLog(value = "指挥中心-能耗分析")
@ApiOperation(value="指挥中心-能耗分析", notes="指挥中心-能耗分析")
@GetMapping(value = "/statisticsByElectricity")
public Result<List<FRportlCommandCenterVO>> statisticsByElectricity(ReportItemvParam reportItemvParam) {
Result<List<FRportlCommandCenterVO>> result = new Result();
String departId = BaseContextHandler.getDeparts();
if(reportItemvParam.getDepartIds()!=null){
departId = reportItemvParam.getDepartIds();
}
List<FRportlCommandCenterVO> dataList = reportItemvService.statisticsByElectricity(departId,reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
result.setResult(dataList );
return result;
}
@AutoLog(value = "指挥中心-能耗分析(新)")
@ApiOperation(value="指挥中心-能耗分析(新)", notes="指挥中心-能耗分析(新)")
@GetMapping(value = "/statisticsByElectricityNew")
public Result<List<FRportlCommandCenterVO>> statisticsByElectricityNew(ReportItemvParam reportItemvParam) {
Result<List<FRportlCommandCenterVO>> result = new Result();
String departId = BaseContextHandler.getDeparts();
if(reportItemvParam.getDepartIds()!=null){
departId = reportItemvParam.getDepartIds();
}
List<FRportlCommandCenterVO> dataList = reportItemvService.statisticsByElectricityNew(departId,reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
result.setResult(dataList );
return result;
}
@AutoLog(value = "指挥中心-能耗分析")
@ApiOperation(value="指挥中心-能耗分析--详情列表", notes="指挥中心-能耗分析--详情列表")
@GetMapping(value = "/statisticsByElectricityList")
public Result<List<ReportItemVO>> statisticsByElectricityList(ReportItemvParam reportItemvParam) {
Result<List<ReportItemVO>> result = new Result();
String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
List<ReportItemVO> dataList = reportItemvService.statisticsByElectricityList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
result.setResult(dataList );
return result;
}
@AutoLog(value = "指挥中心-水量电耗趋势")
@ApiOperation(value="指挥中心-水量电耗趋势", notes="指挥中心-水量电耗趋势")
@GetMapping(value = "/statisticsBySewage")
public Result<StackedAreaChartDataVO> statisticsBySewage(ReportItemvParam reportItemvParam) {
List<String > dateList = new ArrayList<>();//日期数据
List<String> electricityList = new ArrayList<>();//电能数据数据;
List<String> waterList = new ArrayList<>();// 水集合
List<String> consumeList = new ArrayList<>();//电耗集合
String departIds = BaseContextHandler.getDeparts();
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
List<ReportDateTrendVO> dlhjDateList = reportItemvService.getDayDateFieldList(ReportConstant.view3a24, "DLHJ", departIds, reportItemvParam.getStartDate(), reportItemvParam.getEndDate());
List<ReportDateTrendVO> cslDateList = reportItemvService.getDayDateFieldList(ReportConstant.view2119, "CSL", departIds, reportItemvParam.getStartDate(), reportItemvParam.getEndDate());
List<String > dateTimeList = DateUtil.getInstance().getBetweenDate(reportItemvParam.getStartDate(),reportItemvParam.getEndDate(),null);
String dlhj = null; String csl = null; String dh = null;
if(dateTimeList != null){
for(String dateTime : dateTimeList){
csl = null;
dlhj = null;
dateList.add( DateUtil.getInstance().formatDate(dateTime,"MM-dd") ) ;
//水
if( cslDateList != null ){
for(ReportDateTrendVO cslVo : cslDateList){
if(dateTime.equals(cslVo.getTime())){
csl = cslVo.getValue();
break;
}
}
}
waterList.add(JSUtils.divide(csl,10000));
//电
if( dlhjDateList != null ){
for(ReportDateTrendVO dlhjVo : dlhjDateList){
if(dateTime.equals(dlhjVo.getTime())){
dlhj = dlhjVo.getValue();
break;
}
}
}
electricityList.add(JSUtils.divide(dlhj,10000));
//电耗
consumeList.add(JSUtils.divide(JSUtils.divide(dlhj,csl),10000) );
}
}
StackedAreaChartDataVO stackedAreaChartDataVO = new StackedAreaChartDataVO();
stackedAreaChartDataVO.setElectricityList(electricityList);//电集合
stackedAreaChartDataVO.setWaterList(waterList);//水集合
stackedAreaChartDataVO.setConsumeList( consumeList);//电耗集合
stackedAreaChartDataVO.setDateList(dateList );//日期集合
stackedAreaChartDataVO.setXAxis(dateList);
List<String> yaXisList = new ArrayList<String>();
yaXisList.addAll(electricityList ) ;//电
yaXisList.addAll( waterList) ;//水
yaXisList.addAll(consumeList ) ;//电耗
stackedAreaChartDataVO.setYAxis( yaXisList );
Result<StackedAreaChartDataVO> result = new Result<>();
result.setSuccess(true);
result.setResult(stackedAreaChartDataVO);
return result;
}
@AutoLog(value = "指挥中心-费用趋势")
@ApiOperation(value="指挥中心-费用趋势", notes="指挥中心-费用趋势")
@GetMapping(value = "/statisticsByFy")
public Result<StackedAreaChartDataVO> statisticsByFy(ReportItemvParam reportItemvParam) {
//费用
String startDate = reportItemvParam.getStartDate();
String endDate = reportItemvParam.getEndDate();
reportItemvParam.setStartDate( DateUtils.formatDate(startDate ,"YYYY-MM"));
reportItemvParam.setEndDate( DateUtils.formatDate(endDate ,"YYYY-MM"));
String departIds = BaseContextHandler.getDeparts();
if(reportItemvParam.getDepartIds()!=null){
departIds = reportItemvParam.getDepartIds();
}
reportItemvParam.setDepartIds( JSUtils.quoteEach(departIds,","));
List<ReportDateTrendVO> fyDataList = commandCentreService.getFyData(reportItemvParam);
List<ReportDateTrendVO> waterDataList = reportItemvService.getDateFieldList(ReportConstant.view2119,"CSL", departIds, startDate,endDate);
//水集合
List<String> fyList = new ArrayList<>();//电能数据数据;
List<String> waterList = new ArrayList<>();// 水集合
List<String> dateTimeList = getMonthsBetween(startDate,endDate);
for(String dateTime : dateTimeList){
if(fyDataList != null ){
for( ReportDateTrendVO dateTrendVO : fyDataList){
if( dateTime.equals( dateTrendVO.getTime() )){
fyList.add(ConvertUtils.getString( dateTrendVO.getValue() ,"0")) ;
break;
}
}
}
if(waterDataList != null ){
for( ReportDateTrendVO dateTrendVO : waterDataList){
if( dateTime.equals( dateTrendVO.getTime() )){
waterList.add(ConvertUtils.getString( dateTrendVO.getValue() ,"0")) ;
break;
}
}
}
}
StackedAreaChartDataVO stackedAreaChartDataVO = new StackedAreaChartDataVO();
stackedAreaChartDataVO.setElectricityList(fyList);//费用集合
stackedAreaChartDataVO.setWaterList(waterList);//水集合
stackedAreaChartDataVO.setDateList(dateTimeList);//日期集合
stackedAreaChartDataVO.setXAxis(dateTimeList);
List<String> yaXisList = new ArrayList<String>();
yaXisList.addAll(fyList) ;//费用
yaXisList.addAll(waterList) ;//水
stackedAreaChartDataVO.setYAxis( yaXisList );
Result<StackedAreaChartDataVO> result = new Result<>();
result.setSuccess(true);
result.setResult(stackedAreaChartDataVO);
return result;
}
@AutoLog(value = "指挥中心-药剂趋势")
@ApiOperation(value="指挥中心-药剂趋势", notes="指挥中心-药剂趋势")
@GetMapping(value = "/statisticsByYjqs")
public Result<DepartDrugResult> statisticsByYjqs(@RequestParam(name = "month", required = true)String month) {
DateVO dateVO = new DateVO(month);
DepartDrugResult departDrugResult = commandCentreService.getYhTotal(dateVO.getNowMonth());
Result<DepartDrugResult> result = new Result<>();
result.setSuccess(true);
result.setResult(departDrugResult);
return result;
}
//EquipmentRepairAnalysisVO
@AutoLog(value = "指挥中心-设备维修维护费用统计")
@ApiOperation(value="指挥中心-设备维修维护费用统计", notes="指挥中心-设备维修维护费用统计")
@GetMapping(value = "/statisticsBySbwx")
public Result<Map<String,Object>> equipmentRepairAnalysis(String startDate, String endDate) {
Map<String,Object> dataMap = commandCentreService.equipmentRepairAnalysis(startDate,endDate);
Result<Map<String,Object>> result = new Result<>();
result.setSuccess(true);
result.setResult(dataMap);
return result;
}
/**
* 获取时间之间的月份
* @param start
* @param end
* @return
*/
private List<String> getMonthsBetween(String start, String end) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 解析日期
LocalDate startDate = LocalDate.parse(start, formatter);
LocalDate endDate = LocalDate.parse(end, formatter);
List<String> months = new ArrayList<>();
// 获取起始和结束月份
YearMonth startMonth = YearMonth.from(startDate);
YearMonth endMonth = YearMonth.from(endDate);
// 遍历月份并添加到列表
YearMonth currentMonth = startMonth;
while (!currentMonth.isAfter(endMonth)) {
months.add(currentMonth.toString()); // 格式化为 yyyy-MM
currentMonth = currentMonth.plusMonths(1);
}
return months;
}
}