xiejun
2024-01-29 d1ebae3f837f69af8d7d8f752ebd7b976b56db2a
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
package com.vci.ubcs.code.util;
 
import com.vci.ubcs.omd.feign.IAttributeClient;
import com.vci.ubcs.omd.util.Tool;
import com.vci.ubcs.omd.vo.AttributeVO;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
public class AttributeChecker {
 
    @Autowired(required = false)
    private  IAttributeClient attributeClient;
 
    public static HashMap<String, AttributeVO> attrItemMap = new HashMap();
    public static List<AttributeVO> attrItems = new ArrayList<AttributeVO>();
 
    public void getAllAttribute() {
        if (attrItems == null) {
            R<List<AttributeVO>> R = attributeClient.getAll();
            attrItems=R.getData();
            List<AttributeVO> var4;
            int var3 = (var4 = attrItems).size();
 
            for(int var2 = 0; var2 < var3; ++var2) {
                AttributeVO attrItem = var4.get(var2);
                attrItemMap.put(attrItem.getName(), attrItem);
            }
        }
 
    }
 
    public int isAttrValValid(String attrName, String attrVal) {
//        if (!BusinessConstants.BO_CONSTANTS.containsKey(attrName.toUpperCase())) {
            if (attrVal != null && !attrVal.trim().equals("")) {
                this.getAllAttribute();
                AttributeVO attributeVO = (AttributeVO)attrItemMap.get(attrName);
                if (attributeVO == null) {
                    return 0;
                } else {
                    String attrType = attributeVO.getTypeKey();
                    int rs;
                    if (attrType.equals("VTString")) {
                    //    rs = this.checkVTStringValValid(attributeVO, attrName, attrVal);
                        rs = 0;
                    } else if (attrType.equals("VTInteger")) {
                    //    rs = this.checkVTIntegerValValid(attributeVO, attrName, attrVal);
                        rs = 0;
                    } else if (attrType.equals("VTLong")) {
                    //    rs = this.checkVTLongValValid(attributeVO, attrName, attrVal);
                        rs = 0;
                    } else if (attrType.equals("VTDouble")) {
                    //    rs = this.checkVTDoubleValValid(attributeVO, attrName, attrVal);
                        rs = 0;
                    } else if (attrType.equals("VTBoolean")) {
                        rs = 0;
                    } else if (attrType.equals("VTImage")) {
                        rs = 0;
                    } else if (attrType.equals("VTDate")) {
                        rs = 0;
                    } else if (attrType.equals("VTTime")) {
                        rs = 0;
                    } else if (attrType.equals("VTDateTime")) {
                        rs = 0;
                    } else if (attrType.equals("VTNote")) {
                        rs = 0;
                    } else if (attrType.equals("VTFilePath")) {
                        rs = 0;
                    } else {
                        rs = 0;
                    }
 
                    return rs;
                }
            } else {
                return 0;
            }
//        } else {
//            return 0;
//        }
    }
 
    /*private int checkVTStringValValid(AttributeVO attributeVO, String attrName, String attrVal) {
        String other ="";
        int maxLength = Integer.valueOf(Tool.getOtherValueByType(other, "length"));
        int length = attrVal.length();
        return length > maxLength ? 1 : 0;
    }
 
    private int checkVTIntegerValValid(AttributeVO attributeVO, String attrName, String attrVal) {
        VTInteger obj = new VTInteger(Integer.valueOf(attrVal));
        return !obj.checkRageValueByRage(attributeVO.rage) ? 2 : 0;
    }
 
    private int checkVTLongValValid(AttributeVO attributeVO, String attrName, String attrVal) {
        VTLong obj = new VTLong(Long.valueOf(attrVal));
        return !obj.checkRageValueByRage(attributeVO.rage) ? 2 : 0;
    }
 
    private int checkVTDoubleValValid(AttributeVO attributeVO, String attrName, String attrVal) {
        VTDouble obj = new VTDouble(Double.valueOf(attrVal));
        String other = attributeVO.other;
        int maxLength = Integer.valueOf(Tool.getOtherValueByType(other, "length"));
        int length = String.valueOf(attrVal).length() - 1;
        if (length >= maxLength && !obj.checkRageValueByRage(attributeVO.rage)) {
            return 3;
        } else if (!obj.checkRageValueByRage(attributeVO.rage)) {
            return 2;
        } else {
            return length >= maxLength ? 1 : 0;
        }
    }*/
}