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
package com.dy.common.mw.protocol.p206V2.upVos;
 
import com.dy.common.mw.protocol.UpDataVo;
import lombok.Data;
 
@Data
public class DataAlarmVo implements UpDataVo {
    public Byte batteryVolt ;// 蓄电池电压
    public Byte loss ;//漏损
    public Byte meter ;//流量计故障
    public Byte valve ;//阀门
 
    public String to1010(){
        String s = "" ;
        s += (batteryVolt == null ? "0" : batteryVolt.byteValue())  ;
        s += (loss == null ? "0" : loss.byteValue())  ;
        s += (meter == null ? "0" : meter.byteValue())  ;
        s += (valve == null ? "0" : valve.byteValue())  ;
        return s ;
    }
 
    public boolean hasDiff(DataAlarmVo oth){
        if(this.batteryVolt.byteValue() != oth.batteryVolt.byteValue()
                || this.loss.byteValue() != oth.loss.byteValue()
                || this.meter.byteValue() != oth.meter.byteValue()
                || this.valve.byteValue() != oth.valve.byteValue()){
            return true ;
        }else{
            return false ;
        }
    }
 
    public boolean hasAlarm(){
        boolean flag = false ;
        if((batteryVolt != null && batteryVolt == 1) ||
                (loss != null && loss == 1) ||
                (meter != null && meter == 1) ||
                (valve != null && valve == 1)){
            flag = true ;
        }
        return flag ;
    }
 
 
    public boolean hasAlarmExcludeLoss(){
        boolean flag = false ;
        if((batteryVolt != null && batteryVolt == 1) ||
                (meter != null && meter == 1) ||
                (valve != null && valve == 1)){
            flag = true ;
        }
        return flag ;
    }
 
    public String alarmContent(){
        String txt = "" ;
        boolean hasTxt = false ;
        if(batteryVolt != null && batteryVolt == 1){
            txt += (hasTxt?"、":"") + "蓄电池电压报警" ;
            hasTxt = true ;
        }
        if(meter != null && meter == 1){
            txt += (hasTxt?"、":"") + "流量计故障报警" ;
            hasTxt = true ;
        }
        if(valve != null && valve == 1){
            txt += (hasTxt?"、":"") + "阀门故障报警" ;
            hasTxt = true ;
        }
       if(loss != null && loss == 1){
            txt += (hasTxt?"、":"") + "漏损报警" ;
            hasTxt = true ;
        }
        return txt ;
    }
 
    public String alarmContentExcludeLoss(){
        String txt = "" ;
        boolean hasTxt = false ;
        if(batteryVolt != null && batteryVolt == 1){
            txt += (hasTxt?"、":"") + "蓄电池电压报警" ;
            hasTxt = true ;
        }
        if(meter != null && meter == 1){
            txt += (hasTxt?"、":"") + "流量计故障报警" ;
            hasTxt = true ;
        }
        if(valve != null && valve == 1){
            txt += (hasTxt?"、":"") + "阀门故障报警" ;
            hasTxt = true ;
        }
        return txt ;
    }
    public String toString(){
        StringBuilder str = new StringBuilder() ;
        str.append("      报警:\n");
        str.append("         蓄电池电压:");
        str.append(batteryVolt==null?"":(batteryVolt==1?"报警(1)":"正常(0)"));
        str.append("\n");
        str.append("         漏损:     ");
        str.append(loss==null?"":(loss==1?"报警(1)":"正常(0)"));
        str.append("\n");
        str.append("         流量计故障:");
        str.append(meter==null?"":(meter==1?"报警(1)":"正常(0)"));
        str.append("\n");
        str.append("         阀门:     ");
        str.append(valve==null?"":(valve==1?"报警(1)":"正常(0)"));
        return str.toString() ;
    }
}