AirPort.java
2.6 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
package com.air.model;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.air.model.base.BaseAirPort;
import com.jfinal.log.Log;
@SuppressWarnings("serial")
public class AirPort extends BaseAirPort<AirPort> {
public static final AirPort dao = new AirPort();
public String table() {
return "WDS_"+getClass().getSimpleName();
}
/**
*
* @param stationArea
* 货站区域标识
* @param isArrival
* 是否为进港(提货)业务
* @return
*/
public List<AirPort> getAirPortList(String stationArea, boolean isArrival) {
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("stationArea", stationArea);
maps.put("isArrival", isArrival);
return AirPort.dao.search(maps);
}
/**
* 查询某个货站最空闲的码头
*
* @param stationArea
* 货站的区域代码
*
* @param isArrival
* 是否为进港业务(即提货)
* @return
*/
public AirPort free(String stationArea, boolean isArrival) {
String sql = "select * from " + table();
sql += " where stationArea='" + stationArea + "'";
sql += " and isArrival=" + isArrival + "";
String orderBy = " order by waitCount asc";
sql += orderBy;
Log.getLog(getClass()).error("sql-->" + sql);
return AirPort.dao.findFirst(sql);
}
/**
* 查询某个货站最空闲的码头(没有进港业务(即提货)
*
* @param stationArea
* 货站的区域代码
* @return
*/
public AirPort freetwo(String stationArea) {
String sql = "select * from " + table();
sql += " where stationArea='" + stationArea + "'";
String orderBy = " order by waitCount asc";
sql += orderBy;
Log.getLog(getClass()).error("sql-->" + sql);
return AirPort.dao.findFirst(sql);
}
public boolean enter(String stationArea, boolean isArrival, int portNo) {
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("stationArea", stationArea);
maps.put("isArrival", isArrival);
maps.put("portNo", portNo);
AirPort model = AirPort.dao.searchFirst(maps);
if (model != null) {
model.setWaitCount(model.getWaitCount() + 1);
return model.update();
}
return false;
}
public boolean left(String stationArea, boolean isArrival, int portNo) {
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("stationArea", stationArea);
maps.put("isArrival", isArrival);
maps.put("portNo", portNo);
AirPort model = AirPort.dao.searchFirst1(maps);
if (model != null) {
int count = model.getWaitCount() - 1;
if (count < 0) {
count = 0;
}
model.setWaitCount(count);
return model.update();
}
return false;
}
}