北京经济技术开发区经开区虚拟城市项目-【后端】-服务,Poi,企业,地块等定制接口
13693261870
2023-10-07 a3e257a2868b89ae918dc992214a735dca085fbd
修改根据编号更新接口
已修改3个文件
68 ■■■■■ 文件已修改
src/main/java/com/smartearth/poiexcel/config/InitConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/service/DkService.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.properties 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/config/InitConfig.java
@@ -40,7 +40,7 @@
        try {
            log.info("***************** 系统启动完毕 *****************" + "\n");
            test();
            //test();
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
src/main/java/com/smartearth/poiexcel/service/DkService.java
@@ -1,9 +1,13 @@
package com.smartearth.poiexcel.service;
import com.alibaba.fastjson.JSONObject;
import com.smartearth.poiexcel.entity.DkEntity;
import com.smartearth.poiexcel.utils.RestHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
 * 地块服务类
@@ -13,14 +17,56 @@
@Service
@SuppressWarnings("ALL")
public class DkService {
    @Value("${dk.host}")
    String host;
    private final static Log log = LogFactory.getLog(DkService.class);
    private final static String GET_INFO_URL = "%s/poisearch/guihuacon/getInfo?ydbm=%s";
    private final static String GET_ENT_BASE_INFO = "%s/yqfwg/api/project/getEntBaseInfoForOtherSysListPage?ctoken=%s&showCount=%d&currentPage=%d";
    /**
     * 根据编号更新
     */
    public boolean updateByBh(DkEntity dk) {
        try {
            //
            String url = String.format(GET_INFO_URL, host, dk.getDikuaibianhao());
            RestTemplate rest = RestHelper.getRestTemplate();
            JSONObject obj = rest.getForObject(url, JSONObject.class);
            if (null == obj || !"200".equals(obj.get("code").toString()) || null == obj.getJSONObject("data")) {
                return false;
            }
            JSONObject data = obj.getJSONObject("data");
            JSONObject cr = data.getJSONObject("churangxinxi");
            JSONObject yd = data.getJSONObject("yongdishuju");
            if (null == cr && null == yd) {
                return false;
            }
            if (null != cr) {
                dk.setYdbh(cr.getString("ydbh"));
                dk.setXmmc(cr.getString("xmmc"));
                dk.setYdlx(cr.getString("ydlx"));
                dk.setCyfx(cr.getString("cyfx"));
                dk.setYdmj(getDouble(cr, "ydmj"));
                dk.setXmdz(cr.getString("xmdz"));
                dk.setCrnx(getInteger(cr, "crnx"));
                dk.setCrnf(getInteger(cr, "crnf"));
            }
            if (null != yd) {
                dk.setYdbh(yd.getString("ydbh"));
                dk.setXmmc(yd.getString("xmmc"));
                dk.setYdlx(yd.getString("ydlx"));
                dk.setYdmj(getDouble(yd,"ydmj"));
                dk.setXmdz(yd.getString("xmdz"));
                dk.setRjl(getDouble(yd,"rjl"));
                dk.setYdlxmc(yd.getString("ydlxmc"));
                dk.setCyfx(yd.getString("cyfx"));
                dk.setJzxg(getDouble(yd,"jzxg"));
            }
            return true;
        } catch (Exception ex) {
@@ -29,6 +75,22 @@
        }
    }
    private Integer getInteger(JSONObject obj, String key) {
        try {
            return obj.getInteger(key);
        } catch (Exception ex) {
            return null;
        }
    }
    private Double getDouble(JSONObject obj, String key) {
        try {
            return obj.getDouble(key);
        } catch (Exception ex) {
            return null;
        }
    }
    /**
     * 根据坐标更新
     */
src/main/resources/application.properties
@@ -24,4 +24,4 @@
qylweb.user=shikong001
qylweb.pwd=123!@#qwe
yd.host=http://10.10.4.115:8022/
dk.host=http://10.10.4.115:8022