浏览代码

GridFsUtil 问题

demon 8 年之前
父节点
当前提交
9884f26a7c

+ 4 - 1
hos-broker/src/main/java/com/yihu/hos/broker/HosBrokerApplication.java

@ -8,14 +8,16 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.data.mongodb.gridfs.GridFsOperations;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class HosBrokerApplication extends SpringBootServletInitializer implements CommandLineRunner {
    @Autowired
    private GridFSUtil gridFSUtil;
    private GridFsOperations operations;
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(HosBrokerApplication.class);
@ -24,6 +26,7 @@ public class HosBrokerApplication extends SpringBootServletInitializer implement
    @Override
    public void run(String... strings) throws Exception {
        GridFSUtil.gridFsOperations = operations;
        new CamelStartBoot().start();
    }

+ 1 - 10
hos-web-framework/src/main/java/com/yihu/hos/web/framework/util/GridFSUtil.java

@ -9,13 +9,11 @@ import com.yihu.hos.core.file.FileUtil;
import eu.medsea.mimeutil.MimeUtil;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.gridfs.GridFsCriteria;
import org.springframework.data.mongodb.gridfs.GridFsOperations;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.*;
import java.sql.Blob;
import java.util.*;
@ -32,16 +30,10 @@ public class GridFSUtil {
    public static final int defaultChunkSize = 1024 * 1024 * 4;
    @Autowired
    private  GridFsOperations operations;
    private static GridFsOperations gridFsOperations;
    public static GridFsOperations gridFsOperations;
    @PostConstruct
    public void init() {
        gridFsOperations = this.operations;
    }
    public static ObjectId uploadFile( Blob blob, String fileType, Map<String, Object> params) {
//        String fileName = UUID.randomUUID().toString() + "." + fileType;
@ -348,7 +340,6 @@ public class GridFSUtil {
    /**
     * 从 mongodb GridFS 下载文件
     *
     * @param dbName   数据库名
     * @param savePath 文件保存路径
     * @param fileName GridFS文件名
     * @return

+ 1 - 1
src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java

@ -25,7 +25,7 @@ import java.util.Map;
@Service("ServerMonitorService")
public class ServerMonitorService {
    public static final String BEAN_ID = "ServerMonitorService";
    public static final String MONITOR = "monitor";
    public static final String MONITOR = "log";
    public static final String SERVER = "server";
    public static final String HOST = "host";

+ 2 - 1
src/main/java/com/yihu/hos/services/ServiceFlowEventService.java

@ -76,9 +76,10 @@ public class ServiceFlowEventService {
            String msg = objectMapper.writeValueAsString(serviceFlow);
            Map<String, Object> header = new HashMap<>();
            String attachment = LocalContext.getContext().getAttachment(ContextAttributes.TENANT_NAME);
            serviceFlow.setTenant(attachment);
            header.put("tenant", attachment);
            header.put("event", event);
            this.jmsMessagingTemplate.convertAndSend(this.queue, msg, header);
                    this.jmsMessagingTemplate.convertAndSend(this.queue, msg, header);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            logger.error(e.getMessage());

+ 4 - 1
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -1,9 +1,11 @@
package com.yihu.hos.system.service;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.config.MongoConfig;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.encrypt.DES;
import com.yihu.hos.core.file.FileUtil;
import com.yihu.hos.interceptor.LocalContext;
import com.yihu.hos.services.ServiceFlowEventService;
import com.yihu.hos.system.dao.FlowClassDao;
import com.yihu.hos.system.dao.FlowDao;
@ -160,10 +162,11 @@ public class FlowManager {
        List<ServiceFlow> serviceFlowList = new ArrayList<>();
        List<SystemServiceFlow> classFlowList = flowDao.getFlowList(ServiceFlowConstant.CLASS);
        for (SystemServiceFlow systemServiceFlow : classFlowList) {
            String tenant = LocalContext.getContext().getAttachment(ContextAttributes.TENANT_NAME);
            ServiceFlow serviceFlow = new ServiceFlow();
            serviceFlow.setRouteCode(systemServiceFlow.getCode());
            serviceFlow.setFlowType(systemServiceFlow.getFileType());
            serviceFlow.setTenant(tenant);
            List<SystemServiceFlowClass> classList = flowClassDao.getFlowClassByFlowId(systemServiceFlow.getId());
            ArrayList<ServiceFlow.HandleFile> handleFileList = new ArrayList<>();
            for (SystemServiceFlowClass flowClass : classList) {