package com.dy.pipIrrMwTestWeb.p206V202404test; 
 | 
  
 | 
import com.dy.common.mw.protocol.p206V202404.CodeV202404; 
 | 
import com.dy.common.mw.protocol.p206V202404.downVos.*; 
 | 
import com.dy.common.webUtil.BaseResponse; 
 | 
import lombok.extern.slf4j.Slf4j; 
 | 
import org.springframework.web.bind.annotation.*; 
 | 
  
 | 
/** 
 | 
 * @Author: liurunyu 
 | 
 * @Date: 2024/5/14 14:20 
 | 
 * @Description 
 | 
 */ 
 | 
@Slf4j 
 | 
@RestController 
 | 
@RequestMapping(path="comP206V202404") 
 | 
@SuppressWarnings("unchecked")//java版本越高,对泛型约束越严,所以配置SuppressWarnings("unchecked") 
 | 
public class CommandP206V202404Ctrl extends ComSupportP206V202404 { 
 | 
  
 | 
    @GetMapping(path = "test") 
 | 
    public BaseResponse<String> test(String rtuAddr, String com) { 
 | 
        BaseResponse<String> rt = null ; 
 | 
        if(rtuAddr == null || rtuAddr.trim().equals("")){ 
 | 
            rt = this.connect() ;//连接通信中间件测试 
 | 
        }else{ 
 | 
            this.rtuAddr = rtuAddr ; 
 | 
            if(com == null || com.trim().equals("")){ 
 | 
                rt = this.connect() ;//连接通信中间件测试 
 | 
            }else{ 
 | 
                try{ 
 | 
                    if(com.equals("10")){ 
 | 
                        rt = this.cd10() ; 
 | 
                    }else if(com.equals("15")){ 
 | 
                        rt = this.cd15() ; 
 | 
                    }else if(com.equals("16")){ 
 | 
                        rt = this.cd16() ; 
 | 
                    }else if(com.equals("21")){ 
 | 
                        rt = this.cd21() ; 
 | 
                    }else if(com.equals("22")){ 
 | 
                        rt = this.cd22() ; 
 | 
                    }else if(com.equals("23")){ 
 | 
                        rt = this.cd23() ; 
 | 
                    }else if(com.equals("24")){ 
 | 
                        rt = this.cd24() ; 
 | 
                    }else if(com.equals("26")){ 
 | 
                        rt = this.cd26() ; 
 | 
                    }else if(com.equals("31")){ 
 | 
                        rt = this.cd31() ; 
 | 
                    }else if(com.equals("55")){ 
 | 
                        rt = this.cd55(1) ; 
 | 
                    }else if(com.equals("65")){ 
 | 
                        rt = this.cd65(1) ; 
 | 
                    }else if(com.equals("86")){ 
 | 
                        rt = this.cd86() ; 
 | 
                    }else if(com.equals("87")){ 
 | 
                        rt = this.cd87() ; 
 | 
                    }else if(com.equals("92")){ 
 | 
                        rt = this.cd92() ; 
 | 
                    }else if(com.equals("93")){ 
 | 
                        rt = this.cd93() ; 
 | 
                    }else if(com.equals("9C")){ 
 | 
                        rt = this.cd9C() ; 
 | 
                    }else if(com.equals("A2")){ 
 | 
                        rt = this.cdA2() ; 
 | 
                    }else if(com.equals("A3")){ 
 | 
                        rt = this.cdA3() ; 
 | 
                    }else{ 
 | 
                        rt = this.cdXY(com) ;//发送固定参数XY的命令, 例命令CodeV202404.cd_9C 
 | 
                    } 
 | 
                }catch (Exception e){ 
 | 
                    e.printStackTrace(); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
        return rt ; 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 测试连通性 
 | 
     * @return 
 | 
     */ 
 | 
    private BaseResponse connect(){ 
 | 
        return this.sendTest() ; 
 | 
    } 
 | 
  
 | 
    //发送固定参数的命令 
 | 
    private BaseResponse cdXY(String code){ 
 | 
        return this.sendCom2Mw(this.command(code, this.comCdXyVo(), null)) ; 
 | 
    } 
 | 
  
 | 
    //设置终端地址(AFN=0x10H) 
 | 
    private BaseResponse cd10(){ 
 | 
        ComCd10Vo comVo = new ComCd10Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.rtuNewAddr = CommandP206V202404Ctrl.rtuAddr ; 
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_10, comVo, null)) ; 
 | 
    } 
 | 
     //远程用户充值 (AFN=0x15H) 
 | 
    private BaseResponse cd15(){ 
 | 
        ComCd15Vo comVo = new ComCd15Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.icCardAddr = CommandP206V202404Ctrl.icCardAddr ;//IC卡地址(8位数字或字母) 
 | 
        comVo.icCardNo = CommandP206V202404Ctrl.icCardNo ;//用户卡序列号(17位数字)(6字节BCD,2字节HEX) 
 | 
        comVo.chargeMoney = 20.0 ;//单位:元  2位小数点(最大值 99999999.99) 
 | 
        comVo.chargeWater = 20.0 ;//单位:m3  2位小数点(最大值 99999999.99) 
 | 
        comVo.flowNo = "123456789012" ;//流水号(12位数字) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_15, comVo, null)) ; 
 | 
    } 
 | 
    //设置设备终端剩余水量和剩余金额报警值 (AFN=0x16H) 
 | 
    private BaseResponse cd16(){ 
 | 
        ComCd16Vo comVo = new ComCd16Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.waterAlarm = 100 ;//剩余水量报警值,单位:m3。整数,取值范围0~9999 
 | 
        comVo.moneyAlarm = 3 ;//剩余金额报警值,单位:元。整数,取值范围0~9999 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_16, comVo, null)) ; 
 | 
    } 
 | 
    //设置设备终端IP地址 (AFN=0x21H) 
 | 
    private BaseResponse cd21(){ 
 | 
        ComCd21Vo comVo = new ComCd21Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.channel = 1 ;//IP通道号(取值范围 1、2). 
 | 
        comVo.ip = "8.140.180.59" ;//IP(例如 125.235.35.89) 
 | 
        comVo.port = 6001 ;///端口号(0~65536) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_21, comVo, null)) ; 
 | 
    } 
 | 
    //设置机井年最大开采量和水位下限 (AFN=0x22H) 
 | 
    private BaseResponse cd22(){ 
 | 
        ComCd22Vo comVo = new ComCd22Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.maxAmountYear = 99998888 ;//机井年最大用水量单位:m3 整数,取值范围0~99999999 
 | 
        comVo.limitLevel = 9978.60; //水位下限 单位:m 取值范围:0~9999.99 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_22, comVo, null)) ; 
 | 
    } 
 | 
    //设置设备终端域名(AFN=0x23H) 
 | 
    private BaseResponse cd23(){ 
 | 
        ComCd23Vo comVo = new ComCd23Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.channel = 1 ;//IP通道号(取值范围 1、2). 
 | 
        comVo.domain = "dayuyanjiuyuan.top" ;//域名(例如 dayuyanjiuyuan.top),最大长度42字符 
 | 
        comVo.port = 6001 ;///端口号(0~65536) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_23, comVo, null)) ; 
 | 
    } 
 | 
    //设置设备终端注册号(AFN=0x24H) 
 | 
    private BaseResponse cd24(){ 
 | 
        ComCd24Vo comVo = new ComCd24Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.registerNo = "10203040506070809000" ;// 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_24, comVo, null)) ; 
 | 
    } 
 | 
    //设置设备终端年用水量(AFN=0x24H) 
 | 
    private BaseResponse cd26(){ 
 | 
        ComCd26Vo comVo = new ComCd26Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.maxAmountYear = 200  ;//设备终端年用水量 单位:m3 整数,取值范围0~99999999 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_26, comVo, null)) ; 
 | 
    } 
 | 
    //设置设备终端用水有效(AFN=0x31H) 
 | 
    private BaseResponse cd31(){ 
 | 
        ComCd31Vo comVo = new ComCd31Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.valid = false ;//有效性 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_31, comVo, null)) ; 
 | 
    } 
 | 
    //查询遥测终端充值记录 (AFN=0x55H) 
 | 
    private BaseResponse cd55(int page){ 
 | 
        ComCd55Vo comVo = new ComCd55Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.page = page ;//分页(取值范围1、2、3、4、5、6、7、8、9) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_55, comVo, null)) ; 
 | 
    } 
 | 
    //查询设备终端用户用水记录(AFN=0x65H) 
 | 
    private BaseResponse cd65(int page){ 
 | 
        ComCd65Vo comVo = new ComCd65Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.page = page ; 
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_65, comVo, null)) ; 
 | 
    } 
 | 
    //查询控制器IP地址(AFN=0x86H) 
 | 
    private BaseResponse cd86(){ 
 | 
        ComCd86Vo comVo = new ComCd86Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.channel = 1 ;//IP通道号(取值范围 1、2). 
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_86, comVo, null)) ; 
 | 
    } 
 | 
    //查询控制器域名(AFN=0x87H) 
 | 
    private BaseResponse cd87(){ 
 | 
        ComCd87Vo comVo = new ComCd87Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.channel = 1 ;//IP通道号(取值范围 1、2). 
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_87, comVo, null)) ; 
 | 
    } 
 | 
    //平台/APP远程开启水泵/阀门(AFN=0x92H/AFN=0xA2H) 
 | 
    private BaseResponse cd92(){ 
 | 
        ComCd92_A2Vo comVo = new ComCd92_A2Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        //comVo.icCardAddr = Test.icCardAddr ;//IC卡地址(8位数字或字母) 
 | 
        comVo.icCardNo = CommandP206V202404Ctrl.icCardNo ;//用户卡序列号(17位数字)(6字节BCD,2字节HEX) 
 | 
        comVo.waterRemain = 123.45 ;//单位:元  2位小数点(最大值 99999999.99) 
 | 
        comVo.moneyRemain = 234.56 ;//单位:m3  2位小数点(最大值 99999999.99) 
 | 
        comVo.waterPrice = 0.8 ;//水量单价 单位:元, 2个小数点 
 | 
        comVo.elePrice = 1.2 ;//电量单价 单位:元, 2个小数点 
 | 
        comVo.orderNo = "1234567890123456" ;//订单号(16位数字) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_92, comVo, null)) ; 
 | 
    } 
 | 
    //平台/APP远程开启水泵/阀门(AFN=0x92H/AFN=0xA2H) 
 | 
    private BaseResponse cdA2(){ 
 | 
        ComCd92_A2Vo comVo = new ComCd92_A2Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        //comVo.icCardAddr = Test.icCardAddr ;//IC卡地址(8位数字或字母) 
 | 
        comVo.icCardNo = CommandP206V202404Ctrl.icCardNo ;//用户卡序列号(17位数字)(6字节BCD,2字节HEX) 
 | 
        comVo.waterRemain = 123.45 ;//单位:元  2位小数点(最大值 99999999.99) 
 | 
        comVo.moneyRemain = 234.56 ;//单位:m3  2位小数点(最大值 99999999.99) 
 | 
        comVo.waterPrice = 0.8 ;//水量单价 单位:元, 2个小数点 
 | 
        comVo.elePrice = 1.2 ;//电量单价 单位:元, 2个小数点 
 | 
        comVo.orderNo = "1234567890123456" ;//订单号(16位数字) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_A2, comVo, null)) ; 
 | 
    } 
 | 
  
 | 
   //平台/APP远程关闭水泵/阀门(AFN=0x93H/AFN=0xA3H) 
 | 
    private BaseResponse cd93(){ 
 | 
        ComCd93_A3Vo comVo = new ComCd93_A3Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.icCardNo = CommandP206V202404Ctrl.icCardNo ;//用户卡序列号(17位数字)(6字节BCD,2字节HEX) 
 | 
        comVo.orderNo = "1234567890123456" ;//订单号(16位数字) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_93, comVo, null)) ; 
 | 
    } 
 | 
  
 | 
   //平台/APP远程关闭水泵/阀门(AFN=0x93H/AFN=0xA3H) 
 | 
    private BaseResponse cd9C(){ 
 | 
        ComCd9CVo comVo = new ComCd9CVo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.icCardAddr = "04BEA5BB" ;// 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_9C, comVo, null)) ; 
 | 
    } 
 | 
    //平台/APP远程关闭水泵/阀门(AFN=0x93H/AFN=0xA3H) 
 | 
    private BaseResponse cdA3(){ 
 | 
        ComCd93_A3Vo comVo = new ComCd93_A3Vo() ; 
 | 
        comVo.controllerType = CommandP206V202404Ctrl.controllerType ; 
 | 
        comVo.projectNo = CommandP206V202404Ctrl.projectNo  ; 
 | 
        comVo.icCardNo = CommandP206V202404Ctrl.icCardNo ;//用户卡序列号(17位数字)(6字节BCD,2字节HEX) 
 | 
        comVo.orderNo = "1234567890123456" ;//订单号(16位数字) 
 | 
  
 | 
        return this.sendCom2Mw(this.command(CodeV202404.cd_A3, comVo, null)) ; 
 | 
    } 
 | 
  
 | 
  
 | 
} 
 |