# WipWorkflowQueryServiceImpl.java

    package com.mycim.server.wip.service;

    import com.alipay.sofa.runtime.api.annotation.SofaService;
    import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
    import com.fa.sesa.i18n.I18nUtils;
    import com.fa.sesa.threadlocal.LocalContext;
    import com.mycim.framework.utils.lang.StringUtils;
    import com.mycim.framework.workflow.engine.WorkflowManagerService;
    import com.mycim.server.base.manager.NamedObjectManager;
    import com.mycim.server.wip.manager.WipWorkflowQueryManager;
    import com.mycim.valueobject.ObjectList;
    import com.mycim.workflow.valueobject.Workflow;
    import com.mycim.workflow.valueobject.WorkflowPath;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;

    /**
     * @author shijie.deng
     * @version 6.0.0
     * @date 2019/9/17
     **/
    @Service
    @SofaService(interfaceType = WipWorkflowQueryService.class, bindings = {@SofaServiceBinding(bindingType = "bolt")})
    public class WipWorkflowQueryServiceImpl implements WipWorkflowQueryService {

        @Autowired
        private WipWorkflowQueryManager wipWorkflowQueryManager;

        @Autowired
        private NamedObjectManager namedObjectManager;

        @Autowired
        private WorkflowManagerService workflowManagerService;

        @Override
        public Map getStepsInfoByVersion(long processRrn, int processVer, String stepPath, Map matchingRules) {
            return wipWorkflowQueryManager.getStepsInfoByVersion(processRrn, processVer, stepPath, matchingRules);
        }

        @Override
        public Map getStepsInfo(long processRrn, String stepPath, Map matchingRules) {
            return wipWorkflowQueryManager.getStepsInfo(processRrn, stepPath, matchingRules);
        }

        @Override
        public List<Map> qryWflCombo(String type, String cascadeSource) {
            List<Map> comboList = new ArrayList<>();
            Map<String, Object> conditionMap = new HashMap<String, Object>();
            if (StringUtils.isNotBlank(cascadeSource)) {
                String[] cascadeConditionArray = cascadeSource.split(";;");
                conditionMap.put("productType", StringUtils
                        .trimToUpperCase(StringUtils.replace(cascadeConditionArray[0], "*", "%").toString()));
                conditionMap.put("productId", StringUtils
                        .trimToUpperCase(StringUtils.replace(cascadeConditionArray[1], "*", "%").toString()));
                conditionMap.put("processId", StringUtils
                        .trimToUpperCase(StringUtils.replace(cascadeConditionArray[2], "*", "%").toString()));
                conditionMap.put("routeId", StringUtils
                        .trimToUpperCase(StringUtils.replace(cascadeConditionArray[3], "*", "%").toString()));
            }
            conditionMap.put("processNamedSpace",
                             namedObjectManager.getNamedSpace(LocalContext.getFacilityRrn(), ObjectList.WFL_KEY));
            if (StringUtils.equalsIgnoreCase("productType", type)) {
                comboList = wipWorkflowQueryManager
                        .getWflInfoForCombo("product_t.object_type", "object_type", conditionMap);
            } else if (StringUtils.equalsIgnoreCase("product", type)) {
                comboList = wipWorkflowQueryManager
                        .getWflInfoForCombo("getinstanceid(pph.product_rrn) as product_id", "product_id", conditionMap);
            } else if (StringUtils.equalsIgnoreCase("process", type)) {
                comboList = wipWorkflowQueryManager.getWflInfoForCombo("wfl_info.process_id", "process_id", conditionMap);
            } else if (StringUtils.equalsIgnoreCase("route", type)) {
                comboList = wipWorkflowQueryManager.getWflInfoForCombo("wfl_info.route_id", "route_id", conditionMap);
            } else if (StringUtils.equalsIgnoreCase("operation", type)) {
                comboList = wipWorkflowQueryManager
                        .getWflInfoForCombo("wfl_info.operation_rrn", "operation_rrn", conditionMap);
            }

            Map<String, Object> defaultSelect = new HashMap<>(2);
            if (StringUtils.equalsIgnoreCase("CN", I18nUtils.getCurrentLanguage().name())) {
                defaultSelect.put("key", "--选择--");
            } else {
                defaultSelect.put("key", "--Choice--");
            }
            defaultSelect.put("value", StringUtils.EMPTY);
            comboList.add(0, defaultSelect);
            return comboList;
        }

        @Override
        public boolean isExistExecutionRrn(long executionRrn) {
            return wipWorkflowQueryManager.isExistExecutionRrn(executionRrn);
        }

        @Override
        public List getNextMultiStepInfoByDao(long executionRrn, int n) {
            return wipWorkflowQueryManager.getNextMultiStepInfoByDao(executionRrn, n);
        }

        @Override
        public String reconstructRouteMap(String returnProcessStepVersion, Map processStep) {
            return wipWorkflowQueryManager.reconstructRouteMap(returnProcessStepVersion, processStep);
        }

        @Override
        public long getOperationByExec(long executionRrn) {
            return wipWorkflowQueryManager.getOperationByExec(executionRrn);
        }

        @Override
        public String[] parseWflStepPath(String wflStepPath) {
            return wipWorkflowQueryManager.parseWflStepPath(wflStepPath);
        }

        @Override
        public Workflow getWorkflow(long wflRrn, boolean active, WorkflowPath workflowPath) {
            return workflowManagerService.getWorkflow(wflRrn,active,workflowPath);
        }

        @Override
        public List<String> getMethodIdListByExecutionRrn(long executionRrn) {
            return wipWorkflowQueryManager.getMethodIdListByExecutionRrn(executionRrn);
        }

    }