Commit 8dd33389047b01b24f1467fd23a8e5cce4c85931

Authored by 廖磊
1 parent 3c3df9d7

油量计算

src/main/java/com/bsth/service/oil/impl/DlbServiceImpl.java
... ... @@ -128,7 +128,8 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS
128 128 Dlb t1=dlList.get(k);
129 129 if(t1.getNbbm().equals(map.get("clZbh").toString())
130 130 &&t1.getJsy().equals(map.get("jGh").toString())
131   - &&t1.getXlbm().equals(map.get("xlBm").toString()))
  131 + &&t1.getXlbm().equals(map.get("xlBm").toString())
  132 + &&t1.getLp().equals(map.get("lpName").toString()))
132 133 {
133 134 t=t1;
134 135 type="update";
... ... @@ -194,6 +195,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS
194 195 t.setSsgsdm(map.get("company")==null?"":map.get("company").toString());
195 196 t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString());
196 197 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
  198 + t.setLp(map.get("lpName").toString());
197 199 t.setRq(sdf.parse(rq));
198 200 t.setCreatetime(new Date());
199 201 /*if(type.equals("add")){
... ... @@ -560,9 +562,15 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS
560 562 long l=Math.round(nextJzyl);
561 563 double ylxs=l*100/100;
562 564 dh=Arith.add(dh, Arith.sub(nextJzyl,ylxs));
563   - t.setHd(dh);
564   - t.setCdl(dh);
565   - nextJzyl=ylxs;
  565 + if(dh<0){
  566 + t.setHd(dh);
  567 + t.setCdl(dh);
  568 + nextJzyl=Arith.add(ylxs, dh);
  569 + }else{
  570 + t.setHd(dh);
  571 + t.setCdl(dh);
  572 + nextJzyl=ylxs;
  573 + }
566 574 }else{
567 575 t.setHd(0.0);
568 576 t.setCdl(0.0);
... ... @@ -586,9 +594,15 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
586 594  
587 595 }
588 596 dh=Arith.add(dh, Arith.sub(nextJzyl,ylxs));
589   - t.setHd(dh);
590   - t.setCdl(dh);
591   - nextJzyl=ylxs;
  597 + if(dh<0){
  598 + t.setHd(dh);
  599 + t.setCdl(dh);
  600 + nextJzyl=Arith.add(ylxs, dh);
  601 + }else{
  602 + t.setHd(dh);
  603 + t.setCdl(dh);
  604 + nextJzyl=ylxs;
  605 + }
592 606 }else{
593 607 t.setHd(0.0);
594 608 t.setCdl(0.0);
... ...
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
... ... @@ -128,7 +128,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
128 128 Ylb t1=ylList.get(k);
129 129 if(t1.getNbbm().equals(map.get("clZbh").toString())
130 130 &&t1.getJsy().equals(map.get("jGh").toString())
131   - &&t1.getXlbm().equals(map.get("xlBm").toString()))
  131 + &&t1.getXlbm().equals(map.get("xlBm").toString())
  132 + &&t1.getLp().equals(map.get("lpName").toString()))
132 133 {
133 134 t=t1;
134 135 type="update";
... ... @@ -618,13 +619,13 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
618 619 czyl = t.getCzyl();
619 620 zyl =jzl;
620 621 Double yh=0.0;
621   - if(zlc>0){
  622 + if(zlc>0 ){
622 623 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
623 624 }
624 625 nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()), t.getCzyl()),yh);
625 626 //把进场油量的小数和整数分别取出
626 627 // int ylxs=(int) nextJzyl; 10.6--11 10.3--10
627   - if(zlc>0){
  628 + if(zlc>0 && t.getZlc()>0){
628 629 long l=Math.round(nextJzyl);
629 630 double ylxs=l*100/100;
630 631 // nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
... ... @@ -643,14 +644,12 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
643 644 yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
644 645 }
645 646 nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()),nextJzyl),yh);
646   - if(zlc>0){
  647 + if(zlc>0 && t.getZlc()>0){
647 648 long l=0l;
648 649 double ylxs=0.0;
649 650 if(j==iterator2.size()-1){
650 651 ylxs=czyl;
651 652 }else{
652   -// l=Math.round(nextJzyl);
653   -// ylxs=l*100/100;
654 653 if(iterator2.get(j+1).getNbbm().equals(t.getNbbm())){
655 654 l=Math.round(nextJzyl);
656 655 ylxs=l*100/100;
... ... @@ -693,154 +692,6 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
693 692 return map2;
694 693 }
695 694  
696   - /**
697   - * 拆分
698   - */
699   - /*
700   - @Transactional
701   - @Override
702   - public Map<String, Object> sort(Map<String, Object> map) throws Exception{
703   - // TODO Auto-generated method stub
704   - Map<String, Object> newMap = new HashMap<String, Object>();
705   - SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
706   - try {
707   - // 获取车辆存油信息
708   - List<Cyl> cylList = cylRepository.findAll(new CustomerSpecs<Cyl>(newMap));
709   - int id = Integer.parseInt(map.get("id").toString());
710   - // 最后存油量
711   - Double yl = Double.parseDouble(map.get("jzyl").toString());
712   - Double sh= Double.parseDouble(map.get("sh").toString());
713   - String shyy=map.get("shyy").toString();
714   - Ylb ylb = repository.findOne(id);
715   - List<Cyl> cylListAdd=new ArrayList<Cyl>();
716   - Map<String, Object> cylMapAdd=new HashMap<String,Object>();
717   - String nbbm_eq = ylb.getNbbm();
718   - Date rq_eq = ylb.getRq();
719   - // 得到一天总的加油和里程(根据车,时间)
720   - List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm());
721   - // 保存总的加油量
722   - Double jzl = 0.0;
723   - // 保存总的里程
724   - Double zlc = 0.0;
725   - //保存总的损耗
726   - Double zsh = 0.0;
727   - for (int j = 0; j < sumList.size(); j++) {
728   - jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString()));
729   - zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString()));
730   - zsh = Arith.add(zsh, Double.valueOf(sumList.get(j)[2].toString()));
731   - }
732   - jzl = Arith.sub(jzl, zsh);
733   -
734   - //新的 损耗不等于 旧的损耗 总损耗从新算
735   - if(Arith.sub(ylb.getSh(),sh )!=0){
736   - zsh =Arith.add(Arith.sub(zsh, ylb.getSh()), sh);
737   - jzl =Arith.sub(jzl, zsh);
738   - }else{
739   - jzl =Arith.sub(jzl, zsh);
740   - }
741   - map.put("nbbm_eq", nbbm_eq);
742   - map.put("rq_eq", rq_eq);
743   - List<Ylb> iterator2=repository.obtainYl(sdf.format(rq_eq),ylb.getSsgsdm(),ylb.getFgsdm(),ylb.getXlbm(),
744   - ylb.getNbbm(),"jcsx");
745   -// Iterator<Ylb> iterator = repository.findAll(new CustomerSpecs<Ylb>(map), new Sort(Direction.ASC, "jcsx"))
746   -// .iterator();
747   - // 根据jcyl排序1为该车当日第一个出场,出场油量为前一天的存油
748   - // 保留两位小数
749   - DecimalFormat df = new DecimalFormat("#.00");
750   - Double zyl = 0.0;
751   - Double nextJzyl = 0.0;
752   - // 车的,进,出油量及耗油
753   - for (int i = 0; i < iterator2.size(); i++) {
754   - Ylb t = iterator2.get(i);
755   - if (t.getJcsx() == 1) {
756   - if(t.getId()==id){
757   - t.setSh(sh);
758   - t.setShyy(shyy);
759   - }
760   - Double jcyl = t.getCzyl();
761   - zyl = Arith.sub(Arith.add(jcyl, jzl), yl);
762   - Double yh = 0.0;
763   - if (zlc > 0 && t.getZlc() > 0) {
764   - yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
765   - }
766   - nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh()));
767   - long l=Math.round(nextJzyl);
768   - double ylxs=l*100/100;
769   -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
770   - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
771   - t.setJzyl(ylxs);
772   - t.setYh(yh);
773   - nextJzyl=ylxs;
774   - } else {
775   - if(t.getId()==id){
776   - t.setSh(sh);
777   - t.setShyy(shyy);
778   - }
779   - t.setCzyl(nextJzyl);
780   - Double yh =0.0;
781   - if (t.getZlc() != 0) {
782   - yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
783   - }
784   - nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh()));
785   - long l=Math.round(nextJzyl);
786   - double ylxs=l*100/100;
787   -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
788   - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
789   - t.setJzyl(ylxs);
790   - t.setYh(yh);
791   - nextJzyl=ylxs;
792   - }
793   - repository.save(t);
794   -
795   - // 设置存油量
796   - Cyl cyl = null;
797   - boolean fage = false;
798   - for (int z = 0; z < cylList.size(); z++) {
799   - cyl = cylList.get(z);
800   - if (t.getNbbm().equals(cyl.getNbbm())) {
801   - cyl.setCyl(t.getJzyl());
802   - cyl.setUpdatetime(t.getRq());
803   - fage = true;
804   - break;
805   - }
806   - }
807   - if (fage) {
808   - cylRepository.save(cyl);
809   - } else {
810   - if(cylMapAdd.get(t.getNbbm())!=null){
811   - for (int l = 0; l < cylListAdd.size(); l++) {
812   - cyl=cylListAdd.get(l);
813   - if(cyl.getNbbm().equals(t.getNbbm())){
814   - cyl.setNbbm(t.getNbbm());
815   - cyl.setCyl(t.getJzyl());
816   - cyl.setGsdm(t.getSsgsdm());
817   - cyl.setFgsdm(t.getFgsdm());
818   - cyl.setUpdatetime(t.getRq());
819   - }
820   - }
821   - }else{
822   - cyl = new Cyl();
823   - cyl.setNbbm(t.getNbbm());
824   - cyl.setCyl(t.getJzyl());
825   - cyl.setGsdm(t.getSsgsdm());
826   - cyl.setFgsdm(t.getFgsdm());
827   - cyl.setUpdatetime(t.getRq());
828   - cylListAdd.add(cyl);
829   - }
830   - }
831   -
832   - newMap.put("status", ResponseCode.SUCCESS);
833   - }
834   - for (int i = 0; i < cylListAdd.size(); i++) {
835   - cylRepository.save(cylListAdd.get(i));
836   - }
837   - } catch (Exception e) {
838   - newMap.put("status", ResponseCode.ERROR);
839   - logger.error("save erro.", e);
840   - throw e;
841   - }
842   - return newMap;
843   - }*/
844 695  
845 696 /**
846 697 * 核对,有加注没里程
... ... @@ -1315,6 +1166,9 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1315 1166 String nbbm =jsonObject.getString("nbbm");
1316 1167 String rq=jsonObject.getString("rq");
1317 1168 double yh = Arith.sub(Arith.add(czyl, jzl), jzyl);
  1169 + if(yh<0){
  1170 + yh=0.0;
  1171 + }
1318 1172 /*t.setJzyl(jzyl);
1319 1173 t.setSh(sh);
1320 1174 t.setShyy(shyy);
... ... @@ -1417,10 +1271,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1417 1271 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
1418 1272 }
1419 1273 nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh()));
1420   - if(zlc>0){
  1274 + if(zlc>0 && t.getZlc() > 0){
1421 1275 long l=Math.round(nextJzyl);
1422 1276 double ylxs=l*100/100;
1423   -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  1277 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
1424 1278 yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));
1425 1279 t.setYh(yh);
1426 1280 t.setJzyl(ylxs);
... ... @@ -1436,11 +1290,11 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1436 1290 }
1437 1291 t.setCzyl(nextJzyl);
1438 1292 Double yh =0.0;
1439   - if (t.getZlc() != 0) {
  1293 + if (t.getZlc() >= 0) {
1440 1294 yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
1441 1295 }
1442 1296 nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh()));
1443   - if(zlc>0){
  1297 + if(zlc>0 && t.getZlc() >0){
1444 1298 long l=0l;
1445 1299 double ylxs=0.0;
1446 1300 if(i==iterator2.size()-1){
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -1929,6 +1929,9 @@ public class ReportServiceImpl implements ReportService{
1929 1929 newMap.put("jhglzgf", culateService.culateJhgl_(sList,"zgf"));
1930 1930 newMap.put("jhglwgf", culateService.culateJhgl_(sList,"wgf"));
1931 1931  
  1932 + newMap.put("lbgl", culateService.culateLbgl(sList));
  1933 + newMap.put("lbbc", culateService.culateLbbc(sList));
  1934 +
1932 1935 newMap.put("sjbc", culateService.culateSjbc(lists,""));
1933 1936 newMap.put("sjbczgf", culateService.culateSjbc(lists,"zgf"));
1934 1937 newMap.put("sjbcwgf", culateService.culateSjbc(lists,"wgf"));
... ... @@ -1936,8 +1939,7 @@ public class ReportServiceImpl implements ReportService{
1936 1939 newMap.put("sjglzgf", culateService.culateSjgl_(lists,"zgf"));
1937 1940 newMap.put("sjglwgf", culateService.culateSjgl_(lists,"wgf"));
1938 1941  
1939   - newMap.put("lbgl", culateService.culateLbgl(lists));
1940   - newMap.put("lbbc", culateService.culateLbbc(lists));
  1942 +
1941 1943 newMap.put("ljgl", culateService.culateLjgl(lists));
1942 1944 newMap.put("ljglzgf", culateService.culateLjgl_(lists,"zgf"));
1943 1945 newMap.put("ljglwgf", culateService.culateLjgl_(lists,"wgf"));
... ...
src/main/resources/static/pages/oil/list_ph.html
... ... @@ -674,7 +674,7 @@ onkeyup=&quot;this.value=this.value.replace(/[^(\d||/.)]/g,&#39;&#39;).replace(&#39;.&#39;,&#39;$#$&#39;).rep
674 674  
675 675 var l = layer.load(2);
676 676 $get('/ylb/ylbList', params, function (data) {
677   -
  677 + console.log(data);
678 678 for(var i=1;i<data.length;i++){
679 679 moveArray[i]=new Array();
680 680 for(var j=1;j<6;j++){
... ...