Commit be81722ede42c8e1dfa602664315144bf1517e12

Authored by 潘钊
2 parents 80dcf5b2 89e20a31

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

into qingpu

# Conflicts:
#	src/main/java/com/bsth/data/gpsdata/GpsRealData.java
#	src/main/resources/application-prod.properties
#	src/main/resources/ms-jdbc.properties

Too many changes to show.

To preserve performance only 20 of 52 files are displayed.

README.md
1 -公交调度系统BS版 0.1  
2 -======  
3 -----------  
4 -## 目录  
5 ----------  
6 - * [字典表](#字典表)  
7 - * [动态jpa查询实现](#动态jpa查询实现)  
8 - * [车载 gps 相关数据](#gps)  
9 - * [实时gps数据接口 http](#实时gps接口)  
10 - * [进出站数据表结构](#进站数据)  
11 - * [异常警报表结构](#异常警报)  
12 - * [大间隔](#大间隔)  
13 - * [超速](#超速)  
14 - * [越界](#越界)  
15 - * [越站](#越站)  
16 - * [聚集](#聚集)  
17 - * [掉线](#掉线)  
18 - * [调度消息下发接口HTTP](#调度消息下发接口)  
19 - * [调度消息上传接口HTTP](#调度消息上传接口)  
20 - * [车辆历史GPS数据](#车辆历史GPS)  
21 -  
22 -----------  
23 -  
24 -## 字典表  
25 -----------  
26 -字典操作全部由前端负责,主要有2种。  
27 -  
28 -1、转换字典代码。  
29 - 当pjax的`pjax:success`事件被触发(片段加载完成)  
30 - 扫描容器内所有有 `$(".nt-dictionary")` 元素进行字典转换  
31 -``` html  
32 ---dom标签为span div p h1 h2 h3 h4 h5 h6 等等文本元素时,如下写法,text为要转换的代码  
33 -<span class="nt-dictionary" data-group="ScheduleType">out</span>  
34 ---to  
35 -<span>出场</span>  
36 -  
37 -<!- dom标签为input时,如下 data-code为要转换的代码 -->  
38 -<input class="nt-dictionary" data-group="ScheduleType" data-code="out">  
39 ---to  
40 -<input value="出场">  
41 -  
42 -<!- dom标签为select时 如下 data-code为要选中的项 -->  
43 -<select class="nt-dictionary" data-group="ScheduleType" data-code="out"></select>  
44 ---to  
45 -<select>  
46 - <option value="normal">正常班次</option>  
47 - <option value="out" selected>出场</option>  
48 - <option value="in">进场</option>  
49 - <option value="oil">加油</option>  
50 - <option value="temp">临加</option>  
51 - <option value="region">区间</option>  
52 - <option value="venting">放空</option>  
53 - <option value="major">放大站</option>  
54 -</select>  
55 -```  
56 -*原标签的class 除nt-dictionary 外,其余均会被保留*  
57 -  
58 -2、dictionary.js提供如下方法自行使用  
59 -| 方法名 | 参数|返回|  
60 -| ---- | ---- | ---- | ---- |  
61 -| groups (获取所有字典组) | 无| | {LineTrend: 线路走向, ScheduleType: 班次类型} |  
62 -| getByGroup (获取字典组下的字典)| (group) |{0: 上行, 1: 下行}|  
63 -| transformCode (转换字典代码)| (group, code) | 上行 |  
64 -  
65 -## 动态jpa查询实现  
66 -----------  
67 -*参考调度系统枚举com.bsth.entity.search.SearchOperator*  
68 -  
69 -  
70 -## gps  
71 -----------  
72 -### 实时gps接口  
73 -  
74 -所有在线GPS: [http://192.168.168.192:8080/transport_server/rtgps](http://192.168.168.192:8080/transport_server/rtgps/)  
75 -根据设备号查询:[http://192.168.168.192:8080/transport_server/rtgps/05B01901](http://192.168.168.192:8080/transport_server/rtgps/05B01901)  
76 -  
77 -<span style="color: red">Response</span>:  
78 -```json  
79 -{  
80 - "data":[  
81 - {  
82 - "companyCode":5,  
83 - "lineId":10329,  
84 - "deviceId":"05B01901",  
85 - "carparkNo":"00000000",  
86 - "stopNo":"7C890002",  
87 - "lon":121.549866,  
88 - "lat":31.238798,  
89 - "timestamp":1397104499000,  
90 - "speed":42.0,  
91 - "direction":245.9,  
92 - "state":0,  
93 - "upDown":0  
94 - }]  
95 -}  
96 -```  
97 -  
98 -| -- | --|--|  
99 -| ---- | ---- | ---- |  
100 -| companyCode | int | 公司代码 |  
101 -| lineId | int | 线路编码 |  
102 -| deviceId | String | 设备编号 |  
103 -| carparkNo | String | 停车场编码 |  
104 -| stopNo | String | 站点编码 |  
105 -| lon | float | 经度 |  
106 -| lat | float | 纬度 |  
107 -| timestamp | long | 时间戳 |  
108 -| speed | float | 速度|  
109 -| direction | float | 方向(角度) |  
110 -| state | int | 营运状态( 0 营运 ,1 非营运, -1 无效) |  
111 -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效)|  
112 -  
113 -  
114 -### 进站数据  
115 -----------  
116 -表名:  
117 -  
118 -| .. | .. | .. |  
119 -| ---- | ---- | ---- |  
120 -| id | int | 主键 |  
121 -| deviceId | String | 设备号 |  
122 -| lineId | int | 线路编码 |  
123 -| stopNo | long | 站点编码 |  
124 -| timestamp | long | 时间戳 |  
125 -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |  
126 -| createDate | Date | 创建时间 |  
127 -  
128 -  
129 -### 异常警报  
130 -----------  
131 -  
132 -### 大间隔  
133 -----------  
134 -表名:  
135 -  
136 -| .. | .. | .. |  
137 -| ---- | ---- | ---- |  
138 -| id | int | 主键 |  
139 -| line | int | 线路编码 |  
140 -| station | String | 站点编码 |  
141 -| cVehicle | String | 当前车辆编码 |  
142 -| lastVehicle | String | 上一个车辆编码 |  
143 -| interval | long | 间隔时间(秒) |  
144 -| timestamp | long | 时间戳 |  
145 -| createDate | Date | 创建时间 |  
146 -  
147 -### 超速  
148 -----------  
149 -表名:  
150 -  
151 -| .. | .. | .. |  
152 -| ---- | ---- | ---- |  
153 -| id | int | 主键 |  
154 -| vehicle | String | 车辆编码 |  
155 -| line | int | 线路编码 |  
156 -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |  
157 -| lon | float | 经度 |  
158 -| lat | float | 纬度|  
159 -| speed | float | 速度 |  
160 -| timestamp | long | 时间戳 |  
161 -| createDate | Date | 时间 |  
162 -  
163 -### 越界  
164 -----------  
165 -表名:  
166 -  
167 -| .. | .. | .. |  
168 -| ---- | ---- | ---- |  
169 -| id | int | 主键 |  
170 -| vehicle | String | 车辆编码 |  
171 -| line | int | 线路编码 |  
172 -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |  
173 -| lon | float | 经度 |  
174 -| lat | float | 纬度|  
175 -| location | String | 越界位置(由线调页面进行初始转换)意思是该字段默认为空,页面第一次查看时会写入值|  
176 -| timestamp | long | 时间戳 |  
177 -| createDate | Date | 时间 |  
178 -  
179 -  
180 -### 越站  
181 -----------  
182 -表名:  
183 -  
184 -| .. | .. | .. |  
185 -| ---- | ---- | ---- |  
186 -| id | int | 主键 |  
187 -| line | int | 线路编码 |  
188 -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |  
189 -| station | String | 站点编码 |  
190 -| vehicle | String | 车辆编码 |  
191 -| inData | Date | 进站时间 |  
192 -| outDate | Date | 出站时间 |  
193 -  
194 -  
195 -### 聚集  
196 -----------  
197 -表名:  
198 -  
199 -| .. | .. | .. |  
200 -| ---- | ---- | ---- |  
201 -| id | int | 主键 |  
202 -| line | int | 线路编码 |  
203 -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |  
204 -| stations | String | 站点(多个用 , 号分隔。应该是连续站点) |  
205 -| vehicles | String | 车辆编码(多个用 , 号分隔) |  
206 -| timestamp | long | 时间戳 |  
207 -| createDate | Date | 时间 |  
208 -  
209 -  
210 -### 掉线  
211 -----------  
212 -表名:  
213 -  
214 -| .. | .. | .. |  
215 -| ---- | ---- | ---- |  
216 -| id | int | 主键 |  
217 -| line | int | 线路编码 |  
218 -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |  
219 -| vehicle | String | 车辆编码 |  
220 -| lon | float | 经度 |  
221 -| lat | float | 纬度|  
222 -| timestamp | long | 时间戳 |  
223 -| createDate | Date | 时间 |  
224 -  
225 -  
226 -### 调度消息下发接口  
227 -----------  
228 -[http://192.168.168.192:8080/transport_server/message](http://192.168.168.192:8080/transport_server/message/)  
229 -  
230 -<span style="color: red">Request</span>:  
231 -```json  
232 -{  
233 - "deviceId":12345,  
234 - "timestamp":44324,  
235 - "operCode":0x60,  
236 - "data":{  
237 - "companyCode":22,  
238 - "deviceId":"029L2222",  
239 - "timestamp":134326,  
240 - "instructType":00,  
241 - "dispatchInstruct":0x00,  
242 - "msgId":12345,  
243 - "alarmTime":201606012000,  
244 - "serviceState":00000000,  
245 - "txtContent":"你好"  
246 - }  
247 -}  
248 -```  
249 -| .. | .. | .. |  
250 -| ---- | ---- | ---- |  
251 -| deviceId | string | 设备编号 |  
252 -| timestamp | long | 时间戳(ms) |  
253 -| operCode | short | 一级协议 |  
254 -| data.companyCode | short | 公司代码 |  
255 -| data.deviceId | string | 设备编号 |  
256 -| data.timestamp | long | 时间戳 |  
257 -| data.instructType | short | 保留 默认0 |  
258 -| data.dispatchInstruct | short | 调度指令 调度指令。0X00表示信息短语,0X01表示取消上次指令+调度指令(闹钟有效),0x02表示为调度指令(闹钟有效); 0x03表示运营状态指令(闹钟无效);0x04表示其他指令。|  
259 -| data.msgId | long | 同上 |  
260 -| data.alarmTime | long | 闹钟 MMddhhmm|  
261 -| data.serviceState | long | 多状态字节   先由车载发起车辆故障、事故报告、扣证、纠纷、加油等审请,经调度确认后,下发调度指令与运营状态。当调度指令为0X00终端需要提示信息。当调度指令为0x01和0x02,终端需要收到后提示信息。并且必须在闹钟结束后进行终端相关状态更新。在闹钟时间前120秒开始提示。当调度指令为0x03,收到后进行终端相关状态更新,终端不需要提示信息。当调度指令为0x04,暂不需要提示信息。|  
262 -| data.txtContent | string | 下发的消息文本 |  
263 -```json  
264 -{  
265 - "deviceId":12345,  
266 - "timestamp":44324,  
267 - "operCode":0x64,  
268 - "data":{  
269 - "cityCode":22,  
270 - "deviceId":"029L2222",  
271 - "lineId":"134326"  
272 - }  
273 -}  
274 -```  
275 -| .. | .. | .. |  
276 -| ---- | ---- | ---- |  
277 -| deviceId | string | 设备编号 |  
278 -| timestamp | long | 时间戳(ms) |  
279 -| operCode | short | 一级协议 |  
280 -| data.cityCode | short | 城市区号 |  
281 -| data.deviceId | string | 设备编号 |  
282 -| data.lineId | string | 线路编号 6位 不足6位前面补0 如编号890 用000890表示 |  
283 -  
284 -```json  
285 -{  
286 - "deviceId":12345,  
287 - "timestamp":44324,  
288 - "operCode":0xC0,  
289 - "data":{  
290 - "operCode":0x86,  
291 - "requestAck":0x06  
292 - }  
293 -}  
294 -```  
295 -| .. | .. | .. |  
296 -| ---- | ---- | ---- |  
297 -| deviceId | string | 设备编号 |  
298 -| timestamp | long | 时间戳(ms) |  
299 -| operCode | short | 一级协议 |  
300 -| data.operCode | short | 二级协议 |  
301 -| data.requestAck | short | 请求应答字 0x06同意 0x15不同意|  
302 -  
303 -```json  
304 -{  
305 - "deviceId":12345,  
306 - "timestamp":44324,  
307 - "operCode":0xC0,  
308 - "data":{  
309 - "operCode":0xa3,  
310 - "deviceId":12345,  
311 - "ipAddress":222.66.0.204,  
312 - "port":8899,  
313 - "reportMode":0,  
314 - "interval":0,  
315 - "distance":0,  
316 - "speedingThreshold":0,  
317 - "alarmThreshold":0,  
318 - "posIpAddress":0,  
319 - "posPort":0,  
320 - "delay":0,  
321 - "speedThreshold1":0,  
322 - "speedThreshold2":0,  
323 - "contrast":0,  
324 - "brightness":0,  
325 - "saturation":0  
326 - }  
327 -}  
328 -```  
329 -| .. | .. | .. |  
330 -| ---- | ---- | ---- |  
331 -| deviceId | string | 设备编号 |  
332 -| timestamp | long | 时间戳(ms) |  
333 -| operCode | short | 一级协议 |  
334 -| data.operCode | short | 二级协议 |  
335 -| data.deviceId | string | 设备编号|  
336 -| data.ipAddress | string | 网关IP地址|  
337 -| data.port | string | 网关端口|  
338 -| data.reportMode | short | 定时定距上报模式|  
339 -| data.interval | int | 定时上报时间间隔|  
340 -| data.distance | string | 定距上报距离间隔|  
341 -| data.speedingThreshold | short | 非线路状态超速阀门|  
342 -| data.alarmThreshold | short | 预警阀门|  
343 -| data.posIpAddress | string | pos机IP地址|  
344 -| data.posPort | string | pos机端口|  
345 -| data.delay | int | 延迟机关时间|  
346 -| data.deviceId | short | 中门视频切换到码表界面速度阀门 默认45|  
347 -| data.deviceId | short | 码表界面切换到中门视频速度阀门 默认35|  
348 -| data.deviceId | short | 对比度|  
349 -| data.deviceId | short | 亮度|  
350 -| data.deviceId | short | 饱和度|  
351 -  
352 -```json  
353 -{  
354 - "deviceId":12345,  
355 - "timestamp":44324,  
356 - "operCode":0xC0,  
357 - "data":{  
358 - "operCode":0xa4  
359 - }  
360 -}  
361 -```  
362 -| .. | .. | .. |  
363 -| ---- | ---- | ---- |  
364 -| deviceId | string | 设备编号 |  
365 -| timestamp | long | 时间戳(ms) |  
366 -| operCode | short | 一级协议 |  
367 -| data.operCode | short | 二级协议 |  
368 -  
369 -```json  
370 -{  
371 - "deviceId":12345,  
372 - "timestamp":44324,  
373 - "operCode":0xC0,  
374 - "data":{  
375 - "operCode":0xa5  
376 - "programVersion":2  
377 - }  
378 -}  
379 -```  
380 -| .. | .. | .. |  
381 -| ---- | ---- | ---- |  
382 -| deviceId | string | 设备编号 |  
383 -| timestamp | long | 时间戳(ms) |  
384 -| operCode | short | 一级协议 |  
385 -| data.operCode | short | 二级协议 |  
386 -| data.programVersion | short | 程序版本 |  
387 -  
388 -<span style="color: red">Response</span>:  
389 -```json  
390 -{  
391 - "errCode":0  
392 -}  
393 -```  
394 -  
395 -### 调度消息上传接口  
396 -----------  
397 -上行POST地址:[http://192.168.168.120:9088/control/upstream](http://192.168.168.120:9088/control/upstream)  
398 -<span style="color: red">Request</span>:  
399 -```json  
400 -{  
401 - "deviceId":12345,  
402 - "timestamp":44324,  
403 - "status":0,  
404 - "operCode":0x80,  
405 - "data":{  
406 - "operCode":0x26,  
407 - "requestCode":22  
408 - }  
409 -}  
410 -```  
411 -| .. | .. | .. |  
412 -| ---- | ---- | ---- |  
413 -| deviceId | string | 设备编号 |  
414 -| timestamp | long | 时间戳(ms) |  
415 -| status | int | 0x80时无数据 0表示失败 1表示成功或设备确认 2表示驾驶员阅读 |  
416 -| operCode | short | 一级协议 消息确认将无数据 |  
417 -| data.operCode | short | 二级协议 |  
418 -| data.requestCode | short | 请求代码0xa1 恢复运营 0xa2 申请调档 0xa3 出场请求 0xa5 进场请求 0xa7 加油请求 0x50 车辆故障 0x70 路阻报告 0x60 事故报告 0x11 扣证纠纷 0x12 报警 |  
419 -<span style="color: red">Response</span>:  
420 -```json  
421 -{  
422 - "errCode":0  
423 -}  
424 -```  
425 -  
426 -### 车辆历史GPS  
427 -----------  
428 -表名:BSTH_C_GPS_INFO  
429 -  
430 -| .. | .. | .. |  
431 -| ---- | ---- | ---- |  
432 -| cityCode | int | 城市代码 |  
433 -| industryCode | int | 行业代码 |  
434 -| companyCode | int | 企业代码 |  
435 -| lineId | int | 线路编号 |  
436 -| deviceId | string | 设备编号 |  
437 -| driverNo | int | 驾驶员工号 |  
438 -| carparkSerialNo | int | 停车场序列号 |  
439 -| carparkNo | string | 停车场编号 |  
440 -| stopSerialNo | int | 站点序列号 |  
441 -| stopNo | string | 停车场编号 |  
442 -| lon | float | 经度 |  
443 -| lat | float | 维度 |  
444 -| ts | long | 时间戳 |  
445 -| speedSensor | float | 发动机速度 |  
446 -| speedGps | float | gps速度 |  
447 -| direction | float | 角度0-359 |  
448 -| inTemp | int | 车内温度 |  
449 -| serviceState | long | 设备状态字 |  
450 -| daysYear | int | 对应年中的天数 为分区字段 查询一定要用此字段过滤 |  
451 - 1 +公交调度系统BS版 0.1
  2 +======
  3 +----------
  4 +## 目录
  5 +---------
  6 + * [字典表](#字典表)
  7 + * [动态jpa查询实现](#动态jpa查询实现)
  8 + * [车载 gps 相关数据](#gps)
  9 + * [实时gps数据接口 http](#实时gps接口)
  10 + * [进出站数据表结构](#进站数据)
  11 + * [异常警报表结构](#异常警报)
  12 + * [大间隔](#大间隔)
  13 + * [超速](#超速)
  14 + * [越界](#越界)
  15 + * [越站](#越站)
  16 + * [聚集](#聚集)
  17 + * [掉线](#掉线)
  18 + * [调度消息下发接口HTTP](#调度消息下发接口)
  19 + * [调度消息上传接口HTTP](#调度消息上传接口)
  20 + * [车辆历史GPS数据](#车辆历史GPS)
  21 +
  22 +----------
  23 +
  24 +## 字典表
  25 +----------
  26 +字典操作全部由前端负责,主要有2种。
  27 +
  28 +1、转换字典代码。
  29 + 当pjax的`pjax:success`事件被触发(片段加载完成)
  30 + 扫描容器内所有有 `$(".nt-dictionary")` 元素进行字典转换
  31 +``` html
  32 +--dom标签为span div p h1 h2 h3 h4 h5 h6 等等文本元素时,如下写法,text为要转换的代码
  33 +<span class="nt-dictionary" data-group="ScheduleType">out</span>
  34 +--to
  35 +<span>出场</span>
  36 +
  37 +<!- dom标签为input时,如下 data-code为要转换的代码 -->
  38 +<input class="nt-dictionary" data-group="ScheduleType" data-code="out">
  39 +--to
  40 +<input value="出场">
  41 +
  42 +<!- dom标签为select时 如下 data-code为要选中的项 -->
  43 +<select class="nt-dictionary" data-group="ScheduleType" data-code="out"></select>
  44 +--to
  45 +<select>
  46 + <option value="normal">正常班次</option>
  47 + <option value="out" selected>出场</option>
  48 + <option value="in">进场</option>
  49 + <option value="oil">加油</option>
  50 + <option value="temp">临加</option>
  51 + <option value="region">区间</option>
  52 + <option value="venting">放空</option>
  53 + <option value="major">放大站</option>
  54 +</select>
  55 +```
  56 +*原标签的class 除nt-dictionary 外,其余均会被保留*
  57 +
  58 +2、dictionary.js提供如下方法自行使用
  59 +| 方法名 | 参数|返回|
  60 +| ---- | ---- | ---- | ---- |
  61 +| groups (获取所有字典组) | 无| | {LineTrend: 线路走向, ScheduleType: 班次类型} |
  62 +| getByGroup (获取字典组下的字典)| (group) |{0: 上行, 1: 下行}|
  63 +| transformCode (转换字典代码)| (group, code) | 上行 |
  64 +
  65 +## 动态jpa查询实现
  66 +----------
  67 +*参考调度系统枚举com.bsth.entity.search.SearchOperator*
  68 +
  69 +
  70 +## gps
  71 +----------
  72 +### 实时gps接口
  73 +
  74 +所有在线GPS: [http://192.168.168.192:8080/transport_server/rtgps](http://192.168.168.192:8080/transport_server/rtgps/)
  75 +根据设备号查询:[http://192.168.168.192:8080/transport_server/rtgps/05B01901](http://192.168.168.192:8080/transport_server/rtgps/05B01901)
  76 +
  77 +<span style="color: red">Response</span>:
  78 +```json
  79 +{
  80 + "data":[
  81 + {
  82 + "companyCode":5,
  83 + "lineId":10329,
  84 + "deviceId":"05B01901",
  85 + "carparkNo":"00000000",
  86 + "stopNo":"7C890002",
  87 + "lon":121.549866,
  88 + "lat":31.238798,
  89 + "timestamp":1397104499000,
  90 + "speed":42.0,
  91 + "direction":245.9,
  92 + "state":0,
  93 + "upDown":0
  94 + }]
  95 +}
  96 +```
  97 +
  98 +| -- | --|--|
  99 +| ---- | ---- | ---- |
  100 +| companyCode | int | 公司代码 |
  101 +| lineId | int | 线路编码 |
  102 +| deviceId | String | 设备编号 |
  103 +| carparkNo | String | 停车场编码 |
  104 +| stopNo | String | 站点编码 |
  105 +| lon | float | 经度 |
  106 +| lat | float | 纬度 |
  107 +| timestamp | long | 时间戳 |
  108 +| speed | float | 速度|
  109 +| direction | float | 方向(角度) |
  110 +| state | int | 营运状态( 0 营运 ,1 非营运, -1 无效) |
  111 +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效)|
  112 +
  113 +
  114 +### 进站数据
  115 +----------
  116 +表名:
  117 +
  118 +| .. | .. | .. |
  119 +| ---- | ---- | ---- |
  120 +| id | int | 主键 |
  121 +| deviceId | String | 设备号 |
  122 +| lineId | int | 线路编码 |
  123 +| stopNo | long | 站点编码 |
  124 +| timestamp | long | 时间戳 |
  125 +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |
  126 +| createDate | Date | 创建时间 |
  127 +
  128 +
  129 +### 异常警报
  130 +----------
  131 +
  132 +### 大间隔
  133 +----------
  134 +表名:
  135 +
  136 +| .. | .. | .. |
  137 +| ---- | ---- | ---- |
  138 +| id | int | 主键 |
  139 +| line | int | 线路编码 |
  140 +| station | String | 站点编码 |
  141 +| cVehicle | String | 当前车辆编码 |
  142 +| lastVehicle | String | 上一个车辆编码 |
  143 +| interval | long | 间隔时间(秒) |
  144 +| timestamp | long | 时间戳 |
  145 +| createDate | Date | 创建时间 |
  146 +
  147 +### 超速
  148 +----------
  149 +表名:
  150 +
  151 +| .. | .. | .. |
  152 +| ---- | ---- | ---- |
  153 +| id | int | 主键 |
  154 +| vehicle | String | 车辆编码 |
  155 +| line | int | 线路编码 |
  156 +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |
  157 +| lon | float | 经度 |
  158 +| lat | float | 纬度|
  159 +| speed | float | 速度 |
  160 +| timestamp | long | 时间戳 |
  161 +| createDate | Date | 时间 |
  162 +
  163 +### 越界
  164 +----------
  165 +表名:
  166 +
  167 +| .. | .. | .. |
  168 +| ---- | ---- | ---- |
  169 +| id | int | 主键 |
  170 +| vehicle | String | 车辆编码 |
  171 +| line | int | 线路编码 |
  172 +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |
  173 +| lon | float | 经度 |
  174 +| lat | float | 纬度|
  175 +| location | String | 越界位置(由线调页面进行初始转换)意思是该字段默认为空,页面第一次查看时会写入值|
  176 +| timestamp | long | 时间戳 |
  177 +| createDate | Date | 时间 |
  178 +
  179 +
  180 +### 越站
  181 +----------
  182 +表名:
  183 +
  184 +| .. | .. | .. |
  185 +| ---- | ---- | ---- |
  186 +| id | int | 主键 |
  187 +| line | int | 线路编码 |
  188 +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |
  189 +| station | String | 站点编码 |
  190 +| vehicle | String | 车辆编码 |
  191 +| inData | Date | 进站时间 |
  192 +| outDate | Date | 出站时间 |
  193 +
  194 +
  195 +### 聚集
  196 +----------
  197 +表名:
  198 +
  199 +| .. | .. | .. |
  200 +| ---- | ---- | ---- |
  201 +| id | int | 主键 |
  202 +| line | int | 线路编码 |
  203 +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |
  204 +| stations | String | 站点(多个用 , 号分隔。应该是连续站点) |
  205 +| vehicles | String | 车辆编码(多个用 , 号分隔) |
  206 +| timestamp | long | 时间戳 |
  207 +| createDate | Date | 时间 |
  208 +
  209 +
  210 +### 掉线
  211 +----------
  212 +表名:
  213 +
  214 +| .. | .. | .. |
  215 +| ---- | ---- | ---- |
  216 +| id | int | 主键 |
  217 +| line | int | 线路编码 |
  218 +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) |
  219 +| vehicle | String | 车辆编码 |
  220 +| lon | float | 经度 |
  221 +| lat | float | 纬度|
  222 +| timestamp | long | 时间戳 |
  223 +| createDate | Date | 时间 |
  224 +
  225 +
  226 +### 调度消息下发接口
  227 +----------
  228 +[http://192.168.168.192:8080/transport_server/message](http://192.168.168.192:8080/transport_server/message/)
  229 +
  230 +<span style="color: red">Request</span>:
  231 +```json
  232 +{
  233 + "deviceId":12345,
  234 + "timestamp":44324,
  235 + "operCode":0x60,
  236 + "data":{
  237 + "companyCode":22,
  238 + "deviceId":"029L2222",
  239 + "timestamp":134326,
  240 + "instructType":00,
  241 + "dispatchInstruct":0x00,
  242 + "msgId":12345,
  243 + "alarmTime":201606012000,
  244 + "serviceState":00000000,
  245 + "txtContent":"你好"
  246 + }
  247 +}
  248 +```
  249 +| .. | .. | .. |
  250 +| ---- | ---- | ---- |
  251 +| deviceId | string | 设备编号 |
  252 +| timestamp | long | 时间戳(ms) |
  253 +| operCode | short | 一级协议 |
  254 +| data.companyCode | short | 公司代码 |
  255 +| data.deviceId | string | 设备编号 |
  256 +| data.timestamp | long | 时间戳 |
  257 +| data.instructType | short | 保留 默认0 |
  258 +| data.dispatchInstruct | short | 调度指令 调度指令。0X00表示信息短语,0X01表示取消上次指令+调度指令(闹钟有效),0x02表示为调度指令(闹钟有效); 0x03表示运营状态指令(闹钟无效);0x04表示其他指令。|
  259 +| data.msgId | long | 同上 |
  260 +| data.alarmTime | long | 闹钟 MMddhhmm|
  261 +| data.serviceState | long | 多状态字节   先由车载发起车辆故障、事故报告、扣证、纠纷、加油等审请,经调度确认后,下发调度指令与运营状态。当调度指令为0X00终端需要提示信息。当调度指令为0x01和0x02,终端需要收到后提示信息。并且必须在闹钟结束后进行终端相关状态更新。在闹钟时间前120秒开始提示。当调度指令为0x03,收到后进行终端相关状态更新,终端不需要提示信息。当调度指令为0x04,暂不需要提示信息。|
  262 +| data.txtContent | string | 下发的消息文本 |
  263 +```json
  264 +{
  265 + "deviceId":12345,
  266 + "timestamp":44324,
  267 + "operCode":0x64,
  268 + "data":{
  269 + "cityCode":22,
  270 + "deviceId":"029L2222",
  271 + "lineId":"134326"
  272 + }
  273 +}
  274 +```
  275 +| .. | .. | .. |
  276 +| ---- | ---- | ---- |
  277 +| deviceId | string | 设备编号 |
  278 +| timestamp | long | 时间戳(ms) |
  279 +| operCode | short | 一级协议 |
  280 +| data.cityCode | short | 城市区号 |
  281 +| data.deviceId | string | 设备编号 |
  282 +| data.lineId | string | 线路编号 6位 不足6位前面补0 如编号890 用000890表示 |
  283 +
  284 +```json
  285 +{
  286 + "deviceId":12345,
  287 + "timestamp":44324,
  288 + "operCode":0xC0,
  289 + "data":{
  290 + "operCode":0x86,
  291 + "requestAck":0x06
  292 + }
  293 +}
  294 +```
  295 +| .. | .. | .. |
  296 +| ---- | ---- | ---- |
  297 +| deviceId | string | 设备编号 |
  298 +| timestamp | long | 时间戳(ms) |
  299 +| operCode | short | 一级协议 |
  300 +| data.operCode | short | 二级协议 |
  301 +| data.requestAck | short | 请求应答字 0x06同意 0x15不同意|
  302 +
  303 +```json
  304 +{
  305 + "deviceId":12345,
  306 + "timestamp":44324,
  307 + "operCode":0xC0,
  308 + "data":{
  309 + "operCode":0xa3,
  310 + "deviceId":12345,
  311 + "ipAddress":222.66.0.204,
  312 + "port":8899,
  313 + "reportMode":0,
  314 + "interval":0,
  315 + "distance":0,
  316 + "speedingThreshold":0,
  317 + "alarmThreshold":0,
  318 + "posIpAddress":0,
  319 + "posPort":0,
  320 + "delay":0,
  321 + "speedThreshold1":0,
  322 + "speedThreshold2":0,
  323 + "contrast":0,
  324 + "brightness":0,
  325 + "saturation":0
  326 + }
  327 +}
  328 +```
  329 +| .. | .. | .. |
  330 +| ---- | ---- | ---- |
  331 +| deviceId | string | 设备编号 |
  332 +| timestamp | long | 时间戳(ms) |
  333 +| operCode | short | 一级协议 |
  334 +| data.operCode | short | 二级协议 |
  335 +| data.deviceId | string | 设备编号|
  336 +| data.ipAddress | string | 网关IP地址|
  337 +| data.port | string | 网关端口|
  338 +| data.reportMode | short | 定时定距上报模式|
  339 +| data.interval | int | 定时上报时间间隔|
  340 +| data.distance | string | 定距上报距离间隔|
  341 +| data.speedingThreshold | short | 非线路状态超速阀门|
  342 +| data.alarmThreshold | short | 预警阀门|
  343 +| data.posIpAddress | string | pos机IP地址|
  344 +| data.posPort | string | pos机端口|
  345 +| data.delay | int | 延迟机关时间|
  346 +| data.deviceId | short | 中门视频切换到码表界面速度阀门 默认45|
  347 +| data.deviceId | short | 码表界面切换到中门视频速度阀门 默认35|
  348 +| data.deviceId | short | 对比度|
  349 +| data.deviceId | short | 亮度|
  350 +| data.deviceId | short | 饱和度|
  351 +
  352 +```json
  353 +{
  354 + "deviceId":12345,
  355 + "timestamp":44324,
  356 + "operCode":0xC0,
  357 + "data":{
  358 + "operCode":0xa4
  359 + }
  360 +}
  361 +```
  362 +| .. | .. | .. |
  363 +| ---- | ---- | ---- |
  364 +| deviceId | string | 设备编号 |
  365 +| timestamp | long | 时间戳(ms) |
  366 +| operCode | short | 一级协议 |
  367 +| data.operCode | short | 二级协议 |
  368 +
  369 +```json
  370 +{
  371 + "deviceId":12345,
  372 + "timestamp":44324,
  373 + "operCode":0xC0,
  374 + "data":{
  375 + "operCode":0xa5
  376 + "programVersion":2
  377 + }
  378 +}
  379 +```
  380 +| .. | .. | .. |
  381 +| ---- | ---- | ---- |
  382 +| deviceId | string | 设备编号 |
  383 +| timestamp | long | 时间戳(ms) |
  384 +| operCode | short | 一级协议 |
  385 +| data.operCode | short | 二级协议 |
  386 +| data.programVersion | short | 程序版本 |
  387 +
  388 +<span style="color: red">Response</span>:
  389 +```json
  390 +{
  391 + "errCode":0
  392 +}
  393 +```
  394 +
  395 +### 调度消息上传接口
  396 +----------
  397 +上行POST地址:[http://192.168.168.120:9088/control/upstream](http://192.168.168.120:9088/control/upstream)
  398 +<span style="color: red">Request</span>:
  399 +```json
  400 +{
  401 + "deviceId":12345,
  402 + "timestamp":44324,
  403 + "status":0,
  404 + "operCode":0x80,
  405 + "data":{
  406 + "operCode":0x26,
  407 + "requestCode":22
  408 + }
  409 +}
  410 +```
  411 +| .. | .. | .. |
  412 +| ---- | ---- | ---- |
  413 +| deviceId | string | 设备编号 |
  414 +| timestamp | long | 时间戳(ms) |
  415 +| status | int | 0x80时无数据 0表示失败 1表示成功或设备确认 2表示驾驶员阅读 |
  416 +| operCode | short | 一级协议 消息确认将无数据 |
  417 +| data.operCode | short | 二级协议 |
  418 +| data.requestCode | short | 请求代码0xa1 恢复运营 0xa2 申请调档 0xa3 出场请求 0xa5 进场请求 0xa7 加油请求 0x50 车辆故障 0x70 路阻报告 0x60 事故报告 0x11 扣证纠纷 0x12 报警 |
  419 +<span style="color: red">Response</span>:
  420 +```json
  421 +{
  422 + "errCode":0
  423 +}
  424 +```
  425 +
  426 +### 车辆历史GPS
  427 +----------
  428 +表名:BSTH_C_GPS_INFO
  429 +
  430 +| .. | .. | .. |
  431 +| ---- | ---- | ---- |
  432 +| cityCode | int | 城市代码 |
  433 +| industryCode | int | 行业代码 |
  434 +| companyCode | int | 企业代码 |
  435 +| lineId | int | 线路编号 |
  436 +| deviceId | string | 设备编号 |
  437 +| driverNo | int | 驾驶员工号 |
  438 +| carparkSerialNo | int | 停车场序列号 |
  439 +| carparkNo | string | 停车场编号 |
  440 +| stopSerialNo | int | 站点序列号 |
  441 +| stopNo | string | 停车场编号 |
  442 +| lon | float | 经度 |
  443 +| lat | float | 维度 |
  444 +| ts | long | 时间戳 |
  445 +| speedSensor | float | 发动机速度 |
  446 +| speedGps | float | gps速度 |
  447 +| direction | float | 角度0-359 |
  448 +| inTemp | int | 车内温度 |
  449 +| serviceState | long | 设备状态字 |
  450 +<<<<<<< HEAD
  451 +| daysYear | int | 对应年中的天数 为分区字段 查询一定要用此字段过滤 |
  452 +=======
  453 +| daysYear | int | 对应年中的天数 为分区字段 查询一定要用此字段过滤 |
  454 +
  455 +>>>>>>> af8ec3bedc8644f5813e9adab12a163e93cc7f50
src/main/java/com/bsth/controller/schedule/RerunController.java
1 -package com.bsth.controller.schedule;  
2 -  
3 -import com.bsth.controller.BaseController;  
4 -import com.bsth.entity.schedule.rule.RerunRule;  
5 -import com.bsth.repository.schedule.RerunRuleRepository;  
6 -import org.springframework.beans.factory.annotation.Autowired;  
7 -import org.springframework.web.bind.annotation.*;  
8 -  
9 -import java.util.Map;  
10 -  
11 -/**  
12 - * Created by xu on 16/10/20.  
13 - */  
14 -@RestController  
15 -@RequestMapping("rms")  
16 -public class RerunController extends BaseController<RerunRule, Long> {  
17 -  
18 - @Autowired  
19 - private RerunRuleRepository rerunRuleRepository;  
20 -  
21 - @Override  
22 - public RerunRule findById(@PathVariable("id") Long aLong) {  
23 - return super.findById(aLong);  
24 - }  
25 -  
26 - /**  
27 - * 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody  
28 - * @Title: save  
29 - * @Description: TODO(持久化对象)  
30 - * @param @param t  
31 - * @param @return 设定文件  
32 - * @return Map<String,Object> {status: 1(成功),-1(失败)}  
33 - * @throws  
34 - */  
35 - @RequestMapping(method = RequestMethod.POST)  
36 - public Map<String, Object> save(@RequestBody RerunRule t){  
37 - return baseService.save(t);  
38 - }  
39 -  
40 -} 1 +package com.bsth.controller.schedule;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.schedule.rule.RerunRule;
  5 +import com.bsth.repository.schedule.RerunRuleRepository;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.*;
  8 +
  9 +import java.util.Map;
  10 +
  11 +/**
  12 + * Created by xu on 16/10/20.
  13 + */
  14 +@RestController
  15 +@RequestMapping("rms")
  16 +public class RerunController extends BaseController<RerunRule, Long> {
  17 +
  18 + @Autowired
  19 + private RerunRuleRepository rerunRuleRepository;
  20 +
  21 + @Override
  22 + public RerunRule findById(@PathVariable("id") Long aLong) {
  23 + return rerunRuleRepository.findOneExtend(aLong);
  24 + }
  25 +
  26 + /**
  27 + * 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody
  28 + * @Title: save
  29 + * @Description: TODO(持久化对象)
  30 + * @param @param t
  31 + * @param @return 设定文件
  32 + * @return Map<String,Object> {status: 1(成功),-1(失败)}
  33 + * @throws
  34 + */
  35 + @RequestMapping(method = RequestMethod.POST)
  36 + public Map<String, Object> save(@RequestBody RerunRule t){
  37 + return baseService.save(t);
  38 + }
  39 +
  40 +
  41 +}
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
@@ -72,7 +72,8 @@ public class GpsRealData implements CommandLineRunner{ @@ -72,7 +72,8 @@ public class GpsRealData implements CommandLineRunner{
72 72
73 @Override 73 @Override
74 public void run(String... arg0) throws Exception { 74 public void run(String... arg0) throws Exception {
75 - //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 6, TimeUnit.SECONDS); 75 + logger.info("gpsDataLoader,20,6");
  76 + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 7, TimeUnit.SECONDS);
76 } 77 }
77 78
78 public GpsEntity add(GpsEntity gps) { 79 public GpsEntity add(GpsEntity gps) {
src/main/java/com/bsth/entity/schedule/rule/RerunRule.java
1 -package com.bsth.entity.schedule.rule;  
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.GuideboardInfo;  
7 -import com.bsth.entity.schedule.TTInfo;  
8 -import com.bsth.entity.sys.SysUser;  
9 -  
10 -import javax.persistence.*;  
11 -import java.util.Date;  
12 -  
13 -/**  
14 - * 套跑规则。  
15 - */  
16 -@Entity  
17 -@Table(name = "bsth_c_s_rerun_rule")  
18 -@NamedEntityGraphs({  
19 - @NamedEntityGraph(name = "dylp", attributeNodes = {  
20 - @NamedAttributeNode("rerunXl"),  
21 - @NamedAttributeNode("rerunTtinfo"),  
22 - @NamedAttributeNode("rerunLp"),  
23 - @NamedAttributeNode("useXl"),  
24 - @NamedAttributeNode("useLp"),  
25 - @NamedAttributeNode("useCarConfig"),  
26 - @NamedAttributeNode("useEmployeeConfig")  
27 - })  
28 -})  
29 -public class RerunRule {  
30 - /** 主键Id */  
31 - @Id  
32 - @GeneratedValue  
33 - private Long id;  
34 -  
35 - /** 套跑线路 */  
36 - @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
37 - private Line rerunXl;  
38 - /** 套跑时刻表 */  
39 - @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
40 - private TTInfo rerunTtinfo;  
41 - /** 套跑路牌 */  
42 - @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
43 - private GuideboardInfo rerunLp;  
44 - /** 套跑班次(时刻表明细ids,使用逗号连接) */  
45 - private String rerunTtinfodetailIds;  
46 -  
47 -  
48 - /** 套跑类型(dylp;对应路牌,dybc:对应班车) */  
49 - @Column(nullable = false)  
50 - private String rerunType;  
51 -  
52 - //--------- 对应路牌 ----------/  
53 - /** 使用线路 */  
54 - @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
55 - private Line useXl;  
56 - /** 使用路牌 */  
57 - @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
58 - private GuideboardInfo useLp;  
59 -  
60 - //--------- 对应班车 ----------/  
61 - /** 车辆配置 */  
62 - @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
63 - private CarConfigInfo useCarConfig;  
64 - /** 人员配置 */  
65 - @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
66 - private EmployeeConfigInfo useEmployeeConfig;  
67 -  
68 - /** 创建人 */  
69 - @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)  
70 - private SysUser createBy;  
71 - /** 修改人 */  
72 - @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)  
73 - private SysUser updateBy;  
74 - /** 创建日期 */  
75 - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")  
76 - private Date createDate;  
77 - /** 修改日期 */  
78 - @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")  
79 - private Date updateDate;  
80 -  
81 - public Long getId() {  
82 - return id;  
83 - }  
84 -  
85 - public void setId(Long id) {  
86 - this.id = id;  
87 - }  
88 -  
89 - public Line getRerunXl() {  
90 - return rerunXl;  
91 - }  
92 -  
93 - public void setRerunXl(Line rerunXl) {  
94 - this.rerunXl = rerunXl;  
95 - }  
96 -  
97 - public TTInfo getRerunTtinfo() {  
98 - return rerunTtinfo;  
99 - }  
100 -  
101 - public void setRerunTtinfo(TTInfo rerunTtinfo) {  
102 - this.rerunTtinfo = rerunTtinfo;  
103 - }  
104 -  
105 - public GuideboardInfo getRerunLp() {  
106 - return rerunLp;  
107 - }  
108 -  
109 - public void setRerunLp(GuideboardInfo rerunLp) {  
110 - this.rerunLp = rerunLp;  
111 - }  
112 -  
113 - public String getRerunTtinfodetailIds() {  
114 - return rerunTtinfodetailIds;  
115 - }  
116 -  
117 - public void setRerunTtinfodetailIds(String rerunTtinfodetailIds) {  
118 - this.rerunTtinfodetailIds = rerunTtinfodetailIds;  
119 - }  
120 -  
121 - public String getRerunType() {  
122 - return rerunType;  
123 - }  
124 -  
125 - public void setRerunType(String rerunType) {  
126 - this.rerunType = rerunType;  
127 - }  
128 -  
129 - public Line getUseXl() {  
130 - return useXl;  
131 - }  
132 -  
133 - public void setUseXl(Line useXl) {  
134 - this.useXl = useXl;  
135 - }  
136 -  
137 - public GuideboardInfo getUseLp() {  
138 - return useLp;  
139 - }  
140 -  
141 - public void setUseLp(GuideboardInfo useLp) {  
142 - this.useLp = useLp;  
143 - }  
144 -  
145 - public CarConfigInfo getUseCarConfig() {  
146 - return useCarConfig;  
147 - }  
148 -  
149 - public void setUseCarConfig(CarConfigInfo useCarConfig) {  
150 - this.useCarConfig = useCarConfig;  
151 - }  
152 -  
153 - public EmployeeConfigInfo getUseEmployeeConfig() {  
154 - return useEmployeeConfig;  
155 - }  
156 -  
157 - public void setUseEmployeeConfig(EmployeeConfigInfo useEmployeeConfig) {  
158 - this.useEmployeeConfig = useEmployeeConfig;  
159 - }  
160 -  
161 - public SysUser getCreateBy() {  
162 - return createBy;  
163 - }  
164 -  
165 - public void setCreateBy(SysUser createBy) {  
166 - this.createBy = createBy;  
167 - }  
168 -  
169 - public SysUser getUpdateBy() {  
170 - return updateBy;  
171 - }  
172 -  
173 - public void setUpdateBy(SysUser updateBy) {  
174 - this.updateBy = updateBy;  
175 - }  
176 -  
177 - public Date getCreateDate() {  
178 - return createDate;  
179 - }  
180 -  
181 - public void setCreateDate(Date createDate) {  
182 - this.createDate = createDate;  
183 - }  
184 -  
185 - public Date getUpdateDate() {  
186 - return updateDate;  
187 - }  
188 -  
189 - public void setUpdateDate(Date updateDate) {  
190 - this.updateDate = updateDate;  
191 - }  
192 -} 1 +package com.bsth.entity.schedule.rule;
  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.GuideboardInfo;
  7 +import com.bsth.entity.schedule.TTInfo;
  8 +import com.bsth.entity.sys.SysUser;
  9 +
  10 +import javax.persistence.*;
  11 +import java.util.Date;
  12 +
  13 +/**
  14 + * 套跑规则。
  15 + */
  16 +@Entity
  17 +@Table(name = "bsth_c_s_rerun_rule")
  18 +@NamedEntityGraphs({
  19 + @NamedEntityGraph(name = "dylp", attributeNodes = {
  20 + @NamedAttributeNode("rerunXl"),
  21 + @NamedAttributeNode("rerunTtinfo"),
  22 + @NamedAttributeNode("rerunLp"),
  23 + @NamedAttributeNode("useXl"),
  24 + @NamedAttributeNode("useLp"),
  25 + @NamedAttributeNode("useCarConfig"),
  26 + @NamedAttributeNode("useEmployeeConfig")
  27 +
  28 + // TODO:subgraph貌似没有用,再议
  29 +// subgraphs = {
  30 +// @NamedSubgraph(name = "useCarConfig", attributeNodes = {
  31 +// @NamedAttributeNode("xl"),
  32 +// @NamedAttributeNode("cl")
  33 +// }),
  34 +// @NamedSubgraph(name = "useEmployeeConfig", attributeNodes = {
  35 +// @NamedAttributeNode("jsy"),
  36 +// @NamedAttributeNode("spy"),
  37 +// @NamedAttributeNode("xl")
  38 +// })
  39 +// }
  40 + })
  41 +})
  42 +
  43 +
  44 +public class RerunRule {
  45 + /** 主键Id */
  46 + @Id
  47 + @GeneratedValue
  48 + private Long id;
  49 +
  50 + /** 套跑线路 */
  51 + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
  52 + private Line rerunXl;
  53 + /** 套跑时刻表 */
  54 + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
  55 + private TTInfo rerunTtinfo;
  56 + /** 套跑路牌 */
  57 + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
  58 + private GuideboardInfo rerunLp;
  59 + /** 套跑班次(时刻表明细ids,使用逗号连接) */
  60 + private String rerunTtinfodetailIds;
  61 +
  62 +
  63 + /** 套跑类型(dylp;对应路牌,dybc:对应班车) */
  64 + @Column(nullable = false)
  65 + private String rerunType;
  66 +
  67 + //--------- 对应路牌 ----------/
  68 + /** 使用线路 */
  69 + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
  70 + private Line useXl;
  71 + /** 使用路牌 */
  72 + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
  73 + private GuideboardInfo useLp;
  74 +
  75 + //--------- 对应班车 ----------/
  76 + /** 车辆配置 */
  77 + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
  78 + private CarConfigInfo useCarConfig;
  79 + /** 人员配置 */
  80 + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
  81 + private EmployeeConfigInfo useEmployeeConfig;
  82 +
  83 + /** 是否删除(标记) */
  84 + @Column(nullable = false)
  85 + private Boolean isCancel = false;
  86 +
  87 + /** 创建人 */
  88 + @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
  89 + private SysUser createBy;
  90 + /** 修改人 */
  91 + @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
  92 + private SysUser updateBy;
  93 + /** 创建日期 */
  94 + @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  95 + private Date createDate;
  96 + /** 修改日期 */
  97 + @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  98 + private Date updateDate;
  99 +
  100 + public Long getId() {
  101 + return id;
  102 + }
  103 +
  104 + public void setId(Long id) {
  105 + this.id = id;
  106 + }
  107 +
  108 + public Line getRerunXl() {
  109 + return rerunXl;
  110 + }
  111 +
  112 + public void setRerunXl(Line rerunXl) {
  113 + this.rerunXl = rerunXl;
  114 + }
  115 +
  116 + public TTInfo getRerunTtinfo() {
  117 + return rerunTtinfo;
  118 + }
  119 +
  120 + public void setRerunTtinfo(TTInfo rerunTtinfo) {
  121 + this.rerunTtinfo = rerunTtinfo;
  122 + }
  123 +
  124 + public GuideboardInfo getRerunLp() {
  125 + return rerunLp;
  126 + }
  127 +
  128 + public void setRerunLp(GuideboardInfo rerunLp) {
  129 + this.rerunLp = rerunLp;
  130 + }
  131 +
  132 + public String getRerunTtinfodetailIds() {
  133 + return rerunTtinfodetailIds;
  134 + }
  135 +
  136 + public void setRerunTtinfodetailIds(String rerunTtinfodetailIds) {
  137 + this.rerunTtinfodetailIds = rerunTtinfodetailIds;
  138 + }
  139 +
  140 + public String getRerunType() {
  141 + return rerunType;
  142 + }
  143 +
  144 + public void setRerunType(String rerunType) {
  145 + this.rerunType = rerunType;
  146 + }
  147 +
  148 + public Line getUseXl() {
  149 + return useXl;
  150 + }
  151 +
  152 + public void setUseXl(Line useXl) {
  153 + this.useXl = useXl;
  154 + }
  155 +
  156 + public GuideboardInfo getUseLp() {
  157 + return useLp;
  158 + }
  159 +
  160 + public void setUseLp(GuideboardInfo useLp) {
  161 + this.useLp = useLp;
  162 + }
  163 +
  164 + public CarConfigInfo getUseCarConfig() {
  165 + return useCarConfig;
  166 + }
  167 +
  168 + public void setUseCarConfig(CarConfigInfo useCarConfig) {
  169 + this.useCarConfig = useCarConfig;
  170 + }
  171 +
  172 + public EmployeeConfigInfo getUseEmployeeConfig() {
  173 + return useEmployeeConfig;
  174 + }
  175 +
  176 + public void setUseEmployeeConfig(EmployeeConfigInfo useEmployeeConfig) {
  177 + this.useEmployeeConfig = useEmployeeConfig;
  178 + }
  179 +
  180 + public SysUser getCreateBy() {
  181 + return createBy;
  182 + }
  183 +
  184 + public void setCreateBy(SysUser createBy) {
  185 + this.createBy = createBy;
  186 + }
  187 +
  188 + public SysUser getUpdateBy() {
  189 + return updateBy;
  190 + }
  191 +
  192 + public void setUpdateBy(SysUser updateBy) {
  193 + this.updateBy = updateBy;
  194 + }
  195 +
  196 + public Date getCreateDate() {
  197 + return createDate;
  198 + }
  199 +
  200 + public void setCreateDate(Date createDate) {
  201 + this.createDate = createDate;
  202 + }
  203 +
  204 + public Date getUpdateDate() {
  205 + return updateDate;
  206 + }
  207 +
  208 + public Boolean getIsCancel() {
  209 + return isCancel;
  210 + }
  211 +
  212 + public void setIsCancel(Boolean isCancel) {
  213 + this.isCancel = isCancel;
  214 + }
  215 +
  216 + public void setUpdateDate(Date updateDate) {
  217 + this.updateDate = updateDate;
  218 + }
  219 +}
src/main/java/com/bsth/repository/schedule/RerunRuleRepository.java
1 -package com.bsth.repository.schedule;  
2 -  
3 -import com.bsth.entity.schedule.rule.RerunRule;  
4 -import com.bsth.entity.schedule.rule.ScheduleRule1Flat;  
5 -import com.bsth.repository.BaseRepository;  
6 -import org.springframework.data.domain.Page;  
7 -import org.springframework.data.domain.Pageable;  
8 -import org.springframework.data.jpa.domain.Specification;  
9 -import org.springframework.data.jpa.repository.EntityGraph;  
10 -import org.springframework.data.jpa.repository.Query;  
11 -import org.springframework.stereotype.Repository;  
12 -  
13 -/**  
14 - * Created by xu on 16/10/18.  
15 - */  
16 -@Repository  
17 -public interface RerunRuleRepository extends BaseRepository<RerunRule, Long> {  
18 - @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH)  
19 - @Override  
20 - Page<RerunRule> findAll(Specification<RerunRule> spec, Pageable pageable);  
21 -  
22 - @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH)  
23 - @Query("select cc from RerunRule cc where cc.id=?1")  
24 - RerunRule findOneExtend(Long aLong);  
25 -} 1 +package com.bsth.repository.schedule;
  2 +
  3 +import com.bsth.entity.schedule.rule.RerunRule;
  4 +import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  5 +import com.bsth.repository.BaseRepository;
  6 +import org.springframework.data.domain.Page;
  7 +import org.springframework.data.domain.Pageable;
  8 +import org.springframework.data.jpa.domain.Specification;
  9 +import org.springframework.data.jpa.repository.EntityGraph;
  10 +import org.springframework.data.jpa.repository.Query;
  11 +import org.springframework.stereotype.Repository;
  12 +
  13 +/**
  14 + * Created by xu on 16/10/18.
  15 + */
  16 +@Repository
  17 +public interface RerunRuleRepository extends BaseRepository<RerunRule, Long> {
  18 + @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH)
  19 + @Override
  20 + Page<RerunRule> findAll(Specification<RerunRule> spec, Pageable pageable);
  21 +
  22 + @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH)
  23 + @Query("select cc from RerunRule cc where cc.id=?1")
  24 + RerunRule findOneExtend(Long aLong);
  25 +}
src/main/java/com/bsth/service/schedule/RerunService.java
1 -package com.bsth.service.schedule;  
2 -  
3 -import com.bsth.entity.schedule.rule.RerunRule;  
4 -import com.bsth.service.BaseService;  
5 -  
6 -/**  
7 - * Created by xu on 16/10/20.  
8 - */  
9 -public interface RerunService extends BaseService<RerunRule, Long> {  
10 -} 1 +package com.bsth.service.schedule;
  2 +
  3 +import com.bsth.entity.schedule.rule.RerunRule;
  4 +import com.bsth.service.BaseService;
  5 +
  6 +/**
  7 + * Created by xu on 16/10/20.
  8 + */
  9 +public interface RerunService extends BaseService<RerunRule, Long> {
  10 +}
src/main/java/com/bsth/service/schedule/RerunServiceImpl.java
1 -package com.bsth.service.schedule;  
2 -  
3 -import com.bsth.entity.schedule.rule.RerunRule;  
4 -import com.bsth.service.impl.BaseServiceImpl;  
5 -import org.springframework.stereotype.Service;  
6 -  
7 -/**  
8 - * Created by xu on 16/10/20.  
9 - */  
10 -@Service  
11 -public class RerunServiceImpl extends BaseServiceImpl<RerunRule, Long> implements RerunService {  
12 -} 1 +package com.bsth.service.schedule;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.schedule.rule.RerunRule;
  5 +import com.bsth.repository.schedule.RerunRuleRepository;
  6 +import com.bsth.service.impl.BaseServiceImpl;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import javax.transaction.Transactional;
  11 +import java.util.HashMap;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * Created by xu on 16/10/20.
  16 + */
  17 +@Service
  18 +public class RerunServiceImpl extends BaseServiceImpl<RerunRule, Long> implements RerunService {
  19 +
  20 + @Autowired
  21 + private RerunRuleRepository rerunRuleRepository;
  22 +
  23 + @Override
  24 + @Transactional
  25 + public Map<String, Object> delete(Long aLong) {
  26 + // 获取带作废的数据
  27 + RerunRule rerunRule = rerunRuleRepository.findOne(aLong);
  28 +
  29 + toogleIsCancel(rerunRule);
  30 +
  31 + Map<String, Object> map = new HashMap<>();
  32 + map.put("status", ResponseCode.SUCCESS);
  33 +
  34 + return map;
  35 +
  36 + }
  37 +
  38 + /**
  39 + * 撤销/作废切换。
  40 + * @param rerunRule
  41 + */
  42 + private void toogleIsCancel(RerunRule rerunRule) {
  43 + boolean isCancel = rerunRule.getIsCancel();
  44 + if (isCancel) {
  45 + rerunRule.setIsCancel(false);
  46 + } else {
  47 + rerunRule.setIsCancel(true);
  48 + }
  49 + }
  50 +}
src/main/java/com/bsth/websocket/handler/RealControlSocketHandler.java
@@ -9,6 +9,7 @@ import java.util.Set; @@ -9,6 +9,7 @@ import java.util.Set;
9 9
10 import org.slf4j.Logger; 10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
  12 +import org.springframework.context.annotation.Scope;
12 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
13 import org.springframework.web.socket.CloseStatus; 14 import org.springframework.web.socket.CloseStatus;
14 import org.springframework.web.socket.TextMessage; 15 import org.springframework.web.socket.TextMessage;
@@ -26,6 +27,7 @@ import com.google.common.collect.ArrayListMultimap; @@ -26,6 +27,7 @@ import com.google.common.collect.ArrayListMultimap;
26 * @author PanZhao 27 * @author PanZhao
27 */ 28 */
28 @Component 29 @Component
  30 +@Scope("prototype")
29 public class RealControlSocketHandler implements WebSocketHandler { 31 public class RealControlSocketHandler implements WebSocketHandler {
30 32
31 Logger logger = LoggerFactory.getLogger(this.getClass()); 33 Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -146,7 +148,7 @@ public class RealControlSocketHandler implements WebSocketHandler { @@ -146,7 +148,7 @@ public class RealControlSocketHandler implements WebSocketHandler {
146 //Set<String> uids = BasicData.lineCode2SocketUserMap.get(lineCode); 148 //Set<String> uids = BasicData.lineCode2SocketUserMap.get(lineCode);
147 //if(null == uids || uids.size() == 0) 149 //if(null == uids || uids.size() == 0)
148 // return; 150 // return;
149 - 151 +
150 TextMessage message = new TextMessage(msg.getBytes()); 152 TextMessage message = new TextMessage(msg.getBytes());
151 153
152 List<WebSocketSession> sessList = listenMap.get(lineCode); 154 List<WebSocketSession> sessList = listenMap.get(lineCode);
src/main/resources/application-prod.properties
@@ -23,6 +23,8 @@ spring.datasource.test-on-return=true @@ -23,6 +23,8 @@ spring.datasource.test-on-return=true
23 spring.datasource.test-while-idle=true 23 spring.datasource.test-while-idle=true
24 spring.datasource.validation-query=select 1 24 spring.datasource.validation-query=select 1
25 25
  26 +##
  27 +#222.66.0.204:5555
26 ##\u5B9E\u65F6gps 28 ##\u5B9E\u65F6gps
27 http.gps.real.url= http://192.168.40.82:8080/transport_server/rtgps/ 29 http.gps.real.url= http://192.168.40.82:8080/transport_server/rtgps/
28 ##\u6D88\u606F\u4E0B\u53D1 30 ##\u6D88\u606F\u4E0B\u53D1
src/main/resources/datatools/config-prod.properties
@@ -4,13 +4,13 @@ @@ -4,13 +4,13 @@
4 datatools.kettle_properties=/datatools/kettle.properties 4 datatools.kettle_properties=/datatools/kettle.properties
5 # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正) 5 # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正)
6 #数据库ip地址 6 #数据库ip地址
7 -datatools.kvars_dbip=192.168.168.171 7 +datatools.kvars_dbip=192.168.40.82
8 #数据库用户名 8 #数据库用户名
9 datatools.kvars_dbuname=root 9 datatools.kvars_dbuname=root
10 #数据库密码 10 #数据库密码
11 -datatools.kvars_dbpwd=root2jsp 11 +datatools.kvars_dbpwd=123456
12 #数据库库名 12 #数据库库名
13 -datatools.kvars_dbdname=control 13 +datatools.kvars_dbdname=qp_control
14 14
15 # 3、上传数据配置信息 15 # 3、上传数据配置信息
16 # 上传文件目录配置(根据不同的环境需要修正) 16 # 上传文件目录配置(根据不同的环境需要修正)
src/main/resources/ms-jdbc.properties
  1 +#ms.mysql.driver= com.mysql.jdbc.Driver
  2 +#ms.mysql.url= jdbc:mysql://192.168.40.82:3306/ms?useUnicode=true&characterEncoding=utf-8
  3 +#ms.mysql.username= root
  4 +#ms.mysql.password= 123456
  5 +
1 ms.mysql.driver= com.mysql.jdbc.Driver 6 ms.mysql.driver= com.mysql.jdbc.Driver
2 ms.mysql.url= jdbc:mysql://192.168.168.201:3306/ms?useUnicode=true&characterEncoding=utf-8 7 ms.mysql.url= jdbc:mysql://192.168.168.201:3306/ms?useUnicode=true&characterEncoding=utf-8
3 ms.mysql.username= root 8 ms.mysql.username= root
4 ms.mysql.password= 123456 9 ms.mysql.password= 123456
5 -  
6 -#ms.mysql.driver= com.mysql.jdbc.Driver  
7 -#ms.mysql.url= jdbc:mysql://192.168.40.82:3306/ms?useUnicode=true&characterEncoding=utf-8  
8 -#ms.mysql.username= root  
9 -#ms.mysql.password= 123456  
10 \ No newline at end of file 10 \ No newline at end of file
src/main/resources/static/assets/img/bg_9b9dcb65ff.png

5.9 KB | W: | H:

17.4 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
src/main/resources/static/assets/img/login_bgcenter.png

37.4 KB | W: | H:

40.8 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
src/main/resources/static/pages/control/line/js/webSocketHandle.js
@@ -157,7 +157,7 @@ function appendLogItem(tempId, json, lineCode){ @@ -157,7 +157,7 @@ function appendLogItem(tempId, json, lineCode){
157 var text = $item.find('.log-item-text').text(); 157 var text = $item.find('.log-item-text').text();
158 //线路名称 158 //线路名称
159 var lineName = _data.getLineIds()[lineCode]; 159 var lineName = _data.getLineIds()[lineCode];
160 - h5Speech.speak(lineName.replace('行', '航') + ' ' + text); 160 + h5Speech.speak(lineName + ' ' + text);
161 } 161 }
162 //重新计算未处理消息 162 //重新计算未处理消息
163 _messenger.setUntreatedNum(lineCode); 163 _messenger.setUntreatedNum(lineCode);
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/MyUISelectWrapTemplate2.html
1 -<div class="input-group" name="指令compile阶段设定"  
2 - ng-model="$saSelectCtrl.$$internalmodel">  
3 - <ui-select ng-model="$saSelectCtrl.$$internal_select_value" on-select="$saSelectCtrl.$$internal_select_fn($item)"  
4 - theme="bootstrap" >  
5 - <ui-select-match placeholder="指令compile阶段设定">指令compile阶段设定</ui-select-match>  
6 - <ui-select-choices repeat="指令compile阶段设定"  
7 - refresh="$saSelectCtrl.$$internal_refresh_fn($select.search)"  
8 - refresh-delay="10">  
9 - <span ng-bind="指令compile阶段设定"></span>  
10 - </ui-select-choices>  
11 - </ui-select>  
12 - <span class="input-group-btn">  
13 - <button type="button" ng-click="$saSelectCtrl.$$internal_remove_fn()" class="btn btn-default">  
14 - <span class="glyphicon glyphicon-trash"></span>  
15 - </button>  
16 - </span> 1 +<div class="input-group" name="指令compile阶段设定"
  2 + ng-model="$saSelectCtrl.$$internalmodel">
  3 + <ui-select ng-model="$saSelectCtrl.$$internal_select_value" on-select="$saSelectCtrl.$$internal_select_fn($item)"
  4 + theme="bootstrap" >
  5 + <ui-select-match placeholder="指令compile阶段设定">指令compile阶段设定</ui-select-match>
  6 + <ui-select-choices repeat="指令compile阶段设定"
  7 + refresh="$saSelectCtrl.$$internal_refresh_fn($select.search)"
  8 + refresh-delay="10">
  9 + <span ng-bind="指令compile阶段设定"></span>
  10 + </ui-select-choices>
  11 + </ui-select>
  12 + <span class="input-group-btn">
  13 + <button type="button" ng-click="$saSelectCtrl.$$internal_remove_fn()" class="btn btn-default">
  14 + <span class="glyphicon glyphicon-trash"></span>
  15 + </button>
  16 + </span>
17 </div> 17 </div>
18 \ No newline at end of file 18 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/legacy.txt
1 -/**  
2 - * saSelect4指令,封装angular-ui-select控件,并添加相应的业务。  
3 - * name(必须):控件的名字  
4 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
5 - * placeholder(可选):输入框占位符字符串  
6 - *  
7 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
8 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
9 - * icname(必须):内部与之对应的字段名,如:icname=code  
10 - *  
11 - * cmaps(可选):model其他字段和内部数据字段名映射,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}}  
12 - * dsparams(必须):内部数据源查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}  
13 - * dscol(必须):内部显示的信息(暂时用内部字段),如:dscol=name  
14 - * required(可选):是否要用required验证  
15 - */  
16 -angular.module('ScheduleApp').directive('saSelect4', [  
17 - '$timeout',  
18 - '$$SearchInfoService_g',  
19 - function($timeout, $$searchInfoService_g) {  
20 - return {  
21 - restrict: 'E',  
22 - templateUrl: '/pages/scheduleApp/module/common/dts1/select/MyUISelectWrapTemplate2.html',  
23 - scope: {  
24 - model: "=" // 独立作用域,关联外部的模型object  
25 - },  
26 - controllerAs: "$saSelectCtrl",  
27 - bindToController: true,  
28 - controller: function($scope) {  
29 - var self = this;  
30 - self.$$data = []; // ui-select显示用的数据  
31 - self.$$data_real = []; // 内部真实的数据  
32 -  
33 - // saSelect4组件的ng-model,用于外部绑定验证等操作  
34 - self.$$internalmodel = undefined;  
35 -  
36 - self.$$internal_select_value = undefined; // 选中的值  
37 - },  
38 -  
39 - /**  
40 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
41 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
42 - * @param tElem  
43 - * @param tAttrs  
44 - * @returns {{pre: Function, post: Function}}  
45 - */  
46 - compile: function(tElem, tAttrs) {  
47 - // 获取属性  
48 - var $name_attr = tAttrs["name"]; // 控件的名字  
49 - var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字  
50 -  
51 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
52 - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名  
53 -  
54 - var $cmaps_attr = tAttrs["cmaps"]; // model其他字段和内部数据字段名映射  
55 - var $dscol_attr = tAttrs["dscol"]; // 内部显示的信息  
56 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
57 -  
58 - // controlAs名字  
59 - var ctrlAs = "$saSelectCtrl";  
60 -  
61 - // 验证属性  
62 - if (!$name_attr) {  
63 - throw new error("name属性必须填写");  
64 - }  
65 - if (!$dcname_attr) {  
66 - throw new error("dcname属性必须填写");  
67 - }  
68 - if (!$icname_attr) {  
69 - throw new error("icname属性必须填写");  
70 - }  
71 - if (!$dscol_attr) {  
72 - throw new error("dscol属性必须填写");  
73 - }  
74 -  
75 - // 动态设置dom  
76 - // dom required 属性  
77 - if ($required_attr != undefined) {  
78 - tElem.find("div").attr("required", "");  
79 - }  
80 - // dom placeholder 属性  
81 - tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);  
82 - // dom dscol 属性  
83 - tElem.find("ui-select-match").html("{{$select.selected" + "." + $dscol_attr + "}}");  
84 - tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $dscol_attr);  
85 - // dom icname 属性  
86 - tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");  
87 - // dom name 属性  
88 - tElem.find("div").attr("name", $name_attr);  
89 -  
90 - return {  
91 - pre: function(scope, element, attr) {  
92 - // TODO:  
93 - },  
94 -  
95 - /**  
96 - * 相当于link函数。  
97 - * @param scope  
98 - * @param element  
99 - * @param attr  
100 - */  
101 - post: function(scope, element, attr) {  
102 -  
103 - // 添加选中事件处理函数  
104 - scope[ctrlAs].$$internal_select_fn = function($item) {  
105 - if ($dcname_attr && $icname_attr) {  
106 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");  
107 - }  
108 -  
109 - if ($cmaps_attr) {  
110 - for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名  
111 - var ic = $cmaps_attr[mc]; // 内部数据源对应字段  
112 - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");  
113 - }  
114 - }  
115 - };  
116 -  
117 - // 删除选中事件处理函数  
118 - scope[ctrlAs].$$internal_remove_fn = function() {  
119 - scope[ctrlAs].$$internal_select_value = undefined;  
120 - if ($dcname_attr) {  
121 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");  
122 - }  
123 -  
124 - if ($cmaps_attr) {  
125 - var mc; // model的字段名  
126 - for (mc in $cmaps_attr) {  
127 - eval("scope[ctrlAs].model" + "." + mc + " = undefined;");  
128 - }  
129 - }  
130 - scope[ctrlAs].$$internal_validate_model();  
131 - };  
132 -  
133 - // 刷新数据  
134 - scope[ctrlAs].$$internal_refresh_fn = function(search) {  
135 - if (search && search != "") { // 有search值  
136 - // 处理search  
137 - console.log("search:" + search);  
138 -  
139 - scope[ctrlAs].$$data = [];  
140 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
141 - var upTerm = search.toUpperCase();  
142 - if (scope[ctrlAs].$$data.length < 10) {  
143 - if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1  
144 - || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {  
145 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
146 - }  
147 - } else {  
148 - break;  
149 - }  
150 - }  
151 - }  
152 - };  
153 -  
154 - /**  
155 - * 验证内部数据,更新外部model  
156 - */  
157 - scope[ctrlAs].$$internal_validate_model = function() {  
158 - if (scope[ctrlAs].$$internal_select_value) {  
159 - var select_value_temp = scope[ctrlAs].$$internal_select_value;  
160 - if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {  
161 - var obj;  
162 - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {  
163 - if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {  
164 - obj = angular.copy(scope[ctrlAs].$$data_real[j]);  
165 - break;  
166 - }  
167 - }  
168 - if (obj) { // 在data中判定有没有  
169 - for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {  
170 - if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {  
171 - obj = undefined;  
172 - break;  
173 - }  
174 - }  
175 - if (obj) {  
176 - scope[ctrlAs].$$data.push(obj);  
177 - }  
178 - // 更新内部model,用于外部验证  
179 - // 内部model的值暂时随意,以后再改  
180 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
181 - } else {  
182 - scope[ctrlAs].$$internalmodel = undefined;  
183 - }  
184 -  
185 - } else {  
186 - scope[ctrlAs].$$internalmodel = undefined;  
187 - }  
188 -  
189 - } else {  
190 - scope[ctrlAs].$$internalmodel = undefined;  
191 - }  
192 - };  
193 -  
194 - /**  
195 - * 内部方法,读取字典数据作为数据源。  
196 - * @param atype ajax查询类型  
197 - * @param ajaxparamobj 查询参数对象  
198 - */  
199 - scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {  
200 - ajaxparamobj.type = 'all';  
201 - $$searchInfoService_g[atype].list(  
202 - ajaxparamobj,  
203 - function(result) {  
204 - console.log("$$internal_ajax_data result");  
205 -  
206 - // 清空内部数据  
207 - scope[ctrlAs].$$data_real = [];  
208 - scope[ctrlAs].$$data = [];  
209 -  
210 - // result中添加拼音数据,注意:这里要求result返回对象数组  
211 - for (var i = 0; i < result.length; i ++) {  
212 - if ($dscol_attr) {  
213 - if (eval("result[i]" + "." + $dscol_attr)) {  
214 - // 全拼  
215 - result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $dscol_attr)).toUpperCase();  
216 - // 简拼  
217 - result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $dscol_attr));  
218 - }  
219 - }  
220 -  
221 - if (result[i]["fullChars"]) { // 有拼音的加入数据源  
222 - scope[ctrlAs].$$data_real.push(result[i]);  
223 - }  
224 -  
225 - }  
226 -  
227 - // 数据量太大,取10条记录显示  
228 - if (angular.isArray(scope[ctrlAs].$$data_real)) {  
229 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
230 - if (scope[ctrlAs].$$data.length < 10) {  
231 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
232 - } else {  
233 - break;  
234 - }  
235 - }  
236 - }  
237 -  
238 - scope[ctrlAs].$$internal_validate_model();  
239 - },  
240 - function(result) {  
241 -  
242 - }  
243 - );  
244 - };  
245 -  
246 - /**  
247 - * 内部方法,读取字典数据作为数据源。  
248 - * @param dictype 字典类型,如:gsType  
249 - */  
250 - scope[ctrlAs].$$internal_dic_data = function(dictype) {  
251 - if (!dictionaryUtils.getByGroup(dictype)) {  
252 - throw new error("字典数据不窜在=" + dictype);  
253 - }  
254 -  
255 - // 清空内部数据  
256 - scope[ctrlAs].$$data_real = [];  
257 - scope[ctrlAs].$$data = [];  
258 -  
259 - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);  
260 - var dic_key; // 字典key  
261 -  
262 - for (dic_key in origin_dicgroup) {  
263 - var data = {}; // 重新组合的字典元素对象  
264 - if (dic_key == "true")  
265 - data[$icname_attr] = true;  
266 - else  
267 - data[$icname_attr] = dic_key;  
268 - data[$dscol_attr] = origin_dicgroup[dic_key];  
269 - scope[ctrlAs].$$data_real.push(data);  
270 - }  
271 - // 这里直接将$$data_real数据深拷贝到$$data  
272 - angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);  
273 - scope[ctrlAs].$$internal_validate_model();  
274 - };  
275 -  
276 - attr.$observe("dsparams", function(value) {  
277 - if (value && value != "") {  
278 - var obj = JSON.parse(value);  
279 - console.log("observe 监控 dsparams=" + obj);  
280 -  
281 - // dsparams格式如下:  
282 - // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}  
283 -  
284 - if (obj.type == 'dic') {  
285 - scope[ctrlAs].$$internal_dic_data(obj.param);  
286 -  
287 - } else if (obj.type == 'ajax') {  
288 - scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);  
289 - } else {  
290 - throw new Error("dsparams参数格式异常=" + obj);  
291 - }  
292 -  
293 - }  
294 -  
295 - });  
296 -  
297 - // 监控model绑定的dcvalue值变化  
298 - attr.$observe("dcvalue", function(value) {  
299 - if (value && value != "") {  
300 - console.log("observe 监控 dcvalue=" + value);  
301 - scope[ctrlAs].$$internal_select_value = value;  
302 - scope[ctrlAs].$$internal_validate_model();  
303 - }  
304 - });  
305 - }  
306 - };  
307 -  
308 - }  
309 -  
310 - };  
311 - } 1 +/**
  2 + * saSelect4指令,封装angular-ui-select控件,并添加相应的业务。
  3 + * name(必须):控件的名字
  4 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  5 + * placeholder(可选):输入框占位符字符串
  6 + *
  7 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  8 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  9 + * icname(必须):内部与之对应的字段名,如:icname=code
  10 + *
  11 + * cmaps(可选):model其他字段和内部数据字段名映射,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}}
  12 + * dsparams(必须):内部数据源查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}
  13 + * dscol(必须):内部显示的信息(暂时用内部字段),如:dscol=name
  14 + * required(可选):是否要用required验证
  15 + */
  16 +angular.module('ScheduleApp').directive('saSelect4', [
  17 + '$timeout',
  18 + '$$SearchInfoService_g',
  19 + function($timeout, $$searchInfoService_g) {
  20 + return {
  21 + restrict: 'E',
  22 + templateUrl: '/pages/scheduleApp/module/common/dts1/select/MyUISelectWrapTemplate2.html',
  23 + scope: {
  24 + model: "=" // 独立作用域,关联外部的模型object
  25 + },
  26 + controllerAs: "$saSelectCtrl",
  27 + bindToController: true,
  28 + controller: function($scope) {
  29 + var self = this;
  30 + self.$$data = []; // ui-select显示用的数据
  31 + self.$$data_real = []; // 内部真实的数据
  32 +
  33 + // saSelect4组件的ng-model,用于外部绑定验证等操作
  34 + self.$$internalmodel = undefined;
  35 +
  36 + self.$$internal_select_value = undefined; // 选中的值
  37 + },
  38 +
  39 + /**
  40 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  41 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  42 + * @param tElem
  43 + * @param tAttrs
  44 + * @returns {{pre: Function, post: Function}}
  45 + */
  46 + compile: function(tElem, tAttrs) {
  47 + // 获取属性
  48 + var $name_attr = tAttrs["name"]; // 控件的名字
  49 + var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字
  50 +
  51 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  52 + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名
  53 +
  54 + var $cmaps_attr = tAttrs["cmaps"]; // model其他字段和内部数据字段名映射
  55 + var $dscol_attr = tAttrs["dscol"]; // 内部显示的信息
  56 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  57 +
  58 + // controlAs名字
  59 + var ctrlAs = "$saSelectCtrl";
  60 +
  61 + // 验证属性
  62 + if (!$name_attr) {
  63 + throw new error("name属性必须填写");
  64 + }
  65 + if (!$dcname_attr) {
  66 + throw new error("dcname属性必须填写");
  67 + }
  68 + if (!$icname_attr) {
  69 + throw new error("icname属性必须填写");
  70 + }
  71 + if (!$dscol_attr) {
  72 + throw new error("dscol属性必须填写");
  73 + }
  74 +
  75 + // 动态设置dom
  76 + // dom required 属性
  77 + if ($required_attr != undefined) {
  78 + tElem.find("div").attr("required", "");
  79 + }
  80 + // dom placeholder 属性
  81 + tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);
  82 + // dom dscol 属性
  83 + tElem.find("ui-select-match").html("{{$select.selected" + "." + $dscol_attr + "}}");
  84 + tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $dscol_attr);
  85 + // dom icname 属性
  86 + tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");
  87 + // dom name 属性
  88 + tElem.find("div").attr("name", $name_attr);
  89 +
  90 + return {
  91 + pre: function(scope, element, attr) {
  92 + // TODO:
  93 + },
  94 +
  95 + /**
  96 + * 相当于link函数。
  97 + * @param scope
  98 + * @param element
  99 + * @param attr
  100 + */
  101 + post: function(scope, element, attr) {
  102 +
  103 + // 添加选中事件处理函数
  104 + scope[ctrlAs].$$internal_select_fn = function($item) {
  105 + if ($dcname_attr && $icname_attr) {
  106 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  107 + }
  108 +
  109 + if ($cmaps_attr) {
  110 + for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名
  111 + var ic = $cmaps_attr[mc]; // 内部数据源对应字段
  112 + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  113 + }
  114 + }
  115 + };
  116 +
  117 + // 删除选中事件处理函数
  118 + scope[ctrlAs].$$internal_remove_fn = function() {
  119 + scope[ctrlAs].$$internal_select_value = undefined;
  120 + if ($dcname_attr) {
  121 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  122 + }
  123 +
  124 + if ($cmaps_attr) {
  125 + var mc; // model的字段名
  126 + for (mc in $cmaps_attr) {
  127 + eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  128 + }
  129 + }
  130 + scope[ctrlAs].$$internal_validate_model();
  131 + };
  132 +
  133 + // 刷新数据
  134 + scope[ctrlAs].$$internal_refresh_fn = function(search) {
  135 + if (search && search != "") { // 有search值
  136 + // 处理search
  137 + console.log("search:" + search);
  138 +
  139 + scope[ctrlAs].$$data = [];
  140 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  141 + var upTerm = search.toUpperCase();
  142 + if (scope[ctrlAs].$$data.length < 10) {
  143 + if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1
  144 + || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {
  145 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  146 + }
  147 + } else {
  148 + break;
  149 + }
  150 + }
  151 + }
  152 + };
  153 +
  154 + /**
  155 + * 验证内部数据,更新外部model
  156 + */
  157 + scope[ctrlAs].$$internal_validate_model = function() {
  158 + if (scope[ctrlAs].$$internal_select_value) {
  159 + var select_value_temp = scope[ctrlAs].$$internal_select_value;
  160 + if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {
  161 + var obj;
  162 + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {
  163 + if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {
  164 + obj = angular.copy(scope[ctrlAs].$$data_real[j]);
  165 + break;
  166 + }
  167 + }
  168 + if (obj) { // 在data中判定有没有
  169 + for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {
  170 + if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {
  171 + obj = undefined;
  172 + break;
  173 + }
  174 + }
  175 + if (obj) {
  176 + scope[ctrlAs].$$data.push(obj);
  177 + }
  178 + // 更新内部model,用于外部验证
  179 + // 内部model的值暂时随意,以后再改
  180 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  181 + } else {
  182 + scope[ctrlAs].$$internalmodel = undefined;
  183 + }
  184 +
  185 + } else {
  186 + scope[ctrlAs].$$internalmodel = undefined;
  187 + }
  188 +
  189 + } else {
  190 + scope[ctrlAs].$$internalmodel = undefined;
  191 + }
  192 + };
  193 +
  194 + /**
  195 + * 内部方法,读取字典数据作为数据源。
  196 + * @param atype ajax查询类型
  197 + * @param ajaxparamobj 查询参数对象
  198 + */
  199 + scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {
  200 + ajaxparamobj.type = 'all';
  201 + $$searchInfoService_g[atype].list(
  202 + ajaxparamobj,
  203 + function(result) {
  204 + console.log("$$internal_ajax_data result");
  205 +
  206 + // 清空内部数据
  207 + scope[ctrlAs].$$data_real = [];
  208 + scope[ctrlAs].$$data = [];
  209 +
  210 + // result中添加拼音数据,注意:这里要求result返回对象数组
  211 + for (var i = 0; i < result.length; i ++) {
  212 + if ($dscol_attr) {
  213 + if (eval("result[i]" + "." + $dscol_attr)) {
  214 + // 全拼
  215 + result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $dscol_attr)).toUpperCase();
  216 + // 简拼
  217 + result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $dscol_attr));
  218 + }
  219 + }
  220 +
  221 + if (result[i]["fullChars"]) { // 有拼音的加入数据源
  222 + scope[ctrlAs].$$data_real.push(result[i]);
  223 + }
  224 +
  225 + }
  226 +
  227 + // 数据量太大,取10条记录显示
  228 + if (angular.isArray(scope[ctrlAs].$$data_real)) {
  229 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  230 + if (scope[ctrlAs].$$data.length < 10) {
  231 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  232 + } else {
  233 + break;
  234 + }
  235 + }
  236 + }
  237 +
  238 + scope[ctrlAs].$$internal_validate_model();
  239 + },
  240 + function(result) {
  241 +
  242 + }
  243 + );
  244 + };
  245 +
  246 + /**
  247 + * 内部方法,读取字典数据作为数据源。
  248 + * @param dictype 字典类型,如:gsType
  249 + */
  250 + scope[ctrlAs].$$internal_dic_data = function(dictype) {
  251 + if (!dictionaryUtils.getByGroup(dictype)) {
  252 + throw new error("字典数据不窜在=" + dictype);
  253 + }
  254 +
  255 + // 清空内部数据
  256 + scope[ctrlAs].$$data_real = [];
  257 + scope[ctrlAs].$$data = [];
  258 +
  259 + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);
  260 + var dic_key; // 字典key
  261 +
  262 + for (dic_key in origin_dicgroup) {
  263 + var data = {}; // 重新组合的字典元素对象
  264 + if (dic_key == "true")
  265 + data[$icname_attr] = true;
  266 + else
  267 + data[$icname_attr] = dic_key;
  268 + data[$dscol_attr] = origin_dicgroup[dic_key];
  269 + scope[ctrlAs].$$data_real.push(data);
  270 + }
  271 + // 这里直接将$$data_real数据深拷贝到$$data
  272 + angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);
  273 + scope[ctrlAs].$$internal_validate_model();
  274 + };
  275 +
  276 + attr.$observe("dsparams", function(value) {
  277 + if (value && value != "") {
  278 + var obj = JSON.parse(value);
  279 + console.log("observe 监控 dsparams=" + obj);
  280 +
  281 + // dsparams格式如下:
  282 + // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}
  283 +
  284 + if (obj.type == 'dic') {
  285 + scope[ctrlAs].$$internal_dic_data(obj.param);
  286 +
  287 + } else if (obj.type == 'ajax') {
  288 + scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);
  289 + } else {
  290 + throw new Error("dsparams参数格式异常=" + obj);
  291 + }
  292 +
  293 + }
  294 +
  295 + });
  296 +
  297 + // 监控model绑定的dcvalue值变化
  298 + attr.$observe("dcvalue", function(value) {
  299 + if (value && value != "") {
  300 + console.log("observe 监控 dcvalue=" + value);
  301 + scope[ctrlAs].$$internal_select_value = value;
  302 + scope[ctrlAs].$$internal_validate_model();
  303 + }
  304 + });
  305 + }
  306 + };
  307 +
  308 + }
  309 +
  310 + };
  311 + }
312 ]); 312 ]);
313 \ No newline at end of file 313 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect5.js
1 -/**  
2 - * saSelect5指令,基于简拼查询的select,内部封装angular-ui-select控件,并嵌入相应的业务逻辑。  
3 - * name(必须):控件的名字  
4 - * model(必须):独立作用域,指定一个外部对象模型双向绑定,如:model=ctrl.employeeInfoForSave  
5 - * cmaps(必须):外部对象与指令内部数据对象字段名映射对象,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}}  
6 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
7 - * icname(必须):内部与之对应的字段名,如:icname=id  
8 - *  
9 - * dsparams(必须):内部数据源查询参数对象,如:{{ {'ttid_eq': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}  
10 - * iterobjname(必须):内部数据源迭代的数据变量名,如:iterobjname=item  
11 - * iterobjexp(必须):内部显示用的表达式  
12 - * searchph(必须):查询输入占位符字符串,如:searchph=请输入...  
13 - * searchexp(必须):查询基于的内部数据源的表达式,如:searchexp=this.name+'('+this.code+')'  
14 - *  
15 - * required(可选):是否需要form的required验证  
16 - *  
17 - */  
18 -angular.module('ScheduleApp').directive('saSelect5', [  
19 - '$timeout',  
20 - '$$SearchInfoService_g',  
21 - function($timeout, $$searchInfoService_g) {  
22 - return {  
23 - restrict: 'E',  
24 - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect5Template.html',  
25 - scope: { // 独立作用域  
26 - model: "=" // 绑定外部对象  
27 - },  
28 - controllerAs: "$saSelectCtrl",  
29 - bindToController: true,  
30 - controller: function($scope) {  
31 - var self = this;  
32 - self.$$data = []; // 内部ui-select显示用数据  
33 - self.$$data_real = []; // 内部保存的实际数据  
34 -  
35 - // myselect组件的ng-model,用于外部绑定验证等操作  
36 - self.$$internalmodel = undefined;  
37 -  
38 - self.$$internal_select_value = undefined; // 选中的值  
39 -  
40 - },  
41 -  
42 - /**  
43 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
44 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
45 - * @param tElem  
46 - * @param tAttrs  
47 - * @returns {{pre: Function, post: Function}}  
48 - */  
49 - compile: function(tElem, tAttrs) {  
50 - // 获取属性,并验证必须按属性  
51 - var $name_attr = tAttrs["name"]; // 控件的名字  
52 - var $cmaps_attr = tAttrs["cmaps"]; // 外部对象与指令内部数据对象字段名映射对象  
53 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
54 - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名  
55 -  
56 - var $dsparams_attr = tAttrs["dsparams"]; // 内部数据源查询参数对象  
57 - var $iterobjname_attr = tAttrs["iterobjname"]; // 内部数据源迭代的数据变量名  
58 - var $iterobjexp_attr = tAttrs["iterobjexp"]; // 内部显示用的表达式  
59 - var $searchph_attr = tAttrs["searchph"]; // 查询输入占位符字符串  
60 - var $searchexp_attr = tAttrs["searchexp"]; // 查询基于的内部数据源的表达式  
61 -  
62 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
63 -  
64 - if (!$name_attr) {  
65 - throw new Error("name属性必须填写");  
66 - }  
67 - if (!$cmaps_attr) {  
68 - throw new Error("cmaps属性必须填写")  
69 - }  
70 - if (!$dcname_attr || !$icname_attr) {  
71 - throw new Error("dcname、icname属性必须填写");  
72 - }  
73 - if (!$dsparams_attr) {  
74 - throw new Error("dsparams属性必须填写");  
75 - }  
76 - if (!$iterobjname_attr) {  
77 - throw new Error("iterobjname属性必须填写");  
78 - }  
79 - if (!$iterobjexp_attr) {  
80 - throw new Error("iterobjexp属性必须填写");  
81 - }  
82 - if (!$searchph_attr) {  
83 - throw new Error("searchph属性必须填写");  
84 - }  
85 - if (!$searchexp_attr) {  
86 - throw new Error("searchexp属性必须填写");  
87 - }  
88 -  
89 - // 内部controlAs名字  
90 - var ctrlAs = "$saSelectCtrl";  
91 -  
92 - // 动态设置dom  
93 - // dom,最外层name属性设置  
94 - tElem.find("div:first").attr("name", $name_attr);  
95 - // dom,最外层divrequired属性设置  
96 - if ($required_attr != undefined) {  
97 - tElem.find("div[name=\'" + $name_attr + "\']").attr("required", "");  
98 - }  
99 - // dom,ui-select-match的placeholder属性设定  
100 - tElem.find("ui-select-match").attr("placeholder", $searchph_attr);  
101 - // dom,ui-select-match的内容设定  
102 - var uiSelectMatchHtml = "{{" + ctrlAs + ".$$internal_match_str($select.selected)}}";  
103 - tElem.find("ui-select-match").html(uiSelectMatchHtml);  
104 - // dom,ui-select-choices的repeat属性设定  
105 - var uiSelectChoices_repeatAttr = $iterobjname_attr + "." + $icname_attr + " as " + $iterobjname_attr + " in " + ctrlAs + ".$$data";  
106 - tElem.find("ui-select-choices").attr("repeat", uiSelectChoices_repeatAttr);  
107 - // dom,span ng-bind属性设置,TODO:暂时无法用transclude设置,先用属性设置  
108 - tElem.find("ui-select-choices").html("{{" + $iterobjexp_attr + "}}");  
109 -  
110 - return {  
111 - pre: function (scope, element, attr) {  
112 - // TODO:  
113 - },  
114 -  
115 - /**  
116 - * 相当于link函数。  
117 - * @param scope  
118 - * @param element  
119 - * @param attr  
120 - */  
121 - post: function (scope, element, attr) {  
122 -  
123 - // 添加选中事件处理函数  
124 - scope[ctrlAs].$$internal_select_fn = function($item) {  
125 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");  
126 -  
127 - for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名  
128 - var ic = $cmaps_attr[mc]; // 内部数据源对应字段  
129 - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");  
130 - }  
131 - };  
132 -  
133 - // 删除选中事件处理函数  
134 - scope[ctrlAs].$$internal_remove_fn = function() {  
135 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");  
136 -  
137 - var mc; // model的字段名  
138 - for (mc in $cmaps_attr) {  
139 - eval("scope[ctrlAs].model" + "." + mc + " = undefined;");  
140 - }  
141 - };  
142 -  
143 - // 刷新数据  
144 - scope[ctrlAs].$$internal_refresh_fn = function(search) {  
145 - if (search && search != "") { // 有search值  
146 - // 处理search  
147 - console.log("search:" + search);  
148 -  
149 - scope[ctrlAs].$$data = [];  
150 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
151 - var upTerm = search.toUpperCase();  
152 - if (scope[ctrlAs].$$data.length < 10) {  
153 - if (scope[ctrlAs].$$data_real[k].$fullChars.indexOf(upTerm) != -1  
154 - || scope[ctrlAs].$$data_real[k].$camelChars.indexOf(upTerm) != -1  
155 - || scope[ctrlAs].$$data_real[k].$calcu_str.indexOf(upTerm) != -1) {  
156 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
157 - }  
158 - } else {  
159 - break;  
160 - }  
161 - }  
162 - }  
163 - };  
164 -  
165 - /**  
166 - * 验证内部数据,更新外部model  
167 - */  
168 - scope[ctrlAs].$$internal_validate_model = function() {  
169 - if (scope[ctrlAs].$$internal_select_value) {  
170 - var select_value_temp = scope[ctrlAs].$$internal_select_value;  
171 - if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {  
172 - var obj;  
173 - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {  
174 - if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {  
175 - obj = angular.copy(scope[ctrlAs].$$data_real[j]);  
176 - break;  
177 - }  
178 - }  
179 - if (obj) { // 在data中判定有没有  
180 - for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {  
181 - if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {  
182 - obj = undefined;  
183 - break;  
184 - }  
185 - }  
186 - if (obj) {  
187 - scope[ctrlAs].$$data.push(obj);  
188 - }  
189 - // 更新内部model,用于外部验证  
190 - // 内部model的值暂时随意,以后再改  
191 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
192 - } else {  
193 - scope[ctrlAs].$$internalmodel = undefined;  
194 - }  
195 -  
196 - } else {  
197 - scope[ctrlAs].$$internalmodel = undefined;  
198 - }  
199 -  
200 - } else {  
201 - scope[ctrlAs].$$internalmodel = undefined;  
202 - }  
203 - };  
204 -  
205 - /**  
206 - * 内部match表达式转换函数,需要外部绑定此函数的上下文。  
207 - * @param context function上下文  
208 - */  
209 - scope[ctrlAs].$$internal_match_str = function (context) {  
210 - var fx = function() {  
211 - return eval($searchexp_attr);  
212 - };  
213 -  
214 - var str = fx.bind(context)();  
215 - if (str && str != "")  
216 - return str;  
217 - else  
218 - return undefined;  
219 - };  
220 -  
221 - /**  
222 - * 内部方法,读取字典数据作为数据源。  
223 - * @param atype ajax查询类型  
224 - * @param ajaxparamobj 查询参数对象  
225 - */  
226 - scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {  
227 - ajaxparamobj.type = 'all';  
228 - $$searchInfoService_g[atype].list(  
229 - ajaxparamobj,  
230 - function(result) {  
231 - console.log("$$internal_ajax_data result");  
232 -  
233 - // 重新创建内部保存的数据  
234 - scope[ctrlAs].$$data = [];  
235 - // result中添加拼音数据,注意:这里要求result返回对象数组  
236 - for (var i = 0; i < result.length; i ++) {  
237 - // 闭包绑定返回最终查询的值  
238 - var calcu_str = scope[ctrlAs].$$internal_match_str(result[i]);  
239 - if (calcu_str) {  
240 - // 全拼  
241 - result[i]["$fullChars"] = pinyin.getFullChars(calcu_str);  
242 - // 简拼  
243 - result[i]["$camelChars"] = pinyin.getCamelChars(calcu_str);  
244 - // 原值  
245 - result[i]["$calcu_str"] = calcu_str;  
246 -  
247 - scope[ctrlAs].$$data_real.push(result[i]);  
248 - }  
249 - }  
250 -  
251 - // 重新创建内部ui-select显示用数据,默认取10条记录显示  
252 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
253 - if (scope[ctrlAs].$$data.length < 10) {  
254 - scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);  
255 - } else {  
256 - break;  
257 - }  
258 - }  
259 -  
260 - scope[ctrlAs].$$internal_validate_model();  
261 - },  
262 - function(result) {  
263 - throw new Error("ajax查询出错");  
264 - }  
265 - );  
266 - };  
267 -  
268 - /**  
269 - * 内部方法,读取字典数据作为数据源。  
270 - * @param dictype 字典类型,如:gsType  
271 - */  
272 - scope[ctrlAs].$$internal_dic_data = function(dictype) {  
273 - if (!dictionaryUtils.getByGroup(dictype)) {  
274 - throw new error("字典数据不窜在=" + dictype);  
275 - }  
276 -  
277 - // 重新创建内部保存的数据  
278 - scope[ctrlAs].$$data_real = [];  
279 - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);  
280 - var dic_key; // 字典key  
281 -  
282 - for (dic_key in origin_dicgroup) {  
283 - var data = {}; // 重新组合的字典元素对象  
284 - if (dic_key == "true")  
285 - data[$icname_attr] = true;  
286 - else  
287 - data[$icname_attr] = dic_key;  
288 - data[$dscol_attr] = origin_dicgroup[dic_key];  
289 - scope[ctrlAs].$$data_real.push(data);  
290 - }  
291 -  
292 - // 重新创建内部ui-select显示用数据,直接复制所有的字典数据  
293 - scope[ctrlAs].$$data = [];  
294 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
295 - scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);  
296 - }  
297 -  
298 - scope[ctrlAs].$$internal_validate_model();  
299 - };  
300 -  
301 - /**  
302 - * 监控dsparams属性变化  
303 - */  
304 - attr.$observe("dsparams", function(value) {  
305 - if (value && value != "") {  
306 - var obj = JSON.parse(value);  
307 - console.log("saSelect5 监控到dsparams属性变化,old=" + $dsparams_attr + ",new=" + value);  
308 -  
309 - // dsparams格式如下:  
310 - // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}  
311 -  
312 - if (obj.type == 'dic') {  
313 - scope[ctrlAs].$$internal_dic_data(obj.param);  
314 -  
315 - } else if (obj.type == 'ajax') {  
316 - scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);  
317 - } else {  
318 - throw new Error("dsparams参数格式异常=" + obj);  
319 - }  
320 -  
321 - }  
322 - });  
323 -  
324 - /**  
325 - * 监控外部模型dcname的值的变化。  
326 - */  
327 - scope.$watch(  
328 - function() {  
329 - return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);  
330 - },  
331 - function(newValue, oldValue) {  
332 - if (newValue === undefined && oldValue === undefined) {  
333 - // 两侧都是undefined,不处理  
334 -  
335 - } else {  
336 - console.log("saSelect5 监控到外部模型" + $dcname_attr + "属性值变化,old=" + oldValue + ",new=" + newValue);  
337 - scope[ctrlAs].$$internal_select_value = newValue;  
338 - scope[ctrlAs].$$internal_validate_model();  
339 - }  
340 - },  
341 - true  
342 - );  
343 - }  
344 - };  
345 - }  
346 - };  
347 - } 1 +/**
  2 + * saSelect5指令,基于简拼查询的select,内部封装angular-ui-select控件,并嵌入相应的业务逻辑。
  3 + * name(必须):控件的名字
  4 + * model(必须):独立作用域,指定一个外部对象模型双向绑定,如:model=ctrl.employeeInfoForSave
  5 + * cmaps(必须):外部对象与指令内部数据对象字段名映射对象,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}}
  6 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  7 + * icname(必须):内部与之对应的字段名,如:icname=id
  8 + *
  9 + * dsparams(必须):内部数据源查询参数对象,如:{{ {'ttid_eq': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}
  10 + * iterobjname(必须):内部数据源迭代的数据变量名,如:iterobjname=item
  11 + * iterobjexp(必须):内部显示用的表达式
  12 + * searchph(必须):查询输入占位符字符串,如:searchph=请输入...
  13 + * searchexp(必须):查询基于的内部数据源的表达式,如:searchexp=this.name+'('+this.code+')'
  14 + *
  15 + * required(可选):是否需要form的required验证
  16 + *
  17 + */
  18 +angular.module('ScheduleApp').directive('saSelect5', [
  19 + '$timeout',
  20 + '$$SearchInfoService_g',
  21 + function($timeout, $$searchInfoService_g) {
  22 + return {
  23 + restrict: 'E',
  24 + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect5Template.html',
  25 + scope: { // 独立作用域
  26 + model: "=" // 绑定外部对象
  27 + },
  28 + controllerAs: "$saSelectCtrl",
  29 + bindToController: true,
  30 + controller: function($scope) {
  31 + var self = this;
  32 + self.$$data = []; // 内部ui-select显示用数据
  33 + self.$$data_real = []; // 内部保存的实际数据
  34 +
  35 + // myselect组件的ng-model,用于外部绑定验证等操作
  36 + self.$$internalmodel = undefined;
  37 +
  38 + self.$$internal_select_value = undefined; // 选中的值
  39 +
  40 + },
  41 +
  42 + /**
  43 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  44 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  45 + * @param tElem
  46 + * @param tAttrs
  47 + * @returns {{pre: Function, post: Function}}
  48 + */
  49 + compile: function(tElem, tAttrs) {
  50 + // 获取属性,并验证必须按属性
  51 + var $name_attr = tAttrs["name"]; // 控件的名字
  52 + var $cmaps_attr = tAttrs["cmaps"]; // 外部对象与指令内部数据对象字段名映射对象
  53 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  54 + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名
  55 +
  56 + var $dsparams_attr = tAttrs["dsparams"]; // 内部数据源查询参数对象
  57 + var $iterobjname_attr = tAttrs["iterobjname"]; // 内部数据源迭代的数据变量名
  58 + var $iterobjexp_attr = tAttrs["iterobjexp"]; // 内部显示用的表达式
  59 + var $searchph_attr = tAttrs["searchph"]; // 查询输入占位符字符串
  60 + var $searchexp_attr = tAttrs["searchexp"]; // 查询基于的内部数据源的表达式
  61 +
  62 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  63 +
  64 + if (!$name_attr) {
  65 + throw new Error("name属性必须填写");
  66 + }
  67 + if (!$cmaps_attr) {
  68 + throw new Error("cmaps属性必须填写")
  69 + }
  70 + if (!$dcname_attr || !$icname_attr) {
  71 + throw new Error("dcname、icname属性必须填写");
  72 + }
  73 + if (!$dsparams_attr) {
  74 + throw new Error("dsparams属性必须填写");
  75 + }
  76 + if (!$iterobjname_attr) {
  77 + throw new Error("iterobjname属性必须填写");
  78 + }
  79 + if (!$iterobjexp_attr) {
  80 + throw new Error("iterobjexp属性必须填写");
  81 + }
  82 + if (!$searchph_attr) {
  83 + throw new Error("searchph属性必须填写");
  84 + }
  85 + if (!$searchexp_attr) {
  86 + throw new Error("searchexp属性必须填写");
  87 + }
  88 +
  89 + // 内部controlAs名字
  90 + var ctrlAs = "$saSelectCtrl";
  91 +
  92 + // 动态设置dom
  93 + // dom,最外层name属性设置
  94 + tElem.find("div:first").attr("name", $name_attr);
  95 + // dom,最外层divrequired属性设置
  96 + if ($required_attr != undefined) {
  97 + tElem.find("div[name=\'" + $name_attr + "\']").attr("required", "");
  98 + }
  99 + // dom,ui-select-match的placeholder属性设定
  100 + tElem.find("ui-select-match").attr("placeholder", $searchph_attr);
  101 + // dom,ui-select-match的内容设定
  102 + var uiSelectMatchHtml = "{{" + ctrlAs + ".$$internal_match_str($select.selected)}}";
  103 + tElem.find("ui-select-match").html(uiSelectMatchHtml);
  104 + // dom,ui-select-choices的repeat属性设定
  105 + var uiSelectChoices_repeatAttr = $iterobjname_attr + "." + $icname_attr + " as " + $iterobjname_attr + " in " + ctrlAs + ".$$data";
  106 + tElem.find("ui-select-choices").attr("repeat", uiSelectChoices_repeatAttr);
  107 + // dom,span ng-bind属性设置,TODO:暂时无法用transclude设置,先用属性设置
  108 + tElem.find("ui-select-choices").html("{{" + $iterobjexp_attr + "}}");
  109 +
  110 + return {
  111 + pre: function (scope, element, attr) {
  112 + // TODO:
  113 + },
  114 +
  115 + /**
  116 + * 相当于link函数。
  117 + * @param scope
  118 + * @param element
  119 + * @param attr
  120 + */
  121 + post: function (scope, element, attr) {
  122 +
  123 + // 添加选中事件处理函数
  124 + scope[ctrlAs].$$internal_select_fn = function($item) {
  125 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  126 +
  127 + for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名
  128 + var ic = $cmaps_attr[mc]; // 内部数据源对应字段
  129 + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  130 + }
  131 + };
  132 +
  133 + // 删除选中事件处理函数
  134 + scope[ctrlAs].$$internal_remove_fn = function() {
  135 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  136 +
  137 + var mc; // model的字段名
  138 + for (mc in $cmaps_attr) {
  139 + eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  140 + }
  141 + };
  142 +
  143 + // 刷新数据
  144 + scope[ctrlAs].$$internal_refresh_fn = function(search) {
  145 + if (search && search != "") { // 有search值
  146 + // 处理search
  147 + console.log("search:" + search);
  148 +
  149 + scope[ctrlAs].$$data = [];
  150 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  151 + var upTerm = search.toUpperCase();
  152 + if (scope[ctrlAs].$$data.length < 10) {
  153 + if (scope[ctrlAs].$$data_real[k].$fullChars.indexOf(upTerm) != -1
  154 + || scope[ctrlAs].$$data_real[k].$camelChars.indexOf(upTerm) != -1
  155 + || scope[ctrlAs].$$data_real[k].$calcu_str.indexOf(upTerm) != -1) {
  156 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  157 + }
  158 + } else {
  159 + break;
  160 + }
  161 + }
  162 + }
  163 + };
  164 +
  165 + /**
  166 + * 验证内部数据,更新外部model
  167 + */
  168 + scope[ctrlAs].$$internal_validate_model = function() {
  169 + if (scope[ctrlAs].$$internal_select_value) {
  170 + var select_value_temp = scope[ctrlAs].$$internal_select_value;
  171 + if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {
  172 + var obj;
  173 + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {
  174 + if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {
  175 + obj = angular.copy(scope[ctrlAs].$$data_real[j]);
  176 + break;
  177 + }
  178 + }
  179 + if (obj) { // 在data中判定有没有
  180 + for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {
  181 + if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {
  182 + obj = undefined;
  183 + break;
  184 + }
  185 + }
  186 + if (obj) {
  187 + scope[ctrlAs].$$data.push(obj);
  188 + }
  189 + // 更新内部model,用于外部验证
  190 + // 内部model的值暂时随意,以后再改
  191 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  192 + } else {
  193 + scope[ctrlAs].$$internalmodel = undefined;
  194 + }
  195 +
  196 + } else {
  197 + scope[ctrlAs].$$internalmodel = undefined;
  198 + }
  199 +
  200 + } else {
  201 + scope[ctrlAs].$$internalmodel = undefined;
  202 + }
  203 + };
  204 +
  205 + /**
  206 + * 内部match表达式转换函数,需要外部绑定此函数的上下文。
  207 + * @param context function上下文
  208 + */
  209 + scope[ctrlAs].$$internal_match_str = function (context) {
  210 + var fx = function() {
  211 + return eval($searchexp_attr);
  212 + };
  213 +
  214 + var str = fx.bind(context)();
  215 + if (str && str != "")
  216 + return str;
  217 + else
  218 + return undefined;
  219 + };
  220 +
  221 + /**
  222 + * 内部方法,读取字典数据作为数据源。
  223 + * @param atype ajax查询类型
  224 + * @param ajaxparamobj 查询参数对象
  225 + */
  226 + scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {
  227 + ajaxparamobj.type = 'all';
  228 + $$searchInfoService_g[atype].list(
  229 + ajaxparamobj,
  230 + function(result) {
  231 + console.log("$$internal_ajax_data result");
  232 +
  233 + // 重新创建内部保存的数据
  234 + scope[ctrlAs].$$data = [];
  235 + // result中添加拼音数据,注意:这里要求result返回对象数组
  236 + for (var i = 0; i < result.length; i ++) {
  237 + // 闭包绑定返回最终查询的值
  238 + var calcu_str = scope[ctrlAs].$$internal_match_str(result[i]);
  239 + if (calcu_str) {
  240 + // 全拼
  241 + result[i]["$fullChars"] = pinyin.getFullChars(calcu_str);
  242 + // 简拼
  243 + result[i]["$camelChars"] = pinyin.getCamelChars(calcu_str);
  244 + // 原值
  245 + result[i]["$calcu_str"] = calcu_str;
  246 +
  247 + scope[ctrlAs].$$data_real.push(result[i]);
  248 + }
  249 + }
  250 +
  251 + // 重新创建内部ui-select显示用数据,默认取10条记录显示
  252 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  253 + if (scope[ctrlAs].$$data.length < 10) {
  254 + scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);
  255 + } else {
  256 + break;
  257 + }
  258 + }
  259 +
  260 + scope[ctrlAs].$$internal_validate_model();
  261 + },
  262 + function(result) {
  263 + throw new Error("ajax查询出错");
  264 + }
  265 + );
  266 + };
  267 +
  268 + /**
  269 + * 内部方法,读取字典数据作为数据源。
  270 + * @param dictype 字典类型,如:gsType
  271 + */
  272 + scope[ctrlAs].$$internal_dic_data = function(dictype) {
  273 + if (!dictionaryUtils.getByGroup(dictype)) {
  274 + throw new error("字典数据不窜在=" + dictype);
  275 + }
  276 +
  277 + // 重新创建内部保存的数据
  278 + scope[ctrlAs].$$data_real = [];
  279 + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);
  280 + var dic_key; // 字典key
  281 +
  282 + for (dic_key in origin_dicgroup) {
  283 + var data = {}; // 重新组合的字典元素对象
  284 + if (dic_key == "true")
  285 + data[$icname_attr] = true;
  286 + else
  287 + data[$icname_attr] = dic_key;
  288 + data[$dscol_attr] = origin_dicgroup[dic_key];
  289 + scope[ctrlAs].$$data_real.push(data);
  290 + }
  291 +
  292 + // 重新创建内部ui-select显示用数据,直接复制所有的字典数据
  293 + scope[ctrlAs].$$data = [];
  294 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  295 + scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);
  296 + }
  297 +
  298 + scope[ctrlAs].$$internal_validate_model();
  299 + };
  300 +
  301 + /**
  302 + * 监控dsparams属性变化
  303 + */
  304 + attr.$observe("dsparams", function(value) {
  305 + if (value && value != "") {
  306 + var obj = JSON.parse(value);
  307 + console.log("saSelect5 监控到dsparams属性变化,old=" + $dsparams_attr + ",new=" + value);
  308 +
  309 + // dsparams格式如下:
  310 + // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}
  311 +
  312 + if (obj.type == 'dic') {
  313 + scope[ctrlAs].$$internal_dic_data(obj.param);
  314 +
  315 + } else if (obj.type == 'ajax') {
  316 + scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);
  317 + } else {
  318 + throw new Error("dsparams参数格式异常=" + obj);
  319 + }
  320 +
  321 + }
  322 + });
  323 +
  324 + /**
  325 + * 监控外部模型dcname的值的变化。
  326 + */
  327 + scope.$watch(
  328 + function() {
  329 + return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);
  330 + },
  331 + function(newValue, oldValue) {
  332 + if (newValue === undefined && oldValue === undefined) {
  333 + // 两侧都是undefined,不处理
  334 +
  335 + } else {
  336 + console.log("saSelect5 监控到外部模型" + $dcname_attr + "属性值变化,old=" + oldValue + ",new=" + newValue);
  337 + scope[ctrlAs].$$internal_select_value = newValue;
  338 + scope[ctrlAs].$$internal_validate_model();
  339 + }
  340 + },
  341 + true
  342 + );
  343 + }
  344 + };
  345 + }
  346 + };
  347 + }
