Browse Source

获取流程状态

huangzhiyong 8 years ago
parent
commit
1ab13c4633

+ 9 - 4
hos-broker/src/main/java/com/yihu/hos/broker/controllers/ESBCamelController.java

@ -5,10 +5,7 @@ import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
 * Created by lingfeng on 2016/8/4.
@ -73,4 +70,12 @@ public class ESBCamelController {
            @RequestBody() String msg) {
        return esbCamelService.onServiceFlowStop(msg);
    }
    @RequestMapping(value = "/serviceFlow/status", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation(value = "服务流程运行状态", produces = "application/json", notes = "查看服务流程的运行状态,运行中/停止")
    public String serviceFlowStatus(
            @ApiParam(name = "routeId", value = "routeId", required = true)
            @RequestParam String routeId) {
        return esbCamelService.getRouteStatus(routeId);
    }
}

+ 10 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/ESBCamelService.java

@ -12,6 +12,7 @@ import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.model.bo.ServiceFlow;
import org.apache.camel.Route;
import org.apache.camel.ServiceStatus;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.bson.Document;
@ -426,6 +427,15 @@ public class ESBCamelService {
    }
    public String getRouteStatus(String routeId){
        ServiceStatus routeStatus = SystemCamelContext.getContext().getRouteStatus(routeId);
        if (routeStatus!=null){
            return routeStatus.name();
        }else {
            return null;
        }
    }
    private class ServiceFlowValid {
        private boolean myResult;
        private String msg;

+ 3 - 1
src/main/java/com/yihu/hos/system/controller/FlowController.java

@ -9,6 +9,7 @@ import com.yihu.hos.system.model.SystemServiceFlowTemp;
import com.yihu.hos.system.service.FlowManager;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import com.yihu.hos.web.framework.model.ActionResult;
import com.yihu.hos.web.framework.model.DataGridResult;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
@ -72,7 +73,8 @@ public class FlowController extends BaseController {
            params.put("page", page);
            params.put("rows", rows);
            Result result = flowManage.getFlowList(params);
            DataGridResult result = (DataGridResult) flowManage.getFlowList(params);
            List<SystemServiceFlow> detailModelList = result.getDetailModelList();
            return result;
        } catch (Exception ex) {
            ex.printStackTrace();

+ 14 - 2
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -27,6 +27,7 @@ import javax.annotation.Resource;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 系统流程管理业务类
@ -327,10 +328,21 @@ public class FlowManager {
    }
    public Result getFlowClassList(Map<String, Object> params) throws Exception {
        return null;
    public List<String> getFlowIdList(List<SystemServiceFlow> routeLis) throws Exception {
        List<String> routeCodes = new ArrayList<>();
        if (routeLis!=null && !routeLis.isEmpty()){
            routeCodes = routeLis.stream().filter(route -> ServiceFlowConstant.CLASS.equals(route.getFileType())).map(SystemServiceFlow::getCode).collect(Collectors.toList());
        }
        return routeCodes;
    }
    public Map<String,String> getFlowStausList(List<String> routeCodeLis) throws Exception {
        Map<String,String>  routeCodesStaus = new HashMap<>();
        if (routeCodeLis!=null && !routeCodeLis.isEmpty()){
        }
        return routeCodesStaus;
    }
    public List<SystemServiceFlowClass> getFlowClassByFlowId(Integer flowId) throws Exception {
        return flowClassDao.getFlowClassByFlowId(flowId);