| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | |
| | | private final CommandSv commandSv; |
| | | private final SeVirtualCardMapper seVirtualCardMapper; |
| | | private final IDLongGenerator idLongGenerator; |
| | | private String rtuResultSendWebUrl = "http://127.0.0.1:8087/wx/comRes/receive"; |
| | | |
| | | @Value("${mw.rtuCallbackUrl_wx}") |
| | | private String rtuCallbackUrl_wx; |
| | | |
| | | /** |
| | | * 小程序远程开阀 |
| | |
| | | } |
| | | |
| | | Long intakeId = valve.getIntakeId(); |
| | | String intakeName = valve.getIntakeName(); |
| | | Long vcId = valve.getVcId(); |
| | | Boolean forceOpen = valve.getForceOpen(); |
| | | Long operator = valve.getOperator(); |
| | | Long comId = idLongGenerator.generate(); |
| | | |
| | | if(intakeId == null && intakeName == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage()); |
| | | } |
| | | |
| | | // intakeName换intakeId |
| | | if(intakeId == null) { |
| | | intakeId = commandSv.getIntakeIdByName(intakeName); |
| | | if(intakeId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | |
| | | if (vc == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); |
| | | } |
| | | if (vc.getInUse() == 1) { |
| | | |
| | | // 虚拟卡状态为使用中,且不是强制开阀时提示 |
| | | if (vc.getInUse() == 1 && !forceOpen) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage()); |
| | | } |
| | | |
| | |
| | | myParam.setProtocol(protocol); |
| | | myParam.setVcId(vcId); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuResultSendWebUrl); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | |
| | |
| | | myParam.setProtocol(protocol); |
| | | myParam.setVcId(vcId); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuResultSendWebUrl); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | } else { |
| | |
| | | myParam.setProtocol(protocol); |
| | | myParam.setVcId(vcId); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuResultSendWebUrl); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | } else if (protocol.equals("p206V1_0_1")) { |
| | |
| | | myParam.setProtocol(protocol); |
| | | myParam.setVcId(vcId); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuResultSendWebUrl); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | } else { |
| | |
| | | myParam.setRtuAddr(rtuAddr); |
| | | myParam.setProtocol(protocol); |
| | | myParam.setParam(param); |
| | | myParam.setRtuResultSendWebUrl(rtuResultSendWebUrl); |
| | | myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx); |
| | | myParam.setOperator(operator); |
| | | return dealWithCommandResult(myParam); |
| | | } else if(protocol.equals("p206V1_0_1")) { |
| | | // 获取功能码 |
| | | commandCode = CodeV1_0_1.cd_10; |
| | | |
| | | // 创建视图 |
| | | Com97Vo param = new Com97Vo() ; |
| | | return BaseResponseUtils.buildSuccess(""); |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.THE_DEVICE_DOES_NOT_HAVE_THIS_FUNCTION.getMessage()); |
| | | } else { |
| | | return BaseResponseUtils.buildFail("系统暂不支持该协议"); |
| | | } |