348 ]); 348 ]);
349 \ No newline at end of file 349 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect5Template.html
1 -<div class="input-group" name="指令compile阶段设定1"  
2 - ng-model="$saSelectCtrl.$$internalmodel">  
3 - <ui-select ng-model="$saSelectCtrl.$$internal_select_value" on-select="$saSelectCtrl.$$internal_select_fn($item)"  
4 - theme="bootstrap" >  
5 - <ui-select-match placeholder="指令compile阶段设定">指令compile阶段设定2</ui-select-match>  
6 - <ui-select-choices repeat="指令compile阶段设定3"  
7 - refresh="$saSelectCtrl.$$internal_refresh_fn($select.search)"  
8 - refresh-delay="10">  
9 -  
10 - 指令compile阶段设定777  
11 -  
12 - </ui-select-choices>  
13 - </ui-select>  
14 - <span class="input-group-btn">  
15 - <button type="button" ng-click="$saSelectCtrl.$$internal_remove_fn()" class="btn btn-default">  
16 - <span class="glyphicon glyphicon-trash"></span>  
17 - </button>  
18 - </span> 1 +<div class="input-group" name="指令compile阶段设定1"
  2 + ng-model="$saSelectCtrl.$$internalmodel">
  3 + <ui-select ng-model="$saSelectCtrl.$$internal_select_value" on-select="$saSelectCtrl.$$internal_select_fn($item)"
  4 + theme="bootstrap" >
  5 + <ui-select-match placeholder="指令compile阶段设定">指令compile阶段设定2</ui-select-match>
  6 + <ui-select-choices repeat="指令compile阶段设定3"
  7 + refresh="$saSelectCtrl.$$internal_refresh_fn($select.search)"
  8 + refresh-delay="10">
  9 +
  10 + 指令compile阶段设定777
  11 +
  12 + </ui-select-choices>
  13 + </ui-select>
  14 + <span class="input-group-btn">
  15 + <button type="button" ng-click="$saSelectCtrl.$$internal_remove_fn()" class="btn btn-default">
  16 + <span class="glyphicon glyphicon-trash"></span>
  17 + </button>
  18 + </span>
