管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-05 8b98fa02322caea99476dc90808f353f7ea6c412
1
已修改3个文件
100 ■■■■ 文件已修改
src/main/java/com/lf/server/controller/show/DataLibController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/UploadAttachService.java 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/data/MetaMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/show/DataLibController.java
@@ -146,11 +146,7 @@
            }
            QueryWrapper wrapper = new QueryWrapper();
            //wrapper.eq("dirid", meta.getDirid());
            //wrapper.eq("depid", meta.getDepid());
            //wrapper.eq("verid", meta.getVerid());
            wrapper.eq("createuser", meta.getCreateUser());
            wrapper.eq("createtime", meta.getCreateTime());
            wrapper.eq("parentid", meta.getEventid());
            Page<Object> page = new Page<>(pageIndex, pageSize);
            page.addOrder(OrderItem.asc("gid"));
src/main/java/com/lf/server/service/all/UploadAttachService.java
@@ -1,17 +1,16 @@
package com.lf.server.service.all;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.HttpStatus;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.all.SettingData;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.all.*;
import com.lf.server.entity.ctrl.KeyValueEntity;
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.sys.AttachEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.*;
import com.lf.server.mapper.all.BasicMapper;
import com.lf.server.service.sys.AttachService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -21,6 +20,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +40,7 @@
    private static String tabs = "''";
    private static Map<String, String> attachTabs = new HashMap<>();
    private final static Map<String, String> ATTACH_TABS = new HashMap<>();
    private final static Log log = LogFactory.getLog(UploadAttachService.class);
@@ -68,11 +68,11 @@
        List<String> keys = new ArrayList<>();
        for (String str : strs) {
            if (attachTabs.containsKey(str)) {
            if (ATTACH_TABS.containsKey(str)) {
                continue;
            }
            attachTabs.put(str, str.contains("bd.") ? "materiname" : "photono");
            ATTACH_TABS.put(str, str.contains("bd.") ? "materiname" : "photono");
            keys.add("'" + str + "'");
        }
        tabs = StringHelper.join(keys, ",");
@@ -174,9 +174,9 @@
        }
        List<KeyValueEntity> rs = new ArrayList<>();
        for (MetaEntity me : ms) {
            int rows = uploadXlsAnnex(me, files);
            rs.add(new KeyValueEntity(me.getName(), String.valueOf(rows)));
        for (MetaEntity meta : ms) {
            int rows = uploadXlsAnnex(meta, files);
            rs.add(new KeyValueEntity(meta.getName(), String.valueOf(rows)));
        }
        return rs;
@@ -253,9 +253,77 @@
    /**
     * 上传Excel附件
     */
    private int uploadXlsAnnex(MetaEntity me, List<String> files) {
    private int uploadXlsAnnex(MetaEntity meta, List<String> files) {
        List<?> list = queryXlsData(meta);
        if (null == list || list.size() == 0) {
            return 0;
        }
        Field field = getAnnexField(list.get(0), meta);
        return 0;
        int rows = 0;
        for (Object obj : list) {
            BaseEntity be = (BaseEntity) obj;
            rows += insertXlsAnnex(be, files);
        }
        return rows;
    }
    /**
     * 查询Excel数据
     */
    private List<?> queryXlsData(MetaEntity meta) {
        String entity = meta.getTab().substring(meta.getTab().indexOf(".") + 1).replace("_", "").toLowerCase();
        BasicMapper basicMapper = ClassHelper.getBasicMapper(entity);
        if (null == basicMapper) {
            return null;
        }
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("parentid", meta.getEventid());
        List<?> list = basicMapper.selectList(wrapper);
        if (null == list || list.size() == 0) {
            return null;
        }
        if (!(list.get(0) instanceof BaseEntity)) {
            return null;
        }
        return list;
    }
    /**
     * 获取附件字段
     */
    private Field getAnnexField(Object obj, MetaEntity meta) {
        try {
            String str = ATTACH_TABS.get(meta.getTab());
            Field field = obj.getClass().getDeclaredField(str);
            field.setAccessible(true);
            return field;
        } catch (Exception ex) {
            return null;
        }
    }
    /**
     * 查找Excel附件
     */
    private String findXlsAnnex(Object obj) {
        return null;
    }
    /**
     * 插入Excel附件
     */
    private int insertXlsAnnex(BaseEntity be, List<String> files) {
        return 1;
    }
}
src/main/resources/mapper/data/MetaMapper.xml
@@ -133,7 +133,7 @@
    <select id="selectXlsAnnex" resultType="com.lf.server.entity.data.MetaEntity">
        select * from lf.sys_meta
        where type in ('xls', 'xlsx') and tab is not null and rows > 0 and id in
        where type in ('xls', 'xlsx') and eventid is not null and tab is not null and rows > 0 and id in
        <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
            #{id}
        </foreach>