管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-06-10 dc1ad2b146bd1f66b4f411d02cc920ccc80ec88e
解决矢量数据批量插入过多时报错
已修改5个文件
51 ■■■■■ 文件已修改
data/db_cx.sql 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/all/BaseQueryController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/all/StaticData.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/ctrl/SdkDecryptDataEntity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/UploadService.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_cx.sql
@@ -44,28 +44,13 @@
update lf.sys_layer set serve_type = 'DEM' where type = 2 and serve_type is null and position('terrain/' in url) > 0;
select id, pid, cn_name, en_name, url, serve_type, data_type, elev, pubid, is_project, bak
from lf.sys_layer
where type = 2 and serve_type is not null
order by id;
from lf.sys_layer where type = 2 and serve_type is not null order by id;
-- update lf.sys_publish a set url = replace(url, '192.168.20.205:80', '{host}') where position('192.' in url) > 0; 
select * from bs.s_explorationpoint where createtime < '2023-05-26 10:00:00';
--delete from bs.s_explorationpoint where dirid in ('00','04');
select * from bs.s_surveyworksite where createtime < '2023-05-26 10:00:00';
--delete from bs.s_surveyworksite where createtime < '2023-05-26 10:00:00';
select * from lf.sys_meta where type='cpt';
select * from lf.sys_dict where tab='u_sectionline';
select * from bs.u_sectionline where parentid='5bf5fe98-31a0-4dd9-9fa6-5e6d1570ae00';
select * from lf.sys_attach;
select * from lf.sys_dir where pid=0 order by id;
select * from lf.sys_fme_log where tcdm='u_sectionline' order by id desc;
select * from lf.sys_meta where name='勘探点表.xlsx' and dircode like '0A%';
select * from lf.sys_meta where name='工程地质剖面图控制点.xlsx';
select * from lf.sys_fme_log where parentid= '70ca841d-2103-485b-ab10-278cb9df85bd'
select * from lf.sys_meta where eventid='aa690060-1266-4fd2-bde4-44b9d843948d';
select * from bs.u_sectionline where parentid='aa690060-1266-4fd2-bde4-44b9d843948d';
--http://192.168.20.205:8088/server/dataQuery/selectFiles?tabName=bs.u_sectionline&eventid=f68f5041-329e-407a-b6ef-deacc8d79910
select * from lf.sys_attach where tab='bs.u_sectionline' order by id desc;
src/main/java/com/lf/server/controller/all/BaseQueryController.java
@@ -200,7 +200,7 @@
            if (StringHelper.isEmpty(wkt)) {
                return fail("WKT不能为空", null);
            }
            if (null == limit || limit < 1 || limit > StaticData.ONE_HUNDRED) {
            if (null == limit || limit < 1 || limit > StaticData.I100) {
                limit = 20;
            }
            if (null == buffer || buffer < 0 || buffer > StaticData.ONE_HUNDRED_THOUSAND) {
src/main/java/com/lf/server/entity/all/StaticData.java
@@ -26,11 +26,11 @@
    public final static int SIXTEEN = 16;
    public final static int ONE_HUNDRED = 100;
    public final static int TWO_HUNDRED = 200;
    public final static int ONE_HUNDRED_THOUSAND = 100000;
    public static final double D100 = 100.0;
    public static final double D1024 = 1024.0;
@@ -50,6 +50,8 @@
    public static final int I90_NEG = -90;
    public final static int I100 = 100;
    public static final int I180 = 180;
    public static final int I180_NEG = -180;
src/main/java/com/lf/server/entity/ctrl/SdkDecryptDataEntity.java
@@ -19,7 +19,7 @@
    private static List<Integer> registeredModules = new ArrayList<>();
    static {
        for (int i = 1; i <= StaticData.ONE_HUNDRED; i++) {
        for (int i = 1; i <= StaticData.I100; i++) {
            registeredModules.add(i);
        }
    }
src/main/java/com/lf/server/service/data/UploadService.java
@@ -1,5 +1,6 @@
package com.lf.server.service.data;
import com.google.common.collect.Lists;
import com.lf.server.entity.all.BaseEntity;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.data.*;
@@ -236,7 +237,7 @@
        }
        setCreateInfo(list, mf);
        int rows = basicMapper.insertBatch(list);
        int rows = batchInserts(basicMapper, list);
        if (rows > 0) {
            mf.setEntity(mf.getTab());
            mf.setTab(tabName);
@@ -245,6 +246,25 @@
    }
    /**
     * 批量插入
     */
    private <T>  int batchInserts(BasicMapper basicMapper, List<T> list) {
        int rows = 0;
        int count = (int) Math.ceil(list.size() / StaticData.D100);
        List<List<T>> subLists = Lists.partition(list, count);
        for (List<T> sub : subLists) {
            try {
                rows += basicMapper.insertBatch(sub);
            } catch (Exception ex) {
                log.error(ex);
            }
        }
        return rows;
    }
    /**
     * 设置创建信息
     */
    private <T> void setCreateInfo(List<T> list, MetaFileEntity mf) {