Parcourir la source

综合分析中,万元占比报表、按月统计能耗表中新加的指标,加入相应节超量的计算

chenwen il y a 3 ans
Parent
commit
038277721e

+ 3 - 0
src/main/java/com/hb/proj/car/controller/EnergyWaterCompareController.java

@@ -20,6 +20,7 @@ import com.hb.proj.model.CarConsumeMulRptVO;
 import com.hb.proj.model.ERP;
 import com.hb.proj.model.EnergyWaterCompareVO;
 import com.hb.proj.model.EnergyWaterRatioCompareVO;
+import com.hb.proj.model.MonitorRemainOil;
 import com.hb.proj.model.OtherConsume;
 import com.hb.proj.model.Wpg;
 import com.hb.proj.model.WpgCorrect;
@@ -128,6 +129,8 @@ public class EnergyWaterCompareController {
 		WpgCorrect wpgcrt=service.wpgCorrectMonthSum(startMonth,endMonth);
 		wpg=ERPKlSumUtil.processWpgSum(wpg,wpgcrt);
 		CarConsumeMulRptVO consume=service.carOilMonthSum(startMonth, endMonth);
+		MonitorRemainOil remainOil=service.carOilPeriodDiff(startMonth, endMonth);
+		consume.adjust(remainOil);
 		return new EnergyWaterRatioCompareVO(erp,wpg,service.workloadMonthSum(startMonth,endMonth),consume);
 		
 	}

+ 3 - 1
src/main/java/com/hb/proj/car/controller/HomeRptController.java

@@ -23,6 +23,7 @@ import com.hb.proj.model.ERP;
 import com.hb.proj.model.EnergyWaterCompareVO;
 import com.hb.proj.model.EnergyWaterSumVO;
 import com.hb.proj.model.EnergyWaterSumVOUtil;
+import com.hb.proj.model.MonitorRemainOil;
 import com.hb.proj.model.OtherConsume;
 import com.hb.proj.model.Workload;
 import com.hb.proj.model.Wpg;
@@ -294,7 +295,8 @@ public class HomeRptController {
 		}
 		Map<String,EnergyWaterSumVO> voIndex=EnergyWaterSumVOUtil.build(service.erpMonthGrp(year), service.otherMonthGrp(year), service.wpgSumRpt(year), service.wpgCorrectSumRpt(year), service.workloadSumRpt(year),null,null);
 		List<CarConsumeMulRptVO> indConsumes=service.carOilMulRptMonthGrp(year);
-		EnergyWaterSumVOUtil.attachForMulRpt(voIndex, indConsumes);
+		List<MonitorRemainOil> remainOils=service.carOilPeriodDiffMonthGrp(year);
+		EnergyWaterSumVOUtil.attachForMulRpt(voIndex, indConsumes,remainOils);
 		
 		Map<String,Object> rootMap=new HashMap<String,Object>();
 		rootMap.put("months", mths); 

+ 69 - 1
src/main/java/com/hb/proj/car/service/EnergySumRptService.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
 import com.hb.proj.model.CarConsume;
 import com.hb.proj.model.CarConsumeMulRptVO;
 import com.hb.proj.model.ERP;
+import com.hb.proj.model.MonitorRemainOil;
 import com.hb.proj.model.OtherConsume;
 import com.hb.proj.model.Workload;
 import com.hb.proj.model.Wpg;
