|
@@ -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,");
|