Commit 2eff389e3016b0d63203c25154089a8d545d28bb
1 parent
a20368b4
统计公式优化
Showing
3 changed files
with
252 additions
and
174 deletions
src/main/java/com/bsth/service/calc/impl/CalcCulateMileageServiceImpl.java
| ... | ... | @@ -252,28 +252,28 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ |
| 252 | 252 | if(!scheduleRealInfo.isDestroy()){ |
| 253 | 253 | double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig(); |
| 254 | 254 | double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); |
| 255 | -// if(jhlc-jhlcOrig>0){ | |
| 256 | -// sjgl=Arith.add(sjgl,jhlcOrig); | |
| 257 | -// }else{ | |
| 255 | + if(jhlc-jhlcOrig>0){ | |
| 256 | + sjgl=Arith.add(sjgl,jhlcOrig); | |
| 257 | + }else{ | |
| 258 | 258 | sjgl=Arith.add(sjgl,jhlc); |
| 259 | -// } | |
| 259 | + } | |
| 260 | 260 | } |
| 261 | - } | |
| 262 | - }else{ | |
| 263 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 264 | - while (it.hasNext()) { | |
| 265 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 266 | - if(childTaskPlan.getMileageType().equals("empty") | |
| 267 | -// &&"正常".equals(childTaskPlan.getType1()) | |
| 268 | - && (!childTaskPlan.isNoClerk()) | |
| 269 | - && childTaskPlan.getCcId()==null){ | |
| 270 | - if (!childTaskPlan.isDestroy()) { | |
| 271 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 272 | - sjgl=Arith.add(sjgl,jhgl); | |
| 273 | - } | |
| 261 | + } | |
| 262 | + }else{ | |
| 263 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 264 | + while (it.hasNext()) { | |
| 265 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 266 | + if(childTaskPlan.getMileageType().equals("empty") | |
| 267 | + &&"正常".equals(childTaskPlan.getType1()) | |
| 268 | + && (!childTaskPlan.isNoClerk()) | |
| 269 | + && childTaskPlan.getCcId()==null){ | |
| 270 | + if (!childTaskPlan.isDestroy()) { | |
| 271 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 272 | + sjgl=Arith.add(sjgl,jhgl); | |
| 273 | + } | |
| 274 | 274 | } |
| 275 | - } | |
| 276 | - } | |
| 275 | + } | |
| 276 | + } | |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | return sjgl; |
| ... | ... | @@ -421,7 +421,7 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | - } | |
| 424 | + } | |
| 425 | 425 | }else{ |
| 426 | 426 | if(childTaskPlans.isEmpty()){ |
| 427 | 427 | Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); |
| ... | ... | @@ -451,7 +451,7 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ |
| 451 | 451 | for (int i = 0; i < lists.size(); i++) { |
| 452 | 452 | ScheduleRealInfo scheduleRealInfo=lists.get(i); |
| 453 | 453 | Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); |
| 454 | -// if (isInOut(scheduleRealInfo)) { | |
| 454 | + if (isInOut(scheduleRealInfo)) { | |
| 455 | 455 | if(scheduleRealInfo.isSflj()){ |
| 456 | 456 | if(childTaskPlans.isEmpty()){ |
| 457 | 457 | if(!scheduleRealInfo.isDestroy() && isInOut(scheduleRealInfo)) |
| ... | ... | @@ -470,48 +470,47 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | + }else{ | |
| 474 | + if(childTaskPlans.isEmpty()){ | |
| 475 | + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); | |
| 476 | + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig(); | |
| 477 | + double zjlc=Arith.sub(jhlc, jhlcOrig); | |
| 478 | + if(zjlc>0){ | |
| 479 | + ljgl=Arith.add(zjlc, ljgl); | |
| 480 | + } | |
| 481 | + }else{ | |
| 482 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 483 | + while (it.hasNext()) { | |
| 484 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 485 | + if("empty".equals(childTaskPlan.getMileageType()) | |
| 486 | + &&"临加".equals(childTaskPlan.getType1()) | |
| 487 | + && childTaskPlan.getCcId() == null | |
| 488 | + && (!childTaskPlan.isNoClerk())){ | |
| 489 | + if (!childTaskPlan.isDestroy()) { | |
| 490 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 491 | + ljgl=Arith.add(ljgl,jhgl); | |
| 492 | + } | |
| 493 | + } | |
| 494 | + } | |
| 495 | + } | |
| 473 | 496 | } |
| 474 | -// }else{ | |
| 475 | -// if(childTaskPlans.isEmpty()){ | |
| 476 | -// double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); | |
| 477 | -// double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig(); | |
| 478 | -// double zjlc=Arith.sub(jhlc, jhlcOrig); | |
| 479 | -// if(zjlc>0){ | |
| 480 | -// ljgl=Arith.add(zjlc, ljgl); | |
| 481 | -// } | |
| 482 | -// }else{ | |
| 483 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 484 | -// while (it.hasNext()) { | |
| 485 | -// ChildTaskPlan childTaskPlan = it.next(); | |
| 486 | -// if("empty".equals(childTaskPlan.getMileageType()) | |
| 487 | -// &&"临加".equals(childTaskPlan.getType1()) | |
| 488 | -// && childTaskPlan.getCcId() == null | |
| 489 | -// && (!childTaskPlan.isNoClerk())){ | |
| 490 | -// if (!childTaskPlan.isDestroy()) { | |
| 491 | -// Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 492 | -// ljgl=Arith.add(ljgl,jhgl); | |
| 493 | -// } | |
| 494 | -// } | |
| 495 | -// } | |
| 496 | -// } | |
| 497 | -// } | |
| 498 | -// }else{ | |
| 499 | -// if (!childTaskPlans.isEmpty()) { | |
| 500 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 501 | -// while (it.hasNext()) { | |
| 502 | -// ChildTaskPlan childTaskPlan = it.next(); | |
| 503 | -// if ("empty".equals(childTaskPlan.getMileageType()) | |
| 504 | -// && "临加".equals(childTaskPlan.getType1()) | |
| 505 | -// && childTaskPlan.getCcId() == null | |
| 506 | -// && (!childTaskPlan.isNoClerk())) { | |
| 507 | -// if (!childTaskPlan.isDestroy()) { | |
| 508 | -// Float jhgl = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 509 | -// ljgl = Arith.add(ljgl, jhgl); | |
| 510 | -// } | |
| 511 | -// } | |
| 512 | -// } | |
| 513 | -// } | |
| 514 | -// } | |
| 497 | + }else{ | |
| 498 | + if (!childTaskPlans.isEmpty()) { | |
| 499 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 500 | + while (it.hasNext()) { | |
| 501 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 502 | + if ("empty".equals(childTaskPlan.getMileageType()) | |
| 503 | + && "临加".equals(childTaskPlan.getType1()) | |
| 504 | + && childTaskPlan.getCcId() == null | |
| 505 | + && (!childTaskPlan.isNoClerk())) { | |
| 506 | + if (!childTaskPlan.isDestroy()) { | |
| 507 | + Float jhgl = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 508 | + ljgl = Arith.add(ljgl, jhgl); | |
| 509 | + } | |
| 510 | + } | |
| 511 | + } | |
| 512 | + } | |
| 513 | + } | |
| 515 | 514 | } |
| 516 | 515 | return ljgl; |
| 517 | 516 | } |
| ... | ... | @@ -522,7 +521,7 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ |
| 522 | 521 | double ljgl =0; |
| 523 | 522 | for (int i = 0; i < lists.size(); i++) { |
| 524 | 523 | ScheduleRealInfo scheduleRealInfo=lists.get(i); |
| 525 | -// if (!isInOut(scheduleRealInfo)) { | |
| 524 | + if (!isInOut(scheduleRealInfo)) { | |
| 526 | 525 | Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); |
| 527 | 526 | if(scheduleRealInfo.isSflj()){ |
| 528 | 527 | if(!childTaskPlans.isEmpty()){ |
| ... | ... | @@ -538,24 +537,24 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ |
| 538 | 537 | } |
| 539 | 538 | } |
| 540 | 539 | } |
| 541 | - } | |
| 542 | -// }else{ | |
| 543 | -// if(childTaskPlans.isEmpty()){ | |
| 544 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 545 | -// while (it.hasNext()) { | |
| 546 | -// ChildTaskPlan childTaskPlan = it.next(); | |
| 547 | -// if("empty".equals(childTaskPlan.getMileageType()) | |
| 548 | -// &&"临加".equals(childTaskPlan.getType1()) | |
| 549 | -// && childTaskPlan.getCcId()==null | |
| 550 | -// && childTaskPlan.isNoClerk()){ | |
| 551 | -// if (!childTaskPlan.isDestroy()) { | |
| 552 | -// Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 553 | -// ljgl=Arith.add(ljgl,jhgl); | |
| 554 | -// } | |
| 555 | -// } | |
| 556 | -// } | |
| 557 | -// } | |
| 558 | -// } | |
| 540 | + } | |
| 541 | + }else{ | |
| 542 | + if(childTaskPlans.isEmpty()){ | |
| 543 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 544 | + while (it.hasNext()) { | |
| 545 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 546 | + if("empty".equals(childTaskPlan.getMileageType()) | |
| 547 | + &&"临加".equals(childTaskPlan.getType1()) | |
| 548 | + && childTaskPlan.getCcId()==null | |
| 549 | + && childTaskPlan.isNoClerk()){ | |
| 550 | + if (!childTaskPlan.isDestroy()) { | |
| 551 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 552 | + ljgl=Arith.add(ljgl,jhgl); | |
| 553 | + } | |
| 554 | + } | |
| 555 | + } | |
| 556 | + } | |
| 557 | + } | |
| 559 | 558 | } |
| 560 | 559 | } |
| 561 | 560 | return ljgl; | ... | ... |
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
| ... | ... | @@ -109,10 +109,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 109 | 109 | if(date == null || date.trim().length() == 0){ |
| 110 | 110 | Date d = new Date(); |
| 111 | 111 | d.setTime(d.getTime() - (4l * 1000 * 60 * 60 * 24)); |
| 112 | - for(long i = 0; i < 3; i++){ | |
| 113 | - d.setTime(d.getTime() + (i * 1000 * 60 * 60 * 24)); | |
| 114 | - dateList.add(sdf.format(d)); | |
| 115 | - } | |
| 112 | + dateList.add(sdf.format(d)); | |
| 113 | + d.setTime(d.getTime() - (1l * 1000 * 60 * 60 * 24)); | |
| 114 | + dateList.add(sdf.format(d)); | |
| 116 | 115 | } else { |
| 117 | 116 | date = date.trim(); |
| 118 | 117 | dateList.add(date); |
| ... | ... | @@ -130,21 +129,21 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 130 | 129 | m.put("generateNew", generateNew); |
| 131 | 130 | } catch (Exception e) { |
| 132 | 131 | // TODO: handle exception |
| 133 | - logger.info("重新统计保存失败!"); | |
| 132 | + logger.info("date="+d+";line="+line+";重新统计保存失败!"); | |
| 134 | 133 | } |
| 135 | 134 | try { |
| 136 | 135 | Map<String, Object> calcLineMileage = calcLineMileage(d, line); |
| 137 | 136 | m.put("lineMileage", calcLineMileage); |
| 138 | 137 | } catch (Exception e) { |
| 139 | 138 | // TODO: handle exception |
| 140 | - logger.info("线路公里审计保存失败!"); | |
| 139 | + logger.info("date="+d+";line="+line+";线路公里审计保存失败!"); | |
| 141 | 140 | } |
| 142 | 141 | try { |
| 143 | 142 | Map<String, Object> calcBusMileage = calcBusMileage(d, line); |
| 144 | 143 | m.put("busMileage", calcBusMileage); |
| 145 | 144 | } catch (Exception e) { |
| 146 | 145 | // TODO: handle exception |
| 147 | - logger.info("路单数据审计保存失败!"); | |
| 146 | + logger.info("date="+d+";line="+line+";路单数据审计保存失败!"); | |
| 148 | 147 | } |
| 149 | 148 | } |
| 150 | 149 | |
| ... | ... | @@ -473,6 +472,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 473 | 472 | public String calcDaily(String rq, String line) throws Exception{ |
| 474 | 473 | String result = ""; |
| 475 | 474 | try { |
| 475 | + List<String> dateList = new ArrayList<String>(); | |
| 476 | 476 | if(rq == null || rq.trim().length() == 0){ |
| 477 | 477 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
| 478 | 478 | Date dNow = new Date(); //当前时间 |
| ... | ... | @@ -481,101 +481,115 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 481 | 481 | calendar.setTime(dNow);//把当前时间赋给日历 |
| 482 | 482 | calendar.add(Calendar.DAY_OF_MONTH, -4); //设置为前一天 |
| 483 | 483 | dBefore = calendar.getTime(); //得到前一天的时间 |
| 484 | - rq = sdf.format(dBefore); | |
| 484 | +// rq = sdf.format(dBefore); | |
| 485 | + dateList.add(sdf.format(dBefore)); | |
| 486 | + Date date = new Date(); | |
| 487 | + date.setTime(dBefore.getTime() - 1l*1000*60*60*24); | |
| 488 | + dateList.add(sdf.format(date)); | |
| 485 | 489 | } else { |
| 486 | - rq = rq.trim(); | |
| 490 | +// rq = rq.trim(); | |
| 491 | + dateList.add(rq.trim()); | |
| 487 | 492 | } |
| 488 | 493 | if(line == null || line.trim().length() == 0){ |
| 489 | 494 | line = ""; |
| 490 | 495 | } else { |
| 491 | 496 | line = line.trim(); |
| 492 | 497 | } |
| 493 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 494 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 495 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 496 | - | |
| 497 | - String gsSql="select gs_bm, fgs_bm from bsth_c_s_sp_info_real where schedule_date_str = '"+rq+"'"; | |
| 498 | - if(line.trim().length() > 0) | |
| 499 | - gsSql += " and xl_bm = '"+line+"'"; | |
| 500 | - gsSql += " group by gs_bm, fgs_bm"; | |
| 501 | - List<Map<String, String>> gsList=jdbcTemplate.query(gsSql, new RowMapper<Map<String, String>>() { | |
| 502 | - @Override | |
| 503 | - public Map<String, String> mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 504 | - Map<String, String> m = new HashMap<String, String>(); | |
| 505 | - m.put("gsdm", arg0.getString("gs_bm")); | |
| 506 | - m.put("fgsdm", arg0.getString("fgs_bm")); | |
| 507 | - return m; | |
| 508 | - }}); | |
| 509 | - | |
| 510 | - //查询所有线路 | |
| 511 | - for(Map<String, String> m : gsList){ | |
| 512 | - list.addAll(calcStatisticsRepository.scheduleByDateAndLine(line, rq, rq, m.get("gsdm"), m.get("fgsdm"))); | |
| 513 | - } | |
| 514 | 498 | |
| 515 | - List<CalcInterval> listInterval=calcIntervalRepository.selectByDateAndCompany(rq, "", "",""); | |
| 516 | - Map<String,CalcInterval> mapInterval=new HashMap<String,CalcInterval>(); | |
| 517 | - for (int i = 0; i < listInterval.size(); i++) { | |
| 518 | - CalcInterval c=listInterval.get(i); | |
| 519 | - mapInterval.put(c.getXlBm(), c); | |
| 520 | - } | |
| 521 | - | |
| 522 | - | |
| 523 | - for (int i = 0; i < list.size(); i++) { | |
| 524 | - ScheduleRealInfo s=list.get(i); | |
| 525 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 526 | - if(cts != null && cts.size() > 0){ | |
| 527 | - list_s.add(s); | |
| 528 | - }else{ | |
| 529 | - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | |
| 530 | - list_s.add(s); | |
| 499 | + for(int j = 0; j < dateList.size(); j++){ | |
| 500 | + rq = dateList.get(j); | |
| 501 | + | |
| 502 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 503 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 504 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 505 | + | |
| 506 | + String gsSql="select gs_bm, fgs_bm from bsth_c_s_sp_info_real where schedule_date_str = '"+rq+"'"; | |
| 507 | + if(line.trim().length() > 0) | |
| 508 | + gsSql += " and xl_bm = '"+line+"'"; | |
| 509 | + gsSql += " group by gs_bm, fgs_bm"; | |
| 510 | + List<Map<String, String>> gsList=jdbcTemplate.query(gsSql, new RowMapper<Map<String, String>>() { | |
| 511 | + @Override | |
| 512 | + public Map<String, String> mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 513 | + Map<String, String> m = new HashMap<String, String>(); | |
| 514 | + m.put("gsdm", arg0.getString("gs_bm")); | |
| 515 | + m.put("fgsdm", arg0.getString("fgs_bm")); | |
| 516 | + return m; | |
| 517 | + }}); | |
| 518 | + | |
| 519 | + //查询所有线路 | |
| 520 | + for(Map<String, String> m : gsList){ | |
| 521 | + list.addAll(calcStatisticsRepository.scheduleByDateAndLine(line, rq, rq, m.get("gsdm"), m.get("fgsdm"))); | |
| 522 | + } | |
| 523 | + | |
| 524 | + List<CalcInterval> listInterval=calcIntervalRepository.selectByDateAndCompany(rq, "", "",""); | |
| 525 | + Map<String,CalcInterval> mapInterval=new HashMap<String,CalcInterval>(); | |
| 526 | + for (int i = 0; i < listInterval.size(); i++) { | |
| 527 | + CalcInterval c=listInterval.get(i); | |
| 528 | + mapInterval.put(c.getXlBm(), c); | |
| 529 | + } | |
| 530 | + | |
| 531 | + | |
| 532 | + for (int i = 0; i < list.size(); i++) { | |
| 533 | + ScheduleRealInfo s=list.get(i); | |
| 534 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 535 | + if(cts != null && cts.size() > 0){ | |
| 536 | + list_s.add(s); | |
| 537 | + }else{ | |
| 538 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | |
| 539 | + list_s.add(s); | |
| 540 | + } | |
| 531 | 541 | } |
| 532 | - } | |
| 533 | - } | |
| 534 | - List<CalcStatistics> lMap = new ArrayList<CalcStatistics>(); | |
| 535 | - for (int i = 0; i < list.size(); i++) { | |
| 536 | - if(i<list.size()-1){ | |
| 537 | - if(list.get(i+1).getXlBm().equals(list.get(i).getXlBm())){ | |
| 538 | - lists.add(list.get(i)); | |
| 539 | - }else{ | |
| 540 | - lists.add(list.get(i)); | |
| 541 | - CalcInterval t=null; | |
| 542 | - if(mapInterval.get(lists.get(0).getXlBm())!=null){ | |
| 543 | - t=mapInterval.get(lists.get(0).getXlBm()); | |
| 544 | - } | |
| 545 | - | |
| 546 | - CalcStatistics s=staticTj(lists,t); | |
| 547 | - lMap.add(s); | |
| 548 | - lists=new ArrayList<ScheduleRealInfo>(); | |
| 549 | - } | |
| 550 | - }else{ | |
| 551 | - if(list.get(i).getXlBm().equals(list.get(i-1).getXlBm())){ | |
| 552 | - lists.add(list.get(i)); | |
| 553 | - CalcInterval t=null; | |
| 554 | - if(mapInterval.get(lists.get(0).getXlBm())!=null){ | |
| 555 | - t=mapInterval.get(lists.get(0).getXlBm()); | |
| 556 | - } | |
| 557 | - CalcStatistics s=staticTj(lists,t); | |
| 558 | - lMap.add(s); | |
| 559 | - }else{ | |
| 560 | - lists=new ArrayList<ScheduleRealInfo>(); | |
| 561 | - lists.add(list.get(i)); | |
| 562 | - CalcInterval t=null; | |
| 563 | - if(mapInterval.get(lists.get(0).getXlBm())!=null){ | |
| 564 | - t=mapInterval.get(lists.get(0).getXlBm()); | |
| 565 | - } | |
| 566 | - CalcStatistics s=staticTj(lists,t); | |
| 567 | - lMap.add(s); | |
| 568 | - } | |
| 569 | - } | |
| 570 | - } | |
| 571 | -// Collections.sort(lMap,new AccountXlbm()); | |
| 572 | - | |
| 573 | - if(line.trim().length() > 0){ | |
| 574 | - calcStatisticsRepository.deleteByDateAndLine(rq, line); | |
| 575 | - } else { | |
| 576 | - calcStatisticsRepository.deleteByDate(rq); | |
| 577 | - } | |
| 578 | - calcStatisticsRepository.save(lMap); | |
| 542 | + } | |
| 543 | + List<CalcStatistics> lMap = new ArrayList<CalcStatistics>(); | |
| 544 | + for (int i = 0; i < list.size(); i++) { | |
| 545 | + if(i<list.size()-1){ | |
| 546 | + if(list.get(i+1).getXlBm().equals(list.get(i).getXlBm())){ | |
| 547 | + lists.add(list.get(i)); | |
| 548 | + }else{ | |
| 549 | + lists.add(list.get(i)); | |
| 550 | + CalcInterval t=null; | |
| 551 | + if(mapInterval.get(lists.get(0).getXlBm())!=null){ | |
| 552 | + t=mapInterval.get(lists.get(0).getXlBm()); | |
| 553 | + } | |
| 554 | + | |
| 555 | + CalcStatistics s=staticTj(lists,t); | |
| 556 | + lMap.add(s); | |
| 557 | + lists=new ArrayList<ScheduleRealInfo>(); | |
| 558 | + } | |
| 559 | + }else{ | |
| 560 | + if(list.get(i).getXlBm().equals(list.get(i-1).getXlBm())){ | |
| 561 | + lists.add(list.get(i)); | |
| 562 | + CalcInterval t=null; | |
| 563 | + if(mapInterval.get(lists.get(0).getXlBm())!=null){ | |
| 564 | + t=mapInterval.get(lists.get(0).getXlBm()); | |
| 565 | + } | |
| 566 | + CalcStatistics s=staticTj(lists,t); | |
| 567 | + lMap.add(s); | |
| 568 | + }else{ | |
| 569 | + lists=new ArrayList<ScheduleRealInfo>(); | |
| 570 | + lists.add(list.get(i)); | |
| 571 | + CalcInterval t=null; | |
| 572 | + if(mapInterval.get(lists.get(0).getXlBm())!=null){ | |
| 573 | + t=mapInterval.get(lists.get(0).getXlBm()); | |
| 574 | + } | |
| 575 | + CalcStatistics s=staticTj(lists,t); | |
| 576 | + lMap.add(s); | |
| 577 | + } | |
| 578 | + } | |
| 579 | + } | |
| 580 | + // Collections.sort(lMap,new AccountXlbm()); | |
| 581 | + | |
| 582 | + if(line.trim().length() > 0){ | |
| 583 | + calcStatisticsRepository.deleteByDateAndLine(rq, line); | |
| 584 | + } else { | |
| 585 | + calcStatisticsRepository.deleteByDate(rq); | |
| 586 | + } | |
| 587 | + calcStatisticsRepository.save(lMap); | |
| 588 | + | |
| 589 | + System.out.println(rq); | |
| 590 | + System.out.println(dateList.size()); | |
| 591 | + } | |
| 592 | + | |
| 579 | 593 | result = "success"; |
| 580 | 594 | } catch (Exception e) { |
| 581 | 595 | // TODO: handle exception | ... | ... |
src/main/java/com/bsth/service/report/impl/CulateMileageServiceImpl.java
| ... | ... | @@ -1101,6 +1101,71 @@ public class CulateMileageServiceImpl implements CulateMileageService{ |
| 1101 | 1101 | } |
| 1102 | 1102 | } |
| 1103 | 1103 | } |
| 1104 | + } else { | |
| 1105 | + Set<ChildTaskPlan> childTaskPlans = t.getcTasks(); | |
| 1106 | + if(!isInOut(t)){ | |
| 1107 | + if(childTaskPlans.isEmpty()){ | |
| 1108 | + double jhlc=t.getJhlc()==null?0:t.getJhlc(); | |
| 1109 | + double jhlcOrig=t.getJhlcOrig()==null?0:t.getJhlcOrig(); | |
| 1110 | + double zjlc=Arith.sub(jhlc, jhlcOrig); | |
| 1111 | + if(zjlc>0){ | |
| 1112 | + ljyy=Arith.add(zjlc, ljyy); | |
| 1113 | + } | |
| 1114 | + }else{ | |
| 1115 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 1116 | + while (it.hasNext()) { | |
| 1117 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 1118 | + if("service".equals(childTaskPlan.getMileageType()) | |
| 1119 | + &&"临加".equals(childTaskPlan.getType1()) | |
| 1120 | + && childTaskPlan.getCcId() == null | |
| 1121 | + && (!childTaskPlan.isNoClerk())){ | |
| 1122 | + if (!childTaskPlan.isDestroy()) { | |
| 1123 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 1124 | + ljyy=Arith.add(ljyy,jhgl); | |
| 1125 | + } | |
| 1126 | + } | |
| 1127 | + } | |
| 1128 | + } | |
| 1129 | + } else { | |
| 1130 | + if(childTaskPlans.isEmpty()){ | |
| 1131 | + if(t.getBcType().equals("in") || t.getBcType().equals("out")){ | |
| 1132 | + double jhlc=t.getJhlc()==null?0:t.getJhlc(); | |
| 1133 | + double jhlcOrig=t.getJhlcOrig()==null?0:t.getJhlcOrig(); | |
| 1134 | + double zjlc=Arith.sub(jhlc, jhlcOrig); | |
| 1135 | + if(zjlc>0){ | |
| 1136 | + ljjcc=Arith.add(zjlc, ljjcc); | |
| 1137 | + } | |
| 1138 | + } | |
| 1139 | + | |
| 1140 | + if(t.getBcType().equals("ldks")){ | |
| 1141 | + double jhlc=t.getJhlc()==null?0:t.getJhlc(); | |
| 1142 | + double jhlcOrig=t.getJhlcOrig()==null?0:t.getJhlcOrig(); | |
| 1143 | + double zjlc=Arith.sub(jhlc, jhlcOrig); | |
| 1144 | + if(zjlc>0){ | |
| 1145 | + ljkfks=Arith.add(zjlc, ljkfks); | |
| 1146 | + } | |
| 1147 | + } | |
| 1148 | + }else{ | |
| 1149 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 1150 | + while (it.hasNext()) { | |
| 1151 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 1152 | + if("empty".equals(childTaskPlan.getMileageType()) | |
| 1153 | + &&"临加".equals(childTaskPlan.getType1()) | |
| 1154 | + && childTaskPlan.getCcId() == null | |
| 1155 | + && (!childTaskPlan.isNoClerk())){ | |
| 1156 | + if (!childTaskPlan.isDestroy()) { | |
| 1157 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 1158 | + if(childTaskPlan.getType2().equals("2")||childTaskPlan.getType2().equals("3")){ | |
| 1159 | + ljjcc=Arith.add(ljjcc,jhgl); | |
| 1160 | + } else { | |
| 1161 | + ljkfks=Arith.add(ljkfks,jhgl); | |
| 1162 | + } | |
| 1163 | + | |
| 1164 | + } | |
| 1165 | + } | |
| 1166 | + } | |
| 1167 | + } | |
| 1168 | + } | |
| 1104 | 1169 | } |
| 1105 | 1170 | } |
| 1106 | 1171 | ... | ... |