9a72d6f5 康伟

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

1 个父辈 de88b37b
package com.skua.tool.util;
import com.skua.constant.BaseConstant;
import com.skua.modules.common.vo.DateVO;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.ParsePosition;
......@@ -72,9 +74,25 @@ public class DateUtils {
};
public static void main(String[] args) {
System.out.println(getHbMonth(formatDate("2024-01-01","yyyy-MM")));
// System.out.println(getHbMonth(formatDate("2024-01-01","yyyy-MM")));
// 获取当前日期的Calendar实例
Calendar calendar = Calendar.getInstance();
// 将当前日期减去一个月
calendar.add(Calendar.MONTH, -1);
// 创建日期格式化对象
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
// 格式化上个月的日期
String lastMonth = dateFormat.format(calendar.getTime());
calendar.add(Calendar.MONTH, -1);
String lastMonth2 = dateFormat.format(calendar.getTime());
calendar.add(Calendar.MONTH, -11);
String lastMonth3 = dateFormat.format(calendar.getTime());
System.out.println("上月"+lastMonth);
System.out.println("上上月"+lastMonth2);
System.out.println("同比"+lastMonth3);
// System.out.println("天数差异: " + daysBetween);
}
......
......@@ -21,10 +21,8 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
......@@ -85,8 +83,8 @@ public class ReportItemvService {
public List<FRportlCommandCenterVO> statisticsByElectricity(String departId, String startTime, String endTime) {
List<FRportlCommandCenterVO> fRportlCommandCenterVOList = new ArrayList<>();
DateVO dateVO = new DateVO(startTime);
// String dataViewName3a24 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"DLHJ", departId, startTime,endTime);
// String sql = "select ROUND( SUM( IFNULL(aaa.DLHJ,0) ), 2 ) AS DLHJ from " + dataViewName3a24+ "aaa";
// String dataViewName3a24 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"DLHJ", departId, startTime,endTime);
// String sql = "select ROUND( SUM( IFNULL(aaa.DLHJ,0) ), 2 ) AS DLHJ from " + dataViewName3a24+ "aaa";
ReportItemVO dlhjData = ReportViewUtil.getSumValueByTBHB(ReportConstant.view3a24, "DLHJ", departId, startTime, endTime);
......@@ -99,12 +97,12 @@ public class ReportItemvService {
String csl_avg_valueHB = getSumCSL(departId, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
String csl_avg_valueTB = getSumCSL(departId, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());*/
String dsdh_value = ReportViewUtil.getValueByDSDH(departId,startTime, endTime) ;
String dsdh_value = ReportViewUtil.getValueByDSDH(departId,startTime, endTime) ;
String dsdh_value_Hb = ReportViewUtil.getValueByDSDH(departId,dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime()) ;
String dsdh_value_Tb = ReportViewUtil.getValueByDSDH(departId,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());
// long nowDifferDay = DateUtils.differenceDay(dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
// long lastMonthDifferDay = DateUtils.differenceDay(dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
// long lastYearDifferDay = DateUtils.differenceDay(dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
//当月数据/环比、同比
FRportlCommandCenterVO nowMonthVO = new FRportlCommandCenterVO("月总电耗", JSUtils.divide(dlhjData.getValue(),10000), JSUtils.divide(dlhjData.getValueTb(),10000), JSUtils.divide(dlhjData.getValueHb(),10000));
......@@ -247,7 +245,7 @@ public class ReportItemvService {
private Map<String,String> commonQueryByField(String departIds ,String startTime ,String endTime,String dataViewName,String field){
Map<String,String> cslMap = new HashMap<>();
String dataViewNameSql = ReportViewUtil.buildViewLike(dataViewName,field, departIds, startTime,endTime);
//System.out.println("dataViewNameSql ="+dataViewNameSql );
//System.out.println("dataViewNameSql ="+dataViewNameSql );
List<Map<String, Object>> dataMapList = getJdbcTemplate().queryForList(dataViewNameSql);
if(dataMapList != null){
for(Map<String, Object> dataMap : dataMapList){
......@@ -382,6 +380,9 @@ public class ReportItemvService {
String dsdh_value_Tb = ReportViewUtil.getValueByDSDH(departId,dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime()) ;
startTime = dateVO.getLastMonthStartTime();
endTime = dateVO.getLastMonthEndTime();
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")+"' ";
dfValueSql += " and t.depart_id in ("+JSUtils.quoteEach(departId,",")+")";
String dfValue = getJdbcTemplate().queryForObject(dfValueSql,String.class);
......@@ -424,13 +425,42 @@ public class ReportItemvService {
ReportItemVO zyhReportVO = ReportViewUtil.getSumValueByTBHB( ReportConstant.view3a24,ReportConstant.fieldYj, departIds, startDate,endDate);
//日均 value ,同比,环比
//ReportItemVO zyhReportAVG = ReportViewUtil.getSumValueByTBHB( ReportConstant.view3a24,ReportConstant.fieldYj, departIds, startDate,endDate,"avg");
//月吨水药费
ReportItemVO dsyfReportVO = ReportViewUtil.getSumValueByTBHB( ReportConstant.view4411,"yyh", departIds, startDate,endDate);
// 获取当前日期的Calendar实例
Calendar calendar = Calendar.getInstance();
// 将当前日期减去一个月
calendar.add(Calendar.MONTH, -1);
// 创建日期格式化对象
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
// 格式化上个月的日期
String month = dateFormat.format(calendar.getTime());
calendar.add(Calendar.MONTH, -1);
String monthHB = dateFormat.format(calendar.getTime());
calendar.add(Calendar.MONTH, -11);
String monthTB = dateFormat.format(calendar.getTime());
String dataViewName3a24_value = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, month,month);
String dataViewName3a24_valueHB = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, monthHB,monthHB);
String dataViewName3a24_valueTB = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, monthTB,monthTB);
String sql = "select ";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_value+ "aaa) 'value',";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueHB+ "aaa) 'valueHb',";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueTB+ "aaa) 'valueTb' ";
sql += " from dual";
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
ReportItemVO dsyfReportVO = null;
List<ReportItemVO> dsyfReportList = masterDB.query(sql,new BeanPropertyRowMapper<ReportItemVO>(ReportItemVO.class));
if( dsyfReportList!= null && !dsyfReportList.isEmpty()){
dsyfReportVO = dsyfReportList.get(0);
}else{
dsyfReportVO = new ReportItemVO();
}
//出水量:+同比+环比
// ReportItemVO csl_reportVO2 = ReportViewUtil.getSumValueByTBHB(ReportConstant.view2119,ReportConstant.field_CSL, departIds, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
List<FRportlCommandCenterVO> dataList = new ArrayList<>();
dataList.add( new FRportlCommandCenterVO("月总药耗" ,"monthValue","万吨",JSUtils.divide(zyhReportVO.getValue(),"10000"),JSUtils.divide(zyhReportVO.getValueTb(),"10000"),JSUtils.divide(zyhReportVO.getValueHb(),"10000")) );
dataList.add( new FRportlCommandCenterVO("吨水药费" ,"dsyfValue","元/吨",dsyfReportVO.getValue(),dsyfReportVO.getValueTb(),dsyfReportVO.getValueHb()) );
dataList.add( new FRportlCommandCenterVO("吨水药费" ,"dsyfValue","元/吨",dsyfReportVO.getValue(),dsyfReportVO.getValueTb(),dsyfReportVO.getValueHb()) );
dataList.add( new FRportlCommandCenterVO("吨水药耗" ,"dsyhValue","kg/吨",JSUtils.divide(zyhReportVO.getValue(), csl_reportVO.getValue()),JSUtils.divide(zyhReportVO.getValueTb(), csl_reportVO.getValueTb()),JSUtils.divide(zyhReportVO.getValueHb(), csl_reportVO.getValueHb())) );
return dataList;
}
......
......@@ -147,7 +147,7 @@ public class CommandCentreServiceImpl implements ICommandCentreService {
sql += " where aaa.equipment_level = '6bf727eb7e7cca6a95c694dab0036b2c'";//A类设备
List<EquipmentRepairAnalysisVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<EquipmentRepairAnalysisVO>(EquipmentRepairAnalysisVO.class));;
dataMap.put("totalCost",JSUtils.multiply(repairCost,maintainCost));
dataMap.put("totalCost",JSUtils.subtract(repairCost,maintainCost));
dataMap.put("dataList",dataList);
return dataMap;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!