copy from pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/Cd50Ctrl.java
copy to pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd68/CdCtrl.java
File was copied from pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/Cd50Ctrl.java |
| | |
| | | package com.dy.pipIrrRemote.monitor.p202404V201; |
| | | package com.dy.pipIrrRemote.monitor.p202404V201.cd68; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.mw.protocol.p206V202404.CodeV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd68Vo; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrRemote.common.dto.DtoBase; |
| | |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/9 14:41 |
| | | * @Date: 2025/5/12 13:53 |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Tag(name = "远程透传命令", description = "远程透传命令") |
| | | @RestController |
| | | @RequestMapping(path = "p202404V201") |
| | | @Tag(name = "远程命令", description = "查询机井年最大开采量和水位下限") |
| | | @RestController("cd68Ctrl") |
| | | @RequestMapping(path = "p202404V201/cd68") |
| | | @RequiredArgsConstructor |
| | | @Scope("prototype") //因为有对象类属性,所以采用原型模式,每次请求新建一个实例对象 |
| | | public class Cd50Ctrl extends ComCtrl { |
| | | public class CdCtrl extends ComCtrl { |
| | | |
| | | private static final String RtuSuccessMsg = "控制器接收并执行命令成功"; |
| | | private static final String RtuSuccessMsg = "控制器接收并执行命令成功,无返回数据"; |
| | | |
| | | private static final String ComCode = "50" ; |
| | | private static final String ComCode = "68" ; |
| | | |
| | | @Autowired |
| | | private Cd50Sv sv ; |
| | | private CdSv sv ; |
| | | /** |
| | | * 向设备(控制器)发送透传命令 |
| | | * 向设备(控制器)发送命令 |
| | | * @param dto 前端发来的值对象 |
| | | * @param bindingResult 对dto验证的结果 |
| | | * @return 返回前端 |
| | | */ |
| | | @PostMapping(path = "cd50", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @SsoAop() |
| | | public BaseResponse<Object> send(@RequestBody @Valid Cd50Dto dto, BindingResult bindingResult) { |
| | | public BaseResponse<Object> send(@RequestBody @Valid CdDto dto, BindingResult bindingResult) { |
| | | BaseResponse<Object> res ; |
| | | //发送命令前-1:验证 |
| | | res = super.pre1(sv, ComCode, dto, bindingResult); |
| | |
| | | res = super.pre2(sv, ComCode, dto, bindingResult); |
| | | if (res == null) { |
| | | //发送命令前-3:保存命令日志 |
| | | Cd50Param comParam = Cd50Param.builder().commandCode(ComCode).build(); |
| | | CdParam comParam = CdParam.builder().commandCode(ComCode).projectNo(projectNo).controllerType(controllerType).build(); |
| | | res = super.pre3(sv, dto.getIntakeId(), dto.getOperator(), ComCode, comParam); |
| | | if (res == null) { |
| | | //发送命令前-4:准备Feature |
| | | super.pre4(); |
| | | try { |
| | | //创建外部命令(发给控制器) |
| | | Command com = sv.createOuterCommand("" + comId, ComCode); |
| | | com.rtuAddr = ctrlPo.getRtuAddr(); |
| | | Command com = sv.createOuterCommand(ctrlPo.getRtuAddr(), "" + comId, ComCode); |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | com.param = comParam ; |
| | | //发送命令 |
| | | res = super.doSend(sv, com); |
| | | if (res == null) { |
| | |
| | | if(resultData != null){ |
| | | JSONObject codeData = resultData.getJSONObject("data") ; |
| | | if(codeData == null){ |
| | | return RtuSuccessMsg ; |
| | | msg = RtuSuccessMsg ; |
| | | }else { |
| | | Integer minute = codeData.getInteger("minute"); |
| | | return "查询成功,自报周期:" + minute + "分钟"; |
| | | String json = codeData.toJSONString(); |
| | | DataCd68Vo cvo = JSON.parseObject(json, DataCd68Vo.class) ; |
| | | if(cvo != null){ |
| | | msg = cvo.toStr(false) ; |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | } |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |