|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONObject; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Command; | 
|---|
|  |  |  | import com.dy.common.util.Callback; | 
|---|
|  |  |  | import com.dy.common.util.IDLongGenerator; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoPr.PrController; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; | 
|---|
|  |  |  | import com.dy.pipIrrRemote.common.dto.DtoBase; | 
|---|
|  |  |  | import com.dy.pipIrrRemote.monitor.p202404V201.Cd50Param; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Qualifier; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.core.env.Environment; | 
|---|
|  |  |  | import org.springframework.validation.BindingResult; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${mw.rtuCallbackUrl_rm}") | 
|---|
|  |  |  | protected String rtuResultSendWebUrl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${project.projectNo}") | 
|---|
|  |  |  | protected Integer projectNo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${project.controllerType}") | 
|---|
|  |  |  | protected String controllerType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //控制器对象 | 
|---|
|  |  |  | protected PrController ctrlPo ; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param param 命令参数 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public BaseResponse<Object> pre3(ComSv comSv, Long intakeId, Long operator, String comCode, CdParam param) { | 
|---|
|  |  |  | public BaseResponse<Object> pre3(ComSv comSv, Long intakeId, Long operator, String comCode, CdParameter param) { | 
|---|
|  |  |  | comId = new IDLongGenerator().generate(); | 
|---|
|  |  |  | //生成并保存命令日志 | 
|---|
|  |  |  | RmCommandHistory po = comSv.saveComHistoryPo(comId, | 
|---|
|  |  |  | 
|---|
|  |  |  | * 发送命令后 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public BaseResponse<Object> after(String comCode) { | 
|---|
|  |  |  | public BaseResponse<Object> after(String comCode, Callback callback) { | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | //等待通信中间件通知控制器执行命令上行数据(命令结果) | 
|---|
|  |  |  | JSONObject resultData = feature.get(waitMwRtnResultTimeout, TimeUnit.SECONDS); | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(this.createRtnMsg(comCode, resultData)); | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(this.dealComResult(comCode, resultData, callback)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return BaseResponseUtils.buildFail("等待通信中间件通知命令结果超时"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 生成命令返回信息 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | protected abstract String createRtnMsg(String code, JSONObject resultData); | 
|---|
|  |  |  | protected abstract String dealComResult(String code, JSONObject resultData, Callback callback); | 
|---|
|  |  |  | } | 
|---|