Authored by mali

地址的调整

... ... @@ -40,6 +40,9 @@ public class AreaService {
private static final String GETPROVINCES = "/erp/passport/getProvinces"; //根据地址父id查询子集合
private static final String GETAREABYCODE = "/erp/passport/getAreaByCode"; //根据地址父id查询caption
@Autowired
private ServiceCaller serviceCaller;
... ... @@ -56,7 +59,7 @@ public class AreaService {
public Map<Integer, String> selectByCodeList(Integer uid, List<Integer> codeList) {
if (areaByErp()) {
//return getAddressInfoByErp(uid, codeList.get(3), codeList);
return getAddressInfoByErp(codeList.get(3), codeList);
}
List<Area> areaList = areaMapper.selectByCodeList(codeList);
... ... @@ -64,6 +67,45 @@ public class AreaService {
return areaMap;
}
private Map<Integer, String> getAddressInfoByErp(Integer fourAreaCode, List<Integer> codeList) {
LOGGER.info("method getAddressInfoByErp in codeList is {}", codeList);
Map<String,Object> params = Maps.newHashMap();
params.put("id", fourAreaCode);
params.put("debug", "XYZ");
AddressInfo addressInfo ;
ApiResponse userAddressBO ;
try {
userAddressBO = serviceCaller.get("users.getAreaByCode", erpGatewayUrl + GETAREABYCODE, params, ApiResponse.class, null).get(500, TimeUnit.MILLISECONDS);
}catch (Exception ex){
LOGGER.warn("in getAreaByCode fail, fourAreaCode {}", fourAreaCode, ex);
throw new ServiceException(ServiceError.ADDRESS_NULL);
}
JSONObject addressData ;
if (userAddressBO == null || (addressData = (JSONObject)userAddressBO.getData()) == null){
LOGGER.warn("in getAreaByCode fail, fourAreaCode {}", fourAreaCode);
throw new ServiceException(ServiceError.ADDRESS_NULL);
}
JSONObject parent = addressData.getJSONObject("parent");
Map<Integer, String> result = new HashMap<>();
return result;
}
private void parseResp(JSONObject jsonObject, Map<Integer, String> result) {
if (null == jsonObject) {
return;
}
result.put(jsonObject.getInteger("id"), jsonObject.getString("caption"));
parseResp(jsonObject.getJSONObject("parent"), result);
}
public Map<Integer, String> selectByParentCode(String parentCode) {
if (areaByErp()) {
... ...