fengxiang
2018-02-06 7014fd76c199e676159ac30da6f4dbb91e3a137e
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
package com.moral.common.bean;
 
import com.moral.common.util.ResourceUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * 系统常量.
 */
@Component
public class Constants {
    
    /** The Constant IS_DELETE_TRUE. */
    public static final String IS_DELETE_TRUE = "1";
    
    /** The Constant IS_DELETE_FALSE. */
    public static final String IS_DELETE_FALSE = "0";
    
    /** The Constant NULL_VALUE. */
    public static final String NULL_VALUE = "N/V";
    
    public static final String IS_USED_FALSE = "0";
 
    public static final String IS_USED_TRUE = "1";
    private static Integer[] specialOrgIds;
    @PostConstruct
    private void loadSpecialOrgIds(){
      String orgIds = ResourceUtil.getValue("specialOrgIds");
      if(!StringUtils.isBlank(orgIds)){
          String [] orgIdArray = orgIds.split(",");
          if(!ArrayUtils.isEmpty(orgIdArray)){
              List<Integer> orgIdList =  Arrays.asList(orgIdArray).stream().map(Integer::new).collect(Collectors.toList());
              specialOrgIds = orgIdList.toArray(new Integer[orgIdList.size()]);
          }
      }
 
    }
    public static final Boolean isNotSpecialOrgId(Integer orgId) {
        if(ArrayUtils.isEmpty(specialOrgIds)){
            return true;
        }
        for(int i = 0; i < specialOrgIds.length; ++i) {
            if (specialOrgIds[i].equals(orgId)) {
                return false;
            }
        }
        return true;
    }
    //device 状态
    public static final String DEVICE_STATE_NORMAL ="0";
    public static final String DEVICE_STATE_MILD = "1";
    public static final String DEVICE_STATE_MIDDLE ="2";
    public static final String DEVICE_STATE_SERIOUS ="3";
    public static final String DEVICE_STATE_OFFLINE ="4";
}