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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
package com.dy.pipIrrMwTestWeb.p206V1_0_0;
 
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol.CommandType;
import com.dy.common.mw.protocol.p206V1_0_0.CodeV1_0_1;
import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0;
import com.dy.common.mw.protocol.p206V1_0_0.downVos.*;
import com.dy.common.webUtil.BaseResponse;
import com.dy.pipIrrMwTestWeb.common.CodeLocal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * @Author: liurunyu
 * @Date: 2024/6/29 6:46
 * @Description
 */
@Slf4j
@RestController
@RequestMapping(path="comP206V1_0_0")
@SuppressWarnings("unchecked")//java版本越高,对泛型约束越严,所以配置SuppressWarnings("unchecked")
public class CommandP206V1_0_0Ctrl extends ComSupportP206V1_0_0 {
 
    @GetMapping(path = "test")
    public BaseResponse<String> test(String com) {
        BaseResponse<String> rt = null ;
        if(com == null){
            rt = this.connect() ;//连接通信中间件测试
        }else{
            if(com.equals("10")){
                rt = this.cd10() ;
            }else if(com.equals("21")){
                rt = this.cd21() ;
            }else if(com.equals("37")){
                rt = this.cd37() ;
            }else if(com.equals("67")){
                rt = this.cd67() ;
            }else if(com.equals("38")){
                rt = this.cd38() ;
            }else if(com.equals("68")){
                rt = this.cd68() ;
            }else if(com.equals("39")){
                rt = this.cd39() ;
            }else if(com.equals("69")){
                rt = this.cd69() ;
            }else if(com.equals("3A")){
                rt = this.cd3A() ;
            }else if(com.equals("6A")){
                rt = this.cd6A() ;
            }else if(com.equals("3B")){
                rt = this.cd3B() ;
            }else if(com.equals("6B")){
                rt = this.cd6B() ;
            }else if(com.equals("3C")){
                rt = this.cd3C() ;
            }else if(com.equals("65")){
                rt = this.cd65() ;
            }else if(com.equals("91")){
                rt = this.cd91() ;
            }else if(com.equals("92")){
                rt = this.cd92() ;
            }else if(com.equals("93")){
                rt = this.cd93() ;
            }else if(com.equals("97")){
                rt = this.cd97() ;
            }else if(com.equals("98")){
                rt = this.cd98() ;
            }else if(com.equals("99")){
                rt = this.cd99() ;
            }else if(com.equals("A0")){
                rt = this.cdA0() ;
            }else if(com.equals("B0")){
                rt = this.cdB0() ;
            }
        }
        return rt ;
    }
 
 
    /**
     * 测试连通性
     * @return
     */
    private BaseResponse connect(){
        return this.sendTest() ;
    }
 
    private BaseResponse cd10(){
        Com10Vo comVo = new Com10Vo() ;
        comVo.rtuAddr = "532328059995" ;//前6位是行政区划码,后6位是序列号最大是065535
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_10, comVo, null)) ;
    }
 
    private BaseResponse cd21(){
        Com21Vo comVo = new Com21Vo() ;
        comVo.ip = "8.140.180.59" ;//IP(例如 125.235.35.89)
        comVo.port = 6001 ;///端口号(0~65536)
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_21, comVo, null)) ;
    }
 
    private BaseResponse cd37(){
        Com37Vo comVo = new Com37Vo() ;
        comVo.seconds = 20 ;//单位秒
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_37, comVo, null)) ;
    }
    private BaseResponse cd67(){
        Com37Vo comVo = new Com37Vo() ;
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_67, comVo, null)) ;
    }
 
    private BaseResponse cd38(){
        Com38Vo comVo = new Com38Vo() ;
        comVo.remainMoneyAlarm = 10.0 ;//用户余额报警值(大于1.0)
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_38, comVo, null)) ;
    }
 
    private BaseResponse cd68(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_68, null, null)) ;
    }
 
    private BaseResponse cd39(){
        Com39Vo comVo = new Com39Vo() ;
        comVo.batteryVoltAlarm = 7.0 ;//电池电压报警值(大于0.1)
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_39, comVo, null)) ;
    }
 
    private BaseResponse cd69(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_69, null, null)) ;
    }
 
    private BaseResponse cd3A(){
        Com3AVo comVo = new Com3AVo() ;
        comVo.current = 1.0 ;//阀门堵转电流(大于0)
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_3A, comVo, null)) ;
    }
 
    private BaseResponse cd6A(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_6A, null, null)) ;
    }
 
    private BaseResponse cd3B(){
        Com3BVo comVo = new Com3BVo() ;
        comVo.second = 120 ;//阀门超时时间(秒)(大于1)
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_3B, comVo, null)) ;
    }
 
    private BaseResponse cd6B(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_6B, null, null)) ;
    }
 
    private BaseResponse cd3C(){
        Com3CVo comVo = new Com3CVo() ;
        comVo.minute = 5 ;
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_3C, comVo, null)) ;
    }
 
    private BaseResponse cd65(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_65, null, null)) ;
    }
 
    private BaseResponse<String> cd91() {
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_91, null, null)) ;
    }
 
    private BaseResponse cd92(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_92, null, null)) ;
    }
 
    private BaseResponse cd93(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_93, null, null)) ;
    }
 
    //APP远程开阀
    private BaseResponse cd97(){
        Com97Vo comVo = new Com97Vo() ;
        comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo;
        comVo.moneyRemain = 234.56 ;
        comVo.waterPrice = 1.2 ;
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_97, comVo, null)) ;
    }
    //APP远程关阀
    private BaseResponse cd98(){
        Com98Vo comVo = new Com98Vo() ;
        comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo;
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_98, comVo, null)) ;
    }
 
    //定时关阀开阀
    private BaseResponse cd99(){
        Com99Vo comVo = new Com99Vo() ;
        comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo;
        comVo.moneyRemain = 234.56 ;
        comVo.waterPrice = 1.2 ;
        comVo.minutes = 3 ;
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_99, comVo, null)) ;
    }
 
    //定量关阀开阀
    private BaseResponse cdA0(){
        ComA0Vo comVo = new ComA0Vo() ;
        comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo;
        comVo.moneyRemain = 234.56 ;
        comVo.waterPrice = 1.2 ;
        comVo.waterAmount = 10 ;
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_98, comVo, null)) ;
    }
 
    private BaseResponse cdB0(){
        return this.sendCom2Mw(this.command(CodeV1_0_1.cd_B0, null, null)) ;
    }
 
    //在线情况
    private BaseResponse online(){
        Command com = new Command() ;
        com.id = Command.defaultId;//实际应用中,替换成数据库记录id
        com.protocol = ProtocolConstantV206V1_0_0.protocolName ;
        com.code = CodeLocal.onLine ;
        com.type = CommandType.innerCommand ;
        com.rtuResultSendWebUrl = rtuResultSendWebUrl ;
        return this.sendCom2Mw(com) ;
    }
 
 
}