|  |  | 
 |  |  | package com.dy.pipIrrRemote.rtu; | 
 |  |  |  | 
 |  |  | import com.dy.common.aop.SsoAop; | 
 |  |  | import com.dy.common.multiDataSource.DataSourceContext; | 
 |  |  | import com.dy.common.webUtil.BaseResponse; | 
 |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
 |  |  | import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw; | 
 |  |  | import jakarta.servlet.ServletOutputStream; | 
 |  |  | import jakarta.servlet.http.HttpServletRequest; | 
 |  |  | import jakarta.servlet.http.HttpServletResponse; | 
 |  |  | 
 |  |  | @Slf4j | 
 |  |  | @RestController | 
 |  |  | @RequestMapping(path="rtuLog") | 
 |  |  | public class RtuLogCtrl { | 
 |  |  |  | 
 |  |  |     private static final String pro_mw = "mw"; | 
 |  |  |     private static final String key_mw_file = "rtuLogFileUrl"; | 
 |  |  |     private static final String key_mw_text = "rtuLogTextUrl"; | 
 |  |  | public class RtuLogCtrl extends Web2RtuMw { | 
 |  |  |  | 
 |  |  |     private Environment env ; | 
 |  |  |     private RestTemplate restTemplate; | 
 |  |  | 
 |  |  |     @GetMapping(path = "file") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<List<String>> rtuLogFile(String rtuAddr, HttpServletRequest req, HttpServletResponse rep){ | 
 |  |  |         String mwUrlRtuLogFile = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_file); | 
 |  |  |         String rqUrl = this.get2MwRequestUrl(this.env, ContextRtuLogFile) ; | 
 |  |  |         ServletOutputStream out = null ; | 
 |  |  |         try{ | 
 |  |  |             byte[] bs = this.requestMw4File(rtuAddr, mwUrlRtuLogFile) ; | 
 |  |  |             byte[] bs = this.requestMw4File(rtuAddr, rqUrl) ; | 
 |  |  |             if(bs != null && bs.length > 0){ | 
 |  |  |                 String fileReName = rtuAddr + ".log" ; | 
 |  |  |                 //URLEncoder.encode可以防止中文乱码 | 
 |  |  | 
 |  |  |     @GetMapping(path="text") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<List<String>> rtuLogText(String rtuAddr){ | 
 |  |  |         String mwUrlRtuLogText = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_text); | 
 |  |  |         return this.requestMw4Text(rtuAddr, mwUrlRtuLogText) ; | 
 |  |  |         String rqUrl = this.get2MwRequestUrl(this.env, ContextRtuLogText) ; | 
 |  |  |         //String mwUrlRtuLogText = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_text); | 
 |  |  |         BaseResponse<List<String>> text = this.requestMw4Text(rtuAddr, rqUrl); | 
 |  |  |         if (text != null){ | 
 |  |  |             if (text.getContent().get(0).contains("控制器")){ | 
 |  |  |                 return BaseResponseUtils.buildErrorMsg(""+text.getContent().get(0)+"") ; | 
 |  |  |             } | 
 |  |  |             return text ; | 
 |  |  |         }else { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("获取日志文件为null") ; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |         return (response==null?null:response.getBody()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |