Commit 9c3813657f23112d610d8619d50baf7dfc6bcc38

Authored by 廖磊
1 parent 68f800a0

油量管理 去很长的小数点

src/main/java/com/bsth/controller/oil/YlbController.java
@@ -163,8 +163,8 @@ public class YlbController extends BaseController<Ylb, Integer>{ @@ -163,8 +163,8 @@ public class YlbController extends BaseController<Ylb, Integer>{
163 } 163 }
164 164
165 @RequestMapping(value = "/sumYlb",method = RequestMethod.GET) 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 return list; 168 return list;
169 } 169 }
170 170
src/main/java/com/bsth/entity/oil/Ylb.java
@@ -30,7 +30,7 @@ public class Ylb { @@ -30,7 +30,7 @@ public class Ylb {
30 private Double jzlc=0.0; 30 private Double jzlc=0.0;
31 private Double czyl=0.0; 31 private Double czyl=0.0;
32 private Double jzyl=0.0; 32 private Double jzyl=0.0;
33 - private Double jzl; 33 + private Double jzl=0.0;
34 private int sfkt; 34 private int sfkt;
35 private String jhsj; 35 private String jhsj;
36 private Double yh=0.0; 36 private Double yh=0.0;
src/main/java/com/bsth/repository/oil/YlbRepository.java
@@ -51,7 +51,7 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{ @@ -51,7 +51,7 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
51 */ 51 */
52 @Transactional 52 @Transactional
53 @Modifying 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 List<Object[]> sumLcYl(String nbbm,Date rq,String xlbm); 55 List<Object[]> sumLcYl(String nbbm,Date rq,String xlbm);
56 56
57 /** 57 /**
@@ -71,7 +71,7 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{ @@ -71,7 +71,7 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
71 List<Object[]> checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm); 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 + " where to_days(?1)=to_days(s.rq) " 75 + " where to_days(?1)=to_days(s.rq) "
76 + " and s.ssgsdm like %?2% " 76 + " and s.ssgsdm like %?2% "
77 + " and s.fgsdm like %?3%" 77 + " and s.fgsdm like %?3%"
@@ -81,7 +81,7 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{ @@ -81,7 +81,7 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
81 81
82 @Transactional 82 @Transactional
83 @Modifying 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 + " where to_days(?1)=to_days(rq) " 85 + " where to_days(?1)=to_days(rq) "
86 + " and ssgsdm like %?2% " 86 + " and ssgsdm like %?2% "
87 + " and fgsdm like %?3%" 87 + " and fgsdm like %?3%"
src/main/java/com/bsth/service/oil/YlbService.java
@@ -15,7 +15,7 @@ public interface YlbService extends BaseService&lt;Ylb, Integer&gt;{ @@ -15,7 +15,7 @@ public interface YlbService extends BaseService&lt;Ylb, Integer&gt;{
15 15
16 Map<String, Object> checkYl(Map<String, Object> map); 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 List<Ylb> oilListMonth(String line,String date); 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,6 +38,7 @@ import com.bsth.repository.oil.YlxxbRepository;
38 import com.bsth.service.impl.BaseServiceImpl; 38 import com.bsth.service.impl.BaseServiceImpl;
39 import com.bsth.service.oil.YlbService; 39 import com.bsth.service.oil.YlbService;
40 import com.bsth.service.realcontrol.ScheduleRealInfoService; 40 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  41 +import com.bsth.util.Arith;
41 import com.bsth.util.BatchSaveUtils; 42 import com.bsth.util.BatchSaveUtils;
42 import com.github.abel533.echarts.code.Y; 43 import com.github.abel533.echarts.code.Y;
43 44
@@ -298,9 +299,16 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -298,9 +299,16 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
298 Ylxxb ylxxb = ylxxList.get(j); 299 Ylxxb ylxxb = ylxxList.get(j);
299 if (map.get("clZbh").toString().equals(ylxxb.getNbbm()) 300 if (map.get("clZbh").toString().equals(ylxxb.getNbbm())
300 && map.get("jGh").toString().equals(ylxxb.getJsy())) { 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 t.setJzl(jzl); 312 t.setJzl(jzl);
305 t.setNbbm(map.get("clZbh").toString()); 313 t.setNbbm(map.get("clZbh").toString());
306 t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString()); 314 t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString());
@@ -389,13 +397,17 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -389,13 +397,17 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
389 // 得到一天总的加油和里程(根据车,时间) 397 // 得到一天总的加油和里程(根据车,时间)
390 List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm()); 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 DecimalFormat df = new DecimalFormat("#.00"); 412 DecimalFormat df = new DecimalFormat("#.00");
401 Double zyl = 0.0; 413 Double zyl = 0.0;
@@ -417,17 +429,23 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -417,17 +429,23 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
417 // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量 429 // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量
418 Double yl = t.getCzyl(); 430 Double yl = t.getCzyl();
419 Double jcyl = t.getCzyl(); 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 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); 434 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
422 t.setYh(yh); 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 } else { 440 } else {
426 - t.setCzyl(Double.parseDouble(df.format(nextJzyl))); 441 +// t.setCzyl(Double.parseDouble(df.format(nextJzyl)));
  442 + t.setCzyl(nextJzyl);
427 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); 443 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
428 t.setYh(yh); 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 repository.save(t); 450 repository.save(t);
433 } 451 }
@@ -490,18 +508,27 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -490,18 +508,27 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
490 // 得到一天总的加油和里程(根据车,时间) 508 // 得到一天总的加油和里程(根据车,时间)
491 List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm()); 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 }else{ 529 }else{
504 - jzl=jzl-zsh; 530 +// jzl=jzl-zsh;
  531 + jzl =Arith.sub(jzl, zsh);
505 } 532 }
506 map.put("nbbm_eq", nbbm_eq); 533 map.put("nbbm_eq", nbbm_eq);
507 map.put("rq_eq", rq_eq); 534 map.put("rq_eq", rq_eq);
@@ -523,25 +550,31 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -523,25 +550,31 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
523 t.setShyy(shyy); 550 t.setShyy(shyy);
524 } 551 }
525 Double jcyl = t.getCzyl(); 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 Double yh = 0.0; 555 Double yh = 0.0;
528 if (zlc > 0 && t.getZlc() > 0) { 556 if (zlc > 0 && t.getZlc() > 0) {
529 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); 557 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
530 } 558 }
531 t.setYh(yh); 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 } else { 564 } else {
535 if(t.getId()==id){ 565 if(t.getId()==id){
536 t.setSh(sh); 566 t.setSh(sh);
537 t.setShyy(shyy); 567 t.setShyy(shyy);
538 } 568 }
539 if (t.getZlc() != 0) { 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 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); 572 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
542 t.setYh(yh); 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&lt;Ylb,Integer&gt; implements YlbS @@ -642,7 +675,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
642 for(int z=0;z<cylList.size();z++){ 675 for(int z=0;z<cylList.size();z++){
643 cyl=cylList.get(z); 676 cyl=cylList.get(z);
644 if(t.getNbbm().equals(cyl.getNbbm())){ 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 cyl.setUpdatetime(t.getRq()); 680 cyl.setUpdatetime(t.getRq());
647 status=true; 681 status=true;
648 break; 682 break;
@@ -734,7 +768,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -734,7 +768,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
734 768
735 769
736 @Override 770 @Override
737 - public List<Object[]> sumYlb(Map<String, Object> map) { 771 + public Map<String, Object> sumYlb(Map<String, Object> map) {
738 // TODO Auto-generated method stub 772 // TODO Auto-generated method stub
739 List<String> stringList=new ArrayList<String>(); 773 List<String> stringList=new ArrayList<String>();
740 String rq=map.get("rq").toString(); 774 String rq=map.get("rq").toString();
@@ -784,7 +818,17 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -784,7 +818,17 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; 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 // String sql="select sum(jzl),sum(yh),sum(sh) from bsth_c_ylb " 832 // String sql="select sum(jzl),sum(yh),sum(sh) from bsth_c_ylb "
789 // + " where to_days('"+map.get("rq").toString()+"')=to_days(rq) " 833 // + " where to_days('"+map.get("rq").toString()+"')=to_days(rq) "
790 // + " and ssgsdm like '%"+map.get("ssgsdm_like").toString()+"%' " 834 // + " and ssgsdm like '%"+map.get("ssgsdm_like").toString()+"%' "
@@ -794,7 +838,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -794,7 +838,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
794 // if(map.get("nbbm_in")!=null){ 838 // if(map.get("nbbm_in")!=null){
795 //// sql +=" and nbbm in (" 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&lt;ScheduleRealInf @@ -1529,7 +1529,26 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1529 listSchedule.add(s); 1529 listSchedule.add(s);
1530 //计算营运里程,空驶里程 1530 //计算营运里程,空驶里程
1531 if (!childTaskPlans.isEmpty()) { 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 List<ScheduleRealInfo> lists = jdbcTemplate.query(sqlPc, 1552 List<ScheduleRealInfo> lists = jdbcTemplate.query(sqlPc,
1534 new RowMapper<ScheduleRealInfo>() { 1553 new RowMapper<ScheduleRealInfo>() {
1535 @Override 1554 @Override
@@ -1554,7 +1573,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1554,7 +1573,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1554 for (int j = 0; j < lists.size(); j++) { 1573 for (int j = 0; j < lists.size(); j++) {
1555 ScheduleRealInfo t = lists.get(j); 1574 ScheduleRealInfo t = lists.get(j);
1556 listSchedule.add(t); 1575 listSchedule.add(t);
1557 - } 1576 + }*/
1558 } 1577 }
1559 } 1578 }
1560 1579
@@ -2870,6 +2889,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2870,6 +2889,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2870 } 2889 }
2871 2890
2872 public List<Map<String, Object>> yesterdayDataList(String line, String date,String gsbm,String fgsbm,String jGh,String nbbm) { 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 // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1)); 2894 // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
2875 // String date = "2016-09-20"; 2895 // String date = "2016-09-20";
@@ -2884,7 +2904,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2884,7 +2904,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2884 String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); 2904 String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
2885 2905
2886 double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0; 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 Map<String, Object> map = new HashMap<String, Object>(); 2908 Map<String, Object> map = new HashMap<String, Object>();
2889 boolean fage = true; 2909 boolean fage = true;
2890 String company=""; 2910 String company="";
@@ -2905,16 +2925,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2905,16 +2925,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2905 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); 2925 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
2906 if (scheduleRealInfo.isSflj()) { 2926 if (scheduleRealInfo.isSflj()) {
2907 if(scheduleRealInfo.getStatus() == -1){ 2927 if(scheduleRealInfo.getStatus() == -1){
2908 - addMileage += tempJhlc; 2928 +// addMileage += tempJhlc;
  2929 + addMileage =Arith.add(addMileage, tempJhlc);
2909 } 2930 }
2910 } else { 2931 } else {
2911 if (!(scheduleRealInfo.getBcType().equals("in") 2932 if (!(scheduleRealInfo.getBcType().equals("in")
2912 || scheduleRealInfo.getBcType().equals("out"))) { 2933 || scheduleRealInfo.getBcType().equals("out"))) {
2913 - jhlc += tempJhlc; 2934 +// jhlc += tempJhlc;
  2935 + jhlc =Arith.add(jhlc,tempJhlc);
2914 } 2936 }
2915 2937
2916 if (scheduleRealInfo.getStatus() == -1) { 2938 if (scheduleRealInfo.getStatus() == -1) {
2917 - remMileage += tempJhlc; 2939 +// remMileage += tempJhlc;
  2940 + remMileage =Arith.add(remMileage,tempJhlc);
2918 } 2941 }
2919 } 2942 }
2920 Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); 2943 Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
@@ -2923,7 +2946,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2923,7 +2946,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2923 if (scheduleRealInfo.getBcType().equals("in") || 2946 if (scheduleRealInfo.getBcType().equals("in") ||
2924 scheduleRealInfo.getBcType().equals("out")) { 2947 scheduleRealInfo.getBcType().equals("out")) {
2925 if (scheduleRealInfo.getStatus() != -1) { 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&lt;ScheduleRealInf @@ -2932,7 +2956,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2932 // } 2956 // }
2933 else { 2957 else {
2934 if (scheduleRealInfo.getStatus() != -1) { 2958 if (scheduleRealInfo.getStatus() != -1) {
2935 - yygl += tempJhlc; 2959 +// yygl += tempJhlc;
  2960 + yygl=Arith.add(yygl,tempJhlc);
2936 } 2961 }
2937 } 2962 }
2938 } else { 2963 } else {
@@ -2941,15 +2966,21 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2941,15 +2966,21 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2941 ChildTaskPlan childTaskPlan = it.next(); 2966 ChildTaskPlan childTaskPlan = it.next();
2942 if (childTaskPlan.getMileageType().equals("empty")) { 2967 if (childTaskPlan.getMileageType().equals("empty")) {
2943 if (childTaskPlan.isDestroy()) { 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 } else { 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 } else { 2975 } else {
2949 if (childTaskPlan.isDestroy()) { 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 } else { 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&lt;ScheduleRealInf @@ -2959,7 +2990,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2959 } 2990 }
2960 yesterdayDataList.get(x).put("company", company); 2991 yesterdayDataList.get(x).put("company", company);
2961 yesterdayDataList.get(x).put("bCompany", bCompany); 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 System.out.println(); 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,7 +20,7 @@
20 class="caption-subject font-dark sbold uppercase">加油人员不符</span> 20 class="caption-subject font-dark sbold uppercase">加油人员不符</span>
21 </div> 21 </div>
22 <div class="actions"> 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 <button type="button" class="btn btn-circle blue" id="saveButton"><i class="fa fa-minus-square"></i> 保存</button> 24 <button type="button" class="btn btn-circle blue" id="saveButton"><i class="fa fa-minus-square"></i> 保存</button>
25 <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> 删除用户</button> --> 25 <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> 删除用户</button> -->
26 <!-- <div class="btn-group"> 26 <!-- <div class="btn-group">
src/main/resources/static/pages/oil/list_ph.html
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 </div> 21 </div>
22 <div class="actions"> 22 <div class="actions">
23 <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加</a> 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 <button type="button" class="btn btn-circle blue" id="sortButton"><i class="fa fa-minus-square"></i> 25 <button type="button" class="btn btn-circle blue" id="sortButton"><i class="fa fa-minus-square"></i>
26 拆分/保存 26 拆分/保存
27 </button> 27 </button>
@@ -293,7 +293,8 @@ @@ -293,7 +293,8 @@
293 } else { 293 } else {
294 layer.msg('请选择日期.'); 294 layer.msg('请选择日期.');
295 } 295 }
296 - }) 296 + });
  297 +
297 //拆分 298 //拆分
298 $("#sortButton").on('click', function () { 299 $("#sortButton").on('click', function () {
299 if ($("#rq").val() != "") { 300 if ($("#rq").val() != "") {
@@ -489,10 +490,11 @@ @@ -489,10 +490,11 @@
489 } 490 }
490 layer.close(l); 491 layer.close(l);
491 $get('/ylb/sumYlb',params,function(returns){ 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 startOptJzylLink($('#ll_oil_list .in_carpark_jzyl')); 499 startOptJzylLink($('#ll_oil_list .in_carpark_jzyl'));
498 startOptShylLink($('#ll_oil_list .in_carpark_shyl')); 500 startOptShylLink($('#ll_oil_list .in_carpark_shyl'));
@@ -582,13 +584,15 @@ @@ -582,13 +584,15 @@
582 584
583 //删除 585 //删除
584 $('#removeButton').on('click', function () { 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 //搜索线路