Commit fdf2d682217c247e80d8d6e7e520029bfce04bf6

Authored by 潘钊
1 parent 22f2cea6

update...

src/main/java/com/bsth/server_ws/util/ScheduleCalculator.java
@@ -10,6 +10,8 @@ import com.google.common.collect.ArrayListMultimap; @@ -10,6 +10,8 @@ import com.google.common.collect.ArrayListMultimap;
10 import org.apache.commons.lang3.StringUtils; 10 import org.apache.commons.lang3.StringUtils;
11 import org.joda.time.format.DateTimeFormat; 11 import org.joda.time.format.DateTimeFormat;
12 import org.joda.time.format.DateTimeFormatter; 12 import org.joda.time.format.DateTimeFormatter;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
13 15
14 import java.util.*; 16 import java.util.*;
15 17
@@ -19,6 +21,7 @@ import java.util.*; @@ -19,6 +21,7 @@ import java.util.*;
19 */ 21 */
20 public class ScheduleCalculator { 22 public class ScheduleCalculator {
21 23
  24 + static Logger logger = LoggerFactory.getLogger(ScheduleCalculator.class);
22 25
23 /** 26 /**
24 * 计划公里(不包括临加公里) 27 * 计划公里(不包括临加公里)
@@ -28,10 +31,14 @@ public class ScheduleCalculator { @@ -28,10 +31,14 @@ public class ScheduleCalculator {
28 */ 31 */
29 public static double calcJHLC(List<ScheduleRealInfo> list) { 32 public static double calcJHLC(List<ScheduleRealInfo> list) {
30 double sum = 0; 33 double sum = 0;
31 - for (ScheduleRealInfo sch : list) {  
32 - if (sch.isSflj())  
33 - continue;  
34 - sum = Arith.add(sum, sch.getJhlcOrig()==null?0:sch.getJhlcOrig()); 34 + try {
  35 + for (ScheduleRealInfo sch : list) {
  36 + if (sch.isSflj())
  37 + continue;
  38 + sum = Arith.add(sum, sch.getJhlcOrig() == null ? 0 : sch.getJhlcOrig());
  39 + }
  40 + } catch (Exception e) {
  41 + logger.error("", e);
35 } 42 }
36 return sum; 43 return sum;
37 } 44 }
@@ -44,19 +51,22 @@ public class ScheduleCalculator { @@ -44,19 +51,22 @@ public class ScheduleCalculator {
44 */ 51 */
45 public static double calcCCLC(List<ScheduleRealInfo> list) { 52 public static double calcCCLC(List<ScheduleRealInfo> list) {
46 double sum = 0; 53 double sum = 0;
47 -  
48 - Set<ChildTaskPlan> cts;  
49 - for (ScheduleRealInfo sch : list) {  
50 - cts = sch.getcTasks();  
51 - //有子任务  
52 - if (cts != null && cts.size() > 0) {  
53 - for (ChildTaskPlan ct : cts) {  
54 - if (ct.getType2().equals("3"))  
55 - sum = Arith.add(sum, ct.getMileage()); 54 + try {
  55 + Set<ChildTaskPlan> cts;
  56 + for (ScheduleRealInfo sch : list) {
  57 + cts = sch.getcTasks();
  58 + //有子任务
  59 + if (cts != null && cts.size() > 0) {
  60 + for (ChildTaskPlan ct : cts) {
  61 + if (ct.getType2().equals("3"))
  62 + sum = Arith.add(sum, ct.getMileage());
  63 + }
  64 + } else if (sch.getBcType().equals("out") && sch.getStatus() != -1) {
  65 + sum = Arith.add(sum, sch.getJhlc());
56 } 66 }
57 - } else if (sch.getBcType().equals("out") && sch.getStatus() != -1) {  
58 - sum = Arith.add(sum, sch.getJhlc());  
59 } 67 }
  68 + } catch (Exception e) {
  69 + logger.error("", e);
60 } 70 }
61 return sum; 71 return sum;
62 } 72 }
@@ -69,18 +79,22 @@ public class ScheduleCalculator { @@ -69,18 +79,22 @@ public class ScheduleCalculator {
69 */ 79 */
70 public static double calcJCLC(List<ScheduleRealInfo> list) { 80 public static double calcJCLC(List<ScheduleRealInfo> list) {
71 double sum = 0; 81 double sum = 0;
72 - Set<ChildTaskPlan> cts;  
73 - for (ScheduleRealInfo sch : list) {  
74 - cts = sch.getcTasks();  
75 - //有子任务  
76 - if (cts != null && cts.size() > 0) {  
77 - for (ChildTaskPlan ct : cts) {  
78 - if (ct.getType2().equals("2"))  
79 - sum = Arith.add(sum, ct.getMileage()); 82 + try {
  83 + Set<ChildTaskPlan> cts;
  84 + for (ScheduleRealInfo sch : list) {
  85 + cts = sch.getcTasks();
  86 + //有子任务
  87 + if (cts != null && cts.size() > 0) {
  88 + for (ChildTaskPlan ct : cts) {
  89 + if (ct.getType2().equals("2"))
  90 + sum = Arith.add(sum, ct.getMileage());
  91 + }
  92 + } else if (sch.getBcType().equals("in") && sch.getStatus() != -1) {
  93 + sum = Arith.add(sum, sch.getJhlc());
80 } 94 }
81 - } else if (sch.getBcType().equals("in") && sch.getStatus() != -1) {  
82 - sum = Arith.add(sum, sch.getJhlc());  
83 } 95 }
  96 + } catch (Exception e) {
  97 + logger.error("", e);
84 } 98 }
85 return sum; 99 return sum;
86 } 100 }
@@ -93,10 +107,14 @@ public class ScheduleCalculator { @@ -93,10 +107,14 @@ public class ScheduleCalculator {
93 */ 107 */
94 public static double calcSJLC(List<ScheduleRealInfo> list) { 108 public static double calcSJLC(List<ScheduleRealInfo> list) {
95 double sum = 0; 109 double sum = 0;
96 - for (ScheduleRealInfo sch : list) {  
97 - if (sch.getStatus() == -1)  
98 - continue;  
99 - sum = Arith.add(sum, sch.getJhlcOrig()); 110 + try {
  111 + for (ScheduleRealInfo sch : list) {
  112 + if (sch.getStatus() == -1)
  113 + continue;
  114 + sum = Arith.add(sum, sch.getJhlcOrig());
  115 + }
  116 + } catch (Exception e) {
  117 + logger.error("", e);
100 } 118 }
101 return sum; 119 return sum;
102 } 120 }
@@ -110,22 +128,26 @@ public class ScheduleCalculator { @@ -110,22 +128,26 @@ public class ScheduleCalculator {
110 public static double calcYYLC(List<ScheduleRealInfo> list) { 128 public static double calcYYLC(List<ScheduleRealInfo> list) {
111 double sum = 0; 129 double sum = 0;
112 130
113 - Set<ChildTaskPlan> cts;  
114 - for (ScheduleRealInfo sch : list) {  
115 - if (sch.getStatus() == -1)  
116 - continue;  
117 - if (isInOut(sch) || sch.getBcType().equals("ldks"))  
118 - continue;  
119 -  
120 - cts = sch.getcTasks();  
121 - //有子任务  
122 - if (cts != null && cts.size() > 0) {  
123 - for (ChildTaskPlan ct : cts) {  
124 - if (ct.getMileageType().equals("service") && !ct.isDestroy())  
125 - sum = Arith.add(sum, ct.getMileage());  
126 - }  
127 - } else  
128 - sum = Arith.add(sum, sch.getJhlc()); 131 + try {
  132 + Set<ChildTaskPlan> cts;
  133 + for (ScheduleRealInfo sch : list) {
  134 + if (sch.getStatus() == -1)
  135 + continue;
  136 + if (isInOut(sch) || sch.getBcType().equals("ldks"))
  137 + continue;
  138 +
  139 + cts = sch.getcTasks();
  140 + //有子任务
  141 + if (cts != null && cts.size() > 0) {
  142 + for (ChildTaskPlan ct : cts) {
  143 + if (ct.getMileageType().equals("service") && !ct.isDestroy())
  144 + sum = Arith.add(sum, ct.getMileage());
  145 + }
  146 + } else
  147 + sum = Arith.add(sum, sch.getJhlc());
  148 + }
  149 + } catch (Exception e) {
  150 + logger.error("", e);
129 } 151 }
130 return sum; 152 return sum;
131 } 153 }
@@ -139,19 +161,22 @@ public class ScheduleCalculator { @@ -139,19 +161,22 @@ public class ScheduleCalculator {
139 public static double calcKSLC(List<ScheduleRealInfo> list) { 161 public static double calcKSLC(List<ScheduleRealInfo> list) {
140 double sum = 0; 162 double sum = 0;
141 163
142 - Set<ChildTaskPlan> cts;  
143 - for (ScheduleRealInfo sch : list) {  
144 - cts = sch.getcTasks();  
145 - //有子任务  
146 - if (cts != null && cts.size() > 0) {  
147 - for (ChildTaskPlan ct : cts) {  
148 - if (ct.getMileageType().equals("empty"))  
149 - sum = Arith.add(sum, ct.getMileage()); 164 + try {
  165 + Set<ChildTaskPlan> cts;
  166 + for (ScheduleRealInfo sch : list) {
  167 + cts = sch.getcTasks();
  168 + //有子任务
  169 + if (cts != null && cts.size() > 0) {
  170 + for (ChildTaskPlan ct : cts) {
  171 + if (ct.getMileageType().equals("empty"))
  172 + sum = Arith.add(sum, ct.getMileage());
  173 + }
  174 + } else if ((isInOut(sch) || sch.getBcType().equals("ldks")) && sch.getStatus() != -1) {
  175 + sum = Arith.add(sum, sch.getJhlc());
150 } 176 }
151 } 177 }
152 - else if ((isInOut(sch) || sch.getBcType().equals("ldks")) && sch.getStatus() != -1) {  
153 - sum = Arith.add(sum, sch.getJhlc());  
154 - } 178 + } catch (Exception e) {
  179 + logger.error("", e);
155 } 180 }
156 return sum; 181 return sum;
157 } 182 }
@@ -165,11 +190,15 @@ public class ScheduleCalculator { @@ -165,11 +190,15 @@ public class ScheduleCalculator {
165 public static double calcZJLC(List<ScheduleRealInfo> list) { 190 public static double calcZJLC(List<ScheduleRealInfo> list) {
166 double sum = 0; 191 double sum = 0;
167 192
168 - for (ScheduleRealInfo sch : list) {  
169 - if (sch.isSflj() && sch.getStatus() != -1)  
170 - sum = Arith.add(sum, sch.getJhlc());  
171 - else if (sch.getJhlc() > sch.getJhlcOrig())  
172 - sum = Arith.add(sum, (sch.getJhlc() - sch.getJhlcOrig())); 193 + try {
  194 + for (ScheduleRealInfo sch : list) {
  195 + if (sch.isSflj() && sch.getStatus() != -1)
  196 + sum = Arith.add(sum, sch.getJhlc());
  197 + else if (sch.getJhlc() > sch.getJhlcOrig())
  198 + sum = Arith.add(sum, (sch.getJhlc() - sch.getJhlcOrig()));
  199 + }
  200 + } catch (Exception e) {
  201 + logger.error("", e);
173 } 202 }
174 return sum; 203 return sum;
175 } 204 }
@@ -192,48 +221,56 @@ public class ScheduleCalculator { @@ -192,48 +221,56 @@ public class ScheduleCalculator {
192 */ 221 */
193 public static Double calcLBLC(List<ScheduleRealInfo> list) { 222 public static Double calcLBLC(List<ScheduleRealInfo> list) {
194 double sum = 0; 223 double sum = 0;
195 - Set<ChildTaskPlan> cts;  
196 - for (ScheduleRealInfo sch : list) {  
197 - if (sch.isSflj() || isInOut(sch) || sch.getBcType().equals("ldks"))  
198 - continue;  
199 -  
200 - cts = sch.getcTasks();  
201 - //有子任务  
202 - if (cts != null && cts.size() > 0) {  
203 - for (ChildTaskPlan ct : cts) {  
204 - if (ct.isDestroy() && ct.getMileageType().equals("service"))  
205 - sum = Arith.add(sum, ct.getMileage()); 224 + try {
  225 + Set<ChildTaskPlan> cts;
  226 + for (ScheduleRealInfo sch : list) {
  227 + if (sch.isSflj() || isInOut(sch) || sch.getBcType().equals("ldks"))
  228 + continue;
  229 +
  230 + cts = sch.getcTasks();
  231 + //有子任务
  232 + if (cts != null && cts.size() > 0) {
  233 + for (ChildTaskPlan ct : cts) {
  234 + if (ct.isDestroy() && ct.getMileageType().equals("service"))
  235 + sum = Arith.add(sum, ct.getMileage());
  236 + }
  237 + } else if (sch.getStatus() == -1) {
  238 + sum = Arith.add(sum, sch.getJhlcOrig());
206 } 239 }
207 - } else if (sch.getStatus() == -1) {  
208 - sum = Arith.add(sum, sch.getJhlcOrig());  
209 } 240 }
  241 + } catch (Exception e) {
  242 + logger.error("", e);
210 } 243 }
211 -  
212 return sum; 244 return sum;
213 } 245 }
214 246
215 /** 247 /**
216 * 拼接烂班原因,去重复 , 号拼接多个 248 * 拼接烂班原因,去重复 , 号拼接多个
  249 + *
217 * @param list 250 * @param list
218 * @return 251 * @return
219 */ 252 */
220 - public static String joinLBYY(List<ScheduleRealInfo> list){ 253 + public static String joinLBYY(List<ScheduleRealInfo> list) {
221 Set<String> sets = new HashSet<>(); 254 Set<String> sets = new HashSet<>();
222 Set<ChildTaskPlan> cts; 255 Set<ChildTaskPlan> cts;
223 - for(ScheduleRealInfo sch : list){  
224 - if (sch.isSflj() || isInOut(sch))  
225 - continue;  
226 -  
227 - cts = sch.getcTasks();  
228 - //有子任务  
229 - if (cts != null && cts.size() > 0) {  
230 - for (ChildTaskPlan ct : cts) {  
231 - if (ct.isDestroy())  
232 - sets.add(ct.getDestroyReason()); 256 + try {
  257 + for (ScheduleRealInfo sch : list) {
  258 + if (sch.isSflj() || isInOut(sch))
  259 + continue;
  260 +
  261 + cts = sch.getcTasks();
  262 + //有子任务
  263 + if (cts != null && cts.size() > 0) {
  264 + for (ChildTaskPlan ct : cts) {
  265 + if (ct.isDestroy())
  266 + sets.add(ct.getDestroyReason());
  267 + }
  268 + } else if (sch.getStatus() == -1) {
  269 + sets.add(sch.getAdjustExps());
233 } 270 }
234 - } else if (sch.getStatus() == -1) {  
235 - sets.add(sch.getAdjustExps());  
236 } 271 }
  272 + } catch (Exception e) {
  273 + logger.error("", e);
237 } 274 }
238 return Joiner.on(",").join(sets); 275 return Joiner.on(",").join(sets);
239 } 276 }
@@ -247,11 +284,15 @@ public class ScheduleCalculator { @@ -247,11 +284,15 @@ public class ScheduleCalculator {
247 public static int countJHBC(List<ScheduleRealInfo> list) { 284 public static int countJHBC(List<ScheduleRealInfo> list) {
248 int count = 0; 285 int count = 0;
249 286
250 - for (ScheduleRealInfo sch : list) {  
251 - if (sch.isSflj() || isInOut(sch))  
252 - continue; 287 + try {
  288 + for (ScheduleRealInfo sch : list) {
  289 + if (sch.isSflj() || isInOut(sch))
  290 + continue;
253 291
254 - count++; 292 + count++;
  293 + }
  294 + } catch (Exception e) {
  295 + logger.error("", e);
255 } 296 }
256 return count; 297 return count;
257 } 298 }
@@ -265,11 +306,15 @@ public class ScheduleCalculator { @@ -265,11 +306,15 @@ public class ScheduleCalculator {
265 public static int countSJJHBC(List<ScheduleRealInfo> list) { 306 public static int countSJJHBC(List<ScheduleRealInfo> list) {
266 int count = 0; 307 int count = 0;
267 308
268 - for (ScheduleRealInfo sch : list) {  
269 - if (sch.getStatus() == -1 || isInOut(sch))  
270 - continue; 309 + try {
  310 + for (ScheduleRealInfo sch : list) {
  311 + if (sch.getStatus() == -1 || isInOut(sch))
  312 + continue;
271 313
272 - count++; 314 + count++;
  315 + }
  316 + } catch (Exception e) {
  317 + logger.error("", e);
273 } 318 }
274 return count; 319 return count;
275 } 320 }
@@ -283,11 +328,15 @@ public class ScheduleCalculator { @@ -283,11 +328,15 @@ public class ScheduleCalculator {
283 public static int countZJBC(List<ScheduleRealInfo> list) { 328 public static int countZJBC(List<ScheduleRealInfo> list) {
284 int count = 0; 329 int count = 0;
285 330
286 - for (ScheduleRealInfo sch : list) {  
287 - if (!sch.isSflj() || isInOut(sch))  
288 - continue; 331 + try {
  332 + for (ScheduleRealInfo sch : list) {
  333 + if (!sch.isSflj() || isInOut(sch))
  334 + continue;
289 335
290 - count++; 336 + count++;
  337 + }
  338 + } catch (Exception e) {
  339 + logger.error("", e);
291 } 340 }
292 return count; 341 return count;
293 } 342 }
@@ -301,11 +350,15 @@ public class ScheduleCalculator { @@ -301,11 +350,15 @@ public class ScheduleCalculator {
301 public static int countCJBC(List<ScheduleRealInfo> list) { 350 public static int countCJBC(List<ScheduleRealInfo> list) {
302 int count = 0; 351 int count = 0;
303 352
304 - for (ScheduleRealInfo sch : list) {  
305 - if (sch.getStatus() != -1 || isInOut(sch))  
306 - continue; 353 + try {
  354 + for (ScheduleRealInfo sch : list) {
  355 + if (sch.getStatus() != -1 || isInOut(sch))
  356 + continue;
307 357
308 - count++; 358 + count++;
  359 + }
  360 + } catch (Exception e) {
  361 + logger.error("", e);
309 } 362 }
310 return count; 363 return count;
311 } 364 }
@@ -319,56 +372,70 @@ public class ScheduleCalculator { @@ -319,56 +372,70 @@ public class ScheduleCalculator {
319 public static Double calcLBGS(List<ScheduleRealInfo> list) { 372 public static Double calcLBGS(List<ScheduleRealInfo> list) {
320 double sum = 0; 373 double sum = 0;
321 374
322 - for (ScheduleRealInfo sch : list) {  
323 - if (sch.getStatus() != -1)  
324 - continue; 375 + try {
  376 + for (ScheduleRealInfo sch : list) {
  377 + if (sch.getStatus() != -1)
  378 + continue;
325 379
326 - sum = Arith.add(sum, sch.getBcsj()); 380 + sum = Arith.add(sum, sch.getBcsj());
  381 + }
  382 + } catch (Exception e) {
  383 + logger.error("", e);
327 } 384 }
328 return sum; 385 return sum;
329 } 386 }
330 387
331 388
332 -  
333 /** 389 /**
334 * 截取早班班次 390 * 截取早班班次
  391 + *
335 * @param list 392 * @param list
336 * @return 393 * @return
337 */ 394 */
338 - public static List<ScheduleRealInfo> earlyArray(List<ScheduleRealInfo> list){ 395 + public static List<ScheduleRealInfo> earlyArray(List<ScheduleRealInfo> list) {
339 List<ScheduleRealInfo> rs = new ArrayList<>(); 396 List<ScheduleRealInfo> rs = new ArrayList<>();
340 - for(ScheduleRealInfo sch : list){  
341 - if(sch.getDfsj().compareTo("00:00") > 0 && sch.getDfsj().compareTo("12:00") <= 0){  
342 - rs.add(sch); 397 + try {
  398 + for (ScheduleRealInfo sch : list) {
  399 + if (sch.getDfsj().compareTo("00:00") > 0 && sch.getDfsj().compareTo("12:00") <= 0) {
  400 + rs.add(sch);
  401 + }
343 } 402 }
  403 + } catch (Exception e) {
  404 + logger.error("", e);
344 } 405 }
345 return rs; 406 return rs;
346 } 407 }
347 408
348 /** 409 /**
349 * 截取晚班班次 410 * 截取晚班班次
  411 + *
350 * @param list 412 * @param list
351 * @return 413 * @return
352 */ 414 */
353 - public static List<ScheduleRealInfo> lastArray(List<ScheduleRealInfo> list){ 415 + public static List<ScheduleRealInfo> lastArray(List<ScheduleRealInfo> list) {
354 List<ScheduleRealInfo> rs = new ArrayList<>(); 416 List<ScheduleRealInfo> rs = new ArrayList<>();
355 - for(ScheduleRealInfo sch : list){  
356 - if(sch.getDfsj().compareTo("12:00") > 0 && sch.getDfsj().compareTo("23:59") <= 0){  
357 - rs.add(sch); 417 + try {
  418 + for (ScheduleRealInfo sch : list) {
  419 + if (sch.getDfsj().compareTo("12:00") > 0 && sch.getDfsj().compareTo("23:59") <= 0) {
  420 + rs.add(sch);
  421 + }
358 } 422 }
  423 + } catch (Exception e) {
  424 + logger.error("", e);
359 } 425 }
360 return rs; 426 return rs;
361 } 427 }
362 428
363 /** 429 /**
364 * 当班调度员 430 * 当班调度员
  431 + *
365 * @param list 432 * @param list
366 * @param des 433 * @param des
367 * @return 434 * @return
368 */ 435 */
369 public static String calcDDY(List<ScheduleRealInfo> list, List<DutyEmployee> des) { 436 public static String calcDDY(List<ScheduleRealInfo> list, List<DutyEmployee> des) {
370 String rs = ""; 437 String rs = "";
371 - 438 + try {
372 /*Collections.sort(list, new Comparator<ScheduleRealInfo>() { 439 /*Collections.sort(list, new Comparator<ScheduleRealInfo>() {
373 @Override 440 @Override
374 public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { 441 public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
@@ -377,22 +444,24 @@ public class ScheduleCalculator { @@ -377,22 +444,24 @@ public class ScheduleCalculator {
377 }); 444 });
378 445
379 long et = list.get(list.size() - 1).getDfsjT();*/ 446 long et = list.get(list.size() - 1).getDfsjT();*/
380 - String lineCode = list.get(0).getXlBm() + ","; 447 + String lineCode = list.get(0).getXlBm() + ",";
381 448
382 - Map<String, Integer> desMap = new HashMap<>();  
383 - for(DutyEmployee dEmp : des){  
384 - //if( dEmp.getTs() < et && dEmp.getCodeIdx().indexOf(lineCode) != -1)  
385 - if(dEmp.getCodeIdx().indexOf(lineCode) != -1 && dEmp.isMain())  
386 - desMap.put(dEmp.getuName(), 1);  
387 - } 449 + Map<String, Integer> desMap = new HashMap<>();
  450 + for (DutyEmployee dEmp : des) {
  451 + //if( dEmp.getTs() < et && dEmp.getCodeIdx().indexOf(lineCode) != -1)
  452 + if (dEmp.getCodeIdx().indexOf(lineCode) != -1 && dEmp.isMain())
  453 + desMap.put(dEmp.getuName(), 1);
  454 + }
388 455
389 - List<String> keys = new ArrayList<>(desMap.keySet());  
390 - int size = keys.size() > 3? 3 :keys.size(); 456 + List<String> keys = new ArrayList<>(desMap.keySet());
  457 + int size = keys.size() > 3 ? 3 : keys.size();
391 458
392 - for(int i = 0; i < size; i ++){  
393 - rs += (keys.get(i) + ","); 459 + for (int i = 0; i < size; i++) {
  460 + rs += (keys.get(i) + ",");
  461 + }
  462 + } catch (Exception e) {
  463 + logger.error("", e);
394 } 464 }
395 -  
396 return rs; 465 return rs;
397 } 466 }
398 467
@@ -405,68 +474,74 @@ public class ScheduleCalculator { @@ -405,68 +474,74 @@ public class ScheduleCalculator {
405 public static double calcCJLC(List<ScheduleRealInfo> list) { 474 public static double calcCJLC(List<ScheduleRealInfo> list) {
406 475
407 double sum = 0; 476 double sum = 0;
408 - Set<ChildTaskPlan> cts;  
409 - for (ScheduleRealInfo sch : list) {  
410 - if (sch.isSflj())  
411 - continue;  
412 -  
413 - cts = sch.getcTasks();  
414 - //有子任务  
415 - if (cts != null && cts.size() > 0) {  
416 - for (ChildTaskPlan ct : cts) {  
417 - if (ct.isDestroy())  
418 - sum = Arith.add(sum, ct.getMileage()); 477 + try {
  478 + Set<ChildTaskPlan> cts;
  479 + for (ScheduleRealInfo sch : list) {
  480 + if (sch.isSflj())
  481 + continue;
  482 +
  483 + cts = sch.getcTasks();
  484 + //有子任务
  485 + if (cts != null && cts.size() > 0) {
  486 + for (ChildTaskPlan ct : cts) {
  487 + if (ct.isDestroy())
  488 + sum = Arith.add(sum, ct.getMileage());
  489 + }
  490 + } else if (isInOut(sch))
  491 + continue;
  492 + else if (sch.getStatus() == -1) {
  493 + sum = Arith.add(sum, sch.getJhlcOrig());
  494 + } else if (sch.getJhlc() < sch.getJhlcOrig()) {
  495 + sum = Arith.add(sum, (Arith.sub(sch.getJhlcOrig(), sch.getJhlc())));
419 } 496 }
420 } 497 }
421 - else if(isInOut(sch))  
422 - continue;  
423 - else if (sch.getStatus() == -1) {  
424 - sum = Arith.add(sum, sch.getJhlcOrig());  
425 - } else if (sch.getJhlc() < sch.getJhlcOrig()) {  
426 - sum = Arith.add(sum, (Arith.sub(sch.getJhlcOrig(), sch.getJhlc())));  
427 - } 498 + } catch (Exception e) {
  499 + logger.error("", e);
428 } 500 }
429 -  
430 return sum; 501 return sum;
431 } 502 }
432 503
433 /** 504 /**
434 * 抽减原因 统计方式同上 505 * 抽减原因 统计方式同上
  506 + *
435 * @param list 507 * @param list
436 * @return 508 * @return
437 */ 509 */
438 - public static String joinCJYY(List<ScheduleRealInfo> list){ 510 + public static String joinCJYY(List<ScheduleRealInfo> list) {
439 Set<String> sets = new HashSet<>(); 511 Set<String> sets = new HashSet<>();
440 Set<ChildTaskPlan> cts; 512 Set<ChildTaskPlan> cts;
441 - for (ScheduleRealInfo sch : list) {  
442 - if (sch.isSflj())  
443 - continue;  
444 -  
445 - cts = sch.getcTasks();  
446 - //有子任务  
447 - if (cts != null && cts.size() > 0) {  
448 - for (ChildTaskPlan ct : cts) {  
449 - if (ct.isDestroy())  
450 - sets.add(ct.getDestroyReason()); 513 + try {
  514 + for (ScheduleRealInfo sch : list) {
  515 + if (sch.isSflj())
  516 + continue;
  517 +
  518 + cts = sch.getcTasks();
  519 + //有子任务
  520 + if (cts != null && cts.size() > 0) {
  521 + for (ChildTaskPlan ct : cts) {
  522 + if (ct.isDestroy())
  523 + sets.add(ct.getDestroyReason());
  524 + }
  525 + } else if (isInOut(sch))
  526 + continue;
  527 + else if (sch.getStatus() == -1) {
  528 + sets.add(sch.getAdjustExps());
  529 + } else if (sch.getJhlc() < sch.getJhlcOrig()) {
  530 + sets.add(sch.getAdjustExps());
451 } 531 }
452 } 532 }
453 - else if(isInOut(sch))  
454 - continue;  
455 - else if (sch.getStatus() == -1) {  
456 - sets.add(sch.getAdjustExps());  
457 - } else if (sch.getJhlc() < sch.getJhlcOrig()) {  
458 - sets.add(sch.getAdjustExps());  
459 - } 533 + } catch (Exception e) {
  534 + logger.error("", e);
460 } 535 }
461 536
462 - try{  
463 - if(sets.size() == 1) 537 + try {
  538 + if (sets.size() == 1)
464 return sets.iterator().next(); 539 return sets.iterator().next();
465 - else if(sets.size() > 1) 540 + else if (sets.size() > 1)
466 return Joiner.on(",").join(sets); 541 return Joiner.on(",").join(sets);
467 else 542 else
468 return ""; 543 return "";
469 - }catch (NullPointerException e){ 544 + } catch (NullPointerException e) {
470 return ""; 545 return "";
471 } 546 }
472 } 547 }
@@ -475,6 +550,7 @@ public class ScheduleCalculator { @@ -475,6 +550,7 @@ public class ScheduleCalculator {
475 * 根据原因统计抽减公里,不包括临加班次,不包括进出场 550 * 根据原因统计抽减公里,不包括临加班次,不包括进出场
476 * 没有原因,算其他 551 * 没有原因,算其他
477 * 无子任务 ,直接修改的公里,也算其他 552 * 无子任务 ,直接修改的公里,也算其他
  553 + *
478 * @param list 554 * @param list
479 * @param item 555 * @param item
480 * @return 556 * @return
@@ -482,56 +558,64 @@ public class ScheduleCalculator { @@ -482,56 +558,64 @@ public class ScheduleCalculator {
482 public static double calcCJLC2(List<ScheduleRealInfo> list, String item) { 558 public static double calcCJLC2(List<ScheduleRealInfo> list, String item) {
483 double sum = 0; 559 double sum = 0;
484 560
485 - Set<ChildTaskPlan> cts;  
486 - for(ScheduleRealInfo sch : list){  
487 - if (sch.isSflj())  
488 - continue;  
489 -  
490 - cts = sch.getcTasks();  
491 - //有子任务  
492 - if (cts != null && cts.size() > 0) {  
493 - for(ChildTaskPlan c : cts){  
494 - if(c.isDestroy() && c.getDestroyReason().equals(item))  
495 - sum = Arith.add(sum, c.getMileage());  
496 - }  
497 - }  
498 - else if(isInOut(sch))  
499 - continue;  
500 - //主任务烂班  
501 - else if(sch.getStatus() == -1){  
502 - if(sch.getAdjustExps().equals(item) ||  
503 - (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){  
504 - sum = Arith.add(sum, sch.getJhlcOrig());  
505 - }  
506 - }  
507 - else if(item.equals("其他")){  
508 - double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());  
509 - if(diff > 0){  
510 - sum = Arith.add(sum, diff); 561 + try {
  562 + Set<ChildTaskPlan> cts;
  563 + for (ScheduleRealInfo sch : list) {
  564 + if (sch.isSflj())
  565 + continue;
  566 +
  567 + cts = sch.getcTasks();
  568 + //有子任务
  569 + if (cts != null && cts.size() > 0) {
  570 + for (ChildTaskPlan c : cts) {
  571 + if (c.isDestroy() && c.getDestroyReason().equals(item))
  572 + sum = Arith.add(sum, c.getMileage());
  573 + }
  574 + } else if (isInOut(sch))
  575 + continue;
  576 + //主任务烂班
  577 + else if (sch.getStatus() == -1) {
  578 + if (sch.getAdjustExps().equals(item) ||
  579 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))) {
  580 + sum = Arith.add(sum, sch.getJhlcOrig());
  581 + }
  582 + } else if (item.equals("其他")) {
  583 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  584 + if (diff > 0) {
  585 + sum = Arith.add(sum, diff);
  586 + }
511 } 587 }
512 } 588 }
  589 + } catch (Exception e) {
  590 + logger.error("", e);
513 } 591 }
514 return sum; 592 return sum;
515 } 593 }
516 594
517 /** 595 /**
518 * 统计空放班次 596 * 统计空放班次
  597 + *
519 * @param list 598 * @param list
520 * @return 599 * @return
521 */ 600 */
522 public static int countEmpty(List<ScheduleRealInfo> list) { 601 public static int countEmpty(List<ScheduleRealInfo> list) {
523 int count = 0; 602 int count = 0;
524 603
525 - for(ScheduleRealInfo sch : list){  
526 - if((sch.getBcType().equals("venting") || sch.getBcType().equals("major")) &&  
527 - sch.getStatus() != -1)  
528 - count ++; 604 + try {
  605 + for (ScheduleRealInfo sch : list) {
  606 + if ((sch.getBcType().equals("venting") || sch.getBcType().equals("major")) &&
  607 + sch.getStatus() != -1)
  608 + count++;
  609 + }
  610 + } catch (Exception e) {
  611 + logger.error("", e);
529 } 612 }
530 return count; 613 return count;
531 } 614 }
532 615
533 /** 616 /**
534 * 统计大间隔班次 30 分钟算大间隔 617 * 统计大间隔班次 30 分钟算大间隔
  618 + *
535 * @param list 619 * @param list
536 * @return 620 * @return
537 */ 621 */
@@ -541,25 +625,30 @@ public class ScheduleCalculator { @@ -541,25 +625,30 @@ public class ScheduleCalculator {
541 int count = 0; 625 int count = 0;
542 int maxSpace = 1000 * 60 * 30; 626 int maxSpace = 1000 * 60 * 30;
543 int space; 627 int space;
544 - Set<String> ks = listMap.keySet();  
545 - List<ScheduleRealInfo> subList;  
546 - for(String k : ks){  
547 - subList = listMap.get(k);  
548 -  
549 - //排序  
550 - Collections.sort(subList, new SceduleComp());  
551 -  
552 - for(int i = 0; i < subList.size() - 1; i ++){  
553 - space = calcSpace(subList.get(i), subList.get(i + 1));  
554 - if(space >= maxSpace)  
555 - count ++; 628 + try {
  629 + Set<String> ks = listMap.keySet();
  630 + List<ScheduleRealInfo> subList;
  631 + for (String k : ks) {
  632 + subList = listMap.get(k);
  633 +
  634 + //排序
  635 + Collections.sort(subList, new SceduleComp());
  636 +
  637 + for (int i = 0; i < subList.size() - 1; i++) {
  638 + space = calcSpace(subList.get(i), subList.get(i + 1));
  639 + if (space >= maxSpace)
  640 + count++;
  641 + }
556 } 642 }
  643 + } catch (Exception e) {
  644 + logger.error("", e);
557 } 645 }
558 return count; 646 return count;
559 } 647 }
560 648
561 /** 649 /**
562 * 计算最大间隔 650 * 计算最大间隔
  651 + *
563 * @param list 652 * @param list
564 * @return 653 * @return
565 */ 654 */
@@ -568,27 +657,33 @@ public class ScheduleCalculator { @@ -568,27 +657,33 @@ public class ScheduleCalculator {
568 657
569 int space = 0; 658 int space = 0;
570 int maxSpace = 0; 659 int maxSpace = 0;
571 - Set<String> ks = listMap.keySet();  
572 - List<ScheduleRealInfo> subList;  
573 - for(String k : ks){  
574 - subList = listMap.get(k);  
575 -  
576 - //排序  
577 - Collections.sort(subList, new SceduleComp());  
578 -  
579 - for(int i = 0; i < subList.size() - 1; i ++){  
580 - space = calcSpace(subList.get(i), subList.get(i + 1));  
581 - if(space > maxSpace)  
582 - maxSpace = space; 660 + try {
  661 + Set<String> ks = listMap.keySet();
  662 + List<ScheduleRealInfo> subList;
  663 + for (String k : ks) {
  664 + subList = listMap.get(k);
  665 +
  666 + //排序
  667 + Collections.sort(subList, new SceduleComp());
  668 +
  669 + for (int i = 0; i < subList.size() - 1; i++) {
  670 + space = calcSpace(subList.get(i), subList.get(i + 1));
  671 + if (space > maxSpace)
  672 + maxSpace = space;
  673 + }
583 } 674 }
  675 + } catch (Exception e) {
  676 + logger.error("", e);
584 } 677 }
585 return maxSpace / 1000 / 60; 678 return maxSpace / 1000 / 60;
586 } 679 }
587 680
588 681
589 private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); 682 private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  683 +
590 /** 684 /**
591 * 计算班次间隔(毫秒) 685 * 计算班次间隔(毫秒)
  686 + *
592 * @param scheduleRealInfo 687 * @param scheduleRealInfo
593 * @param scheduleRealInfo1 688 * @param scheduleRealInfo1
594 * @return 689 * @return
@@ -601,23 +696,25 @@ public class ScheduleCalculator { @@ -601,23 +696,25 @@ public class ScheduleCalculator {
601 696
602 /** 697 /**
603 * 是否是进出场班次 698 * 是否是进出场班次
  699 + *
604 * @param sch 700 * @param sch
605 * @return 701 * @return
606 */ 702 */
607 - private static boolean isInOut(ScheduleRealInfo sch){ 703 + private static boolean isInOut(ScheduleRealInfo sch) {
608 return sch.getBcType().equals("out") || sch.getBcType().equals("in"); 704 return sch.getBcType().equals("out") || sch.getBcType().equals("in");
609 } 705 }
610 706
611 /** 707 /**
612 * 是否是进出场子任务 708 * 是否是进出场子任务
  709 + *
613 * @param ct 710 * @param ct
614 * @return 711 * @return
615 */ 712 */
616 - private static boolean isInOut(ChildTaskPlan ct){ 713 + private static boolean isInOut(ChildTaskPlan ct) {
617 return ct.getType2().equals("2") || ct.getType2().equals("3"); 714 return ct.getType2().equals("2") || ct.getType2().equals("3");
618 } 715 }
619 716
620 - public static class SceduleComp implements Comparator<ScheduleRealInfo>{ 717 + public static class SceduleComp implements Comparator<ScheduleRealInfo> {
621 718
622 @Override 719 @Override
623 public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { 720 public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {