IceDistrictClient.java 1.48 KB
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;
    }


}