CarParkServiceImpl.java
9.05 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
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 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();
// 地理位置中心点(百度坐标)
String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString();
// 地理位置中心点(WGS坐标)
String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString();
// 坐标类型
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;
}
@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();
// 图形坐标点集合(WGS坐标)
String gParkPoint = map.get("gParkPoint").equals("") ? "" : map.get("gParkPoint").toString();
// 编码
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;
}
}