liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
package com.basic.x01.securityCheck;
 
public class SecurityCheckUtil {
    public final static int CHECK_WAY_PHOTO = 1;
    public final static int CHECK_WAY_VIDEO = 2;
    
    public final static String[] checkWays=new String[]{
        CHECK_WAY_PHOTO+"", "拍照",
        CHECK_WAY_VIDEO+"", "视频"
    };
    
    public final static int CHECK_TIME_DAY = 1;
    public final static int CHECK_TIME_WEEK = 7;
    public final static int CHECK_TIME_MONTH = 30;
    public final static int CHECK_TIME_SEASON = 91;
    public final static int CHECK_TIME_HALF_YEAR = 182;
    public final static int CHECK_TIME_YEAR = 365;
    
    public final static String[] CHECK_TIME_STRING = new String[]{
        CHECK_TIME_DAY+"", "每天",
        CHECK_TIME_WEEK+"", "每周",
        CHECK_TIME_MONTH+"", "每月",
        CHECK_TIME_SEASON+"", "每季度",
        CHECK_TIME_HALF_YEAR+"", "每半年",
        CHECK_TIME_YEAR+"", "每年",
    };
    
    public final static String getSelectBoxHtml(String time){
        if(time==null){
            time = "";
        }
        time = "/" + time + "/";
        
        StringBuffer s = new StringBuffer("<select class=\"security-check-flow-time\">");
        for(int i=0; i<CHECK_TIME_STRING.length; i=i+2){
            String val=CHECK_TIME_STRING[i];
            String txt=CHECK_TIME_STRING[i+1];
            
            s.append("<option value=\"").append(val).append("\"");
            if(val.equals(time)){
                s.append(" selected=\"selected\"");
            }
            s.append(">").append(txt).append("</option>");
        }
        
        s.append("</select>");
        
        return s.toString();
    }
    
    public static String getCheckWayHtml4Edit(String checkWay){
        if(checkWay==null){
            checkWay="";
        }
        checkWay="/"+checkWay+"/";
        
        StringBuffer s = new StringBuffer();
        for(int i=0; i<checkWays.length; i=i+2){
            String val=checkWays[i];
            String txt=checkWays[i+1];
            
            s.append("<label for=\"security-item-check-way-")
            .append(val).append("\"><input type=\"checkbox\" ")
            .append("name=\"security-item-check-way\" ");
            if(checkWay.contains("/"+val+"/")){
                s.append("checked=\"checked\" ");
            }
            s.append("id=\"security-item-check-way-").append(val)
            .append("\" value=\"").append(val).append("\"/>")
            .append(txt).append("</label>");
        }
        
        return s.toString();
    }
    
    public static String getCheckWayText4Display(String checkWay){
        if(checkWay==null){
            checkWay="";
        }
        checkWay="/"+checkWay+"/";
        
        StringBuffer s = new StringBuffer();
        for(int i=0; i<checkWays.length; i=i+2){
            String val=checkWays[i];
            String txt=checkWays[i+1];
            
            if(checkWay.contains("/"+val+"/")){
                s.append("/").append(txt);
            }
        }
        if(s.toString().length()>0){
            s.deleteCharAt(0);
        }
        
        return s.toString();
    }
    
    public static boolean isCheckWay(String checkWay, int val){
        if(checkWay==null){
            checkWay="";
        }
        checkWay="/"+checkWay+"/";
        return checkWay.contains("/"+val+"/");
    }
}