CarParkServiceImpl.java
12.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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
package com.bsth.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.bsth.common.ResponseCode;
import com.bsth.entity.CarPark;
import com.bsth.repository.CarParkRepository;
import com.bsth.service.CarParkService;
import com.bsth.util.TransGPS;
import com.bsth.util.TransGPS.Location;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implements CarParkService {
@Autowired
CarParkRepository carParkRepository;
@Override
public Map<String, Object> carParkSave(Map<String, Object> map) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
// 停车场编码
String parkCode = map.get("parkCode").equals("") ? null : map.get("parkCode").toString();
// 停车场id
Integer id = Integer.parseInt(parkCode);
// 停车场名称
String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString();
// 地理位置(百度坐标集合)
String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString();
// 地理位置(WGS坐标集合)
// String gParkPoint = map.get("gParkPoint").equals("") ? "" :map.get("gParkPoint").toString();
// 多边形WGS坐标点集合
String gParkPoint ="";
if(!bParkPoint.equals("")) {
String bPloygonGridArray[] = bParkPoint.split(",");
int bLen_ = bPloygonGridArray.length;
for(int b = 0 ;b<bLen_;b++) {
String tempArray[]= bPloygonGridArray[b].split(" ");
Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
if(b==0) {
gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat();
}else {
gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
}
}
}
bParkPoint = "POLYGON((" + bParkPoint +"))";
gParkPoint = "POLYGON((" + gParkPoint +"))";
// 地理位置中心点(百度坐标)
String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString();
// 地理位置中心点(WGS坐标)
// String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString();
String bJwpointsArray[] =null;
if(bCenterPoint!=null) {
bJwpointsArray = bCenterPoint.split(" ");
}
String gCenterPoint = "";
if(bJwpointsArray.length>0) {
Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
}
// 坐标类型
String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
// 图形类型
String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
// 半径
Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
// 面积
double area = map.get("area").equals("") ? null : Double.parseDouble(map.get("area").toString());
// 公司
String company = map.get("company").equals("") ? "" : map.get("company").toString();
// 分公司
String brancheCompany = map.get("brancheCompany").equals("") ? "" : map.get("brancheCompany").toString();
// 是否撤销
Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
// 版本号
Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
// 描述与说明
String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
// 创建日期
String createDate = formatter.format(date);
// 修改日期
String updateDate = formatter.format(date);
// 创建人
Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
// 修改人
Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
carParkRepository.carParkSave(id, area, company, parkCode, parkName,
brancheCompany, createBy, createDate, descriptions, destroy,
updateBy, updateDate, versions, bCenterPoint, bParkPoint,
dbType, gCenterPoint, gParkPoint, radius, shapesType);
resultMap.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
resultMap.put("status", ResponseCode.ERROR);
logger.error("save erro.", e);
}
return resultMap;
}
@Override
public List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map) {
// 获取线路ID
Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString());
List<Object[]> objects = carParkRepository.findCarParkInfoFormId(id);
List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
int len = objects.size();
if(objects.size()>0) {
for(int i = 0 ; i < len; i++) {
Map<String, Object> tempM = new HashMap<String,Object>();
tempM.put("carParkId", objects.get(i)[0]);
tempM.put("carParkArea", objects.get(i)[1]);
tempM.put("carParkCompany", objects.get(i)[2]);
tempM.put("carParkCode", objects.get(i)[3]);
tempM.put("carParkName", objects.get(i)[4]);
tempM.put("carParkBrancheCompany", objects.get(i)[5]);
tempM.put("carParkCreateBy", objects.get(i)[6]);
tempM.put("carParkCreateDate", objects.get(i)[7]);
tempM.put("carParkDescriptions", objects.get(i)[8]);
tempM.put("carParkDestroy", objects.get(i)[9]);
tempM.put("carParkUpdate", objects.get(i)[10]);
tempM.put("carParkUpdateDate", objects.get(i)[11]);
tempM.put("carParkVersions", objects.get(i)[12]);
tempM.put("carParkBcenterPoint", objects.get(i)[13]);
tempM.put("carParkBparkPoint", objects.get(i)[14]);
tempM.put("carParkGcenterPoint", objects.get(i)[15]);
tempM.put("carParkGparkPoint", objects.get(i)[16]);
tempM.put("carParkDBtype", objects.get(i)[17]);
tempM.put("carParkRadius", objects.get(i)[18]);
tempM.put("carParkShapesType", objects.get(i)[19]);
resultList.add(tempM);
}
}
return resultList;
}
/**
* 修改停车场信息
*
*
* @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;
*
* brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;
*
* destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;
*
* parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>
*
* @return map <SUCCESS:成功;ERROR:失败>
*
*/
@Override
public Map<String, Object> carParkUpdate(Map<String, Object> map) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
// id
Integer id = map.get("id").equals("") ? null : Integer.parseInt(map.get("id").toString());
if(id!=null) {
// 面积
double area = map.get("area").equals("") ? null : Double.parseDouble(map.get("area").toString());
// 中心点(百度坐标)
String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString();
// 图形坐标点集合(百度坐标)
String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString();
// 分公司
String brancheCompany = map.get("brancheCompany").equals("")? "" :map.get("brancheCompany").toString();
// 公司
String company = map.get("company").equals("") ? "" : map.get("company").toString();
// 坐标类型
String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
// 描述与说明
String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
// 是否撤销
Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
// 中心点(WGS坐标)
// String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString();
String bJwpointsArray[] =null;
if(bCenterPoint!=null) {
bJwpointsArray = bCenterPoint.split(" ");
}
String gCenterPoint = "";
if(bJwpointsArray.length>0) {
Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
}
// 图形坐标点集合(WGS坐标)
// String gParkPoint = map.get("gParkPoint").equals("") ? "" : map.get("gParkPoint").toString();
// 多边形WGS坐标点集合
String gParkPoint ="";
if(!bParkPoint.equals("")) {
String bPloygonGridArray[] = bParkPoint.split(",");
int bLen_ = bPloygonGridArray.length;
for(int b = 0 ;b<bLen_;b++) {
String tempArray[]= bPloygonGridArray[b].split(" ");
Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
if(b==0) {
gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat();
}else {
gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
}
}
}
bParkPoint = "POLYGON((" + bParkPoint +"))";
gParkPoint = "POLYGON((" + gParkPoint +"))";
// 编码
String parkCode = map.get("parkCode").equals("") ? "" : map.get("parkCode").toString();
// 名称
String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString();
// 半径
Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
// 图形类型
String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
// 版本
Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
// 创建人
Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
// 创建日期
String createDate = map.get("createDate").equals("") ? "" : map.get("createDate").toString();
Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
// 修改日期
String updateDate = formatter.format(date);
carParkRepository.carParkUpdate(area, company, parkCode, parkName, brancheCompany, createBy, createDate, descriptions, destroy, updateBy, updateDate, versions, bCenterPoint, gCenterPoint, bParkPoint, gParkPoint, dbType, radius, shapesType, id);
}
resultMap.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
resultMap.put("status", ResponseCode.ERROR);
logger.error("save erro.", e);
}
return resultMap;
}
/** 百度坐标转WGS坐标 */
public Location FromBDPointToWGSPoint(String bLonx,String bLatx) {
double lng = Double.parseDouble(bLonx);
double lat = Double.parseDouble(bLatx);
Location bdLoc = TransGPS.LocationMake(lng, lat);
Location location = TransGPS.bd_decrypt(bdLoc);
Location WGSPoint = TransGPS.transformFromGCJToWGS(location);
return WGSPoint;
}
}