Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
| | |
| | | public static final String cd_98 = "98" ;//APP远程关阀 |
| | | public static final String cd_99 = "99" ;//定时关阀开阀 |
| | | public static final String cd_A0 = "A0" ;//定量关阀开阀 |
| | | public static final String cd_A1 = "A1" ;//定时关阀计划开阀 |
| | | public static final String cd_A2 = "A2" ;//定量关阀计划开阀 |
| | | public static final String cd_B0 = "B0" ;//查询实时数据(未实现) |
| | | public static final String cd_C0 = "C0" ;//遥测站整点上报实时数据 ok |
| | | |
| | |
| | | (code.equals(cd_98) ? "APP远程关阀" : |
| | | (code.equals(cd_99) ? "定时关阀开阀" : |
| | | (code.equals(cd_A0) ? "定量关阀开阀" : |
| | | (code.equals(cd_A1) ? "定时关阀计划开阀" : |
| | | (code.equals(cd_A2) ? "定量关阀计划开阀" : |
| | | (code.equals(cd_B0) ? "查询实时数据" : |
| | | (code.equals(cd_C0) ? "自报(整点)实时数据" : |
| | | ""))))))))))))))))))))))))))))))))))))))))) ; |
| | | ""))))))))))))))))))))))))))))))))))))))))))) ; |
| | | return name ; |
| | | } |
| | | |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.downVos; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/5/28 21:30 |
| | | * @Description 定时关阀开阀 |
| | | */ |
| | | @Data |
| | | public class ComA1Vo { |
| | | public String icCardNo ;//17位虚拟IC卡编号(协议是10位数字) |
| | | public Double moneyRemain;//剩余金额(取值范围0.00~999999.99,单位为元) |
| | | public Double waterPrice;//水价(取值范围0.00~99.99元/m3) |
| | | public Integer minutes ;//用水时长(0~9999分钟) |
| | | public Integer year ; //计划开阀时间---年 |
| | | public Integer month ;//计划开阀时间---月 |
| | | public Integer day ;//计划开阀时间---日 |
| | | public Integer hour ;//计划开阀时间---时 |
| | | public Integer minute ;//计划开阀时间---分 |
| | | |
| | | public String orderNo ;//订单号(16位数字) |
| | | } |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.downVos; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/5/28 21:30 |
| | | * @Description 定时关阀开阀 |
| | | */ |
| | | @Data |
| | | public class ComA2Vo { |
| | | public String icCardNo ;//17位虚拟IC卡编号(协议是10位数字) |
| | | public Double moneyRemain;//剩余金额(取值范围0.00~999999.99,单位为元) |
| | | public Double waterPrice;//水价(取值范围0.00~99.99元/m3) |
| | | public Integer waterAmount ;//预用水量(0~9999 m3) |
| | | public Integer year ; //计划开阀时间---年 |
| | | public Integer month ;//计划开阀时间---月 |
| | | public Integer day ;//计划开阀时间---日 |
| | | public Integer hour ;//计划开阀时间---时 |
| | | public Integer minute ;//计划开阀时间---分 |
| | | public String orderNo ;//订单号(16位数字) |
| | | } |
| | |
| | | * @throws Exception 异常 |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | byte opType = bs[ProtocolConstantV206V1_0_0.dataIndex]; |
| | | byte opType = (byte)ByteUtil.BCD2Int_LE(bs[ProtocolConstantV206V1_0_0.dataIndex]) ; |
| | | Boolean isCloseType = CommonV1_0_1.isCloseValveType(opType) ; |
| | | if(isCloseType != null && isCloseType.booleanValue()){ |
| | | this.doParseClose(opType, bs, bsLen, dataCode, data); |
| | | }else if(isCloseType != null && !isCloseType.booleanValue()){ |
| | | this.doParseOpen(opType, bs, bsLen, dataCode, data); |
| | | }else{ |
| | | throw new Exception("开关阀类型[" + ByteUtil.bytes2Hex(new byte[]{opType}, false) + "(hex)]不可识别" ) ; |
| | | } |
| | | } |
| | | private void doParseOpen(byte opType, byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | |
| | | cdData.openDt = GlParse.parseTp(bs, index) ; |
| | | |
| | | index += 6 ; |
| | | /* 开阀时,此部分没有 |
| | | cdData.priceType = bs[index] ; |
| | | |
| | | index++ ; |
| | | cdData.price = 0.0D ; |
| | | tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ; |
| | | index++ ; |
| | | cdData.price += tpInt/100.0 ; |
| | | tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ; |
| | | index++ ; |
| | | cdData.price += tpInt; |
| | | |
| | | cdData.cardType = bs[index] ; |
| | | |
| | | index++ ; |
| | | */ |
| | | //控制器时钟 |
| | | cdData.rtuDt = GlParse.parseTp(bs, index) ; |
| | | //index += 6 ; |
| | |
| | | dV1.subData = cdData ; |
| | | |
| | | short index = ProtocolConstantV206V1_0_0.dataIndex ; |
| | | cdData.opType = bs[index] ; |
| | | cdData.opType = (byte)ByteUtil.BCD2Int_LE(bs[index]) ; |
| | | |
| | | index++ ; |
| | | cdData.cardType = bs[index] ; |
| | |
| | | String json = obj.toJSONString(); |
| | | Com99Vo cvo = JSON.parseObject(json, Com99Vo.class) ; |
| | | if(cvo == null){ |
| | | throw new Exception("json转Com97Vo为null") ; |
| | | throw new Exception("json转Com99Vo为null") ; |
| | | } |
| | | if(cvo.icCardNo == null){ |
| | | throw new Exception("虚拟IC卡编号不能为空") ; |
| | |
| | | //ByteUtil.string2BCD_LE(bs, icCardNoGrp[1], index) ; |
| | | byte[] bs = new byte[8] ; |
| | | GlCreate.createIcCardNo(cvo.icCardNo, bs, 0); |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | |
| | | |
| | | index += 5 ; |
| | | bs = new byte[4] ; |
| | | index = 0 ; |
| | | Integer money = Double.valueOf(cvo.moneyRemain * 100.0D).intValue() ; |
| | | byte[] bTemp = ByteUtil.int2BCD_LE(money) ; |
| | | int bTempLen = bTemp.length ; |
| | |
| | | for(; count < 4; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | Integer price = Double.valueOf(cvo.waterPrice * 100.0D).intValue() ; |
| | | bTemp = ByteUtil.int2BCD_LE(price) ; |
| | | bTempLen = bTemp.length ; |
| | |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | bTemp = ByteUtil.int2BCD_LE(cvo.minutes) ; |
| | | bTempLen = bTemp.length ; |
| | | count = 0 ; |
| | |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | GlCreate.createLen(bytes);//长度放字节数组中 |
| | | |
| | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCd98Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCd99Vo; |
| | | import com.dy.common.util.ByteUtil; |
| | |
| | | DataCd99Vo cdData = new DataCd99Vo() ; |
| | | dV1.subData = cdData ; |
| | | //虚拟卡号 |
| | | cdData.cardNo = ByteUtil.BCD2String_LE(bs, ProtocolConstantV206V1_0_0.dataIndex, ProtocolConstantV206V1_0_0.dataIndex+4) ; |
| | | if(bs[ProtocolConstantV206V1_0_0.dataIndex + 5] == (byte)0xAA){ |
| | | cdData.cardNo = GlParse.parseIcCardNo(bs, ProtocolConstantV206V1_0_0.dataIndex) ; |
| | | |
| | | if(bs[ProtocolConstantV206V1_0_0.dataIndex + 8] == (byte)0xAA){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
| | |
| | | String json = obj.toJSONString(); |
| | | ComA0Vo cvo = JSON.parseObject(json, ComA0Vo.class) ; |
| | | if(cvo == null){ |
| | | throw new Exception("json转Com97Vo为null") ; |
| | | throw new Exception("json转ComA0Vo为null") ; |
| | | } |
| | | if(cvo.icCardNo == null){ |
| | | throw new Exception("虚拟IC卡编号不能为空") ; |
| | |
| | | //if(icCardNoGrp[0] != null){ |
| | | // midRs.param = icCardNoGrp[0] ; |
| | | //} |
| | | //ByteUtil.string2BCD_LE(bs, icCardNoGrp[1], index) ; |
| | | byte[] bs = new byte[16] ; |
| | | index = 0 ; |
| | | //ByteUtil.string2BCD_LE(bs, icCardNoGrp[1], index) ; |
| | | GlCreate.createIcCardNo(cvo.icCardNo, bs, 0); |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | |
| | | index += 5 ; |
| | | bs = new byte[4] ; |
| | | index = 0 ; |
| | | Integer money = Double.valueOf(cvo.moneyRemain * 100.0D).intValue() ; |
| | | byte[] bTemp = ByteUtil.int2BCD_LE(money) ; |
| | | int bTempLen = bTemp.length ; |
| | |
| | | for(; count < 4; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | Integer price = Double.valueOf(cvo.waterPrice * 100.0D).intValue() ; |
| | | bTemp = ByteUtil.int2BCD_LE(price) ; |
| | | bTempLen = bTemp.length ; |
| | |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | bTemp = ByteUtil.int2BCD_LE(cvo.waterAmount) ; |
| | | bTempLen = bTemp.length ; |
| | | count = 0 ; |
| | |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | GlCreate.createLen(bytes);//长度放字节数组中 |
| | | |
| | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCd99Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCdA0Vo; |
| | | import com.dy.common.util.ByteUtil; |
| | |
| | | DataCdA0Vo cdData = new DataCdA0Vo() ; |
| | | dV1.subData = cdData ; |
| | | //虚拟卡号 |
| | | cdData.cardNo = ByteUtil.BCD2String_LE(bs, ProtocolConstantV206V1_0_0.dataIndex, ProtocolConstantV206V1_0_0.dataIndex+4) ; |
| | | if(bs[ProtocolConstantV206V1_0_0.dataIndex + 5] == (byte)0xAA){ |
| | | cdData.cardNo = GlParse.parseIcCardNo(bs, ProtocolConstantV206V1_0_0.dataIndex) ; |
| | | |
| | | if(bs[ProtocolConstantV206V1_0_0.dataIndex + 8] == (byte)0xAA){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.parse; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.CodeV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.CommonV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ParseParamsForDownV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.downVos.Com99Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.downVos.ComA1Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeDown(ifAny={ |
| | | CodeV1_0_1.cd_A1 |
| | | }) |
| | | public class Cd_A1_Down implements CodeParse { |
| | | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { |
| | | ParseParamsForDownV1_0_1 para = (ParseParamsForDownV1_0_1) params ; |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | byte[] bs = this.doParse(midRs, para) ; |
| | | |
| | | midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;//rtu返回命令结果 发向目的地web URL |
| | | midRs.protocolName = para.protocolName ;//协议名称 |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtu地址 |
| | | midRs.commandId = para.commandId ;//命令ID,发起命令的客户端(web端)生成,以匹配命令结果 |
| | | midRs.downCode = para.commandCode ;//下行命令功能码; |
| | | midRs.downBuffer = bs ;//下行命令数据 |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//下行命令数据十六进制形式 |
| | | midRs.hasResponse = true ;//是否有应答 |
| | | midRs.maxSendTimes = null ;//命令最大发送次数(当收不到应答时,将重发),如果不设置,命令缓存器进行补充设置 |
| | | midRs.isCachForOffLine = false ;//RTU不在线,命令是否缓存,低功耗时为true |
| | | |
| | | if(isLowPower != null && isLowPower.booleanValue()){ |
| | | //低功耗时,尽快发送 |
| | | midRs.isQuickSend = true ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | |
| | | /** |
| | | * 构造下行数据 |
| | | * @param midRs 参数 |
| | | * @param para 参数 |
| | | * @return 字节数组 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public byte[] doParse(MidResultToRtu midRs, ParseParamsForDownV1_0_1 para) throws Exception { |
| | | CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ; |
| | | byte[] bytes ; |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ; |
| | | byte index = 0 ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = 0 ;//帧长度 |
| | | |
| | | index++ ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; |
| | | |
| | | index++ ; |
| | | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); |
| | | index += 5 ; |
| | | |
| | | ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; |
| | | |
| | | JSONObject obj = (JSONObject)para.param; |
| | | String json = obj.toJSONString(); |
| | | ComA1Vo cvo = JSON.parseObject(json, ComA1Vo.class) ; |
| | | if(cvo == null){ |
| | | throw new Exception("json转Com99Vo为null") ; |
| | | } |
| | | if(cvo.icCardNo == null){ |
| | | throw new Exception("虚拟IC卡编号不能为空") ; |
| | | } |
| | | if(cvo.moneyRemain == null){ |
| | | throw new Exception("剩余金额不能为空") ; |
| | | } |
| | | if(cvo.waterPrice == null){ |
| | | throw new Exception("水价不能为空") ; |
| | | } |
| | | if(cvo.minutes == null){ |
| | | throw new Exception("用水时长不能为空") ; |
| | | } |
| | | if(cvo.minutes < 0 || cvo.minutes > 9999){ |
| | | throw new Exception("用水时长取值范围是0~9999分钟") ; |
| | | } |
| | | if(cvo.year == null){ |
| | | throw new Exception("计划开阀时间---年不能为空") ; |
| | | } |
| | | if(cvo.year < 24 || cvo.year > 9999){ |
| | | throw new Exception("计划开阀时间---年不正确") ; |
| | | } |
| | | if(cvo.year > 24 && cvo.year < 2024){ |
| | | throw new Exception("计划开阀时间---年不正确") ; |
| | | } |
| | | if(cvo.month == null){ |
| | | throw new Exception("计划开阀时间---月不能为空") ; |
| | | } |
| | | if(cvo.month < 1 || cvo.month > 12){ |
| | | throw new Exception("计划开阀时间---月不正确") ; |
| | | } |
| | | if(cvo.day == null){ |
| | | throw new Exception("计划开阀时间---日不能为空") ; |
| | | } |
| | | if(cvo.day < 1 || cvo.day > 31){ |
| | | throw new Exception("计划开阀时间---日不正确") ; |
| | | } |
| | | if(cvo.hour == null){ |
| | | throw new Exception("计划开阀时间---时不能为空") ; |
| | | } |
| | | if(cvo.hour < 0 || cvo.hour > 23){ |
| | | throw new Exception("计划开阀时间---时不正确") ; |
| | | } |
| | | if(cvo.minute == null){ |
| | | throw new Exception("计划开阀时间---时不能为空") ; |
| | | } |
| | | if(cvo.minute < 0 || cvo.minute > 59){ |
| | | throw new Exception("计划开阀时间---分不正确") ; |
| | | } |
| | | |
| | | byte[] bs = new byte[8] ; |
| | | GlCreate.createIcCardNo(cvo.icCardNo, bs, 0); |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | |
| | | bs = new byte[4] ; |
| | | index = 0 ; |
| | | Integer money = Double.valueOf(cvo.moneyRemain * 100.0D).intValue() ; |
| | | byte[] bTemp = ByteUtil.int2BCD_LE(money) ; |
| | | int bTempLen = bTemp.length ; |
| | | int count = 0 ; |
| | | for(int i = 0 ; i < bTempLen; i++){ |
| | | bs[index++] = bTemp[i] ; |
| | | count ++ ; |
| | | if(count >= 4){ |
| | | break ; |
| | | } |
| | | } |
| | | for(; count < 4; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | Integer price = Double.valueOf(cvo.waterPrice * 100.0D).intValue() ; |
| | | bTemp = ByteUtil.int2BCD_LE(price) ; |
| | | bTempLen = bTemp.length ; |
| | | count = 0 ; |
| | | for(int i = 0 ; i < bTempLen; i++){ |
| | | bs[index++] = bTemp[i] ; |
| | | count ++ ; |
| | | if(count >= 2){ |
| | | break ; |
| | | } |
| | | } |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | bTemp = ByteUtil.int2BCD_LE(cvo.minutes) ; |
| | | bTempLen = bTemp.length ; |
| | | count = 0 ; |
| | | for(int i = 0 ; i < bTempLen; i++){ |
| | | bs[index++] = bTemp[i] ; |
| | | count ++ ; |
| | | if(count >= 2){ |
| | | break ; |
| | | } |
| | | } |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[5] ; |
| | | if(cvo.year >= 2024){ |
| | | cvo.year = cvo.year - 2000 ; |
| | | } |
| | | bs[0] = ByteUtil.int2BCD_LE(cvo.minute)[0] ; |
| | | bs[1] = ByteUtil.int2BCD_LE(cvo.hour)[0] ; |
| | | bs[2] = ByteUtil.int2BCD_LE(cvo.day)[0] ; |
| | | bs[3] = ByteUtil.int2BCD_LE(cvo.month)[0] ; |
| | | bs[4] = ByteUtil.int2BCD_LE(cvo.year)[0] ; |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | GlCreate.createLen(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCd99Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCdA1Vo; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeUp(ifAny={ |
| | | CodeV1_0_1.cd_A1 |
| | | }) |
| | | @SuppressWarnings("unused") |
| | | public class Cd_A1_Up implements CodeParse { |
| | | |
| | | private static final Logger log = LogManager.getLogger(Cd_A1_Up.class); |
| | | |
| | | /** |
| | | * 分析上行数据 |
| | | */ |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ; |
| | | int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | | para.upCode, |
| | | para.data) ; |
| | | } |
| | | log.info("分析上行数据<" + CodeV1_0_1.getCodeName(para.upCode) + " RTU地址=" + para.rtuAddr + ">:\n" + para.data.toString()); |
| | | |
| | | MidResultFromRtu midRs = new MidResultFromRtu() ; |
| | | midRs.protocolName = para.protocolName ;//协议名称 |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtu地址 |
| | | midRs.upCode = para.upCode ;//上行数据中的功能码 |
| | | midRs.upHex = para.upHex ;//上行数据十六进制形式 |
| | | midRs.upBuffer = para.upBuffer ;//上行数据字节数组 |
| | | midRs.data = para.data ;//解析后的数据 |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主动上报 |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | /** |
| | | * 执行分析 |
| | | * @param bs 字节数组 |
| | | * @param bsLen 字节长度(总包长,包括包头和包尾) |
| | | * @param dataCode 功能码 |
| | | * @param data 数据 |
| | | * @throws Exception 异常 |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ; |
| | | DataCdA1Vo cdData = new DataCdA1Vo() ; |
| | | dV1.subData = cdData ; |
| | | //虚拟卡号 |
| | | cdData.cardNo = GlParse.parseIcCardNo(bs, ProtocolConstantV206V1_0_0.dataIndex) ; |
| | | |
| | | if(bs[ProtocolConstantV206V1_0_0.dataIndex + 8] == (byte)0xAA){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.parse; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.CodeV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.CommonV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ParseParamsForDownV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.downVos.ComA0Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.downVos.ComA2Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeDown(ifAny={ |
| | | CodeV1_0_1.cd_A2 |
| | | }) |
| | | public class Cd_A2_Down implements CodeParse { |
| | | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { |
| | | ParseParamsForDownV1_0_1 para = (ParseParamsForDownV1_0_1) params ; |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | byte[] bs = this.doParse(midRs, para) ; |
| | | |
| | | midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;//rtu返回命令结果 发向目的地web URL |
| | | midRs.protocolName = para.protocolName ;//协议名称 |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtu地址 |
| | | midRs.commandId = para.commandId ;//命令ID,发起命令的客户端(web端)生成,以匹配命令结果 |
| | | midRs.downCode = para.commandCode ;//下行命令功能码; |
| | | midRs.downBuffer = bs ;//下行命令数据 |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//下行命令数据十六进制形式 |
| | | midRs.hasResponse = true ;//是否有应答 |
| | | midRs.maxSendTimes = null ;//命令最大发送次数(当收不到应答时,将重发),如果不设置,命令缓存器进行补充设置 |
| | | midRs.isCachForOffLine = false ;//RTU不在线,命令是否缓存,低功耗时为true |
| | | |
| | | if(isLowPower != null && isLowPower.booleanValue()){ |
| | | //低功耗时,尽快发送 |
| | | midRs.isQuickSend = true ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | |
| | | /** |
| | | * 构造下行数据 |
| | | * @param midRs 参数 |
| | | * @param para 参数 |
| | | * @return 字节数组 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public byte[] doParse(MidResultToRtu midRs, ParseParamsForDownV1_0_1 para) throws Exception { |
| | | CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ; |
| | | byte[] bytes ; |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ; |
| | | byte index = 0 ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = 0 ;//帧长度 |
| | | |
| | | index++ ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; |
| | | |
| | | index++ ; |
| | | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); |
| | | index += 5 ; |
| | | |
| | | ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; |
| | | |
| | | JSONObject obj = (JSONObject)para.param; |
| | | String json = obj.toJSONString(); |
| | | ComA2Vo cvo = JSON.parseObject(json, ComA2Vo.class) ; |
| | | if(cvo == null){ |
| | | throw new Exception("json转ComA0Vo为null") ; |
| | | } |
| | | if(cvo.icCardNo == null){ |
| | | throw new Exception("虚拟IC卡编号不能为空") ; |
| | | } |
| | | if(cvo.moneyRemain == null){ |
| | | throw new Exception("剩余金额不能为空") ; |
| | | } |
| | | if(cvo.waterPrice == null){ |
| | | throw new Exception("水价不能为空") ; |
| | | } |
| | | if(cvo.waterAmount == null){ |
| | | throw new Exception("预用水量不能为空") ; |
| | | } |
| | | if(cvo.waterAmount < 0 || cvo.waterAmount > 9999){ |
| | | throw new Exception("预用水量取值范围是0~9999m3") ; |
| | | } |
| | | if(cvo.year == null){ |
| | | throw new Exception("计划开阀时间---年不能为空") ; |
| | | } |
| | | if(cvo.year < 24 || cvo.year > 9999){ |
| | | throw new Exception("计划开阀时间---年不正确") ; |
| | | } |
| | | if(cvo.year > 24 && cvo.year < 2024){ |
| | | throw new Exception("计划开阀时间---年不正确") ; |
| | | } |
| | | if(cvo.month == null){ |
| | | throw new Exception("计划开阀时间---月不能为空") ; |
| | | } |
| | | if(cvo.month < 1 || cvo.month > 12){ |
| | | throw new Exception("计划开阀时间---月不正确") ; |
| | | } |
| | | if(cvo.day == null){ |
| | | throw new Exception("计划开阀时间---日不能为空") ; |
| | | } |
| | | if(cvo.day < 1 || cvo.day > 31){ |
| | | throw new Exception("计划开阀时间---日不正确") ; |
| | | } |
| | | if(cvo.hour == null){ |
| | | throw new Exception("计划开阀时间---时不能为空") ; |
| | | } |
| | | if(cvo.hour < 0 || cvo.hour > 23){ |
| | | throw new Exception("计划开阀时间---时不正确") ; |
| | | } |
| | | if(cvo.minute == null){ |
| | | throw new Exception("计划开阀时间---时不能为空") ; |
| | | } |
| | | if(cvo.minute < 0 || cvo.minute > 59){ |
| | | throw new Exception("计划开阀时间---分不正确") ; |
| | | } |
| | | |
| | | //String[] icCardNoGrp = CommonV1_0_1.dealIcCardNo(cvo.icCardNo) ; |
| | | //if(icCardNoGrp[0] != null){ |
| | | // midRs.param = icCardNoGrp[0] ; |
| | | //} |
| | | //ByteUtil.string2BCD_LE(bs, icCardNoGrp[1], index) ; |
| | | byte[] bs = new byte[16] ; |
| | | index = 0 ; |
| | | GlCreate.createIcCardNo(cvo.icCardNo, bs, 0); |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | |
| | | bs = new byte[4] ; |
| | | index = 0 ; |
| | | Integer money = Double.valueOf(cvo.moneyRemain * 100.0D).intValue() ; |
| | | byte[] bTemp = ByteUtil.int2BCD_LE(money) ; |
| | | int bTempLen = bTemp.length ; |
| | | int count = 0 ; |
| | | for(int i = 0 ; i < bTempLen; i++){ |
| | | bs[index++] = bTemp[i] ; |
| | | count ++ ; |
| | | if(count >= 4){ |
| | | break ; |
| | | } |
| | | } |
| | | for(; count < 4; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | Integer price = Double.valueOf(cvo.waterPrice * 100.0D).intValue() ; |
| | | bTemp = ByteUtil.int2BCD_LE(price) ; |
| | | bTempLen = bTemp.length ; |
| | | count = 0 ; |
| | | for(int i = 0 ; i < bTempLen; i++){ |
| | | bs[index++] = bTemp[i] ; |
| | | count ++ ; |
| | | if(count >= 2){ |
| | | break ; |
| | | } |
| | | } |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | |
| | | bs = new byte[2] ; |
| | | index = 0 ; |
| | | bTemp = ByteUtil.int2BCD_LE(cvo.waterAmount) ; |
| | | bTempLen = bTemp.length ; |
| | | count = 0 ; |
| | | for(int i = 0 ; i < bTempLen; i++){ |
| | | bs[index++] = bTemp[i] ; |
| | | count ++ ; |
| | | if(count >= 2){ |
| | | break ; |
| | | } |
| | | } |
| | | for(; count < 2; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | |
| | | bs = new byte[5] ; |
| | | if(cvo.year >= 2024){ |
| | | cvo.year = cvo.year - 2000 ; |
| | | } |
| | | bs[0] = ByteUtil.int2BCD_LE(cvo.minute)[0] ; |
| | | bs[1] = ByteUtil.int2BCD_LE(cvo.hour)[0] ; |
| | | bs[2] = ByteUtil.int2BCD_LE(cvo.day)[0] ; |
| | | bs[3] = ByteUtil.int2BCD_LE(cvo.month)[0] ; |
| | | bs[4] = ByteUtil.int2BCD_LE(cvo.year)[0] ; |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | GlCreate.createLen(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCdA0Vo; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCdA2Vo; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeUp(ifAny={ |
| | | CodeV1_0_1.cd_A2 |
| | | }) |
| | | @SuppressWarnings("unused") |
| | | public class Cd_A2_Up implements CodeParse { |
| | | |
| | | private static final Logger log = LogManager.getLogger(Cd_A2_Up.class); |
| | | |
| | | /** |
| | | * 分析上行数据 |
| | | */ |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ; |
| | | int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | | para.upCode, |
| | | para.data) ; |
| | | } |
| | | log.info("分析上行数据<" + CodeV1_0_1.getCodeName(para.upCode) + " RTU地址=" + para.rtuAddr + ">:\n" + para.data.toString()); |
| | | |
| | | MidResultFromRtu midRs = new MidResultFromRtu() ; |
| | | midRs.protocolName = para.protocolName ;//协议名称 |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtu地址 |
| | | midRs.upCode = para.upCode ;//上行数据中的功能码 |
| | | midRs.upHex = para.upHex ;//上行数据十六进制形式 |
| | | midRs.upBuffer = para.upBuffer ;//上行数据字节数组 |
| | | midRs.data = para.data ;//解析后的数据 |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主动上报 |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | /** |
| | | * 执行分析 |
| | | * @param bs 字节数组 |
| | | * @param bsLen 字节长度(总包长,包括包头和包尾) |
| | | * @param dataCode 功能码 |
| | | * @param data 数据 |
| | | * @throws Exception 异常 |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ; |
| | | DataCdA2Vo cdData = new DataCdA2Vo() ; |
| | | dV1.subData = cdData ; |
| | | //虚拟卡号 |
| | | cdData.cardNo = GlParse.parseIcCardNo(bs, ProtocolConstantV206V1_0_0.dataIndex) ; |
| | | |
| | | if(bs[ProtocolConstantV206V1_0_0.dataIndex + 8] == (byte)0xAA){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
| | | } |
| | | } |
| | | } |
| | |
| | | @Data |
| | | public class DataCd84Vo { |
| | | |
| | | public Byte opType;//开关阀类型(1:刷卡开阀;2:刷卡关阀;3:中心站开阀;4:中心站关阀;5:欠费关阀;6:流量计故障关阀;7:紧急关闭;8:用户远程开阀;9:用户远程关阀;10:开关阀卡关阀;11:开关阀卡刷卡卡开阀;) |
| | | public Byte opType; |
| | | public Byte cardType ;//卡类型(0:无卡;1:用户卡;2:管理员卡;3:调试卡;4:开关阀卡;5:清空卡) |
| | | public String cardAddr ;//IC卡地址(8位字符) |
| | | public String cardNo ;//IC卡编号 |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.upVos; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/01/13 10:08 |
| | | * @LastEditTime 2024/01/13 10:08 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | public class DataCdA1Vo { |
| | | public String cardNo ;//虚拟卡号 |
| | | public boolean success; |
| | | |
| | | public String toString(){ |
| | | StringBuilder sb = new StringBuilder() ; |
| | | sb.append(" 定时关阀开阀应答:\n"); |
| | | sb.append(" 虚拟卡号:"); |
| | | sb.append(cardNo); |
| | | sb.append("\n"); |
| | | sb.append(" 结果:"); |
| | | sb.append(success?"执行":"失败"); |
| | | sb.append("\n"); |
| | | |
| | | return sb.toString() ; |
| | | } |
| | | |
| | | |
| | | public String comLog(){ |
| | | StringBuilder sb = new StringBuilder() ; |
| | | sb.append("定时关阀开阀命令回复:\n"); |
| | | sb.append(" 虚拟卡号:"); |
| | | sb.append(cardNo); |
| | | sb.append("\n"); |
| | | sb.append(" 结果:"); |
| | | sb.append(success?"执行":"失败"); |
| | | sb.append("\n"); |
| | | return sb.toString() ; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.upVos; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/01/13 10:08 |
| | | * @LastEditTime 2024/01/13 10:08 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | public class DataCdA2Vo { |
| | | public String cardNo ;//虚拟卡号 |
| | | public boolean success; |
| | | |
| | | public String toString(){ |
| | | StringBuilder sb = new StringBuilder() ; |
| | | sb.append(" 定量关阀开阀应答:\n"); |
| | | sb.append(" 虚拟卡号:"); |
| | | sb.append(cardNo); |
| | | sb.append("\n"); |
| | | sb.append(" 结果:"); |
| | | sb.append(success?"执行":"失败"); |
| | | sb.append("\n"); |
| | | |
| | | return sb.toString() ; |
| | | } |
| | | |
| | | |
| | | public String comLog(){ |
| | | StringBuilder sb = new StringBuilder() ; |
| | | sb.append("定量关阀开阀命令回复:\n"); |
| | | sb.append(" 虚拟卡号:"); |
| | | sb.append(cardNo); |
| | | sb.append("\n"); |
| | | sb.append(" 结果:"); |
| | | sb.append(success?"执行":"失败"); |
| | | sb.append("\n"); |
| | | return sb.toString() ; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 开阀类型 |
| | | */ |
| | | private Byte openType; |
| | | //private Byte openType; |
| | | private String openType; |
| | | |
| | | /** |
| | | * 开阀订单号 |
| | |
| | | /** |
| | | * 关阀类型 |
| | | */ |
| | | private Byte closeType; |
| | | //private Byte closeType; |
| | | private String closeType; |
| | | |
| | | /** |
| | | * 关阀报中本地用水量 |
| | |
| | | /** |
| | | * 电表累计电量(单位0.01度) |
| | | */ |
| | | private Double ele_total; |
| | | private Double eleTotal; |
| | | |
| | | /** |
| | | * 用户剩余金额(单位0.01元) |
| | |
| | | |
| | | pipIrr: |
| | | global: |
| | | dev: true #是否开发阶段,true或false |
| | | dev: false #是否开发阶段,true或false |
| | | dsName: ym #开发阶段,设置临时的数据库名称 |
| | | mw: |
| | | webPort: 8070 |
| | |
| | | oh.op_ic_card_no AS openIcNum, |
| | | oh.op_ic_card_addr AS openIcAddr, |
| | | oh.op_dt AS openTime, |
| | | oh.op_type AS openType, |
| | | CASE |
| | | WHEN oh.op_type = 1 THEN "刷卡开阀" |
| | | WHEN oh.op_type = 3 THEN "中心站开阀" |
| | | WHEN oh.op_type = 5 THEN "欠费关阀" |
| | | WHEN oh.op_type = 8 THEN "用户远程开阀" |
| | | WHEN oh.op_type = 11 THEN "开关阀卡开阀" |
| | | ELSE "未知" |
| | | END AS openType, |
| | | oh.op_order_no AS openOrderNo, |
| | | oh.op_total_amount AS openTotalAmount, |
| | | oh.op_remain_money AS openRemainMoney, |
| | |
| | | oh.cl_ic_card_no AS closeIcNum, |
| | | oh.cl_ic_card_addr AS closeIcAddr, |
| | | oh.cl_dt AS closeTime, |
| | | oh.cl_type AS closeType, |
| | | CASE |
| | | WHEN oh.cl_type = 2 THEN "刷卡关阀" |
| | | WHEN oh.cl_type = 4 THEN "中心站关阀" |
| | | WHEN oh.cl_type = 5 THEN "欠费关阀" |
| | | WHEN oh.cl_type = 6 THEN "流量计故障关阀" |
| | | WHEN oh.cl_type = 7 THEN "紧急关闭" |
| | | WHEN oh.cl_type = 9 THEN "用户远程关阀" |
| | | WHEN oh.cl_type = 10 THEN "开关阀卡关阀" |
| | | WHEN oh.cl_type = 12 THEN "黑名单命令关阀" |
| | | WHEN oh.cl_type = 13 THEN "用户远程定时关阀" |
| | | WHEN oh.cl_type = 14 THEN "用户远程定量关阀" |
| | | ELSE "未知" |
| | | END AS closeType, |
| | | oh.cl_this_amount AS closeThisAmount, |
| | | oh.cl_this_time AS thisTime, |
| | | oh.cl_this_money AS thisMoney, |
| | |
| | | oh.op_ic_card_no AS openIcNum, |
| | | oh.op_ic_card_addr AS openIcAddr, |
| | | oh.op_dt AS openTime, |
| | | oh.op_type AS openType, |
| | | CASE |
| | | WHEN oh.op_type = 1 THEN "刷卡开阀" |
| | | WHEN oh.op_type = 3 THEN "中心站开阀" |
| | | WHEN oh.op_type = 5 THEN "欠费关阀" |
| | | WHEN oh.op_type = 8 THEN "用户远程开阀" |
| | | WHEN oh.op_type = 11 THEN "开关阀卡开阀" |
| | | ELSE "未知" |
| | | END AS openType, |
| | | oh.op_order_no AS openOrderNo, |
| | | oh.op_total_amount AS openTotalAmount, |
| | | oh.op_remain_money AS openRemainMoney, |
| | |
| | | oh.cl_ic_card_no AS closeIcNum, |
| | | oh.cl_ic_card_addr AS closeIcAddr, |
| | | oh.cl_dt AS closeTime, |
| | | oh.cl_type AS closeType, |
| | | CASE |
| | | WHEN oh.cl_type = 2 THEN "刷卡关阀" |
| | | WHEN oh.cl_type = 4 THEN "中心站关阀" |
| | | WHEN oh.cl_type = 5 THEN "欠费关阀" |
| | | WHEN oh.cl_type = 6 THEN "流量计故障关阀" |
| | | WHEN oh.cl_type = 7 THEN "紧急关闭" |
| | | WHEN oh.cl_type = 9 THEN "用户远程关阀" |
| | | WHEN oh.cl_type = 10 THEN "开关阀卡关阀" |
| | | WHEN oh.cl_type = 12 THEN "黑名单命令关阀" |
| | | WHEN oh.cl_type = 13 THEN "用户远程定时关阀" |
| | | WHEN oh.cl_type = 14 THEN "用户远程定量关阀" |
| | | ELSE "未知" |
| | | END AS closeType, |
| | | oh.cl_this_amount AS closeThisAmount, |
| | | oh.cl_this_time AS thisTime, |
| | | oh.cl_this_money AS thisMoney, |
| | |
| | | wo.water_press AS waterPress, |
| | | wo.water_instant AS waterInstant, |
| | | wo.water_total AS waterTotal, |
| | | wo.ele_total AS ele_total, |
| | | wo.ele_total AS eleTotal, |
| | | wo.money_remain AS moneyRemain, |
| | | wo.water_remain AS waterRemain, |
| | | wo.this_ele AS thisEle, |
| | |
| | | wo.water_press AS waterPress, |
| | | wo.water_instant AS waterInstant, |
| | | wo.water_total AS waterTotal, |
| | | wo.ele_total AS ele_total, |
| | | wo.ele_total AS eleTotal, |
| | | wo.money_remain AS moneyRemain, |
| | | wo.water_remain AS waterRemain, |
| | | wo.this_ele AS thisEle, |
| | |
| | | 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.util.DateTime; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.pipIrrMwTestWeb.common.CodeLocal; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | 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() ; |
| | | try{ |
| | | 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("A1")){ |
| | | rt = this.cdA1() ; |
| | | }else if(com.equals("A2")){ |
| | | rt = this.cdA2() ; |
| | | }else if(com.equals("B0")){ |
| | | rt = this.cdB0() ; |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return rt ; |
| | |
| | | comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo; |
| | | comVo.moneyRemain = 234.56 ; |
| | | comVo.waterPrice = 1.2 ; |
| | | comVo.minutes = 5 ; |
| | | comVo.minutes = 3 ; |
| | | return this.sendCom2Mw(this.command(CodeV1_0_1.cd_99, comVo, null)) ; |
| | | } |
| | | |
| | |
| | | comVo.moneyRemain = 234.56 ; |
| | | comVo.waterPrice = 1.2 ; |
| | | comVo.waterAmount = 10 ; |
| | | return this.sendCom2Mw(this.command(CodeV1_0_1.cd_98, comVo, null)) ; |
| | | return this.sendCom2Mw(this.command(CodeV1_0_1.cd_A0, comVo, null)) ; |
| | | } |
| | | |
| | | |
| | | //定时关阀计划开阀 |
| | | private BaseResponse cdA1() throws Exception { |
| | | ComA1Vo comVo = new ComA1Vo() ; |
| | | comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo; |
| | | comVo.moneyRemain = 234.56 ; |
| | | comVo.waterPrice = 1.2 ; |
| | | comVo.minutes = 3 ; |
| | | String nextDtStr = DateTime.nextXMinute_yyyy_MM_dd_HH_mm_ss(DateTime.yyyy_MM_dd_HH_mm_ss(), 5) ;//将来5分钟 |
| | | int[] nextDt = DateTime.yyyy_MM_dd_HH_MM_SS_2_ymdhmsGroup(nextDtStr) ; |
| | | comVo.year = nextDt[0] ; |
| | | comVo.month = nextDt[1] ; |
| | | comVo.day = nextDt[2] ; |
| | | comVo.hour = nextDt[3] ; |
| | | comVo.minute = nextDt[4] ; |
| | | return this.sendCom2Mw(this.command(CodeV1_0_1.cd_A1, comVo, null)) ; |
| | | } |
| | | |
| | | //定量关阀计划开阀 |
| | | private BaseResponse cdA2() throws Exception { |
| | | ComA2Vo comVo = new ComA2Vo() ; |
| | | comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo; |
| | | comVo.moneyRemain = 234.56 ; |
| | | comVo.waterPrice = 1.2 ; |
| | | comVo.waterAmount = 10 ; |
| | | String nextDtStr = DateTime.nextXMinute_yyyy_MM_dd_HH_mm_ss(DateTime.yyyy_MM_dd_HH_mm_ss(), 5) ;//将来5分钟 |
| | | int[] nextDt = DateTime.yyyy_MM_dd_HH_MM_SS_2_ymdhmsGroup(nextDtStr) ; |
| | | comVo.year = nextDt[0] ; |
| | | comVo.month = nextDt[1] ; |
| | | comVo.day = nextDt[2] ; |
| | | comVo.hour = nextDt[3] ; |
| | | comVo.minute = nextDt[4] ; |
| | | return this.sendCom2Mw(this.command(CodeV1_0_1.cd_A2, comVo, null)) ; |
| | | } |
| | | |
| | | |
| | | private BaseResponse cdB0(){ |
| | | return this.sendCom2Mw(this.command(CodeV1_0_1.cd_B0, null, null)) ; |
| | | } |
| | |
| | | package com.dy.pipIrrRemote.common.dto; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | public static final long serialVersionUID = 202407231039001L; |
| | | |
| | | /** |
| | | * 阀控器地址 |
| | | * 虚拟卡ID |
| | | */ |
| | | @NotBlank(message = "阀控器地址不能为空") |
| | | private String rtuAddr; |
| | | |
| | | /** |
| | | * 虚拟卡编号 |
| | | */ |
| | | @NotBlank(message = "虚拟卡编号不能为空") |
| | | private String vcNum; |
| | | |
| | | /** |
| | | * 订单号 |
| | | */ |
| | | @NotBlank(message = "订单号不能为空") |
| | | private String orderNo; |
| | | private Long vcId; |
| | | |
| | | /** |
| | | * 用水时长,拥有定时关阀 |
| | |
| | | } |
| | | |
| | | Long intakeId = automaticClose.getIntakeId(); |
| | | String rtuAddr = automaticClose.getRtuAddr(); |
| | | String vcNum = automaticClose.getVcNum(); |
| | | String orderNo = automaticClose.getOrderNo(); |
| | | Long vcId = automaticClose.getVcId(); |
| | | Integer minutes = automaticClose.getMinutes(); |
| | | Long operator = automaticClose.getOperator(); |
| | | |
| | | Long vcId = Optional.ofNullable(seVirtualCardMapper.getVcIdByNum(vcNum)).orElse(0L); |
| | | Long comId = idLongGenerator.generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | } |
| | | |
| | | // 虚拟卡ID换虚拟卡对象 |
| | | VoVirtualCard vc = commandSv.getVcById(vcId); |
| | | if (vc == null) { |
| | | if(vc == null) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | String vcNum = vc.getVcNum().toString(); |
| | | Double moneyRemain = vc.getMoney(); |
| | | |
| | | // 获取水价 |
| | | Double waterPrice = commandSv.getPrice(); |
| | | |
| | | // 阀控器地址换取水口ID和通讯协议 |
| | | JSONObject job_rtu = getRtu(null, rtuAddr); |
| | | // 取水口ID换阀控器地址及通讯协议 |
| | | JSONObject job_rtu = getRtu(intakeId, null); |
| | | if(job_rtu == null) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.RTU_NOT_EXIST.getMessage()); |
| | | } |
| | | String rtuAddr = job_rtu.getString("rtuAddr"); |
| | | String protocol = job_rtu.getString("protocol"); |
| | | String orgTag = job_rtu.getString("orgTag"); |
| | | comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); |
| | | |
| | | // 生成订单号 |
| | | String orderNo = generateOrderNo(); |
| | | |
| | | String commandCode = null; |
| | | if(protocol.equals("p206V202404")) { |
| | |
| | | } |
| | | |
| | | Long intakeId = automaticClose.getIntakeId(); |
| | | String rtuAddr = automaticClose.getRtuAddr(); |
| | | String vcNum = automaticClose.getVcNum(); |
| | | String orderNo = automaticClose.getOrderNo(); |
| | | Long vcId = automaticClose.getVcId(); |
| | | Integer waterAmount = automaticClose.getWaterAmount(); |
| | | Long operator = automaticClose.getOperator(); |
| | | |
| | | Long vcId = Optional.ofNullable(seVirtualCardMapper.getVcIdByNum(vcNum)).orElse(0L); |
| | | Long comId = idLongGenerator.generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | } |
| | | |
| | | // 虚拟卡ID换虚拟卡对象 |
| | | VoVirtualCard vc = commandSv.getVcById(vcId); |
| | | if (vc == null) { |
| | | if(vc == null) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | String vcNum = vc.getVcNum().toString(); |
| | | Double moneyRemain = vc.getMoney(); |
| | | |
| | | // 获取水价 |
| | | Double waterPrice = commandSv.getPrice(); |
| | | |
| | | // 阀控器地址换取水口ID和通讯协议 |
| | | JSONObject job_rtu = getRtu(null, rtuAddr); |
| | | // 取水口ID换阀控器地址及通讯协议 |
| | | JSONObject job_rtu = getRtu(intakeId, null); |
| | | if(job_rtu == null) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.RTU_NOT_EXIST.getMessage()); |
| | | } |
| | | String rtuAddr = job_rtu.getString("rtuAddr"); |
| | | String protocol = job_rtu.getString("protocol"); |
| | | String orgTag = job_rtu.getString("orgTag"); |
| | | comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); |
| | | |
| | | // 生成订单号 |
| | | String orderNo = generateOrderNo(); |
| | | |
| | | String commandCode = null; |
| | | if(protocol.equals("p206V202404")) { |
| | | return BaseResponseUtils.buildSuccess(); |
| | |
| | | } |
| | | |
| | | Long intakeId = automaticClose.getIntakeId(); |
| | | String rtuAddr = automaticClose.getRtuAddr(); |
| | | String vcNum = automaticClose.getVcNum(); |
| | | String orderNo = automaticClose.getOrderNo(); |
| | | Long vcId = automaticClose.getVcId(); |
| | | Integer minutes = automaticClose.getMinutes(); |
| | | Long operator = automaticClose.getOperator(); |
| | | |
| | | Long vcId = Optional.ofNullable(seVirtualCardMapper.getVcIdByNum(vcNum)).orElse(0L); |
| | | Long comId = idLongGenerator.generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | } |
| | | |
| | | // 虚拟卡ID换虚拟卡对象 |
| | | VoVirtualCard vc = commandSv.getVcById(vcId); |
| | | if (vc == null) { |
| | | if(vc == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | String vcNum = vc.getVcNum().toString(); |
| | | Double moneyRemain = vc.getMoney(); |
| | | |
| | | // 获取水价 |
| | | Double waterPrice = commandSv.getPrice(); |
| | | |
| | | // 阀控器地址换取水口ID和通讯协议 |
| | | JSONObject job_rtu = getRtu(null, rtuAddr); |
| | | // 取水口ID换阀控器地址及通讯协议 |
| | | JSONObject job_rtu = getRtu(intakeId, null); |
| | | if(job_rtu == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage()); |
| | | } |
| | | String rtuAddr = job_rtu.getString("rtuAddr"); |
| | | String protocol = job_rtu.getString("protocol"); |
| | | String orgTag = job_rtu.getString("orgTag"); |
| | | comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); |
| | | |
| | | // 生成订单号 |
| | | String orderNo = generateOrderNo(); |
| | | |
| | | String commandCode = null; |
| | | if(protocol.equals("p206V202404")) { |
| | |
| | | } |
| | | |
| | | Long intakeId = automaticClose.getIntakeId(); |
| | | String rtuAddr = automaticClose.getRtuAddr(); |
| | | String vcNum = automaticClose.getVcNum(); |
| | | String orderNo = automaticClose.getOrderNo(); |
| | | Long vcId = automaticClose.getVcId(); |
| | | Integer waterAmount = automaticClose.getWaterAmount(); |
| | | Long operator = automaticClose.getOperator(); |
| | | |
| | | Long vcId = Optional.ofNullable(seVirtualCardMapper.getVcIdByNum(vcNum)).orElse(0L); |
| | | Long comId = idLongGenerator.generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | } |
| | | |
| | | // 虚拟卡ID换虚拟卡对象 |
| | | VoVirtualCard vc = commandSv.getVcById(vcId); |
| | | if (vc == null) { |
| | | if(vc == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | String vcNum = vc.getVcNum().toString(); |
| | | Double moneyRemain = vc.getMoney(); |
| | | |
| | | // 获取水价 |
| | | Double waterPrice = commandSv.getPrice(); |
| | | |
| | | // 阀控器地址换取水口ID和通讯协议 |
| | | JSONObject job_rtu = getRtu(null, rtuAddr); |
| | | // 取水口ID换阀控器地址及通讯协议 |
| | | JSONObject job_rtu = getRtu(intakeId, null); |
| | | if(job_rtu == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage()); |
| | | } |
| | | String rtuAddr = job_rtu.getString("rtuAddr"); |
| | | String protocol = job_rtu.getString("protocol"); |
| | | String orgTag = job_rtu.getString("orgTag"); |
| | | comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); |
| | | |
| | | // 生成订单号 |
| | | String orderNo = generateOrderNo(); |
| | | String commandCode = null; |
| | | if(protocol.equals("p206V202404")) { |
| | | return BaseResponseUtils.buildSuccess(); |
| | |
| | | package com.dy.pipIrrWechat.command.dto; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | public static final long serialVersionUID = 202407231056001L; |
| | | |
| | | /** |
| | | * 阀控器地址 |
| | | * 虚拟卡ID |
| | | */ |
| | | @NotBlank(message = "阀控器地址不能为空") |
| | | private String rtuAddr; |
| | | |
| | | /** |
| | | * 虚拟卡编号 |
| | | */ |
| | | @NotBlank(message = "虚拟卡编号不能为空") |
| | | private String vcNum; |
| | | |
| | | /** |
| | | * 订单号 |
| | | */ |
| | | @NotBlank(message = "订单号不能为空") |
| | | private String orderNo; |
| | | private Long vcId; |
| | | |
| | | /** |
| | | * 用水时长,拥有定时关阀 |