19 </div> 19 </div>
20 \ No newline at end of file 20 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/bcGroup/MyBcGroupWrapTemplate.html
1 -<div name="{{$saBcgroupCtrl.$name_attr}}"  
2 - ng-model="$saBcgroupCtrl.$$internalmodel">  
3 -  
4 - <style>  
5 - .bc-select {  
6 - min-height: 180px;  
7 - border: 1px solid #ddd;  
8 - }  
9 - .bc-select .bc-input {  
10 - margin: 5px 5px 0px 5px;  
11 - padding-left: 0;  
12 - }  
13 - .bc-select .bc-select-cont {  
14 - text-align: left;  
15 - min-height: 60px;  
16 - padding-right: 0px;  
17 - }  
18 - .bc-select .bc-select-body {  
19 - margin-top: 5px;  
20 - overflow: auto;  
21 - width: auto;  
22 - min-height: 5px;  
23 - }  
24 - .bc-select .bc {  
25 - display: inline-block;  
26 - padding: 8px;  
27 - min-width: 50px;  
28 - text-align: center;  
29 - border: 1px solid #C1C1C1;  
30 - color: #666;  
31 - border-radius: 5px !important;  
32 - margin: 5px;  
33 - }  
34 - .bc-select .bc.active {  
35 - color: white;  
36 - background: #4095E8;  
37 - border: 1px solid #4095E8;  
38 - }  
39 -  
40 -  
41 - </style>  
42 -  
43 - <div class="col-md-12 bc-select">  
44 - <div class="col-md-12 bc-input">  
45 - <div class="col-md-9">  
46 - 班次列表,共{{$saBcgroupCtrl.$$data.length}}个  
47 - </div>  
48 - </div>  
49 - <div class="col-md-12 bc-select-cont">  
50 - <div class="bc-select-body">  
51 - <div class="bc active"  
52 - ng-repeat="$d in $saBcgroupCtrl.$$data track by $index"  
53 - ng-click="$saBcgroupCtrl.$$internal_bclist_click($index)">  
54 - <i class="fa fa-list" aria-hidden="true"></i>  
55 - <span ng-if="$d.bctype == 'out'">  
56 - 出场  
57 - </span>  
58 - <span ng-if="$d.bctype == 'in'">  
59 - 进场  
60 - </span>  
61 - {{"(" + $d.bcfcsj + ")"}}  
62 - </div>  
63 - </div>  
64 - </div>  
65 - <div class="col-md-12 bc-input">  
66 - <div class="col-md-12">  
67 - 已经选中的班次列表,共{{$saBcgroupCtrl.$$dataSelected.length}}个  
68 - </div>  
69 - </div>  
70 - <div class="col-md-12 bc-select-cont">  
71 - <div class="bc-select-body">  
72 - <div ng-class="{bc: true, active: true}"  
73 - ng-repeat="$d in $saBcgroupCtrl.$$dataSelected track by $index"  
74 - ng-click="$saBcgroupCtrl.$$internal_selbclist_click($index)"  
75 - ng-dblclick="$saBcgroupCtrl.$$internal_selbclist_dbclick($index)">  
76 - <i class="fa fa-list" aria-hidden="true"></i>  
77 - <span ng-if="$d.bctype == 'out'">  
78 - 出场  
79 - </span>  
80 - <span ng-if="$d.bctype == 'in'">  
81 - 进场  
82 - </span>  
83 - {{"(" + $d.bcfcsj + ")"}}  
84 - </div>  
85 - </div>  
86 - </div>  
87 - </div>  
88 -  
89 - 1 +<div name="{{$saBcgroupCtrl.$name_attr}}"
  2 + ng-model="$saBcgroupCtrl.$$internalmodel">
  3 +
  4 + <style>
  5 + .bc-select {
  6 + min-height: 180px;
  7 + border: 1px solid #ddd;
  8 + }
  9 + .bc-select .bc-input {
  10 + margin: 5px 5px 0px 5px;
  11 + padding-left: 0;
  12 + }
  13 + .bc-select .bc-select-cont {
  14 + text-align: left;
  15 + min-height: 60px;
  16 + padding-right: 0px;
  17 + }
  18 + .bc-select .bc-select-body {
  19 + margin-top: 5px;
  20 + overflow: auto;
  21 + width: auto;
  22 + min-height: 5px;
  23 + }
  24 + .bc-select .bc {
  25 + display: inline-block;
  26 + padding: 8px;
  27 + min-width: 50px;
  28 + text-align: center;
  29 + border: 1px solid #C1C1C1;
  30 + color: #666;
  31 + border-radius: 5px !important;
  32 + margin: 5px;
  33 + }
  34 + .bc-select .bc.active {
  35 + color: white;
  36 + background: #4095E8;
  37 + border: 1px solid #4095E8;
  38 + }
  39 +
  40 +
  41 + </style>
  42 +
  43 + <div class="col-md-12 bc-select">
  44 + <div class="col-md-12 bc-input">
  45 + <div class="col-md-9">
  46 + 班次列表,共{{$saBcgroupCtrl.$$data.length}}个
  47 + </div>
  48 + </div>
  49 + <div class="col-md-12 bc-select-cont">
  50 + <div class="bc-select-body">
  51 + <div class="bc active"
  52 + ng-repeat="$d in $saBcgroupCtrl.$$data track by $index"
  53 + ng-click="$saBcgroupCtrl.$$internal_bclist_click($index)">
  54 + <i class="fa fa-list" aria-hidden="true"></i>
  55 + <span ng-if="$d.bctype == 'out'">
  56 + 出场
  57 + </span>
  58 + <span ng-if="$d.bctype == 'in'">
  59 + 进场
  60 + </span>
  61 + {{"(" + $d.bcfcsj + ")"}}
  62 + </div>
  63 + </div>
  64 + </div>
  65 + <div class="col-md-12 bc-input">
  66 + <div class="col-md-12">
  67 + 已经选中的班次列表,共{{$saBcgroupCtrl.$$dataSelected.length}}个
  68 + </div>
  69 + </div>
  70 + <div class="col-md-12 bc-select-cont">
  71 + <div class="bc-select-body">
  72 + <div ng-class="{bc: true, active: true}"
  73 + ng-repeat="$d in $saBcgroupCtrl.$$dataSelected track by $index"
  74 + ng-click="$saBcgroupCtrl.$$internal_selbclist_click($index)"
  75 + ng-dblclick="$saBcgroupCtrl.$$internal_selbclist_dbclick($index)">
  76 + <i class="fa fa-list" aria-hidden="true"></i>
  77 + <span ng-if="$d.bctype == 'out'">
  78 + 出场
  79 + </span>
  80 + <span ng-if="$d.bctype == 'in'">
  81 + 进场
  82 + </span>
  83 + {{"(" + $d.bcfcsj + ")"}}
  84 + </div>
  85 + </div>
  86 + </div>
  87 + </div>
  88 +
  89 +
