rerun.drl
5.81 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package com.bsth.service.schedule.rerun;
import org.joda.time.*;
import java.util.*;
import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
import com.bsth.service.schedule.rules.rerun.RerunRule_input;
import com.bsth.service.schedule.rules.rerun.RerunRule_param;
import com.bsth.repository.schedule.CarConfigInfoRepository;
import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
import org.slf4j.Logger
import com.bsth.entity.schedule.CarConfigInfo
import java.util.HashMap
import com.bsth.entity.schedule.EmployeeConfigInfo
import com.bsth.entity.schedule.SchedulePlanInfo;
// 全局日志类(一般使用调用此规则的service类)
global Logger log;
global CarConfigInfoRepository carConfigInfoRepository;
global EmployeeConfigInfoRepository employeeConfigInfoRepository;
// 输出
/*
规则说明:
1、对应路牌规则:将对应路牌的车辆,人员替换指定的套跑班次已有的配置
2、对应班车规则:直接使用指定的人员,车辆替换指定的套跑班次已有的配置
*/
//-------------------- 第一阶段、计算对应路牌套跑的车辆配置,人员配置数据 -----------------//
//--------------- 车辆配置信息载入 -------------//
declare Dylp_CarConfig_Wraps
xlId: String // 线路Id
ccMap: Map // 车辆配置Map Map<id, CarConfigInfo>
end
rule "calcu_Dylp_CarConfig_Wraps"
salience 1000
when
$rp: RerunRule_param($xlId: mxlid)
$dylpxlid: String() from $rp.getXlIds_dylp()
then
List carConfigInfos = carConfigInfoRepository.findByXlId(Integer.parseInt($dylpxlid));
Dylp_CarConfig_Wraps carConfig_wraps = new Dylp_CarConfig_Wraps();
carConfig_wraps.setXlId($dylpxlid);
carConfig_wraps.setCcMap(new HashMap());
for (int i = 0; i < carConfigInfos.size(); i++) {
CarConfigInfo carConfigInfo = (CarConfigInfo) carConfigInfos.get(i);
carConfig_wraps.getCcMap().put(carConfigInfo.getId().toString(), carConfigInfo);
}
insert(carConfig_wraps);
log.info("calcu_Dylp_CarConfig_Wraps");
end
//--------------- 人员配置信息载入 --------------//
declare Dylp_EmployeeConfig_Wraps
xlId: String // 线路Id
ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>
end
rule "calcu_Dylp_EmployeeConfig_Wraps"
salience 1000
when
$rp: RerunRule_param($xlId: mxlid)
$dylpxlid: String() from $rp.getXlIds_dylp()
then
List employeeConfigInfos = employeeConfigInfoRepository.findByXlId(Integer.parseInt($dylpxlid));
Dylp_EmployeeConfig_Wraps employeeConfig_wraps = new Dylp_EmployeeConfig_Wraps();
employeeConfig_wraps.setXlId($dylpxlid);
employeeConfig_wraps.setEcMap(new HashMap());
for (int i = 0; i < employeeConfigInfos.size(); i++) {
EmployeeConfigInfo employeeConfigInfo = (EmployeeConfigInfo) employeeConfigInfos.get(i);
employeeConfig_wraps.getEcMap().put(employeeConfigInfo.getId().toString(), employeeConfigInfo);
}
insert(employeeConfig_wraps);
log.info("calcu_Dylp_EmployeeConfig_Wraps");
end
//-------------------- 第二阶段、包装对应路牌的循环规则输出 -----------------//
declare Dylp_ScheduleResult_output_wrap
xlId: String // 线路
sd: DateTime // 日期
lp: String // 路牌
cc: CarConfigInfo // 使用的车辆配置
ec: List // 使用的人员配置 List<EmployeeConfigInfo>
end
rule "calcu_Dylp_ScheduleResult_output_wrap"
salience 900
when
$sro: ScheduleResults_output($xlId: xlid)
$sr: ScheduleResult_output() from $sro.getResults()
Dylp_CarConfig_Wraps(xlId == $xlId, $ccmap: ccMap)
Dylp_EmployeeConfig_Wraps(xlId == $xlId, $ecmap: ecMap)
then
Dylp_ScheduleResult_output_wrap wrap = new Dylp_ScheduleResult_output_wrap();
wrap.setXlId($xlId);
wrap.setSd($sr.getSd());
wrap.setLp($sr.getGuideboardId());
wrap.setCc((CarConfigInfo) $ccmap.get($sr.getCarConfigId()));
List ecs = new ArrayList();
String[] ecids = $sr.getEmployeeConfigId().split("-"); // 分班的人
for (int i = 0; i < ecids.length; i++) {
ecs.add($ecmap.get(ecids[i]));
}
wrap.setEc(ecs);
// log.info("xlid = {}", $xlId);
insert(wrap);
end
//-------------------- 第三阶段、套跑线路,替换班次的车辆,人员 --------------------//
rule "calcu_Dylp_rerun_update_dylp"
salience 800
// no-loop
when
$spi: SchedulePlanInfo($xlid: xl, $sd: scheduleDate, $lp: lp, $fcsj: fcsj, $ttinfo: ttInfo)
$ri: RerunRule_input(
type == "dylp",
xl == $xlid.toString(),
ttinfo == $ttinfo.toString(),
lp == $lp.toString(),
fcsj == $fcsj,
$sxl: s_xl, $slp: s_lp, $type: usetype, $hrtype: userhrtype
)
$dsro: Dylp_ScheduleResult_output_wrap(
xlId == $sxl,
lp == $slp,
sd.getMillis() == $sd.getTime()
)
then
// log.info("TODO:测试 {}", $fcsj);
$spi.setRerunInfoDylp($dsro.getCc(), $dsro.getEc(), $type, $hrtype);
end
rule "calcu_Dylp_rerun_update_dybc"
salience 700
when
$spi: SchedulePlanInfo($xlid: xl, $sd: scheduleDate, $lp: lp, $fcsj: fcsj, $ttinfo: ttInfo)
$ri: RerunRule_input(
type == "dybc",
xl == $xlid.toString(),
ttinfo == $ttinfo.toString(),
lp == $lp.toString(),
fcsj == $fcsj
)
then
$spi.setRerunInfoDybc($ri);
end