浏览代码

修复代码7

xusl 3 年之前
父节点
当前提交
2356d90efb

+ 0 - 2
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/JwtUtil.java

@@ -28,8 +28,6 @@ public class JwtUtil {
     private final String SECRET = "!@#xwexe3@!#ds123";
     private final String ISSUER = "jiayue";
 
-    private final String ROLE_CLAIMS = "role";
-
     /**
      * @Description: 单位秒,即过期时间是24个小时
      */

+ 0 - 1
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/WebUtil.java

@@ -26,7 +26,6 @@ import java.io.PrintWriter;
 @Slf4j
 @UtilityClass
 public class WebUtil extends org.springframework.web.util.WebUtils {
-    private final String BASIC_ = "Basic ";
     private final String UNKNOWN = "unknown";
 
     /**

+ 11 - 9
ipfcst-common/ipfcst-common-data/src/main/java/org/hibernate/cfg/InheritanceState.java

@@ -294,19 +294,21 @@ public class InheritanceState {
 
         //ordered to allow proper messages on properties subclassing
         XClass currentClassInHierarchy = clazz;
-        org.hibernate.cfg.InheritanceState superclassState;
+        org.hibernate.cfg.InheritanceState superclassState = null;
         do {
             classesToProcessForMappedSuperclass.add( 0, currentClassInHierarchy );
             XClass superClass = currentClassInHierarchy;
-            do {
-                superClass = superClass.getSuperclass();
-                superclassState = inheritanceStatePerClass.get( superClass );
-            }
-            while ( superClass != null
-                    && !buildingContext.getBootstrapContext().getReflectionManager().equals( superClass, Object.class )
-                    && superclassState == null );
+            if (superClass!=null){
+                do {
+                    superClass = superClass.getSuperclass();
+                    superclassState = inheritanceStatePerClass.get( superClass );
+                }
+                while ( superClass != null
+                        && !buildingContext.getBootstrapContext().getReflectionManager().equals( superClass, Object.class )
+                        && superclassState == null );
 
-            currentClassInHierarchy = superClass;
+                currentClassInHierarchy = superClass;
+            }
         }
         while ( superclassState != null && superclassState.isEmbeddableSuperclass() );
     }

+ 5 - 13
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ElectricFieldController.java

@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedOutputStream;
-import java.io.IOException;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -159,7 +158,6 @@ public class ElectricFieldController {
   //导出所有场站
   @RequestMapping(value = "/export")
   public void export(HttpServletResponse response) {
-    BufferedOutputStream bos = null;
     try {
       StringBuilder templateContent = new StringBuilder();
       response.setCharacterEncoding("UTF-8");
@@ -189,19 +187,13 @@ public class ElectricFieldController {
       response.setContentType("application/x-msdownload;charset=UTF-8");// 文件下载必须配置为application/x-msdownload
       response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode("场站信息数据.csv", "UTF-8"));// 中文文件名必须使用URLEncoder.encode进行转码
       byte[] templateContentBytes = templateContent.toString().getBytes(StandardCharsets.UTF_8);
-      bos = new BufferedOutputStream(response.getOutputStream());// 向response中写入文件流
-      bos.write(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});// 指定csv文件用UTF-8字符集打开
-      bos.write(templateContentBytes);
-      response.flushBuffer();
+      try(BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());) {// 向response中写入文件流
+        bos.write(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});// 指定csv文件用UTF-8字符集打开
+        bos.write(templateContentBytes);
+        response.flushBuffer();
+      }
     } catch (Exception e) {
       log.error("系统错误:" + e.getMessage(), e);
-    } finally {
-      if (bos != null)
-        try {
-          bos.close();
-        } catch (IOException e) {
-          log.error("系统错误:" + e.getMessage(), e);
-        }
     }
   }
 }

+ 10 - 44
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/FileAnalysisService.java

@@ -280,11 +280,9 @@ public class FileAnalysisService extends BaseService {
   private List<Nwp> fileAnalysisNwp(File file, String stationCode) {
     List<Nwp> listNwp = new ArrayList<>();
     if (file.renameTo(file)) {
-      InputStreamReader readNwp = null;
-      BufferedReader bufferedReaderNwp = null;
-      try {
-        readNwp = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8.name());//考虑到编码格式
-        bufferedReaderNwp = new BufferedReader(readNwp);
+      try(
+        InputStreamReader readNwp = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8.name());//考虑到编码格式
+        BufferedReader bufferedReaderNwp = new BufferedReader(readNwp);){
         String lineTxt;
         Nwp nwpData;
         BigDecimal nwpDirectRadiation = new BigDecimal("0.7"); //直接辐射
@@ -349,8 +347,6 @@ public class FileAnalysisService extends BaseService {
         } catch (IOException e1) {
           log.error(file.getName() + analysisFaild, e);
         }
-      } finally {
-        close(bufferedReaderNwp, readNwp);
       }
     }
     return listNwp;
@@ -367,13 +363,11 @@ public class FileAnalysisService extends BaseService {
     List<HolidayCalendar> holidayCalendars = new ArrayList<>();
     // 当文件未被使用时,进行解析上报
     if (file.renameTo(file)) {
-      InputStreamReader read = null;
-      BufferedReader bufferedReader = null;
       String stringLine;
       HolidayCalendar holiday;
-      try {
-        read = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
-        bufferedReader = new BufferedReader(read);
+      try(
+        InputStreamReader read = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
+        BufferedReader bufferedReader = new BufferedReader(read);){
         while ((stringLine = bufferedReader.readLine()) != null) {
           String[] string_arr = stringLine.split("\t");
           if (string_arr.length == 7 && string_arr[0].startsWith("#")) {
@@ -392,8 +386,6 @@ public class FileAnalysisService extends BaseService {
       } catch (IOException | ParseException | RuntimeException e) {
         log.error(systemErrorLog, e);
         // 进行告警
-
-
         File destFile = new File(file.getPath().replaceFirst("new", systemErrorLog));
         if (destFile.exists()) {
           try {
@@ -407,8 +399,6 @@ public class FileAnalysisService extends BaseService {
         } catch (IOException e1) {
           log.error(file.getName() + analysisFaild, e);
         }
-      } finally {
-        close(bufferedReader, read);
       }
     }
     return holidayCalendars;
@@ -426,13 +416,11 @@ public class FileAnalysisService extends BaseService {
     List<ForecastPowerShortTerm> forecastPowerShortTerm = new ArrayList<>();
     // 当文件未被使用时,进行解析上报
     if (file.renameTo(file)) {
-      InputStreamReader read = null;
-      BufferedReader bufferedReader = null;
       String stringLine;
       ForecastPowerShortTerm stf;
-      try {
-        read = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
-        bufferedReader = new BufferedReader(read);
+      try (
+        InputStreamReader read = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
+        BufferedReader bufferedReader = new BufferedReader(read);){
         while ((stringLine = bufferedReader.readLine()) != null) {
           String[] string_arr = stringLine.split("\t");
 
@@ -446,7 +434,7 @@ public class FileAnalysisService extends BaseService {
               forecastPowerShortTerm.add(stf);
           }
         }
-      } catch (IOException | ParseException | RuntimeException e) {
+      } catch (Exception e) {
         log.error(systemErrorLog, e);
         // 进行告警
         File destFile = new File(file.getPath().replaceFirst("new", systemErrorLog));
@@ -462,8 +450,6 @@ public class FileAnalysisService extends BaseService {
         } catch (IOException e1) {
           log.error(file.getName() +analysisFaild, e);
         }
-      } finally {
-        close(bufferedReader, read);
       }
     }
     return forecastPowerShortTerm;
@@ -566,24 +552,4 @@ public class FileAnalysisService extends BaseService {
     fileParsingRecord.setStationCode(staticCode);
     fileAnalysisRecordService.save(fileParsingRecord);
   }
-
-
-  /**
-   * 关闭文件流
-   *
-   * @param bufferedReader 字符数据
-   * @param read           字节流
-   */
-  private void close(BufferedReader bufferedReader, InputStreamReader read) {
-    try {
-      if (bufferedReader != null) {
-        bufferedReader.close();
-      }
-      if (read != null) {
-        read.close();
-      }
-    } catch (IOException e) {
-      log.error("关闭文件流失败:", e);
-    }
-  }
 }

+ 0 - 3
ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/service/ContinueFTPService.java

@@ -42,9 +42,6 @@ public class ContinueFTPService {
   public FTPFile[] listFiles(String remotepath) throws IOException {
     client.enterLocalPassiveMode();
     remotepath = new String(remotepath.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
-    if (client == null) {
-      return null;
-    }
     client.changeWorkingDirectory(remotepath);//获取所有的目录
     return client.listFiles();//返回获取到的目录信息
   }