david-PC\david
2018-06-12 f240ac3ccd37c541cab2c21cfc433d3510999a3c
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
package frame.persist;
 
import frame.util.Util;
 
 
 
public class DataCenter {
 
    public static int Count_BatchLoad = 10000;
    public static int Count_BatchSave = 10000;
    
    public static String SQL_Name_GetDataFilter = "getDataFilter";
    public static String SQL_Name_UploadData = "uploadData";
    public static String SQL_Name_WriteUploadRecord = "writeUploadRecord";
    public static String SQL_Name_WriteUploadSuccess = "writeUploadSuccess";
    public static String SQL_Name_ChangePassword = "changePassword";
    public static String SQL_Name_EmptyTable = "emptyTable";
    public static String SQL_Name_LoadOrgCode = "loadOrgCode";
    public static String SQL_Name_LoadQRCode = "loadQRCode";
    public static String SQL_Name_LoadUPNCode = "loadUPNCode";
    public static String SQL_Name_LoadDocNo = "loadDocNo";
    
    public static String Param_Name_TableNameField = "table_name";
    public static String Param_Name_DataLogTable = "data_log";
    public static String Param_Name_LocalStamp = "localStamp";
    public static String Param_Name_MaxStamp = "maxStamp";
    public static String Param_Name_Schema = "schema";
    public static String Param_Name_TableListId = "tableListId";
    public static String Param_Name_CollectorId = "collectorId";
    public static String Param_Name_OperatorField = "operatorField";
    public static String Param_Name_RowIdField = "rowIdField";
    
    
    public static String getDataFilter(String username) throws Exception {
        NamedSQL namedSQL = NamedSQL.getInstance(SQL_Name_GetDataFilter);
        namedSQL.setParam("username", username);
        
        String result = SQLRunner.getString(namedSQL);
        return result;
    }
 
 
    public static String writeUploadRecord(String username, String filename, String path) throws Exception {
        String id = Util.newShortGUID();
        
        NamedSQL namedSQL = NamedSQL.getInstance(SQL_Name_WriteUploadRecord);
        namedSQL.setParam("id", id);
        namedSQL.setParam("filename", filename);
        namedSQL.setParam("path", path);        
        namedSQL.setParam("username", username);
        
        SQLRunner.execSQL(namedSQL);
        
        return id;
    }
 
    public static void writeUploadSuccess(String id, int qty) throws Exception {
        NamedSQL namedSQL = NamedSQL.getInstance(SQL_Name_WriteUploadSuccess);
        namedSQL.setParam("id", id);
        namedSQL.setParam("qty", qty);
        
        SQLRunner.execSQL(namedSQL);
    }
 
    public static void changePassword(String username, String password) throws Exception {
        NamedSQL namedSQL = NamedSQL.getInstance(SQL_Name_ChangePassword);
        namedSQL.setParam("username", username);
        namedSQL.setParam("password", password);
        
        SQLRunner.execSQL(namedSQL);
    }
 
 
    public static void deleteData(String tableName) throws Exception {
        NamedSQL namedSQL = NamedSQL.getInstance(SQL_Name_EmptyTable);
        namedSQL.setTableName(tableName);
        
        SQLRunner.execSQL(namedSQL);
    }
 
}