kBase2_wrap_rule.drl
4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package com.bsth.service.schedule.impl.plan.kBase2.wrap.rule;
import org.joda.time.*;
import java.util.*;
import org.slf4j.Logger;
import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleCalcuParam_input;
import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;
import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;
import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;
import com.bsth.repository.schedule.RerunRuleRepository;
import com.bsth.repository.schedule.ScheduleRule1FlatRepository;
import com.bsth.service.schedule.impl.plan.ScheduleRuleService;
import com.bsth.entity.Line;
import com.bsth.entity.schedule.CarConfigInfo
import com.bsth.entity.schedule.EmployeeConfigInfo
import javax.print.attribute.standard.DateTimeAtCompleted;
// 全局日志类(一般使用调用此规则的service类)
global Logger log;
global ScheduleRule1FlatRepository srf;
global RerunRuleRepository rrr;
global ScheduleRuleService srservice;
global List sriList;
declare Sri_Wrap
xlId : String // 线路id
lpIds : List // 路牌id
srf : Object // ScheduleRule1Flat类型
sri : ScheduleRule_input; // ScheduleRule_input输入
end
rule "rw1"
salience 1000
when
ScheduleCalcuParam_input(
$fromDate : fromDate,
$toDate : toDate,
$xlId: xlId
)
$srf : Object() from srf.findByXlId(Integer.parseInt($xlId))
then
// 创建Sri_Wrap
Sri_Wrap sw = new Sri_Wrap();
sw.setXlId($xlId);
sw.setSrf($srf);
ScheduleRule_input sri = new ScheduleRule_input((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf());
sw.setSri(sri);
sw.setLpIds(sri.getGuideboardIds());
insert(sw);
end
rule "rw2"
salience 800
no-loop
when
ScheduleCalcuParam_input(
$fromDate : fromDate,
$toDate : toDate,
$xlId: xlId
)
$reu : RerunRule_input($lpId : lp) from srservice.findRerunrule(Integer.parseInt($xlId))
not Sri_Wrap(xlId == $xlId, lpIds contains $lpId)
then
// 套跑中有规则,主线路的路牌,主线路该路牌不存在,添加一个临时的,做处理
Sri_Wrap sw = new Sri_Wrap();
sw.setSrf(new com.bsth.entity.schedule.rule.ScheduleRule1Flat());
// 线路
Line xl = new Line();
xl.setId(Integer.valueOf($xlId));
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setXl(xl);
// id,使用当前日期作为原始值加上路牌id最为临时id值
DateTime dt = new DateTime(new Date());
DateTime dt2 = new DateTime(dt.year().get(), dt.monthOfYear().get(), dt.dayOfMonth().get(), 0, 0, 0);
long id = (dt2.toDate().getTime() + Long.parseLong($lpId));
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setId(id);
// 启用日期
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setQyrq($fromDate.toDate());
// 车辆配置
CarConfigInfo cci = new CarConfigInfo();
cci.setId(new Date().getTime());
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setCarConfigInfo(cci);
// 人员配置
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyConfigIds("TEMP");
// 人员搭班编码
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyDbbms("TEMP");
// 起始人员
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyStart(1);
// 路牌id
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setLpIds($lpId);
// 起始路牌
((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setLpStart(1);
ScheduleRule_input sri = new ScheduleRule_input((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf());
sri.setsType(ScheduleRule_Type.RERUN);
sw.setSri(sri);
sw.setXlId($xlId);
List lpIds = new ArrayList();
lpIds.add($lpId);
sw.setLpIds(lpIds);
insert(sw);
end
rule "rw3"
salience 600
when
$sri_wrap : Sri_Wrap($sri : sri, $xlId: xlId, $lpIds : lpIds)
then
log.info("线路id={},type={},ruleId={},lpids={}", $xlId, $sri.getsType(), $sri.getRuleId(), $lpIds);
sriList.add($sri);
end