90 </div> 90 </div>
91 \ No newline at end of file 91 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/bcGroup/saBcgroup.js
1 -/**  
2 - * saBcgroup指令,用于套跑界面中,从指定线路,指定时刻表,指定路牌的班次列表中选择套跑班次。  
3 - * 属性如下:  
4 - * name(必须):控件的名字  
5 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
6 - * bcttinfoidsvalue(必须):绑定的model班次ids字段值,如:bcttinfoidsvalue={{ctrl.employeeInfoForSave.lprange}}  
7 - * bcttinfoidsname(必须):bind的model班次ids字段名,如:bcttinfoidsname=lprange  
8 - * dataparams (必须):内部数据关联的查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}  
9 - * required(可选):是否要用required验证  
10 - *  
11 - */  
12 -angular.module('ScheduleApp').directive('saBcgroup', [  
13 - 'TimeTableDetailManageService_g',  
14 - function(timeTableDetailManageService_g) {  
15 - return {  
16 - restrict: 'E',  
17 - templateUrl: '/pages/scheduleApp/module/common/dts2/bcGroup/MyBcGroupWrapTemplate.html',  
18 - scope: {  
19 - model: "=" // 独立作用域,关联外部的模型object  
20 - },  
21 - controllerAs: '$saBcgroupCtrl',  
22 - bindToController: true,  
23 - controller: function($scope) {  
24 - var self = this;  
25 - self.$$data = []; // 选择线路,时刻表,路牌后的班次列表  
26 -  
27 - // 测试数据  
28 - //self.$$data = [  
29 - // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},  
30 - // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},  
31 - // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}  
32 - //];  
33 -  
34 -  
35 - self.$$dataSelected = []; // 套跑选中的班次列表  
36 -  
37 - //self.$$dataSelected = [  
38 - // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},  
39 - // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},  
40 - // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}  
41 - //];  
42 -  
43 - // saBcgroup组件的ng-model,用于外部绑定等操作  
44 - self.$$internalmodel = undefined;  
45 -  
46 - self.$$data_bcdata_first_init = false; // 班次数据首次初始化标志  
47 - self.$$data_bcttinfoids_first_init = false; // 班次ids数据首次初始化标志  
48 - self.$$data_bcttinfoids_first_data = undefined; // 班次ids数据首次初始化数据  
49 -  
50 - },  
51 -  
52 - /**  
53 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
54 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
55 - * @param tElem  
56 - * @param tAttrs  
57 - * @returns {{pre: Function, post: Function}}  
58 - */  
59 - compile: function(tElem, tAttrs) {  
60 - // TODO:获取所有的属性  
61 - var $name_attr = tAttrs["name"]; // 控件的名字  
62 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
63 - var $bcttinfoidsname_attr = tAttrs["bcttinfoidsname"]; // bind的model班次ids字段名  
64 -  
65 - // controlAs名字  
66 - var ctrlAs = '$saBcgroupCtrl';  
67 -  
68 - // 如果有required属性,添加angularjs required验证  
69 - if ($required_attr != undefined) {  
70 - //console.log(tElem.html());  
71 - tElem.find("div").attr("required", "");  
72 - }  
73 -  
74 - return {  
75 - pre: function(scope, element, attr) {  
76 - // TODO:  
77 - },  
78 -  
79 - /**  
80 - * 相当于link函数。  
81 - * @param scope  
82 - * @param element  
83 - * @param attr  
84 - */  
85 - post: function(scope, element, attr) {  
86 - // name属性  
87 - if ($name_attr) {  
88 - scope[ctrlAs]["$name_attr"] = $name_attr;  
89 - }  
90 -  
91 - // TODO:  
92 -  
93 -  
94 - /**  
95 - * 班次列表点击(班次列表中选中班次)  
96 - * @param $index  
97 - */  
98 - scope[ctrlAs].$$internal_bclist_click = function($index) {  
99 - var data_temp = scope[ctrlAs].$$data;  
100 - var data_temp2 = scope[ctrlAs].$$dataSelected;  
101 - var i = 0;  
102 - var isunique = true; // 是否已经选择过  
103 - if (data_temp && data_temp.length > $index) {  
104 - for (i = 0; i < data_temp2.length; i++) {  
105 - if (data_temp2[i].bcttinfoid == data_temp[$index].bcttinfoid) {  
106 - isunique = false;  
107 - break;  
108 - }  
109 - }  
110 - if (isunique) {  
111 - data_temp2.push({  
112 - bcttinfoid: data_temp[$index].bcttinfoid,  
113 - bcfcsj: data_temp[$index].bcfcsj,  
114 - bctype: data_temp[$index].bctype  
115 - });  
116 - }  
117 -  
118 - }  
119 - };  
120 - /**  
121 - * 选中的班次双击(删除选中的班次)  
122 - * @param $index  
123 - */  
124 - scope[ctrlAs].$$internal_selbclist_dbclick = function($index) {  
125 - var data_temp = scope[ctrlAs].$$dataSelected;  
126 - if (data_temp && data_temp.length > $index) {  
127 - data_temp.splice($index, 1);  
128 - }  
129 - };  
130 -  
131 -  
132 - /**  
133 - * 验证内部数据,更新外部model  
134 - */  
135 - scope[ctrlAs].$$internal_validate_model = function() {  
136 - var data_temp = scope[ctrlAs].$$dataSelected;  
137 - var bcttinfoIds = [];  
138 - var i = 0;  
139 -  
140 - if (data_temp &&  
141 - data_temp.length > 0) {  
142 -  
143 - for (i = 0; i < data_temp.length; i++) {  
144 - bcttinfoIds.push(data_temp[i].bcttinfoid);  
145 - }  
146 -  
147 - // 更新外部model字段  
148 - if ($bcttinfoidsname_attr) {  
149 - console.log("bcttinfoidsname=" + bcttinfoIds.join(','));  
150 - eval("scope[ctrlAs].model" + "." + $bcttinfoidsname_attr + " = bcttinfoIds.join(',');");  
151 - }  
152 -  
153 - // 更新内部model,用于外部验证  
154 - // 内部model的值暂时随意,以后再改  
155 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
156 -  
157 - scope[ctrlAs].$$data_bcdata_first_init = true;  
158 - scope[ctrlAs].$$data_bcttinfoids_first_init = true;  
159 -  
160 - } else {  
161 - scope[ctrlAs].$$internalmodel = undefined;  
162 - }  
163 -  
164 - };  
165 -  
166 - // 监控内部数据,$$data_selected 变化  
167 - scope.$watch(  
168 - function() {  
169 - return scope[ctrlAs].$$dataSelected;  
170 - },  
171 - function(newValue, oldValue) {  
172 - scope[ctrlAs].$$internal_validate_model();  
173 - },  
174 - true  
175 - );  
176 -  
177 - /**  
178 - * 验证数据是否初始化完成,  
179 - * 所谓的初始化就是内部所有的数据被有效设定过一次。  
180 - */  
181 - scope[ctrlAs].$$internal_validate_init = function() {  
182 - var self = scope[ctrlAs];  
183 -  
184 - var data_temp = self.$$data;  
185 - var dataSelect_temp = self.$$dataSelected;  
186 - var bcttinfoids = null;  
187 -  
188 - var i = 0;  
189 - var j = 0;  
190 -  
191 - if (self.$$data_bcdata_first_init &&  
192 - self.$$data_bcttinfoids_first_init) {  
193 - console.log("开始初始化数据");  
194 -  
195 - bcttinfoids = self.$$data_bcttinfoids_first_data ? self.$$data_bcttinfoids_first_data.split(",") : [];  
196 -  
197 - for (i = 0; i < bcttinfoids.length; i++) {  
198 - dataSelect_temp.push({  
199 - bcttinfoid: bcttinfoids[i]  
200 - });  
201 - for (j = 0; j < data_temp.length; j++) {  
202 - if (dataSelect_temp[i].bcttinfoid == data_temp[j].bcttinfoid) {  
203 - dataSelect_temp[i].bcfcsj = data_temp[j].bcfcsj;  
204 - dataSelect_temp[i].bctype = data_temp[j].bctype;  
205 - break;  
206 - }  
207 - }  
208 - }  
209 -  
210 - console.log("数据初始化完毕!");  
211 - }  
212 -  
213 - };  
214 -  
215 - // 监控初始化标志  
216 - scope.$watch(  
217 - function() {  
218 - return scope[ctrlAs].$$data_bcdata_first_init;  
219 - },  
220 - function(newValue, oldValue) {  
221 - scope[ctrlAs].$$internal_validate_init();  
222 - }  
223 - );  
224 - scope.$watch(  
225 - function() {  
226 - return scope[ctrlAs].$$data_bcttinfoids_first_init;  
227 - },  
228 - function(newValue, oldValue) {  
229 - scope[ctrlAs].$$internal_validate_init();  
230 - }  
231 - );  
232 -  
233 - // 监控内部数据的变化  
234 - attr.$observe("dataparams", function(value) {  
235 - if (value && value != "") {  
236 - console.log("observe 监控 dataparams=" + value);  
237 -  
238 - var obj = JSON.parse(value);  
239 - timeTableDetailManageService_g.bcdetails.list(  
240 - obj,  
241 - function(result) {  
242 - // 获取值了  
243 - console.log("内部班次数据获取了");  
244 -  
245 - scope[ctrlAs].$$data = [];  
246 - for (var i = 0; i < result.length; i++) {  
247 - scope[ctrlAs].$$data.push({  
248 - bcttinfoid: result[i].id,  
249 - bcfcsj: result[i].fcsj,  
250 - bctype: result[i].bcType  
251 - });  
252 - }  
253 - if (scope[ctrlAs].$$data_bcdata_first_init &&  
254 - scope[ctrlAs].$$data_bcttinfoids_first_init) {  
255 -  
256 - scope[ctrlAs].$$dataSelected = [];  
257 - scope[ctrlAs].$$internalmodel = undefined;  
258 - }  
259 - scope[ctrlAs].$$data_bcdata_first_init = true;  
260 - },  
261 - function(result) {  
262 -  
263 - }  
264 - );  
265 - }  
266 - });  
267 - // 监控班次ids数据的变化  
268 - attr.$observe("bcttinfoidsvalue", function(value) {  
269 - if (value && value != "") {  
270 - console.log("observe 监控 bcttinfoidsvalue=" + value);  
271 - scope[ctrlAs].$$data_bcttinfoids_first_init = true;  
272 - scope[ctrlAs].$$data_bcttinfoids_first_data = value;  
273 - }  
274 - });  
275 -  
276 - }  
277 - }  
278 -  
279 - }  
280 - }  
281 - } 1 +/**
  2 + * saBcgroup指令,用于套跑界面中,从指定线路,指定时刻表,指定路牌的班次列表中选择套跑班次。
  3 + * 属性如下:
  4 + * name(必须):控件的名字
  5 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  6 + * bcttinfoidsvalue(必须):绑定的model班次ids字段值,如:bcttinfoidsvalue={{ctrl.employeeInfoForSave.lprange}}
  7 + * bcttinfoidsname(必须):bind的model班次ids字段名,如:bcttinfoidsname=lprange
  8 + * dataparams (必须):内部数据关联的查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}
  9 + * required(可选):是否要用required验证
  10 + *
  11 + */
  12 +angular.module('ScheduleApp').directive('saBcgroup', [
  13 + 'TimeTableDetailManageService_g',
  14 + function(timeTableDetailManageService_g) {
  15 + return {
  16 + restrict: 'E',
  17 + templateUrl: '/pages/scheduleApp/module/common/dts2/bcGroup/MyBcGroupWrapTemplate.html',
  18 + scope: {
  19 + model: "=" // 独立作用域,关联外部的模型object
  20 + },
  21 + controllerAs: '$saBcgroupCtrl',
  22 + bindToController: true,
  23 + controller: function($scope) {
  24 + var self = this;
  25 + self.$$data = []; // 选择线路,时刻表,路牌后的班次列表
  26 +
  27 + // 测试数据
  28 + //self.$$data = [
  29 + // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},
  30 + // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},
  31 + // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}
  32 + //];
  33 +
  34 +
  35 + self.$$dataSelected = []; // 套跑选中的班次列表
  36 +
  37 + //self.$$dataSelected = [
  38 + // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},
  39 + // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},
  40 + // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}
  41 + //];
  42 +
  43 + // saBcgroup组件的ng-model,用于外部绑定等操作
  44 + self.$$internalmodel = undefined;
  45 +
  46 + self.$$data_bcdata_first_init = false; // 班次数据首次初始化标志
  47 + self.$$data_bcttinfoids_first_init = false; // 班次ids数据首次初始化标志
  48 + self.$$data_bcttinfoids_first_data = undefined; // 班次ids数据首次初始化数据
  49 +
  50 + },
  51 +
  52 + /**
  53 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  54 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  55 + * @param tElem
  56 + * @param tAttrs
  57 + * @returns {{pre: Function, post: Function}}
  58 + */
  59 + compile: function(tElem, tAttrs) {
  60 + // TODO:获取所有的属性
  61 + var $name_attr = tAttrs["name"]; // 控件的名字
  62 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  63 + var $bcttinfoidsname_attr = tAttrs["bcttinfoidsname"]; // bind的model班次ids字段名
  64 +
  65 + // controlAs名字
  66 + var ctrlAs = '$saBcgroupCtrl';
  67 +
  68 + // 如果有required属性,添加angularjs required验证
  69 + if ($required_attr != undefined) {
  70 + //console.log(tElem.html());
  71 + tElem.find("div").attr("required", "");
  72 + }
  73 +
  74 + return {
  75 + pre: function(scope, element, attr) {
  76 + // TODO:
  77 + },
  78 +
  79 + /**
  80 + * 相当于link函数。
  81 + * @param scope
  82 + * @param element
  83 + * @param attr
  84 + */
  85 + post: function(scope, element, attr) {
  86 + // name属性
  87 + if ($name_attr) {
  88 + scope[ctrlAs]["$name_attr"] = $name_attr;
  89 + }
  90 +
  91 + // TODO:
  92 +
  93 +
  94 + /**
  95 + * 班次列表点击(班次列表中选中班次)
  96 + * @param $index
  97 + */
  98 + scope[ctrlAs].$$internal_bclist_click = function($index) {
  99 + var data_temp = scope[ctrlAs].$$data;
  100 + var data_temp2 = scope[ctrlAs].$$dataSelected;
  101 + var i = 0;
  102 + var isunique = true; // 是否已经选择过
  103 + if (data_temp && data_temp.length > $index) {
  104 + for (i = 0; i < data_temp2.length; i++) {
  105 + if (data_temp2[i].bcttinfoid == data_temp[$index].bcttinfoid) {
  106 + isunique = false;
  107 + break;
  108 + }
  109 + }
  110 + if (isunique) {
  111 + data_temp2.push({
  112 + bcttinfoid: data_temp[$index].bcttinfoid,
  113 + bcfcsj: data_temp[$index].bcfcsj,
  114 + bctype: data_temp[$index].bctype
  115 + });
  116 + }
  117 +
  118 + }
  119 + };
  120 + /**
  121 + * 选中的班次双击(删除选中的班次)
  122 + * @param $index
  123 + */
  124 + scope[ctrlAs].$$internal_selbclist_dbclick = function($index) {
  125 + var data_temp = scope[ctrlAs].$$dataSelected;
  126 + if (data_temp && data_temp.length > $index) {
  127 + data_temp.splice($index, 1);
  128 + }
  129 + };
  130 +
  131 +
  132 + /**
  133 + * 验证内部数据,更新外部model
  134 + */
  135 + scope[ctrlAs].$$internal_validate_model = function() {
  136 + var data_temp = scope[ctrlAs].$$dataSelected;
  137 + var bcttinfoIds = [];
  138 + var i = 0;
  139 +
  140 + if (data_temp &&
  141 + data_temp.length > 0) {
  142 +
  143 + for (i = 0; i < data_temp.length; i++) {
  144 + bcttinfoIds.push(data_temp[i].bcttinfoid);
  145 + }
  146 +
  147 + // 更新外部model字段
  148 + if ($bcttinfoidsname_attr) {
  149 + console.log("bcttinfoidsname=" + bcttinfoIds.join(','));
  150 + eval("scope[ctrlAs].model" + "." + $bcttinfoidsname_attr + " = bcttinfoIds.join(',');");
  151 + }
  152 +
  153 + // 更新内部model,用于外部验证
  154 + // 内部model的值暂时随意,以后再改
  155 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  156 +
  157 + scope[ctrlAs].$$data_bcdata_first_init = true;
  158 + scope[ctrlAs].$$data_bcttinfoids_first_init = true;
  159 +
  160 + } else {
  161 + scope[ctrlAs].$$internalmodel = undefined;
  162 + }
  163 +
  164 + };
  165 +
  166 + // 监控内部数据,$$data_selected 变化
  167 + scope.$watch(
  168 + function() {
  169 + return scope[ctrlAs].$$dataSelected;
  170 + },
  171 + function(newValue, oldValue) {
  172 + scope[ctrlAs].$$internal_validate_model();
  173 + },
  174 + true
  175 + );
  176 +
  177 + /**
  178 + * 验证数据是否初始化完成,
  179 + * 所谓的初始化就是内部所有的数据被有效设定过一次。
  180 + */
  181 + scope[ctrlAs].$$internal_validate_init = function() {
  182 + var self = scope[ctrlAs];
  183 +
  184 + var data_temp = self.$$data;
  185 + var dataSelect_temp = self.$$dataSelected;
  186 + var bcttinfoids = null;
  187 +
  188 + var i = 0;
  189 + var j = 0;
  190 +
  191 + if (self.$$data_bcdata_first_init &&
  192 + self.$$data_bcttinfoids_first_init) {
  193 + console.log("开始初始化数据");
  194 +
  195 + bcttinfoids = self.$$data_bcttinfoids_first_data ? self.$$data_bcttinfoids_first_data.split(",") : [];
  196 +
  197 + for (i = 0; i < bcttinfoids.length; i++) {
  198 + dataSelect_temp.push({
  199 + bcttinfoid: bcttinfoids[i]
  200 + });
  201 + for (j = 0; j < data_temp.length; j++) {
  202 + if (dataSelect_temp[i].bcttinfoid == data_temp[j].bcttinfoid) {
  203 + dataSelect_temp[i].bcfcsj = data_temp[j].bcfcsj;
  204 + dataSelect_temp[i].bctype = data_temp[j].bctype;
  205 + break;
  206 + }
  207 + }
  208 + }
  209 +
  210 + console.log("数据初始化完毕!");
  211 + }
  212 +
  213 + };
  214 +
  215 + // 监控初始化标志
  216 + scope.$watch(
  217 + function() {
  218 + return scope[ctrlAs].$$data_bcdata_first_init;
  219 + },
  220 + function(newValue, oldValue) {
  221 + scope[ctrlAs].$$internal_validate_init();
  222 + }
  223 + );
  224 + scope.$watch(
  225 + function() {
  226 + return scope[ctrlAs].$$data_bcttinfoids_first_init;
  227 + },
  228 + function(newValue, oldValue) {
  229 + scope[ctrlAs].$$internal_validate_init();
  230 + }
  231 + );
  232 +
  233 + // 监控内部数据的变化
  234 + attr.$observe("dataparams", function(value) {
  235 + if (value && value != "") {
  236 + console.log("observe 监控 dataparams=" + value);
  237 +
  238 + var obj = JSON.parse(value);
  239 + timeTableDetailManageService_g.bcdetails.list(
  240 + obj,
  241 + function(result) {
  242 + // 获取值了
  243 + console.log("内部班次数据获取了");
  244 +
  245 + scope[ctrlAs].$$data = [];
  246 + for (var i = 0; i < result.length; i++) {
  247 + scope[ctrlAs].$$data.push({
  248 + bcttinfoid: result[i].id,
  249 + bcfcsj: result[i].fcsj,
  250 + bctype: result[i].bcType
  251 + });
  252 + }
  253 + if (scope[ctrlAs].$$data_bcdata_first_init &&
  254 + scope[ctrlAs].$$data_bcttinfoids_first_init) {
  255 +
  256 + scope[ctrlAs].$$dataSelected = [];
  257 + scope[ctrlAs].$$internalmodel = undefined;
  258 + }
  259 + scope[ctrlAs].$$data_bcdata_first_init = true;
  260 + },
  261 + function(result) {
  262 +
  263 + }
  264 + );
  265 + }
  266 + });
  267 + // 监控班次ids数据的变化
  268 + attr.$observe("bcttinfoidsvalue", function(value) {
  269 + if (value && value != "") {
  270 + console.log("observe 监控 bcttinfoidsvalue=" + value);
  271 + scope[ctrlAs].$$data_bcttinfoids_first_init = true;
  272 + scope[ctrlAs].$$data_bcttinfoids_first_data = value;
  273 + }
  274 + });
  275 +
  276 + }
  277 + }
  278 +
  279 + }
  280 + }
  281 + }
282 ]); 282 ]);
283 \ No newline at end of file 283 \ No newline at end of file