IceDistrictClient.java
1.48 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
package com.glsx.ice.iceClient;
import com.glsx.config.SystemProperty;
import com.glsx.ice.DISTRICT.IDistrictFinderPrx;
import com.glsx.ice.DISTRICT.IDistrictFinderPrxHelper;
import com.glsx.model.DTO.BsRecordDto;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
@Slf4j
public class IceDistrictClient {
static String url = SystemProperty.getProperty("ice.districUrl");
static Ice.Communicator ic = Ice.Util.initialize();
static Ice.ObjectPrx base = ic.stringToProxy(url).ice_timeout(Integer.parseInt(SystemProperty.getProperty("ice.connectTimeout")));
static IDistrictFinderPrx prx = IDistrictFinderPrxHelper.checkedCast(base);
/**
* 通过经纬度查询所属行政区域
* @return
*/
public static List<BsRecordDto> getDistInfoByPos(float lng, float lat) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
}
Ice.IntHolder distCode = new Ice.IntHolder();
Ice.StringHolder strDistName = new Ice.StringHolder();
boolean res = prx.get_distinfo_by_pos(lng,lat,distCode,strDistName);
if (res) {
log.info("success===getDistInfoByPos:" + distCode+"=="+strDistName);
}
} catch (Ice.LocalException e) {
log.error("===getDistInfoByPos_ICE_EXCEP:" + e.getMessage(), e);
} catch (Exception e) {
log.error("===getDistInfoByPos_EXCEP:" + e.getMessage(), e);
}
return null;
}
}