|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrRemote.monitor.p202404V201.cd65; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONArray; | 
|---|
|  |  |  | 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.DataCd65Vo; | 
|---|
|  |  |  | import com.dy.common.util.Callback; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
|---|
|  |  |  | import com.dy.pipIrrRemote.common.dto.DtoBase; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Tag(name = "远程命令", description = "查询设备终端用户用水记录") | 
|---|
|  |  |  | @RestController("cd65Ctrl") | 
|---|
|  |  |  | @RestController("p202404V201Cd65Ctrl") | 
|---|
|  |  |  | @RequestMapping(path = "p202404V201/cd65") | 
|---|
|  |  |  | @RequiredArgsConstructor | 
|---|
|  |  |  | @Scope("prototype") //因为有对象类属性,所以采用原型模式,每次请求新建一个实例对象 | 
|---|
|  |  |  | 
|---|
|  |  |  | res = super.doSend(sv, com); | 
|---|
|  |  |  | if (res == null) { | 
|---|
|  |  |  | //发送命令后 | 
|---|
|  |  |  | res = super.after(ComCode); | 
|---|
|  |  |  | res = super.after(ComCode, null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | res = BaseResponseUtils.buildFail("服务端构造并向通信中间件发送请求时异常" + (e.getMessage() == null ? "" : e.getMessage())); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | protected String createRtnMsg(String code, JSONObject resultData){ | 
|---|
|  |  |  | protected String dealComResult(String code, JSONObject resultData, Callback callback){ | 
|---|
|  |  |  | String msg; | 
|---|
|  |  |  | if(resultData != null){ | 
|---|
|  |  |  | JSONObject codeData = resultData.getJSONObject("data") ; | 
|---|
|  |  |  | JSONArray codeDataArray = null ; | 
|---|
|  |  |  | if(codeData == null){ | 
|---|
|  |  |  | codeDataArray = resultData.getJSONArray("data") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(codeData == null && codeDataArray == null){ | 
|---|
|  |  |  | msg = RtuSuccessMsg ; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | String json = codeData.toJSONString(); | 
|---|
|  |  |  | String json = null ; | 
|---|
|  |  |  | if(codeData != null){ | 
|---|
|  |  |  | json = codeData.toJSONString() ; | 
|---|
|  |  |  | }else if(codeDataArray != null){ | 
|---|
|  |  |  | json = codeDataArray.toJSONString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<DataCd65Vo> list = JSON.parseArray(json, DataCd65Vo.class) ; | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | msg = "" ; | 
|---|
|  |  |  | msg = "\n" ; | 
|---|
|  |  |  | for(DataCd65Vo cvo : list){ | 
|---|
|  |  |  | msg += cvo.toStr(false) ; | 
|---|
|  |  |  | msg += "\n" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | msg = RtuSuccessMsg ; | 
|---|