浏览代码

Merge branch 'master' of http://192.168.1.220:10080/esb/esb

Airhead 8 年之前
父节点
当前提交
63a62592de

+ 2 - 2
esb.iml

@ -96,8 +96,6 @@
    <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.4.0" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.4.0" level="project" />
    <orderEntry type="library" name="Maven: javax.transaction:javax.transaction-api:1.2" level="project" />
    <orderEntry type="library" name="Maven: com.yihu.core:ehr-dbhelper:1.1.9" level="project" />
    <orderEntry type="library" name="Maven: com.yihu.core:html2image:0.9" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-orm:4.3.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-extras:3.0.5" level="project" />
@ -181,6 +179,8 @@
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:1.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.jasypt:jasypt:1.9.0" level="project" />
    <orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.9" level="project" />
    <orderEntry type="library" name="Maven: com.yihu.core:ehr-dbhelper:1.1.9" level="project" />
    <orderEntry type="library" name="Maven: com.yihu.core:html2image:0.9" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.4.1.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.4.1.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.4.1.RELEASE" level="project" />

+ 18 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/BrokerServer.java

@ -14,6 +14,7 @@ import java.util.Date;
public class BrokerServer {
    @Id
    private String id;
    private String tenant;
    private String hostName;
    private String hostAddress;
    private int port;
@ -37,6 +38,14 @@ public class BrokerServer {
        return false;
    }
    public String getTenant() {
        return tenant;
    }
    public void setTenant(String tenant) {
        this.tenant = tenant;
    }
    public String getId() {
        return id;
    }
@ -119,6 +128,15 @@ public class BrokerServer {
        String routeCode;
        String type;
        Date updated;
        String tenant;
        public String getTenant() {
            return tenant;
        }
        public void setTenant(String tenant) {
            this.tenant = tenant;
        }
        public String getRouteCode() {
            return routeCode;

+ 1 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/BrokerServerService.java

@ -50,6 +50,7 @@ public class BrokerServerService {
        query.addCriteria(Criteria.where("port").is(brokerServer.getPort()));
        Update update = new Update();
        update.set("tenant", brokerServer.getTenant());
        update.set("hostName", brokerServer.getHostName());
        update.set("hostAddress", brokerServer.getHostAddress());
        update.set("port", brokerServer.getPort());

+ 5 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/BrokerServerService.java

@ -15,6 +15,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.IOException;
@ -33,6 +34,9 @@ public class BrokerServerService implements DisposableBean {
    private ApplicationConfiguration applicationConfiguration;
    @Autowired
    private ArbiterConfiguration arbiterConfiguration;
    @Value("${hos.tenant.name}")
    private String tenant;
    private String hostName;
    private String hostAddress;
    private int port;
@ -44,6 +48,7 @@ public class BrokerServerService implements DisposableBean {
            port = applicationConfiguration.getPort();
            ObjectMapper objectMapper = new ObjectMapper();
            ObjectNode objectNode = objectMapper.createObjectNode();
            objectNode.put("tenant", tenant);
            objectNode.put("hostName", hostName);
            objectNode.put("hostAddress", hostAddress);
            objectNode.put("port", port);

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

@ -15,8 +15,10 @@ 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 org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.PostConstruct;
import java.io.*;
import java.sql.Blob;
import java.util.*;
@ -28,13 +30,22 @@ import java.util.*;
 * @vsrsion 1.0
 * Created at 2016/7/21.
 */
@Component
public class GridFSUtil {
    public static final int defaultChunkSize = 1024 * 1024 * 4;
    @Autowired
    private  GridFsOperations operations;
    private static GridFsOperations gridFsOperations;
    @PostConstruct
    public void init() {
        gridFsOperations = this.operations;
    }
    public static ObjectId uploadFile(String dbName, Blob blob, String fileType, Map<String, Object> params) {
//        String fileName = UUID.randomUUID().toString() + "." + fileType;
        //自定义字段
@ -348,6 +359,25 @@ public class GridFSUtil {
        GridFSUploadOptions gridFSUploadOptions = new GridFSUploadOptions()
                .chunkSizeBytes(defaultChunkSize).metadata(metaDocument);
        FileInputStream fileInputStream = null;
        // Create some custom options
//        GridFSUploadOptions gridFSUploadOptions = new GridFSUploadOptions()
//                .chunkSizeBytes(defaultChunkSize).metadata(metaDocument);
//        String fileName = UUID.randomUUID() + file.getFileItem().getName();
//        GridFSUploadStream uploadStream = gridFS.openUploadStream(fileName, gridFSUploadOptions);
//        try {
//            byte[] data = FileUtil.toByteArray(filePath);
//            uploadStream.write(data);
//            ObjectId id = uploadStream.getFileId();
//            if (id != null) {
//                return fileName;
//            }
//        } finally {
//            if (uploadStream != null) {
//                uploadStream.close();
//            }
//        }
        try {
            fileInputStream = new FileInputStream(filePath);
            com.mongodb.gridfs.GridFSFile gridFSFile = gridFsOperations.store(fileInputStream, gridFSUploadOptions);
@ -397,7 +427,7 @@ public class GridFSUtil {
    public static String readFile(String dbName, String fileName) {
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            GridFSDBFile gridFSDBFile = gridFsOperations.findOne(Query.query(GridFsCriteria.where("").is(fileName)));
            GridFSDBFile gridFSDBFile = gridFsOperations.findOne(Query.query(GridFsCriteria.where("filename").is(fileName)));
            gridFSDBFile.writeTo(byteArrayOutputStream);
            return byteArrayOutputStream.toString();
        } catch (Exception e) {

+ 20 - 0
src/main/java/com/yihu/hos/monitor/controller/ServiceMonitorController.java

@ -70,6 +70,26 @@ public class ServiceMonitorController {
    }
    @RequestMapping(value = "/serviceStatus", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "服务状态", produces = "application/json", notes = "服务状态获取")
    public Result serviceStatus(
            HttpServletRequest request,
            @ApiParam(name = "routeCode", value = "流程Code", required = true)
            @RequestParam(value = "routeCode") Integer routeCode ) {
        try {
            boolean succ = flowManager.serviceOpenOrPause(routeCode,0);
            if (succ){
                return Result.success("获取服务状态成功");
            }else {
                return Result.error("获取服务状态失败");
            }
        } catch (Exception e) {
            return Result.error("获取服务状态异常");
        }
    }
    @RequestMapping(value = "/startService", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "开启服务", produces = "application/json", notes = "开启服务")

+ 11 - 0
src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java

@ -34,6 +34,8 @@ public class ServiceMonitorService {
    public static final String BEAN_ID = "ServiceMonitorService";
    public static final String dbName = "log";
    public static final String tableName = "serviceMetrics";
    public static final String serviceFlow = "serviceFlow";
    public static final String configuration = "configuration";
    @Autowired
    private MongoOperations mongoOperations;
@ -154,4 +156,13 @@ public class ServiceMonitorService {
        return Result.success(jsonArray.toString());
    }
    public boolean serviceStatus(String routeCode){
        boolean succ = false;
//        MongoDatabase db = mongoConfig.mongoClient().getDatabase(configuration);
//        MongoCollection<Document> collection = db.getCollection(serviceFlow);
        return succ;
    }
}

+ 20 - 0
src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManageJs.jsp

@ -128,6 +128,7 @@
                    service.qps(message.qps);
                    service.delay(message.delay);
                    service.usage(message.usage);
                    service.setJobStatus();
                } else {
                    $.ligerDialog.error(re.message);
                }
@ -395,6 +396,25 @@
            else{
                myChart.clear();
            }
        },
        //任务状态
        setJobStatus:function(status)
        {
            var me = this;
            if(status=="1")
            {
                $('#jobStatusSwitch').attr("checked",true);
                me.switchery.element.checked=true;
                me.switchery.setPosition();
                $("#jobStatus").html('<span class="green job_run">正在运行中...</span>');
            }
            else{
                $('#jobStatusSwitch').removeAttr("checked");
                me.switchery.element.checked=false;
                me.switchery.setPosition();
                $("#jobStatus").html('<span class="red job_stop">运行暂停</span>');
            }
        }
    };