| | |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | String rtuAddr = valve.getRtuAddr(); |
| | | String vcNum = valve.getVcNum(); |
| | | Long vcId = Optional.ofNullable(seVirtualCardMapper.getVcIdByNum(vcNum)).orElse(0L); |
| | | String orderNo = valve.getOrderNo(); |
| | | Long operator = valve.getOperator(); |
| | | Long comId = new IDLongGenerator().generate(); |
| | | |
| | | // 阀控器地址换取水口ID和通讯协议 |
| | | JSONObject job_rtu = getRtu(null, rtuAddr); |
| | | if (job_rtu == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage()); |
| | | Map map_result = commandSv.closeWx(valve, null, null); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | Long intakeId = job_rtu.getLong("intakeId"); |
| | | String protocol = job_rtu.getString("protocol"); |
| | | //String orgTag = job_rtu.getString("orgTag"); |
| | | //if(orgTag == null) { |
| | | // return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_SET_DATA_SOURCE.getMessage()); |
| | | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; |
| | | |
| | | //String rtuAddr = valve.getRtuAddr(); |
| | | //String vcNum = valve.getVcNum(); |
| | | //Long vcId = Optional.ofNullable(seVirtualCardMapper.getVcIdByNum(vcNum)).orElse(0L); |
| | | //String orderNo = valve.getOrderNo(); |
| | | //Long operator = valve.getOperator(); |
| | | //Long comId = new IDLongGenerator().generate(); |
| | | // |
| | | //// 阀控器地址换取水口ID和通讯协议 |
| | | //JSONObject job_rtu = getRtu(null, rtuAddr); |
| | | //if (job_rtu == null) { |
| | | // return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage()); |
| | | //} |
| | | //comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); |
| | | comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw); |
| | | |
| | | String commandCode = null; |
| | | if (protocol.equals(ProtocolConstantV206V202404.protocolName)) { |
| | | // 获取功能码 |
| | | commandCode = CodeV202404.cd_A3; |
| | | |
| | | // 创建视图 |
| | | ComCd93_A3Vo param = new ComCd93_A3Vo(); |
| | | param.controllerType = controllerType; |
| | | param.projectNo = projectNo; |
| | | param.icCardNo = vcNum; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | | myParam.setCommandCode(commandCode); |
| | | myParam.setCommandName(CodeV202404.getCodeName(commandCode)); |
| | | myParam.setIntakeId(intakeId); |
| | | myParam.setRtuAddr(rtuAddr); |
| | | myParam.setProtocol(protocol); |
| | | myParam.setVcId(vcId); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | } else if (protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) { |
| | | // 获取功能码 |
| | | commandCode = CodeV1.cd_98; |
| | | |
| | | // 创建视图 |
| | | Com98Vo param = new Com98Vo(); |
| | | param.icCardNo = vcNum; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | | myParam.setCommandCode(commandCode); |
| | | myParam.setCommandName(CodeV1.getCodeName(commandCode)); |
| | | myParam.setIntakeId(intakeId); |
| | | myParam.setRtuAddr(rtuAddr); |
| | | myParam.setProtocol(protocol); |
| | | myParam.setVcId(vcId); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | } else { |
| | | return BaseResponseUtils.buildErrorMsg("系统暂不支持该协议"); |
| | | } |
| | | //Long intakeId = job_rtu.getLong("intakeId"); |
| | | //String protocol = job_rtu.getString("protocol"); |
| | | ////String orgTag = job_rtu.getString("orgTag"); |
| | | ////if(orgTag == null) { |
| | | //// return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_SET_DATA_SOURCE.getMessage()); |
| | | ////} |
| | | ////comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); |
| | | //comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw); |
| | | // |
| | | //String commandCode = null; |
| | | //if (protocol.equals(ProtocolConstantV206V202404.protocolName)) { |
| | | // // 获取功能码 |
| | | // commandCode = CodeV202404.cd_A3; |
| | | // |
| | | // // 创建视图 |
| | | // ComCd93_A3Vo param = new ComCd93_A3Vo(); |
| | | // param.controllerType = controllerType; |
| | | // param.projectNo = projectNo; |
| | | // param.icCardNo = vcNum; |
| | | // param.orderNo = orderNo; |
| | | // |
| | | // /** |
| | | // * 构造命令、发送命令并处理请求结果及执行结果 |
| | | // * 1 准备参数 |
| | | // * 2 调用公共方法 |
| | | // */ |
| | | // Param myParam = new Param(); |
| | | // myParam.setComId(comId); |
| | | // myParam.setComType((byte)2); |
| | | // myParam.setCommandCode(commandCode); |
| | | // myParam.setCommandName(CodeV202404.getCodeName(commandCode)); |
| | | // myParam.setIntakeId(intakeId); |
| | | // myParam.setRtuAddr(rtuAddr); |
| | | // myParam.setProtocol(protocol); |
| | | // myParam.setVcId(vcId); |
| | | // myParam.setParam(param); |
| | | // myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | // myParam.setOperator(operator); |
| | | // return dealWithCommandResult(myParam); |
| | | //} else if (protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) { |
| | | // // 获取功能码 |
| | | // commandCode = CodeV1.cd_98; |
| | | // |
| | | // // 创建视图 |
| | | // Com98Vo param = new Com98Vo(); |
| | | // param.icCardNo = vcNum; |
| | | // param.orderNo = orderNo; |
| | | // |
| | | // /** |
| | | // * 构造命令、发送命令并处理请求结果及执行结果 |
| | | // * 1 准备参数 |
| | | // * 2 调用公共方法 |
| | | // */ |
| | | // Param myParam = new Param(); |
| | | // myParam.setComId(comId); |
| | | // myParam.setComType((byte)2); |
| | | // myParam.setCommandCode(commandCode); |
| | | // myParam.setCommandName(CodeV1.getCodeName(commandCode)); |
| | | // myParam.setIntakeId(intakeId); |
| | | // myParam.setRtuAddr(rtuAddr); |
| | | // myParam.setProtocol(protocol); |
| | | // myParam.setVcId(vcId); |
| | | // myParam.setParam(param); |
| | | // myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | // myParam.setOperator(operator); |
| | | // return dealWithCommandResult(myParam); |
| | | //} else { |
| | | // return BaseResponseUtils.buildErrorMsg("系统暂不支持该协议"); |
| | | //} |
| | | } |
| | | |
| | | /** |
| | |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | //return dealWithCommandResult(myParam); |
| | | |
| | | BaseResponse<Boolean> result = dealWithCommandResult(myParam); |
| | | // 如果命令执行失败,则再次执行命令 |
| | | if(!result.isSuccess()) { |
| | | myParam.setComId(new IDLongGenerator().generate()); |
| | | result = dealWithCommandResult(myParam); |
| | | } |
| | | return result; |
| | | } else { |
| | | return BaseResponseUtils.buildErrorMsg("系统暂不支持该协议"); |
| | | } |
| | |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | //return dealWithCommandResult(myParam); |
| | | |
| | | BaseResponse<Boolean> result = dealWithCommandResult(myParam); |
| | | // 如果命令执行失败,则再次执行命令 |
| | | if(!result.isSuccess()) { |
| | | myParam.setComId(new IDLongGenerator().generate()); |
| | | result = dealWithCommandResult(myParam); |
| | | } |
| | | return result; |
| | | } else { |
| | | return BaseResponseUtils.buildErrorMsg("系统暂不支持该协议"); |
| | | } |
| | |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | //return dealWithCommandResult(myParam); |
| | | |
| | | BaseResponse<Boolean> result = dealWithCommandResult(myParam); |
| | | // 如果命令执行失败,则再次执行命令 |
| | | if(!result.isSuccess()) { |
| | | myParam.setComId(new IDLongGenerator().generate()); |
| | | result = dealWithCommandResult(myParam); |
| | | } |
| | | return result; |
| | | } else { |
| | | return BaseResponseUtils.buildErrorMsg("系统暂不支持该协议"); |
| | | } |