Commit 25a2b68d25d4a232c92e3e8da38c184c6b9da06c
1 parent
a16b07b2
月存油表格重做 添加事后计算油量数据
Showing
7 changed files
with
221 additions
and
42 deletions
src/main/java/com/bsth/controller/oil/YlbController.java
| ... | ... | @@ -210,7 +210,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 210 | 210 | return maps; |
| 211 | 211 | } |
| 212 | 212 | @RequestMapping(value="/oilListMonth") |
| 213 | - public List<Ylb> oilListMonth(@RequestParam Map<String, Object> map){ | |
| 213 | + public List<Map<String, Object>> oilListMonth(@RequestParam Map<String, Object> map){ | |
| 214 | 214 | return yblService.oilListMonth(map); |
| 215 | 215 | } |
| 216 | 216 | ... | ... |
src/main/java/com/bsth/repository/oil/YlbRepository.java
| ... | ... | @@ -52,7 +52,11 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 52 | 52 | + " order by nbbm , rq desc,jcsx desc",nativeQuery=true) |
| 53 | 53 | List<Ylb> listByRqJcsx(String rq,String gsbm,String fgsbm,String xlbm,String nbbm); |
| 54 | 54 | |
| 55 | - | |
| 55 | + @Query(value="select * from bsth_c_ylb where rq>=?1 " | |
| 56 | + + " and rq<= ?2 and ssgsdm =?3" | |
| 57 | + + " and fgsdm =?4 and xlbm like %?5% " | |
| 58 | + + " order by nbbm , rq desc,jcsx desc",nativeQuery=true) | |
| 59 | + List<Ylb> listByMonthJcsx(String rq,String rq2,String gsbm,String fgsbm,String xlbm); | |
| 56 | 60 | |
| 57 | 61 | /** |
| 58 | 62 | * 当天YLB信息 | ... | ... |
src/main/java/com/bsth/service/oil/YlbService.java
| ... | ... | @@ -19,7 +19,7 @@ public interface YlbService extends BaseService<Ylb, Integer>{ |
| 19 | 19 | |
| 20 | 20 | Map<String, Object> sumYlb(Map<String, Object> map); |
| 21 | 21 | String checkJsy(Map<String, Object> map); |
| 22 | - List<Ylb> oilListMonth(Map<String, Object> map); | |
| 22 | + List<Map<String, Object>> oilListMonth(Map<String, Object> map); | |
| 23 | 23 | List<Ylb> listYlb(Map<String, Object> map); |
| 24 | 24 | StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx); |
| 25 | 25 | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -832,7 +832,10 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 832 | 832 | |
| 833 | 833 | |
| 834 | 834 | @Override |
| 835 | - public List<Ylb> oilListMonth(Map<String, Object> map) { | |
| 835 | + public List<Map<String, Object>> oilListMonth(Map<String, Object> map) { | |
| 836 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 837 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 838 | + | |
| 836 | 839 | String type=map.get("type").toString(); |
| 837 | 840 | String date=map.get("date").toString().trim(); |
| 838 | 841 | String gsdm=map.get("gsdm").toString(); |
| ... | ... | @@ -840,7 +843,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 840 | 843 | String date2=date.substring(0, 8)+"01"; |
| 841 | 844 | String lineStr=""; |
| 842 | 845 | String line =map.get("line").toString().trim(); |
| 843 | - if(line !=null && !line.equals("")){ | |
| 846 | + /*if(line !=null && !line.equals("")){ | |
| 844 | 847 | lineStr =" and xlbm= '"+ line +"'"; |
| 845 | 848 | }else{ |
| 846 | 849 | lineStr =" and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' "; |
| ... | ... | @@ -868,23 +871,86 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 868 | 871 | s.setJzyl(rs.getDouble("jzyl")); |
| 869 | 872 | return s; |
| 870 | 873 | } |
| 871 | - }); | |
| 874 | + }); */ | |
| 872 | 875 | |
| 873 | - if(type != null && type.equals("export")){ | |
| 874 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 875 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 876 | - | |
| 877 | - List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); | |
| 878 | - for(Ylb ylb : list){ | |
| 879 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 880 | - m.put("nbbm", ylb.getNbbm()!=null?ylb.getNbbm():""); | |
| 881 | - m.put("rq", ylb.getRq()!=null?sdfMonth.format(ylb.getRq()):""); | |
| 882 | - m.put("jzyl", ylb.getJzyl()!=null?ylb.getJzyl():""); | |
| 883 | - mapList.add(m); | |
| 876 | + double qtyy=0.0;//其他用油 | |
| 877 | + double cdyy=0.0;//车队用油 | |
| 878 | + double byyy=0.0;//保养用油 | |
| 879 | + double cjxx=0.0;//车间小修 | |
| 880 | + double cjgb=0.0;//车间高保 | |
| 881 | + double fyyyhj=0.0;//非营运用油合计 | |
| 882 | + List<Ylb> listYlb=repository.listByMonthJcsx(date2, date, gsdm, fgsdm, line); | |
| 883 | + | |
| 884 | + Map<String, Object> ms=new HashMap<String,Object>(); | |
| 885 | + List<Ylb> list=new ArrayList<Ylb>(); | |
| 886 | + for (int i = 0; i < listYlb.size(); i++) { | |
| 887 | + Ylb t=listYlb.get(i); | |
| 888 | + fyyyhj =Arith.add(fyyyhj, t.getSh()); | |
| 889 | + if(t.getShyy()==null){ | |
| 890 | + qtyy=Arith.add(qtyy, t.getSh()); | |
| 891 | + }else{ | |
| 892 | + if(t.getShyy().equals("6")){ | |
| 893 | + cdyy=Arith.add(cdyy, t.getSh()); | |
| 894 | + }else if(t.getShyy().equals("2")){ | |
| 895 | + byyy=Arith.add(byyy, t.getSh()); | |
| 896 | + }else if(t.getShyy().equals("7")){ | |
| 897 | + cjxx=Arith.add(cjxx, t.getSh()); | |
| 898 | + }else if(t.getShyy().equals("8")){ | |
| 899 | + cjgb=Arith.add(cjgb, t.getSh()); | |
| 900 | + }else{ | |
| 901 | + qtyy=Arith.add(qtyy, t.getSh()); | |
| 902 | + } | |
| 903 | + } | |
| 904 | + if(ms.get(t.getNbbm())==null){ | |
| 905 | + ms.put(t.getNbbm(), t.getNbbm()); | |
| 906 | + list.add(t); | |
| 884 | 907 | } |
| 908 | + } | |
| 909 | + | |
| 910 | + List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); | |
| 911 | + int size = 0; | |
| 912 | + Map<String, Object> m_ = new HashMap<String, Object>(); | |
| 913 | + double ycyhj=0.0; | |
| 914 | + for(Ylb ylb : list){ | |
| 915 | + ycyhj=Arith.add(ycyhj, ylb.getJzyl()); | |
| 916 | + int x=size%3; | |
| 917 | + if(x==0 && size>0){ | |
| 918 | + mapList.add(m_); | |
| 919 | + m_ = new HashMap<String, Object>(); | |
| 920 | + } | |
| 921 | + size++; | |
| 922 | + m_.put("xh"+x, size); | |
| 923 | + m_.put("nbbm"+x, ylb.getNbbm()!=null?ylb.getNbbm():""); | |
| 924 | + m_.put("rq"+x, ylb.getRq()!=null?sdfMonth.format(ylb.getRq()):""); | |
| 925 | + m_.put("jzyl"+x, ylb.getJzyl()!=null?ylb.getJzyl():""); | |
| 885 | 926 | |
| 927 | + } | |
| 928 | + if(m_.get("nbbm0")!=null){ | |
| 929 | + if(m_.get("nbbm1")==null){ | |
| 930 | + m_.put("xh1", ""); | |
| 931 | + m_.put("nbbm1" , ""); | |
| 932 | + m_.put("rq1" , ""); | |
| 933 | + m_.put("jzyl1" , ""); | |
| 934 | + } | |
| 935 | + if(m_.get("nbbm2")==null){ | |
| 936 | + m_.put("xh2", ""); | |
| 937 | + m_.put("nbbm2" , ""); | |
| 938 | + m_.put("rq2" , ""); | |
| 939 | + m_.put("jzyl2" , ""); | |
| 940 | + } | |
| 941 | + mapList.add(m_); | |
| 942 | + } | |
| 943 | + | |
| 944 | + if(type != null && type.equals("export")){ | |
| 886 | 945 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); |
| 887 | 946 | Map<String, Object> m = new HashMap<String, Object>(); |
| 947 | + m.put("ycyhj", ycyhj); | |
| 948 | + m.put("qtyy", qtyy); | |
| 949 | + m.put("cdyy", cdyy); | |
| 950 | + m.put("byyy", byyy); | |
| 951 | + m.put("cjxx", cjxx); | |
| 952 | + m.put("cjgb", cjgb); | |
| 953 | + m.put("fyyyhj", fyyyhj); | |
| 888 | 954 | ReportUtils ee = new ReportUtils(); |
| 889 | 955 | try { |
| 890 | 956 | listI.add(mapList.iterator()); |
| ... | ... | @@ -895,9 +961,15 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 895 | 961 | // TODO: handle exception |
| 896 | 962 | e.printStackTrace(); |
| 897 | 963 | } |
| 964 | + }else{ | |
| 965 | + m_=new HashMap<String,Object>(); | |
| 966 | + m_.put("xh0", "99"); | |
| 967 | + m_.put("nbbm0", "存油合计:"+ycyhj +" 非营运用油: 其他用油:"+qtyy +",车队:"+cdyy+",保养用油:"+byyy | |
| 968 | + +",车间(小修):"+cjxx+",车间(高保):"+cjgb+",非营运用油合计:"+fyyyhj); | |
| 969 | + mapList.add(m_); | |
| 898 | 970 | } |
| 899 | 971 | |
| 900 | - return list; | |
| 972 | + return mapList; | |
| 901 | 973 | } |
| 902 | 974 | |
| 903 | 975 | @Override |
| ... | ... | @@ -1478,7 +1550,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1478 | 1550 | } |
| 1479 | 1551 | |
| 1480 | 1552 | } |
| 1481 | - | |
| 1553 | + String nbbmStr=""; | |
| 1482 | 1554 | List<Ylb> list=new ArrayList<Ylb>(); |
| 1483 | 1555 | /* |
| 1484 | 1556 | * 第一步 修改车辆里程 和加注量 |
| ... | ... | @@ -1592,6 +1664,9 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1592 | 1664 | t.setLp(maps.get("lpName")==null?"":maps.get("lpName").toString()); |
| 1593 | 1665 | if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){ |
| 1594 | 1666 | if(type.equals("add")){ |
| 1667 | + if(nbbmStr.indexOf(t.getNbbm())<0){ | |
| 1668 | + nbbmStr +=t.getNbbm()+","; | |
| 1669 | + } | |
| 1595 | 1670 | t.setCreatetime(new Date()); |
| 1596 | 1671 | }else{ |
| 1597 | 1672 | t.setUpdatetime(new Date()); |
| ... | ... | @@ -1603,10 +1678,92 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1603 | 1678 | |
| 1604 | 1679 | for (int i = 0; i < ylbList_del.size(); i++) { |
| 1605 | 1680 | Ylb y=ylbList_del.get(i); |
| 1681 | + if(nbbmStr.indexOf(y.getNbbm())<0){ | |
| 1682 | + nbbmStr +=y.getNbbm()+","; | |
| 1683 | + } | |
| 1606 | 1684 | repository.delete(y.getId()); |
| 1607 | 1685 | } |
| 1686 | + | |
| 1687 | + //重新计算删除了的或者新增了的车的车的油耗信息(考虑车辆可能跨线路,从分公司赛选计算) | |
| 1688 | + double czyl=0.0; | |
| 1689 | + List<Ylb> iterator2=this.listOrderBy(date,gsdm,fgsdm,line,"","nbbm,jcsx"); | |
| 1690 | + String[] nbbms=nbbmStr.split(","); | |
| 1691 | + for (int i = 0; i < nbbms.length; i++) { | |
| 1692 | + String clzbm=nbbms[i]; | |
| 1693 | + // 得到一天总的加油和里程(根据车,时间) | |
| 1694 | + List<Object[]> sumList = repository.sumLcYl(clzbm, sdf.parse(date),"",gsdm,fgsdm); | |
| 1695 | + // 保存总的加油量 | |
| 1696 | + Double jzl = 0.0; | |
| 1697 | + // 保存总的里程 | |
| 1698 | + Double zlc = 0.0; | |
| 1699 | + for (int j = 0; j < sumList.size(); j++) { | |
| 1700 | + jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString())); | |
| 1701 | + zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString())); | |
| 1702 | + } | |
| 1703 | + // 保留两位小数 | |
| 1704 | + DecimalFormat df = new DecimalFormat("#.00"); | |
| 1705 | + Double zyl = 0.0; | |
| 1706 | + Double nextJzyl = 0.0; | |
| 1707 | + for (int j = 0; j < iterator2.size(); j++) { | |
| 1708 | + Ylb t = iterator2.get(j); | |
| 1709 | + if(t.getNbbm().equals(clzbm)){ | |
| 1710 | + if (t.getJcsx() == 1) { | |
| 1711 | + // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量 | |
| 1712 | + czyl = t.getCzyl(); | |
| 1713 | + zyl =jzl; | |
| 1714 | + Double yh=0.0; | |
| 1715 | + if(zlc>0 ){ | |
| 1716 | + yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); | |
| 1717 | + } | |
| 1718 | + nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh); | |
| 1719 | + //把进场油量的小数和整数分别取出 | |
| 1720 | + if(zlc>0 && t.getZlc()>0){ | |
| 1721 | + long l=Math.round(nextJzyl); | |
| 1722 | + double ylxs=l*100/100; | |
| 1723 | + yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs)); | |
| 1724 | + t.setYh(yh); | |
| 1725 | + t.setJzyl(ylxs); | |
| 1726 | + nextJzyl=ylxs; | |
| 1727 | + }else{ | |
| 1728 | + t.setYh(yh); | |
| 1729 | + t.setJzyl(nextJzyl); | |
| 1730 | + } | |
| 1731 | + } else { | |
| 1732 | + t.setCzyl(nextJzyl); | |
| 1733 | + Double yh=0.0; | |
| 1734 | + if(zlc>0){ | |
| 1735 | + yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); | |
| 1736 | + } | |
| 1737 | + nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh); | |
| 1738 | + if(zlc>0 && t.getZlc()>0){ | |
| 1739 | + long l=0l; | |
| 1740 | + double ylxs=0.0; | |
| 1741 | + if(j==iterator2.size()-1){ | |
| 1742 | + ylxs=czyl; | |
| 1743 | + }else{ | |
| 1744 | + if(iterator2.get(j+1).getNbbm().equals(t.getNbbm())){ | |
| 1745 | + l=Math.round(nextJzyl); | |
| 1746 | + ylxs=l*100/100; | |
| 1747 | + }else{ | |
| 1748 | + ylxs=czyl; | |
| 1749 | + } | |
| 1750 | + | |
| 1751 | + } | |
| 1752 | + yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs)); | |
| 1753 | + t.setYh(yh); | |
| 1754 | + t.setJzyl(ylxs); | |
| 1755 | + nextJzyl=ylxs; | |
| 1756 | + }else{ | |
| 1757 | + t.setYh(yh); | |
| 1758 | + t.setJzyl(nextJzyl); | |
| 1759 | + } | |
| 1760 | + } | |
| 1761 | + repository.save(t); | |
| 1762 | + } | |
| 1763 | + } | |
| 1764 | + } | |
| 1765 | + | |
| 1608 | 1766 | //重新统计油车数据结束 |
| 1609 | - | |
| 1610 | 1767 | |
| 1611 | 1768 | |
| 1612 | 1769 | //重新获取电耗数据开始 | ... | ... |
src/main/resources/static/pages/forms/mould/oilListMonth.xls
No preview for this file type
src/main/resources/static/pages/oil/list_ph.html
| ... | ... | @@ -58,6 +58,11 @@ |
| 58 | 58 | <li><a href="javascript:;" data-action="3" class="tool-action" |
| 59 | 59 | id="export"> <i class="fa fa-file-excel-o"></i> 导出Excel |
| 60 | 60 | </a></li> |
| 61 | + | |
| 62 | +<!-- <li class="divider"></li> --> | |
| 63 | +<!-- <li><a href="javascript:;" data-action="3" class="tool-action" --> | |
| 64 | +<!-- id="cxtj"> <i class="fa fa-file-excel-o"></i> 导出Excel --> | |
| 65 | +<!-- </a></li> --> | |
| 61 | 66 | </ul> |
| 62 | 67 | </div> |
| 63 | 68 | </div> |
| ... | ... | @@ -214,6 +219,9 @@ |
| 214 | 219 | <button type="button" class="btn btn-circle saveButton" > |
| 215 | 220 | <i class="fa fa-check-circle"></i> 保存 |
| 216 | 221 | </button> |
| 222 | + <button type="button" class="btn btn-circle saveButton" > | |
| 223 | + <i class="fa fa-check-circle"></i> 保存 | |
| 224 | + </button> | |
| 217 | 225 | </div> |
| 218 | 226 | </div> |
| 219 | 227 | |
| ... | ... | @@ -963,6 +971,17 @@ onkeyup="this.value=this.value.replace(/[^(\d||/.)]/g,'').replace('.','$#$').rep |
| 963 | 971 | |
| 964 | 972 | } |
| 965 | 973 | // } |
| 974 | + | |
| 975 | +// $("#cxtj").on("click", function () { | |
| 976 | +// if ($("#rq").val() != "") { | |
| 977 | +// // var params=getParamsList(); | |
| 978 | +// $post('/ylb/updateHistory', {date:'2017-10-01',line:'10845',gsdm:'55',fgsdm:'3'}, function (result) { | |
| 979 | +// window.open("/downloadFile/download?fileName="+$("#rq").val()+"进出场存油量" ); | |
| 980 | +// }); | |
| 981 | +// } else { | |
| 982 | +// layer.msg('请选择日期.'); | |
| 983 | +// } | |
| 984 | +// }); | |
| 966 | 985 | |
| 967 | 986 | //导出 |
| 968 | 987 | ... | ... |
src/main/resources/static/pages/report/oil/oilListMonth.html
| ... | ... | @@ -69,15 +69,6 @@ |
| 69 | 69 | <td>日期</td> |
| 70 | 70 | <td>存油</td> |
| 71 | 71 | |
| 72 | - <td>序号</td> | |
| 73 | - <td>车号</td> | |
| 74 | - <td>日期</td> | |
| 75 | - <td>存油</td> | |
| 76 | - | |
| 77 | - <td>序号</td> | |
| 78 | - <td>车号</td> | |
| 79 | - <td>日期</td> | |
| 80 | - <td>存油</td> | |
| 81 | 72 | </tr> |
| 82 | 73 | </thead> |
| 83 | 74 | |
| ... | ... | @@ -139,10 +130,8 @@ |
| 139 | 130 | var xlList; |
| 140 | 131 | $.get('/report/lineList',function(result){ |
| 141 | 132 | xlList=result; |
| 142 | - | |
| 143 | 133 | $.get('/user/companyData', function(result){ |
| 144 | 134 | obj = result; |
| 145 | - console.log(obj); | |
| 146 | 135 | var options = ''; |
| 147 | 136 | for(var i = 0; i < obj.length; i++){ |
| 148 | 137 | options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; |
| ... | ... | @@ -226,9 +215,6 @@ |
| 226 | 215 | var gsdm = $("#gsdm").val(); |
| 227 | 216 | var fgsdm = $("#fgsdm").val(); |
| 228 | 217 | $get('/ylb/oilListMonth',{line:line,date:date,gsdm:gsdm,fgsdm,fgsdm,type:'query'},function(result){ |
| 229 | -// $.each(result, function(i, obj) { | |
| 230 | -// obj.rq = moment(obj.rq).format("DD"); | |
| 231 | -// }); | |
| 232 | 218 | var oilListMonth = template('oilListMonth',{list:result}); |
| 233 | 219 | $('#forms tbody').html(oilListMonth); |
| 234 | 220 | }); |
| ... | ... | @@ -252,16 +238,29 @@ |
| 252 | 238 | </script> |
| 253 | 239 | <script type="text/html" id="oilListMonth"> |
| 254 | 240 | {{each list as obj i}} |
| 255 | - {{if i%5 == 0}} | |
| 241 | + | |
| 256 | 242 | <tr> |
| 257 | - {{/if}} | |
| 258 | - <td>{{i+1}}</td> | |
| 259 | - <td>{{obj.nbbm}}</td> | |
| 260 | - <td>{{obj.rq}}</td> | |
| 261 | - <td>{{obj.jzyl}}</td> | |
| 262 | - {{if (i+1)%5 == 0}} | |
| 243 | + {{if obj.xh0==99}} | |
| 244 | + <td colspan="12"> | |
| 245 | + {{obj.nbbm0}} | |
| 246 | + </td> | |
| 247 | + {{else}} | |
| 248 | + <td>{{obj.xh0}}</td> | |
| 249 | + <td>{{obj.nbbm0}}</td> | |
| 250 | + <td>{{obj.rq0}}</td> | |
| 251 | + <td>{{obj.jzyl0}}</td> | |
| 252 | + <td>{{obj.xh1}}</td> | |
| 253 | + <td>{{obj.nbbm1}}</td> | |
| 254 | + <td>{{obj.rq1}}</td> | |
| 255 | + <td>{{obj.jzyl1}}</td> | |
| 256 | + <td>{{obj.xh2}}</td> | |
| 257 | + <td>{{obj.nbbm2}}</td> | |
| 258 | + <td>{{obj.rq2}}</td> | |
| 259 | + <td>{{obj.jzyl2}}</td> | |
| 260 | + {{/if}} | |
| 261 | + | |
| 263 | 262 | </tr> |
| 264 | - {{/if}} | |
| 263 | + | |
| 265 | 264 | {{/each}} |
| 266 | 265 | {{if list.length == 0}} |
| 267 | 266 | <tr> | ... | ... |