| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * @param hk |
| | | */ |
| | | public String regionNodesByParams(HkVO hk) { |
| | | // 先按地市查询对应的区域code |
| | | String parentIndexCode = getIndexCodeByRegionName(hk,hk.getCityName(),null); |
| | | if (!Strings.isBlank(parentIndexCode)) { |
| | | return getIndexCodeByRegionName(hk,hk.getRegionName(),parentIndexCode); |
| | | } |
| | | // 返回 |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 按区域名称查询对应的区域code |
| | | * @param hk |
| | | * @param regionName |
| | | * @param parentIndexCode |
| | | * @return |
| | | */ |
| | | private String getIndexCodeByRegionName(HkVO hk,String regionName,String parentIndexCode) { |
| | | String indexCode = ""; |
| | | // 组装请求参数 |
| | | JSONObject jsonBody = new JSONObject(); |
| | | jsonBody.put("resourceType", "region"); |
| | | jsonBody.put("regionName", hk.getRegionName()); |
| | | jsonBody.put("regionName", regionName); |
| | | if (!Strings.isBlank(parentIndexCode)){ |
| | | jsonBody.put("parentIndexCodes", new ArrayList<>(){{ |
| | | add(parentIndexCode); |
| | | }}); |
| | | } |
| | | jsonBody.put("pageNo", 1); |
| | | jsonBody.put("pageSize", 10); |
| | | String body = jsonBody.toJSONString(); |