Commit 3b6ee8534365b2fbb40c5add8ffcaa60857cf7df

Authored by 廖磊
1 parent 4d5e7aa3

油,电 对于同人同车同线路不同路的处理

src/main/java/com/bsth/entity/oil/Dlb.java
... ... @@ -73,7 +73,7 @@ public class Dlb {
73 73 private String fgsname;
74 74  
75 75  
76   -
  76 + private String lp;
77 77  
78 78 public Integer getId() {
79 79 return id;
... ... @@ -383,6 +383,15 @@ public class Dlb {
383 383 public void setUpdatetime(Date updatetime) {
384 384 this.updatetime = updatetime;
385 385 }
  386 +
  387 + public String getLp() {
  388 + return lp;
  389 + }
  390 +
  391 + public void setLp(String lp) {
  392 + this.lp = lp;
  393 + }
  394 +
386 395  
387 396  
388 397 }
... ...
src/main/java/com/bsth/entity/oil/Ylb.java
... ... @@ -56,6 +56,7 @@ public class Ylb {
56 56 //进场顺序(根据最先出场和最后进场来关联车辆的存油量)
57 57 private int jcsx;
58 58  
  59 + private String lp;
59 60 @Transient
60 61 private String bglyh;
61 62  
... ... @@ -330,5 +331,14 @@ public class Ylb {
330 331 public void setUpdatetime(Date updatetime) {
331 332 this.updatetime = updatetime;
332 333 }
  334 +
  335 + public String getLp() {
  336 + return lp;
  337 + }
  338 +
  339 + public void setLp(String lp) {
  340 + this.lp = lp;
  341 + }
  342 +
333 343  
334 344 }
... ...
src/main/java/com/bsth/repository/oil/YlbRepository.java
... ... @@ -125,8 +125,8 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{
125 125  
126 126 @Query(value="select s from Ylb s "
127 127 + " where to_days(?1)=to_days(s.rq) "
128   - + " and s.ssgsdm like %?2% "
129   - + " and s.fgsdm like %?3%"
  128 + + " and s.ssgsdm =?2 "
  129 + + " and s.fgsdm =?3 "
130 130 + " and s.xlbm like %?4% "
131 131 + " and s.nbbm in ?5 order by nbbm,jcsx")
132 132 List<Ylb> listYlb(String rq, String gsbm,String fgsbm,String xlbm,List<String> listNbbm);
... ...
src/main/java/com/bsth/repository/oil/YlxxbRepository.java
... ... @@ -17,17 +17,17 @@ public interface YlxxbRepository extends BaseRepository&lt;Ylxxb, Integer&gt;{
17 17 * @param rq
18 18 * @return
19 19 */
20   - @Query(value="SELECT * FROM bsth_c_ylxxb where to_days(?1)=to_days(yyrq) and nylx=?2 and gsdm like %?3%",nativeQuery=true)
  20 + @Query(value="SELECT * FROM bsth_c_ylxxb where yyrq=?1 and nylx=?2 and gsdm like %?3%",nativeQuery=true)
21 21 List<Ylxxb> obtainYlxx(String rq,int nylx,String gsdm);
22 22  
23   - @Query(value="SELECT * FROM bsth_c_ylxxb where to_days(?1)=to_days(yyrq) and gsdm=?2",nativeQuery=true)
  23 + @Query(value="SELECT * FROM bsth_c_ylxxb where yyrq=?1 and gsdm=?2",nativeQuery=true)
24 24 List<Ylxxb> checkYlxx(String rq,String gs);
25 25  
26   - @Query(value="SELECT * FROM bsth_c_ylxxb where to_days(?1)=to_days(yyrq) and nbbm =?2 and jylx=1",nativeQuery=true)
  26 + @Query(value="SELECT * FROM bsth_c_ylxxb where yyrq=?1 and nbbm =?2 and jylx=1",nativeQuery=true)
27 27 List<Ylxxb> obtainYlxx2(String rq,String nbbm);
28 28  
29 29 @Query(value="select * from bsth_c_ylxxb s where s.nbbm = ?1 and "
30   - + "to_days(s.yyrq) = to_days(?2)",nativeQuery=true)
  30 + + "s.yyrq=?2",nativeQuery=true)
31 31 List<Ylxxb> queryListYlxxb(String clZbh,String date);
32 32  
33 33  
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -190,10 +190,10 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
190 190 List<ScheduleRealInfo> scheduleByDateAndLineYbb(String line,String date,String date2);
191 191  
192 192  
193   - @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 s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate ORDER BY clZbh,fcsj")
  193 + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,s.lpName as lpName,min(s.fcsj) as fcsj,min(s.realExecDate) as realExecDate ) from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,lpName ORDER BY clZbh,realExecDate,fcsj")
194 194 List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm,String nbbm);
195 195  
196   - @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 =?1 and s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate ORDER BY clZbh,fcsj")
  196 + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,s.lpName as lpName,min(s.fcsj) as fcsj,min(s.realExecDate) as realExecDate ) from ScheduleRealInfo s where s.xlBm =?1 and s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,lpName ORDER BY clZbh,realExecDate,fcsj")
197 197 List<Map<String,Object>> yesterdayDataList_eq(String line,String date,String gsbm,String fgsbm,String nbbm);
198 198  
199 199 @Query(value="select s from ScheduleRealInfo s where s.scheduleDateStr = ?1 ORDER BY xlBm,lpName,clZbh,xlDir")
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -739,15 +739,29 @@ public class FormsServiceImpl implements FormsService {
739 739 ScheduleRealInfo s=listReal.get(j);
740 740 if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)
741 741 &&s.getXlBm().equals(line)){
742   - newList.add(s);
743   - Set<ChildTaskPlan> cts = s.getcTasks();
744   - if(cts != null && cts.size() > 0){
745   - newList_.add(s);
746   - }else{
747   - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  742 + if(y.getLp()==null){
  743 + newList.add(s);
  744 + Set<ChildTaskPlan> cts = s.getcTasks();
  745 + if(cts != null && cts.size() > 0){
748 746 newList_.add(s);
  747 + }else{
  748 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  749 + newList_.add(s);
  750 + }
749 751 }
750   - }
  752 + }else{
  753 + if(y.getLp().equals(s.getLpName())){
  754 + newList.add(s);
  755 + Set<ChildTaskPlan> cts = s.getcTasks();
  756 + if(cts != null && cts.size() > 0){
  757 + newList_.add(s);
  758 + }else{
  759 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  760 + newList_.add(s);
  761 + }
  762 + }
  763 + }
  764 + }
