Commit bd498804df8913a3a9b8dacdee38d410ed9710d3

Authored by ljq
1 parent c13b5e5b

20223-10-09 初步完成考试框架

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 +上海交通职业技术学院智慧交通系 2023
  2 +新型高职建设“公共交通运营调度教学
  3 +资源”项目
452 4 \ No newline at end of file
... ...
... ... @@ -402,6 +402,13 @@
402 402 <version>2.4</version>
403 403 <classifier>jdk15</classifier>
404 404 </dependency>
  405 +
  406 +
  407 + <dependency>
  408 + <groupId>org.javassist</groupId>
  409 + <artifactId>javassist</artifactId>
  410 + <version>3.21.0-GA</version>
  411 + </dependency>
405 412 </dependencies>
406 413  
407 414 <dependencyManagement>
... ...
src/main/java/com/bsth/controller/subject/SubjectController.java 0 → 100644
  1 +package com.bsth.controller.subject;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.subject.Subject;
  5 +import com.bsth.service.subject.SubjectService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +@RestController
  11 +@RequestMapping("subject")
  12 +public class SubjectController extends BaseController<Subject, Integer> {
  13 +
  14 + @Autowired
  15 + SubjectService subjectService;
  16 +
  17 +}
... ...
src/main/java/com/bsth/controller/subject/SubjectUserController.java 0 → 100644
  1 +package com.bsth.controller.subject;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.subject.Subject;
  5 +import com.bsth.entity.subject.SubjectUser;
  6 +import com.bsth.service.subject.SubjectService;
  7 +import com.bsth.service.subject.SubjectUserService;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +
  16 +@RestController
  17 +@RequestMapping("subjectUser")
  18 +public class SubjectUserController extends BaseController<SubjectUser, Integer> {
  19 + @Autowired
  20 + SubjectUserService subjectUserService;
  21 +
  22 + //查看题目
  23 + @RequestMapping("/userAll")
  24 + public List<SubjectUser> userAll(){
  25 + return subjectUserService.userAll();
  26 + }
  27 + //判断用户答题是否正确
  28 + @RequestMapping("/determine")
  29 + public String determine(@RequestParam("id") Integer id){
  30 + return subjectUserService.determine(id);
  31 + }
  32 +
  33 +
  34 +}
... ...
src/main/java/com/bsth/entity/subject/Subject.java 0 → 100644
  1 +package com.bsth.entity.subject;
  2 +
  3 +import javax.persistence.*;
  4 +
  5 +@Entity
  6 +@Table(name = "bsth_subject")
  7 +public class Subject {
  8 + /** 主键Id */
  9 + @Id
  10 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  11 + private Integer id;
  12 + //题目或场景描述
  13 + private String subjectText;
  14 + //操作
  15 + private String operateTest;
  16 + //待发时间
  17 + private String fcsj;
  18 + //考题类型
  19 + private String type;
  20 + //上下行
  21 + private String dir;
  22 + //应对答案
  23 + private String answer;
  24 +
  25 + public String getSubjectText() {
  26 + return subjectText;
  27 + }
  28 +
  29 + public void setSubjectText(String subjectText) {
  30 + this.subjectText = subjectText;
  31 + }
  32 +
  33 + public String getOperateTest() {
  34 + return operateTest;
  35 + }
  36 +
  37 + public void setOperateTest(String operateTest) {
  38 + this.operateTest = operateTest;
  39 + }
  40 +
  41 +
  42 + public String getFcsj() {
  43 + return fcsj;
  44 + }
  45 +
  46 + public void setFcsj(String fcsj) {
  47 + this.fcsj = fcsj;
  48 + }
  49 +
  50 + public String getType() {
  51 + return type;
  52 + }
  53 +
  54 + public void setType(String type) {
  55 + this.type = type;
  56 + }
  57 +
  58 + public String getDir() {
  59 + return dir;
  60 + }
  61 +
  62 + public void setDir(String dir) {
  63 + this.dir = dir;
  64 + }
  65 +
  66 + public String getAnswer() {
  67 + return answer;
  68 + }
  69 +
  70 + public void setAnswer(String answer) {
  71 + this.answer = answer;
  72 + }
  73 +}
