GoodsController.java
6.3 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package com.teplot.air.controller;
import java.util.HashMap;
import java.util.Map;
import com.air.model.Goods;
import com.air.model.GoodsStatus;
import com.jfinal.aop.Before;
import com.teplot.air.common.AbsController;
import com.teplot.air.validator.GoodsValidator;
import com.teplot.common.BaseController;
import com.teplot.common.Response;
/**
*
* Depiction:
* <p>
* Modify:
* <p>
* Author: Kevin Lynn
* <p>
* Create Date:2017年5月25日 上午10:36:55
*
*/
@Before(GoodsValidator.class)
public class GoodsController extends AbsController {
public void add() {
Response ret = new Response(CODE_FAILURE);
Goods model = getModel(Goods.class, "");
if (model != null) {
model.set("orderUid", 0);
if (model.save()) {
ret = new Response(CODE_SUCCESS);
}
}
renderJson(ret);
}
public void delete() {
Response ret = new Response(CODE_FAILURE);
Integer id = getParaToInt("id");
Integer uid = getParaToInt("uid");
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("id", id);
maps.put("uid", uid);
Goods model = Goods.dao.searchFirst(maps);
if (model != null && model.delete()) {
ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
} else {
ret.setMsg("货物不存在");
}
renderJson(ret);
}
public void edit() {
Response ret = new Response(CODE_FAILURE);
Goods model = getModel(Goods.class, "");
if (model != null) {
Integer id = model.getInt("id");
Integer uid = model.getInt("uid");
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("id", id);
maps.put("uid", uid);
Goods temp = Goods.dao.searchFirst(maps);
if (temp != null) {
if (model.update()) {
ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
}
} else {
ret.setMsg("货物不存在");
}
}
renderJson(ret);
}
public void my() {
Response ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
Integer status = getParaToInt("status", -1);
Integer ownerId = getParaToInt("uid", 0);
Integer page = getParaToInt("page", 1);
page = page < 1 ? 1 : page;
Integer pageNum = getParaToInt("pageNum", 20);
pageNum = page < 1 ? 20 : pageNum;
String key = getPara("key");
ret = Goods.dao.search(ownerId, true, page, pageNum, key, GoodsStatus.valueOf(status));
renderJson(ret);
}
public void list() {
Response ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
Integer status = getParaToInt("status", -1);
Integer agentId = getParaToInt("uid", 0);
Integer page = getParaToInt("page", 1);
page = page < 1 ? 1 : page;
Integer pageNum = getParaToInt("pageNum", 20);
pageNum = page < 1 ? 20 : pageNum;
String key = getPara("key");
ret = Goods.dao.search(agentId, false, page, pageNum, key, GoodsStatus.valueOf(status));
renderJson(ret);
}
// 货代接单
public void taken() {
Response ret = new Response(CODE_FAILURE);
Integer goodsId = getParaToInt("goodsId", 0);
Goods model = Goods.dao.findById(goodsId);
if (model != null) {
GoodsStatus status = GoodsStatus.valueOf(model.getInt("status"));
if (status == GoodsStatus.ENTRUSTING) {
model.set("status", GoodsStatus.TAKEN.ordinal());
Integer uid = getParaToInt("uid", 0);
model.set("orderUid", uid);
if (model.update()) {
ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
}
} else {
ret.setMsg("货物已被接单");
}
} else {
ret.setMsg("货物不存在");
}
renderJson(ret);
}
// 提交机场系统的货运单号
public void orderNo() {
Response ret = new Response(CODE_FAILURE);
String orderNo = getPara("orderNo");
Integer uid = getParaToInt("uid", 0);
Integer goodsId = getParaToInt("goodsId", 0);
Map<String, Object> maps = new HashMap<String,Object>();
maps.put("orderUid", uid);
maps.put("id", goodsId);
Goods model = Goods.dao.searchFirst(maps);
if (model != null) {
GoodsStatus status = GoodsStatus.valueOf(model.getInt("status"));
if (status == GoodsStatus.TAKEN) {
model.set("status", GoodsStatus.TRANSPORT.ordinal());
model.set("orderNo", orderNo);
if (model.update()) {
ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
}
} else {
ret.setMsg("货物状态异常");
}
} else {
ret.setMsg("货物状态异常");
}
renderJson(ret);
}
// 货物已接单
public void receipt() {
Response ret = new Response(CODE_FAILURE);
Integer uid = getParaToInt("uid", 0);
Integer goodsId = getParaToInt("goodsId", 0);
Map<String, Object> maps = new HashMap<String,Object>();
maps.put("orderUid", uid);
maps.put("id", goodsId);
Goods model = Goods.dao.searchFirst(maps);
if (model != null) {
GoodsStatus status = GoodsStatus.valueOf(model.getInt("status"));
if (status == GoodsStatus.TRANSPORT) {
model.set("status", GoodsStatus.FINISH.ordinal());
if (model.update()) {
ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
}
} else {
ret.setMsg("货物状态异常");
}
} else {
ret.setMsg("货物状态异常");
}
renderJson(ret);
}
public void query() {
// 进港下面显示:
// 运抵时间: shipTime
// 理货时间: dealTime
// 报关时间: 默认为空先 applyTime
// 提货时间: pickTime
//
// 离港业务:
// 接单时间:receiptTime
// 收运时间:shipTime
// 交单时间:submitTime
// 正式舱单:默认为空先 formalTime
// 机坪交接:默认为空先 aerodromeTime
// 离境时间:leaveTime
Response ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
renderJson(ret);
}
// 代理企业代码 companyNum
// 航次编号 airNum
// 运输工具名称 trafficName
// 运输方式代码 shipTypeNum
// 承运人代码 shiperNum
// 总提运单号 totalSingleNum
// 分提运单号 singleNum
// 运输条款代码 itemNum
// 货物信息
// 货物体积 volume;
// 货物价值 price;
// 货币类型 currencyType;
// 货物托运地 startPlace;
// 包装种类 packType;
// 货物件数 piece;
// 货物中毛重 grossWeight;
// 收货地址
// 收货地代码 desNum;
// 收货地名称 desName;
public void preplan() {
Response ret = new Response(CODE_SUCCESS);
ret.setMsg(BaseController.MSG_SUCCESS);
renderJson(ret);
}
}