Commit 896f18b2d907881f5afca16965848493e1be27c2

Authored by 廖磊
1 parent 73a56793

油量计算

src/main/java/com/bsth/repository/oil/YlbRepository.java
... ... @@ -27,6 +27,29 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{
27 27 + " xlbm like %?4% and nbbm like %?5% ",nativeQuery=true)
28 28 List<Ylb> obtainYlbefore(String rq,String gsbm,String fgsbm,String xlbm,String nbbm);
29 29  
  30 +
  31 + /**
  32 + * 获取当天日期前的最大的日期中最大进出顺序的数据
  33 + *
  34 + */
  35 + @Transactional
  36 + @Modifying
  37 + @Query(value="select y.* from (select max(d.id) as id ,d.nbbm from ("
  38 + + " select b.rq,b.nbbm,max(b.jcsx) as jcsx from ("
  39 + + " select max(t.rq) as rq ,t.nbbm from bsth_c_ylb t "
  40 + + " where to_days(t.rq)< to_days(?1) "
  41 + + " and t.ssgsdm like %?2% and t.fgsdm like %?3% "
  42 + + " and t.xlbm like %?4% and t.nbbm like %?5% group by nbbm ) a "
  43 + + " left join bsth_c_ylb b on a.rq=b.rq and a.nbbm=b.nbbm "
  44 + + " where b.ssgsdm like %?2% and b.fgsdm like %?3% and "
  45 + + " b.xlbm like %?4% and b.nbbm like %?5% group by b.rq,b.nbbm) c"
  46 + + " left join bsth_c_ylb d on c.rq=d.rq and c.nbbm=d.nbbm and c.jcsx=d.jcsx "
  47 + + " where d.ssgsdm like %?2% and d.fgsdm like %?3% and d.xlbm like %?4% "
  48 + + " and d.nbbm like %?5% group by d.nbbm) x left join "
  49 + + " bsth_c_ylb y on x.id=y.id where y.ssgsdm like %?2% and y.fgsdm like %?3% "
  50 + + " and y.xlbm like %?4% and y.nbbm like %?5%",nativeQuery=true)
  51 + List<Ylb> listMaxRqJcsx(String rq,String gsbm,String fgsbm,String xlbm,String nbbm);
  52 +
