| | |
| | | if(vc == null) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | if(vc.getInUse() == 1) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage()); |
| | | } |
| | | |
| | | //嘉峪关项目虚拟卡不扣费,不做使用中判断 |
| | | //if(vc.getInUse() == 1) { |
| | | // return BaseResponseUtils.buildErrorMsg(RemoteResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage()); |
| | | //} |
| | | |
| | | // 获取水价 |
| | | Double waterPrice = commandSv.getPrice(); |
| | |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "usability", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> usability(@RequestBody @Valid Usability usability, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Long intakeId = usability.getIntakeId(); |
| | | Boolean valid = usability.getValid(); |
| | | Long operator = usability.getOperator(); |
| | | Long comId = idLongGenerator.generate(); |
| | | |
| | | // 获取系统参数 |
| | | if(!setuped) { |
| | | setUp(); |
| | | } |
| | | |
| | | // 取水口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 commandCode = null; |
| | | if(protocol.equals("p206V202404")) { |
| | | if(valid) { |
| | | // 获取功能码 |
| | | commandCode = CodeV202404.cd_30; |
| | | |
| | | // 创建视图 |
| | | ComCd31Vo param = new ComCd31Vo(); |
| | | param.controllerType = controllerType; |
| | | param.projectNo = projectNo; |
| | | param.valid = true; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setCommandCode(commandCode); |
| | | myParam.setCommandName(CodeV202404.getCodeName(commandCode)); |
| | | myParam.setIntakeId(intakeId); |
| | | myParam.setRtuAddr(rtuAddr); |
| | | myParam.setProtocol(protocol); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_rm); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | }else { |
| | | // 获取功能码 |
| | | commandCode = CodeV202404.cd_31; |
| | | |
| | | // 创建视图 |
| | | ComCd31Vo param = new ComCd31Vo(); |
| | | param.controllerType = controllerType; |
| | | param.projectNo = projectNo; |
| | | param.valid = false; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setCommandCode(commandCode); |
| | | myParam.setCommandName(CodeV202404.getCodeName(commandCode)); |
| | | myParam.setIntakeId(intakeId); |
| | | myParam.setRtuAddr(rtuAddr); |
| | | myParam.setProtocol(protocol); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_rm); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | } |
| | | } else if(protocol.equals("p206V1_0_1")) { |
| | | return BaseResponseUtils.buildErrorMsg(RemoteResultCode.THE_DEVICE_DOES_NOT_HAVE_THIS_FUNCTION.getMessage()); |
| | | } else { |
| | | return BaseResponseUtils.buildErrorMsg("系统暂不支持该协议"); |
| | | } |
| | | } |
| | | //@PostMapping(path = "usability", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | //@SsoAop() |
| | | //public BaseResponse<Boolean> usability(@RequestBody @Valid Usability usability, BindingResult bindingResult) { |
| | | // if(bindingResult != null && bindingResult.hasErrors()){ |
| | | // return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | // } |
| | | // |
| | | // Long intakeId = usability.getIntakeId(); |
| | | // Boolean valid = usability.getValid(); |
| | | // Long operator = usability.getOperator(); |
| | | // Long comId = idLongGenerator.generate(); |
| | | // |
| | | // // 获取系统参数 |
| | | // if(!setuped) { |
| | | // setUp(); |
| | | // } |
| | | // |
| | | // // 取水口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 commandCode = null; |
| | | // if(protocol.equals("p206V202404")) { |
| | | // if(valid) { |
| | | // // 获取功能码 |
| | | // commandCode = CodeV202404.cd_30; |
| | | // |
| | | // // 创建视图 |
| | | // ComCd31Vo param = new ComCd31Vo(); |
| | | // param.controllerType = controllerType; |
| | | // param.projectNo = projectNo; |
| | | // param.valid = true; |
| | | // |
| | | // /** |
| | | // * 构造命令、发送命令并处理请求结果及执行结果 |
| | | // * 1 准备参数 |
| | | // * 2 调用公共方法 |
| | | // */ |
| | | // Param myParam = new Param(); |
| | | // myParam.setComId(comId); |
| | | // myParam.setCommandCode(commandCode); |
| | | // myParam.setCommandName(CodeV202404.getCodeName(commandCode)); |
| | | // myParam.setIntakeId(intakeId); |
| | | // myParam.setRtuAddr(rtuAddr); |
| | | // myParam.setProtocol(protocol); |
| | | // myParam.setParam(param); |
| | | // myParam.setRtuResultSendWebUrl(rtuCallbackUrl_rm); |
| | | // myParam.setOperator(operator); |
| | | // return dealWithCommandResult(myParam); |
| | | // }else { |
| | | // // 获取功能码 |
| | | // commandCode = CodeV202404.cd_31; |
| | | // |
| | | // // 创建视图 |
| | | // ComCd31Vo param = new ComCd31Vo(); |
| | | // param.controllerType = controllerType; |
| | | // param.projectNo = projectNo; |
| | | // param.valid = false; |
| | | // |
| | | // /** |
| | | // * 构造命令、发送命令并处理请求结果及执行结果 |
| | | // * 1 准备参数 |
| | | // * 2 调用公共方法 |
| | | // */ |
| | | // Param myParam = new Param(); |
| | | // myParam.setComId(comId); |
| | | // myParam.setCommandCode(commandCode); |
| | | // myParam.setCommandName(CodeV202404.getCodeName(commandCode)); |
| | | // myParam.setIntakeId(intakeId); |
| | | // myParam.setRtuAddr(rtuAddr); |
| | | // myParam.setProtocol(protocol); |
| | | // myParam.setParam(param); |
| | | // myParam.setRtuResultSendWebUrl(rtuCallbackUrl_rm); |
| | | // myParam.setOperator(operator); |
| | | // return dealWithCommandResult(myParam); |
| | | // } |
| | | // } else if(protocol.equals("p206V1_0_1")) { |
| | | // return BaseResponseUtils.buildErrorMsg(RemoteResultCode.THE_DEVICE_DOES_NOT_HAVE_THIS_FUNCTION.getMessage()); |
| | | // } else { |
| | | // return BaseResponseUtils.buildErrorMsg("系统暂不支持该协议"); |
| | | // } |
| | | //} |
| | | } |