... ...
src/main/java/com/bsth/entity/subject/SubjectUser.java 0 → 100644
  1 +package com.bsth.entity.subject;
  2 +
  3 +import javax.persistence.*;
  4 +
  5 +@Entity
  6 +@Table(name = "bsth_subject_user")
  7 +public class SubjectUser {
  8 + /** 主键Id */
  9 + @Id
  10 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  11 + private Integer id;
  12 +
  13 + //用户Id
  14 + private Integer userId;
  15 + //日期
  16 + private String rq;
  17 + //对或错 0/1
  18 + private String result;
  19 +
  20 + //题库id
  21 + @ManyToOne
  22 + private Subject subjectId;
  23 +
  24 + public Integer getId() {
  25 + return id;
  26 + }
  27 +
  28 + public void setId(Integer id) {
  29 + this.id = id;
  30 + }
  31 +
  32 + public Subject getSubjectId() {
  33 + return subjectId;
  34 + }
  35 +
  36 + public void setSubjectId(Subject subjectId) {
  37 + this.subjectId = subjectId;
  38 + }
  39 +
  40 + public Integer getUserId() {
  41 + return userId;
  42 + }
  43 +
  44 + public void setUserId(Integer userId) {
  45 + this.userId = userId;
  46 + }
  47 +
  48 + public String getRq() {
  49 + return rq;
  50 + }
  51 +
  52 + public void setRq(String rq) {
  53 + this.rq = rq;
  54 + }
  55 +
  56 + public String getResult() {
  57 + return result;
  58 + }
  59 +
  60 + public void setResult(String result) {
  61 + this.result = result;
  62 + }
  63 +
  64 +
  65 +}
