Commit 4591be1b84004b479164b36c321ef5db3f6e5df0

Authored by 徐烜
1 parent 4a9bde17

Update

src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
@@ -177,6 +177,15 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im @@ -177,6 +177,15 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im
177 session.insert(ttInfo_input); 177 session.insert(ttInfo_input);
178 } 178 }
179 179
  180 +
  181 + // 载入数据2
  182 + Iterator<ScheduleRule1Flat> scheduleRule1FlatIterator = strategy.getScheduleRule(schedulePlan.getXl().getId()).iterator();
  183 + while (scheduleRule1FlatIterator.hasNext()) {
  184 + ScheduleRule1Flat scheduleRule1Flat_temp = scheduleRule1FlatIterator.next();
  185 + ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat_temp);
  186 + session.insert(scheduleRule_input);
  187 + }
  188 +
180 // 执行rule 189 // 执行rule
181 session.fireAllRules(); 190 session.fireAllRules();
182 191
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
@@ -58,9 +58,9 @@ public class MyDroolsConfiguration { @@ -58,9 +58,9 @@ public class MyDroolsConfiguration {
58 kfs.write("src/main/resources/HelloWorld.drl", kieServices.getResources() 58 kfs.write("src/main/resources/HelloWorld.drl", kieServices.getResources()
59 .newInputStreamResource(this.getClass().getResourceAsStream( 59 .newInputStreamResource(this.getClass().getResourceAsStream(
60 "/rules/HelloWorld.drl"), "UTF-8")); 60 "/rules/HelloWorld.drl"), "UTF-8"));
61 - kfs.write("src/main/resources/shiftloop_fb.drl", kieServices.getResources() 61 + kfs.write("src/main/resources/shiftloop_fb_2.drl", kieServices.getResources()
62 .newInputStreamResource(this.getClass().getResourceAsStream( 62 .newInputStreamResource(this.getClass().getResourceAsStream(
63 - "/rules/shiftloop_fb.drl"), "UTF-8")); 63 + "/rules/shiftloop_fb_2.drl"), "UTF-8"));
64 kfs.write("src/main/resources/ttinfo.drl", kieServices.getResources() 64 kfs.write("src/main/resources/ttinfo.drl", kieServices.getResources()
65 .newInputStreamResource(this.getClass().getResourceAsStream( 65 .newInputStreamResource(this.getClass().getResourceAsStream(
66 "/rules/ttinfo.drl"), "UTF-8")); 66 "/rules/ttinfo.drl"), "UTF-8"));
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleRule_input.java
@@ -12,6 +12,9 @@ import java.util.List; @@ -12,6 +12,9 @@ import java.util.List;
12 * 排班规则_输入。 12 * 排班规则_输入。
13 */ 13 */
14 public class ScheduleRule_input { 14 public class ScheduleRule_input {
  15 + /** 线路Id */
  16 + private String xlId;
  17 +
15 /** 规则Id */ 18 /** 规则Id */
16 private String ruleId; 19 private String ruleId;
17 /** 规则启用日期 */ 20 /** 规则启用日期 */
@@ -36,6 +39,7 @@ public class ScheduleRule_input { @@ -36,6 +39,7 @@ public class ScheduleRule_input {
36 public ScheduleRule_input() {} 39 public ScheduleRule_input() {}
37 40
38 public ScheduleRule_input(ScheduleRule1Flat scheduleRule1Flat) { 41 public ScheduleRule_input(ScheduleRule1Flat scheduleRule1Flat) {
  42 + this.xlId = String.valueOf(scheduleRule1Flat.getXl().getId());
39 this.ruleId = String.valueOf(scheduleRule1Flat.getId()); 43 this.ruleId = String.valueOf(scheduleRule1Flat.getId());
40 this.qyrq = new DateTime(scheduleRule1Flat.getQyrq()); 44 this.qyrq = new DateTime(scheduleRule1Flat.getQyrq());
41 List<String> lpIds = Splitter.on(",").splitToList(scheduleRule1Flat.getLpIds()); 45 List<String> lpIds = Splitter.on(",").splitToList(scheduleRule1Flat.getLpIds());
@@ -135,4 +139,12 @@ public class ScheduleRule_input { @@ -135,4 +139,12 @@ public class ScheduleRule_input {
135 public void setWeekdays(List<Boolean> weekdays) { 139 public void setWeekdays(List<Boolean> weekdays) {
136 this.weekdays = weekdays; 140 this.weekdays = weekdays;
137 } 141 }
  142 +
  143 + public String getXlId() {
  144 + return xlId;
  145 + }
  146 +
  147 + public void setXlId(String xlId) {
  148 + this.xlId = xlId;
  149 + }
138 } 150 }
src/main/java/com/bsth/service/schedule/rules/ttinfo/MinRuleQyrqFunction.java 0 → 100644
  1 +package com.bsth.service.schedule.rules.ttinfo;
  2 +
  3 +import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
  4 +import org.joda.time.DateTime;
  5 +import org.kie.api.runtime.rule.AccumulateFunction;
  6 +
  7 +import java.io.*;
  8 +
  9 +/**
  10 + * 最小的规则启用日期。
  11 + */
  12 +public class MinRuleQyrqFunction implements AccumulateFunction {
  13 + @Override
  14 + public void writeExternal(ObjectOutput out) throws IOException {
  15 + }
  16 +
  17 + @Override
  18 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  19 +
  20 + }
  21 +
  22 + protected static class MinRuleQyrqData implements Externalizable {
  23 + public DateTime min;
  24 +
  25 + public MinRuleQyrqData() {}
  26 +
  27 + @Override
  28 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  29 + min = (DateTime) in.readObject();
  30 + }
  31 +
  32 + @Override
  33 + public void writeExternal(ObjectOutput out) throws IOException {
  34 + out.writeObject(min);
  35 + }
  36 + }
  37 +
  38 + @Override
  39 + public Serializable createContext() {
  40 + return new MinRuleQyrqData();
  41 + }
  42 +
  43 + @Override
  44 + public void init(Serializable context) throws Exception {
  45 + // TODO:
  46 + }
  47 +
  48 + @Override
  49 + public void accumulate(Serializable context, Object value) {
  50 + MinRuleQyrqData minRuleQyrqData = (MinRuleQyrqData) context;
  51 + ScheduleRule_input scheduleRule_input = (ScheduleRule_input) value;
  52 +
  53 + if (minRuleQyrqData.min == null) {
  54 + minRuleQyrqData.min = scheduleRule_input.getQyrq();
  55 + } else if (scheduleRule_input.getQyrq().isBefore(minRuleQyrqData.min)) {
  56 + minRuleQyrqData.min = scheduleRule_input.getQyrq();
  57 + }
  58 + }
  59 +
  60 + @Override
  61 + public boolean supportsReverse() {
  62 + return false;
  63 + }
  64 +
  65 + @Override
  66 + public void reverse(Serializable serializable, Object o) throws Exception {
  67 +
  68 + }
  69 +
  70 + @Override
  71 + public Class<?> getResultType() {
  72 + return DateTime.class;
  73 + }
  74 +
  75 + @Override
  76 + public Object getResult(Serializable context) throws Exception {
  77 + MinRuleQyrqData minRuleQyrqData = (MinRuleQyrqData) context;
  78 + return minRuleQyrqData.min;
  79 + }
  80 +}
  81 +
  82 +
  83 +
  84 +
  85 +
  86 +
  87 +
  88 +
  89 +
  90 +
  91 +
  92 +
  93 +
  94 +
  95 +
src/main/resources/rules/functions.drl
@@ -3,4 +3,5 @@ package com.bsth.service.schedule; @@ -3,4 +3,5 @@ package com.bsth.service.schedule;
3 import accumulate com.bsth.service.schedule.rules.ttinfo2.ErrorBcCountFunction ecount; 3 import accumulate com.bsth.service.schedule.rules.ttinfo2.ErrorBcCountFunction ecount;
4 import accumulate com.bsth.service.schedule.rules.shiftloop.GidsCountFunction gidscount; 4 import accumulate com.bsth.service.schedule.rules.shiftloop.GidsCountFunction gidscount;
5 import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime; 5 import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime;
6 -import accumulate com.bsth.service.schedule.rules.ttinfo.LpInfoResultsFunction lpinforesult;  
7 \ No newline at end of file 6 \ No newline at end of file
  7 +import accumulate com.bsth.service.schedule.rules.ttinfo.LpInfoResultsFunction lpinforesult;
  8 +import accumulate com.bsth.service.schedule.rules.ttinfo.MinRuleQyrqFunction minruleqyrq
8 \ No newline at end of file 9 \ No newline at end of file
src/main/resources/rules/shiftloop_fb_2.drl
@@ -71,7 +71,7 @@ rule &quot;calcu_days_1_&quot; @@ -71,7 +71,7 @@ rule &quot;calcu_days_1_&quot;
71 71
72 insert(cdrp); 72 insert(cdrp);
73 73
74 - log.info("总共需要排班的天数 sdays={} ruleId={}", (p2.getDays() + 1), $ruleId); 74 + log.info("总共需要排班的天数 sdays={} ruleId={} from={} to={}", (p2.getDays() + 1), $ruleId, $fromDate, $toDate);
75 75
76 end 76 end
77 77
@@ -103,12 +103,12 @@ rule &quot;calcu_days_2_&quot; @@ -103,12 +103,12 @@ rule &quot;calcu_days_2_&quot;
103 103
104 insert(cdrp); 104 insert(cdrp);
105 105
106 - log.info("总共需要排班的天数 sdays={} ruleId={}", (p2.getDays() + 1), $ruleId); 106 + log.info("总共需要排班的天数 sdays={} ruleId={} from={} to={}", (p2.getDays() + 1), $ruleId, $qyrq, $toDate);
107 107
108 end 108 end
109 109
110 //------------------------- 第二阶段、计算规则准备数据2(第一组循环) ----------------------------// 110 //------------------------- 第二阶段、计算规则准备数据2(第一组循环) ----------------------------//
111 -rule "Calcu_loop1_1_" // 时刻表的关联的路牌不存在,调整翻版规则 111 +rule "Calcu_loop1_1_" // 路牌在时刻表中存在,就翻
112 salience 900 112 salience 900
113 when 113 when
114 $cdrp: Calcu_days_result_pre( 114 $cdrp: Calcu_days_result_pre(
@@ -141,8 +141,8 @@ rule &quot;Calcu_loop1_1_&quot; // 时刻表的关联的路牌不存在,调整翻版规 @@ -141,8 +141,8 @@ rule &quot;Calcu_loop1_1_&quot; // 时刻表的关联的路牌不存在,调整翻版规
141 update($cdrp); 141 update($cdrp);
142 end 142 end
143 143
144 -rule "Calcu_loop1_2_" // 时刻表的关联路牌存在,就翻  
145 - salience 800 144 +rule "Calcu_loop1_2_" // 路牌在时刻表中不存在,就不翻
  145 + salience 900
146 when 146 when
147 $cdrp: Calcu_days_result_pre( 147 $cdrp: Calcu_days_result_pre(
148 calcu_start_date_1.isBefore(calcu_end_date_1), 148 calcu_start_date_1.isBefore(calcu_end_date_1),
@@ -163,292 +163,91 @@ rule &quot;Calcu_loop1_2_&quot; // 时刻表的关联路牌存在,就翻 @@ -163,292 +163,91 @@ rule &quot;Calcu_loop1_2_&quot; // 时刻表的关联路牌存在,就翻
163 update($cdrp); 163 update($cdrp);
164 end 164 end
165 165
  166 +//------------------------- 第三阶段、计算规则准备数据2(第二组循环) ----------------------------//
  167 +rule "Calcu_loop2_1_" // 路牌在时刻表中存在,就翻
  168 + salience 800
  169 + when
  170 + $cdrp: Calcu_days_result_pre(
  171 + calcu_start_date_1.isEqual(calcu_end_date_1),
  172 + calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),
  173 + $csd2: calcu_start_date_2,
  174 + $ced2: calcu_end_date_2,
  175 + $ruleId: ruleId,
  176 + $lpindex: calcu_index_lp,
  177 + $ryindex: calcu_index_ry
  178 + )
  179 + $sri: ScheduleRule_input(
  180 + ruleId == $ruleId,
  181 + $cid: carConfigId,
  182 + $gids: guideboardIds,
  183 + $eids: employeeConfigIds,
  184 + $lprangesize : guideboardIds.size(),
  185 + $ryrangesize: employeeConfigIds.size()
  186 + )
  187 + $liro: LpInfoResult_output(
  188 + dateTime.isEqual($csd2),
  189 + $gids.get($lpindex) == lpId,
  190 + $lpId: lpId
  191 + )
  192 + then
  193 + ScheduleResult_output ro = new ScheduleResult_output();
  194 + ro.setRuleId($ruleId);
  195 + ro.setSd($csd2);
  196 + ro.setGuideboardId(String.valueOf($gids.get($lpindex)));
  197 + ro.setEmployeeConfigId(String.valueOf($eids.get($ryindex)));
  198 + ro.setCarConfigId($cid);
  199 +
  200 + scheduleResult.getResults().add(ro);
  201 +
  202 + $cdrp.setCalcu_index_lp(($lpindex + 1) % $lprangesize);
  203 + $cdrp.setCalcu_index_ry(($ryindex + 1) % $ryrangesize);
  204 + $cdrp.setCalcu_start_date_2($csd2.plusDays(1));
  205 +
  206 + log.info("Calcu_loop2_1_ ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",
  207 + $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd2, $ced2);
  208 +
  209 + update($cdrp);
  210 +end
  211 +
  212 +rule "Calcu_loop2_2_" // 路牌在时刻表中不存在,就不翻
  213 + salience 800
  214 + when
  215 + $cdrp: Calcu_days_result_pre(
  216 + calcu_start_date_1.isEqual(calcu_end_date_1),
  217 + calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),
  218 + $csd2: calcu_start_date_2,
  219 + $ced2: calcu_end_date_2,
  220 + $ruleId: ruleId,
  221 + $lpindex: calcu_index_lp,
  222 + $ryindex: calcu_index_ry
  223 + )
  224 + $sri: ScheduleRule_input(
  225 + ruleId == $ruleId,
  226 + $cid: carConfigId,
  227 + $gids: guideboardIds,
  228 + $eids: employeeConfigIds
  229 +
  230 + )
  231 + then
  232 + ScheduleResult_output ro = new ScheduleResult_output();
  233 + ro.setRuleId($ruleId);
  234 + ro.setSd($csd2);
  235 + ro.setGuideboardId(String.valueOf($gids.get($lpindex)));
  236 + ro.setEmployeeConfigId(String.valueOf($eids.get($ryindex)));
  237 + ro.setCarConfigId($cid);
  238 +
  239 + scheduleResult.getResults().add(ro);
  240 +
  241 + $cdrp.setCalcu_start_date_2($csd2.plusDays(1));
  242 +
  243 + log.info("Calcu_loop2_2_ ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",
  244 + $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd2, $ced2);
  245 +
  246 + update($cdrp);
  247 +end
  248 +
  249 +
  250 +
166 251
167 -//----------------------- 路牌范围循环计算 ------------------------//  
168 -  
169 -//declare Calcu_guideboard_index_result  
170 -// ruleId : String // 规则Id  
171 -// calcu_index : Integer // 计算之后的起始索引  
172 -//end  
173 -//  
174 -//// 启用日期等于开始日期  
175 -//rule "calcu_guideboard_index_qyrq_eq_startrq"  
176 -// when  
177 -// $calcu_days_result : Calcu_days_result(  
178 -// qyrq_days == 0,  
179 -// $ruleId: ruleId  
180 -// )  
181 -// $scheduleRule_input : ScheduleRule_input(  
182 -// ruleId == $ruleId,  
183 -// $oindex : startGbdIndex  
184 -// )  
185 -// then  
186 -// Calcu_guideboard_index_result cgir = new Calcu_guideboard_index_result();  
187 -// cgir.setRuleId($ruleId);  
188 -// cgir.setCalcu_index($oindex);  
189 -//  
190 -// log.info("calcu_guideboard_index_qyrq_eq_startrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());  
191 -//  
192 -// insert(cgir);  
193 -//end  
194 -//  
195 -//// 开始日期大于启用日期  
196 -//rule "calcu_guideboard_index_startrq_gt_qyrq"  
197 -// when  
198 -// $calcu_days_result : Calcu_days_result(  
199 -// qyrq_days > 0,  
200 -// $ruleId: ruleId, $qyrq_days: qyrq_days,  
201 -// $calcu_start_date: calcu_start_date  
202 -// )  
203 -// $scheduleRule_input : ScheduleRule_input(  
204 -// ruleId == $ruleId,  
205 -// $qyrq: qyrq,  
206 -// $rangesize : guideboardIds.size(),  
207 -// $oindex : startGbdIndex,  
208 -// $weekdays: weekdays  
209 -// )  
210 -// then  
211 -// // 开始时间  
212 -// DateTime initDate = $qyrq;  
213 -// int index = $oindex;  
214 -// int resultIndex = index;  
215 -//  
216 -// while (!initDate.isAfter($calcu_start_date)) {  
217 -// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {  
218 -// resultIndex = index;  
219 -// index = (index + 1) % $rangesize;  
220 -// }  
221 -// initDate = initDate.plusDays(1);  
222 -// }  
223 -//  
224 -// Calcu_guideboard_index_result cgir = new Calcu_guideboard_index_result();  
225 -// cgir.setRuleId($ruleId);  
226 -// cgir.setCalcu_index(resultIndex);  
227 -//  
228 -// log.info("calcu_guideboard_index_startrq_gt_qyrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());  
229 -//  
230 -// insert(cgir);  
231 -//end  
232 -//  
233 -////----------------------- 人员范围循环计算 ------------------------//  
234 -//  
235 -//declare Calcu_employee_index_result  
236 -// ruleId : String // 规则Id  
237 -// calcu_index : Integer // 计算之后的起始索引  
238 -//end  
239 -//  
240 -//// 启用日期等于开始日期  
241 -//rule "calcu_employee_index_qyrq_eq_startrq"  
242 -// when  
243 -// $calcu_days_result : Calcu_days_result(  
244 -// qyrq_days == 0,  
245 -// $ruleId: ruleId)  
246 -// $scheduleRule_input : ScheduleRule_input(  
247 -// ruleId == $ruleId,  
248 -// $oindex : startEIndex)  
249 -// then  
250 -// Calcu_employee_index_result cgir = new Calcu_employee_index_result();  
251 -// cgir.setRuleId($ruleId);  
252 -// cgir.setCalcu_index($oindex);  
253 -//  
254 -// log.info("calcu_employee_index_qyrq_eq_startrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());  
255 -//  
256 -// insert(cgir);  
257 -//end  
258 -//  
259 -//// 开始日期大于启用日期  
260 -//rule "calcu_employee_index_startrq_gt_qyrq"  
261 -// when  
262 -// $calcu_days_result : Calcu_days_result(  
263 -// qyrq_days > 0,  
264 -// $ruleId: ruleId, $qyrq_days: qyrq_days,  
265 -// $calcu_start_date: calcu_start_date  
266 -// )  
267 -// $scheduleRule_input : ScheduleRule_input(  
268 -// ruleId == $ruleId,  
269 -// $qyrq: qyrq,  
270 -// $rangesize : employeeConfigIds.size(),  
271 -// $oindex : startEIndex,  
272 -// $weekdays: weekdays  
273 -// )  
274 -// then  
275 -// // 开始时间  
276 -// DateTime initDate = $qyrq;  
277 -// int index = $oindex;  
278 -// int resultIndex = index;  
279 -//  
280 -// while (!initDate.isAfter($calcu_start_date)) {  
281 -// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {  
282 -// resultIndex = index;  
283 -// index = (index + 1) % $rangesize;  
284 -// }  
285 -// initDate = initDate.plusDays(1);  
286 -// }  
287 -//  
288 -// Calcu_employee_index_result cgir = new Calcu_employee_index_result();  
289 -// cgir.setRuleId($ruleId);  
290 -// cgir.setCalcu_index(resultIndex);  
291 -//  
292 -// log.info("calcu_employee_index_startrq_gt_qyrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());  
293 -//  
294 -// insert(cgir);  
295 -//  
296 -//end  
297 -//  
298 -////------------------------- 第三阶段、循环计算 ------------------------//  
299 -//  
300 -////----------------------- 路牌范围循环计算 ------------------------//  
301 -//declare loop_guideboard_result  
302 -// ruleId : String // 规则id  
303 -// go_list : List // 路牌循环的列表  
304 -//end  
305 -//  
306 -//// 循环路牌计算  
307 -//rule "Calcu_loop_guideboard_result"  
308 -// when  
309 -// Calcu_days_result(  
310 -// $ruleId: ruleId,  
311 -// $startDate : calcu_start_date,  
312 -// $calcu_end_date: calcu_end_date  
313 -// )  
314 -// $ruleData : ScheduleRule_input(  
315 -// ruleId == $ruleId,  
316 -// $rangesize : guideboardIds.size(),  
317 -// $weekdays: weekdays  
318 -// )  
319 -// $indexData : Calcu_guideboard_index_result(  
320 -// ruleId == $ruleId  
321 -// )  
322 -// then  
323 -// DateTime initDate = $startDate; // 开始时间  
324 -// DateTime endDate = $calcu_end_date; // 结束实际  
325 -// List<ScheduleResult_output> scheduleResult_outputs =  
326 -// new ArrayList<ScheduleResult_output>();  
327 -//  
328 -// int i = $indexData.getCalcu_index();  
329 -// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue() == false) {  
330 -// i = (i + 1) % $rangesize;  
331 -// }  
332 -//  
333 -// while (!initDate.isAfter(endDate)) {  
334 -// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {  
335 -// ScheduleResult_output ro = new ScheduleResult_output();  
336 -// ro.setRuleId($ruleId);  
337 -// ro.setSd(initDate);  
338 -// ro.setGuideboardId($ruleData.getGuideboardIds().get(i));  
339 -// ro.setCarConfigId($ruleData.getCarConfigId());  
340 -// scheduleResult_outputs.add(ro);  
341 -//  
342 -// i = (i + 1) % $rangesize;  
343 -// }  
344 -//  
345 -// initDate = initDate.plusDays(1);  
346 -// }  
347 -//  
348 -// loop_guideboard_result clgr = new loop_guideboard_result();  
349 -// clgr.setRuleId($ruleId);  
350 -// clgr.setGo_list(scheduleResult_outputs);  
351 -//  
352 -// log.info(String.valueOf(scheduleResult_outputs.size()));  
353 -//  
354 -// insert(clgr);  
355 -//  
356 -//end  
357 -//  
358 -////----------------------- 人员范围循环计算 ------------------------//  
359 -//declare loop_employee_result  
360 -// ruleId : String // 规则id  
361 -// eo_list : List // 人员循环的列表  
362 -//end  
363 -//  
364 -//// 循环人员计算  
365 -//rule "Calcu_loop_employee_result"  
366 -// when  
367 -// Calcu_days_result(  
368 -// $ruleId: ruleId,  
369 -// $startDate : calcu_start_date,  
370 -// $calcu_end_date: calcu_end_date  
371 -// )  
372 -// $ruleData : ScheduleRule_input(  
373 -// ruleId == $ruleId,  
374 -// $rangesize : employeeConfigIds.size(),  
375 -// $weekdays: weekdays  
376 -// )  
377 -// $indexData : Calcu_employee_index_result(  
378 -// ruleId == $ruleId  
379 -// )  
380 -// then  
381 -// DateTime initDate = $startDate; // 开始时间  
382 -// DateTime endDate = $calcu_end_date; // 结束实际  
383 -// List<ScheduleResult_output> scheduleResult_outputs =  
384 -// new ArrayList<ScheduleResult_output>();  
385 -//  
386 -// int i = $indexData.getCalcu_index();  
387 -// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue() == false) {  
388 -// i = (i + 1) % $rangesize;  
389 -// }  
390 -//  
391 -// while (!initDate.isAfter(endDate)) {  
392 -// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {  
393 -// ScheduleResult_output ro = new ScheduleResult_output();  
394 -// ro.setRuleId($ruleId);  
395 -// ro.setSd(initDate);  
396 -// ro.setEmployeeConfigId($ruleData.getEmployeeConfigIds().get(i));  
397 -// ro.setCarConfigId($ruleData.getCarConfigId());  
398 -// scheduleResult_outputs.add(ro);  
399 -//  
400 -// i = (i + 1) % $rangesize;  
401 -// }  
402 -//  
403 -// initDate = initDate.plusDays(1);  
404 -// }  
405 -//  
406 -// loop_employee_result clgr = new loop_employee_result();  
407 -// clgr.setRuleId($ruleId);  
408 -// clgr.setEo_list(scheduleResult_outputs);  
409 -//  
410 -// log.info(String.valueOf(scheduleResult_outputs.size()));  
411 -//  
412 -// insert(clgr);  
413 -//end  
414 -//  
415 -////------------------------- 第四阶段、范围组循环计算 ----------------------------//  
416 -//  
417 -//global ScheduleResults_output scheduleResult;  
418 -//  
419 -//rule "output"  
420 -// when  
421 -// loop_guideboard_result(  
422 -// go_list.size() > 0,  
423 -// $ruleId : ruleId, $go_list : go_list  
424 -// )  
425 -// loop_employee_result(  
426 -// ruleId == $ruleId,  
427 -// eo_list.size() == $go_list.size(),  
428 -// $eo_list : eo_list  
429 -// )  
430 -// then  
431 -// for (int i = 0; i < $go_list.size(); i++) {  
432 -// ScheduleResult_output go = (ScheduleResult_output) $go_list.get(i);  
433 -// ScheduleResult_output eo = (ScheduleResult_output) $eo_list.get(i);  
434 -// go.setEmployeeConfigId(eo.getEmployeeConfigId());  
435 -// scheduleResult.getResults().add(go);  
436 -// }  
437 -//  
438 -//end  
439 -//  
440 -//  
441 -//  
442 -//  
443 -//  
444 -//  
445 -//  
446 -//  
447 -//  
448 -//  
449 -//  
450 -//  
451 -//  
452 -//  
453 252
454 253
src/main/resources/rules/ttinfo.drl
@@ -10,6 +10,8 @@ import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; @@ -10,6 +10,8 @@ import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output;
10 import com.bsth.service.schedule.rules.ttinfo.LpInfoResult_output; 10 import com.bsth.service.schedule.rules.ttinfo.LpInfoResult_output;
11 import com.bsth.service.schedule.rules.ttinfo.LpInfoResults_output; 11 import com.bsth.service.schedule.rules.ttinfo.LpInfoResults_output;
12 12
  13 +import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
  14 +
13 import com.bsth.service.schedule.TTInfoDetailService; 15 import com.bsth.service.schedule.TTInfoDetailService;
14 16
15 import com.bsth.entity.schedule.TTInfo; 17 import com.bsth.entity.schedule.TTInfo;
@@ -38,7 +40,18 @@ function Map ttidParams(List ttinfolist) { @@ -38,7 +40,18 @@ function Map ttidParams(List ttinfolist) {
38 TODO:规则说明,以后待说明 40 TODO:规则说明,以后待说明
39 */ 41 */
40 42
41 -// TODO: 43 +//----------------- pre 预处理 param对象 -----------------------//
  44 +
  45 +rule "pre_calcu_TTInfoCalcuParam_input"
  46 + no-loop
  47 + salience 1000
  48 + when
  49 + $ttp: TTInfoCalcuParam_input($xlId : xlId)
  50 + $minqyrq: DateTime() from accumulate ($sri: ScheduleRule_input(xlId == $xlId), minruleqyrq($sri))
  51 + then
  52 + $ttp.setFromDate($minqyrq);
  53 + update($ttp);
  54 +end
42 55
43 //----------------- 第一阶段、计算规则准备数据(天数)----------------// 56 //----------------- 第一阶段、计算规则准备数据(天数)----------------//
44 57