751 765 }
752 766 }
753 767 double jhgl=culateMileageService.culateJhgl(newList);
... ... @@ -793,8 +807,9 @@ public class FormsServiceImpl implements FormsService {
793 807 ScheduleRealInfo s=listReal.get(j);
794 808 if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)
795 809 &&s.getXlBm().equals(line)){
796   - newList.add(s);
797   - Set<ChildTaskPlan> cts = s.getcTasks();
  810 + if(y.getLp()==null){
  811 + newList.add(s);
  812 + Set<ChildTaskPlan> cts = s.getcTasks();
798 813 if(cts != null && cts.size() > 0){
799 814 newList_.add(s);
800 815 }else{
... ... @@ -802,6 +817,19 @@ public class FormsServiceImpl implements FormsService {
802 817 newList_.add(s);
803 818 }
804 819 }
  820 + }else{
  821 + if(y.getLp().equals(s.getLpName())){
  822 + newList.add(s);
  823 + Set<ChildTaskPlan> cts = s.getcTasks();
  824 + if(cts != null && cts.size() > 0){
  825 + newList_.add(s);
  826 + }else{
  827 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  828 + newList_.add(s);
  829 + }
  830 + }
  831 + }
  832 + }
805 833 }
806 834 }
807 835 double jhgl=culateMileageService.culateJhgl(newList);
... ... @@ -1604,7 +1632,7 @@ public class FormsServiceImpl implements FormsService {
1604 1632 @Override
1605 1633 public int compare(Singledata o1, Singledata o2) {
1606 1634 // TODO Auto-generated method stub
1607   - return o2.getxL().compareTo(o1.getxL());
  1635 + return (o2.getxL()+o2.getClzbh()).compareTo((o1.getxL()+o1.getClzbh()));
1608 1636 }
1609 1637 }
1610 1638 }
... ...
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
... ... @@ -184,6 +184,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
184 184 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));
185 185 t.setSsgsdm(map.get("company")==null?"":map.get("company").toString());
186 186 t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString());
  187 + t.setLp(map.get("lpName")==null?"":map.get("lpName").toString());
187 188 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
188 189 t.setRq(sdf.parse(rq));
189 190 t.setCreatetime(dNow);
... ... @@ -262,13 +263,16 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
262 263 // TODO Auto-generated method stub
263 264 // 当天YLB信息
264 265 List<Ylb> ylList = this.listOrderBy(rq,gsbm,fgsbm,line,nbbm,"nbbm");
265   -// repository.obtainYl(rq,gsbm,fgsbm,line,nbbm,"nbbm");
  266 +
266 267 // 当天YLXXB信息
267 268 List<Ylxxb> ylxxList = ylxxbRepository.obtainYlxx(rq, 0,gsbm);
  269 +
268 270 // 前一天所有车辆最后进场班次信息
269 271 // List<Ylb> ylListBe = repository.obtainYlbefore(rq, gsbm, fgsbm, line, nbbm);
270 272 List<Ylb> ylListBe =repository.listMaxRqJcsx(rq, gsbm, fgsbm, line, nbbm);
  273 +
271 274 List<Cyl> clyList = cylRepository.obtainCyl(nbbm,gsbm);
  275 +
272 276 // 从排班表中计算出行驶的总里程
273 277 List<Map<String, Object>> listpb =new ArrayList<Map<String, Object>>();
274 278 List<Map<String, Object>> listpbs=scheduleRealInfoService.yesterdayDataList(line, rq, gsbm, fgsbm, "", nbbm);
... ... @@ -307,11 +311,12 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
307 311 }
308 312 }
309 313 }
310   -
  314 +
311 315 List<Ylb> addList = new ArrayList<Ylb>();
312 316 List<Ylb> updateList = new ArrayList<Ylb>();
313   - String ins="";
314 317 Map<String, Object> ylMap=new HashMap<String, Object>();
  318 +
  319 + Map<String, Object> cMap=new HashMap<String, Object>();
315 320 for (int x = 0; x < listpb.size(); x++) {
316 321 String type = "add";
317 322 boolean sfdc = true;
... ... @@ -328,12 +333,25 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
328 333 Ylb t1 = ylList.get(k);
329 334 if (t1.getNbbm().equals(map.get("clZbh").toString())
330 335 && t1.getJsy().equals(map.get("jGh").toString())
331   - && t1.getXlbm().equals(map.get("xlBm").toString())) {
332   - t = t1;
333   - type = "update";
  336 + && t1.getXlbm().equals(map.get("xlBm").toString()
  337 + )) {
  338 + if(t1.getLp()==null){
  339 + //同人同车同线路不同路牌的过滤 (考虑到历史数据)
  340 + if (cMap.get(map.get("clZbh").toString()+map.get("jGh").toString()+map.get("xlBm").toString())==null) {
  341 + t = t1;
  342 + type = "update";
  343 + cMap.put(map.get("clZbh").toString()+map.get("jGh").toString()+map.get("xlBm").toString(),
  344 + map.get("clZbh").toString());
  345 + }
  346 + }else{
  347 + if(t1.getLp().equals(map.get("lpName").toString())){
  348 + t = t1;
  349 + type = "update";
  350 + }
  351 +
  352 + }
334 353 }
335 354 }
336   -
337 355 // 当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量
338 356 if (map.get("seqNumber").toString().equals("1")) {
339 357 boolean fage = true;
... ... @@ -428,7 +446,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
428 446 t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString());
429 447 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
430 448 t.setRq(sdf.parse(rq));
431   -
  449 + t.setLp(map.get("lpName")==null?"":map.get("lpName").toString());
