Commit 78ef3de64f8e01e82c48a8367df5b8f945080d14
1 parent
8cb334ec
油量导入、百公里油耗日报两张报表添加合计栏。
Showing
2 changed files
with
96 additions
and
1 deletions
src/main/java/com/bsth/service/impl/RefuelServiceImpl.java
| ... | ... | @@ -60,6 +60,74 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 60 | 60 | driver = "%" + map.get("driver").toString() + "%"; |
| 61 | 61 | } |
| 62 | 62 | List<Refuel> list = repository.findByDate(date, car, driver); |
| 63 | + Refuel sum = new Refuel(); | |
| 64 | + sum.setDateStr("合计"); | |
| 65 | + sum.setLineName(""); | |
| 66 | + sum.setCar(""); | |
| 67 | + sum.setDriver(""); | |
| 68 | + for(Refuel r : list){ | |
| 69 | + if(r.getOutOil() != null && r.getOutOil().trim().length() > 0) | |
| 70 | + if(sum.getOutOil() != null && sum.getOutOil().trim().length() > 0){ | |
| 71 | + sum.setOutOil(new BigDecimal(sum.getOutOil()).add(new BigDecimal(r.getOutOil())).toString()); | |
| 72 | + } else { | |
| 73 | + sum.setOutOil(r.getOutOil()); | |
| 74 | + } | |
| 75 | + if(r.getInOil() != null && r.getInOil().trim().length() > 0) | |
| 76 | + if(sum.getInOil() != null && sum.getInOil().trim().length() > 0){ | |
| 77 | + sum.setInOil(new BigDecimal(sum.getInOil()).add(new BigDecimal(r.getInOil())).toString()); | |
| 78 | + } else { | |
| 79 | + sum.setInOil(r.getInOil()); | |
| 80 | + } | |
| 81 | + if(r.getInStation0() != null && r.getInStation0().trim().length() > 0) | |
| 82 | + if(sum.getInStation0() != null && sum.getInStation0().trim().length() > 0){ | |
| 83 | + sum.setInStation0(new BigDecimal(sum.getInStation0()).add(new BigDecimal(r.getInStation0())).toString()); | |
| 84 | + } else { | |
| 85 | + sum.setInStation0(r.getInStation0()); | |
| 86 | + } | |
| 87 | + if(r.getInStation5() != null && r.getInStation5().trim().length() > 0) | |
| 88 | + if(sum.getInStation5() != null && sum.getInStation5().trim().length() > 0){ | |
| 89 | + sum.setInStation5(new BigDecimal(sum.getInStation5()).add(new BigDecimal(r.getInStation5())).toString()); | |
| 90 | + } else { | |
| 91 | + sum.setInStation5(r.getInStation5()); | |
| 92 | + } | |
| 93 | + if(r.getOilCard0() != null && r.getOilCard0().trim().length() > 0) | |
| 94 | + if(sum.getOilCard0() != null && sum.getOilCard0().trim().length() > 0){ | |
| 95 | + sum.setOilCard0(new BigDecimal(sum.getOilCard0()).add(new BigDecimal(r.getOilCard0())).toString()); | |
| 96 | + } else { | |
| 97 | + sum.setOilCard0(r.getOilCard0()); | |
| 98 | + } | |
| 99 | + if(r.getOilCard10() != null && r.getOilCard10().trim().length() > 0) | |
| 100 | + if(sum.getOilCard10() != null && sum.getOilCard10().trim().length() > 0){ | |
| 101 | + sum.setOilCard10(new BigDecimal(sum.getOilCard10()).add(new BigDecimal(r.getOilCard10())).toString()); | |
| 102 | + } else { | |
| 103 | + sum.setOilCard10(r.getOilCard10()); | |
| 104 | + } | |
| 105 | + if(r.getEastStation0() != null && r.getEastStation0().trim().length() > 0) | |
| 106 | + if(sum.getEastStation0() != null && sum.getEastStation0().trim().length() > 0){ | |
| 107 | + sum.setEastStation0(new BigDecimal(sum.getEastStation0()).add(new BigDecimal(r.getEastStation0())).toString()); | |
| 108 | + } else { | |
| 109 | + sum.setEastStation0(r.getEastStation0()); | |
| 110 | + } | |
| 111 | + if(r.getEastStation10() != null && r.getEastStation10().trim().length() > 0) | |
| 112 | + if(sum.getEastStation10() != null && sum.getEastStation10().trim().length() > 0){ | |
| 113 | + sum.setEastStation10(new BigDecimal(sum.getEastStation10()).add(new BigDecimal(r.getEastStation10())).toString()); | |
| 114 | + } else { | |
| 115 | + sum.setEastStation10(r.getEastStation10()); | |
| 116 | + } | |
| 117 | + if(r.getOutStation0() != null && r.getOutStation0().trim().length() > 0) | |
| 118 | + if(sum.getOutStation0() != null && sum.getOutStation0().trim().length() > 0){ | |
| 119 | + sum.setOutStation0(new BigDecimal(sum.getOutStation0()).add(new BigDecimal(r.getOutStation0())).toString()); | |
| 120 | + } else { | |
| 121 | + sum.setOutStation0(r.getOutStation0()); | |
| 122 | + } | |
| 123 | + if(r.getOutStation10() != null && r.getOutStation10().trim().length() > 0) | |
| 124 | + if(sum.getOutStation10() != null && sum.getOutStation10().trim().length() > 0){ | |
| 125 | + sum.setOutStation10(new BigDecimal(sum.getOutStation10()).add(new BigDecimal(r.getOutStation10())).toString()); | |
| 126 | + } else { | |
| 127 | + sum.setOutStation10(r.getOutStation10()); | |
| 128 | + } | |
| 129 | + } | |
| 130 | + list.add(sum); | |
| 63 | 131 | return list; |
| 64 | 132 | } |
| 65 | 133 | |
| ... | ... | @@ -167,6 +235,13 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 167 | 235 | } |
| 168 | 236 | |
| 169 | 237 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 238 | + Map<String, Object> sum = new HashMap<String, Object>(); | |
| 239 | + sum.put("date", "合计"); | |
| 240 | + sum.put("line", ""); | |
| 241 | + sum.put("car", ""); | |
| 242 | + sum.put("driver", ""); | |
| 243 | + String realMileageSum = "", oilSum = ""; | |
| 244 | + | |
| 170 | 245 | for(String key : keyList){ |
| 171 | 246 | Refuel r = rMap.get(key); |
| 172 | 247 | Map<String, Object> m = new HashMap<String, Object>(); |
| ... | ... | @@ -234,9 +309,29 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 234 | 309 | m.put("oil", oil); |
| 235 | 310 | m.put("consume", consume); |
| 236 | 311 | |
| 312 | + if(realMileage != null && realMileage.trim().length() > 0) | |
| 313 | + if(realMileageSum.length() > 0){ | |
| 314 | + realMileageSum = new BigDecimal(realMileageSum).add(new BigDecimal(realMileage)).toString(); | |
| 315 | + } else { | |
| 316 | + realMileageSum = realMileage + ""; | |
| 317 | + } | |
| 318 | + if(oil != null && oil.trim().length() > 0) | |
| 319 | + if(oilSum.length() > 0){ | |
| 320 | + oilSum = new BigDecimal(oilSum).add(new BigDecimal(oil)).toString(); | |
| 321 | + } else { | |
| 322 | + oilSum = oil + ""; | |
| 323 | + } | |
| 324 | + | |
| 237 | 325 | resList.add(m); |
| 238 | 326 | } |
| 239 | 327 | |
| 328 | + sum.put("realMileage", realMileageSum); | |
| 329 | + sum.put("oil", oilSum); | |
| 330 | + if(realMileageSum.length() > 0 && oilSum.length() > 0 && !("0".equals(realMileageSum))){ | |
| 331 | + sum.put("consume", df.format(new BigDecimal(oilSum).divide(new BigDecimal(realMileageSum), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)))); | |
| 332 | + } | |
| 333 | + resList.add(sum); | |
| 334 | + | |
| 240 | 335 | return resList; |
| 241 | 336 | } |
| 242 | 337 | ... | ... |