Administrator
2024-07-02 854e951894deaa54b26590f8575474ed7a5f5b88
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java
@@ -9,6 +9,7 @@
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd15Vo;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd92_A2Vo;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd93_A3Vo;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd9CVo;
import com.dy.common.util.IDLongGenerator;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
@@ -20,6 +21,7 @@
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
import com.dy.pipIrrRemote.common.CommandSv;
import com.dy.pipIrrRemote.common.dto.Card;
import com.dy.pipIrrRemote.common.dto.DtoBase;
import com.dy.pipIrrRemote.common.dto.Recharge;
import com.dy.pipIrrRemote.common.dto.ValveOpen;
@@ -393,4 +395,70 @@
            return BaseResponseUtils.buildFail("系统暂不支持该协议");
        }
    }
    /**
     * 强制关阀
     * @param card
     * @param bindingResult
     * @return
     */
    @PostMapping(path = "forced_close", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> forcedClose(@RequestBody @Valid Card card, BindingResult bindingResult) {
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        Long intakeId = card.getIntakeId();
        String cardAddr = card.getCardAddr();
        Long operator = card.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")) {
            // 获取功能码
            commandCode = CodeV202404.cd_9C;
            // 创建视图
            ComCd9CVo param = new ComCd9CVo();
            param.controllerType = controllerType;
            param.projectNo = projectNo;
            param.icCardAddr = cardAddr;
            /**
             * 构造命令、发送命令并处理请求结果及执行结果
             * 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("系统暂不支持该协议");
        }
    }
}