1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.vci.server.workflow.server.event;
 
import java.util.ArrayList;
import java.util.List;
 
import org.jbpm.api.listener.EventListenerExecution;
 
import com.vci.common.objects.UserEntity;
import com.vci.corba.common.VCIError;
import com.vci.server.workflow.dao.FlowInstanceDaoImpl;
import com.vci.server.workflow.objects.FlowInstance;
import com.vci.server.workflow.objects.PLFlowObject;
import com.vci.server.workflow.server.template.ProcessTemplateService;
 
public class BaseRmStatusListener {
 
    String codeName = "";
    public void doAction(EventListenerExecution eventListenerExecution, String fields, String values,String operType) throws Exception {
 
        String outcome = (String) eventListenerExecution.getProcessInstance().getVariable("OUTCOME");
        String userName = (String) eventListenerExecution.getProcessInstance().getVariable("userName");
        String userIP = (String) eventListenerExecution.getProcessInstance().getVariable("userIP");
        String userModule = (String) eventListenerExecution.getProcessInstance().getVariable("userModule");
        
        UserEntity user = new UserEntity();
        user.setIp(userIP);
        user.setModule(userModule);
        user.setUserName(userName);
        
        if ("不同意".equals(outcome)) {
            return;
        }
 
        String id = eventListenerExecution.getId();
//        String id = eventListenerExecution.getProcessInstance().getId();
 
        FlowInstanceDaoImpl impl = new FlowInstanceDaoImpl();
        String hql = "from FlowInstance t where t.executionid = ?";
        FlowInstance flowInstance = impl.findEntity(hql, new Object[]{id});
        String tableName = flowInstance.getTableName();
 
        List<String> list = new ArrayList<String>();
        List<PLFlowObject> flowObjects = new ProcessTemplateService().getFlowObjectByExecutionId(id);
        for (PLFlowObject flowObject : flowObjects) {
            list.add(flowObject.getPlobjectid());
        }
        
        
//        TemplateService service = new TemplateService(user);
//        for (String ploid : list) {
//            try{
//                service.updateDynamicTable(ploid, tableName, new String[] { fields }, new String[] { values }, "", 0, 0, "",operType,"工作流");
//            }catch(VCIError e) {
//                throw new VCIError(320215, new String[] { e.getCause().getMessage() });
//            }
//        }
//        if(false){
//            new TemplateClientDelegate().deleteResourceCopy(id, "normal");
//        }
    }
    
    
    //恢复资源到发起流程之前的状态, 删除,启用,停用流程需要调用该方法
    protected void restoreStatus(EventListenerExecution eventListenerExecution) throws Exception {
        String outcome = (String) eventListenerExecution.getProcessInstance().getVariable("OUTCOME");
        if ("不同意".equals(outcome)) {
            return;
        }
 
        String id = eventListenerExecution.getProcessInstance().getId();
//        new ProcessTemplateService().restoreStatus(id);
    }
}