... ...
src/main/java/com/bsth/repository/LineRepository.java
... ... @@ -40,6 +40,9 @@ public interface LineRepository extends BaseRepository&lt;Line, Integer&gt; {
40 40  
41 41 @Query(value = " SELECT l FROM Line l where l.name like ?1")
42 42 List<Line> findLine(String line);
  43 +
  44 + @Query(value = " SELECT l FROM Line l where l.name = ?1")
  45 + Line findLineName(String lineName);
43 46  
44 47 @Query(value = " SELECT l FROM Line l where l.lineCode = ?1")
45 48 List<Line> findLineByCode(String lineCode);
... ...
src/main/java/com/bsth/repository/subject/SubjectRepository.java 0 → 100644
  1 +package com.bsth.repository.subject;
  2 +
  3 +import com.bsth.entity.subject.Subject;
  4 +import com.bsth.repository.BaseRepository;
  5 +
  6 +public interface SubjectRepository extends BaseRepository<Subject, Integer> {
  7 +
  8 +}
... ...
src/main/java/com/bsth/repository/subject/SubjectUserRepository.java 0 → 100644
  1 +package com.bsth.repository.subject;
  2 +
  3 +import com.bsth.entity.subject.SubjectUser;
  4 +import com.bsth.repository.BaseRepository;
  5 +import org.springframework.data.jpa.repository.Modifying;
  6 +import org.springframework.data.jpa.repository.Query;
  7 +import org.springframework.transaction.annotation.Transactional;
  8 +
  9 +import java.util.List;
  10 +
  11 +public interface SubjectUserRepository extends BaseRepository<SubjectUser, Integer> {
  12 +
  13 +
  14 +
  15 + @Query(value = "SELECT su FROM SubjectUser su where su.rq =?1 and su.userId =?2")
  16 + List<SubjectUser> userAll(String rq, Integer userId);
  17 + @Transactional
  18 + @Modifying
  19 + @Query(value = "update SubjectUser su set su.result =?1 where su.id =?2")
  20 + int updates(String rq, Integer userId);
  21 +}
... ...
src/main/java/com/bsth/service/subject/SubjectService.java 0 → 100644
  1 +package com.bsth.service.subject;
  2 +
  3 +import com.bsth.entity.subject.Subject;
  4 +import com.bsth.service.BaseService;
  5 +
  6 +public interface SubjectService extends BaseService<Subject, Integer> {
  7 +}
... ...
src/main/java/com/bsth/service/subject/SubjectUserService.java 0 → 100644
  1 +package com.bsth.service.subject;
  2 +
  3 +import com.bsth.entity.subject.SubjectUser;
  4 +import com.bsth.service.BaseService;
  5 +
  6 +import java.util.List;
  7 +
  8 +public interface SubjectUserService extends BaseService<SubjectUser, Integer> {
  9 +
  10 +
  11 + List<SubjectUser> userAll();
  12 +
  13 + String determine(Integer id);
  14 +}
... ...
src/main/java/com/bsth/service/subject/impl/SubjectServiceImpl.java 0 → 100644
  1 +package com.bsth.service.subject.impl;
  2 +
  3 +import com.bsth.entity.subject.Subject;
  4 +import com.bsth.service.impl.BaseServiceImpl;
  5 +import com.bsth.service.subject.SubjectService;
  6 +import org.springframework.stereotype.Service;
  7 +
  8 +@Service
  9 +public class SubjectServiceImpl extends BaseServiceImpl<Subject, Integer> implements SubjectService {
  10 +}
... ...
src/main/java/com/bsth/service/subject/impl/SubjectUserServiceImpl.java 0 → 100644
  1 +package com.bsth.service.subject.impl;
  2 +
  3 +import com.bsth.data.schedule.DayOfSchedule;
  4 +import com.bsth.entity.Line;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import com.bsth.entity.subject.SubjectUser;
  7 +import com.bsth.entity.sys.SysUser;
  8 +import com.bsth.repository.LineRepository;
  9 +import com.bsth.repository.subject.SubjectUserRepository;
  10 +import com.bsth.security.util.SecurityUtils;
  11 +import com.bsth.service.impl.BaseServiceImpl;
  12 +import com.bsth.service.subject.SubjectUserService;
  13 +import com.bsth.util.subject.subEnum;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Service;
  16 +
  17 +import java.text.SimpleDateFormat;
  18 +import java.util.*;
  19 +
  20 +@Service
  21 +public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer> implements SubjectUserService {
  22 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  23 +
  24 + @Autowired
  25 + SubjectUserRepository subjectUserRepository;
  26 + @Autowired
  27 + LineRepository lineRepository;
  28 + @Autowired
  29 + DayOfSchedule dayOfSchedule;
  30 +
  31 + public List<SubjectUser> userAll(){
  32 + SysUser user = SecurityUtils.getCurrentUser();
  33 + Integer userId = user.getId();
  34 +
  35 + String ksstatus = user.getKsstatus();//判断今天有没有考试
  36 + String rq = sdf.format(new Date());
  37 + List list = subjectUserRepository.userAll(rq,userId);
  38 + return list;
  39 + }
  40 +
  41 +
  42 + public String determine(Integer id){
  43 +
  44 + //当前题目
  45 + Optional<SubjectUser> subjectUser = subjectUserRepository.findById(id);
  46 + SubjectUser sur = subjectUser.isPresent() ? subjectUser.get() : null;
  47 +
  48 + //线路编号 A线+用户id组成的
  49 + SysUser user = SecurityUtils.getCurrentUser();
  50 + String xlName = "A线-"+user.getUserName();
  51 + Line line = lineRepository.findLineName(xlName);
  52 + //缓存查看排班
  53 + List<ScheduleRealInfo> sch = dayOfSchedule.findByLineCode(line.getLineCode());
  54 +
  55 +
  56 + //答题是否正确
  57 + // String result = result(sur,sch) == true ? "0" : "1";
  58 +
  59 + //类型
  60 + String type = sur.getSubjectId().getType();
  61 + //判断答题是否正确
  62 + subEnum sjm = subEnum.valueOf(type);
  63 + String result = sjm.run(sur,sch) == true ? "0" : "1";
  64 +
  65 + //修改答案
  66 + int status = subjectUserRepository.updates(result,id);
  67 +
  68 + //List list = subjectUserRepository.userAll(sur.getRq(),sur.getUserId());
  69 + // map.put("result",result);
  70 + //map.put("list",list);
  71 + if (status == 1){
  72 + return result;
  73 + }
  74 + return null;
  75 + }
  76 +
  77 +
  78 +
  79 +
  80 +
  81 +}
... ...
src/main/java/com/bsth/util/subject/subEnum.java 0 → 100644
  1 +package com.bsth.util.subject;
  2 +
  3 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  4 +import com.bsth.entity.subject.SubjectUser;
  5 +
  6 +import java.util.List;
  7 +import java.util.stream.Collectors;
  8 +
  9 +public enum subEnum {
  10 + //判断待发
  11 + df{
  12 + @Override
  13 + public boolean run(SubjectUser sur, List<ScheduleRealInfo> sch){
  14 + String sj = sur.getSubjectId().getFcsj();//计划发车时间
  15 + String answer = sur.getSubjectId().getAnswer();//待发是按
  16 + String dir = sur.getSubjectId().getDir();//
  17 + //筛选满足条件的情况下
  18 + //List<ScheduleRealInfo> sh = sch.stream().filter(s -> s.getXlDir().equals(dir)).collect(Collectors.toList());
  19 + //判断结果是否合格
  20 + for (ScheduleRealInfo s : sch) {
  21 + if (s.getFcsj().equals(sj) &&
  22 + s.getXlDir().equals(dir) &&
  23 + s.getDfsj().equals(answer)) {
  24 + return true;
  25 + }
  26 + }
  27 + return false;
  28 + }
  29 + },
  30 + //判断烂班
  31 + lb{
  32 + @Override
  33 + public boolean run(SubjectUser sur, List<ScheduleRealInfo> sch){
  34 + String sj = sur.getSubjectId().getFcsj();//计划发车时间
  35 + String answer = sur.getSubjectId().getAnswer();//答案
  36 + String[] t = answer.split(","); //0 计划里程 1 是否烂班状态 2烂班原因
  37 + String dir = sur.getSubjectId().getDir();//
  38 + //筛选满足条件的情况下
  39 + //List<ScheduleRealInfo> sh = sch.stream().filter(s -> s.getXlDir().equals(dir)).collect(Collectors.toList());
  40 + //判断结果是否合格
  41 + for (ScheduleRealInfo s : sch) {
  42 + if (s.getDfsj().equals(sj) &&
  43 + s.getXlDir().equals(dir) &&
  44 + s.getJhlc() == Double.parseDouble(t[0]) &&
  45 + s.getStatus() == Integer.parseInt(t[1]) &&
  46 + s.getRemarks().contains(t[2])) {
  47 + return true;
  48 + }
  49 + }
  50 + return false;
  51 + }
  52 + },
  53 + //判断烂班后撤销烂班
  54 + clb{
  55 + @Override
  56 + public boolean run(SubjectUser sur, List<ScheduleRealInfo> sch){
  57 + String sj = sur.getSubjectId().getFcsj();//计划发车时间
  58 + String answer = sur.getSubjectId().getAnswer();//答案
  59 + String[] t = answer.split(","); //0 是否烂班状态 1是否烂班过
  60 + String dir = sur.getSubjectId().getDir();//
  61 + //判断结果是否合格
  62 + for (ScheduleRealInfo s : sch) {
  63 + if (s.getDfsj().equals(sj) &&
  64 + s.getXlDir().equals(dir) &&
  65 + s.getStatus() == Integer.parseInt(t[0]) &&
  66 + t[1].equals(s.getAdjustExps())) {
  67 + return true;
  68 + }
  69 + }
  70 + return false;
  71 + }
  72 + },
  73 + jgs{
  74 + @Override
  75 + public boolean run(SubjectUser sur, List<ScheduleRealInfo> sch){
  76 + String sj = sur.getSubjectId().getFcsj();//计划发车时间
  77 + String answer = sur.getSubjectId().getAnswer();//答案
  78 + String[] t = answer.split(","); //0 计划里程
  79 + String dir = sur.getSubjectId().getDir();//
  80 + //筛选满足条件的情况下
  81 + List<ScheduleRealInfo> sh = sch.stream().filter(s -> s.getXlDir().equals(dir)).collect(Collectors.toList());
  82 + //判断结果是否合格
  83 + for (ScheduleRealInfo s : sch) {
  84 +
  85 + }
  86 + return false;
  87 + }
  88 + };
  89 +
  90 +
  91 +
  92 + public abstract boolean run(SubjectUser sur, List<ScheduleRealInfo> sch);
  93 +}
... ...
src/main/resources/application-dev.properties
... ... @@ -14,7 +14,7 @@ spring.jpa.show-sql= false
14 14  
15 15 #DATABASE
16 16 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
17   -spring.datasource.url= jdbc:mysql://127.0.0.1/jp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  17 +spring.datasource.url= jdbc:mysql://127.0.0.1/school_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
18 18 #spring.datasource.url= jdbc:mysql://192.168.168.222/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
19 19 spring.datasource.username= root
20 20 spring.datasource.password= root
... ...
src/main/resources/static/real_control_v2/css/main.css
... ... @@ -2127,4 +2127,20 @@ g.gps-wrap rect.twinkle[updown=&quot;1&quot;] {
2127 2127 stroke: #c94f21;
2128 2128 fill: #c94f21;
2129 2129 }
2130   -}
2131 2130 \ No newline at end of file
  2131 +}
  2132 +.uk-panels .north-tm{
  2133 + padding-left: 400px;
  2134 + font-size: 18px;
  2135 + color: white;
  2136 +}
  2137 +.uk-panels .north-tmx{
  2138 + padding-left: 400px;
  2139 + font-size: 18px;
  2140 + color: red;
  2141 +}
  2142 +.uk-panels .north-button{
  2143 + padding-right: 60px;
  2144 + color: red;
  2145 + position:absolute;
  2146 + right:0;
  2147 +}