432 450 if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){
433 451 if(type.equals("add")){
434 452 t.setCreatetime(date);
... ... @@ -436,7 +454,6 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
436 454 }else{
437 455 t.setUpdatetime(date);
438 456 updateList.add(t);
439   - ins += t.getId().toString()+",";
440 457 }
441 458 }
442 459 // repository.save(t);
... ... @@ -456,7 +473,6 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
456 473 }
457 474  
458 475 }
459   -
460 476 if(updateList.size()>0){
461 477 for (int i = 0; i < updateList.size(); i++) {
462 478 repository.save(updateList.get(i));
... ... @@ -1437,23 +1453,12 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1437 1453 t.setYh(yh);
1438 1454 t.setJzyl(ylxs);
1439 1455 nextJzyl=ylxs;
1440   -
1441   -
1442 1456 }else{
1443 1457 t.setYh(yh);
1444 1458 t.setJzyl(nextJzyl);
1445 1459 }
1446 1460 }
1447 1461 repository.save(t);
1448   - for (int z = 0; z < cylList.size(); z++) {
1449   - Cyl cyl = cylList.get(z);
1450   - if (t.getNbbm().equals(cyl.getNbbm())) {
1451   - cyl.setCyl(t.getJzyl());
1452   - cyl.setUpdatetime(t.getRq());
1453   - break;
1454   - }
1455   - cylRepository.save(cyl);
1456   - }
1457 1462 }
1458 1463 newMap.put("status", ResponseCode.SUCCESS);
1459 1464 }
... ... @@ -1547,7 +1552,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1547 1552 String px) {
1548 1553 // TODO Auto-generated method stub
1549 1554 String sql="SELECT * FROM bsth_c_ylb "
1550   - + " where to_days('"+rq+"')=to_days(rq) and ssgsdm like '%"+gsdm+"%' "
  1555 + + " where rq ='"+rq+"' and ssgsdm like '%"+gsdm+"%' "
1551 1556 + " and fgsdm like '%"+fgsdm+"%'";
1552 1557 if(xlbm.equals("")){
1553 1558 sql+= " and xlbm like '%"+xlbm+"%' ";
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -2949,21 +2949,22 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2949 2949 }else{
2950 2950 yesterdayDataList=scheduleRealInfoRepository.yesterdayDataList_eq(line, date,gsbm,fgsbm,nbbm);
2951 2951 }
2952   - System.out.println("time2:"+new Date());
2953   -
2954 2952 List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date,gsbm,fgsbm);
2955 2953 for (int x = 0; x < yesterdayDataList.size(); x++) {
2956 2954 String jName = yesterdayDataList.get(x).get("jGh").toString();
2957 2955 String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
2958 2956 String xlbm = yesterdayDataList.get(x).get("xlBm").toString();
  2957 + String lp =yesterdayDataList.get(x).get("lpName").toString();
2959 2958 Map<String, Object> map = new HashMap<String, Object>();
2960 2959 boolean fage = true;
2961 2960 String company="";
2962 2961 String bCompany="";
2963 2962 List<ScheduleRealInfo> listS=new ArrayList<ScheduleRealInfo>();
2964 2963 for (ScheduleRealInfo scheduleRealInfo : lists) {
2965   - if(scheduleRealInfo.getjGh().equals(jName) && scheduleRealInfo.getClZbh().equals(clZbh)
2966   - && scheduleRealInfo.getXlBm().equals(xlbm)){
  2964 + if(scheduleRealInfo.getjGh().equals(jName)
  2965 + && scheduleRealInfo.getClZbh().equals(clZbh)
  2966 + && scheduleRealInfo.getXlBm().equals(xlbm)
  2967 + && scheduleRealInfo.getLpName().equals(lp)){
2967 2968 if (fage) {
2968 2969 //根据线路代码获取公司
2969 2970 company=scheduleRealInfo.getGsBm();
... ... @@ -2980,7 +2981,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2980 2981 }
2981 2982 }
2982 2983 }
2983   -
2984 2984 yesterdayDataList.get(x).put("company", company);
2985 2985 yesterdayDataList.get(x).put("bCompany", bCompany);
2986 2986 Double ljgl=culateMieageService.culateLjgl(listS);
... ... @@ -3005,6 +3005,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3005 3005 }
3006 3006 }
3007 3007 }
  3008 +