30 53 /**
31 54 * 当天YLB信息
32 55 * @param rq
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -164,8 +164,8 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
164 164 List<ScheduleRealInfo> scheduleByDateAndLineYbb(String line,String date,String date2);
165 165  
166 166  
167   - @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,min(s.fcsj) as fcsj ) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY clZbh,fcsj")
168   - List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm);
  167 + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,min(s.fcsj) as fcsj ) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY clZbh,fcsj")
  168 + List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm,String nbbm);
169 169  
170 170 @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 ORDER BY xlBm,lpName,clZbh,xlDir")
171 171 List<ScheduleRealInfo> setLD(String date);
... ...
src/main/java/com/bsth/service/oil/impl/CwjyServiceImpl.java
... ... @@ -276,17 +276,22 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw
276 276 // TODO Auto-generated method stub
277 277 String rq=map.get("rq").toString();
278 278 String nbbm=map.get("nbbh").toString();
  279 + String gsdm=map.get("gsdm_like").toString();
  280 +
  281 + String fgsdm=map.get("fgsdm_like").toString();
279 282 String sql="SELECT a.gsdm as gsdm,a.fgsdm as fgsdm,a.nbbm as nbbm,"
280 283 + "b.jyggh as jyggh,b.jzl as jzl ,b.stationid as stationid,b.jsy as jsy,"
281 284 + "b.nylx as nylx,b.yj as yj,b.bz as bz,b.id as id ,c.jsy as ldgh FROM bsth_c_cwjy a "+
282 285 " left join ("
283 286 + " select * from bsth_c_ylxxb b "
284   - + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1) b " +
  287 + + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1 "
  288 + + " and gsdm = '"+gsdm+"') b " +
285 289 " on a.nbbm=b.nbbm "
286 290 + "left join (select nbbm,group_concat(jsy) as jsy "
287   - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) group by nbbm "+
  291 + + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) "
  292 + + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' group by nbbm "+
288 293 " ) c on a.nbbm=c.nbbm "
289   - + "where a.nbbm like '%"+nbbm+"%'";
  294 + + "where a.nbbm like '%"+nbbm+"%' and a.gsdm='"+gsdm+"' and a.fgsdm ='"+fgsdm+"'";
290 295  
291 296 List<Ylxxb> yList= jdbcTemplate.query(sql,
292 297 new RowMapper<Ylxxb>(){
... ...
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
... ... @@ -102,7 +102,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
102 102 //当天YLXXB信息
103 103 // List<Ylxxb> ylxxList=ylxxbRepository.obtainYlxx(rq);
104 104 //前一天所有车辆最后进场班次信息
105   - List<Ylb> ylListBe=repository.obtainYlbefore(rq,"","","","");
  105 +// List<Ylb> ylListBe=repository.obtainYlbefore(rq,"","","","");
  106 + List<Ylb> ylListBe=repository.listMaxRqJcsx(rq, "", "", "", "");
106 107 List<Cyl> clyList=cylRepository.obtainCyl("","");
107 108 //从排班表中计算出行驶的总里程
108 109 List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList("", rq, "", "", "", "");
... ... @@ -240,7 +241,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
240 241 // 当天YLXXB信息
241 242 List<Ylxxb> ylxxList = ylxxbRepository.obtainYlxx(rq, 0,gsbm);
242 243 // 前一天所有车辆最后进场班次信息
243   - List<Ylb> ylListBe = repository.obtainYlbefore(rq, gsbm, fgsbm, line, nbbm);
  244 +// List<Ylb> ylListBe = repository.obtainYlbefore(rq, gsbm, fgsbm, line, nbbm);
  245 + List<Ylb> ylListBe =repository.listMaxRqJcsx(rq, gsbm, fgsbm, line, nbbm);
244 246 List<Cyl> clyList = cylRepository.obtainCyl(nbbm,gsbm);
245 247 // 从排班表中计算出行驶的总里程
246 248 List<Map<String, Object>> listpb = scheduleRealInfoService.yesterdayDataList(line, rq, gsbm, fgsbm, "", nbbm);
... ... @@ -325,7 +327,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
325 327 t.setNbbm(map.get("clZbh").toString());
326 328 t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString());
327 329 t.setZlc(map.get("totalKilometers") == null ? 0.0
328   - : Double.parseDouble(df.format(Double.parseDouble(map.get("totalKilometers").toString()))));
  330 + : Double.parseDouble(map.get("totalKilometers").toString()));
329 331 t.setXlbm(map.get("xlBm") == null ? "" : map.get("xlBm").toString());
330 332 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));
331 333 t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString());
... ... @@ -451,13 +453,21 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
451 453 nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()), t.getCzyl()),yh);
452 454 //把进场油量的小数和整数分别取出
453 455 // int ylxs=(int) nextJzyl; 10.6--11 10.3--10
454   - long l=Math.round(nextJzyl);
455   - double ylxs=l*100/100;
456   -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
457   - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
458   - t.setYh(yh);
459   - t.setJzyl(ylxs);
460   - nextJzyl=ylxs;
  456 + if(zlc>0){
  457 + long l=Math.round(nextJzyl);
  458 + double ylxs=l*100/100;
  459 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  460 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  461 + t.setYh(yh);
  462 + t.setJzyl(ylxs);
  463 + nextJzyl=ylxs;
  464 + }else{
  465 + t.setYh(yh);
  466 + t.setJzyl(nextJzyl);
  467 + }
  468 +
  469 +
  470 +
461 471 } else {
462 472 t.setCzyl(nextJzyl);
463 473 Double yh=0.0;
... ... @@ -465,16 +475,21 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
465 475 yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
466 476 }
467 477 nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()),nextJzyl),yh);
468   - long l=Math.round(nextJzyl);
469   - double ylxs=l*100/100;
470   -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
471   - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
472   - t.setYh(yh);
473   - t.setJzyl(ylxs);
474   - nextJzyl= ylxs;
  478 + if(zlc>0){
  479 + long l=Math.round(nextJzyl);
  480 + double ylxs=l*100/100;
  481 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  482 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  483 + t.setYh(yh);
  484 + t.setJzyl(ylxs);
  485 + nextJzyl=ylxs;
  486 + }else{
  487 + t.setYh(yh);
  488 + t.setJzyl(nextJzyl);
  489 + }
475 490 }
476 491 repository.save(t);
477   - for (int z = 0; z < cylList.size(); z++) {
  492 + /*for (int z = 0; z < cylList.size(); z++) {
478 493 Cyl cyl = cylList.get(z);
479 494 if (t.getNbbm().equals(cyl.getNbbm())) {
480 495 cyl.setCyl(t.getJzyl());
... ... @@ -482,7 +497,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
482 497 break;
483 498 }
484 499 cylRepository.save(cyl);
485   - }
  500 + }*/
486 501 }
487 502 map2.put("status", ResponseCode.SUCCESS);
488 503 }
... ... @@ -687,7 +702,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
687 702 if(map.get("nbbm_eq")!=null){
688 703 nbbm=map.get("nbbm_eq").toString();
689 704 }
690   - List<Ylb> ylListBe=repository.obtainYlbefore(rq, gsbm, "", xlbm, nbbm);
  705 +// List<Ylb> ylListBe=repository.obtainYlbefore(rq, gsbm, "", xlbm, nbbm);
  706 + List<Ylb> ylListBe=repository.listMaxRqJcsx(rq, gsbm, fgsbm, xlbm, nbbm);
