北京经济技术开发区经开区虚拟城市项目-【后端】-服务,Poi,企业,地块等定制接口
13693261870
2023-10-05 19a45e1c33a0925bc8237bd79d74902d20a1e16e
src/main/java/com/smartearth/poiexcel/service/EntService.java
@@ -1,7 +1,9 @@
package com.smartearth.poiexcel.service;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.smartearth.poiexcel.entity.*;
import com.smartearth.poiexcel.mapper.BasicMapper;
import com.smartearth.poiexcel.mapper.EntMapper;
import com.smartearth.poiexcel.utils.RestHelper;
import org.apache.commons.logging.Log;
@@ -53,12 +55,14 @@
            map.put("userName", user);
            map.put("passWord", pwd);
            // String str = RestHelper.postForRest(url, map)
            Result rs = postForRest(url, map, Result.class);
            if (null == rs || StaticData.I200 != rs.getCode()) {
                return null;
            }
            TokenResult tr = JSONObject.parseObject(rs.getData(), TokenResult.class);
            // TokenResult tr = JSONObject.parseObject(rs.getData().toJSONString(), TokenResult.class)
            TokenResult tr = rs.getData().toJavaObject(TokenResult.class);
            return tr.getCtoken();
        } catch (Exception ex) {
@@ -88,7 +92,7 @@
                return null;
            }
            EntResult er = JSONObject.parseObject(rs.getData(), EntResult.class);
            EntResult er = JSONObject.parseObject(rs.getData().toJSONString(), EntResult.class);
            return er.getPd().getList();
        } catch (Exception ex) {
@@ -98,6 +102,28 @@
    }
    /**
     * 插入企业
     */
    public Integer insertEnts(List<EntEntity> list) {
        try {
            int rows = 0;
            List<List<EntEntity>> subLists = Lists.partition(list, StaticData.I200);
            for (List<EntEntity> sub : subLists) {
                try {
                    rows += entMapper.insertBatch(sub);
                } catch (Exception ex) {
                    log.error(ex);
                }
            }
            return rows;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return 0;
        }
    }
    /**
     * get请求(Rest)
     */
    public <T> T getForRest(String url, Class<T> clazz) {