3008 3009 return yesterdayDataList;
3009 3010 }
3010 3011  
... ... @@ -3550,7 +3551,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3550 3551 map.put("fast", "");
3551 3552 map.put("slow", "");
3552 3553 }
3553   - System.out.println(map);
3554 3554 listMap.add(map);
3555 3555 } catch (Exception e) {
3556 3556 e.printStackTrace();
... ... @@ -3741,26 +3741,46 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3741 3741 type=0;
3742 3742 for (int i = 0; i < listYlb.size(); i++) {
3743 3743 Ylb y = listYlb.get(i);
3744   - ccyl=Arith.add(ccyl, y.getCzyl());
3745   - jcyl=Arith.add(jcyl, y.getJzyl());
3746   - yh =Arith.add(yh ,y.getYh());
3747   - jzl =Arith.add(jzl, y.getJzl());
3748   - zlc =Arith.add(zlc, y.getZlc());
  3744 + if(y.getLp()==null){
  3745 + ccyl=Arith.add(ccyl, y.getCzyl());
  3746 + jcyl=Arith.add(jcyl, y.getJzyl());
  3747 + yh =Arith.add(yh ,y.getYh());
  3748 + jzl =Arith.add(jzl, y.getJzl());
  3749 + zlc =Arith.add(zlc, y.getZlc());
  3750 + }else{
  3751 + if(y.getLp().equals(s.getLpName())){
  3752 + ccyl=Arith.add(ccyl, y.getCzyl());
  3753 + jcyl=Arith.add(jcyl, y.getJzyl());
  3754 + yh =Arith.add(yh ,y.getYh());
  3755 + jzl =Arith.add(jzl, y.getJzl());
  3756 + zlc =Arith.add(zlc, y.getZlc());
  3757 + }
  3758 + }
  3759 +
3749 3760 }
3750 3761 }else{
3751 3762 type=1;
3752 3763 for (int i = 0; i < listDlb.size(); i++) {
3753 3764 Dlb d=listDlb.get(i);
3754   - ccyl=Arith.add(ccyl, d.getCzcd());
3755   - jcyl=Arith.add(jcyl, d.getJzcd());
3756   - yh =Arith.add(yh ,d.getHd());
3757   - jzl =Arith.add(jzl, d.getCdl());
3758   - zlc =Arith.add(zlc, d.getZlc());
  3765 + if(d.getLp()==null){
  3766 + ccyl=Arith.add(ccyl, d.getCzcd());
  3767 + jcyl=Arith.add(jcyl, d.getJzcd());
  3768 + yh =Arith.add(yh ,d.getHd());
  3769 + jzl =Arith.add(jzl, d.getCdl());
  3770 + zlc =Arith.add(zlc, d.getZlc());
  3771 + }else{
  3772 + if(d.getLp().equals(s.getLpName())){
  3773 + ccyl=Arith.add(ccyl, d.getCzcd());
  3774 + jcyl=Arith.add(jcyl, d.getJzcd());
  3775 + yh =Arith.add(yh ,d.getHd());
  3776 + jzl =Arith.add(jzl, d.getCdl());
  3777 + zlc =Arith.add(zlc, d.getZlc());
  3778 + }
  3779 + }
  3780 +
3759 3781 }
3760 3782 }
3761 3783  
3762   -
3763   -
3764 3784 map.put("jzl", jzl);
3765 3785 map.put("yh", yh);
3766 3786 map.put("ccyl", ccyl);
... ...