08bdd8bd 康伟

kangwei :修改reportUtils工具类

1 个父辈 62269c2c
...@@ -72,9 +72,9 @@ public class ReportViewUtil { ...@@ -72,9 +72,9 @@ public class ReportViewUtil {
72 if(!StringUtils.isEmpty(itemIds)) { 72 if(!StringUtils.isEmpty(itemIds)) {
73 itemIds = itemIds.substring(1); 73 itemIds = itemIds.substring(1);
74 } 74 }
75 sb.append("`a`.`depart_id` AS `depart_id`,`a`.`data_id` AS `id`,`a`.`data_time` AS `time` from (( "); 75 sb.append(" `a`.`depart_id` AS `depart_id`,`a`.`data_id` AS `id`,`a`.`data_time` AS `time` from (( ");
76 76
77 sb.append("SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv v WHERE 1=1 "); 77 sb.append(" SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv v WHERE 1=1 ");
78 if(StringUtils.isNotEmpty(departIds)){ 78 if(StringUtils.isNotEmpty(departIds)){
79 sb.append(" and depart_id in ("+inSqlPart+") "); 79 sb.append(" and depart_id in ("+inSqlPart+") ");
80 } 80 }
...@@ -141,16 +141,16 @@ public class ReportViewUtil { ...@@ -141,16 +141,16 @@ public class ReportViewUtil {
141 itemIds = itemIds.substring(1); 141 itemIds = itemIds.substring(1);
142 } 142 }
143 sb.append("`a`.`depart_id` AS `depart_id`,`a`.`data_id` AS `id`,`a`.`data_time` AS `time` from (( "); 143 sb.append("`a`.`depart_id` AS `depart_id`,`a`.`data_id` AS `id`,`a`.`data_time` AS `time` from (( ");
144 sb.append("SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv WHERE 1=1 "); 144 sb.append(" SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv WHERE 1=1 ");
145 if(StringUtils.isNotEmpty(departIds)){ 145 if(StringUtils.isNotEmpty(departIds)){
146 sb.append("and depart_id in ("+inSqlPart+")"); 146 sb.append(" and depart_id in ("+inSqlPart+")");
147 } 147 }
148 if(!StringUtils.isEmpty(dataTime)) { 148 if(!StringUtils.isEmpty(dataTime)) {
149 sb.append("and data_time like'"+dataTime+"%'"); 149 sb.append("and data_time like'"+dataTime+"%'");
150 } 150 }
151 sb.append("and reit_id in ("+itemIds+")"); 151 sb.append(" and reit_id in ("+itemIds+")");
152 152
153 sb.append(") `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`data_id`,`a`.`depart_id`,`a`.`data_time` order by `a`.`data_time`)"); 153 sb.append(" ) `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`data_id`,`a`.`depart_id`,`a`.`data_time` order by `a`.`data_time`)");
154 154
155 return sb.toString(); 155 return sb.toString();
156 } 156 }
...@@ -204,17 +204,17 @@ public class ReportViewUtil { ...@@ -204,17 +204,17 @@ public class ReportViewUtil {
204 sb.append("SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv WHERE 1=1 "); 204 sb.append("SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv WHERE 1=1 ");
205 205
206 if(!StringUtils.isEmpty(departIds)) { 206 if(!StringUtils.isEmpty(departIds)) {
207 sb.append(" and depart_id in ("+inSqlPart+")"); 207 sb.append(" and depart_id in ("+inSqlPart+") ");
208 } 208 }
209 if(!StringUtils.isEmpty(startTime)) { 209 if(!StringUtils.isEmpty(startTime)) {
210 sb.append("and data_time >='"+startTime+"'"); 210 sb.append(" and data_time >='"+startTime+"' ");
211 } 211 }
212 if(!StringUtils.isEmpty(endTime)) { 212 if(!StringUtils.isEmpty(endTime)) {
213 sb.append("and data_time <='"+endTime+"'"); 213 sb.append(" and data_time <='"+endTime+"' ");
214 } 214 }
215 sb.append("and reit_id in ("+itemIds+")"); 215 sb.append(" and reit_id in ("+itemIds+") ");
216 216
217 sb.append(") `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`depart_id`)"); 217 sb.append(") `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`depart_id`) ");
218 218
219 return sb.toString(); 219 return sb.toString();
220 } 220 }
......
...@@ -64,15 +64,16 @@ public class DateVO { ...@@ -64,15 +64,16 @@ public class DateVO {
64 this.nowYear = Integer.parseInt(DateUtils.dateformat(currentDate,"yyyy")); 64 this.nowYear = Integer.parseInt(DateUtils.dateformat(currentDate,"yyyy"));
65 //同比时间 65 //同比时间
66 this.lastYear = nowYear -1 ;//去年 66 this.lastYear = nowYear -1 ;//去年
67 this.lastYearMonth = DateUtils.getHbMonth(currentDate); 67 this.lastYearMonth = DateUtils.getTbMonth(this.nowMonth);
68 System.out.println(" lastYearMonth "+lastYearMonth); 68 //System.out.println(" lastYearMonth "+lastYearMonth);
69 this.lastYearMonthStartTime = lastYearMonth+"-01"; 69 this.lastYearMonthStartTime = lastYearMonth+"-01";
70 this.lastYearMonthStartTime = lastYearMonth+"-31"; 70 this.lastYearMonthEndTime = lastYearMonth+"-31";
71 this.lastYearStartDate = this.lastYear+"-01-01"; 71 this.lastYearStartDate = this.lastYear+"-01-01";
72 this.lastYearEndDate = this.lastYear+"-12-31"; 72 this.lastYearEndDate = this.lastYear+"-12-31";
73 73
74 //环比时间 74 //环比时间
75 this.lastMonth = DateUtils.getHbMonth(currentDate);// 75 this.lastMonth = DateUtils.getHbMonth(this.nowMonth);//
76 System.out.println(" lastMonth "+lastMonth);
76 this.lastMonthStartTime = lastMonth+"-01"; 77 this.lastMonthStartTime = lastMonth+"-01";
77 this.lastMonthEndTime = lastMonth+"-31"; 78 this.lastMonthEndTime = lastMonth+"-31";
78 79
......
...@@ -51,6 +51,7 @@ public class DigitalUtils { ...@@ -51,6 +51,7 @@ public class DigitalUtils {
51 if(StringUtils.isNotEmpty(val2)){ 51 if(StringUtils.isNotEmpty(val2)){
52 BigDecimal num2 = new BigDecimal(val2); 52 BigDecimal num2 = new BigDecimal(val2);
53 result = result.add( num2 ); 53 result = result.add( num2 );
54 result = result.multiply( num2).setScale(2, BigDecimal.ROUND_HALF_UP);
54 } 55 }
55 return result.toString(); 56 return result.toString();
56 } 57 }
......
...@@ -19,23 +19,51 @@ import java.util.regex.Pattern; ...@@ -19,23 +19,51 @@ import java.util.regex.Pattern;
19 */ 19 */
20 public class JSUtils { 20 public class JSUtils {
21 21
22 // 表达式字符合法性校验正则模式,静态常量化可以降低每次使用都要编译地消耗 22 public static String add(Object obj1 , Object obj2){
23 private static final Pattern EXPRESSION_PATTERN = Pattern.compile("[0-9\\.+-/*()= ]+"); 23 String expression = obj1+ "+" + obj2;
24 // 运算符优先级map 24 return executeExpression(expression,"0.00");
25 private static final Map<String, Integer> OPT_PRIORITY_MAP = new HashMap<String, Integer>() { 25 }
26 private static final long serialVersionUID = 6968472606692771458L; 26 public static String subtract(Object obj1 , Object obj2){
27 { 27 String expression = obj1+ "-" + obj2;
28 put("(", 0); 28 return executeExpression(expression,"0.00");
29 put("+", 2); 29 }
30 put("-", 2); 30 public static String multiply(Object obj1 , Object obj2){
31 put("*", 3); 31 String expression = obj1+ "*" + obj2;
32 put("/", 3); 32 return executeExpression(expression,"0.00");
33 put(")", 7); 33 }
34 put("=", 20); 34 public static String divide(Object obj1 , Object obj2){
35 } 35 String expression = obj1+ "/" + obj2;
36 }; 36 return executeExpression(expression,"0.00");
37 }
37 38
39 /***
40 * 格式化结果,保留两位小数
41 * @param obj1
42 * @return
43 */
44 public static String format(Object obj1 ){
45 return format(obj1,null);
46 }
38 47
48 /***
49 * 格式化结果,指定格式,默认保留两位小数
50 * @param obj1
51 * @param decimalFormat
52 * @return
53 */
54 public static String format(Object obj1 , String decimalFormat){
55 String result = null;
56 try{
57 if(obj1 != null ){
58 if(decimalFormat == null ) decimalFormat = "0.00";
59 DecimalFormat df = new DecimalFormat(decimalFormat);
60 result = df.format(Double.parseDouble(obj1.toString()));
61 }
62 }catch(Exception e){
63 e.printStackTrace();
64 }
65 return result;
66 }
39 /** 67 /**
40 * 输入加减乘除表达式字符串,返回计算结果 68 * 输入加减乘除表达式字符串,返回计算结果
41 * 69 *
...@@ -50,10 +78,29 @@ public class JSUtils { ...@@ -50,10 +78,29 @@ public class JSUtils {
50 DecimalFormat df = new DecimalFormat(decimalFormat); 78 DecimalFormat df = new DecimalFormat(decimalFormat);
51 result = df.format(aDouble); 79 result = df.format(aDouble);
52 }catch(Exception e ){ 80 }catch(Exception e ){
53 // e.printStackTrace(); 81 // e.printStackTrace();
54 } 82 }
55 return result; 83 return result;
56 } 84 }
85
86 // 表达式字符合法性校验正则模式,静态常量化可以降低每次使用都要编译地消耗
87 private static final Pattern EXPRESSION_PATTERN = Pattern.compile("[0-9\\.+-/*()= ]+");
88 // 运算符优先级map
89 private static final Map<String, Integer> OPT_PRIORITY_MAP = new HashMap<String, Integer>() {
90 private static final long serialVersionUID = 6968472606692771458L;
91 {
92 put("(", 0);
93 put("+", 2);
94 put("-", 2);
95 put("*", 3);
96 put("/", 3);
97 put(")", 7);
98 put("=", 20);
99 }
100 };
101
102
103
57 public static double executeExpression(String expression) { 104 public static double executeExpression(String expression) {
58 // 非空校验 105 // 非空校验
59 if (null == expression || "".equals(expression.trim())) { 106 if (null == expression || "".equals(expression.trim())) {
......
1 package com.skua.modules.algorithm.controller; 1 package com.skua.modules.algorithm.controller;
2 2
3 import com.skua.common.report.ReportViewUtil;
3 import com.skua.core.api.vo.Result; 4 import com.skua.core.api.vo.Result;
4 import com.skua.core.aspect.annotation.AutoLog; 5 import com.skua.core.aspect.annotation.AutoLog;
5 import com.skua.core.context.BaseContextHandler; 6 import com.skua.core.context.BaseContextHandler;
7 import com.skua.core.context.SpringContextUtils;
6 import com.skua.modules.algorithm.service.ICommandCentreService; 8 import com.skua.modules.algorithm.service.ICommandCentreService;
9 import com.skua.modules.algorithm.service.impl.ReportItemvService;
7 import com.skua.modules.algorithm.vo.*; 10 import com.skua.modules.algorithm.vo.*;
11 import com.skua.modules.common.vo.DateVO;
8 import com.skua.modules.guest.util.DateUtil; 12 import com.skua.modules.guest.util.DateUtil;
9 import com.skua.modules.report.entity.FReportItemv; 13 import com.skua.modules.report.entity.FReportItemv;
10 import com.skua.modules.report.vo.*; 14 import com.skua.modules.report.vo.*;
11 import com.skua.modules.system.service.ISysConfigService; 15 import com.skua.modules.system.service.ISysConfigService;
12 import com.skua.modules.system.service.ISysFactoryInfoService; 16 import com.skua.modules.system.service.ISysFactoryInfoService;
17 import com.skua.tool.util.DateUtils;
13 import com.skua.tool.util.DigitalUtils; 18 import com.skua.tool.util.DigitalUtils;
19 import com.skua.tool.util.JSUtils;
14 import io.swagger.annotations.Api; 20 import io.swagger.annotations.Api;
15 import io.swagger.annotations.ApiOperation; 21 import io.swagger.annotations.ApiOperation;
16 import lombok.extern.slf4j.Slf4j; 22 import lombok.extern.slf4j.Slf4j;
17 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.jdbc.core.JdbcTemplate;
18 import org.springframework.web.bind.annotation.GetMapping; 25 import org.springframework.web.bind.annotation.GetMapping;
19 import org.springframework.web.bind.annotation.RequestMapping; 26 import org.springframework.web.bind.annotation.RequestMapping;
20 import org.springframework.web.bind.annotation.RestController; 27 import org.springframework.web.bind.annotation.RestController;
...@@ -33,12 +40,12 @@ import java.util.*; ...@@ -33,12 +40,12 @@ import java.util.*;
33 public class SysCommandCentreController { 40 public class SysCommandCentreController {
34 @Autowired 41 @Autowired
35 private ISysFactoryInfoService factoryInfoService; 42 private ISysFactoryInfoService factoryInfoService;
36
37 @Autowired 43 @Autowired
38 private ICommandCentreService commandCentreService; 44 private ICommandCentreService commandCentreService;
39
40 @Autowired 45 @Autowired
41 private ISysConfigService sysConfigService; 46 private ISysConfigService sysConfigService;
47 @Autowired
48 private ReportItemvService reportItemvService;
42 49
43 /** 50 /**
44 * 分页列表查询 51 * 分页列表查询
...@@ -232,96 +239,33 @@ public class SysCommandCentreController { ...@@ -232,96 +239,33 @@ public class SysCommandCentreController {
232 @GetMapping(value = "/statisticsByElectricity") 239 @GetMapping(value = "/statisticsByElectricity")
233 public Result<List<FRportlCommandCenterVO>> statisticsByElectricity( ReportItemvParam reportItemvParam) throws Exception { 240 public Result<List<FRportlCommandCenterVO>> statisticsByElectricity( ReportItemvParam reportItemvParam) throws Exception {
234 Result<List<FRportlCommandCenterVO>> result = new Result<>(); 241 Result<List<FRportlCommandCenterVO>> result = new Result<>();
235 //将jsonObject转sysAlgorithmStatisticsLibraryVO对象 242 List<FRportlCommandCenterVO> fRportlCommandCenterVOList = new ArrayList<>();
236 //SysAlgorithmStatisticsLibraryVO sysAlgorithmLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class); 243 DateVO dateVO = new DateVO(reportItemvParam.getStartDate());
237 244 //电耗
238 // String reportId = "3a243d5715b9e1a3753c180872ca0df9";//报表编号 245 String nowMonthValue = reportItemvService.getSumDLHJ(null,dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
239 // String reportItemCode = "DLHJ";//查询字段 246 String lastMonthValue = reportItemvService.getSumDLHJ(null, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
240 247 String lastYearValue = reportItemvService.getSumDLHJ(null, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
241 //报表数据项值 248 //出水量
242 String reitId = sysConfigService.queryValueByKey("REIT_ID_DLHJ"); 249 String nowMonthCSL = reportItemvService.getSumCSL(null,dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
243 250 String lastMonthCSL = reportItemvService.getSumCSL(null, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
244 //reportItemvParam.setReportItemCode(reportItemCode); 251 String lastYearCSL = reportItemvService.getSumCSL(null, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
245 // reportItemvParam.setReportId(reportId); 252
246 reportItemvParam.initData(reitId ,reportItemvParam.getStartDate() ,reportItemvParam.getEndDate()); 253 long nowDifferDay = DateUtils.differenceDay(dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
247 //ReportItemvParam reportItemvParam = new ReportItemvParam(reportId,reportItemCode ,sysAlgorithmLibraryVO.getStartDate() ,sysAlgorithmLibraryVO.getEndDate()); 254 long lastMonthDifferDay = DateUtils.differenceDay(dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
248 255 long lastYearDifferDay = DateUtils.differenceDay(dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
249 List<FRportlCommandCenterVO> fReportItemvList = new ArrayList<>();//返回集合对象 256
250 //月统计 257 //当月数据/环比、同比
251 FRportlCommandCenterVO reportMonthData = commandCentreService.getReportItemvMonthDataByReitId(reportItemvParam ); 258 FRportlCommandCenterVO nowMonthVO = new FRportlCommandCenterVO("月总电耗(", JSUtils.format(nowMonthValue), JSUtils.format(lastMonthValue), JSUtils.format(lastYearValue));
252 fReportItemvList.add( reportMonthData ); 259 //日均数据:/环比/同比
253 260 FRportlCommandCenterVO lastMonthVO = new FRportlCommandCenterVO("日均电耗",JSUtils.divide( nowMonthValue ,nowDifferDay ) ,JSUtils.divide( lastMonthValue ,lastMonthDifferDay ),JSUtils.divide( lastYearValue ,lastYearDifferDay ) );
254 FRportlCommandCenterVO reportDayData = commandCentreService.getReportItemvDayDataByReitId(reportItemvParam ); 261 //吨水消耗
255 fReportItemvList.add( reportDayData ); 262 FRportlCommandCenterVO lastYearVo = new FRportlCommandCenterVO("吨水电耗",JSUtils.divide( nowMonthValue ,nowMonthCSL ) ,JSUtils.divide( lastMonthValue ,lastMonthCSL ),JSUtils.divide( lastYearValue ,lastYearCSL ));
256 263 fRportlCommandCenterVOList.add( nowMonthVO) ;
257 //单位换算 264 fRportlCommandCenterVOList.add( lastMonthVO) ;
258 if(fReportItemvList != null && !fReportItemvList.isEmpty()){ 265 fRportlCommandCenterVOList.add( lastYearVo) ;
259 String value = null ;
260 String valueHb = null;
261 String valueTb = null;
262 for( FRportlCommandCenterVO reportDayData3 : fReportItemvList){
263 value = DigitalUtils.division(reportDayData3.getValue(),"1");
264 reportDayData3.setValue( value );
265 valueHb = DigitalUtils.division(reportDayData3.getValueHb(),"1");
266 reportDayData3.setValueHb(valueHb );
267
268 valueTb = DigitalUtils.division(reportDayData3.getValueTb(),"1");
269 reportDayData3.setValueTb( valueTb );
270 }
271 }
272 /* FReportItemv currenteportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
273 //上月数据
274 FReportItemv lastMonthReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,reportItemvParam.getLastMonthStartDate() , reportItemvParam.getLastMonthEndDate() );
275 //去年数据
276 FReportItemv lastYearReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode, reportItemvParam.getLastYearStartDate() , reportItemvParam.getLastYearEndDate() );
277
278 //整理数据
279 // SysCommandCentreResultVO commandCentreResultVO = convertSysAlgorithmStatisticsResultNumberVO(currenteportItemv , lastMonthReportItemv,lastYearReportItemv);
280 List<FRportlCommandCenterVO> fReportItemvList = arrangeFRportlCommandCenterVO(currenteportItemv , lastMonthReportItemv,lastYearReportItemv);*/
281 //
282 // FReportItemv waterCurrenteportItemv = ifReportItemvService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
283 //commandCentreResultVO.setTotalData( factoryInfoService.querySumProScale() );
284
285 //出水量 月统计、上月统计、去年同期统计
286 String waterReportId = "2119ecbf53a1d2d0708258ff67cfd9e1";//报表编号
287 String waterReportItemCode = "CSL";//查询字段
288 reportItemvParam.setReitId(waterReportId); reportItemvParam.setReportItemCode(waterReportItemCode);
289 // 出水量 月统计
290 FRportlCommandCenterVO waterReportMonthData = commandCentreService.getReportItemvMonthDataByReitId(reportItemvParam );
291
292
293 FRportlCommandCenterVO statisticsData = new FRportlCommandCenterVO("0.0","0.0","0.0");
294 //需要查询统计数据 = 公式== 电量 / 出水量
295 if(reportMonthData != null && waterReportMonthData != null){
296
297 waterReportMonthData.setValue( DigitalUtils.division( reportMonthData.getValue() , waterReportMonthData.getValue() )); // 当月统计 污泥量 / 出水量
298 waterReportMonthData.setValueTb( DigitalUtils.division( reportMonthData.getValueTb() , waterReportMonthData.getValueTb() )); // 上月同期 统计
299 waterReportMonthData.setValueHb(DigitalUtils.division( reportMonthData.getValueHb() , waterReportMonthData.getValueHb() ) ); //去年同期 统计
300 }
301 fReportItemvList.add(statisticsData);
302
303
304 /* String startDate = sysAlgorithmLibraryVO.getStartDate();
305 String endDate = sysAlgorithmLibraryVO.getEndDate();
306
307 FReportItemv currenteportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
308 //上月数据
309 FReportItemv lastMonthReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,reportItemvParam.getLastMonthStartDate() , reportItemvParam.getLastMonthEndDate() );
310 //去年数据
311 FReportItemv lastYearReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode, reportItemvParam.getLastYearStartDate() , reportItemvParam.getLastYearEndDate() );
312
313 //整理数据
314 //SysCommandCentreResultVO commandCentreResultVO = convertSysAlgorithmStatisticsResultNumberVO(currenteportItemv , lastMonthReportItemv,lastYearReportItemv);
315 List<FRportlCommandCenterVO> fReportItemvList = arrangeFRportlCommandCenterVO(currenteportItemv , lastMonthReportItemv,lastYearReportItemv);
316 // FReportItemv waterCurrenteportItemv = ifReportItemvService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
317 //commandCentreResultVO.setTotalData( factoryInfoService.querySumProScale() );
318
319 FRportlCommandCenterVO statisticsData = new FRportlCommandCenterVO();
320 //需要查询统计数据
321 fReportItemvList.add(statisticsData);*/
322 //todo 演示暂时注释 266 //todo 演示暂时注释
323 result.setSuccess(true); 267 result.setSuccess(true);
324 result.setResult(fReportItemvList); 268 result.setResult(fRportlCommandCenterVOList);
325 return result; 269 return result;
326 } 270 }
327 271
...@@ -522,29 +466,7 @@ public class SysCommandCentreController { ...@@ -522,29 +466,7 @@ public class SysCommandCentreController {
522 return result; 466 return result;
523 } 467 }
524 468
525 /** 469
526 * 获取时间之间的月份
527 * @param start
528 * @param end
529 * @return
530 */
531 public static List<String> getMonthsBetween(String start, String end) {
532 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
533 // 解析日期
534 LocalDate startDate = LocalDate.parse(start, formatter);
535 LocalDate endDate = LocalDate.parse(end, formatter);
536 List<String> months = new ArrayList<>();
537 // 获取起始和结束月份
538 YearMonth startMonth = YearMonth.from(startDate);
539 YearMonth endMonth = YearMonth.from(endDate);
540 // 遍历月份并添加到列表
541 YearMonth currentMonth = startMonth;
542 while (!currentMonth.isAfter(endMonth)) {
543 months.add(currentMonth.toString()); // 格式化为 yyyy-MM
544 currentMonth = currentMonth.plusMonths(1);
545 }
546 return months;
547 }
548 470
549 @AutoLog(value = "指挥中心-药剂趋势") 471 @AutoLog(value = "指挥中心-药剂趋势")
550 @ApiOperation(value="指挥中心-药剂趋势", notes="指挥中心-药剂趋势") 472 @ApiOperation(value="指挥中心-药剂趋势", notes="指挥中心-药剂趋势")
...@@ -569,4 +491,28 @@ public class SysCommandCentreController { ...@@ -569,4 +491,28 @@ public class SysCommandCentreController {
569 return result; 491 return result;
570 } 492 }
571 493
494 /**
495 * 获取时间之间的月份
496 * @param start
497 * @param end
498 * @return
499 */
500 private List<String> getMonthsBetween(String start, String end) {
501 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
502 // 解析日期
503 LocalDate startDate = LocalDate.parse(start, formatter);
504 LocalDate endDate = LocalDate.parse(end, formatter);
505 List<String> months = new ArrayList<>();
506 // 获取起始和结束月份
507 YearMonth startMonth = YearMonth.from(startDate);
508 YearMonth endMonth = YearMonth.from(endDate);
509 // 遍历月份并添加到列表
510 YearMonth currentMonth = startMonth;
511 while (!currentMonth.isAfter(endMonth)) {
512 months.add(currentMonth.toString()); // 格式化为 yyyy-MM
513 currentMonth = currentMonth.plusMonths(1);
514 }
515 return months;
516 }
517
572 } 518 }
......
1 package com.skua.modules.algorithm.service.impl;
2
3 import com.skua.common.report.ReportViewUtil;
4 import com.skua.core.context.SpringContextUtils;
5 import org.springframework.jdbc.core.JdbcTemplate;
6 import org.springframework.stereotype.Service;
7
8
9 /**
10 * @auther kangwei
11 * @create 2024-11-01-10:09
12 */
13 @Service("reportItemvService")
14 public class ReportItemvService {
15
16
17 String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";// 水 COD TP TN NH3H
18 String view3a24 = "3a243d5715b9e1a3753c180872ca0df9";//能耗报表
19 String view4411 = "4411ed3d78634bcdcd700f6e33724025";//生产运营周报
20
21 private JdbcTemplate getJdbcTemplate(){
22 //主库数据源
23 JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
24 return masterDB;
25 }
26
27 public String getSumCSL(String departId ,String startTime ,String endTime){
28 String dataViewName2119 = ReportViewUtil.buildViewLike(view2119,"CSL", departId, startTime,endTime);
29 String sql = "select sum(aaa.CSL) from " + dataViewName2119+ "aaa";
30 String csl = getJdbcTemplate().queryForObject(sql,String.class);
31 return csl;
32 }
33 /* public List<Map<String,Object>> getDeptCSL(String departId , String startTime , String endTime){
34
35 }*/
36
37 public String getSumDLHJ(String departId ,String startTime ,String endTime){
38 String dataViewName3a24 = ReportViewUtil.buildViewLike(view3a24,"DLHJ", departId, startTime,endTime);
39 String sql = "select sum(aaa.DLHJ) from " + dataViewName3a24+ "aaa";
40 String dlhj = getJdbcTemplate().queryForObject(sql,String.class);
41 return dlhj;
42 }
43 /* public List<Map<String,Object>> getDeptDLHJ(String departId , String startTime , String endTime){
44
45 }*/
46 }
...@@ -23,13 +23,12 @@ import javax.servlet.http.HttpServletRequest; ...@@ -23,13 +23,12 @@ import javax.servlet.http.HttpServletRequest;
23 * @create 2024-10-14-16:46 23 * @create 2024-10-14-16:46
24 */ 24 */
25 @Slf4j 25 @Slf4j
26 @Api(tags="在线考试-试卷") 26 @Api(tags="测试报表")
27 @RestController("testReportController") 27 @RestController("testReportController")
28 @RequestMapping("/web/edu/paper")
29 public class TestReportSqlController { 28 public class TestReportSqlController {
30 29
31 @AutoLog(value = "在线考试--构造填报报表视图") 30 @AutoLog(value = "测试报表")
32 @ApiOperation(value="在线考试-构造填报报表视图", notes="在线考试-构造填报报表视图") 31 @ApiOperation(value="测试报表", notes="测试报表")
33 @GetMapping(value = "/testReportSql") 32 @GetMapping(value = "/testReportSql")
34 public Result<String> testReportSql( 33 public Result<String> testReportSql(
35 @RequestParam(name="reportId") String reportId, 34 @RequestParam(name="reportId") String reportId,
......
...@@ -89,8 +89,6 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService { ...@@ -89,8 +89,6 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
89 } 89 }
90 // resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title"))); 90 // resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title")));
91 } 91 }
92
93
94 factoryInfoVOList = new ArrayList(factoryInfoMap.values()); 92 factoryInfoVOList = new ArrayList(factoryInfoMap.values());
95 93
96 // 添加:中冶数据 94 // 添加:中冶数据
...@@ -239,9 +237,12 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService { ...@@ -239,9 +237,12 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
239 StringBuffer sql = new StringBuffer("select round(aaa.CSL,2) 'csl',round(( aaa.JSCOD - aaa.CSCOD ),2) 'codxjl', round(( aaa.JSAD -aaa.CSAD ),2) 'adxjl' from "); 237 StringBuffer sql = new StringBuffer("select round(aaa.CSL,2) 'csl',round(( aaa.JSCOD - aaa.CSCOD ),2) 'codxjl', round(( aaa.JSAD -aaa.CSAD ),2) 'adxjl' from ");
240 sql.append(" "+dataViewName2119 +" aaa "); 238 sql.append(" "+dataViewName2119 +" aaa ");
241 System.out.println(sql.toString()); 239 System.out.println(sql.toString());
242 waterQualityVO = getJdbcTemplate().queryForObject(sql.toString(),new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class)); 240 List<WaterQualityVO> waterQualityVOList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class));
243 241 if(waterQualityVOList != null && !waterQualityVOList.isEmpty()){
244 242 waterQualityVO = waterQualityVOList.get(0);
243 }else{
244 waterQualityVO = new WaterQualityVO();
245 }
245 // if(waterQualityVO == null )waterQualityVO = new WaterQualityVO(); 246 // if(waterQualityVO == null )waterQualityVO = new WaterQualityVO();
246 //负荷率 CSL/设计规模 () 247 //负荷率 CSL/设计规模 ()
247 String factoryProScaleSql = "select round( ("+waterQualityVO.getCsl() +"/(pro_scale * 100) ),2) fhl from sys_factory_info where depart_id = '"+departId+"'"; 248 String factoryProScaleSql = "select round( ("+waterQualityVO.getCsl() +"/(pro_scale * 100) ),2) fhl from sys_factory_info where depart_id = '"+departId+"'";
...@@ -257,10 +258,15 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService { ...@@ -257,10 +258,15 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
257 sql2.append( " "+dataViewName3a24+" aaa "); 258 sql2.append( " "+dataViewName3a24+" aaa ");
258 259
259 System.out.println("sql2 = "+sql2.toString()); 260 System.out.println("sql2 = "+sql2.toString());
260 WaterQualityVO waterQualityVOTemp = getJdbcTemplate().queryForObject( sql2.toString(), new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class)); 261 waterQualityVOList = getJdbcTemplate().query( sql2.toString(), new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class));
261 waterQualityVO.setTnl(waterQualityVOTemp.getTnl() ); 262 if(waterQualityVOList != null && !waterQualityVOList.isEmpty() ){
262 waterQualityVO.setDsdh(waterQualityVOTemp.getDsdh()); 263 WaterQualityVO waterQualityVOTemp = waterQualityVOList.get(0);
263 waterQualityVO.setDsyh(waterQualityVOTemp.getDsyh()); 264 waterQualityVO.setTnl(waterQualityVOTemp.getTnl() );
265 waterQualityVO.setDsdh(waterQualityVOTemp.getDsdh());
266 waterQualityVO.setDsyh(waterQualityVOTemp.getDsyh());
267 }
268
269
264 270
265 return waterQualityVO; 271 return waterQualityVO;
266 } 272 }
......
...@@ -33,7 +33,7 @@ public class OperationReportServiceImpl implements IOperationReportService { ...@@ -33,7 +33,7 @@ public class OperationReportServiceImpl implements IOperationReportService {
33 33
34 String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";// 水 COD TP TN NH3H 34 String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";// 水 COD TP TN NH3H
35 String view3a24 = "3a243d5715b9e1a3753c180872ca0df9";//能耗报表 35 String view3a24 = "3a243d5715b9e1a3753c180872ca0df9";//能耗报表
36 String view4411 = "4411ed3d78634bcdcd700f6e33724025"; 36 String view4411 = "4411ed3d78634bcdcd700f6e33724025";//生产运营周报
37 37
38 private JdbcTemplate getJdbcTemplate(){ 38 private JdbcTemplate getJdbcTemplate(){
39 JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master"); 39 JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
......
...@@ -34,4 +34,10 @@ public class FRportlCommandCenterVO implements Serializable { ...@@ -34,4 +34,10 @@ public class FRportlCommandCenterVO implements Serializable {
34 this.valueTb = valueTb; 34 this.valueTb = valueTb;
35 this.valueHb = valueHb; 35 this.valueHb = valueHb;
36 } 36 }
37 public FRportlCommandCenterVO(String title ,String value, String valueTb, String valueHb) {
38 this.title = title;
39 this.value = value;
40 this.valueTb = valueTb;
41 this.valueHb = valueHb;
42 }
37 } 43 }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!