LedKit.java
4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package com.air.led;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jfinal.log.Log;
import com.air.model.AirPortCar;
import com.air.model.AirPortCarStatus;
import com.jfinal.kit.HttpKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
/**
* Depiction:
* <p>
* Modify:
* <p>
* Author: Kevin Lynn
* <p>
* Create Date:2017年8月22日 下午2:51:17
*
*/
public class LedKit {
final static String LED_API = "http://10.50.3.66:8080/LEDAPI.ashx";
final static String APP_KEY = "93FCC7C01F0E410EACC0A1692BD1B7A1";
public LedKit() {
}
/**
* 显示某个货站中某个码头的下一辆车牌信息
*
* @param stationArea
* 货站区域代码
* @param port
* 码头编码
* @param isPickUp
* 是否为提货
*/
public static void nextCar(String stationArea, int port, boolean isPickUp) {
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("stationArea", stationArea);
maps.put("portNo", port);
String sql = "select * from " + AirPortCar.dao.table();
sql += " where stationArea='" + stationArea + "'";
sql += " and isPickup=" + isPickUp + "";
sql += " and status=" + AirPortCarStatus.ENTER.ordinal();
sql += " and portNo=" + port;
String orderBy = " order by ID asc";
sql += orderBy;
AirPortCar model = AirPortCar.dao.findFirst(sql);
String carNo = "空闲";
if (model != null) {
carNo = model.getCarNo();
}
LedKit.senPortLedScreen(carNo, stationArea, port, isPickUp);
}
/**
*
* @param msg
* 码头LED要显示的信息
* @param stationArea
* 码头所属货站区域代码
* @param portNo
* 码头编号
* @param isPickUp
* 是否为提货业务
*/
public static void senPortLedScreen(String msg, String stationArea, int portNo, boolean isPickUp) {
try {
final Map<String, String> queryParas = new HashMap<String, String>();
queryParas.put("appkey", APP_KEY);
System.out.println(msg+stationArea+portNo+isPickUp);
LedJson led = new LedJson(Led.getLed(portNo, isPickUp), 1, msg);
queryParas.put("jsonValues", led.toString());
System.out.println(queryParas);
new Thread() {
public void run() {
String msg= HttpKit.get(LED_API, queryParas);
System.out.println(msg);
}
}.start();
} catch (Exception e) {
}
}
/**
*
* @param msg
* 大屏要显示的信息
* @param stationArea
* 大屏所属货站区域代码
*/
public static void sendBigLedScreen(String msg, String stationArea) {
try {
final Map<String, String> queryParas = new HashMap<String, String>();
queryParas.put("appkey", APP_KEY);
LedJson led = new LedJson(Led.getBigLed(), 1, msg);
queryParas.put("jsonValues", led.toString());
new Thread() {
public void run() {
HttpKit.get(LED_API, queryParas);
}
}.start();
} catch (Exception e) {
}
}
/**
*
* @param portNo
* @param isPickUp
* @param carNo
* @param stationArea
* @return
*/
public static String bigLedText(int portNo, boolean isPickup, String carNo, String stationArea) {
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("stationArea", stationArea);
maps.put("portNo", portNo);
maps.put("isPickup", isPickup);
maps.put("status", AirPortCarStatus.ENTER.ordinal());
List<AirPortCar> dataList = AirPortCar.dao.search(maps);
int count = dataList != null ? dataList.size() : 0;
if (count > 0) {
count = count - 1;
}
StringBuilder sb = new StringBuilder();
sb.append("车牌号:" + carNo + "\r\n");
sb.append("请进入");
sb.append(portNo);
sb.append("号码头\r\n");
sb.append("前面有");
sb.append(count);
sb.append("辆车");
return sb.toString();
}
// 大屏复位
public static void recovery() {
// 0 待进场;1 已进场;2 已离场;
Number number = Db.queryNumber("select count(*) from WDS_AirPortCar where status=1");
int count = number.intValue();
if (count < 5) {
try {
final Map<String, String> queryParas = new HashMap<String, String>();
queryParas.put("appkey", APP_KEY);
LedJson led = new LedJson(Led.getBigLed(), 0, "空闲");
queryParas.put("jsonValues", led.toString());
new Thread() {
public void run() {
HttpKit.get(LED_API, queryParas);
}
}.start();
} catch (Exception e) {
}
}
}
}