IceHDaoGpsClient.java
6.47 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
package com.glsx.ice.iceClient;
import com.glsx.config.SystemProperty;
import com.glsx.ice.HDaoGps.*;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
public class IceHDaoGpsClient {
static String url = SystemProperty.getProperty("ice.trace.interface.url");
// static String url = "HDaoGpsSvc:default -h 192.168.3.153 -p 23479";
static Ice.Communicator ic = Ice.Util.initialize();
static Ice.ObjectPrx base = ic.stringToProxy(url).ice_timeout(Integer.parseInt(SystemProperty.getProperty("ice.connect.timeout")));
static DaoGpsServicePrx prx= DaoGpsServicePrxHelper.checkedCast(base);
/**HDaoGpsSvc:default -h 192.168.3.153 -p 23479
* 获取一段时间的轨迹
* @param apType 2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
* @param beginTime 开始时间
* @param endTime 结束时间
* @param userId 嘀嘀号
* @return
*/
public static List<GpsRecord> getTrack(int apType, Date beginTime, Date endTime, long userId)
{
try {
if (prx == null) {
throw new Exception("Invalid proxy");
}
if (beginTime.after(endTime)) {
return null;
}
GpsGetResponseHolder res=new GpsGetResponseHolder(new GpsGetResponse());
GpsGetRequest req = new GpsGetRequest();
req.apType = apType;
req.startTime = new Long(beginTime.getTime()/1000).intValue();
req.endTime = new Long(endTime.getTime()/1000).intValue();
req.extraMapReq=1;
req.reqCount = 0;
req.userID = userId;
prx.getGpsRecords(req, res);
List<GpsRecord> list = new ArrayList<GpsRecord>();
if(res!=null && res.value!=null && res.value.oprResult == 0)
{
GpsRecord[] r = res.value.records;
int len = r.length;
for(int i=0;i<len;i++)
{
GpsRecord rec = r[i];
log.debug("====GpsRecord:"+rec);
//GpsRecord g = new GpsRecord();
////BeanUtils.copyProperties(g, rec);
//g.setbLat((int) (rec.getbLat()/1000000D));
//g.setbLng((int) (rec.getbLng()/1000000D));
//g.setSpeed(rec.getSpeed());
//g.setgLat((int) (rec.getgLat()/1000000D));
//g.setgLng((int) (rec.getgLng()/1000000D));
//
//g.setLat((int) (rec.getLat()/1000000D));
//g.setLng((int) (rec.getLng()/1000000D));
//g.setGpsTime(rec.getGpsTime());
//g.setStoreTime(rec.getStoreTime());
//list.add(g);
}
return list;
}
} catch (Ice.LocalException e) {
log.error("===getTrack_ICE_EXCEP:" + e.getMessage(), e);
} catch (Exception e) {
log.error("===getTrack_EXCEP:" + e.getMessage(), e);
}
return null;
}
public static List<GpsRecord> getTrackByImei(int type, Date beginTime, Date endTime, long sn) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
}
if (beginTime.after(endTime)) {
return null;
}
GpsGetExResponseHolder res=new GpsGetExResponseHolder(new GpsGetExResponse());
GpsGetRequest req = new GpsGetRequest();
req.apType = type;
req.startTime = new Long(beginTime.getTime()/1000).intValue();;
req.endTime = new Long(endTime.getTime()/1000).intValue();
req.extraMapReq=1;
req.reqCount = 0;
req.userID = sn;
prx.getGpsRecordsByImei(req, res);
List<GpsRecord> list = new ArrayList<GpsRecord>();
if(res!=null && res.value!=null && res.value.oprResult == 0)
{
GpsRecord[] r = res.value.records;
int len = r.length;
for(int i=0;i<len;i++)
{
GpsRecord rec = r[i];
log.debug("====TrackByImei:"+rec);
//GpsRecord g = new GpsRecord();
////BeanUtils.copyProperties(g, rec);
//g.setbLat((int) (rec.getbLat()/1000000D));
//g.setbLng((int) (rec.getbLng()/1000000D));
//g.setSpeed(rec.getSpeed());
//g.setgLat((int) (rec.getgLat()/1000000D));
//g.setgLng((int) (rec.getgLng()/1000000D));
//
//g.setLat((int) (rec.getLat()/1000000D));
//g.setLng((int) (rec.getLng()/1000000D));
//g.setGpsTime(rec.getGpsTime());
//g.setStoreTime(rec.getStoreTime());
//
//list.add(g);
}
return list;
}
} catch (Ice.LocalException e) {
log.error("===getTrackByImei_ICE_EXCEP:" + e.getMessage(), e);
} catch (Exception e) {
log.error("===getTrackByImei_EXCEP:" + e.getMessage(), e);
}
return null;
}
public static GpsRecord getLatestRGPSRecord(Long userId, Integer deviceType, Integer mapType) {
GpsRecord gpsRecord = null;
try {
if (prx == null) {
throw new Exception("Invalid proxy");
}
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestRgpsGetRequest req = new LatestRgpsGetRequest(userId, deviceType, mapType);
LatestRgpsGetResponseHolder res = new LatestRgpsGetResponseHolder();
boolean ret = false;
ret = prx.getLatestRgpsRecord(req,res);
log.info("===getLatestRGPSRecord:" + ret);
if(ret) {
log.info("===getLatestRGPSRecord:" + res.value.record);
//gpsRecord = new GpsRecord();
//gpsRecord.setgLng(res.value.record.gLng);
//gpsRecord.setgLat(res.value.record.gLat);
//gpsRecord.setLng(res.value.record.lng);
//gpsRecord.setLat(res.value.record.lat);
//gpsRecord.setSpeed(res.value.record.speed);
//gpsRecord.setAlt(res.value.record.alt);
//gpsRecord.setGpsTime(res.value.record.gpsTime);
}
} catch (Ice.LocalException e) {
log.error("===getLatestRGPSRecord_ICE_EXCEP:" + e.getMessage(), e);
} catch (Exception e) {
log.error("===getLatestRGPSRecord_EXCEP:" + e.getMessage(), e);
}
return gpsRecord;
}
public static BsRecord getLatestBsRecord(long userId, Integer deviceType) {
BsRecord bsRecord = null;
try {
if (prx == null) {
throw new Exception("Invalid proxy");
}
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestBsGetResponseHolder res = new LatestBsGetResponseHolder();
boolean ret = false;
LatestBsGetRequest req = new LatestBsGetRequest(userId, deviceType);
ret = prx.getLatestBsRecord(req, res);
log.info("===getLatestBsRecord:" + ret);
if(ret) {
log.info("===LatestBsRecord:" + res.value.record);
int gpsTime = res.value.record.gpsTime;
int storeTime = res.value.record.storeTime;
int mcc = res.value.record.mcc;
int mnc = res.value.record.mnc;
BsInfo[] bsInfos = res.value.record.bsInfos;
bsRecord = new BsRecord(gpsTime,storeTime,mcc,mnc,bsInfos);
}
} catch (Ice.LocalException e) {
log.error("===getLatestBsRecord_ICE_EXCEP:" + e.getMessage(), e);
} catch (Exception e) {
log.error("===getLatestBsRecord_EXCEP:" + e.getMessage(), e);
}
return bsRecord;
}
}