@@ -27,6 +28,69 @@ public class EnergySumRptService {
 	@Autowired
 	private SpringJdbcDAO  dao;
 	
+	/**
+	 * 指定月份内车辆的用油期末期初差值
+	 * @param startMonth
+	 * @param endMonth
+	 * @return
+	 */
+	public MonitorRemainOil carOilPeriodDiff(String startMonth,String endMonth){
+		StringBuilder sql=new StringBuilder(300);
+		sql.append("select sum(case when r.oil_type='柴油' then ifnull(start_volume,0) else 0 end) coil_start_volume,");
+		sql.append(" sum(case when r.oil_type='汽油' then ifnull(start_volume,0) else 0 end) oil_start_volume ");
+		sql.append(" from t_oil_monitor_report mr ");
+		sql.append(" inner join t_car c on mr.car_id=c.car_id ");
+		sql.append(" inner join t_quota_rule r on c.quota_rule_id=r.record_id ");
+		sql.append(" where mr.rpt_month=? ");
+		
+		MonitorRemainOil   startOil=dao.queryForObject(sql.toString(), MonitorRemainOil.class, startMonth);
+		
+		sql.setLength(0);
+		sql.append("select sum(case when r.oil_type='柴油' then ifnull(end_volume,0) else 0 end) coil_end_volume,");
+		sql.append(" sum(case when r.oil_type='汽油' then ifnull(end_volume,0) else 0 end) oil_end_volume ");
+		sql.append(" from t_oil_monitor_report mr ");
+		sql.append(" inner join t_car c on mr.car_id=c.car_id ");
+		sql.append(" inner join t_quota_rule r on c.quota_rule_id=r.record_id ");
+		sql.append(" where mr.rpt_month=? ");
+		
+		MonitorRemainOil   endOil=dao.queryForObject(sql.toString(), MonitorRemainOil.class, endMonth);
+		
+		if(startOil==null){
+			return endOil;
+		}
+		if(endOil==null){
+			return startOil;
+		}
+		startOil.setCoilEndVolume(endOil.getCoilEndVolume());
+		startOil.setOilEndVolume(endOil.getOilEndVolume());
+		return startOil;
+	}
+	
+	/**
+	 * 按月统计车辆的用油期末期初差值
+	 * @param year
+	 * @return
+	 */
+	public List<MonitorRemainOil> carOilPeriodDiffMonthGrp(String year){
+		StringBuilder sql=new StringBuilder(300);
+		sql.append("select mr.rpt_month, (case when r.oil_type='柴油' then ifnull(start_volume,0) else 0 end) coil_start_volume,");
+		sql.append(" (case when r.oil_type='汽油' then ifnull(start_volume,0) else 0 end) oil_start_volume, ");
+		sql.append(" (case when r.oil_type='柴油' then ifnull(end_volume,0) else 0 end) coil_end_volume,");
+		sql.append(" (case when r.oil_type='汽油' then ifnull(end_volume,0) else 0 end) oil_end_volume ");
+		sql.append(" from t_oil_monitor_report mr ");
+		sql.append(" inner join t_car c on mr.car_id=c.car_id ");
+		sql.append(" inner join t_quota_rule r on c.quota_rule_id=r.record_id ");
+		sql.append(" where substr(mr.rpt_month,1,4)=? ");
+		
+		return dao.queryForListPojo(sql.toString(), MonitorRemainOil.class, year);
+	}
+	
+	/**
+	 * 综合分析-万元占比报表新指标2022.7.18
+	 * @param startMonth
+	 * @param endMonth
+	 * @return
+	 */
 	public CarConsumeMulRptVO carOilMonthSum(String startMonth,String endMonth){
 		StringBuilder sql=new StringBuilder();
 		sql.append("select sum(check_mile) check_mile,sum(case when r.oil_type='柴油' then ifnull(travel_mile,0) else 0 end) coil_travel_mile,");
@@ -41,7 +105,11 @@ public class EnergySumRptService {
 		return dao.queryForObject(sql.toString(), CarConsumeMulRptVO.class,startMonth,endMonth);
 	}
 	
-	
+	/**
+	 * 综合分析-用能用水按月统计新指标2022.7.18
+	 * @param year
+	 * @return
+	 */
 	public List<CarConsumeMulRptVO> carOilMulRptMonthGrp(String year){
 		StringBuilder sql=new StringBuilder();
 		sql.append("select DATE_FORMAT(s.rpt_date,'%Y-%m') rpt_month,sum(case when r.oil_type='柴油' then ifnull(travel_mile,0) else 0 end) coil_travel_mile,");

+ 21 - 0
src/main/java/com/hb/proj/model/CarConsumeMulRptVO.java

@@ -41,7 +41,28 @@ public class CarConsumeMulRptVO {
 	
 	private Integer wellCount; //井次
 	
+	/**
+	 * 修正用油量 上报用油量+期初余油-期末余油
+	 * @param remainOil
+	 */
+	public void adjust(MonitorRemainOil remainOil){
+		if(remainOil==null){
+			return;
+		}
+		coilUsLiter=CarRptUtils.addDouble(coilUsLiter, remainOil.getCoilStartVolume());
+		coilUsLiter=CarRptUtils.reduceDouble(coilUsLiter, remainOil.getCoilEndVolume());
+		
+		oilUsLiter=CarRptUtils.addDouble(oilUsLiter, remainOil.getOilStartVolume());
+		oilUsLiter=CarRptUtils.reduceDouble(oilUsLiter, remainOil.getOilEndVolume());
+	}
+	
+	
+	/**
+	 * 计算新的指标值
+	 * @param wcount
+	 */
 	public void calculate(Integer wcount){
+		
 		this.wellCount=wcount!=null?wcount:0;
 		
 		//柴油车行驶油耗=柴有使用量-发电机油耗-作业油耗

+ 12 - 1
src/main/java/com/hb/proj/model/EnergyWaterSumVOUtil.java

@@ -100,12 +100,20 @@ public class EnergyWaterSumVOUtil {
 	 * {@link EnergyWaterSumVOUtil.build}
 	 * @param sumMap
 	 * @param consumes
+	 * @param remainOils  通过监控程序获得的期初期末剩余油量
 	 */
 	
-	public static void attachForMulRpt(Map<String, EnergyWaterSumVO> sumMap,List<CarConsumeMulRptVO> consumes){
+	public static void attachForMulRpt(Map<String, EnergyWaterSumVO> sumMap,List<CarConsumeMulRptVO> consumes,List<MonitorRemainOil> remainOils){
 		if(consumes==null||consumes.size()==0){
 			return ;
 		}
+		Map<String,MonitorRemainOil>  adjustMap=null;
+		if(remainOils!=null&&remainOils.size()>0){
+			adjustMap=new HashMap<String,MonitorRemainOil>();
+			for(MonitorRemainOil itm : remainOils){
+				adjustMap.put(itm.getRptMonth().substring(5, 7), itm);
+			}
+		}
 		String month=null;
 		EnergyWaterSumVO  tmpSum=null;
 		Workload wkload=null;
@@ -115,6 +123,9 @@ public class EnergyWaterSumVOUtil {
 			tmpSum=sumMap.get(month);
 			wkload=tmpSum.getWorkload();
 			wellCount=wkload!=null&&wkload.getWellCount()!=null?wkload.getWellCount().intValue():0;
+			if(adjustMap!=null&&adjustMap.get(month)!=null){
+				consume.adjust(adjustMap.get(month));
+			}
 			consume.calculate(wellCount);
 			
 			tmpSum.setIndConsume(consume);

+ 74 - 0
src/main/java/com/hb/proj/model/MonitorRemainOil.java

@@ -0,0 +1,74 @@
+package com.hb.proj.model;
+
+public class MonitorRemainOil {
+
+	private Double startVolume;  //期初余油 升
+	
+	private Double endVolume;  //期末余油 升
+	
+	private String rptMonth;  //统计月份
+	
+	private Double coilStartVolume;		//期初柴油余油 升
+	
+	private Double oilStartVolume;		//期初汽油余油 升
+	
+	private Double coilEndVolume;		//期末柴油余油 升
+	
+	private Double oilEndVolume;		//期末汽油余油 升
+
+	public Double getStartVolume() {
+		return startVolume;
+	}
+
+	public void setStartVolume(Double startVolume) {
+		this.startVolume = startVolume;
+	}
+
+	public Double getEndVolume() {
+		return endVolume;
+	}
+
+	public void setEndVolume(Double endVolume) {
+		this.endVolume = endVolume;
+	}
+
+	public String getRptMonth() {
+		return rptMonth;
+	}
+
+	public void setRptMonth(String rptMonth) {
+		this.rptMonth = rptMonth;
+	}
+
+	public Double getCoilStartVolume() {
+		return coilStartVolume;
+	}
+
+	public void setCoilStartVolume(Double coilStartVolume) {
+		this.coilStartVolume = coilStartVolume;
+	}
+
+	public Double getOilStartVolume() {
+		return oilStartVolume;
+	}
+
+	public void setOilStartVolume(Double oilStartVolume) {
+		this.oilStartVolume = oilStartVolume;
+	}
+
+	public Double getCoilEndVolume() {
+		return coilEndVolume;
+	}
+
+	public void setCoilEndVolume(Double coilEndVolume) {
+		this.coilEndVolume = coilEndVolume;
+	}
+
+	public Double getOilEndVolume() {
+		return oilEndVolume;
+	}
+
+	public void setOilEndVolume(Double oilEndVolume) {
+		this.oilEndVolume = oilEndVolume;
+	}
+}