wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
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
package com.vci.client.uif.actions.client;
 
import java.io.File;
import java.util.Map;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
 
import com.vci.client.utils.ImportDataTool;
import com.vci.mw.ClientContextVariable;
 
/**
 * 导入业务对象
 * @author zhouhui
 *
 */
public class ImportBOAction extends DoseNotSelectDataAction{
    
    /**
     * 按钮参数信息
     */
    private Map<String, String> paramsMap;
    
    @Override
    public String getKey() {
        return IMPORTBO;
    }
 
    @Override
    public boolean doPost() {
        try{
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileChooser.setDialogTitle("选择文件");
            int result = fileChooser.showOpenDialog(ClientContextVariable.getFrame());
            if(result != JFileChooser.APPROVE_OPTION){
                return false;
            }
            File file = fileChooser.getSelectedFile().getAbsoluteFile();
            String fileName = file.getName();
            //获得按钮参数
            paramsMap = getButtonParams();
            String type = paramsMap.get("type");
            Map<String, String> infoMap = ImportDataTool.importBOData(file, fileName, type, 1);
            String errorInfo = infoMap.get(ImportDataTool.ERROR);
            if(errorInfo != null){
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), 
                        errorInfo, errorInfo, JOptionPane.INFORMATION_MESSAGE);
                return false;
            }
            boolean flag = Boolean.valueOf(infoMap.get(ImportDataTool.RESULT));
            if(flag){
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), 
                        "导入数据成功", "导入数据成功", JOptionPane.INFORMATION_MESSAGE);
            }else{
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), 
                        "导入数据失败", "导入数据失败", JOptionPane.INFORMATION_MESSAGE);
            }
            return flag;
        }catch(Throwable e){
            UIFUtils.showErrorMessage(ClientContextVariable.getFrame(),
                    "uifmodel.plm.uif.actions.importBOerror", e);
            return false;
        }
        
    }
}