ae606232 康伟

kangwei: 吨水电耗

1 个父辈 9a2d14c5
......@@ -7,6 +7,7 @@ import java.util.Map;
import com.skua.common.constant.ReportConstant;
import com.skua.common.report.vo.ReportItemVO;
import com.skua.tool.util.DateUtils;
import com.skua.tool.util.JSUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
......@@ -346,6 +347,25 @@ public class ReportViewUtil {
return reportItemVO;
}
public static String getValueByDSDH( String departIds , String startTime , String endTime){
String dataViewName3a24 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"DLHJ", departIds, startTime,endTime);
String dataViewName2119 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL", departIds, startTime,endTime);
String sql = "select round( ifnull(avg( aaaa.dh/bbbb.csl ),0),2) dsdh from sys_depart d ";
sql += " left join ( select aaa.depart_id , ifnull(sum(aaa.DLHJ),0) dh from " +dataViewName3a24+" aaa group by aaa.depart_id )aaaa on aaaa.depart_id = d.id ";
sql += " left join ( select bb.depart_id , ifnull(sum(bb.CSL),0) csl from "+dataViewName2119+" bb group by bb.depart_id ) bbbb on bbbb.depart_id = d.id ";
sql += " where d.depart_type = 1 ";
if(StringUtils.isNotEmpty(departIds)){
sql += " and d.id in ("+ JSUtils.quoteEach(departIds,",") +")";
}
sql += " and ifnull(aaaa.dh,0) > 0 and ifnull(bbbb.csl , 0 ) > 0 ";
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
String dsdh = masterDB.queryForObject(sql,String.class);
return dsdh;
}
/***
* 某一个字段的时间+吨水消耗
* @param reportId
......
......@@ -82,21 +82,24 @@ public class ReportItemvService {
*/
public List<FRportlCommandCenterVO> statisticsByElectricity(String departId, String startTime, String endTime) {
List<FRportlCommandCenterVO> fRportlCommandCenterVOList = new ArrayList<>();
DateVO dateVO = new DateVO(startTime);
// 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";
ReportItemVO dlhjData = ReportViewUtil.getSumValueByTBHB(ReportConstant.view3a24, "DLHJ", departId, startTime, endTime);
String dlhj_avg_value = getAvgDLHJ(departId,dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
String dlhj_avg_valueHB = getAvgDLHJ(departId, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
String dlhj_avg_valueTB = getAvgDLHJ(departId, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
String dlhj_avg_value = getAvgDLHJ(departId,startTime, endTime);
String dlhj_avg_valueHB = getAvgDLHJ(departId, DateUtils.getHbDate(startTime),DateUtils.getHbDate(endTime));
String dlhj_avg_valueTB = getAvgDLHJ(departId, DateUtils.getTbDate(startTime),DateUtils.getTbDate(endTime));
String csl_avg_value = getSumCSL(departId,dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
/* String csl_avg_value = getSumCSL(departId,dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
String csl_avg_valueHB = getSumCSL(departId, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
String csl_avg_valueTB = getSumCSL(departId, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
String csl_avg_valueTB = getSumCSL(departId, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());*/
String dsdh_value = ReportViewUtil.getValueByDSDH(departId,startTime, endTime) ;
String dsdh_value_Hb = ReportViewUtil.getValueByDSDH(departId,DateUtils.getHbDate(startTime),DateUtils.getHbDate(endTime)) ;
String dsdh_value_Tb = ReportViewUtil.getValueByDSDH(departId,DateUtils.getTbDate(startTime),DateUtils.getTbDate(endTime)) ;
// long nowDifferDay = DateUtils.differenceDay(dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
// long lastMonthDifferDay = DateUtils.differenceDay(dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
// long lastYearDifferDay = DateUtils.differenceDay(dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
......@@ -106,7 +109,7 @@ public class ReportItemvService {
//日均数据:/环比/同比
FRportlCommandCenterVO lastMonthVO = new FRportlCommandCenterVO("日均电耗",dlhj_avg_value ,dlhj_avg_valueHB,dlhj_avg_valueTB );
//吨水消耗
FRportlCommandCenterVO lastYearVo = new FRportlCommandCenterVO("吨水电耗",JSUtils.divide( dlhj_avg_value ,csl_avg_value ) ,JSUtils.divide( dlhj_avg_valueHB ,csl_avg_valueHB ),JSUtils.divide( dlhj_avg_valueTB ,csl_avg_valueTB ));
FRportlCommandCenterVO lastYearVo = new FRportlCommandCenterVO("吨水电耗",dsdh_value ,dsdh_value_Hb ,dsdh_value_Tb);
fRportlCommandCenterVOList.add( nowMonthVO) ;
fRportlCommandCenterVOList.add( lastMonthVO) ;
fRportlCommandCenterVOList.add( lastYearVo) ;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!