Commit db61e5443328559b15075a6acc578e142971c78d
1 parent
15d1a154
百公里能耗接口增加总能耗与总公里字段
Showing
1 changed file
with
54 additions
and
0 deletions
src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java
| @@ -3640,6 +3640,45 @@ public class BigscreenService { | @@ -3640,6 +3640,45 @@ public class BigscreenService { | ||
| 3640 | } | 3640 | } |
| 3641 | }); | 3641 | }); |
| 3642 | 3642 | ||
| 3643 | + String sql="select xl, xl_name, sjyylc, sjkslc, sjzgl " | ||
| 3644 | + + " from bsth_c_calc_count " | ||
| 3645 | + + " where date >= ? and date <= ? "; | ||
| 3646 | + | ||
| 3647 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, new Object[]{date1, date2}, | ||
| 3648 | + new RowMapper<Map<String, Object>>(){ | ||
| 3649 | + @Override | ||
| 3650 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3651 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3652 | + | ||
| 3653 | + m.put("lineCode", rs.getString("xl")); | ||
| 3654 | + m.put("lineName", rs.getString("xl_name")); | ||
| 3655 | + | ||
| 3656 | + m.put("sjyylc", rs.getString("sjyylc")); | ||
| 3657 | + m.put("sjkslc", rs.getString("sjkslc")); | ||
| 3658 | + m.put("sjzgl", rs.getString("sjzgl")); | ||
| 3659 | + | ||
| 3660 | + return m; | ||
| 3661 | + } | ||
| 3662 | + }); | ||
| 3663 | + | ||
| 3664 | + String yyxlSql="SELECT line_code from bsth_c_line " | ||
| 3665 | + + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | ||
| 3666 | + List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | ||
| 3667 | + new RowMapper<Map<String, Object>>(){ | ||
| 3668 | + @Override | ||
| 3669 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3670 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3671 | + m.put("lineCode", rs.getString("line_code")); | ||
| 3672 | + return m; | ||
| 3673 | + } | ||
| 3674 | + }); | ||
| 3675 | + Set<String> yyLine = new HashSet<String>(); | ||
| 3676 | + for(Map<String, Object> t : yyxlList){ | ||
| 3677 | + if(t.get("lineCode") != null){ | ||
| 3678 | + yyLine.add(t.get("lineCode").toString()); | ||
| 3679 | + } | ||
| 3680 | + } | ||
| 3681 | + | ||
| 3643 | BigDecimal yh = new BigDecimal(0), yh_zlc = new BigDecimal(0), | 3682 | BigDecimal yh = new BigDecimal(0), yh_zlc = new BigDecimal(0), |
| 3644 | hd = new BigDecimal(0), hd_zlc = new BigDecimal(0), | 3683 | hd = new BigDecimal(0), hd_zlc = new BigDecimal(0), |
| 3645 | hn = new BigDecimal(0), hn_zlc = new BigDecimal(0); | 3684 | hn = new BigDecimal(0), hn_zlc = new BigDecimal(0); |
| @@ -3657,6 +3696,15 @@ public class BigscreenService { | @@ -3657,6 +3696,15 @@ public class BigscreenService { | ||
| 3657 | hn = hn.add(new BigDecimal(m.get("hn").toString())); | 3696 | hn = hn.add(new BigDecimal(m.get("hn").toString())); |
| 3658 | hn_zlc = hn_zlc.add(new BigDecimal(m.get("zlc").toString())); | 3697 | hn_zlc = hn_zlc.add(new BigDecimal(m.get("zlc").toString())); |
| 3659 | } | 3698 | } |
| 3699 | + | ||
| 3700 | + BigDecimal yygl = new BigDecimal(0), ksgl = new BigDecimal(0), zgl = new BigDecimal(0); | ||
| 3701 | + for(Map<String, Object> m : list){ | ||
| 3702 | + if(yyLine.contains(m.get("lineCode").toString())){ | ||
| 3703 | + yygl = yygl.add(new BigDecimal(m.get("sjyylc").toString())); | ||
| 3704 | + ksgl = ksgl.add(new BigDecimal(m.get("sjkslc").toString())); | ||
| 3705 | + zgl = zgl.add(new BigDecimal(m.get("sjzgl").toString())); | ||
| 3706 | + } | ||
| 3707 | + } | ||
| 3660 | 3708 | ||
| 3661 | if(yh_zlc.compareTo(new BigDecimal(0)) > 0){ | 3709 | if(yh_zlc.compareTo(new BigDecimal(0)) > 0){ |
| 3662 | resMap.put("oil", yh.divide(yh_zlc, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue()); | 3710 | resMap.put("oil", yh.divide(yh_zlc, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue()); |
| @@ -3674,6 +3722,12 @@ public class BigscreenService { | @@ -3674,6 +3722,12 @@ public class BigscreenService { | ||
| 3674 | resMap.put("hydrogen", 0); | 3722 | resMap.put("hydrogen", 0); |
| 3675 | } | 3723 | } |
| 3676 | 3724 | ||
| 3725 | + resMap.put("oilSum", yh.doubleValue()); | ||
| 3726 | + resMap.put("electricitySum", hd.doubleValue()); | ||
| 3727 | + resMap.put("hydrogenSum", hn.doubleValue()); | ||
| 3728 | + resMap.put("realMileageSum", zgl.doubleValue()); | ||
| 3729 | + resMap.put("realMileageService", yygl.doubleValue()); | ||
| 3730 | + resMap.put("realMileageEmpty", ksgl.doubleValue()); | ||
| 3677 | 3731 | ||
| 3678 | 3732 | ||
| 3679 | return resMap; | 3733 | return resMap; |