田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package com.vci.client.workflow.task;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Locale;
 
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import com.vci.client.LogonApplication;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
import com.vci.corba.common.VCIError;
import com.vci.corba.workflow.data.FlowTaskInfo;
import com.vci.corba.workflow.data.ProcessTaskInfo;
 
import javax.swing.JComboBox;
 
public class TodoCheckPanel extends JPanel implements IFlowTaskTpyeEvent {
    
    ProcessTaskInfo frocessTaskInfo;
    FlowUserDialog flowUserDialog ;
    public TodoCheckPanel() {
        setLayout(new BorderLayout(0, 0));
 
        panel = new JPanel();
        add(panel, BorderLayout.NORTH);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0};
        panel.setLayout(gbl_panel);
 
        JLabel label = new JLabel("审批:");
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.insets = new Insets(10, 10, 5, 5);
        gbc_label.gridx = 0;
        gbc_label.gridy = 1;
        panel.add(label, gbc_label);
 
        
        outComeComb = new JComboBox();
        GridBagConstraints gbc_outComeComb = new GridBagConstraints();
        gbc_outComeComb.insets = new Insets(0, 0, 5, 5);
        gbc_outComeComb.fill = GridBagConstraints.HORIZONTAL;
        gbc_outComeComb.gridx = 1;
        gbc_outComeComb.gridy = 1;
        panel.add(outComeComb, gbc_outComeComb);
 
        JLabel lblNewLabel = new JLabel("审批意见:");
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.insets = new Insets(0, 10, 0, 5);
        gbc_lblNewLabel.gridx = 0;
        gbc_lblNewLabel.gridy = 2;
        panel.add(lblNewLabel, gbc_lblNewLabel);
 
        JScrollPane scrollPane = new JScrollPane();
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.gridwidth = 2;
        gbc_scrollPane.weightx = 1.0;
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 1;
        gbc_scrollPane.gridy = 2;
        panel.add(scrollPane, gbc_scrollPane);
 
        textArea = new JTextArea();
        textArea.setLineWrap(true);
        textArea.setRows(6);
        textArea.setBackground(Color.WHITE);
        scrollPane.setViewportView(textArea);
        
    }
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JPanel panel;
    private FlowTaskInfo flowTask;
    private ButtonGroup bg;
    private JTextArea textArea;
 
    private String out = "";
    private boolean flag = true;
    
    private String[] userNames = {};
    private boolean complateTaskFlag = false;
    String backTaskName = "";
    private JComboBox outComeComb;
    public boolean completeTask() {
        String outcome = "";
        outcome = (String) outComeComb.getSelectedItem();
 
        if ("".equals(textArea.getText().trim().length() >= 255)) {
            JOptionPane.showMessageDialog(LogonApplication.frame, "审批意见不能超过255个汉字!", "提示信息", JOptionPane.INFORMATION_MESSAGE);
            return false;
        }
        out = outcome;
        String taskId = flowTask.id;
        String taskName = flowTask.name;
        try {
            String jbpmDeploymentId = new ProcessCustomClientDelegate().getDeploymentIdByExecutionId(flowTask.executionId);
                if("同意".equals(outcome)){
                    // 检查下一个任务是否是结束,如果不是结果,则需要弹出选择处理人的窗口,
                    boolean processTaskByTaskName = new ProcessCustomClientDelegate(
                            LogonApplication.getUserEntityObject())
                    .getProcessTaskByTaskName(taskId, taskName, outcome);
                    if (!processTaskByTaskName) {
                        
                        String[] userNames; 
                        if(chooseFlowUser(jbpmDeploymentId, taskName, outcome)) {
                            return false;
                        }else {
                            userNames = flowUserDialog.userName;
                        }
                        this.userNames = userNames;
                        if (userNames.length == 0) {
                            return false;
                        }
                        complateTaskFlag = false;
                    }else{
                        complateTaskFlag = true;
                    }
                }
        } catch (VCIException e1) {
            e1.printStackTrace();
        } catch (VCIError e) {
            e.printStackTrace();
        }
        
            Thread t = new Thread(){
                public void run() {
                    ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
                    try {
                        if(userNames!=null&&userNames.length!=0) {
                            
                             processCustomClientDelegate.completeTask(flowTask.id, out,backTaskName, textArea.getText(),userNames);
                        }else {
                             processCustomClientDelegate.completeTask(flowTask.id, out,backTaskName, textArea.getText(),new String[]{});
                        }
                    } catch (VCIError e) {
                        VCIOptionPane.showError(LogonApplication.frame, LocaleDisplay.getI18nString(new VCIException(String.valueOf(e.code),e.messages), "RMIPBom", Locale.getDefault()));
                        flag = false;
                    }
                }
            };
            ProgressSample r = new ProgressSample(t);
            r.setVisible(true);
        return flag;
    }
    private boolean chooseFlowUser(String jbpmDeploymentId, String taskName, String outcome){
           flowUserDialog = new FlowUserDialog(LogonApplication.frame , jbpmDeploymentId, taskName, outcome);
           if(!flowUserDialog.isSelectFlag()){
               flowUserDialog.setVisible (true);
           }
            boolean flag = flowUserDialog.flag;
            return flag;
        }
    public Component getComponent() {
        return this;
    }
 
    public void init(FlowTaskInfo flowTask, ProcessTaskInfo frocessTaskInfo) {
        this.flowTask = flowTask;
        this.frocessTaskInfo = frocessTaskInfo;
//        RmDataPanel rmDataPanel = new RmDataPanel();
//        rmDataPanel.init(flowTask);
//        rmDataPanel.setPreferredSize(new Dimension(700,90));
        
        GridBagConstraints gbc_rmDataPanel = new GridBagConstraints();
//        gbc_rmDataPanel.anchor = GridBagConstraints.EAST;
        gbc_rmDataPanel.gridwidth = 3;
        gbc_rmDataPanel.weightx = 1.0;
        gbc_rmDataPanel.fill = GridBagConstraints.BOTH;
        gbc_rmDataPanel.insets = new Insets(10, 10, 5, 5);
        gbc_rmDataPanel.gridx = 0;
        gbc_rmDataPanel.gridy = 0;
//        panel.add(rmDataPanel, gbc_rmDataPanel);
        
//        add(rmDataPanel, BorderLayout.NORTH);
        initOutComeComb();
    }
 
    public String save() {
        return "";
    }
 
    public boolean isShowSaveButton() {
        return false;
    }
 
    private void initOutComeComb(){
        ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate();
        try {
            String[] allOutComes = processCustomClientDelegate .getAllOutComes(flowTask.id);
            for(String outCome : allOutComes){
                outComeComb.addItem(outCome);
            }
        } catch (VCIException e) {
            e.printStackTrace();
        }
    }
}