691 707 List<Cyl> cylList=cylRepository.obtainCyl(nbbm, gsbm);
692 708 List<Ylb> ylbList=repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm");
693 709 List<Ylxxb> ylxxbList=ylxxbRepository.obtainYlxx(rq,0,gsbm);
... ... @@ -751,11 +767,11 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
751 767 t.setYh(0.0);
752 768 if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){
753 769 repository.save(t);
754   - if(null!=cyl){
  770 + /*if(null!=cyl){
755 771 cyl.setCyl(Arith.add(t.getJzl(), t.getCzyl()));
756 772 cyl.setUpdatetime(y1.getYyrq());
757 773 cylRepository.save(cyl);
758   - }
  774 + }*/
759 775 }
760 776 }
761 777 }
... ... @@ -1048,7 +1064,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1048 1064 t.setRylx(rylx);
1049 1065 t.setId(jsonObject.getInteger("id"));*/
1050 1066 repository.ylbUpdate(id, czyl, jzyl, yh, sh, shyy, ns, rylx,yhlx);
1051   - for (int z = 0; z < cylList.size(); z++) {
  1067 + /*for (int z = 0; z < cylList.size(); z++) {
1052 1068 Cyl cyl = cylList.get(z);
1053 1069 if (nbbm.equals(cyl.getNbbm())) {
1054 1070 cyl.setCyl(jzyl);
... ... @@ -1056,7 +1072,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1056 1072 break;
1057 1073 }
1058 1074 cylRepository.save(cyl);
1059   - }
  1075 + }*/
1060 1076 }
1061 1077 // List<Map<String, Object>> list=(List<Map<String, Object>>) map.get("ylbList");
1062 1078  
... ... @@ -1139,13 +1155,18 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1139 1155 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
1140 1156 }
1141 1157 nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh()));
1142   - long l=Math.round(nextJzyl);
1143   - double ylxs=l*100/100;
1144   -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
1145   - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
1146   - t.setJzyl(ylxs);
1147   - t.setYh(yh);
1148   - nextJzyl=ylxs;
  1158 + if(zlc>0){
  1159 + long l=Math.round(nextJzyl);
  1160 + double ylxs=l*100/100;
  1161 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  1162 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  1163 + t.setYh(yh);
  1164 + t.setJzyl(ylxs);
  1165 + nextJzyl=ylxs;
  1166 + }else{
  1167 + t.setYh(yh);
  1168 + t.setJzyl(nextJzyl);
  1169 + }
1149 1170 } else {
1150 1171 if(t.getId()==id){
1151 1172 t.setSh(sh);
... ... @@ -1157,16 +1178,21 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1157 1178 yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
1158 1179 }
1159 1180 nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh()));
1160   - long l=Math.round(nextJzyl);
1161   - double ylxs=l*100/100;
1162   -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
1163   - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
1164   - t.setJzyl(ylxs);
1165   - t.setYh(yh);
1166   - nextJzyl=ylxs;
  1181 + if(zlc>0){
  1182 + long l=Math.round(nextJzyl);
  1183 + double ylxs=l*100/100;
  1184 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  1185 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  1186 + t.setYh(yh);
  1187 + t.setJzyl(ylxs);
  1188 + nextJzyl=ylxs;
  1189 + }else{
  1190 + t.setYh(yh);
  1191 + t.setJzyl(nextJzyl);
  1192 + }
1167 1193 }
1168 1194 repository.save(t);
1169   - for (int z = 0; z < cylList.size(); z++) {
  1195 + /*for (int z = 0; z < cylList.size(); z++) {
1170 1196 Cyl cyl = cylList.get(z);
1171 1197 if (t.getNbbm().equals(cyl.getNbbm())) {
1172 1198 cyl.setCyl(t.getJzyl());
... ... @@ -1174,7 +1200,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1174 1200 break;
1175 1201 }
1176 1202 cylRepository.save(cyl);
1177   - }
  1203 + }*/
1178 1204 }
1179 1205 newMap.put("status", ResponseCode.SUCCESS);
1180 1206 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -2702,12 +2702,13 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2702 2702 // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
2703 2703 // String date = "2016-09-20";
2704 2704 // System.out.println("shijian1:"+new Date());
2705   - List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date,gsbm,fgsbm);
  2705 + List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date,gsbm,fgsbm,nbbm);
2706 2706 // System.out.println("shijian2:"+new Date());
2707 2707 // List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
2708 2708 List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date,gsbm,fgsbm);
2709 2709 // System.out.println("shijian3:"+new Date());
2710 2710 for (int x = 0; x < yesterdayDataList.size(); x++) {
  2711 +
2711 2712 String jName = yesterdayDataList.get(x).get("jGh").toString();
2712 2713 String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
2713 2714  
... ...