Commit fda49142b63bc83a999e7ef3b2f8e3d8551547e3

Authored by 潘钊
2 parents 7c055cbf 9833366b

Merge branch 'qingpu' of http://222.66.0.204:8800/panzhaov5/bsth_control

into qingpu

冲突解决....重点标记,有问题看这次的提交

# Conflicts:
#	src/main/java/com/bsth/service/schedule/rules/ttinfo/TTInfo_input.java
#	src/main/resources/static/pages/scheduleApp/module/common/dt/MyGuideboardGroupWrapTemplate.html
#	src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
#	src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
#	src/main/resources/static/pages/scheduleApp/module/common/prj-common-ui-route-state.js
src/main/java/com/bsth/service/schedule/rules/strategy/IStrategyImpl.java
1   -package com.bsth.service.schedule.rules.strategy;
2   -
3   -import com.bsth.entity.Line;
4   -import com.bsth.entity.schedule.CarConfigInfo;
5   -import com.bsth.entity.schedule.EmployeeConfigInfo;
6   -import com.bsth.entity.schedule.TTInfo;
7   -import com.bsth.entity.schedule.TTInfoDetail;
8   -import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
9   -import com.bsth.service.LineService;
10   -import com.bsth.service.schedule.*;
11   -import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input;
12   -import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output;
13   -import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output;
14   -import com.bsth.service.schedule.rules.ttinfo.TTInfo_input;
15   -import com.google.common.collect.ArrayListMultimap;
16   -import com.google.common.collect.Multimap;
17   -import org.joda.time.DateTime;
18   -import org.kie.api.KieBase;
19   -import org.kie.api.runtime.KieSession;
20   -import org.slf4j.Logger;
21   -import org.slf4j.LoggerFactory;
22   -import org.springframework.beans.factory.annotation.Autowired;
23   -import org.springframework.stereotype.Service;
24   -
25   -import java.util.*;
26   -
27   -/**
28   - * Created by xu on 16/7/10.
29   - */
30   -@Service
31   -public class IStrategyImpl implements IStrategy {
32   - @Autowired
33   - private TTInfoService ttInfoService;
34   - @Autowired
35   - private CarConfigInfoService carConfigInfoService;
36   - @Autowired
37   - private EmployeeConfigInfoService employeeConfigInfoService;
38   - @Autowired
39   - private TTInfoDetailService ttInfoDetailService;
40   - @Autowired
41   - private LineService lineService;
42   - @Autowired
43   - private ScheduleRule1FlatService scheduleRule1FlatService;
44   -
45   - /** 日志记录器 */
46   - private Logger logger = LoggerFactory.getLogger(IStrategyImpl.class);
47   -
48   - @Autowired
49   - private KieBase kieBase;
50   -
51   - @Override
52   - public Line getLine(Integer xlId) {
53   - Line xl = lineService.findById(xlId); // 查找线路具体信息
54   - return xl;
55   - }
56   -
57   - @Override
58   - public List<TTInfo> getTTInfo(Integer xlId) {
59   - // 查询参数
60   - Map<String, Object> param = new HashMap<>();
61   - param.put("xl.id_eq", xlId); // 线路Id
62   - param.put("isCancel_eq", false); // 作废的过滤掉
63   - Iterator<TTInfo> ttInfoIterator = ttInfoService.list(param).iterator();
64   - if (!ttInfoIterator.hasNext()) {
65   - throw new RuntimeException("线路id=" + xlId + " 没有时刻表!");
66   - }
67   - List<TTInfo> ttInfos = new ArrayList<>();
68   - while (ttInfoIterator.hasNext()) {
69   - TTInfo ttInfo = ttInfoIterator.next();
70   - ttInfos.add(ttInfo);
71   - }
72   - return ttInfos;
73   - }
74   -
75   - @Override
76   - public List<TTInfoDetail> getTTInfoDetail(Integer xlId) {
77   - List<TTInfoDetail> ttInfoDetails = new ArrayList<>();
78   -
79   - List<TTInfo> ttInfos = getTTInfo(xlId);
80   - Map<String, Object> param = new HashMap<>();
81   - for (TTInfo ttInfo : ttInfos) {
82   - param.clear();
83   - param.put("ttinfo.id_eq", ttInfo.getId());
84   - Iterator<TTInfoDetail> ttInfoDetailIterator = ttInfoDetailService.list(param).iterator();
85   - while (ttInfoDetailIterator.hasNext()) {
86   - ttInfoDetails.add(ttInfoDetailIterator.next());
87   - }
88   - }
89   -
90   - return ttInfoDetails;
91   - }
92   -
93   - @Override
94   - public Iterable<ScheduleRule1Flat> getScheduleRule(Integer xlId) {
95   - Map<String, Object> param = new HashMap<>(); // 查询参数
96   - Line xl = lineService.findById(xlId); // 查找线路具体信息
97   - param.clear();
98   - param.put("xl.id_eq", xl.getId());
99   - Iterable<ScheduleRule1Flat> scheduleRule1FlatIterable = scheduleRule1FlatService.list(param);
100   - if (!scheduleRule1FlatIterable.iterator().hasNext())
101   - throw new RuntimeException("线路:" + xl.getName() + " 没有配置规则!");
102   -
103   - return scheduleRule1FlatIterable;
104   - }
105   -
106   - @Override
107   - public Map<Date, Multimap<Long, TTInfoDetail>> getGuideboardXlTTInfoDetailMaps(
108   - Integer xlId, Date fromDate, Date toDate) {
109   - // 获取线路的所有时刻表
110   - List<TTInfo> ttInfos = getTTInfo(xlId);
111   -
112   - // 执行规则,判定每天使用的时刻表
113   - KieSession session = kieBase.newKieSession();
114   -
115   - session.setGlobal("log", logger);
116   - TTInfoResults_output ttInfoResults_output = new TTInfoResults_output();
117   - session.setGlobal("results", ttInfoResults_output);
118   -
119   - TTInfoCalcuParam_input ttInfoCalcuParam_input = new TTInfoCalcuParam_input(
120   - new DateTime(fromDate), new DateTime(toDate), String.valueOf(xlId));
121   - session.insert(ttInfoCalcuParam_input);
122   - for (TTInfo ttInfo : ttInfos) {
123   - TTInfo_input ttInfo_input = new TTInfo_input(ttInfo);
124   - session.insert(ttInfo_input);
125   - }
126   -
127   - session.fireAllRules();
128   - session.dispose();
129   -
130   - // 获取ttinfoDetail
131   - List<TTInfoDetail> ttInfoDetails = getTTInfoDetail(xlId);
132   -
133   - // 规则输出结果
134   - Multimap<DateTime, TTInfoResult_output> outputMultimap =
135   - ttInfoResults_output.getResults().get(String.valueOf(xlId));
136   - // return结果输出
137   - Map<Date, Multimap<Long, TTInfoDetail>> ttInfoDetailMultimap = new HashMap<>();
138   -
139   - Map<String, Object> param = new HashMap<>();
140   - for (DateTime dateTime : outputMultimap.keySet()) {
141   - Collection<TTInfoResult_output> ttInfoResult_outputs = outputMultimap.get(dateTime);
142   - // 如果有多个,使用第一个
143   - Iterator<TTInfoResult_output> ttInfoResult_outputIterator = ttInfoResult_outputs.iterator();
144   - if (ttInfoResult_outputIterator.hasNext()) {
145   - // 同一天,多张时刻表只取第一张
146   - TTInfoResult_output ttInfoResult_output = ttInfoResult_outputIterator.next();
147   - // 查找时刻表明细
148   - Multimap<Long, TTInfoDetail> ttinfodetailMap2 = ArrayListMultimap.create();
149   - for (TTInfoDetail ttInfoDetail : ttInfoDetails) {
150   - if (ttInfoDetail.getTtinfo().getId() == Long.valueOf(ttInfoResult_output.getTtInfoId())) {
151   - ttinfodetailMap2.put(ttInfoDetail.getLp().getId(), ttInfoDetail);
152   - }
153   - }
154   -
155   - ttInfoDetailMultimap.put(dateTime.toDate(), ttinfodetailMap2);
156   - }
157   - }
158   -
159   - return ttInfoDetailMultimap;
160   - }
161   -
162   - @Override
163   - public Map<Long, CarConfigInfo> getCarConfigMaps(Integer xlId) {
164   - // 查询参数
165   - Map<String, Object> param = new HashMap<>();
166   - param.put("xl.id_eq", xlId);
167   - Iterable<CarConfigInfo> carConfigInfoIterable = carConfigInfoService.list(param);
168   - Iterator<CarConfigInfo> carConfigInfoIterator = carConfigInfoIterable.iterator();
169   - if (!carConfigInfoIterator.hasNext())
170   - throw new RuntimeException("线路id=" + xlId + ",下没有车辆配置信息!");
171   -
172   - Map<Long, CarConfigInfo> carConfigInfoMap = new HashMap<>();
173   - while (carConfigInfoIterator.hasNext()) {
174   - CarConfigInfo carConfigInfo = carConfigInfoIterator.next();
175   - carConfigInfoMap.put(carConfigInfo.getId(), carConfigInfo);
176   - }
177   - return carConfigInfoMap;
178   - }
179   -
180   - @Override
181   - public Map<Long, EmployeeConfigInfo> getEmployeeConfigMaps(Integer xlId) {
182   - // 查询参数
183   - Map<String, Object> param = new HashMap<>();
184   - param.put("xl.id_eq", xlId);
185   - Iterable<EmployeeConfigInfo> employeeConfigInfoIterable = employeeConfigInfoService.list(param);
186   - Iterator<EmployeeConfigInfo> employeeConfigInfoIterator = employeeConfigInfoIterable.iterator();
187   - if (!employeeConfigInfoIterator.hasNext())
188   - throw new RuntimeException("线路id=" + xlId + ",下没有人员配置信息!");
189   -
190   - Map<Long, EmployeeConfigInfo> employeeConfigInfoMap = new HashMap<>();
191   - while (employeeConfigInfoIterator.hasNext()) {
192   - EmployeeConfigInfo employeeConfigInfo = employeeConfigInfoIterator.next();
193   - employeeConfigInfoMap.put(employeeConfigInfo.getId(), employeeConfigInfo);
194   - }
195   - return employeeConfigInfoMap;
196   - }
197   -}
  1 +package com.bsth.service.schedule.rules.strategy;
  2 +
  3 +import com.bsth.entity.Line;
  4 +import com.bsth.entity.schedule.CarConfigInfo;
  5 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  6 +import com.bsth.entity.schedule.TTInfo;
  7 +import com.bsth.entity.schedule.TTInfoDetail;
  8 +import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  9 +import com.bsth.service.LineService;
  10 +import com.bsth.service.schedule.*;
  11 +import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input;
  12 +import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output;
  13 +import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output;
  14 +import com.bsth.service.schedule.rules.ttinfo.TTInfo_input;
  15 +import com.google.common.collect.ArrayListMultimap;
  16 +import com.google.common.collect.Multimap;
  17 +import org.joda.time.DateTime;
  18 +import org.kie.api.KieBase;
  19 +import org.kie.api.runtime.KieSession;
  20 +import org.slf4j.Logger;
  21 +import org.slf4j.LoggerFactory;
  22 +import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.stereotype.Service;
  24 +
  25 +import java.util.*;
  26 +
  27 +/**
  28 + * Created by xu on 16/7/10.
  29 + */
  30 +@Service
  31 +public class IStrategyImpl implements IStrategy {
  32 + @Autowired
  33 + private TTInfoService ttInfoService;
  34 + @Autowired
  35 + private CarConfigInfoService carConfigInfoService;
  36 + @Autowired
  37 + private EmployeeConfigInfoService employeeConfigInfoService;
  38 + @Autowired
  39 + private TTInfoDetailService ttInfoDetailService;
  40 + @Autowired
  41 + private LineService lineService;
  42 + @Autowired
  43 + private ScheduleRule1FlatService scheduleRule1FlatService;
  44 +
  45 + /** 日志记录器 */
  46 + private Logger logger = LoggerFactory.getLogger(IStrategyImpl.class);
  47 +
  48 + @Autowired
  49 + private KieBase kieBase;
  50 +
  51 + @Override
  52 + public Line getLine(Integer xlId) {
  53 + Line xl = lineService.findById(xlId); // 查找线路具体信息
  54 + return xl;
  55 + }
  56 +
  57 + @Override
  58 + public List<TTInfo> getTTInfo(Integer xlId) {
  59 + // 查询参数
  60 + Map<String, Object> param = new HashMap<>();
  61 + param.put("xl.id_eq", xlId); // 线路Id
  62 + param.put("isCancel_eq", false); // 作废的过滤掉
  63 + Iterator<TTInfo> ttInfoIterator = ttInfoService.list(param).iterator();
  64 + if (!ttInfoIterator.hasNext()) {
  65 + throw new RuntimeException("线路id=" + xlId + " 没有时刻表!");
  66 + }
  67 + List<TTInfo> ttInfos = new ArrayList<>();
  68 + while (ttInfoIterator.hasNext()) {
  69 + TTInfo ttInfo = ttInfoIterator.next();
  70 + ttInfos.add(ttInfo);
  71 + }
  72 + return ttInfos;
  73 + }
  74 +
  75 + @Override
  76 + public List<TTInfoDetail> getTTInfoDetail(Integer xlId) {
  77 + List<TTInfoDetail> ttInfoDetails = new ArrayList<>();
  78 +
  79 + List<TTInfo> ttInfos = getTTInfo(xlId);
  80 + Map<String, Object> param = new HashMap<>();
  81 + for (TTInfo ttInfo : ttInfos) {
  82 + param.clear();
  83 + param.put("ttinfo.id_eq", ttInfo.getId());
  84 + Iterator<TTInfoDetail> ttInfoDetailIterator = ttInfoDetailService.list(param).iterator();
  85 + while (ttInfoDetailIterator.hasNext()) {
  86 + ttInfoDetails.add(ttInfoDetailIterator.next());
  87 + }
  88 + }
  89 +
  90 + return ttInfoDetails;
  91 + }
  92 +
  93 + @Override
  94 + public Iterable<ScheduleRule1Flat> getScheduleRule(Integer xlId) {
  95 + Map<String, Object> param = new HashMap<>(); // 查询参数
  96 + Line xl = lineService.findById(xlId); // 查找线路具体信息
  97 + param.clear();
  98 + param.put("xl.id_eq", xl.getId());
  99 + Iterable<ScheduleRule1Flat> scheduleRule1FlatIterable = scheduleRule1FlatService.list(param);
  100 + if (!scheduleRule1FlatIterable.iterator().hasNext())
  101 + throw new RuntimeException("线路:" + xl.getName() + " 没有配置规则!");
  102 +
  103 + return scheduleRule1FlatIterable;
  104 + }
  105 +
  106 + @Override
  107 + public Map<Date, Multimap<Long, TTInfoDetail>> getGuideboardXlTTInfoDetailMaps(
  108 + Integer xlId, Date fromDate, Date toDate) {
  109 + // 获取线路的所有时刻表
  110 + List<TTInfo> ttInfos = getTTInfo(xlId);
  111 +
  112 + // 执行规则,判定每天使用的时刻表
  113 + KieSession session = kieBase.newKieSession();
  114 +
  115 + session.setGlobal("log", logger);
  116 + TTInfoResults_output ttInfoResults_output = new TTInfoResults_output();
  117 + session.setGlobal("results", ttInfoResults_output);
  118 +
  119 + TTInfoCalcuParam_input ttInfoCalcuParam_input = new TTInfoCalcuParam_input(
  120 + new DateTime(fromDate), new DateTime(toDate), String.valueOf(xlId));
  121 + session.insert(ttInfoCalcuParam_input);
  122 + for (TTInfo ttInfo : ttInfos) {
  123 + TTInfo_input ttInfo_input = new TTInfo_input(ttInfo);
  124 + session.insert(ttInfo_input);
  125 + }
  126 +
  127 + session.fireAllRules();
  128 + session.dispose();
  129 +
  130 + // 获取ttinfoDetail
  131 + List<TTInfoDetail> ttInfoDetails = getTTInfoDetail(xlId);
  132 +
  133 + // 规则输出结果
  134 + Multimap<DateTime, TTInfoResult_output> outputMultimap =
  135 + ttInfoResults_output.getResults().get(String.valueOf(xlId));
  136 + // return结果输出
  137 + Map<Date, Multimap<Long, TTInfoDetail>> ttInfoDetailMultimap = new HashMap<>();
  138 +
  139 + Map<String, Object> param = new HashMap<>();
  140 + for (DateTime dateTime : outputMultimap.keySet()) {
  141 + Collection<TTInfoResult_output> ttInfoResult_outputs = outputMultimap.get(dateTime);
  142 + // 如果有多个,使用第一个
  143 + Iterator<TTInfoResult_output> ttInfoResult_outputIterator = ttInfoResult_outputs.iterator();
  144 + if (ttInfoResult_outputIterator.hasNext()) {
  145 + // 同一天,多张时刻表只取第一张
  146 + TTInfoResult_output ttInfoResult_output = ttInfoResult_outputIterator.next();
  147 + // 查找时刻表明细
  148 + Multimap<Long, TTInfoDetail> ttinfodetailMap2 = ArrayListMultimap.create();
  149 + for (TTInfoDetail ttInfoDetail : ttInfoDetails) {
  150 + if (ttInfoDetail.getTtinfo().getId() == Long.valueOf(ttInfoResult_output.getTtInfoId())) {
  151 + ttinfodetailMap2.put(ttInfoDetail.getLp().getId(), ttInfoDetail);
  152 + }
  153 + }
  154 +
  155 + ttInfoDetailMultimap.put(dateTime.toDate(), ttinfodetailMap2);
  156 + }
  157 + }
  158 +
  159 + return ttInfoDetailMultimap;
  160 + }
  161 +
  162 + @Override
  163 + public Map<Long, CarConfigInfo> getCarConfigMaps(Integer xlId) {
  164 + // 查询参数
  165 + Map<String, Object> param = new HashMap<>();
  166 + param.put("xl.id_eq", xlId);
  167 + Iterable<CarConfigInfo> carConfigInfoIterable = carConfigInfoService.list(param);
  168 + Iterator<CarConfigInfo> carConfigInfoIterator = carConfigInfoIterable.iterator();
  169 + if (!carConfigInfoIterator.hasNext())
  170 + throw new RuntimeException("线路id=" + xlId + ",下没有车辆配置信息!");
  171 +
  172 + Map<Long, CarConfigInfo> carConfigInfoMap = new HashMap<>();
  173 + while (carConfigInfoIterator.hasNext()) {
  174 + CarConfigInfo carConfigInfo = carConfigInfoIterator.next();
  175 + carConfigInfoMap.put(carConfigInfo.getId(), carConfigInfo);
  176 + }
  177 + return carConfigInfoMap;
  178 + }
  179 +
  180 + @Override
  181 + public Map<Long, EmployeeConfigInfo> getEmployeeConfigMaps(Integer xlId) {
  182 + // 查询参数
  183 + Map<String, Object> param = new HashMap<>();
  184 + param.put("xl.id_eq", xlId);
  185 + Iterable<EmployeeConfigInfo> employeeConfigInfoIterable = employeeConfigInfoService.list(param);
  186 + Iterator<EmployeeConfigInfo> employeeConfigInfoIterator = employeeConfigInfoIterable.iterator();
  187 + if (!employeeConfigInfoIterator.hasNext())
  188 + throw new RuntimeException("线路id=" + xlId + ",下没有人员配置信息!");
  189 +
  190 + Map<Long, EmployeeConfigInfo> employeeConfigInfoMap = new HashMap<>();
  191 + while (employeeConfigInfoIterator.hasNext()) {
  192 + EmployeeConfigInfo employeeConfigInfo = employeeConfigInfoIterator.next();
  193 + employeeConfigInfoMap.put(employeeConfigInfo.getId(), employeeConfigInfo);
  194 + }
  195 + return employeeConfigInfoMap;
  196 + }
  197 +}
198 198 \ No newline at end of file
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/TTInfo_input.java
... ... @@ -122,4 +122,4 @@ public class TTInfo_input implements Comparable&lt;TTInfo_input&gt; {
122 122 public void setQyDate(DateTime qyDate) {
123 123 this.qyDate = qyDate;
124 124 }
125   -}
  125 +}
126 126 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
... ... @@ -2146,4 +2146,4 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saEmployeegroup&#39;, [
2146 2146 }
2147 2147 }
2148 2148 }
2149   -]);
  2149 +]);
2150 2150 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
... ... @@ -441,5 +441,4 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;BusLineInfoStatService_g&#39;, [&#39;$resource&#39;,
441 441 }
442 442 }
443 443 );
444   -}]);
445   -
  444 +}]);
446 445 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-ui-route-state.js
... ... @@ -819,4 +819,5 @@ ScheduleApp.config([&#39;$stateProvider&#39;, &#39;$urlRouterProvider&#39;, function($stateProvi
819 819 // TODO:
820 820  
821 821 ;
  822 +
822 823 }]);
823 824 \ No newline at end of file
... ...