Commit 9c3813657f23112d610d8619d50baf7dfc6bcc38
1 parent
68f800a0
油量管理 去很长的小数点
Showing
9 changed files
with
307 additions
and
64 deletions
src/main/java/com/bsth/controller/oil/YlbController.java
| ... | ... | @@ -163,8 +163,8 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | @RequestMapping(value = "/sumYlb",method = RequestMethod.GET) |
| 166 | - public List<Object[]> sumYlb(@RequestParam Map<String, Object> map){ | |
| 167 | - List<Object[]> list=yblService.sumYlb(map); | |
| 166 | + public Map<String, Object> sumYlb(@RequestParam Map<String, Object> map){ | |
| 167 | + Map<String, Object> list=yblService.sumYlb(map); | |
| 168 | 168 | return list; |
| 169 | 169 | } |
| 170 | 170 | ... | ... |
src/main/java/com/bsth/entity/oil/Ylb.java
src/main/java/com/bsth/repository/oil/YlbRepository.java
| ... | ... | @@ -51,7 +51,7 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 51 | 51 | */ |
| 52 | 52 | @Transactional |
| 53 | 53 | @Modifying |
| 54 | - @Query(value="select sum(jzl) as jzl,sum(zlc) as zlc ,sum(sh) as sh from bsth_c_ylb where nbbm=?1 and rq=?2 and xlbm like %?3%",nativeQuery=true) | |
| 54 | + @Query(value="select ifnull(jzl,0),ifnull(zlc,0),ifnull(sh,0) from bsth_c_ylb where nbbm=?1 and rq=?2 and xlbm like %?3%",nativeQuery=true) | |
| 55 | 55 | List<Object[]> sumLcYl(String nbbm,Date rq,String xlbm); |
| 56 | 56 | |
| 57 | 57 | /** |
| ... | ... | @@ -71,7 +71,7 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 71 | 71 | List<Object[]> checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm); |
| 72 | 72 | |
| 73 | 73 | |
| 74 | - @Query(value="select sum(s.jzl),sum(s.yh),sum(s.sh) from Ylb s " | |
| 74 | + @Query(value="select jzl,yh,sh from Ylb s " | |
| 75 | 75 | + " where to_days(?1)=to_days(s.rq) " |
| 76 | 76 | + " and s.ssgsdm like %?2% " |
| 77 | 77 | + " and s.fgsdm like %?3%" |
| ... | ... | @@ -81,7 +81,7 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 81 | 81 | |
| 82 | 82 | @Transactional |
| 83 | 83 | @Modifying |
| 84 | - @Query(value="select sum(jzl),sum(yh),sum(sh) from bsth_c_ylb " | |
| 84 | + @Query(value="select ifnull(jzl,0),ifnull(yh,0),ifnull(sh,0) from bsth_c_ylb " | |
| 85 | 85 | + " where to_days(?1)=to_days(rq) " |
| 86 | 86 | + " and ssgsdm like %?2% " |
| 87 | 87 | + " and fgsdm like %?3%" | ... | ... |
src/main/java/com/bsth/service/oil/YlbService.java
| ... | ... | @@ -15,7 +15,7 @@ public interface YlbService extends BaseService<Ylb, Integer>{ |
| 15 | 15 | |
| 16 | 16 | Map<String, Object> checkYl(Map<String, Object> map); |
| 17 | 17 | |
| 18 | - List<Object[]> sumYlb(Map<String, Object> map); | |
| 18 | + Map<String, Object> sumYlb(Map<String, Object> map); | |
| 19 | 19 | |
| 20 | 20 | List<Ylb> oilListMonth(String line,String date); |
| 21 | 21 | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -38,6 +38,7 @@ import com.bsth.repository.oil.YlxxbRepository; |
| 38 | 38 | import com.bsth.service.impl.BaseServiceImpl; |
| 39 | 39 | import com.bsth.service.oil.YlbService; |
| 40 | 40 | import com.bsth.service.realcontrol.ScheduleRealInfoService; |
| 41 | +import com.bsth.util.Arith; | |
| 41 | 42 | import com.bsth.util.BatchSaveUtils; |
| 42 | 43 | import com.github.abel533.echarts.code.Y; |
| 43 | 44 | |
| ... | ... | @@ -298,9 +299,16 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 298 | 299 | Ylxxb ylxxb = ylxxList.get(j); |
| 299 | 300 | if (map.get("clZbh").toString().equals(ylxxb.getNbbm()) |
| 300 | 301 | && map.get("jGh").toString().equals(ylxxb.getJsy())) { |
| 301 | - jzl += ylxxb.getJzl(); | |
| 302 | +// jzl += ylxxb.getJzl(); | |
| 303 | + jzl =Arith.add(jzl, ylxxb.getJzl()); | |
| 302 | 304 | } |
| 303 | 305 | } |
| 306 | + if(map.get("clZbh").toString().equals("W0A-212")){ | |
| 307 | + System.out.println(); | |
| 308 | + } | |
| 309 | + if(map.get("clZbh").toString().equals("W0A-211")){ | |
| 310 | + System.out.println(); | |
| 311 | + } | |
| 304 | 312 | t.setJzl(jzl); |
| 305 | 313 | t.setNbbm(map.get("clZbh").toString()); |
| 306 | 314 | t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString()); |
| ... | ... | @@ -389,13 +397,17 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 389 | 397 | // 得到一天总的加油和里程(根据车,时间) |
| 390 | 398 | List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm()); |
| 391 | 399 | // 保存总的加油量 |
| 392 | - Double jzl = Double.valueOf(sumList.get(0)[0].toString()); | |
| 400 | + Double jzl = 0.0; | |
| 393 | 401 | // 保存总的里程 |
| 394 | - Double zlc = Double.valueOf(sumList.get(0)[1].toString()); | |
| 395 | - | |
| 396 | - Double zsh = Double.valueOf(sumList.get(0)[2].toString()); | |
| 397 | - | |
| 398 | - jzl=jzl-zsh; | |
| 402 | + Double zlc = 0.0; | |
| 403 | + //保存总的损耗 | |
| 404 | + Double zsh = 0.0; | |
| 405 | + for (int j = 0; j < sumList.size(); j++) { | |
| 406 | + jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString())); | |
| 407 | + zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString())); | |
| 408 | + zsh = Arith.add(zsh, Double.valueOf(sumList.get(j)[2].toString())); | |
| 409 | + } | |
| 410 | + jzl = Arith.sub(jzl, zsh); | |
| 399 | 411 | // 保留两位小数 |
| 400 | 412 | DecimalFormat df = new DecimalFormat("#.00"); |
| 401 | 413 | Double zyl = 0.0; |
| ... | ... | @@ -417,17 +429,23 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 417 | 429 | // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量 |
| 418 | 430 | Double yl = t.getCzyl(); |
| 419 | 431 | Double jcyl = t.getCzyl(); |
| 420 | - zyl = jcyl + jzl - yl; | |
| 432 | +// zyl = jcyl + jzl - yl; | |
| 433 | + zyl =Arith.sub( Arith.add(jcyl, jzl),yl); | |
| 421 | 434 | Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 422 | 435 | t.setYh(yh); |
| 423 | - nextJzyl = t.getJzl() + t.getCzyl() - yh; | |
| 424 | - t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 436 | +// nextJzyl = t.getJzl() + t.getCzyl() - yh; | |
| 437 | + nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh); | |
| 438 | +// t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 439 | + t.setJzyl(nextJzyl); | |
| 425 | 440 | } else { |
| 426 | - t.setCzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 441 | +// t.setCzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 442 | + t.setCzyl(nextJzyl); | |
| 427 | 443 | Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 428 | 444 | t.setYh(yh); |
| 429 | - nextJzyl = t.getJzl() + nextJzyl - yh; | |
| 430 | - t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 445 | +// nextJzyl = t.getJzl() + nextJzyl - yh; | |
| 446 | + nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh); | |
| 447 | +// t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 448 | + t.setJzyl(nextJzyl); | |
| 431 | 449 | } |
| 432 | 450 | repository.save(t); |
| 433 | 451 | } |
| ... | ... | @@ -490,18 +508,27 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 490 | 508 | // 得到一天总的加油和里程(根据车,时间) |
| 491 | 509 | List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm()); |
| 492 | 510 | // 保存总的加油量 |
| 493 | - Double jzl = Double.valueOf(sumList.get(0)[0].toString()); | |
| 511 | + Double jzl = 0.0; | |
| 494 | 512 | // 保存总的里程 |
| 495 | - Double zlc = Double.valueOf(sumList.get(0)[1].toString()); | |
| 496 | - // 保存总的损耗 | |
| 497 | - Double zsh = Double.valueOf(sumList.get(0)[2].toString()); | |
| 513 | + Double zlc = 0.0; | |
| 514 | + //保存总的损耗 | |
| 515 | + Double zsh = 0.0; | |
| 516 | + for (int j = 0; j < sumList.size(); j++) { | |
| 517 | + jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString())); | |
| 518 | + zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString())); | |
| 519 | + zsh = Arith.add(zsh, Double.valueOf(sumList.get(j)[2].toString())); | |
| 520 | + } | |
| 521 | + jzl = Arith.sub(jzl, zsh); | |
| 498 | 522 | |
| 499 | 523 | //新的 损耗不等于 旧的损耗 总损耗从新算 |
| 500 | - if(ylb.getSh() - sh >0.0000001 || ylb.getSh()-sh <0.00000001){ | |
| 501 | - zsh =zsh-ylb.getSh()+sh; | |
| 502 | - jzl =jzl-zsh; | |
| 524 | + if(Arith.sub(ylb.getSh(),sh )!=0){ | |
| 525 | +// zsh =zsh-ylb.getSh()+sh; | |
| 526 | + zsh =Arith.add(Arith.sub(zsh, ylb.getSh()), sh); | |
| 527 | +// jzl =jzl-zsh; | |
| 528 | + jzl =Arith.sub(jzl, zsh); | |
| 503 | 529 | }else{ |
| 504 | - jzl=jzl-zsh; | |
| 530 | +// jzl=jzl-zsh; | |
| 531 | + jzl =Arith.sub(jzl, zsh); | |
| 505 | 532 | } |
| 506 | 533 | map.put("nbbm_eq", nbbm_eq); |
| 507 | 534 | map.put("rq_eq", rq_eq); |
| ... | ... | @@ -523,25 +550,31 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 523 | 550 | t.setShyy(shyy); |
| 524 | 551 | } |
| 525 | 552 | Double jcyl = t.getCzyl(); |
| 526 | - zyl = jcyl + jzl - yl; | |
| 553 | +// zyl = jcyl + jzl - yl; | |
| 554 | + zyl = Arith.sub(Arith.add(jcyl, jzl), yl); | |
| 527 | 555 | Double yh = 0.0; |
| 528 | 556 | if (zlc > 0 && t.getZlc() > 0) { |
| 529 | 557 | yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 530 | 558 | } |
| 531 | 559 | t.setYh(yh); |
| 532 | - nextJzyl = t.getJzl() + t.getCzyl() - yh-t.getSh(); | |
| 533 | - t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 560 | +// nextJzyl = t.getJzl() + t.getCzyl() - yh-t.getSh(); | |
| 561 | + nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh())); | |
| 562 | +// t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 563 | + t.setJzyl(nextJzyl); | |
| 534 | 564 | } else { |
| 535 | 565 | if(t.getId()==id){ |
| 536 | 566 | t.setSh(sh); |
| 537 | 567 | t.setShyy(shyy); |
| 538 | 568 | } |
| 539 | 569 | if (t.getZlc() != 0) { |
| 540 | - t.setCzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 570 | +// t.setCzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 571 | + t.setCzyl(nextJzyl); | |
| 541 | 572 | Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 542 | 573 | t.setYh(yh); |
| 543 | - nextJzyl = t.getJzl() + nextJzyl - yh-t.getSh(); | |
| 544 | - t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 574 | +// nextJzyl = t.getJzl() + nextJzyl - yh-t.getSh(); | |
| 575 | + nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh())); | |
| 576 | +// t.setJzyl(Double.parseDouble(df.format(nextJzyl))); | |
| 577 | + t.setJzyl(nextJzyl); | |
| 545 | 578 | } |
| 546 | 579 | |
| 547 | 580 | } |
| ... | ... | @@ -642,7 +675,8 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 642 | 675 | for(int z=0;z<cylList.size();z++){ |
| 643 | 676 | cyl=cylList.get(z); |
| 644 | 677 | if(t.getNbbm().equals(cyl.getNbbm())){ |
| 645 | - cyl.setCyl(cyl.getCyl()+t.getJzl()); | |
| 678 | +// cyl.setCyl(cyl.getCyl()+t.getJzl()); | |
| 679 | + cyl.setCyl(Arith.add(cyl.getCyl(),t.getJzl())); | |
| 646 | 680 | cyl.setUpdatetime(t.getRq()); |
| 647 | 681 | status=true; |
| 648 | 682 | break; |
| ... | ... | @@ -734,7 +768,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 734 | 768 | |
| 735 | 769 | |
| 736 | 770 | @Override |
| 737 | - public List<Object[]> sumYlb(Map<String, Object> map) { | |
| 771 | + public Map<String, Object> sumYlb(Map<String, Object> map) { | |
| 738 | 772 | // TODO Auto-generated method stub |
| 739 | 773 | List<String> stringList=new ArrayList<String>(); |
| 740 | 774 | String rq=map.get("rq").toString(); |
| ... | ... | @@ -784,7 +818,17 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 784 | 818 | |
| 785 | 819 | } |
| 786 | 820 | |
| 821 | + Double jzl=0.0,yh=0.0,sh=0.0; | |
| 822 | + for (int i = 0; i < sumYlbList.size(); i++) { | |
| 823 | + jzl = Arith.add(jzl, Double.valueOf(sumYlbList.get(i)[0].toString())); | |
| 824 | + yh = Arith.add(yh, Double.valueOf(sumYlbList.get(i)[1].toString())); | |
| 825 | + sh = Arith.add(sh, Double.valueOf(sumYlbList.get(i)[2].toString())); | |
| 826 | + } | |
| 787 | 827 | |
| 828 | + Map<String, Object> sumMap=new HashMap<String,Object>(); | |
| 829 | + sumMap.put("jzl", jzl); | |
| 830 | + sumMap.put("yh", yh); | |
| 831 | + sumMap.put("sh", sh); | |
| 788 | 832 | // String sql="select sum(jzl),sum(yh),sum(sh) from bsth_c_ylb " |
| 789 | 833 | // + " where to_days('"+map.get("rq").toString()+"')=to_days(rq) " |
| 790 | 834 | // + " and ssgsdm like '%"+map.get("ssgsdm_like").toString()+"%' " |
| ... | ... | @@ -794,7 +838,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 794 | 838 | // if(map.get("nbbm_in")!=null){ |
| 795 | 839 | //// sql +=" and nbbm in (" |
| 796 | 840 | // } |
| 797 | - return sumYlbList; | |
| 841 | + return sumMap; | |
| 798 | 842 | } |
| 799 | 843 | |
| 800 | 844 | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -1529,7 +1529,26 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1529 | 1529 | listSchedule.add(s); |
| 1530 | 1530 | //计算营运里程,空驶里程 |
| 1531 | 1531 | if (!childTaskPlans.isEmpty()) { |
| 1532 | - String sqlPc = "select * from bsth_c_s_child_task where schedule=" + s.getId() + " order by start_date "; | |
| 1532 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 1533 | + while (it.hasNext()) { | |
| 1534 | + ScheduleRealInfo t = new ScheduleRealInfo(); | |
| 1535 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 1536 | + if (childTaskPlan.isDestroy()) { | |
| 1537 | + t.setFcsjActual(""); | |
| 1538 | + t.setZdsjActual(""); | |
| 1539 | + t.setJhlc(0.0); | |
| 1540 | + } else { | |
| 1541 | + t.setFcsjActual(childTaskPlan.getStartDate()); | |
| 1542 | + t.setZdsjActual(childTaskPlan.getEndDate()); | |
| 1543 | + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | |
| 1544 | + } | |
| 1545 | + t.setQdzName(childTaskPlan.getStartStationName()); | |
| 1546 | + t.setZdzName(childTaskPlan.getEndStationName()); | |
| 1547 | + t.setRemarks(childTaskPlan.getRemarks()); | |
| 1548 | + t.setAdjustExps("子"); | |
| 1549 | + listSchedule.add(t); | |
| 1550 | + } | |
| 1551 | + /* String sqlPc = "select * from bsth_c_s_child_task where schedule=" + s.getId() + " order by start_date "; | |
| 1533 | 1552 | List<ScheduleRealInfo> lists = jdbcTemplate.query(sqlPc, |
| 1534 | 1553 | new RowMapper<ScheduleRealInfo>() { |
| 1535 | 1554 | @Override |
| ... | ... | @@ -1554,7 +1573,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1554 | 1573 | for (int j = 0; j < lists.size(); j++) { |
| 1555 | 1574 | ScheduleRealInfo t = lists.get(j); |
| 1556 | 1575 | listSchedule.add(t); |
| 1557 | - } | |
| 1576 | + }*/ | |
| 1558 | 1577 | } |
| 1559 | 1578 | } |
| 1560 | 1579 | |
| ... | ... | @@ -2870,6 +2889,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2870 | 2889 | } |
| 2871 | 2890 | |
| 2872 | 2891 | public List<Map<String, Object>> yesterdayDataList(String line, String date,String gsbm,String fgsbm,String jGh,String nbbm) { |
| 2892 | +// Arith arith=new Arith(); | |
| 2873 | 2893 | //前一天日期 |
| 2874 | 2894 | // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1)); |
| 2875 | 2895 | // String date = "2016-09-20"; |
| ... | ... | @@ -2884,7 +2904,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2884 | 2904 | String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); |
| 2885 | 2905 | |
| 2886 | 2906 | double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0; |
| 2887 | - float addMileage = 0l, remMileage = 0l; | |
| 2907 | + double addMileage = 0, remMileage = 0; | |
| 2888 | 2908 | Map<String, Object> map = new HashMap<String, Object>(); |
| 2889 | 2909 | boolean fage = true; |
| 2890 | 2910 | String company=""; |
| ... | ... | @@ -2905,16 +2925,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2905 | 2925 | tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); |
| 2906 | 2926 | if (scheduleRealInfo.isSflj()) { |
| 2907 | 2927 | if(scheduleRealInfo.getStatus() == -1){ |
| 2908 | - addMileage += tempJhlc; | |
| 2928 | +// addMileage += tempJhlc; | |
| 2929 | + addMileage =Arith.add(addMileage, tempJhlc); | |
| 2909 | 2930 | } |
| 2910 | 2931 | } else { |
| 2911 | 2932 | if (!(scheduleRealInfo.getBcType().equals("in") |
| 2912 | 2933 | || scheduleRealInfo.getBcType().equals("out"))) { |
| 2913 | - jhlc += tempJhlc; | |
| 2934 | +// jhlc += tempJhlc; | |
| 2935 | + jhlc =Arith.add(jhlc,tempJhlc); | |
| 2914 | 2936 | } |
| 2915 | 2937 | |
| 2916 | 2938 | if (scheduleRealInfo.getStatus() == -1) { |
| 2917 | - remMileage += tempJhlc; | |
| 2939 | +// remMileage += tempJhlc; | |
| 2940 | + remMileage =Arith.add(remMileage,tempJhlc); | |
| 2918 | 2941 | } |
| 2919 | 2942 | } |
| 2920 | 2943 | Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); |
| ... | ... | @@ -2923,7 +2946,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2923 | 2946 | if (scheduleRealInfo.getBcType().equals("in") || |
| 2924 | 2947 | scheduleRealInfo.getBcType().equals("out")) { |
| 2925 | 2948 | if (scheduleRealInfo.getStatus() != -1) { |
| 2926 | - jcclc += tempJhlc; | |
| 2949 | +// jcclc += tempJhlc; | |
| 2950 | + jcclc=Arith.add(jcclc,tempJhlc); | |
| 2927 | 2951 | } |
| 2928 | 2952 | } |
| 2929 | 2953 | //主任务 放空班次属于营运 |
| ... | ... | @@ -2932,7 +2956,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2932 | 2956 | // } |
| 2933 | 2957 | else { |
| 2934 | 2958 | if (scheduleRealInfo.getStatus() != -1) { |
| 2935 | - yygl += tempJhlc; | |
| 2959 | +// yygl += tempJhlc; | |
| 2960 | + yygl=Arith.add(yygl,tempJhlc); | |
| 2936 | 2961 | } |
| 2937 | 2962 | } |
| 2938 | 2963 | } else { |
| ... | ... | @@ -2941,15 +2966,21 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2941 | 2966 | ChildTaskPlan childTaskPlan = it.next(); |
| 2942 | 2967 | if (childTaskPlan.getMileageType().equals("empty")) { |
| 2943 | 2968 | if (childTaskPlan.isDestroy()) { |
| 2944 | - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2969 | +// remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2970 | + remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); | |
| 2945 | 2971 | } else { |
| 2946 | - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2972 | +// ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2973 | + ksgl += Arith.add(ksgl,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); | |
| 2947 | 2974 | } |
| 2948 | 2975 | } else { |
| 2949 | 2976 | if (childTaskPlan.isDestroy()) { |
| 2950 | - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2977 | +// remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2978 | + remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); | |
| 2979 | + | |
| 2951 | 2980 | } else { |
| 2952 | - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2981 | +// yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 2982 | + yygl=Arith.add(yygl,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); | |
| 2983 | + | |
| 2953 | 2984 | } |
| 2954 | 2985 | } |
| 2955 | 2986 | } |
| ... | ... | @@ -2959,7 +2990,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2959 | 2990 | } |
| 2960 | 2991 | yesterdayDataList.get(x).put("company", company); |
| 2961 | 2992 | yesterdayDataList.get(x).put("bCompany", bCompany); |
| 2962 | - yesterdayDataList.get(x).put("totalKilometers", yygl + ksgl + jcclc); | |
| 2993 | + Double zgl=Arith.add(yygl,ksgl); | |
| 2994 | + yesterdayDataList.get(x).put("totalKilometers", Arith.add(zgl, jcclc)); | |
| 2963 | 2995 | |
| 2964 | 2996 | } |
| 2965 | 2997 | System.out.println(); | ... | ... |
src/main/java/com/bsth/util/Arith.java
0 → 100644
| 1 | +package com.bsth.util; | |
| 2 | + | |
| 3 | +import java.math.BigDecimal; | |
| 4 | + | |
| 5 | +public class Arith { | |
| 6 | + /** | |
| 7 | + * 由于Java的简单类型不能够精确的对浮点数进行运算,这个工具类提供精 | |
| 8 | + * 确的浮点数运算,包括加减乘除和四舍五入。 | |
| 9 | + */ | |
| 10 | + //默认除法运算精度 | |
| 11 | + private static final int DEF_DIV_SCALE = 10; | |
| 12 | + | |
| 13 | + //这个类不能实例化 | |
| 14 | + private Arith(){ | |
| 15 | + } | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 提供精确的加法运算。 | |
| 19 | + * @param v1 被加数 | |
| 20 | + * @param v2 加数 | |
| 21 | + * @return 两个参数的和 | |
| 22 | + */ | |
| 23 | + public static double add(double v1,double v2){ | |
| 24 | + BigDecimal b1 = new BigDecimal(Double.toString(v1)); | |
| 25 | + BigDecimal b2 = new BigDecimal(Double.toString(v2)); | |
| 26 | + return b1.add(b2).doubleValue(); | |
| 27 | + } | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 提供精确的减法运算。 | |
| 31 | + * @param v1 被减数 | |
| 32 | + * @param v2 减数 | |
| 33 | + * @return 两个参数的差 | |
| 34 | + */ | |
| 35 | + public static double sub(double v1,double v2){ | |
| 36 | + BigDecimal b1 = new BigDecimal(Double.toString(v1)); | |
| 37 | + BigDecimal b2 = new BigDecimal(Double.toString(v2)); | |
| 38 | + return b1.subtract(b2).doubleValue(); | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 提供精确的乘法运算。 | |
| 43 | + * @param v1 被乘数 | |
| 44 | + * @param v2 乘数 | |
| 45 | + * @return 两个参数的积 | |
| 46 | + */ | |
| 47 | + public static double mul(double v1,double v2){ | |
| 48 | + BigDecimal b1 = new BigDecimal(Double.toString(v1)); | |
| 49 | + BigDecimal b2 = new BigDecimal(Double.toString(v2)); | |
| 50 | + return b1.multiply(b2).doubleValue(); | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 | |
| 55 | + * 小数点以后10位,以后的数字四舍五入。 | |
| 56 | + * @param v1 被除数 | |
| 57 | + * @param v2 除数 | |
| 58 | + * @return 两个参数的商 | |
| 59 | + */ | |
| 60 | + public static double div(double v1,double v2){ | |
| 61 | + return div(v1,v2,DEF_DIV_SCALE); | |
| 62 | + } | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 | |
| 66 | + * 定精度,以后的数字四舍五入。 | |
| 67 | + * @param v1 被除数 | |
| 68 | + * @param v2 除数 | |
| 69 | + * @param scale 表示表示需要精确到小数点以后几位。 | |
| 70 | + * @return 两个参数的商 | |
| 71 | + */ | |
| 72 | + public static double div(double v1,double v2,int scale){ | |
| 73 | + if(scale<0){ | |
| 74 | + throw new IllegalArgumentException( | |
| 75 | + "The scale must be a positive integer or zero"); | |
| 76 | + } | |
| 77 | + BigDecimal b1 = new BigDecimal(Double.toString(v1)); | |
| 78 | + BigDecimal b2 = new BigDecimal(Double.toString(v2)); | |
| 79 | + return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * 提供精确的小数位四舍五入处理。 | |
| 84 | + * @param v 需要四舍五入的数字 | |
| 85 | + * @param scale 小数点后保留几位 | |
| 86 | + * @return 四舍五入后的结果 | |
| 87 | + */ | |
| 88 | + public static double round(double v,int scale){ | |
| 89 | + if(scale<0){ | |
| 90 | + throw new IllegalArgumentException( | |
| 91 | + "The scale must be a positive integer or zero"); | |
| 92 | + } | |
| 93 | + BigDecimal b = new BigDecimal(Double.toString(v)); | |
| 94 | + BigDecimal one = new BigDecimal("1"); | |
| 95 | + return b.divide(one,scale,BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 96 | + } | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * 提供精确的类型转换(Float) | |
| 100 | + * @param v 需要被转换的数字 | |
| 101 | + * @return 返回转换结果 | |
| 102 | + */ | |
| 103 | + public static float convertsToFloat(double v){ | |
| 104 | + BigDecimal b = new BigDecimal(v); | |
| 105 | + return b.floatValue(); | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * 提供精确的类型转换(Int)不进行四舍五入 | |
| 110 | + * @param v 需要被转换的数字 | |
| 111 | + * @return 返回转换结果 | |
| 112 | + */ | |
| 113 | + public static int convertsToInt(double v){ | |
| 114 | + BigDecimal b = new BigDecimal(v); | |
| 115 | + return b.intValue(); | |
| 116 | + } | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * 提供精确的类型转换(Long) | |
| 120 | + * @param v 需要被转换的数字 | |
| 121 | + * @return 返回转换结果 | |
| 122 | + */ | |
| 123 | + public static long convertsToLong(double v){ | |
| 124 | + BigDecimal b = new BigDecimal(v); | |
| 125 | + return b.longValue(); | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * 返回两个数中大的一个值 | |
| 130 | + * @param v1 需要被对比的第一个数 | |
| 131 | + * @param v2 需要被对比的第二个数 | |
| 132 | + * @return 返回两个数中大的一个值 | |
| 133 | + */ | |
| 134 | + public static double returnMax(double v1,double v2){ | |
| 135 | + BigDecimal b1 = new BigDecimal(v1); | |
| 136 | + BigDecimal b2 = new BigDecimal(v2); | |
| 137 | + return b1.max(b2).doubleValue(); | |
| 138 | + } | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * 返回两个数中小的一个值 | |
| 142 | + * @param v1 需要被对比的第一个数 | |
| 143 | + * @param v2 需要被对比的第二个数 | |
| 144 | + * @return 返回两个数中小的一个值 | |
| 145 | + */ | |
| 146 | + public static double returnMin(double v1,double v2){ | |
| 147 | + BigDecimal b1 = new BigDecimal(v1); | |
| 148 | + BigDecimal b2 = new BigDecimal(v2); | |
| 149 | + return b1.min(b2).doubleValue(); | |
| 150 | + } | |
| 151 | + | |
| 152 | + /** | |
| 153 | + * 精确对比两个数字 | |
| 154 | + * @param v1 需要被对比的第一个数 | |
| 155 | + * @param v2 需要被对比的第二个数 | |
| 156 | + * @return 如果两个数一样则返回0,如果第一个数比第二个数大则返回1,反之返回-1 | |
| 157 | + */ | |
| 158 | + public static int compareTo(double v1,double v2){ | |
| 159 | + BigDecimal b1 = new BigDecimal(v1); | |
| 160 | + BigDecimal b2 = new BigDecimal(v2); | |
| 161 | + return b1.compareTo(b2); | |
| 162 | + } | |
| 163 | +} | ... | ... |
src/main/resources/static/pages/oil/checkJyryList.html
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | class="caption-subject font-dark sbold uppercase">加油人员不符</span> |
| 21 | 21 | </div> |
| 22 | 22 | <div class="actions"> |
| 23 | - <a class="btn btn-circle blue" href="cylAdd.html" data-pjax><i class="fa fa-plus"></i> 添加</a> | |
| 23 | +<!-- <a class="btn btn-circle blue" href="cylAdd.html" data-pjax><i class="fa fa-plus"></i> 添加</a> --> | |
| 24 | 24 | <button type="button" class="btn btn-circle blue" id="saveButton"><i class="fa fa-minus-square"></i> 保存</button> |
| 25 | 25 | <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> 删除用户</button> --> |
| 26 | 26 | <!-- <div class="btn-group"> | ... | ... |
src/main/resources/static/pages/oil/list_ph.html
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | </div> |
| 22 | 22 | <div class="actions"> |
| 23 | 23 | <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加</a> |
| 24 | - <!-- <button type="button" class="btn btn-circle blue" id="removeButton"><i class="fa fa-trash-o"></i> 删除</button> --> | |
| 24 | + <button type="button" class="btn btn-circle blue" id="removeButton"><i class="fa fa-trash-o"></i> 删除</button> | |
| 25 | 25 | <button type="button" class="btn btn-circle blue" id="sortButton"><i class="fa fa-minus-square"></i> |
| 26 | 26 | 拆分/保存 |
| 27 | 27 | </button> |
| ... | ... | @@ -293,7 +293,8 @@ |
| 293 | 293 | } else { |
| 294 | 294 | layer.msg('请选择日期.'); |
| 295 | 295 | } |
| 296 | - }) | |
| 296 | + }); | |
| 297 | + | |
| 297 | 298 | //拆分 |
| 298 | 299 | $("#sortButton").on('click', function () { |
| 299 | 300 | if ($("#rq").val() != "") { |
| ... | ... | @@ -489,10 +490,11 @@ |
| 489 | 490 | } |
| 490 | 491 | layer.close(l); |
| 491 | 492 | $get('/ylb/sumYlb',params,function(returns){ |
| 492 | - console.log(returns[0]) | |
| 493 | - $("#sumJzl").html(returns[0][0]); | |
| 494 | - $("#sumYh").html(returns[0][1]); | |
| 495 | - $("#sumSh").html(returns[0][2]); | |
| 493 | + console.log(returns); | |
| 494 | + console.log(returns.jzl); | |
| 495 | + $("#sumJzl").html(returns.jzl); | |
| 496 | + $("#sumYh").html(returns.yh); | |
| 497 | + $("#sumSh").html(returns.sh); | |
| 496 | 498 | }); |
| 497 | 499 | startOptJzylLink($('#ll_oil_list .in_carpark_jzyl')); |
| 498 | 500 | startOptShylLink($('#ll_oil_list .in_carpark_shyl')); |
| ... | ... | @@ -582,13 +584,15 @@ |
| 582 | 584 | |
| 583 | 585 | //删除 |
| 584 | 586 | $('#removeButton').on('click', function () { |
| 585 | - if ($(this).attr('disabled')) | |
| 586 | - return; | |
| 587 | - | |
| 588 | - var id = $('input.icheck:checked').data('id'); | |
| 589 | - removeConfirm('确定要删除选中的数据?', '/resource/' + id, function () { | |
| 590 | - $('tr.filter .filter-submit').click(); | |
| 591 | - }); | |
| 587 | + var id = $('input.icheck:checked').data('id'); | |
| 588 | + if (typeof(id) == 'undefined') { | |
| 589 | + layer.msg("请选择要删除的数据"); | |
| 590 | + }else{ | |
| 591 | + removeConfirm('确定要删除选中的数据?', '/ylb/' + id, function () { | |
| 592 | + var params=getParamsList(); | |
| 593 | + jsDoQuery(params, true); | |
| 594 | + }); | |
| 595 | + } | |
| 592 | 596 | }); |
| 593 | 597 | |
| 594 | 598 | //搜索线路 | ... | ... |