如何在hybris中使用groovy修复业务流程?

7rfyedvj  于 2022-11-01  发布在  其他
关注(0)|答案(2)|浏览(184)

我需要修复一个业务流程,所以我有OrderProcess,但我不知道如何使用groovy修复它。有什么想法吗?

import de.hybris.platform.core.model.order.OrderModel
import de.hybris.platform.orderprocessing.model.OrderProcessModel

OrderModel orderModel = flexibleSearchService.search(String.format("SELECT {PK} FROM {AbstractOrder} WHERE {code} = '%s'", "P000015003")).result.get(0)

OrderProcessModel orderProcess = new OrderProcessModel();
orderModel.getOrderProcess().forEach {process ->
    if(process.getProcessDefinitionName().contains("global-order-process")){
        orderProcess = process
    }
}
vom3gejh

vom3gejh1#

这可能很有用从“cancelOrderAction”节点修复订单流程

orders.each {o ->
    def proc = o.orderProcess
    try{
        println o.code + "  --> "  + proc.processState
        def contextParameters = proc.contextParameters;
        if(contextParameters!=null){
            contextParameters
        }
        if (proc.processState != null && proc.processState.contains(ProcessState.ERROR)){

            def log = proc.taskLogs.last().last();
            String lastStep = log.actionId;
            if ((lastStep == "cancelOrderAction")) {
                defaultBusinessProcessService.restartProcess(o.orderProcess[0], lastStep);
                println o.code + "  --> "  + proc.processState + " --> " + lastStep + " --> " + o.creationtime
            }
        }
    }
    catch(Exception e){
        println ("Exception occured for process"+ e);
    }}
hgncfbus

hgncfbus2#

import de.hybris.platform.core.model.order.OrderModel
import de.hybris.platform.orderprocessing.model.OrderProcessModel

OrderModel orderModel = flexibleSearchService.search(String.format("SELECT {PK} FROM {AbstractOrder} WHERE {code} = '%s'", "P000015003")).result.get(0)

OrderProcessModel orderProcess = new OrderProcessModel();
orderModel.getOrderProcess().forEach {process ->
    if(process.getProcessDefinitionName().contains("global-order-process")){
        businessProcessService.restartProcess(process, "takePaymentAction");   // you can give the node from which you want to start the process
    }
}

相关问题