田源
2023-12-01 504dcb79430e0010e6b443e1ae2ef7f35b86e1a7
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/log/service/impl/LogLocalServiceImpl.java
@@ -82,7 +82,7 @@
    * @param logParentPath
    * @return
    */
   //@Override
   @Override
   public List<LocalLogVO> getSystemLogList(String logParentPath) {
      List<LocalLogVO> localLogsVO = new ArrayList<>();
      // 不为空说明是加载当前这个服务路径下的日志文件
@@ -90,44 +90,48 @@
         File file = new File(logParentPath);
         if (file.isDirectory()) {
            File[] files = file.listFiles();
            Arrays.stream(files).forEach(item->{
               // 组建日志文件对象
               LocalLogVO localLog = new LocalLogVO();
               localLog.setLogName(item.getName());
               localLog.setLogType(getLogType(item.getName()));
               localLog.setCreateTime(getLastModifiedOrCreatTime(false,logParentPath));
               localLog.setLastModifier(getLastModifiedOrCreatTime(true,logParentPath));
               localLog.setLogPath(logParentPath);
               String serviceId = getServiceId(logParentPath);
               localLog.setServiceId(serviceId);
               localLog.setServiceName(getServiceName(serviceId));
               localLog.setHasChildren(false);
               localLogsVO.add(localLog);
            });
            if(Func.isNotEmpty(files) && files.length>0){
               Arrays.stream(files).forEach(item->{
                  // 组建日志文件对象
                  LocalLogVO localLog = new LocalLogVO();
                  localLog.setLogName(item.getName());
                  localLog.setLogType(getLogType(item.getName()));
                  localLog.setCreateTime(getLastModifiedOrCreatTime(false,logParentPath));
                  localLog.setLastModifier(getLastModifiedOrCreatTime(true,logParentPath));
                  localLog.setLogPath(logParentPath);
                  String serviceId = getServiceId(logParentPath);
                  localLog.setServiceId(serviceId);
                  localLog.setServiceName(getServiceName(serviceId));
                  localLog.setHasChildren(false);
                  localLogsVO.add(localLog);
               });
            }
         }
      }else {
         File fileDir = new File(PARENTPATH);
         File[] childDir = fileDir.listFiles();
         Arrays.stream(childDir).forEach(dir->{
            if(dir.getName().contains("ubcs_")){
               String fullPath = dir.getPath() + LOGPATH;
               File file = new File(fullPath);
               if(file.exists()){
                  LocalLogVO localLogVO = new LocalLogVO();
                  localLogVO.setLastModifier(getLastModifiedOrCreatTime(true,fullPath));
                  localLogVO.setCreateTime(getLastModifiedOrCreatTime(false,fullPath));
                  localLogVO.setLogPath(fullPath);
                  String serviceId = getServiceId(file.getPath());
                  localLogVO.setServiceId(serviceId);
                  String serviceName = getServiceName(serviceId);
                  localLogVO.setServiceName(serviceName);
                  localLogVO.setLogType(serviceName+"日志父目录");
                  localLogVO.setLogName(serviceName+"日志父目录");
                  localLogVO.setHasChildren(true);
                  localLogsVO.add(localLogVO);
         if(Func.isNotEmpty(childDir) && childDir.length > 0){
            Arrays.stream(childDir).forEach(dir->{
               if(dir.getName().contains("ubcs_")){
                  String fullPath = dir.getPath() + LOGPATH;
                  File file = new File(fullPath);
                  if(file.exists()){
                     LocalLogVO localLogVO = new LocalLogVO();
                     localLogVO.setLastModifier(getLastModifiedOrCreatTime(true,fullPath));
                     localLogVO.setCreateTime(getLastModifiedOrCreatTime(false,fullPath));
                     localLogVO.setLogPath(fullPath);
                     String serviceId = getServiceId(file.getPath());
                     localLogVO.setServiceId(serviceId);
                     String serviceName = getServiceName(serviceId);
                     localLogVO.setServiceName(serviceName);
                     localLogVO.setLogType(serviceName+"日志父目录");
                     localLogVO.setLogName(serviceName+"日志父目录");
                     localLogVO.setHasChildren(true);
                     localLogsVO.add(localLogVO);
                  }
               }
            }
         });
            });
         }
      }
      return localLogsVO;
   }