| | |
| | | |
| | | 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; |
| | |
| | | * 发送命令后 |
| | | * @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); |
| | | } |