... ...
src/main/resources/static/real_control_v2/js/main.js
... ... @@ -29,9 +29,15 @@ var gb_main_ep = new EventProxy(),
29 29  
30 30 //line schedule layout
31 31 eq.once('line-schedule-layout', function () {
32   - gb_line_layout.layout(g_emit('render-sch-table'));
  32 + gb_line_layout.layout(g_emit('subject'));
33 33 });
34 34  
  35 + //考试
  36 + eq.once('subject',function (){
  37 + su_subject.init();
  38 + g_emit('render-sch-table')();
  39 + })
  40 +
35 41 //render schedule table
36 42 eq.once('render-sch-table', function () {
37 43 gb_schedule_table.show(function () {
... ...
src/main/resources/static/real_control_v2/js/subject/subject.js 0 → 100644
  1 +var su_subject = (function () {
  2 +
  3 +
  4 + var $wrap = $('.uk-panels');
  5 + var init =function(cb) {
  6 +
  7 + ks();
  8 +
  9 +
  10 +
  11 + };
  12 +
  13 + function ks(){
  14 + //站点路由
  15 + gb_common.$get('/subjectUser/userAll', '',function (rs) {
  16 + if (rs == null || rs.length == 0) {
  17 + return //当前没有考题或
  18 + }
  19 + debugger
  20 + var list = retunhtml(rs);
  21 +
  22 + $('.north_suject').remove();
  23 + if (list == null)
  24 + return; //所有题目已经考完 无考题的情况
  25 +
  26 + var htmlStr = template('suject_pop_wrap', list);
  27 + $wrap.append(htmlStr);
  28 +
  29 + //提交按钮 //加载完成才可以
  30 + $('.uk-panels .north-button').on('click', function () {
  31 + debugger
  32 + var thisall= $('.uk-panels .north-button #submit');
  33 + var id= thisall.data('id');
  34 + //判断答题是否正确 返回参数 返回下一题的情况
  35 + gb_common.$get('/subjectUser/determine', {id: id},function (rs) {
  36 + if (rs == 0){ //提示答题正确
  37 +
  38 + }else if(rs == 1){ //提示答题失败
  39 +
  40 + }else { //系统出错
  41 +
  42 + }
  43 + ks();
  44 + });
  45 + });
  46 + })
  47 + }
  48 +
  49 +
  50 +
  51 + function retunhtml(list){
  52 + for (let t in list){
  53 + if(list[t].result == null || list[t].result == ""){
  54 + return list[t];
  55 + }
  56 + }
  57 + return null;
  58 + }
  59 +
  60 +
  61 + return {
  62 + init: init
  63 + };
  64 +
  65 +})();
0 66 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/main.html
... ... @@ -62,10 +62,31 @@
62 62 <div class="uk-width-6-10">
63 63 <div class="uk-panel uk-width north-toolbar"></div>
64 64 </div>
  65 +
  66 + <div class="uk-width-10-10">
  67 + <div class="uk-panels">
  68 + </div>
  69 + </div>
  70 +
65 71 </div>
66 72 <div class="north-tabs"></div>
67 73 </div>
68 74  
  75 +<!-- #### 考试 start ### -->
  76 +<script id="suject_pop_wrap" type="text/html">
  77 + <div class="north_suject">
  78 + <div class="north-tm">
  79 + 场景:{{subjectId.subjectText}}
  80 + </div>
  81 + <div class="north-tmx">
  82 + 操作: {{subjectId.operateTest}}
  83 + </div>
  84 + <div class="north-button">
  85 + <button id="submit" class="subject_button" data-id="{{id}}">提交</button>
  86 + </div>
  87 + </div>
  88 +</script>
  89 +
69 90 <div class="main-container">
70 91 <div class="load-panel">
71 92 <i class="uk-icon-spinner uk-icon-spin"></i>
... ... @@ -223,6 +244,8 @@
223 244 <script src="/real_control_v2/js/forms/form_embed.js" merge="custom_js"></script>
224 245 <!-- 模态框扩展 -->
225 246 <script src="/real_control_v2/js/modal_extend.js" merge="custom_js"></script>
  247 +<!-- 考试js-->
  248 +<script src="/real_control_v2/js/subject/subject.js" merge="custom_js"></script>
226 249  
227 250 <!-- #### 安全驾驶 start ### -->
228 251 <div class="safe_driv_pop_wrap" ></div>
... ... @@ -240,8 +263,8 @@
240 263 <!-- #### 安全驾驶 end ### -->
241 264  
242 265 <!-- 打电话 -->
243   -<script src="http://114.80.178.12:9003/forward/voip/callCenterJs"></script>
244   -<script src="http://114.80.178.12:9003/forward/voip/phonePluginJs"></script>
  266 +<!--<script src="http://114.80.178.12:9003/forward/voip/callCenterJs"></script>
  267 +<script src="http://114.80.178.12:9003/forward/voip/phonePluginJs"></script>-->
245 268 <script src="/real_control_v2/js/safe_driv/call_phone.js" ></script>
246 269  
247 270 <script id="voip_call_info_panel-temp" type="text/html">
... ...