9a72d6f5 康伟

kangwei: 完善能耗分析,添加单位,解决value空值

1 个父辈 de88b37b
1 package com.skua.tool.util; 1 package com.skua.tool.util;
2 2
3 import com.skua.constant.BaseConstant; 3 import com.skua.constant.BaseConstant;
4 import com.skua.modules.common.vo.DateVO;
5
4 import java.math.BigDecimal; 6 import java.math.BigDecimal;
5 import java.text.ParseException; 7 import java.text.ParseException;
6 import java.text.ParsePosition; 8 import java.text.ParsePosition;
...@@ -72,9 +74,25 @@ public class DateUtils { ...@@ -72,9 +74,25 @@ public class DateUtils {
72 }; 74 };
73 75
74 public static void main(String[] args) { 76 public static void main(String[] args) {
75 System.out.println(getHbMonth(formatDate("2024-01-01","yyyy-MM"))); 77 // System.out.println(getHbMonth(formatDate("2024-01-01","yyyy-MM")));
78 // 获取当前日期的Calendar实例
79 Calendar calendar = Calendar.getInstance();
80 // 将当前日期减去一个月
81 calendar.add(Calendar.MONTH, -1);
82 // 创建日期格式化对象
83 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
84 // 格式化上个月的日期
85 String lastMonth = dateFormat.format(calendar.getTime());
86
87 calendar.add(Calendar.MONTH, -1);
88 String lastMonth2 = dateFormat.format(calendar.getTime());
76 89
90 calendar.add(Calendar.MONTH, -11);
91 String lastMonth3 = dateFormat.format(calendar.getTime());
77 92
93 System.out.println("上月"+lastMonth);
94 System.out.println("上上月"+lastMonth2);
95 System.out.println("同比"+lastMonth3);
78 // System.out.println("天数差异: " + daysBetween); 96 // System.out.println("天数差异: " + daysBetween);
79 } 97 }
80 98
......
...@@ -21,10 +21,8 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper; ...@@ -21,10 +21,8 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
21 import org.springframework.jdbc.core.JdbcTemplate; 21 import org.springframework.jdbc.core.JdbcTemplate;
22 import org.springframework.stereotype.Service; 22 import org.springframework.stereotype.Service;
23 23
24 import java.util.ArrayList; 24 import java.text.SimpleDateFormat;
25 import java.util.HashMap; 25 import java.util.*;
26 import java.util.List;
27 import java.util.Map;
28 26
29 27
30 /** 28 /**
...@@ -382,6 +380,9 @@ public class ReportItemvService { ...@@ -382,6 +380,9 @@ public class ReportItemvService {
382 String dsdh_value_Tb = ReportViewUtil.getValueByDSDH(departId,dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime()) ; 380 String dsdh_value_Tb = ReportViewUtil.getValueByDSDH(departId,dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime()) ;
383 381
384 382
383 startTime = dateVO.getLastMonthStartTime();
384 endTime = dateVO.getLastMonthEndTime();
385
385 String dfValueSql = "select sum(cost) cost from report_electric_cost t where t.month >='"+DateUtils.formatDate(startTime,"yyyy-MM")+"' and t.month<='"+DateUtils.formatDate(endTime,"yyyy-MM")+"' "; 386 String dfValueSql = "select sum(cost) cost from report_electric_cost t where t.month >='"+DateUtils.formatDate(startTime,"yyyy-MM")+"' and t.month<='"+DateUtils.formatDate(endTime,"yyyy-MM")+"' ";
386 dfValueSql += " and t.depart_id in ("+JSUtils.quoteEach(departId,",")+")"; 387 dfValueSql += " and t.depart_id in ("+JSUtils.quoteEach(departId,",")+")";
387 String dfValue = getJdbcTemplate().queryForObject(dfValueSql,String.class); 388 String dfValue = getJdbcTemplate().queryForObject(dfValueSql,String.class);
...@@ -424,9 +425,38 @@ public class ReportItemvService { ...@@ -424,9 +425,38 @@ public class ReportItemvService {
424 ReportItemVO zyhReportVO = ReportViewUtil.getSumValueByTBHB( ReportConstant.view3a24,ReportConstant.fieldYj, departIds, startDate,endDate); 425 ReportItemVO zyhReportVO = ReportViewUtil.getSumValueByTBHB( ReportConstant.view3a24,ReportConstant.fieldYj, departIds, startDate,endDate);
425 //日均 value ,同比,环比 426 //日均 value ,同比,环比
426 //ReportItemVO zyhReportAVG = ReportViewUtil.getSumValueByTBHB( ReportConstant.view3a24,ReportConstant.fieldYj, departIds, startDate,endDate,"avg"); 427 //ReportItemVO zyhReportAVG = ReportViewUtil.getSumValueByTBHB( ReportConstant.view3a24,ReportConstant.fieldYj, departIds, startDate,endDate,"avg");
427 //月吨水药费 428 // 获取当前日期的Calendar实例
428 ReportItemVO dsyfReportVO = ReportViewUtil.getSumValueByTBHB( ReportConstant.view4411,"yyh", departIds, startDate,endDate); 429 Calendar calendar = Calendar.getInstance();
430 // 将当前日期减去一个月
431 calendar.add(Calendar.MONTH, -1);
432 // 创建日期格式化对象
433 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
434 // 格式化上个月的日期
435 String month = dateFormat.format(calendar.getTime());
436 calendar.add(Calendar.MONTH, -1);
437 String monthHB = dateFormat.format(calendar.getTime());
438 calendar.add(Calendar.MONTH, -11);
439 String monthTB = dateFormat.format(calendar.getTime());
440
441 String dataViewName3a24_value = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, month,month);
442 String dataViewName3a24_valueHB = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, monthHB,monthHB);
443 String dataViewName3a24_valueTB = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, monthTB,monthTB);
444 String sql = "select ";
445 sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_value+ "aaa) 'value',";
446 sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueHB+ "aaa) 'valueHb',";
447 sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueTB+ "aaa) 'valueTb' ";
448 sql += " from dual";
449 JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
450 ReportItemVO dsyfReportVO = null;
451 List<ReportItemVO> dsyfReportList = masterDB.query(sql,new BeanPropertyRowMapper<ReportItemVO>(ReportItemVO.class));
452 if( dsyfReportList!= null && !dsyfReportList.isEmpty()){
453 dsyfReportVO = dsyfReportList.get(0);
454 }else{
455 dsyfReportVO = new ReportItemVO();
456 }
429 457
458 //出水量:+同比+环比
459 // ReportItemVO csl_reportVO2 = ReportViewUtil.getSumValueByTBHB(ReportConstant.view2119,ReportConstant.field_CSL, departIds, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
430 460
431 List<FRportlCommandCenterVO> dataList = new ArrayList<>(); 461 List<FRportlCommandCenterVO> dataList = new ArrayList<>();
432 dataList.add( new FRportlCommandCenterVO("月总药耗" ,"monthValue","万吨",JSUtils.divide(zyhReportVO.getValue(),"10000"),JSUtils.divide(zyhReportVO.getValueTb(),"10000"),JSUtils.divide(zyhReportVO.getValueHb(),"10000")) ); 462 dataList.add( new FRportlCommandCenterVO("月总药耗" ,"monthValue","万吨",JSUtils.divide(zyhReportVO.getValue(),"10000"),JSUtils.divide(zyhReportVO.getValueTb(),"10000"),JSUtils.divide(zyhReportVO.getValueHb(),"10000")) );
......
...@@ -147,7 +147,7 @@ public class CommandCentreServiceImpl implements ICommandCentreService { ...@@ -147,7 +147,7 @@ public class CommandCentreServiceImpl implements ICommandCentreService {
147 sql += " where aaa.equipment_level = '6bf727eb7e7cca6a95c694dab0036b2c'";//A类设备 147 sql += " where aaa.equipment_level = '6bf727eb7e7cca6a95c694dab0036b2c'";//A类设备
148 List<EquipmentRepairAnalysisVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<EquipmentRepairAnalysisVO>(EquipmentRepairAnalysisVO.class));; 148 List<EquipmentRepairAnalysisVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<EquipmentRepairAnalysisVO>(EquipmentRepairAnalysisVO.class));;
149 149
150 dataMap.put("totalCost",JSUtils.multiply(repairCost,maintainCost)); 150 dataMap.put("totalCost",JSUtils.subtract(repairCost,maintainCost));
151 dataMap.put("dataList",dataList); 151 dataMap.put("dataList",dataList);
152 return dataMap; 152 return dataMap;
153 } 153 }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!