Browse Source

1.修改代码格式问题

wangtao 3 years ago
parent
commit
d7f420d4c5
66 changed files with 997 additions and 1515 deletions
  1. 7 5
      ipfcst-client/src/main/java/com/jiayue/client/controller/BackDatasController.java
  2. 9 7
      ipfcst-client/src/main/java/com/jiayue/client/job/DownloadFileJob.java
  3. 7 7
      ipfcst-client/src/main/java/com/jiayue/client/job/SendDataToDcJob.java
  4. 29 37
      ipfcst-client/src/main/java/com/jiayue/client/service/QueryDataService.java
  5. 6 4
      ipfcst-client/src/main/java/com/jiayue/client/service/SendDataService.java
  6. 0 21
      ipfcst-client/src/main/java/com/jiayue/client/util/FileUtil.java
  7. 8 8
      ipfcst-client/src/main/java/com/jiayue/client/util/MD5Util.java
  8. 14 16
      ipfcst-client/src/main/java/com/jiayue/client/util/Scpclient.java
  9. 67 67
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ClassUtil.java
  10. 3 18
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CommonUtil.java
  11. 1 4
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CronUtils.java
  12. 11 16
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java
  13. 10 14
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateTimeUtil.java
  14. 1 2
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/JsonBeanUtil.java
  15. 14 13
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ProduceSql.java
  16. 8 15
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/SunRiseSet.java
  17. 65 65
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/abst/AbstractBaseEntity.java
  18. 7 8
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ChannelDisconLog.java
  19. 1 9
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ElectricField.java
  20. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomIDGenerator.java
  21. 4 5
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomUUIDGenerator.java
  22. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzBlobTriggersEntity.java
  23. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCalendarsEntity.java
  24. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCronTriggersEntity.java
  25. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzFiredTriggersEntity.java
  26. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzLocksEntity.java
  27. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzPausedTriggerGrpsEntity.java
  28. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSchedulerStateEntity.java
  29. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpleTriggersEntity.java
  30. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpropTriggersEntity.java
  31. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzTriggersEntity.java
  32. 40 46
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/job/BaseJob.java
  33. 19 18
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/E63UploadFileRuleService.java
  34. 2 2
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/IUploadFileRuleService.java
  35. 2 2
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/UploadFileRuleCommonService.java
  36. 74 167
      ipfcst-common/ipfcst-common-data/src/main/java/org/hibernate/cfg/PropertyContainer.java
  37. 1 6
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SecurityAuthorizeConfigurerProvider.java
  38. 7 6
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SysAuthorizeConfigurerManager.java
  39. 0 8
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SystemAuthorizeConfigurerProvider.java
  40. 4 4
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/filter/JwtAuthenticationTokenFilter.java
  41. 9 13
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationFailureHandler.java
  42. 8 6
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationSuccessHandler.java
  43. 4 18
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/JwtUserDetailsServiceImpl.java
  44. 6 3
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/SysUserService.java
  45. 1 20
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/util/JwtTokenUtil.java
  46. 4 5
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java
  47. 17 8
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadService.java
  48. 36 45
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadTransactionService.java
  49. 23 20
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileChannelService.java
  50. 18 9
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileCodeService.java
  51. 16 14
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogDetailService.java
  52. 119 123
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogService.java
  53. 13 14
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadObjectService.java
  54. 10 8
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadURLService.java
  55. 18 187
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/ByteUtil.java
  56. 12 14
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/FileConstant.java
  57. 1 16
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/FileMutableInteger.java
  58. 8 22
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/FileUtil.java
  59. 3 4
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/IEC102Uitl.java
  60. 66 60
      ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/controller/FTPController.java
  61. 55 49
      ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/controller/SFTPController.java
  62. 23 22
      ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/dto/FTPSFTPDto.java
  63. 53 75
      ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/service/ContinueFTPService.java
  64. 29 123
      ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/service/ContinueSFTPService.java
  65. 13 17
      ipfcst-console/src/test/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileServiceTest.java
  66. 0 9
      ipfcst-console/src/test/java/com/jiayue/ipfcst/fileupload/service/TestFtpClient.java

+ 7 - 5
ipfcst-client/src/main/java/com/jiayue/client/controller/BackDatasController.java

@@ -3,7 +3,6 @@ package com.jiayue.client.controller;
 import cn.hutool.json.JSONUtil;
 import com.jiayue.client.service.SendDataService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -18,15 +17,18 @@ import java.util.Map;
 @Slf4j
 public class BackDatasController {
 
-    @Autowired
-    public SendDataService sendDataService;
+    public final SendDataService sendDataService;
+
+    public BackDatasController(SendDataService sendDataService) {
+        this.sendDataService = sendDataService;
+    }
 
     @RequestMapping("/send")
     public String sendToDc(String startTime, String endTime, String flag) {
-    
+
         sendDataService.send(startTime, endTime, flag);
 
-        Map result = new HashMap();
+        Map<String, Object> result = new HashMap<>();
         result.put("code", 200);
         result.put("msg", "发送结束");
         return JSONUtil.toJsonStr(result);

+ 9 - 7
ipfcst-client/src/main/java/com/jiayue/client/job/DownloadFileJob.java

@@ -11,7 +11,6 @@ import com.jiayue.client.service.QueryDataService;
 import com.jiayue.client.util.FileUtil;
 import com.jiayue.client.util.Scpclient;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
 import org.springframework.core.io.PathResource;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -31,12 +30,11 @@ import java.util.Properties;
 @Slf4j
 public class DownloadFileJob {
 
-    @Autowired
-    public QueryDataService queryDataService;
+    public final QueryDataService queryDataService;
     //获取下载到文件,从临时目录移动到目标目录
-    public static List<String> filedownLoadList = new ArrayList<String>();
-    public static List<String> isDownFileId = new ArrayList<String>();
-    public static Properties properties = new Properties();
+    public static List<String> filedownLoadList = new ArrayList<>();
+    public static List<String> isDownFileId = new ArrayList<>();
+    public static Properties properties;
 
     static {
         YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
@@ -44,6 +42,10 @@ public class DownloadFileJob {
         properties = yaml.getObject();
     }
 
+    public DownloadFileJob(QueryDataService queryDataService) {
+        this.queryDataService = queryDataService;
+    }
+
     /**
      * 每天凌晨2点执行
      */
@@ -71,7 +73,7 @@ public class DownloadFileJob {
                         }
                         log.info("开始下载文件:{}。", fileCreateLog.getFileName());
                         String url = properties.getProperty("v3cloud.fileDownUrl") + fileCreateLog.getId();// "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
-                        Long size = HttpUtil.downloadFile(url, path + File.separatorChar + fileCreateLog.getFileName());
+                        long size = HttpUtil.downloadFile(url, path + File.separatorChar + fileCreateLog.getFileName());
                         if (size > 0) {
                             isDownFileId.add(fileCreateLog.getId());
                             log.info("成功下载文件:{}", path + File.separatorChar + fileCreateLog.getFileName());

+ 7 - 7
ipfcst-client/src/main/java/com/jiayue/client/job/SendDataToDcJob.java

@@ -2,7 +2,6 @@ package com.jiayue.client.job;
 
 import com.jiayue.client.service.SendDataService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
@@ -19,10 +18,13 @@ import java.util.Date;
 @Slf4j
 public class SendDataToDcJob {
 
-    @Autowired
-    public SendDataService sendDataService;
+    public final SendDataService sendDataService;
     public static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
+    public SendDataToDcJob(SendDataService sendDataService) {
+        this.sendDataService = sendDataService;
+    }
+
 
     /**
      * 每天凌晨2点执行
@@ -47,8 +49,7 @@ public class SendDataToDcJob {
         date.set(Calendar.SECOND, 0);
         date.set(Calendar.MILLISECOND, 0);
         date.add(Calendar.DAY_OF_MONTH, -1);
-        String dateString = formatter.format(date.getTime());
-        return dateString;
+        return formatter.format(date.getTime());
     }
 
     /**
@@ -64,7 +65,6 @@ public class SendDataToDcJob {
         date.set(Calendar.SECOND, 59);
         date.set(Calendar.MILLISECOND, 999);
         date.add(Calendar.DAY_OF_MONTH, -1);
-        String dateString = formatter.format(date.getTime());
-        return dateString;
+        return formatter.format(date.getTime());
     }
 }

+ 29 - 37
ipfcst-client/src/main/java/com/jiayue/client/service/QueryDataService.java

@@ -1,7 +1,6 @@
 package com.jiayue.client.service;
 
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Repository;
 
@@ -14,8 +13,24 @@ import java.util.Map;
 @Repository
 @Slf4j
 public class QueryDataService {
-    @Autowired
-    private JdbcTemplate jdbcTemplate;
+    private final JdbcTemplate jdbcTemplate;
+
+    public QueryDataService(JdbcTemplate jdbcTemplate) {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+
+    public static Long changStrTimeToLongTime(String strTime) {
+        long resultTime = -1L;
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        //设置要读取的时间字符串格式
+        try {
+            Date date = format.parse(strTime);
+            resultTime = date.getTime();
+        } catch (ParseException e) {
+            log.error("转换时间 {} 为Long格式出错:{}", strTime, e);
+        }
+        return resultTime;
+    }
 
     /**
      * 查询所有电站信息
@@ -23,8 +38,8 @@ public class QueryDataService {
     public List<Map<String, Object>> getStations() {
         String stationsSql = "SELECT C_STATION_CODE,C_NAME,C_CAPACITY " +
                 "from t_electric_field ";
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(stationsSql);
-        return list;
+        return jdbcTemplate.queryForList(stationsSql);
+
     }
 
     /**
@@ -40,8 +55,7 @@ public class QueryDataService {
                 "from t_power_station_status_data where C_STATION_CODE='" + stationCode +
                 "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("实际功率回传数据查询sql:{}", rpsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(rpsSql);
-        return list;
+        return jdbcTemplate.queryForList(rpsSql);
     }
 
     /**
@@ -58,8 +72,7 @@ public class QueryDataService {
                 "' and C_FORECAST_TIME between '" + changStrTimeToLongTime(startTime) +
                 "'and '" + changStrTimeToLongTime(endTime) + "'";
         log.info("短期回传数据查询sql:{}", dqsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(dqsSql);
-        return list;
+        return jdbcTemplate.queryForList(dqsSql);
     }
 
     /**
@@ -76,8 +89,7 @@ public class QueryDataService {
                 "' and C_FORECAST_TIME between '" + changStrTimeToLongTime(startTime) +
                 "'and '" + changStrTimeToLongTime(endTime) + "'";
         log.info("超短期回传数据查询sql:{}", cdqsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(cdqsSql);
-        return list;
+        return jdbcTemplate.queryForList(cdqsSql);
     }
 
     /**
@@ -92,8 +104,7 @@ public class QueryDataService {
         String wedSql = "SELECT C_TIME,C_EQUIPMENT_NO,C_GLOBALR,C_AIRT " +
                 "from t_weather_station_status_data where C_EQUIPMENT_NO='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("超短期回传数据查询sql:{}", wedSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(wedSql);
-        return list;
+        return jdbcTemplate.queryForList(wedSql);
     }
 
     /**
@@ -109,8 +120,7 @@ public class QueryDataService {
                 "from t_wind_tower_status_data where C_EQUIPMENT_NO='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("测风塔回传数据查询sql:{}", cftsSql);
 
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(cftsSql);
-        return list;
+        return jdbcTemplate.queryForList(cftsSql);
     }
 
     /**
@@ -125,22 +135,7 @@ public class QueryDataService {
         String fjsSql = "SELECT C_TIME,C_EQUIPMENT_NO,C_WS,C_WD " +
                 "from t_wind_turbine_status_data where C_EQUIPMENT_NO='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("风机回传数据查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
-    }
-
-
-    public static Long changStrTimeToLongTime(String strTime) {
-        Long resultTime = -1L;
-        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//设置要读取的时间字符串格式
-        try {
-            Date date = format.parse(strTime);
-            resultTime = date.getTime();
-        } catch (ParseException e) {
-            log.error("转换时间 {} 为Long格式出错:{}", strTime, e);
-        }
-        return resultTime;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 
     /**
@@ -153,8 +148,7 @@ public class QueryDataService {
         String fjsSql = "SELECT C_ID,C_EQUIPMENT_NO,C_EQUIPMENT_TYPE " +
                 "from t_weather_station_info where C_STATION_CODE='" + stationCode + "' ";
         log.info("环境检测仪设备信息查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 
     /**
@@ -167,8 +161,7 @@ public class QueryDataService {
         String fjsSql = "SELECT C_ID,C_EQUIPMENT_NO,C_EQUIPMENT_TYPE " +
                 "from t_wind_tower_info where C_STATION_CODE='" + stationCode + "' ";
         log.info("测风塔设备信息查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 
     /**
@@ -181,7 +174,6 @@ public class QueryDataService {
         String fjsSql = "SELECT C_ID,C_EQUIPMENT_NO,C_EQUIPMENT_TYPE " +
                 "from t_wind_turbine_info where C_STATION_CODE='" + stationCode + "' ";
         log.info("风机设备信息查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 }

+ 6 - 4
ipfcst-client/src/main/java/com/jiayue/client/service/SendDataService.java

@@ -5,7 +5,6 @@ import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONUtil;
 import com.jiayue.client.util.MD5Util;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
 import org.springframework.core.io.PathResource;
 import org.springframework.stereotype.Repository;
@@ -15,12 +14,11 @@ import java.util.*;
 @Repository
 @Slf4j
 public class SendDataService {
-    @Autowired
-    public QueryDataService queryDataService;
+    public final QueryDataService queryDataService;
     //青海回传数据通用签名key
     private final static String qinghaiKey = "Syjy*3377";
 
-    public static Properties properties = new Properties();
+    public static Properties properties;
 
     static {
         YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
@@ -28,6 +26,10 @@ public class SendDataService {
         properties = yaml.getObject();
     }
 
+    public SendDataService(QueryDataService queryDataService) {
+        this.queryDataService = queryDataService;
+    }
+
     /**
      * 向数据中心
      *

+ 0 - 21
ipfcst-client/src/main/java/com/jiayue/client/util/FileUtil.java

@@ -6,24 +6,6 @@ import java.io.File;
 
 @Slf4j
 public class FileUtil {
-    public static void mvFile(String fsPath, String fdPath) {
-//        File fs = new File("D:\\迅雷下载\\f31.mp4");
-//        File fd = new File("D:\\");
-        //源文件
-        File fs = new File(fsPath);
-        //目标目录
-        File fd = new File(fdPath);
-        //判断目标目录是否存在同名文件,存在则删除
-        File md = new File(fdPath + fs.getName());
-        if (md.exists()) {
-            md.delete();
-        }
-        try {
-            fs.renameTo(fd);
-        } catch (Exception e) {
-            log.error("文件移动错误", e);
-        }
-    }
 
     public static String judeDirExists(String path) {
         try {
@@ -48,9 +30,6 @@ public class FileUtil {
                 }
                 file.mkdir();
 
-                /*if (osName.indexOf("Windows") <= -1) {
-                    Runtime.getRuntime().exec("chmod 777 -R " + path);//ftp服务器在linux环境中,生成的文件涉及到读写权限问题,直接给777权限
-                }*/
             }
             log.info("path:" + path);
         } catch (Exception e) {

+ 8 - 8
ipfcst-client/src/main/java/com/jiayue/client/util/MD5Util.java

@@ -16,7 +16,7 @@ public class MD5Util {
     }
 
     public static String encode(String str) {
-        MessageDigest md5 = null;
+        MessageDigest md5;
         try {
             md5 = MessageDigest.getInstance("MD5");
         } catch (Exception e) {
@@ -30,9 +30,9 @@ public class MD5Util {
         }
 
         byte[] md5Bytes = md5.digest(byteArray);
-        StringBuffer hexValue = new StringBuffer();
-        for (int i = 0; i < md5Bytes.length; i++) {
-            int val = ((int) md5Bytes[i]) & 0xff;
+        StringBuilder hexValue = new StringBuilder();
+        for (byte md5Byte : md5Bytes) {
+            int val = ((int) md5Byte) & 0xff;
             if (val < 16) {
                 hexValue.append("0");
             }
@@ -53,13 +53,13 @@ public class MD5Util {
         try {
             MessageDigest md = MessageDigest.getInstance(encryption);
             md.update(plainText.getBytes());
-            byte b[] = md.digest();
+            byte[] b = md.digest();
 
             int i;
 
-            StringBuffer buf = new StringBuffer("");
-            for (int offset = 0; offset < b.length; offset++) {
-                i = b[offset];
+            StringBuilder buf = new StringBuilder();
+            for (byte value : b) {
+                i = value;
                 if (i < 0)
                     i += 256;
                 if (i < 16)

+ 14 - 16
ipfcst-client/src/main/java/com/jiayue/client/util/Scpclient.java

@@ -12,6 +12,17 @@ import java.util.Map;
 @Slf4j
 public class Scpclient {
     static private Scpclient instance;
+    private final String ip;
+    private int port;
+    private String username;
+    private String password;
+
+    public Scpclient(String ip, int port, String username, String passward) {
+        this.ip = ip;
+        this.port = port;
+        this.username = username;
+        this.password = passward;
+    }
 
     static synchronized public Scpclient getInstance(String IP, int port,
                                                      String username, String passward) {
@@ -21,13 +32,6 @@ public class Scpclient {
         return instance;
     }
 
-    public Scpclient(String IP, int port, String username, String passward) {
-        this.ip = IP;
-        this.port = port;
-        this.username = username;
-        this.password = passward;
-    }
-
     /**
      * 远程拷贝文件
      *
@@ -40,7 +44,7 @@ public class Scpclient {
             conn.connect();
             boolean isAuthenticated = conn.authenticateWithPassword(username,
                     password);
-            if (isAuthenticated == false) {
+            if (!isAuthenticated) {
                 log.info("authentication failed");
                 return null;
             }
@@ -54,7 +58,6 @@ public class Scpclient {
         return null;
     }
 
-
     /**
      * 远程上传文件
      *
@@ -67,7 +70,7 @@ public class Scpclient {
             conn.connect();
             boolean isAuthenticated = conn.authenticateWithPassword(username,
                     password);
-            if (isAuthenticated == false) {
+            if (!isAuthenticated) {
                 log.info("authentication failed");
             }
             SCPClient client = new SCPClient(conn);
@@ -93,7 +96,7 @@ public class Scpclient {
             conn.connect();
             boolean isAuthenticated = conn.authenticateWithPassword(username,
                     password);
-            if (isAuthenticated == false) {
+            if (!isAuthenticated) {
                 log.info("authentication failed");
             }
             SCPClient client = new SCPClient(conn);
@@ -114,11 +117,6 @@ public class Scpclient {
         }
     }
 
-    private String ip;
-    private int port;
-    private String username;
-    private String password;
-
     public String getUsername() {
         return username;
     }

+ 67 - 67
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ClassUtil.java

@@ -21,76 +21,76 @@ import java.lang.reflect.Method;
  */
 @UtilityClass
 public class ClassUtil extends ClassUtils {
-	private final ParameterNameDiscoverer PARAMETERNAMEDISCOVERER = new DefaultParameterNameDiscoverer();
+    private final ParameterNameDiscoverer PARAMETERNAMEDISCOVERER = new DefaultParameterNameDiscoverer();
 
-	/**
-	 * 获取方法参数信息
-	 *
-	 * @param constructor    构造器
-	 * @param parameterIndex 参数序号
-	 * @return {MethodParameter}
-	 */
-	public MethodParameter getMethodParameter(Constructor<?> constructor, int parameterIndex) {
-		MethodParameter methodParameter = new SynthesizingMethodParameter(constructor, parameterIndex);
-		methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
-		return methodParameter;
-	}
+    /**
+     * 获取方法参数信息
+     *
+     * @param constructor    构造器
+     * @param parameterIndex 参数序号
+     * @return {MethodParameter}
+     */
+    public MethodParameter getMethodParameter(Constructor<?> constructor, int parameterIndex) {
+        MethodParameter methodParameter = new SynthesizingMethodParameter(constructor, parameterIndex);
+        methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
+        return methodParameter;
+    }
 
-	/**
-	 * 获取方法参数信息
-	 *
-	 * @param method         方法
-	 * @param parameterIndex 参数序号
-	 * @return {MethodParameter}
-	 */
-	public MethodParameter getMethodParameter(Method method, int parameterIndex) {
-		MethodParameter methodParameter = new SynthesizingMethodParameter(method, parameterIndex);
-		methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
-		return methodParameter;
-	}
+    /**
+     * 获取方法参数信息
+     *
+     * @param method         方法
+     * @param parameterIndex 参数序号
+     * @return {MethodParameter}
+     */
+    public MethodParameter getMethodParameter(Method method, int parameterIndex) {
+        MethodParameter methodParameter = new SynthesizingMethodParameter(method, parameterIndex);
+        methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
+        return methodParameter;
+    }
 
-	/**
-	 * 获取Annotation
-	 *
-	 * @param method         Method
-	 * @param annotationType 注解类
-	 * @param <A>            泛型标记
-	 * @return {Annotation}
-	 */
-	public <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
-		Class<?> targetClass = method.getDeclaringClass();
-		// The method may be on an interface, but we need attributes from the target class.
-		// If the target class is null, the method will be unchanged.
-		Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
-		// If we are dealing with method with generic parameters, find the original method.
-		specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
-		// 先找方法,再找方法上的类
-		A annotation = AnnotatedElementUtils.findMergedAnnotation(specificMethod, annotationType);
-		;
-		if (null != annotation) {
-			return annotation;
-		}
-		// 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
-		return AnnotatedElementUtils.findMergedAnnotation(specificMethod.getDeclaringClass(), annotationType);
-	}
+    /**
+     * 获取Annotation
+     *
+     * @param method         Method
+     * @param annotationType 注解类
+     * @param <A>            泛型标记
+     * @return {Annotation}
+     */
+    public <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
+        Class<?> targetClass = method.getDeclaringClass();
+        // The method may be on an interface, but we need attributes from the target class.
+        // If the target class is null, the method will be unchanged.
+        Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
+        // If we are dealing with method with generic parameters, find the original method.
+        specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
+        // 先找方法,再找方法上的类
+        A annotation = AnnotatedElementUtils.findMergedAnnotation(specificMethod, annotationType);
 
-	/**
-	 * 获取Annotation
-	 *
-	 * @param handlerMethod  HandlerMethod
-	 * @param annotationType 注解类
-	 * @param <A>            泛型标记
-	 * @return {Annotation}
-	 */
-	public <A extends Annotation> A getAnnotation(HandlerMethod handlerMethod, Class<A> annotationType) {
-		// 先找方法,再找方法上的类
-		A annotation = handlerMethod.getMethodAnnotation(annotationType);
-		if (null != annotation) {
-			return annotation;
-		}
-		// 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
-		Class<?> beanType = handlerMethod.getBeanType();
-		return AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType);
-	}
+        if (null != annotation) {
+            return annotation;
+        }
+        // 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
+        return AnnotatedElementUtils.findMergedAnnotation(specificMethod.getDeclaringClass(), annotationType);
+    }
+
+    /**
+     * 获取Annotation
+     *
+     * @param handlerMethod  HandlerMethod
+     * @param annotationType 注解类
+     * @param <A>            泛型标记
+     * @return {Annotation}
+     */
+    public <A extends Annotation> A getAnnotation(HandlerMethod handlerMethod, Class<A> annotationType) {
+        // 先找方法,再找方法上的类
+        A annotation = handlerMethod.getMethodAnnotation(annotationType);
+        if (null != annotation) {
+            return annotation;
+        }
+        // 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
+        Class<?> beanType = handlerMethod.getBeanType();
+        return AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType);
+    }
 
 }

+ 3 - 18
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CommonUtil.java

@@ -22,7 +22,6 @@ public abstract class CommonUtil {
 
     private static final int BUFFER_SIZE = 2 * 1024;
     public static Properties props = System.getProperties();
-    public static String osName = props.getProperty("os.name");
 
     /**
      * 获取随机数
@@ -57,21 +56,9 @@ public abstract class CommonUtil {
 
         List<File> list = getFiles(path, new ArrayList<>());
 
-        if (list != null && list.size() > 0) {
+        if (list.size() > 0) {
 
-            Collections.sort(list, new Comparator<File>() {
-                @Override
-                public int compare(File file, File newFile) {
-                    if (file.lastModified() < newFile.lastModified()) {
-                        return 1;
-                    } else if (file.lastModified() == newFile.lastModified()) {
-                        return 0;
-                    } else {
-                        return -1;
-                    }
-
-                }
-            });
+            list.sort((file, newFile) -> Long.compare(newFile.lastModified(), file.lastModified()));
 
         }
 
@@ -89,9 +76,7 @@ public abstract class CommonUtil {
 
         File realFile = new File(realpath);
         File[] subfiles = realFile.listFiles();
-        for (File file : subfiles) {
-            files.add(file);
-        }
+        Collections.addAll(files, Objects.requireNonNull(subfiles));
         return files;
     }
 

+ 1 - 4
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CronUtils.java

@@ -67,8 +67,6 @@ public class CronUtils {
         Date time2 = trigger.getFireTimeAfter(time1);
         Date time3 = trigger.getFireTimeAfter(time2);
         long l = time1.getTime() - (time3.getTime() - time2.getTime());
-//		Date date = new Date(l);
-//		SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date date = new Date();
         date.setTime(l);
         return date;
@@ -83,7 +81,6 @@ public class CronUtils {
     public static Date getNextTriggerTime(String cron) {
         CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("Caclulate Date").withSchedule(CronScheduleBuilder.cronSchedule(cron)).build();
         Date time0 = trigger.getStartTime();
-        Date time1 = trigger.getFireTimeAfter(time0);
-        return time1;
+        return trigger.getFireTimeAfter(time0);
     }
 }

+ 11 - 16
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java

@@ -56,12 +56,10 @@ public abstract class DateMomentUtil {
         int moment = DateMomentUtil.getMoment(dateTime, momentLength);// 获取指定时间所在时刻数
         long differentTime = moment * momentLength;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
         long dayStartTime = DateMomentUtil.getDayStartTime(dateTime);
-        switch (signType) {
-            case 2:
-                return dayStartTime + differentTime;
-            default:
-                return dayStartTime + differentTime - momentLength;
+        if (signType == 2) {
+            return dayStartTime + differentTime;
         }
+        return dayStartTime + differentTime - momentLength;
     }
 
     /**
@@ -79,12 +77,10 @@ public abstract class DateMomentUtil {
         if (24 * 3600 * 1000L % momentLength != 0)
             throw new Exception("时刻长度非法,时刻长度需要能够被一天整除");
         long dayStartTime = DateMomentUtil.getDayStartTime(dateTime);
-        switch (signType) {
-            case 2:
-                return dayStartTime + momentLength;
-            default:
-                return dayStartTime;
+        if (signType == 2) {
+            return dayStartTime + momentLength;
         }
+        return dayStartTime;
     }
 
     /**
@@ -108,12 +104,10 @@ public abstract class DateMomentUtil {
         date.set(Calendar.MINUTE, 0);
         date.set(Calendar.SECOND, 0);
         date.set(Calendar.MILLISECOND, 0);
-        switch (signType) {
-            case 2:
-                return date.getTimeInMillis();
-            default:
-                return date.getTimeInMillis() - momentLength;
+        if (signType == 2) {
+            return date.getTimeInMillis();
         }
+        return date.getTimeInMillis() - momentLength;
     }
 
     /**
@@ -150,8 +144,9 @@ public abstract class DateMomentUtil {
 
     /**
      * 获取两个时间间的间隔天数(自然天)
+     *
      * @param dateFrom 开始时间
-     * @param dateTo 结束时间
+     * @param dateTo   结束时间
      * @return 自然天数
      */
     public static Integer getDaysBetweenTwoDate(Long dateFrom, Long dateTo) {

+ 10 - 14
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateTimeUtil.java

@@ -8,6 +8,7 @@ import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Objects;
 
 /**
  * 时间工具类
@@ -65,7 +66,7 @@ public class DateTimeUtil {
      */
     public static Date getMomentTimeFor15Minute(@NotNull final Long dateTime) {
         int moment = DateTimeUtil.getMomentFor15Minute(dateTime);// 获取指定时间所在时刻数
-        long differentTime = moment * 15 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
+        long differentTime = (long) moment * 15 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
         long dayStartTime = DateTimeUtil.getDayStartTime(dateTime).getTime();
         return new Date(dayStartTime + differentTime - 15 * 60 * 1000);
     }
@@ -80,7 +81,7 @@ public class DateTimeUtil {
      */
     public static Date getMomentTimeFor5Minute(@NotNull final Long dateTime) {
         int moment = DateTimeUtil.getMomentFor15Minute(dateTime);// 获取指定时间所在时刻数
-        long differentTime = moment * 5 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
+        long differentTime = (long) moment * 5 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
         long dayStartTime = DateTimeUtil.getDayStartTime(dateTime).getTime();
         return new Date(dayStartTime + differentTime - 5 * 60 * 1000);
     }
@@ -172,8 +173,7 @@ public class DateTimeUtil {
     public static String getStringDate() {
         Date currentTime = new Date();
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String dateString = formatter.format(currentTime);
-        return dateString;
+        return formatter.format(currentTime);
     }
 
     /**
@@ -184,8 +184,7 @@ public class DateTimeUtil {
      */
     public static String dateToStrLong(Date dateDate) {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String dateString = formatter.format(dateDate);
-        return dateString;
+        return formatter.format(dateDate);
     }
 
     /**
@@ -197,8 +196,7 @@ public class DateTimeUtil {
     public static Date strToDateLongHM(String strDate) {
         SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
         ParsePosition pos = new ParsePosition(0);
-        Date strtodate = formatter.parse(strDate, pos);
-        return strtodate;
+        return formatter.parse(strDate, pos);
     }
 
     /**
@@ -225,17 +223,14 @@ public class DateTimeUtil {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        if (dt1.getTime() > dt2.getTime() && dt1.getTime() < dt3.getTime()) {
-            return true;
-        } else {
-            return false;
-        }
+        return Objects.requireNonNull(dt1).getTime() > Objects.requireNonNull(dt2).getTime() && dt1.getTime() < Objects.requireNonNull(dt3).getTime();
     }
 
     /**
      * 判断时间是不是今天
+     *
      * @param date
-     * @return    是返回true,不是返回false
+     * @return 是返回true,不是返回false
      */
     public static boolean isNow(Date date) {
         //当前时间
@@ -250,6 +245,7 @@ public class DateTimeUtil {
 
     /**
      * 将时间戳秒变成0
+     *
      * @param dateTime
      * @return
      */

+ 1 - 2
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/JsonBeanUtil.java

@@ -23,8 +23,7 @@ public class JsonBeanUtil {
      */
     public static <T> List<T> jsonToBean(String json, Class<T> t) {
         JSONArray array = JSONUtil.parseArray(json);
-        List<T> list = array.toList(t);
-        return list;
+        return array.toList(t);
     }
 
     /**

+ 14 - 13
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ProduceSql.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ReflectUtil;
 import cn.hutool.core.util.StrUtil;
 
 import java.lang.reflect.Field;
+import java.util.Objects;
 
 /**
  * TODO
@@ -22,7 +23,7 @@ public class ProduceSql {
     public static <T> String getInsertSql(String tablename, T t) throws IllegalArgumentException {
         //insert into table_name (column_name1,column_name2, ...) values (value1,value2, ...)
         boolean flag = false;
-        String sql = "";
+        String sql;
         Field[] fields = ReflectUtil.getFieldsDirectly(t.getClass(), false);
         StringBuffer topHalf = new StringBuffer("insert into " + tablename + " (");
         StringBuffer afterAalf = new StringBuffer("values (");
@@ -54,7 +55,7 @@ public class ProduceSql {
         afterAalf = new StringBuffer(StrUtil.removeSuffix(afterAalf.toString(), ","));
         topHalf.append(") ");
         afterAalf.append(") ");
-        sql = topHalf.toString() + afterAalf.toString();
+        sql = topHalf + afterAalf.toString();
         return sql;
     }
 
@@ -72,24 +73,24 @@ public class ProduceSql {
         //or
         //UPDATE table_name SET column_name1 = value1, column_name2 = value2, ... where id=xxx
         boolean flag = false;
-        String sql = "";
+        StringBuilder sql;
         String id = ""; //保存id列名:ID or id
         Field[] fields = ReflectUtil.getFieldsDirectly(t.getClass(), false);
-        sql = "update " + tablename + " set ";
+        sql = new StringBuilder("update " + tablename + " set ");
         for (Field field : fields) {
             StringBuffer tmp = new StringBuffer();
             if ("ID".equals(field.getName()) || "id".equals(field.getName())) {
                 id = field.getName();
                 continue;//更新的时候无需set id=xxx
             }
-            if (ReflectUtil.getFieldValue(t, field.getName()) != null && (String) ReflectUtil.getFieldValue(t, field.getName()) != "") {
+            if (ReflectUtil.getFieldValue(t, field.getName()) != null && !Objects.equals(ReflectUtil.getFieldValue(t, field.getName()), "")) {
 
                 String underScoreCaseColumn = field.getName();
                 for (int i = 0; i < field.getName().length(); i++) {
                     if (Character.isUpperCase(field.getName().charAt(i)))
                     // 将javabean中小驼峰命名变量的“大写字母”转换为“_小写字母”
                     {
-                        underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1, field.getName().length());
+                        underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1);
                     }
                 }
 
@@ -101,14 +102,14 @@ public class ProduceSql {
                     tmp.append(ReflectUtil.getFieldValue(t, underScoreCaseColumn) + ",");
                     flag = true;
                 }
-                sql += tmp;
+                sql.append(tmp);
             }
         }
         if (!flag) {
             throw new IllegalArgumentException(t.getClass() + "NullException.\nThere is no attribute that is not empty except for ID.You must provide an object with at least one attribute exclude ID.");
         }
-        sql = StrUtil.removeSuffix(sql, ",") + " where " + id + "='" + ReflectUtil.getFieldValue(t, id) + "'";
-        return sql;
+        sql = new StringBuilder(StrUtil.removeSuffix(sql.toString(), ",") + " where " + id + "='" + ReflectUtil.getFieldValue(t, id) + "'");
+        return sql.toString();
     }
 
     /**
@@ -150,16 +151,16 @@ public class ProduceSql {
     private static <T> String getSelectOrDeleteSql(String tablename, T t, String operation) throws IllegalArgumentException {
         //operation from table_name where column_name = value
         boolean flag = false;
-        String sql = "";
+        String sql;
         Field[] fields = ReflectUtil.getFieldsDirectly(t.getClass(), false);
-        StringBuffer topHalf = new StringBuffer(operation + " from " + tablename + " where ");
+        StringBuilder topHalf = new StringBuilder(operation + " from " + tablename + " where ");
         for (Field field : fields) {
             String underScoreCaseColumn = field.getName();
             for (int i = 0; i < field.getName().length(); i++) {
                 if (Character.isUpperCase(field.getName().charAt(i)))
                 // 将javabean中小驼峰命名变量的“大写字母”转换为“_小写字母”
                 {
-                    underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1, field.getName().length());
+                    underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1);
                 }
             }
             if ("ID".equals(underScoreCaseColumn) || "id".equals(underScoreCaseColumn)) {
@@ -170,7 +171,7 @@ public class ProduceSql {
                     break;
                 }
             } else {
-                if (ReflectUtil.getFieldValue(t, underScoreCaseColumn) != null && (String) ReflectUtil.getFieldValue(t, underScoreCaseColumn) != "") {
+                if (ReflectUtil.getFieldValue(t, underScoreCaseColumn) != null && !Objects.equals(ReflectUtil.getFieldValue(t, underScoreCaseColumn), "")) {
                     topHalf.append(underScoreCaseColumn + " = '" + ReflectUtil.getFieldValue(t, underScoreCaseColumn) + "'");
                     flag = true;
                     break;

+ 8 - 15
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/SunRiseSet.java

@@ -3,12 +3,13 @@ package com.jiayue.ipfcst.common.core.util;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Objects;
 
 public class SunRiseSet {
 
-    private static int[] days_of_month_1 = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+    private static final int[] days_of_month_1 = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
-    private static int[] days_of_month_2 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+    private static final int[] days_of_month_2 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
     private final static double h = -0.833;//日出日落时太阳的位置
 
@@ -22,9 +23,7 @@ public class SunRiseSet {
 
     public static boolean leap_year(int year) {
 
-        if (((year % 400 == 0) || (year % 100 != 0) && (year % 4 == 0))) return true;
-
-        else return false;
+        return (year % 400 == 0) || (year % 100 != 0) && (year % 4 == 0);
 
     }
 
@@ -227,9 +226,9 @@ public class SunRiseSet {
 
     public static int Zone(double glong) {
 
-        if (glong >= 0) return (int) ((int) (glong / 15.0) + 1);
+        if (glong >= 0) return (int) (glong / 15.0) + 1;
 
-        else return (int) ((int) (glong / 15.0) - 1);
+        else return (int) (glong / 15.0) - 1;
 
     }
 
@@ -247,7 +246,7 @@ public class SunRiseSet {
             if (m != null && m != "" && m.indexOf("0") == -1) {
                 m = m.replaceAll("0", "");
             }
-            month = Integer.parseInt(m);
+            month = Integer.parseInt(Objects.requireNonNull(m));
 
             date = Integer.parseInt(d);
 
@@ -271,12 +270,6 @@ public class SunRiseSet {
 
                                     G_sun(t_century(days(year, month, date), UTo)))))), UTo, glong, glat, year, month, date);
 
-//System.out.println("Sunrise is: "+(int)(sunrise/15+Zone(glong))+":"+(int)(60*(sunrise/15+Zone(glong)-(int)(sunrise/15+Zone(glong))))+" .\n");
-
-//        Log.d("Sunrise", "Sunrise is: "+(int)(sunrise/15+8)+":"+(int)(60*(sunrise/15+8-(int)(sunrise/15+8)))+" .\n");
-
-            //return "Sunrise is: "+(int)(sunrise/15+Zone(glong))+":"+(int)(60*(sunrise/15+Zone(glong)-(int)(sunrise/15+Zone(glong))))+" .\n";
-
             return (int) (sunrise / 15 + 8) + ":" + (int) (60 * (sunrise / 15 + 8 - (int) (sunrise / 15 + 8)));
         }
         return null;
@@ -297,7 +290,7 @@ public class SunRiseSet {
             if (m != null && m != "" && m.indexOf("0") == -1) {
                 m = m.replaceAll("0", "");
             }
-            month = Integer.parseInt(m);
+            month = Integer.parseInt(Objects.requireNonNull(m));
 
             date = Integer.parseInt(d);
 

+ 65 - 65
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/abst/AbstractBaseEntity.java

@@ -27,79 +27,79 @@ import java.util.Date;
 public
 class AbstractBaseEntity implements Serializable {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	/**
-	 * 备用字段A
-	 */
-	@Order(200)
-	@Column
-	private String backupA;
+    /**
+     * 备用字段A
+     */
+    @Order(200)
+    @Column
+    private String backupA;
 
-	/**
-	 * 备用字段B
-	 */
-	@Order(201)
-	@Column
-	private String backupB;
+    /**
+     * 备用字段B
+     */
+    @Order(201)
+    @Column
+    private String backupB;
 
-	/**
-	 * 备用字段C
-	 */
-	@Order(202)
-	@Column
-	private String backupC;
+    /**
+     * 备用字段C
+     */
+    @Order(202)
+    @Column
+    private String backupC;
 
-	/**
-	 * 备用字段D
-	 */
-	@Order(203)
-	@Column
-	private String backupD;
+    /**
+     * 备用字段D
+     */
+    @Order(203)
+    @Column
+    private String backupD;
 
-	/**
-	 * 备用字段E
-	 */
-	@Order(204)
-	@Column
-	private String backupE;
+    /**
+     * 备用字段E
+     */
+    @Order(204)
+    @Column
+    private String backupE;
 
-	/**
-	 * 备用字段F
-	 */
-	@Order(205)
-	@Column
-	private String backupF;
+    /**
+     * 备用字段F
+     */
+    @Order(205)
+    @Column
+    private String backupF;
 
 
-	/**
-	 * 创建人,不允许修改
-	 */
-	@Order(206)
-	@CreatedBy
-	@Column(updatable = false)
-	private String creator;
+    /**
+     * 创建人,不允许修改
+     */
+    @Order(206)
+    @CreatedBy
+    @Column(updatable = false)
+    private String creator;
 
-	/**
-	 * 创建时间,不允许修改
-	 */
-	@Order(207)
-	@CreatedDate
-	@Column(updatable = true)
-	private Date createTime;
+    /**
+     * 创建时间,不允许修改
+     */
+    @Order(207)
+    @CreatedDate
+    @Column()
+    private Date createTime;
 
-	/**
-	 * 最后修改者
-	 */
-	@Order(208)
-	@LastModifiedBy
-	@Column(insertable = false)
-	private String lastModifier;
-	/**
-	 * 最后修改时间
-	 */
-	@Order(209)
-	@LastModifiedDate
-	@Column(insertable = false)
-	private Date lastModifyTime;
+    /**
+     * 最后修改者
+     */
+    @Order(208)
+    @LastModifiedBy
+    @Column(insertable = false)
+    private String lastModifier;
+    /**
+     * 最后修改时间
+     */
+    @Order(209)
+    @LastModifiedDate
+    @Column(insertable = false)
+    private Date lastModifyTime;
 }

+ 7 - 8
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ChannelDisconLog.java

@@ -60,16 +60,15 @@ public class ChannelDisconLog extends AbstractBaseEntity {
     /**
      * 计算并配置持续时间
      */
-    public void countAndSetDuration(){
-        if(this.reconnectTime==null || this.disconnectTime==null || this.reconnectTime <= this.disconnectTime){
+    public void countAndSetDuration() {
+        if (this.reconnectTime == null || this.disconnectTime == null || this.reconnectTime <= this.disconnectTime) {
             return;
         }
-        Long durationL = this.reconnectTime-this.disconnectTime;
-        if (durationL/1000>=60){
-            setDuration(durationL/(1000*60)+"分");
-        }
-        else{
-           setDuration(durationL/1000+"秒");
+        long durationL = this.reconnectTime - this.disconnectTime;
+        if (durationL / 1000 >= 60) {
+            setDuration(durationL / (1000 * 60) + "分");
+        } else {
+            setDuration(durationL / 1000 + "秒");
         }
     }
 }

+ 1 - 9
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ElectricField.java

@@ -20,15 +20,7 @@ import java.math.BigDecimal;
 @Data
 @Entity
 public class ElectricField extends AbstractBaseEntity {
-    /**
-     * 备用字段A(用于所属地调字段)
-     */
-    /**
-     * 备用字段B(站内受阻容量,不需要页面显示)
-     */
-    /**
-     * 备用字段C(用于绿能场站编号)
-     */
+
     /**
      * 场站编号(运维标识,主键)
      */

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomIDGenerator.java

@@ -17,7 +17,7 @@ public class CustomIDGenerator extends IdentityGenerator {
     public Serializable generate(SharedSessionContractImplementor s, Object obj) throws HibernateException {
         Serializable id = s.getEntityPersister(null, obj).getClassMetadata().getIdentifier(obj, s);
 
-        if (id != null && Integer.valueOf(id.toString()) > 0) {
+        if (id != null && Integer.parseInt(id.toString()) > 0) {
             return id;
         } else {
             return super.generate(s, obj);

+ 4 - 5
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomUUIDGenerator.java

@@ -18,11 +18,10 @@ public class CustomUUIDGenerator extends IdGenerator {
     @Override
     public Serializable generate(SharedSessionContractImplementor s, Object obj) throws HibernateException {
         Serializable id = s.getEntityPersister(null, obj).getClassMetadata().getIdentifier(obj, s);
-        if (id != null && !id.toString().isEmpty()) {
-        } else {
-            id=super.generate(s, obj);
-            log.debug("新生成的uuid="+id.toString());
+        if (id == null || id.toString().isEmpty()) {
+            id = super.generate(s, obj);
+            log.debug("新生成的uuid=" + id.toString());
         }
-	    return id;
+        return id;
     }
 }

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzBlobTriggersEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_blob_triggers", catalog = "")
+@Table(name = "qrtz_blob_triggers")
 @IdClass(QrtzBlobTriggersEntityPK.class)
 public class QrtzBlobTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCalendarsEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_calendars", catalog = "")
+@Table(name = "qrtz_calendars")
 @IdClass(QrtzCalendarsEntityPK.class)
 public class QrtzCalendarsEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCronTriggersEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_cron_triggers", catalog = "")
+@Table(name = "qrtz_cron_triggers")
 @IdClass(QrtzCronTriggersEntityPK.class)
 public class QrtzCronTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzFiredTriggersEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_fired_triggers", catalog = "")
+@Table(name = "qrtz_fired_triggers")
 @IdClass(QrtzFiredTriggersEntityPK.class)
 public class QrtzFiredTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzLocksEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_locks", catalog = "")
+@Table(name = "qrtz_locks")
 @IdClass(QrtzLocksEntityPK.class)
 public class QrtzLocksEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzPausedTriggerGrpsEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_paused_trigger_grps", catalog = "")
+@Table(name = "qrtz_paused_trigger_grps")
 @IdClass(QrtzPausedTriggerGrpsEntityPK.class)
 public class QrtzPausedTriggerGrpsEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSchedulerStateEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_scheduler_state", catalog = "")
+@Table(name = "qrtz_scheduler_state")
 @IdClass(QrtzSchedulerStateEntityPK.class)
 public class QrtzSchedulerStateEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpleTriggersEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_simple_triggers", catalog = "")
+@Table(name = "qrtz_simple_triggers")
 @IdClass(QrtzSimpleTriggersEntityPK.class)
 public class QrtzSimpleTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpropTriggersEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_simprop_triggers", catalog = "")
+@Table(name = "qrtz_simprop_triggers")
 @IdClass(QrtzSimpropTriggersEntityPK.class)
 public class QrtzSimpropTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzTriggersEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_triggers", catalog = "")
+@Table(name = "qrtz_triggers")
 @IdClass(QrtzTriggersEntityPK.class)
 public class QrtzTriggersEntity {
     private String schedName;

+ 40 - 46
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/job/BaseJob.java

@@ -21,55 +21,49 @@ import org.springframework.security.core.context.SecurityContextHolder;
 @Slf4j
 public abstract class BaseJob implements Job {
 
-	BaseService baseService;
+    BaseService baseService;
 
-	@Autowired
-	public void setBaseService(BaseService baseService) {
-		this.baseService = baseService;
-	}
+    @Autowired
+    public void setBaseService(BaseService baseService) {
+        this.baseService = baseService;
+    }
 
-	@Override
-	public void execute(JobExecutionContext context) {
+    @Override
+    public void execute(JobExecutionContext context) {
 
-		String method = this.getClass().getName() + ".execute(JobDataMap jobDataMap)";// 执行方法
-		log.info("定时任务:" + method + ",执行开始");
-		String parameter = "";// 参数
-		String errorInfo = "";
-		boolean process;// 执行结果
-		try {
-			// 设置系统用户为job
-			Authentication auth = new UsernamePasswordAuthenticationToken("quartzJob", null);
-			SecurityContextHolder.getContext().setAuthentication(auth);
-			JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
-			parameter = JSONArray.fromObject(jobDataMap).toString();
-			process = this.execute(jobDataMap);
-		} catch (RuntimeException e) {
-			errorInfo = "定时任务执行失败" + e.getMessage();
-			log.error("定时任务执行失败", e);
-			process = false;
-		}
+        String method = this.getClass().getName() + ".execute(JobDataMap jobDataMap)";// 执行方法
+        log.info("定时任务:" + method + ",执行开始");
+        String parameter = "";// 参数
+        boolean process;// 执行结果
+        try {
+            // 设置系统用户为job
+            Authentication auth = new UsernamePasswordAuthenticationToken("quartzJob", null);
+            SecurityContextHolder.getContext().setAuthentication(auth);
+            JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
+            parameter = JSONArray.fromObject(jobDataMap).toString();
+            process = this.execute(jobDataMap);
+        } catch (RuntimeException e) {
+            log.error("定时任务执行失败", e);
+            process = false;
+        }
 
-		if (log.isDebugEnabled()) {
-			log.debug("执行方法:" + method);
-			log.debug("参数:" + parameter);
-			log.debug("执行结果:" + process);
-		}
-		if (!process) {// 如果执行失败,进行告警
-			// 进行告警
-			String name = "定时任务执行失败";
-			String describe = "执行类:" + method + "/r/n参数:" + parameter;
-			String solution = "请检查定时任务";
-			//            this.baseService.saveSysAlarm(AlarmTypeEnum., name, describe,
-			//                SysAlarmPritorityEnum.AlarmPritorityMedium.name(), errorInfo, solution);
-		}
-		log.info("定时任务:" + method + ",执行完成");
-	}
+        if (log.isDebugEnabled()) {
+            log.debug("执行方法:" + method);
+            log.debug("参数:" + parameter);
+            log.debug("执行结果:" + process);
+        }
+        if (!process) {// 如果执行失败,进行告警
+            // 进行告警
+            log.error("定时任务:" + method + ",执行失败");
+        }
+        log.info("定时任务:" + method + ",执行完成");
+    }
 
-	/**
-	 * 任务执行方法
-	 *
-	 * @param jobDataMap 任务参数
-	 * @return 任务执行结果是否成功
-	 */
-	public abstract boolean execute(JobDataMap jobDataMap);
+    /**
+     * 任务执行方法
+     *
+     * @param jobDataMap 任务参数
+     * @return 任务执行结果是否成功
+     */
+    public abstract boolean execute(JobDataMap jobDataMap);
 }

+ 19 - 18
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/E63UploadFileRuleService.java

@@ -32,10 +32,11 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
      * @param fileType
      * @return
      */
+    @Override
     public List<String> getShouldFile(ElectricField electricFieldInfo, Date date, String fileType, String cronStr) {
         // 计算开始结束时间
         super.caleTime(date);
-        Long startTime = 0L;
+        long startTime;
         String fileName = "";
         List<String> shouldFileNameList = new ArrayList<>();
         Date currentDate = new Date();
@@ -71,21 +72,21 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
             case "E2":
                 int cdqUpMin = 0;
                 try {
-                    Optional<SysParameter> optional = sysParameterRepository.findBySysKeyAndStationCode("CDQ_UP_MIN",electricFieldInfo.getStationCode());
+                    Optional<SysParameter> optional = sysParameterRepository.findBySysKeyAndStationCode("CDQ_UP_MIN", electricFieldInfo.getStationCode());
                     cdqUpMin = Integer.parseInt(optional.map(SysParameter::getSysValue).orElse("0"));
                 } catch (RuntimeException e) {
                     e.printStackTrace();
                 }
                 // 可用超短期
-                midNightTime = midNightTime + cdqUpMin * 1000 * 60;
-                endTime = endTime + cdqUpMin * 1000 * 60;
-                for (Long tempDateTime = midNightTime; tempDateTime < endTime; tempDateTime = tempDateTime + 1 * 60 * 1000) {
-                    if (tempDateTime % (15 * 60 * 1000)==0){
+                midNightTime = midNightTime + (long) cdqUpMin * 1000 * 60;
+                endTime = endTime + (long) cdqUpMin * 1000 * 60;
+                for (long tempDateTime = midNightTime; tempDateTime < endTime; tempDateTime = tempDateTime + 60 * 1000) {
+                    if (tempDateTime % (15 * 60 * 1000) == 0) {
                         // 整15分钟
                         if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                             // 此判断为了当前时刻应上报的文件还没执行定时,产生的多余的应上报
                             if (cronStr != null && !"".equals(cronStr)) {
-                                if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr,15)) {
+                                if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr, 15)) {
                                     continue;
                                 }
                             }
@@ -105,11 +106,10 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
-                            if (cronStr != null && !"".equals(cronStr)) {
-                                if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr, 15)) {
-                                    continue;
-                                }
+                            if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr, 15)) {
+                                continue;
                             }
+
                         }
                     }
                     fileName = getFileNameRule(electricFieldInfo, "E27", tempDateTime + 15 * 60 * 1000);
@@ -298,7 +298,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E34":
                 // 超短期日志
-                for (Long tempDateTime = super.midNightTime - 15 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 15 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 15 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 15 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -313,7 +313,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E35":
                 // 超短期可用日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -328,7 +328,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E36":
                 // 理论功率日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -343,7 +343,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E37":
                 // 气象站日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -358,7 +358,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E38":
                 // 测风塔日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -373,7 +373,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E39":
                 // 逆变器日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -388,7 +388,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E40":
                 // 风机日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -444,6 +444,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
      * @param fileNameTime
      * @return
      */
+    @Override
     public String getFileNameRule(ElectricField electricFieldInfo, String fileType, Long fileNameTime) {
         String fileName = "";
         switch (fileType) {

+ 2 - 2
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/IUploadFileRuleService.java

@@ -16,10 +16,10 @@ public interface IUploadFileRuleService {
     /**
      * 指定日期应该上报文件名称
      */
-    public List<String> getShouldFile(ElectricField electricFieldInfo, Date date, String fileType, String cronStr);
+    List<String> getShouldFile(ElectricField electricFieldInfo, Date date, String fileType, String cronStr);
 
     /**
      * 文件名称生成规则
      */
-    public String getFileNameRule(ElectricField electricFieldInfo, String fileType, Long fileNameTime);
+    String getFileNameRule(ElectricField electricFieldInfo, String fileType, Long fileNameTime);
 }

+ 2 - 2
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/UploadFileRuleCommonService.java

@@ -21,10 +21,10 @@ public class UploadFileRuleCommonService {
     public void caleTime(Date inputParamDate) {
         Date nowDate = new Date();
         // 今日凌晨时间
-        Long nowNightTime = DateMomentUtil.getDayStartTime(nowDate.getTime());
+        long nowNightTime = DateMomentUtil.getDayStartTime(nowDate.getTime());
         // 指定日期的凌晨时间
         midNightTime = DateMomentUtil.getDayStartTime(inputParamDate.getTime());
-        if (nowNightTime.longValue() != midNightTime.longValue()) {
+        if (nowNightTime != midNightTime) {
             endTime = midNightTime + 1000 * 60 * 60 * 24;
         } else {
             endTime = nowDate.getTime();

+ 74 - 167
ipfcst-common/ipfcst-common-data/src/main/java/org/hibernate/cfg/PropertyContainer.java

@@ -30,15 +30,11 @@ import java.util.*;
  * A helper class to keep the {@code XProperty}s of a class ordered by access type.
  *
  * @author Hardy Ferentschik
- *
+ * <p>
  * 修改treeMap 为LinkedHashMap 使字段生成顺序与实体定义顺序一致
  */
 @SuppressWarnings("unused")
 class PropertyContainer {
-//
-//    static {
-//        System.setProperty("jboss.i18n.generate-proxies", "true");
-//    }
 
     private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, org.hibernate.cfg.PropertyContainer.class.getName());
 
@@ -60,7 +56,7 @@ class PropertyContainer {
         this.xClass = clazz;
         this.entityAtStake = entityAtStake;
 
-        if ( defaultClassLevelAccessType == org.hibernate.cfg.AccessType.DEFAULT ) {
+        if (defaultClassLevelAccessType == org.hibernate.cfg.AccessType.DEFAULT) {
             // this is effectively what the old code did when AccessType.DEFAULT was passed in
             // to getProperties(AccessType) from AnnotationBinder and InheritanceState
             defaultClassLevelAccessType = org.hibernate.cfg.AccessType.PROPERTY;
@@ -76,13 +72,13 @@ class PropertyContainer {
 
         this.persistentAttributeMap = new LinkedHashMap<>();
 
-        final List<XProperty> fields = xClass.getDeclaredProperties( org.hibernate.cfg.AccessType.FIELD.getType() );
+        final List<XProperty> fields = xClass.getDeclaredProperties(org.hibernate.cfg.AccessType.FIELD.getType());
 
-        final List<XProperty> getters = xClass.getDeclaredProperties( org.hibernate.cfg.AccessType.PROPERTY.getType() );
+        final List<XProperty> getters = xClass.getDeclaredProperties(org.hibernate.cfg.AccessType.PROPERTY.getType());
 
-        preFilter( fields, getters );
+        preFilter(fields, getters);
 
-        final Map<String,XProperty> persistentAttributesFromGetters = new HashMap<>();
+        final Map<String, XProperty> persistentAttributesFromGetters = new HashMap<>();
 
         collectPersistentAttributesUsingLocalAccessType(
                 persistentAttributeMap,
@@ -100,17 +96,17 @@ class PropertyContainer {
 
     private void preFilter(List<XProperty> fields, List<XProperty> getters) {
         Iterator<XProperty> propertyIterator = fields.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty property = propertyIterator.next();
-            if ( mustBeSkipped( property ) ) {
+            if (mustBeSkipped(property)) {
                 propertyIterator.remove();
             }
         }
 
         propertyIterator = getters.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty property = propertyIterator.next();
-            if ( mustBeSkipped( property ) ) {
+            if (mustBeSkipped(property)) {
                 propertyIterator.remove();
             }
         }
@@ -118,31 +114,31 @@ class PropertyContainer {
 
     private void collectPersistentAttributesUsingLocalAccessType(
             LinkedHashMap<String, XProperty> persistentAttributeMap,
-            Map<String,XProperty> persistentAttributesFromGetters,
+            Map<String, XProperty> persistentAttributesFromGetters,
             List<XProperty> fields,
             List<XProperty> getters) {
 
         // Check fields...
         Iterator<XProperty> propertyIterator = fields.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty xProperty = propertyIterator.next();
-            final Access localAccessAnnotation = xProperty.getAnnotation( Access.class );
-            if ( localAccessAnnotation == null
-                    || localAccessAnnotation.value() != javax.persistence.AccessType.FIELD ) {
+            final Access localAccessAnnotation = xProperty.getAnnotation(Access.class);
+            if (localAccessAnnotation == null
+                    || localAccessAnnotation.value() != javax.persistence.AccessType.FIELD) {
                 continue;
             }
 
             propertyIterator.remove();
-            persistentAttributeMap.put( xProperty.getName(), xProperty );
+            persistentAttributeMap.put(xProperty.getName(), xProperty);
         }
 
         // Check getters...
         propertyIterator = getters.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty xProperty = propertyIterator.next();
-            final Access localAccessAnnotation = xProperty.getAnnotation( Access.class );
-            if ( localAccessAnnotation == null
-                    || localAccessAnnotation.value() != javax.persistence.AccessType.PROPERTY ) {
+            final Access localAccessAnnotation = xProperty.getAnnotation(Access.class);
+            if (localAccessAnnotation == null
+                    || localAccessAnnotation.value() != javax.persistence.AccessType.PROPERTY) {
                 continue;
             }
 
@@ -151,60 +147,59 @@ class PropertyContainer {
             final String name = xProperty.getName();
 
             // HHH-10242 detect registration of the same property getter twice - eg boolean isId() + UUID getId()
-            final XProperty previous = persistentAttributesFromGetters.get( name );
-            if ( previous != null ) {
+            final XProperty previous = persistentAttributesFromGetters.get(name);
+            if (previous != null) {
                 throw new org.hibernate.boot.MappingException(
                         LOG.ambiguousPropertyMethods(
                                 xClass.getName(),
-                                HCANNHelper.annotatedElementSignature( previous ),
-                                HCANNHelper.annotatedElementSignature( xProperty )
+                                HCANNHelper.annotatedElementSignature(previous),
+                                HCANNHelper.annotatedElementSignature(xProperty)
                         ),
-                        new Origin( SourceType.ANNOTATION, xClass.getName() )
+                        new Origin(SourceType.ANNOTATION, xClass.getName())
                 );
             }
 
-            persistentAttributeMap.put( name, xProperty );
-            persistentAttributesFromGetters.put( name, xProperty );
+            persistentAttributeMap.put(name, xProperty);
+            persistentAttributesFromGetters.put(name, xProperty);
         }
     }
 
     private void collectPersistentAttributesUsingClassLevelAccessType(
             LinkedHashMap<String, XProperty> persistentAttributeMap,
-            Map<String,XProperty> persistentAttributesFromGetters,
+            Map<String, XProperty> persistentAttributesFromGetters,
             List<XProperty> fields,
             List<XProperty> getters) {
-        if ( classLevelAccessType == org.hibernate.cfg.AccessType.FIELD ) {
-            for ( XProperty field : fields ) {
-                if ( persistentAttributeMap.containsKey( field.getName() ) ) {
+        if (classLevelAccessType == org.hibernate.cfg.AccessType.FIELD) {
+            for (XProperty field : fields) {
+                if (persistentAttributeMap.containsKey(field.getName())) {
                     continue;
                 }
 
-                persistentAttributeMap.put( field.getName(), field );
+                persistentAttributeMap.put(field.getName(), field);
             }
-        }
-        else {
-            for ( XProperty getter : getters ) {
+        } else {
+            for (XProperty getter : getters) {
                 final String name = getter.getName();
 
                 // HHH-10242 detect registration of the same property getter twice - eg boolean isId() + UUID getId()
-                final XProperty previous = persistentAttributesFromGetters.get( name );
-                if ( previous != null ) {
+                final XProperty previous = persistentAttributesFromGetters.get(name);
+                if (previous != null) {
                     throw new org.hibernate.boot.MappingException(
                             LOG.ambiguousPropertyMethods(
                                     xClass.getName(),
-                                    HCANNHelper.annotatedElementSignature( previous ),
-                                    HCANNHelper.annotatedElementSignature( getter )
+                                    HCANNHelper.annotatedElementSignature(previous),
+                                    HCANNHelper.annotatedElementSignature(getter)
                             ),
-                            new Origin( SourceType.ANNOTATION, xClass.getName() )
+                            new Origin(SourceType.ANNOTATION, xClass.getName())
                     );
                 }
 
-                if ( persistentAttributeMap.containsKey( name ) ) {
+                if (persistentAttributeMap.containsKey(name)) {
                     continue;
                 }
 
-                persistentAttributeMap.put( getter.getName(), getter );
-                persistentAttributesFromGetters.put( name, getter );
+                persistentAttributeMap.put(getter.getName(), getter);
+                persistentAttributesFromGetters.put(name, getter);
             }
         }
     }
@@ -223,96 +218,19 @@ class PropertyContainer {
 
     public Collection<XProperty> getProperties() {
         assertTypesAreResolvable();
-        return Collections.unmodifiableCollection( persistentAttributeMap.values() );
+        return Collections.unmodifiableCollection(persistentAttributeMap.values());
     }
 
     private void assertTypesAreResolvable() {
-        for ( XProperty xProperty : persistentAttributeMap.values() ) {
-            if ( !xProperty.isTypeResolved() && !discoverTypeWithoutReflection( xProperty ) ) {
-                String msg = "Property " + StringHelper.qualify( xClass.getName(), xProperty.getName() ) +
+        for (XProperty xProperty : persistentAttributeMap.values()) {
+            if (!xProperty.isTypeResolved() && !discoverTypeWithoutReflection(xProperty)) {
+                String msg = "Property " + StringHelper.qualify(xClass.getName(), xProperty.getName()) +
                         " has an unbound type and no explicit target entity. Resolve this Generic usage issue" +
                         " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type";
-                throw new AnnotationException( msg );
+                throw new AnnotationException(msg);
             }
         }
     }
-//
-//	private void considerExplicitFieldAndPropertyAccess() {
-//		for ( XProperty property : fieldAccessMap.values() ) {
-//			Access access = property.getAnnotation( Access.class );
-//			if ( access == null ) {
-//				continue;
-//			}
-//
-//			// see "2.3.2 Explicit Access Type" of JPA 2 spec
-//			// the access type for this property is explicitly set to AccessType.FIELD, hence we have to
-//			// use field access for this property even if the default access type for the class is AccessType.PROPERTY
-//			AccessType accessType = AccessType.getAccessStrategy( access.value() );
-//            if (accessType == AccessType.FIELD) {
-//				propertyAccessMap.put(property.getName(), property);
-//			}
-//            else {
-//				LOG.debug( "Placing @Access(AccessType.FIELD) on a field does not have any effect." );
-//			}
-//		}
-//
-//		for ( XProperty property : propertyAccessMap.values() ) {
-//			Access access = property.getAnnotation( Access.class );
-//			if ( access == null ) {
-//				continue;
-//			}
-//
-//			AccessType accessType = AccessType.getAccessStrategy( access.value() );
-//
-//			// see "2.3.2 Explicit Access Type" of JPA 2 spec
-//			// the access type for this property is explicitly set to AccessType.PROPERTY, hence we have to
-//			// return use method access even if the default class access type is AccessType.FIELD
-//            if (accessType == AccessType.PROPERTY) {
-//				fieldAccessMap.put(property.getName(), property);
-//			}
-//            else {
-//				LOG.debug( "Placing @Access(AccessType.PROPERTY) on a field does not have any effect." );
-//			}
-//		}
-//	}
-
-//	/**
-//	 * Retrieves all properties from the {@code xClass} with the specified access type. This method does not take
-//	 * any jpa access rules/annotations into account yet.
-//	 *
-//	 * @param access The access type - {@code AccessType.FIELD}  or {@code AccessType.Property}
-//	 *
-//	 * @return A maps of the properties with the given access type keyed against their property name
-//	 */
-//	private TreeMap<String, XProperty> initProperties(AccessType access) {
-//		if ( !( AccessType.PROPERTY.equals( access ) || AccessType.FIELD.equals( access ) ) ) {
-//			throw new IllegalArgumentException( "Access type has to be AccessType.FIELD or AccessType.Property" );
-//		}
-//
-//		//order so that property are used in the same order when binding native query
-//		TreeMap<String, XProperty> propertiesMap = new TreeMap<String, XProperty>();
-//		List<XProperty> properties = xClass.getDeclaredProperties( access.getType() );
-//		for ( XProperty property : properties ) {
-//			if ( mustBeSkipped( property ) ) {
-//				continue;
-//			}
-//			// HHH-10242 detect registration of the same property twice eg boolean isId() + UUID getId()
-//			XProperty oldProperty = propertiesMap.get( property.getName() );
-//			if ( oldProperty != null ) {
-//				throw new org.hibernate.boot.MappingException(
-//						LOG.ambiguousPropertyMethods(
-//								xClass.getName(),
-//								HCANNHelper.annotatedElementSignature( oldProperty ),
-//								HCANNHelper.annotatedElementSignature( property )
-//						),
-//						new Origin( SourceType.ANNOTATION, xClass.getName() )
-//				);
-//			}
-//
-//			propertiesMap.put( property.getName(), property );
-//		}
-//		return propertiesMap;
-//	}
 
     @SuppressWarnings("deprecation")
     private org.hibernate.cfg.AccessType determineLocalClassDefinedAccessStrategy() {
@@ -321,75 +239,64 @@ class PropertyContainer {
         org.hibernate.cfg.AccessType hibernateDefinedAccessType = org.hibernate.cfg.AccessType.DEFAULT;
         org.hibernate.cfg.AccessType jpaDefinedAccessType = org.hibernate.cfg.AccessType.DEFAULT;
 
-        org.hibernate.annotations.AccessType accessType = xClass.getAnnotation( org.hibernate.annotations.AccessType.class );
-        if ( accessType != null ) {
-            hibernateDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy( accessType.value() );
+        org.hibernate.annotations.AccessType accessType = xClass.getAnnotation(org.hibernate.annotations.AccessType.class);
+        if (accessType != null) {
+            hibernateDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy(accessType.value());
         }
 
-        Access access = xClass.getAnnotation( Access.class );
-        if ( access != null ) {
-            jpaDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy( access.value() );
+        Access access = xClass.getAnnotation(Access.class);
+        if (access != null) {
+            jpaDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy(access.value());
         }
 
-        if ( hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT
+        if (hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT
                 && jpaDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT
-                && hibernateDefinedAccessType != jpaDefinedAccessType ) {
+                && hibernateDefinedAccessType != jpaDefinedAccessType) {
             throw new MappingException(
                     "@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. "
             );
         }
 
-        if ( hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT ) {
+        if (hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT) {
             classDefinedAccessType = hibernateDefinedAccessType;
-        }
-        else {
+        } else {
             classDefinedAccessType = jpaDefinedAccessType;
         }
         return classDefinedAccessType;
     }
 
     private static boolean discoverTypeWithoutReflection(XProperty p) {
-        if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
+        if (p.isAnnotationPresent(OneToOne.class) && !p.getAnnotation(OneToOne.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( OneToMany.class ) && !p.getAnnotation( OneToMany.class )
+        } else if (p.isAnnotationPresent(OneToMany.class) && !p.getAnnotation(OneToMany.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( ManyToOne.class ) && !p.getAnnotation( ManyToOne.class )
+        } else if (p.isAnnotationPresent(ManyToOne.class) && !p.getAnnotation(ManyToOne.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( ManyToMany.class ) && !p.getAnnotation( ManyToMany.class )
+        } else if (p.isAnnotationPresent(ManyToMany.class) && !p.getAnnotation(ManyToMany.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
+        } else if (p.isAnnotationPresent(org.hibernate.annotations.Any.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( ManyToAny.class ) ) {
-            if ( !p.isCollection() && !p.isArray() ) {
-                throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
+        } else if (p.isAnnotationPresent(ManyToAny.class)) {
+            if (!p.isCollection() && !p.isArray()) {
+                throw new AnnotationException("@ManyToAny used on a non collection non array property: " + p.getName());
             }
             return true;
-        }
-        else if ( p.isAnnotationPresent( Type.class ) ) {
-            return true;
-        }
-        else if ( p.isAnnotationPresent( Target.class ) ) {
+        } else if (p.isAnnotationPresent(Type.class)) {
             return true;
-        }
-        return false;
+        } else return p.isAnnotationPresent(Target.class);
     }
 
     private static boolean mustBeSkipped(XProperty property) {
-        return property.isAnnotationPresent( Transient.class )
-                || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( property.getType().getName() )
-                || "org.hibernate.bytecode.internal.javassist.FieldHandler".equals( property.getType().getName() );
+        return property.isAnnotationPresent(Transient.class)
+                || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals(property.getType().getName())
+                || "org.hibernate.bytecode.internal.javassist.FieldHandler".equals(property.getType().getName());
     }
 }

+ 1 - 6
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SecurityAuthorizeConfigurerProvider.java

@@ -7,19 +7,14 @@ import org.springframework.stereotype.Component;
 
 /**
  * Security身份认证相关的授权配置
- *
  */
 @Component
-@Order(Integer.MAX_VALUE) // 值越小加载越优先,值越大加载越靠后
+@Order() // 值越小加载越优先,值越大加载越靠后
 public class SecurityAuthorizeConfigurerProvider implements AuthorizeConfigurerProvider {
 
 
-
-
     @Override
     public void confiure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
-       /* config.antMatchers(""
-        ).permitAll(); // 放行登录页面访问*/
 
         // 其他请求都要通过身份认证
         config.anyRequest().authenticated();

+ 7 - 6
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SysAuthorizeConfigurerManager.java

@@ -1,6 +1,5 @@
 package com.jiayue.ipfcst.common.security.authorize;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
 import org.springframework.stereotype.Component;
@@ -9,18 +8,20 @@ import java.util.List;
 
 /**
  * 管理security配置
- *
- *
  */
 @Component
-public class SysAuthorizeConfigurerManager  {
+public class SysAuthorizeConfigurerManager {
 
-    @Autowired
+    final
     List<AuthorizeConfigurerProvider> authorizeConfigurerProviders;
 
+    public SysAuthorizeConfigurerManager(List<AuthorizeConfigurerProvider> authorizeConfigurerProviders) {
+        this.authorizeConfigurerProviders = authorizeConfigurerProviders;
+    }
+
     // 将一个个AuthorizeConfigurerProvider的实现类,传入配置的参数 ExpressionInterceptUrlRegistry
     public void configure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
-        for(AuthorizeConfigurerProvider provider: authorizeConfigurerProviders) {
+        for (AuthorizeConfigurerProvider provider : authorizeConfigurerProviders) {
             provider.confiure(config);
         }
     }

+ 0 - 8
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SystemAuthorizeConfigurerProvider.java

@@ -6,19 +6,11 @@ import org.springframework.stereotype.Component;
 
 /**
  * Security授权配置
- *
  */
 @Component
 public class SystemAuthorizeConfigurerProvider implements AuthorizeConfigurerProvider {
 
     @Override
     public void confiure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
-//        // 有 sys:user 权限的可以访问任意请求方式的/role
-//        config.antMatchers("/user").hasAuthority("sys:user")
-//        // 有 sys:role 权限的可以访问 get方式的/role
-//        .antMatchers(HttpMethod.GET,"/role").hasAuthority("sys:role")
-//        .antMatchers(HttpMethod.GET, "/permission")
-//        // ADMIN 注意角色会在前面加上前缀 ROLE_ , 也就是完整的是 ROLE_ADMIN, ROLE_ROOT
-//        .access("hasAuthority('sys:permission') or hasAnyRole('ADMIN', 'ROOT')");
     }
 }

+ 4 - 4
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/filter/JwtAuthenticationTokenFilter.java

@@ -33,14 +33,14 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
 
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws
-        ServletException, IOException {
-         SecurityContextHolder.getContext().getAuthentication();
+            ServletException, IOException {
+        SecurityContextHolder.getContext().getAuthentication();
         String token = request.getHeader("Authorization");
         if (!StringUtils.isEmpty(token)) {
             String username = jwtTokenUtil.getUsernameFromToken(token);
-            if (username != null && SecurityContextHolder.getContext().getAuthentication() == null){
+            if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
                 UserDetails userDetails = jwtUserDetailsServiceImpl.loadUserByUsername(username);
-                if (jwtTokenUtil.validateToken(token, userDetails)){
+                if (jwtTokenUtil.validateToken(token, userDetails)) {
                     // 将用户信息存入 authentication,方便后续校验
                     UsernamePasswordAuthenticationToken
                             authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());

+ 9 - 13
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationFailureHandler.java

@@ -4,12 +4,10 @@ import cn.hutool.json.JSONUtil;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.security.user.SysUser;
 import com.jiayue.ipfcst.common.security.user.SysUserService;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
 import org.springframework.stereotype.Component;
 
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -20,26 +18,25 @@ import java.io.IOException;
 @Component("customAuthenticationFailureHandler")
 public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
 
-    @Autowired
+    final
     SysUserService sysUserService;
 
+    public CustomAuthenticationFailureHandler(SysUserService sysUserService) {
+        this.sysUserService = sysUserService;
+    }
+
     @Override
     public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
-                                        AuthenticationException e) throws IOException, ServletException {
+                                        AuthenticationException e) throws IOException {
         String username = httpServletRequest.getParameter("username");
-        String errorTips = "";
+        String errorTips;
         SysUser user = sysUserService.findByUserName(username);
-        if (username.equals("admin") || username.equals("consumer")) {
-            errorTips = "用户名或密码不正常";
-        } else {
-            errorTips = "用户名或密码不正常";
-        }
 
         if (user == null) {
             errorTips = "用户名或密码不正常";
         } else {
             if (user.getStatus().equals("1")) {
-                Long xz = (user.getLockTime() + 300000 - System.currentTimeMillis()) / 1000;
+                long xz = (user.getLockTime() + 300000 - System.currentTimeMillis()) / 1000;
                 if (xz < 0) {
                     user.setStatus("0");
                     user.setPwdErrNum(1);
@@ -56,14 +53,13 @@ public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationF
                     errorTips = "用户名或密码不正常,还有" + (errCount - errNum) + "次机会";
                     errNum++;
                     user.setPwdErrNum(errNum);
-                    sysUserService.save(user);
                 } else {
                     errorTips = "用户锁定,稍后再试";
                     user.setPwdErrNum(0);
                     user.setStatus("1");
                     user.setLockTime(System.currentTimeMillis());
-                    sysUserService.save(user);
                 }
+                sysUserService.save(user);
 
             }
 

+ 8 - 6
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationSuccessHandler.java

@@ -5,14 +5,12 @@ import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.security.user.SysUser;
 import com.jiayue.ipfcst.common.security.user.SysUserService;
 import com.jiayue.ipfcst.common.security.util.JwtTokenUtil;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
 import org.springframework.stereotype.Component;
 
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -23,14 +21,18 @@ import java.io.IOException;
 @Component("customAuthenticationSuccessHandler")
 public class CustomAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
 
-    @Autowired
-    private JwtTokenUtil jwtTokenUtil;
+    private final JwtTokenUtil jwtTokenUtil;
 
-    @Autowired
+    final
     SysUserService sysUserService;
 
+    public CustomAuthenticationSuccessHandler(JwtTokenUtil jwtTokenUtil, SysUserService sysUserService) {
+        this.jwtTokenUtil = jwtTokenUtil;
+        this.sysUserService = sysUserService;
+    }
+
     @Override
-    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
+    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException {
         User user = (User) authentication.getPrincipal();
         SecurityContextHolder.getContext().setAuthentication(authentication);
         String token = jwtTokenUtil.generateToken(user);

+ 4 - 18
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/JwtUserDetailsServiceImpl.java

@@ -26,24 +26,12 @@ public class JwtUserDetailsServiceImpl implements UserDetailsService {
 
     @Override
     public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
-        User user = null;
-        String password = null;
+        User user;
+        String password;
         SysUser sysUser = sysUserService.findByUserName(username);
-//        if ("admin".equals(username)) {
-//            if (sysUser == null || sysUser.getUserName().isEmpty()) {
-//                sysUser = new SysUser();
-//                sysUser.setUserName("admin");
-//                sysUser.setPassWord("!QAZ2wsx");
-//                sysUser.setName("admin");
-//                sysUser.setPwdErrNum(0);
-//                sysUser.setLockTime(0L);
-//                sysUser.setStatus("0");
-//                sysUserService.save(sysUser);
-//            }
-//        }
-        if(sysUser == null){
+        if (sysUser == null) {
             password = passwordEncoder.encode("sda21dsad13214sda22dsa@#$#$%!ds1d1");
-        }else {
+        } else {
             password = passwordEncoder.encode(sysUser.getPassWord());
             if (sysUser.getStatus().equals("1") && (System.currentTimeMillis() - sysUser.getLockTime()) < 300000) {
                 password = passwordEncoder.encode("sda21dsad13214sda22dsa@#$#$%!ds1d1");
@@ -55,8 +43,6 @@ public class JwtUserDetailsServiceImpl implements UserDetailsService {
         }
 
 
-
-
         user = new User(username, password, AuthorityUtils.commaSeparatedStringToAuthorityList(username.toUpperCase()));
         return user;
     }

+ 6 - 3
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/SysUserService.java

@@ -1,7 +1,6 @@
 package com.jiayue.ipfcst.common.security.user;
 
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -17,9 +16,13 @@ import java.util.List;
 @Slf4j
 public class SysUserService {
 
-    @Autowired
+    final
     SysUserRepository sysUserRepository;
 
+    public SysUserService(SysUserRepository sysUserRepository) {
+        this.sysUserRepository = sysUserRepository;
+    }
+
     public SysUser findByUserName(String username) {
         return sysUserRepository.findByUserName(username);
     }
@@ -36,7 +39,7 @@ public class SysUserService {
     public void delete(String ids) {
         if (!StringUtils.isEmpty(ids)) {
             String[] idArray = ids.split(",");
-            if (idArray != null && idArray.length > 0) {
+            if (idArray.length > 0) {
                 for (String id : idArray) {
                     this.sysUserRepository.deleteById(Integer.valueOf(id));
                     log.info("删除用户ID为[" + id + "]成功!");

+ 1 - 20
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/util/JwtTokenUtil.java

@@ -15,7 +15,6 @@ import java.util.Map;
 
 /**
  * 生成令牌,验证等等一些操作
- *
  */
 @Data
 @Component
@@ -63,7 +62,7 @@ public class JwtTokenUtil {
      * @return 令牌
      */
     public String generateToken(UserDetails userDetails) {
-        Map<String, Object> claims = new HashMap<String, Object>();
+        Map<String, Object> claims = new HashMap<>();
         claims.put(Claims.SUBJECT, userDetails.getUsername());
         claims.put(Claims.ISSUED_AT, new Date());
         return generateToken(claims);
@@ -103,24 +102,6 @@ public class JwtTokenUtil {
     }
 
     /**
-     * 刷新令牌
-     *
-     * @param token 原令牌
-     * @return 新令牌
-     */
-    public String refreshToken(String token) {
-        String refreshedToken;
-        try {
-            Claims claims = getClaimsFromToken(token);
-            claims.put(Claims.ISSUED_AT, new Date());
-            refreshedToken = generateToken(claims);
-        } catch (Exception e) {
-            refreshedToken = null;
-        }
-        return refreshedToken;
-    }
-
-    /**
      * 验证令牌
      *
      * @param token       令牌

+ 4 - 5
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java

@@ -18,7 +18,6 @@ import org.apache.commons.lang.time.DateUtils;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
@@ -69,10 +68,9 @@ public class E63UploadFileService extends BaseUploadFileService {
 
   private final PowerStationStatusDataRepository powerStationStatusDataRepository;
 
-  @Autowired
-  private RedisUtils redisUtils;
+  private final RedisUtils redisUtils;
 
-  public E63UploadFileService(VelocityEngine velocityEngine, ForecastPowerShortTermService forecastPowerShortTermService, ForecastPowerUltraShortTermService forecastPowerUltraShortTermService, E63UploadFileRuleService e63UploadFileRuleService, WeatherStationInfoRepository weatherStationInfoRepository, WindTurbineInfoRepository windTurbineInfoRepository, WeatherStationStatusDataRepository weatherStationStatusDataRepository, WindTowerInfoRepository windTowerInfoRepository, WindTowerStatusDataRepository windTowerStatusDataRepository, NwpRepository nwpRepository, InverterInfoRepository inverterInfoRepository, WindTurbineStatusDataRepository windTurbineStatusDataRepository, InverterStatusDataRepository inverterStatusDataRepository, PowerStationStatusDataRepository powerStationStatusDataRepository) {
+  public E63UploadFileService(VelocityEngine velocityEngine, ForecastPowerShortTermService forecastPowerShortTermService, ForecastPowerUltraShortTermService forecastPowerUltraShortTermService, E63UploadFileRuleService e63UploadFileRuleService, WeatherStationInfoRepository weatherStationInfoRepository, WindTurbineInfoRepository windTurbineInfoRepository, WeatherStationStatusDataRepository weatherStationStatusDataRepository, WindTowerInfoRepository windTowerInfoRepository, WindTowerStatusDataRepository windTowerStatusDataRepository, NwpRepository nwpRepository, InverterInfoRepository inverterInfoRepository, WindTurbineStatusDataRepository windTurbineStatusDataRepository, InverterStatusDataRepository inverterStatusDataRepository, PowerStationStatusDataRepository powerStationStatusDataRepository, RedisUtils redisUtils) {
     this.velocityEngine = velocityEngine;
     this.forecastPowerShortTermService = forecastPowerShortTermService;
     this.forecastPowerUltraShortTermService = forecastPowerUltraShortTermService;
@@ -87,6 +85,7 @@ public class E63UploadFileService extends BaseUploadFileService {
     this.windTurbineStatusDataRepository = windTurbineStatusDataRepository;
     this.inverterStatusDataRepository = inverterStatusDataRepository;
     this.powerStationStatusDataRepository = powerStationStatusDataRepository;
+    this.redisUtils = redisUtils;
   }
 
   /**
@@ -528,7 +527,7 @@ public class E63UploadFileService extends BaseUploadFileService {
       File file = super.createTempFile(fileName);
       //青海要求 直=总-散;但是当散辐射大于总辐射时直辐射为负数不符合该规则。所以比较总直散三个值,用最大的当总辐射去减去
       log.info(electricFieldInfo.getStationCode() + "qxz实际值 总GlobalR:" + globalR + " 直DirectR:" + directR + " 散DiffuseR:" + diffuseR);
-      if (globalR.compareTo(diffuseR) == -1) {
+      if (globalR.compareTo(diffuseR) < 0) {
         //当散辐射大于总辐射时,数值互换
         BigDecimal a = globalR;
         globalR = diffuseR;

+ 17 - 8
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadService.java

@@ -17,7 +17,6 @@ import com.jiayue.ipfcst.common.data.repository.UploadURLRepository;
 import com.jiayue.ipfcst.fileupload.config.AppenderFactory;
 import com.jiayue.ipfcst.fileupload.util.FileConstant;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
@@ -32,21 +31,31 @@ import java.util.stream.Collectors;
 @Service
 @Slf4j
 public class FtpUploadService {
-  @Autowired
+  final
   UploadFileChannelService uploadFileChannelService;
-  @Autowired
+  final
   UploadFileLogRepository uploadFileLogRepository;
-  @Autowired
+  final
   UploadFileLogDetailRepository uploadFileLogDetailRepository;
-  @Autowired
+  final
   UploadObjectService uploadObjectService;
-  @Autowired
+  final
   FtpUploadTransactionService ftpUploadTransactionService;
-  @Autowired
+  final
   AppenderFactory appenderFactory;
-  @Autowired
+  final
   UploadURLRepository uploadURLRepository;
 
+  public FtpUploadService(UploadFileChannelService uploadFileChannelService, UploadFileLogRepository uploadFileLogRepository, UploadFileLogDetailRepository uploadFileLogDetailRepository, UploadObjectService uploadObjectService, FtpUploadTransactionService ftpUploadTransactionService, AppenderFactory appenderFactory, UploadURLRepository uploadURLRepository) {
+    this.uploadFileChannelService = uploadFileChannelService;
+    this.uploadFileLogRepository = uploadFileLogRepository;
+    this.uploadFileLogDetailRepository = uploadFileLogDetailRepository;
+    this.uploadObjectService = uploadObjectService;
+    this.ftpUploadTransactionService = ftpUploadTransactionService;
+    this.appenderFactory = appenderFactory;
+    this.uploadURLRepository = uploadURLRepository;
+  }
+
   /**
    * 开启FTP客户端上报文件
    */

+ 36 - 45
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadTransactionService.java

@@ -4,7 +4,6 @@ import ch.qos.logback.classic.Logger;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.ftp.Ftp;
 import cn.hutool.extra.ssh.Sftp;
-import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
 import com.jiayue.ipfcst.common.data.constant.enums.FileStatusEnum;
 import com.jiayue.ipfcst.common.data.entity.*;
 import com.jiayue.ipfcst.common.data.repository.UploadFileLogDetailRepository;
@@ -19,6 +18,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.*;
+import java.nio.charset.StandardCharsets;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -51,37 +51,34 @@ public class FtpUploadTransactionService extends BaseUploadFileService {
     fileUploadCount++;
     boolean isSuccess = false;
     String srcPath = FileUtil.getFileUploadPath() + File.separator + "process" + File.separator + keys[0] + File.separator + keys[1] + File.separator + keys[2];
-    Long st = DateTimeUtil.getMillisecondsSubDay();
     //明日凌晨
-    Long et = DateTimeUtil.getMillisecondsSubDay() + 1000 * 60 * 60 * 24 - 1;
     logger.info("准备上报:" + srcPath);
     try {
+      InputStreamReader isr = null;
+      InputStream uploadFileIs = null;
       if (ftp != null) {
-        InputStreamReader isr = null;
-        InputStream uploadFileIs = null;
         try {
-          isr = new InputStreamReader(new FileInputStream(srcPath), "UTF-8");
-          StringBuffer sb = new StringBuffer("");
-          int len1 = 0;
+          isr = new InputStreamReader(new FileInputStream(srcPath), StandardCharsets.UTF_8);
+          StringBuilder sb = new StringBuilder();
+          int len1;
           while ((len1 = isr.read()) != -1) {
             sb.append((char) len1);
           }
           isr.close();
           String str = sb.toString();
           uploadFileIs = new ByteArrayInputStream(str.getBytes(uploadObject.getUploadFileCharSetEnum().getMessage()));
-          String uploadFileName = new String(new File(srcPath).getName().getBytes("UTF-8"), uploadObject.getUploadFileCharSetEnum().getMessage());
+          String uploadFileName = new String(new File(srcPath).getName().getBytes(StandardCharsets.UTF_8), uploadObject.getUploadFileCharSetEnum().getMessage());
           // 是否每个文件类型一个路径
-          if (StrUtil.hasBlank(uploadFileChannel.getBackupC()) || "0".equals(uploadFileChannel.getBackupC())){
+          if (StrUtil.hasBlank(uploadFileChannel.getBackupC()) || "0".equals(uploadFileChannel.getBackupC())) {
             // 公用一个路径
             isSuccess = ftp.upload(uploadFileChannel.getPathService(), uploadFileName, uploadFileIs);
-          }
-          else{
+          } else {
             // 多路径
-            UploadURL uploadURL= uploadURLList.stream().filter(c -> c.getFileTypeEnum().name().equals(keys[1])).collect(Collectors.toList()).get(0);
+            UploadURL uploadURL = uploadURLList.stream().filter(c -> c.getFileTypeEnum().name().equals(keys[1])).collect(Collectors.toList()).get(0);
             isSuccess = ftp.upload(uploadURL.getUploadURL(), uploadFileName, uploadFileIs);
           }
         } catch (Exception e) {
-          logger.error("ftp上传失败",e);
+          logger.error("ftp上传失败", e);
           throw e;
         } finally {
           if (isr != null) {
@@ -92,34 +89,29 @@ public class FtpUploadTransactionService extends BaseUploadFileService {
           }
         }
       } else {
-        InputStreamReader isr = null;
-        InputStream uploadFileIs = null;
         try {
-          isr = new InputStreamReader(new FileInputStream(srcPath), "UTF-8");
-          StringBuffer sb = new StringBuffer("");
-          int len1 = 0;
+          isr = new InputStreamReader(new FileInputStream(srcPath), StandardCharsets.UTF_8);
+          StringBuilder sb = new StringBuilder();
+          int len1;
           while ((len1 = isr.read()) != -1) {
             sb.append((char) len1);
           }
           isr.close();
           String str = sb.toString();
           uploadFileIs = new ByteArrayInputStream(str.getBytes(uploadObject.getUploadFileCharSetEnum().getMessage()));
-          String uploadFileName = new String(new File(srcPath).getName().getBytes("UTF-8"), uploadObject.getUploadFileCharSetEnum().getMessage());
+          String uploadFileName = new String(new File(srcPath).getName().getBytes(StandardCharsets.UTF_8), uploadObject.getUploadFileCharSetEnum().getMessage());
 
-          if (StrUtil.hasBlank(uploadFileChannel.getBackupC()) || "0".equals(uploadFileChannel.getBackupC())){
+          if (StrUtil.hasBlank(uploadFileChannel.getBackupC()) || "0".equals(uploadFileChannel.getBackupC())) {
             // 公用一个路径
             sftp.getClient().put(uploadFileIs, uploadFileChannel.getPathService() + "/" + uploadFileName);
-          }
-          else{
+          } else {
             // 多路径
-            UploadURL uploadURL= uploadURLList.stream().filter(c -> c.getFileTypeEnum().name().equals(keys[1])).collect(Collectors.toList()).get(0);
+            UploadURL uploadURL = uploadURLList.stream().filter(c -> c.getFileTypeEnum().name().equals(keys[1])).collect(Collectors.toList()).get(0);
             sftp.getClient().put(uploadFileIs, uploadURL.getUploadURL() + "/" + uploadFileName);
           }
 
           logger.info("上传远端put结束:" + keys[2]);
           isSuccess = true;
-        } catch (Exception e) {
-          throw e;
         } finally {
           if (isr != null) {
             isr.close();
@@ -149,7 +141,7 @@ public class FtpUploadTransactionService extends BaseUploadFileService {
       try {
         if (isSuccess) {
           // 更新日志表
-          FileStatusEnum fileStatusEnum = null;
+          FileStatusEnum fileStatusEnum;
           if ("1".equals(uploadObject.getUploadD5000())) {
             // 上报给D5000
             fileStatusEnum = FileStatusEnum.E5;
@@ -160,7 +152,7 @@ public class FtpUploadTransactionService extends BaseUploadFileService {
           String targetPath = FileUtil.getFileUploadPath() + File.separator + "backups" + File.separator + keys[0] + File.separator + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd") + File.separator + keys[1];
 
           FileUtil.move(srcPath, targetPath);
-          logger.info("上报通道:" + keys[0] + ",文件:"+keys[0] + "上报成功,移动到backups目录");
+          logger.info("上报通道:" + keys[0] + ",文件:" + keys[0] + "上报成功,移动到backups目录");
 
           Integer id = FileConstant.fileShouldMomentMap.get(entry.getKey());
           UploadFileLog uploadFileLog = uploadFileLogRepository.findById(id).get();
@@ -181,21 +173,20 @@ public class FtpUploadTransactionService extends BaseUploadFileService {
         } else {
           logger.info("上报失败。。。。。。。。。。。。。");
           try {
-            Process process = Runtime.getRuntime().exec("ping "+uploadFileChannel.getRemoteIp() + " -c 2");
+            Process process = Runtime.getRuntime().exec("ping " + uploadFileChannel.getRemoteIp() + " -c 2");
             InputStreamReader r = new InputStreamReader(process.getInputStream());
             LineNumberReader returnData = new LineNumberReader(r);
 
-            String returnMsg="";
-            String line = "";
+            StringBuilder returnMsg = new StringBuilder();
+            String line;
             while ((line = returnData.readLine()) != null) {
-              returnMsg += line;
+              returnMsg.append(line);
             }
 
-            if(returnMsg.indexOf("100% loss")!=-1){
-              logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接不畅通.");
-            }
-            else{
-              logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接畅通.");
+            if (returnMsg.indexOf("100% loss") != -1) {
+              logger.info("与 " + uploadFileChannel.getRemoteIp() + " 连接不畅通.");
+            } else {
+              logger.info("与 " + uploadFileChannel.getRemoteIp() + " 连接畅通.");
             }
 
             returnData.close();
@@ -205,10 +196,10 @@ public class FtpUploadTransactionService extends BaseUploadFileService {
             process.destroy();
 
           } catch (IOException e) {
-            logger.error("ping对方ip执行失败",e);
+            logger.error("ping对方ip执行失败", e);
           }
           // 更新日志表
-          FileStatusEnum fileStatusEnum = null;
+          FileStatusEnum fileStatusEnum;
           if ("1".equals(uploadObject.getUploadD5000())) {
             // 上报给D5000
             fileStatusEnum = FileStatusEnum.E6;
@@ -219,12 +210,12 @@ public class FtpUploadTransactionService extends BaseUploadFileService {
 //          String fileMaxCount = super.getSysParameter("FILE_MAX_COUNT", "3");
 //          // 上报失败
 //          if (fileUploadCount >= Integer.parseInt(fileMaxCount)) {
-            logger.info("上报通道:" + keys[0] + "," + "移动到error目录");
-            String targetPath = FileUtil.getFileUploadPath() + File.separator + "error" + File.separator + keys[0] + File.separator + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd") + File.separator + keys[1];
-            FileUtil.move(srcPath, targetPath);
-            FileConstant.readyUploadFileMap.remove(entry.getKey());
-            FileConstant.fileShouldMomentMap.remove(entry.getKey());
-            FileConstant.uploadCountMap.remove(entry.getKey());
+          logger.info("上报通道:" + keys[0] + "," + "移动到error目录");
+          String targetPath = FileUtil.getFileUploadPath() + File.separator + "error" + File.separator + keys[0] + File.separator + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd") + File.separator + keys[1];
+          FileUtil.move(srcPath, targetPath);
+          FileConstant.readyUploadFileMap.remove(entry.getKey());
+          FileConstant.fileShouldMomentMap.remove(entry.getKey());
+          FileConstant.uploadCountMap.remove(entry.getKey());
 //          } else {
 //            FileMutableInteger fileMutableInteger = new FileMutableInteger(fileUploadCount);
 //            FileConstant.uploadCountMap.put(entry.getKey(), fileMutableInteger);

+ 23 - 20
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileChannelService.java

@@ -1,6 +1,6 @@
 package com.jiayue.ipfcst.fileupload.service;
 
-import ch.qos.logback.classic.Logger;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
 import com.jiayue.ipfcst.common.data.constant.enums.ChannelStatusEnum;
 import com.jiayue.ipfcst.common.data.entity.UploadFileChannel;
@@ -17,7 +17,6 @@ import net.sf.ehcache.search.Attribute;
 import net.sf.ehcache.search.Query;
 import net.sf.ehcache.search.Result;
 import net.sf.ehcache.search.Results;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.ehcache.EhCacheCacheManager;
 import org.springframework.stereotype.Service;
@@ -27,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
@@ -39,20 +39,28 @@ import java.util.stream.Collectors;
 @Service
 @Slf4j
 public class UploadFileChannelService {
-  @Autowired
+  final
   UploadFileChannelRepository uploadFileChannelRepository;
-  @Autowired
+  final
   EhCacheCacheManager ehCacheCacheManager;
-  @Autowired
+  final
   AppenderFactory appenderFactory;
-  @Autowired
+  final
   UploadObjectService uploadObjectService;
-  @Autowired
+  final
   UploadURLRepository uploadURLRepository;
 
   @Value("${fileupload.nettyServer.readerIdleTime}")
   private String readerIdleTime;
 
+  public UploadFileChannelService(UploadFileChannelRepository uploadFileChannelRepository, EhCacheCacheManager ehCacheCacheManager, AppenderFactory appenderFactory, UploadObjectService uploadObjectService, UploadURLRepository uploadURLRepository) {
+    this.uploadFileChannelRepository = uploadFileChannelRepository;
+    this.ehCacheCacheManager = ehCacheCacheManager;
+    this.appenderFactory = appenderFactory;
+    this.uploadObjectService = uploadObjectService;
+    this.uploadURLRepository = uploadURLRepository;
+  }
+
   /**
    * 保存通道
    *
@@ -66,17 +74,14 @@ public class UploadFileChannelService {
     if (!"ftp".equals(uploadObject.getUploadProtocolEnum().getCode()) && !"sftp".equals(uploadObject.getUploadProtocolEnum().getCode())) {
       if (uploadFileChannel.getId() != null) {
         // 102服务端,将原有的服务先销毁掉
-        if (FileConstant.nettyInstanceMap.get(uploadFileChannel.getId()) != null) {
-          FileConstant.nettyInstanceMap.get(uploadFileChannel.getId()).destroy();
+        if (FileConstant.nettyInstanceMap.get(Convert.toStr(uploadFileChannel.getId())) != null) {
+          FileConstant.nettyInstanceMap.get(Convert.toStr(uploadFileChannel.getId())).destroy();
         }
       }
     }
 
     UploadFileChannel uploadFileChannel1 = uploadFileChannelRepository.saveAndFlush(uploadFileChannel);
 
-    // 创建通道对应的日志
-    Logger logger = appenderFactory.getLogger(uploadObject.getUploadObjectName(), uploadObject.getUploadProtocolEnum().getMessage(), uploadObject.getObjectNo());
-
     String protocol = uploadObject.getUploadProtocolEnum().getCode();
 
     if ("102s".equals(protocol)) {
@@ -139,15 +144,14 @@ public class UploadFileChannelService {
    */
   public void clearChannelCache() {
     List<UploadFileChannel> uploadFileChannelList = this.get();
-    Cache cache = ehCacheCacheManager.getCacheManager().getCache("searchablecache");
+    Cache cache = Objects.requireNonNull(ehCacheCacheManager.getCacheManager()).getCache("searchablecache");
     for (UploadFileChannel uploadFileChannel : uploadFileChannelList) {
       cache.remove("ufc" + uploadFileChannel.getId());
     }
   }
 
   public List<UploadFileChannel> getByObjectId(Integer id) {
-    List<UploadFileChannel> uploadFileChannelList = uploadFileChannelRepository.findAllByUploadObjectId(id);
-    return uploadFileChannelList;
+    return uploadFileChannelRepository.findAllByUploadObjectId(id);
   }
 
   public UploadFileChannel getById(Integer id) {
@@ -161,7 +165,7 @@ public class UploadFileChannelService {
    * @return 通道信息
    */
   public List<UploadFileChannel> get() {
-    Cache cache = ehCacheCacheManager.getCacheManager().getCache("searchablecache");
+    Cache cache = Objects.requireNonNull(ehCacheCacheManager.getCacheManager()).getCache("searchablecache");
     Query query = cache.createQuery();
     //查询结果中包含Key和value
     query.includeKeys().includeValues();
@@ -170,7 +174,7 @@ public class UploadFileChannelService {
     Results results = query.execute();
     List<Result> resultList = results.all();
 
-    List<UploadFileChannel> list = new ArrayList();
+    List<UploadFileChannel> list = new ArrayList<>();
     if (resultList != null && !resultList.isEmpty()) {
       for (Result result : resultList) {
         UploadFileChannel e = (UploadFileChannel) result.getValue();
@@ -202,9 +206,8 @@ public class UploadFileChannelService {
 
       if (!"ftp".equals(uploadObject.getUploadProtocolEnum().getCode()) && !"sftp".equals(uploadObject.getUploadProtocolEnum().getCode())) {
         // 创建通道对应的日志
-        Logger logger = appenderFactory.getLogger(uploadObject.getUploadObjectName(), uploadObject.getUploadProtocolEnum().getMessage(), uploadObject.getObjectNo());
-        if (FileConstant.nettyInstanceMap.get(u.getId()) != null) {
-          FileConstant.nettyInstanceMap.remove(u.getId());
+        if (FileConstant.nettyInstanceMap.get(Convert.toStr(u.getId())) != null) {
+          FileConstant.nettyInstanceMap.remove(Convert.toStr(u.getId()));
         }
 
         if ("102s".equals(uploadObject.getUploadProtocolEnum().getCode())) {

+ 18 - 9
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileCodeService.java

@@ -4,28 +4,37 @@ import com.jiayue.ipfcst.common.data.entity.UploadFileCode;
 import com.jiayue.ipfcst.common.data.repository.UploadFileCodeRepository;
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.Element;
-import net.sf.ehcache.search.*;
+import net.sf.ehcache.search.Attribute;
+import net.sf.ehcache.search.Query;
+import net.sf.ehcache.search.Result;
 import net.sf.ehcache.search.Results;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.ehcache.EhCacheCacheManager;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * 上报文件CODE码服务类
+ *
  * @author xsl
  * @version 3.0
  */
 @Service
 public class UploadFileCodeService {
-  @Autowired
+  final
   UploadFileCodeRepository uploadFileCodeRepository;
-  @Autowired
+  final
   EhCacheCacheManager ehCacheCacheManager;
 
+  public UploadFileCodeService(UploadFileCodeRepository uploadFileCodeRepository, EhCacheCacheManager ehCacheCacheManager) {
+    this.uploadFileCodeRepository = uploadFileCodeRepository;
+    this.ehCacheCacheManager = ehCacheCacheManager;
+  }
+
   /**
    * 保存CODE码
    *
@@ -40,7 +49,7 @@ public class UploadFileCodeService {
 
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   public void saveCloud(List<UploadFileCode> beans) {
-    if(beans != null && beans.size() > 0){
+    if (beans != null && beans.size() > 0) {
       clearFileCodeCache();
       uploadFileCodeRepository.deleteAll();
       uploadFileCodeRepository.saveAll(beans);
@@ -63,7 +72,7 @@ public class UploadFileCodeService {
    */
   public void clearFileCodeCache() {
     List<UploadFileCode> uploadFileCodeList = this.get();
-    Cache cache = ehCacheCacheManager.getCacheManager().getCache("searchablecache");
+    Cache cache = Objects.requireNonNull(ehCacheCacheManager.getCacheManager()).getCache("searchablecache");
     for (UploadFileCode uploadFileCode : uploadFileCodeList) {
       cache.remove("code" + uploadFileCode.getId());
     }
@@ -75,7 +84,7 @@ public class UploadFileCodeService {
    * @return 通道信息
    */
   public List<UploadFileCode> get() {
-    Cache cache = ehCacheCacheManager.getCacheManager().getCache("searchablecache");
+    Cache cache = Objects.requireNonNull(ehCacheCacheManager.getCacheManager()).getCache("searchablecache");
     Query query = cache.createQuery();
     //查询结果中包含Key和value
     query.includeKeys().includeValues();
@@ -84,7 +93,7 @@ public class UploadFileCodeService {
     Results results = query.execute();
     List<Result> resultList = results.all();
 
-    List<UploadFileCode> list = new ArrayList();
+    List<UploadFileCode> list = new ArrayList<>();
     if (resultList != null && !resultList.isEmpty()) {
       for (Result result : resultList) {
         UploadFileCode e = (UploadFileCode) result.getValue();

+ 16 - 14
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogDetailService.java

@@ -3,7 +3,6 @@ package com.jiayue.ipfcst.fileupload.service;
 import com.jiayue.ipfcst.common.data.entity.UploadFileLogDetail;
 import com.jiayue.ipfcst.common.data.repository.UploadFileLogDetailRepository;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.stereotype.Service;
 
@@ -11,39 +10,42 @@ import java.util.List;
 
 /**
  * 上报日志明细service
+ *
  * @author zy
  * @version 3.0
  */
 @Service
 @Slf4j
 public class UploadFileLogDetailService {
-  @Autowired
-  private UploadFileLogDetailRepository uploadFileLogDetailRepository;
+  private final UploadFileLogDetailRepository uploadFileLogDetailRepository;
+
+  public UploadFileLogDetailService(UploadFileLogDetailRepository uploadFileLogDetailRepository) {
+    this.uploadFileLogDetailRepository = uploadFileLogDetailRepository;
+  }
 
   /**
    * 根据上报日志id查询明细
+   *
    * @param uploadFileLogId
    * @return UploadFileLogDetail 上报明细
-   *
    */
-  public List<UploadFileLogDetail> getByFileLogId(Integer uploadFileLogId){
+  public List<UploadFileLogDetail> getByFileLogId(Integer uploadFileLogId) {
     UploadFileLogDetail uploadFileLogDetail = new UploadFileLogDetail();
     uploadFileLogDetail.setUploadFileLogId(uploadFileLogId);
-    List<UploadFileLogDetail> list = uploadFileLogDetailRepository.findAll(Example.of(uploadFileLogDetail));
-    return list;
+    return uploadFileLogDetailRepository.findAll(Example.of(uploadFileLogDetail));
   }
 
   /*
-  * 根据上报日志id删除明细
-  * */
-  public void deleteByUploadFileLogId(Integer uploadFileLogId){
-    try{
+   * 根据上报日志id删除明细
+   * */
+  public void deleteByUploadFileLogId(Integer uploadFileLogId) {
+    try {
       List<UploadFileLogDetail> list = getByFileLogId(uploadFileLogId);
-      for(UploadFileLogDetail uploadFileLogDetail : list){
+      for (UploadFileLogDetail uploadFileLogDetail : list) {
         uploadFileLogDetailRepository.deleteById(uploadFileLogDetail.getId());
       }
-    }catch (Exception e){
-      log.info("根据上报日志id删除明细异常:"+e);
+    } catch (Exception e) {
+      log.info("根据上报日志id删除明细异常:" + e);
     }
 
   }

+ 119 - 123
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogService.java

@@ -1,13 +1,14 @@
 package com.jiayue.ipfcst.fileupload.service;
 
-import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
 import com.jiayue.ipfcst.common.data.constant.enums.FileStatusEnum;
 import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.*;
-import com.jiayue.ipfcst.common.data.repository.*;
+import com.jiayue.ipfcst.common.data.repository.ManualUploadLogRepository;
+import com.jiayue.ipfcst.common.data.repository.QuartzRepository;
+import com.jiayue.ipfcst.common.data.repository.UploadFileLogRepository;
+import com.jiayue.ipfcst.common.data.repository.UploadObjectRepository;
 import com.jiayue.ipfcst.common.data.service.uploadfilerule.E63UploadFileRuleService;
-import com.jiayue.ipfcst.common.data.service.uploadfilerule.IUploadFileRuleService;
 import com.jiayue.ipfcst.console.service.ElectricFieldService;
 import com.jiayue.ipfcst.fileupload.util.FileConstant;
 import com.jiayue.ipfcst.fileupload.util.FileUtil;
@@ -66,7 +67,7 @@ public class UploadFileLogService {
       fileType = "";
     }
 
-    Specification<UploadFileLog> specification = this.getQuerySpecification(uploadObjectId, createTime, fileType,stationCode);
+    Specification<UploadFileLog> specification = this.getQuerySpecification(uploadObjectId, createTime, fileType, stationCode);
     List<UploadFileLog> uploadFileLogList = uploadFileLogRepository.findAll(specification);
 
     // 定义查询结果List
@@ -79,7 +80,7 @@ public class UploadFileLogService {
         resultList.addAll(uploadFileLogList);
       }
 
-      if (uploadObjectId.intValue() > 0) {
+      if (uploadObjectId > 0) {
         UploadObject uploadObject = uploadObjectRepository.findById(uploadObjectId).get();
         uploadObjectList.add(uploadObject);
       } else {
@@ -88,7 +89,7 @@ public class UploadFileLogService {
 
       List<Quartz> quartzList = quartzRepository.findAll();
       for (UploadObject uploadObject : uploadObjectList) {
-        if (stationCode.equals(uploadObject.getStationCode())){
+        if (stationCode.equals(uploadObject.getStationCode())) {
           ElectricField electricField = electricFieldService.getSingleStation(stationCode);
           if (!"".equals(fileType)) {
             String executeClass = "com.jiayue.ipfcst.fileupload.job.UploadFile" + fileType + "Job";
@@ -104,7 +105,7 @@ public class UploadFileLogService {
             List<UploadFileLog> filterList = uploadFileLogList.stream().filter(uploadFileLog -> uploadFileLog.getFileTypeEnum().equals(FileTypeEnum.valueOf(finalFileType))).collect(toList());
             // 过滤出未生成的文件名称
             List<String> noCreateFileNameList = shoudFileNameList.stream().filter(item ->
-              !filterList.stream().map(e -> e.getFileName())
+              !filterList.stream().map(UploadFileLog::getFileName)
                 .collect(Collectors.toList()).contains(item)).collect(Collectors.toList());
 
             for (String noCreateFileName : noCreateFileNameList) {
@@ -121,21 +122,20 @@ public class UploadFileLogService {
           } else {
             // 查询所有类型
             String[] uploadFileTypes = uploadObject.getUploadFileType().split(",");
-            for (int i = 0; i < uploadFileTypes.length; i++) {
-              String executeClass = "com.jiayue.ipfcst.fileupload.job.UploadFile" + uploadFileTypes[i] + "Job";
+            for (String type : uploadFileTypes) {
+              String executeClass = "com.jiayue.ipfcst.fileupload.job.UploadFile" + type + "Job";
               List<Quartz> quartzs = quartzList.stream().filter(u -> executeClass.equals(u.getExecuteClass())).collect(Collectors.toList());
               String cronStr = "";
               if (quartzs.size() > 0) {
                 cronStr = quartzs.get(0).getCronExpression();
               }
               // 此类型应该上报的文件名称
-              List<String> shoudFileNameList = e63UploadFileRuleService.getShouldFile(electricField, new Date(Long.parseLong(createTime)), uploadFileTypes[i], cronStr);
-              String uploadFileType = uploadFileTypes[i];
+              List<String> shoudFileNameList = e63UploadFileRuleService.getShouldFile(electricField, new Date(Long.parseLong(createTime)), type, cronStr);
               // 已经生成的文件
-              List<UploadFileLog> filterList = uploadFileLogList.stream().filter(uploadFileLog -> uploadFileLog.getFileTypeEnum().equals(FileTypeEnum.valueOf(uploadFileType))).collect(toList());
+              List<UploadFileLog> filterList = uploadFileLogList.stream().filter(uploadFileLog -> uploadFileLog.getFileTypeEnum().equals(FileTypeEnum.valueOf(type))).collect(toList());
               // 过滤出未生成的文件名称
               List<String> noCreateFileNameList = shoudFileNameList.stream().filter(item ->
-                !filterList.stream().map(e -> e.getFileName())
+                !filterList.stream().map(UploadFileLog::getFileName)
                   .collect(Collectors.toList()).contains(item)).collect(Collectors.toList());
 
               for (String noCreateFileName : noCreateFileNameList) {
@@ -143,7 +143,7 @@ public class UploadFileLogService {
                 noCreateFileLog.setUploadObjectNo(uploadObject.getObjectNo());
                 noCreateFileLog.setUploadObjectName(uploadObject.getUploadObjectName());
                 noCreateFileLog.setFileStatusEnum(FileStatusEnum.E4);
-                noCreateFileLog.setFileTypeEnum(FileTypeEnum.valueOf(uploadFileType));
+                noCreateFileLog.setFileTypeEnum(FileTypeEnum.valueOf(type));
                 noCreateFileLog.setFileName(noCreateFileName);
                 noCreateFileLog.setUploadProtocolEnum(uploadObject.getUploadProtocolEnum());
                 noCreateFileLog.setStationCode(stationCode);
@@ -165,19 +165,16 @@ public class UploadFileLogService {
     if (resultList.size() > 0) {
       for (UploadObject uploadObject : uploadObjectList) {
         String[] uploadType = uploadObject.getUploadFileType().split(",");
-        for (int j = 0; j < uploadType.length; j++) {
-          String ut = uploadType[j];
+        for (String ut : uploadType) {
           List<UploadFileLog> filterTypeList = resultList.stream().filter(uploadFileLog -> uploadFileLog.getFileTypeEnum().equals(FileTypeEnum.valueOf(ut)) && uploadFileLog.getUploadObjectNo().equals(uploadObject.getObjectNo())).collect(toList());
           returnUploadFileList.addAll(filterTypeList);
         }
       }
     }
 
-    List<UploadFileLog> sortResultList = returnUploadFileList.stream()
-      .sorted(Comparator.comparing((UploadFileLog p) -> p.getUploadObjectNo())
+    return returnUploadFileList.stream()
+      .sorted(Comparator.comparing(UploadFileLog::getUploadObjectNo)
         .thenComparing(UploadFileLog::getFileTypeEnum).thenComparing(UploadFileLog::getFileName)).collect(Collectors.toList());
-
-    return sortResultList;
   }
 
   /**
@@ -188,17 +185,17 @@ public class UploadFileLogService {
    * @param fileType
    * @return
    */
-  private Specification<UploadFileLog> getQuerySpecification(Integer uploadObjectId, String createTime, String fileType,String stationCode) {
-    return (Specification<UploadFileLog>) (root, criteriaQuery, cb) -> {
+  private Specification<UploadFileLog> getQuerySpecification(Integer uploadObjectId, String createTime, String fileType, String stationCode) {
+    return (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
-      if (uploadObjectId.intValue() > 0) {
+      if (uploadObjectId > 0) {
         predicates.add(cb.equal(root.get("uploadObjectId").as(Integer.class), uploadObjectId));
       }
 
       if (StringUtils.isNotBlank(createTime)) {
         //大于或等于传入时间
-        predicates.add(cb.greaterThanOrEqualTo(root.get("createTime").as(String.class), DateFormatUtils.format(Long.valueOf(createTime), "yyyy-MM-dd HH:mm:ss'")));
-        predicates.add(cb.lessThanOrEqualTo(root.get("createTime").as(String.class), DateFormatUtils.format(Long.valueOf(createTime) + 1000 * 60 * 60 * 24 - 1, "yyyy-MM-dd HH:mm:ss'")));
+        predicates.add(cb.greaterThanOrEqualTo(root.get("createTime").as(String.class), DateFormatUtils.format(Long.parseLong(createTime), "yyyy-MM-dd HH:mm:ss'")));
+        predicates.add(cb.lessThanOrEqualTo(root.get("createTime").as(String.class), DateFormatUtils.format(Long.parseLong(createTime) + 1000 * 60 * 60 * 24 - 1, "yyyy-MM-dd HH:mm:ss'")));
       }
 
       if (StringUtils.isNotBlank(fileType)) {
@@ -215,15 +212,15 @@ public class UploadFileLogService {
 
   @Transactional(propagation = Propagation.SUPPORTS)
   public boolean uploadFile(Integer objectId, String fileType, MultipartFile file) {
-    Long st = DateTimeUtil.getMillisecondsSubDay();
+    long st = DateTimeUtil.getMillisecondsSubDay();
     //明日凌晨
-    Long et = DateTimeUtil.getMillisecondsSubDay() + 1000 * 60 * 60 * 24 - 1;
+    long et = DateTimeUtil.getMillisecondsSubDay() + 1000 * 60 * 60 * 24 - 1;
     UploadFileLog uploadFileLog = uploadFileLogRepository.findByUploadObjectIdAndFileNameAndCreateTimeBetween(objectId, file.getOriginalFilename(), new Date(st), new Date(et));
     try {
       UploadObject uploadObject = uploadObjectRepository.findById(objectId).get();
-      String destFileDir = null;
+
       // 上报文件目录
-      destFileDir = FileUtil.getFileUploadPath() + File.separator + "process" + File.separator + uploadObject.getObjectNo() + File.separator + fileType;
+      String destFileDir = FileUtil.getFileUploadPath() + File.separator + "process" + File.separator + uploadObject.getObjectNo() + File.separator + fileType;
       File destDir = new File(destFileDir);
       if (!destDir.exists()) {// 如果目录不存在则创建目录
         boolean b = destDir.mkdirs();
@@ -289,40 +286,40 @@ public class UploadFileLogService {
   /*
    * 根据id删除日志
    */
-  public void deleteById(Integer id,String fileCreateDate) {
+  public void deleteById(Integer id, String fileCreateDate) {
     try {
       Optional<UploadFileLog> uploadFileLogOptional = uploadFileLogRepository.findById(id);
       if (uploadFileLogOptional.isPresent()) {
         UploadFileLog uploadFileLog = uploadFileLogOptional.get();
         UploadObject uploadObject = uploadObjectRepository.findById(uploadFileLog.getUploadObjectId()).get();
-        String destFileDir = null;
+
         // 上报文件目录
-        destFileDir = FileUtil.getFileUploadPath() + File.separator + "process" + File.separator + uploadObject.getObjectNo() + File.separator + uploadFileLog.getFileTypeEnum().name();
+        String destFileDir = FileUtil.getFileUploadPath() + File.separator + "process" + File.separator + uploadObject.getObjectNo() + File.separator + uploadFileLog.getFileTypeEnum().name();
         File destDir = new File(destFileDir);
         if (destDir.exists()) {
           File[] files = destDir.listFiles();
-          for (File file : files) {
-            if (uploadFileLog.getFileName().equals(file.getName())) {
-              file.delete();
+          if (null != files) {
+            for (File file : files) {
+              if (uploadFileLog.getFileName().equals(file.getName())) {
+                file.delete();
+              }
             }
           }
         }
-        String errorFileDir = null;
         // 错误文件目录
-        errorFileDir = FileUtil.getFileUploadPath() + File.separator + "error" + File.separator + uploadObject.getObjectNo();
+        String errorFileDir = FileUtil.getFileUploadPath() + File.separator + "error" + File.separator + uploadObject.getObjectNo();
         List<File> files = cn.hutool.core.io.FileUtil.loopFiles(errorFileDir);
-        for (File file:files){
+        for (File file : files) {
           if (uploadFileLog.getFileName().equals(file.getName())) {
-              file.delete();
+            file.delete();
           }
         }
-        String backFileDir = null;
         // 备份文件目录
-        backFileDir = FileUtil.getFileUploadPath() + File.separator + "backups" + File.separator + uploadObject.getObjectNo() + File.separator + DateFormatUtils.format(Long.valueOf(fileCreateDate), "yyyyMMdd'") + File.separator + uploadFileLog.getFileTypeEnum().name();
+        String backFileDir = FileUtil.getFileUploadPath() + File.separator + "backups" + File.separator + uploadObject.getObjectNo() + File.separator + DateFormatUtils.format(Long.parseLong(fileCreateDate), "yyyyMMdd'") + File.separator + uploadFileLog.getFileTypeEnum().name();
         File backDir = new File(backFileDir);
         if (backDir.exists()) {
           File[] backfiles = backDir.listFiles();
-          for (File file : backfiles) {
+          for (File file : Objects.requireNonNull(backfiles)) {
             if (uploadFileLog.getFileName().equals(file.getName())) {
               file.delete();
             }
@@ -365,91 +362,90 @@ public class UploadFileLogService {
    */
   public void report(UploadFileLog uploadFileLog) {
 
-      String pro = "";
-        List<Quartz> quartzList = quartzRepository.findAll();
+    List<Quartz> quartzList = quartzRepository.findAll();
 
-        String executeClass = "com.jiayue.ipfcst.fileupload.job.UploadFile" + uploadFileLog.getFileTypeEnum().name() + "Job";
-        List<Quartz> quartzs = quartzList.stream().filter(u -> executeClass.equals(u.getExecuteClass())).collect(Collectors.toList());
-        String cronStr = "";
-        if (quartzs.size() > 0) {
-          cronStr = quartzs.get(0).getCronExpression();
+    String executeClass = "com.jiayue.ipfcst.fileupload.job.UploadFile" + uploadFileLog.getFileTypeEnum().name() + "Job";
+    List<Quartz> quartzs = quartzList.stream().filter(u -> executeClass.equals(u.getExecuteClass())).collect(Collectors.toList());
+    String cronStr = "";
+    if (quartzs.size() > 0) {
+      cronStr = quartzs.get(0).getCronExpression();
+    }
+    ElectricField electricField = electricFieldService.getSingleStation(uploadFileLog.getStationCode());
+    // 应该上报的文件名称集合
+    List<String> shoudFileNameList = e63UploadFileRuleService.getShouldFile(electricField, uploadFileLog.getCreateTime(), uploadFileLog.getFileTypeEnum().name(), cronStr);
+
+    if (shoudFileNameList.size() > 0) {
+      int n = -1;
+      for (int i = 0; i < shoudFileNameList.size(); i++) {
+        if (shoudFileNameList.get(i).equals(uploadFileLog.getFileName())) {
+          n = i;
+          break;
         }
-      ElectricField electricField = electricFieldService.getSingleStation(uploadFileLog.getStationCode());
-        // 应该上报的文件名称集合
-        List<String> shoudFileNameList = e63UploadFileRuleService.getShouldFile(electricField, uploadFileLog.getCreateTime(), uploadFileLog.getFileTypeEnum().name(), cronStr);
-
-        if (shoudFileNameList.size() > 0) {
-          int n = -1;
-          for (int i = 0; i < shoudFileNameList.size(); i++) {
-            if (shoudFileNameList.get(i).equals(uploadFileLog.getFileName())) {
-              n = i;
-              break;
-            }
-          }
-          BigDecimal bigDecimal = null;
-          if (DateTimeUtil.isNow((uploadFileLog.getCreateTime()))) {
-            //计算文件上报的时间间隔
-            BigDecimal subtract = new BigDecimal(new Date().getTime()).subtract(new BigDecimal(uploadFileLog.getCreateTime().getTime()));
-            BigDecimal[] bigDecimals = subtract.divideAndRemainder(new BigDecimal(60000));
-            BigDecimal[] divide = bigDecimals[0].divideAndRemainder(new BigDecimal(shoudFileNameList.size()));
-            bigDecimal = divide[0].add(new BigDecimal(1));
-          } else {
-            bigDecimal = new BigDecimal(1440).divide(new BigDecimal(shoudFileNameList.size()));
-          }
+      }
+      BigDecimal bigDecimal;
+      if (DateTimeUtil.isNow((uploadFileLog.getCreateTime()))) {
+        //计算文件上报的时间间隔
+        BigDecimal subtract = new BigDecimal(new Date().getTime()).subtract(new BigDecimal(uploadFileLog.getCreateTime().getTime()));
+        BigDecimal[] bigDecimals = subtract.divideAndRemainder(new BigDecimal(60000));
+        BigDecimal[] divide = bigDecimals[0].divideAndRemainder(new BigDecimal(shoudFileNameList.size()));
+        bigDecimal = divide[0].add(new BigDecimal(1));
+      } else {
+        bigDecimal = new BigDecimal(1440).divide(new BigDecimal(shoudFileNameList.size()));
+      }
 
-          if (n != -1) {
-            //得到文件应该生成的时间
-            BigDecimal multiply = bigDecimal.multiply(new BigDecimal(n)).multiply(new BigDecimal(60000));
-            BigDecimal add = new BigDecimal(uploadFileLog.getCreateTime().getTime()).add(multiply);
-
-            long l = add.longValue();
-            Date date = new Date(l);
-            switch (uploadFileLog.getFileTypeEnum().name()) {
-              case "E1":
-                // 短期
-                e63UploadFileService.generateDqFile(date);
-                break;
-              case "E2":
-                // 超短期
-                e63UploadFileService.generateCdqFile(date);
-                break;
-              case "E3":
-                // 理论功率
-                e63UploadFileService.generateTheroyFile(date);
-                break;
-              case "E6":
-                // 气象站
-                e63UploadFileService.generateQxzOrCftFile(date);
-                break;
-              case "E7":
-                // 测风塔
-                e63UploadFileService.generateQxzOrCftFile(date);
-                break;
-              case "E8":
-                // 逆变器
-                e63UploadFileService.generateNbqOrFjFile(date);
-                break;
-              case "E9":
-                // 风机
-                e63UploadFileService.generateNbqOrFjFile(date);
-                break;
-              case "E26":
-                // 短期可用
-                e63UploadFileService.generateDqUseFile(date);
-                break;
-              case "E27":
-                // 超短期可用
-                e63UploadFileService.generateCdqUseFile(date);
-                break;
-              case "E85":
-                // 理论功率风
-                e63UploadFileService.generateTheroyFile(date);
-                break;
-              default:
-                break;
-            }
-          }
+      if (n != -1) {
+        //得到文件应该生成的时间
+        BigDecimal multiply = bigDecimal.multiply(new BigDecimal(n)).multiply(new BigDecimal(60000));
+        BigDecimal add = new BigDecimal(uploadFileLog.getCreateTime().getTime()).add(multiply);
+
+        long l = add.longValue();
+        Date date = new Date(l);
+        switch (uploadFileLog.getFileTypeEnum().name()) {
+          case "E1":
+            // 短期
+            e63UploadFileService.generateDqFile(date);
+            break;
+          case "E2":
+            // 超短期
+            e63UploadFileService.generateCdqFile(date);
+            break;
+          case "E3":
+            // 理论功率
+            e63UploadFileService.generateTheroyFile(date);
+            break;
+          case "E6":
+            // 气象站
+            e63UploadFileService.generateQxzOrCftFile(date);
+            break;
+          case "E7":
+            // 测风塔
+            e63UploadFileService.generateQxzOrCftFile(date);
+            break;
+          case "E8":
+            // 逆变器
+            e63UploadFileService.generateNbqOrFjFile(date);
+            break;
+          case "E9":
+            // 风机
+            e63UploadFileService.generateNbqOrFjFile(date);
+            break;
+          case "E26":
+            // 短期可用
+            e63UploadFileService.generateDqUseFile(date);
+            break;
+          case "E27":
+            // 超短期可用
+            e63UploadFileService.generateCdqUseFile(date);
+            break;
+          case "E85":
+            // 理论功率风
+            e63UploadFileService.generateTheroyFile(date);
+            break;
+          default:
+            break;
         }
+      }
+    }
   }
 
 

+ 13 - 14
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadObjectService.java

@@ -1,8 +1,6 @@
 package com.jiayue.ipfcst.fileupload.service;
 
-import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
-import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.UploadObject;
 import com.jiayue.ipfcst.common.data.repository.UploadObjectRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
@@ -13,16 +11,12 @@ import net.sf.ehcache.search.Attribute;
 import net.sf.ehcache.search.Query;
 import net.sf.ehcache.search.Result;
 import net.sf.ehcache.search.Results;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.ehcache.EhCacheCacheManager;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 上报对象业务层
@@ -33,11 +27,16 @@ import java.util.Map;
 @Service
 @Slf4j
 public class UploadObjectService extends BaseService {
-  @Autowired
+  final
   UploadObjectRepository uploadObjectRepository;
-  @Autowired
+  final
   EhCacheCacheManager ehCacheCacheManager;
 
+  public UploadObjectService(UploadObjectRepository uploadObjectRepository, EhCacheCacheManager ehCacheCacheManager) {
+    this.uploadObjectRepository = uploadObjectRepository;
+    this.ehCacheCacheManager = ehCacheCacheManager;
+  }
+
   /**
    * 保存上报对象
    *
@@ -51,7 +50,7 @@ public class UploadObjectService extends BaseService {
 
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   public void saveCloud(List<UploadObject> beans) {
-    if(beans != null && beans.size() > 0){
+    if (beans != null && beans.size() > 0) {
       clearUploadObjectCache();
       uploadObjectRepository.deleteAll();
       uploadObjectRepository.saveAll(beans);
@@ -74,7 +73,7 @@ public class UploadObjectService extends BaseService {
    */
   public void clearUploadObjectCache() {
     List<UploadObject> uploadObjectList = this.get();
-    Cache cache = ehCacheCacheManager.getCacheManager().getCache("searchablecache");
+    Cache cache = Objects.requireNonNull(ehCacheCacheManager.getCacheManager()).getCache("searchablecache");
     for (UploadObject uploadObject : uploadObjectList) {
       cache.remove("uo" + uploadObject.getId());
     }
@@ -86,7 +85,7 @@ public class UploadObjectService extends BaseService {
    * @return 上报对象信息
    */
   public List<UploadObject> get() {
-    Cache cache = ehCacheCacheManager.getCacheManager().getCache("searchablecache");
+    Cache cache = Objects.requireNonNull(ehCacheCacheManager.getCacheManager()).getCache("searchablecache");
     Query query = cache.createQuery();
     //查询结果中包含Key和value
     query.includeKeys().includeValues();
@@ -95,7 +94,7 @@ public class UploadObjectService extends BaseService {
     Results results = query.execute();
     List<Result> resultList = results.all();
 
-    List<UploadObject> list = new ArrayList();
+    List<UploadObject> list = new ArrayList<>();
     if (resultList != null && !resultList.isEmpty()) {
       for (Result result : resultList) {
         UploadObject e = (UploadObject) result.getValue();
@@ -118,7 +117,7 @@ public class UploadObjectService extends BaseService {
    *
    * @return 上报对象信息
    */
-  public Map<String,String> getUploadFileType() {
+  public Map<String, String> getUploadFileType() {
     Map<String, String> uploadFileTypeMap = new HashMap<>();
     uploadFileTypeMap.put(FileTypeEnum.E1.toString(), FileTypeEnum.E1.getMessage());
     uploadFileTypeMap.put(FileTypeEnum.E2.toString(), FileTypeEnum.E2.getMessage());

+ 10 - 8
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadURLService.java

@@ -2,7 +2,6 @@ package com.jiayue.ipfcst.fileupload.service;
 
 import com.jiayue.ipfcst.common.data.entity.UploadURL;
 import com.jiayue.ipfcst.common.data.repository.UploadURLRepository;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -11,34 +10,37 @@ import java.util.List;
 
 @Service
 public class UploadURLService {
-  @Autowired
-  private UploadURLRepository uploadURLRepository;
+  private final UploadURLRepository uploadURLRepository;
+
+  public UploadURLService(UploadURLRepository uploadURLRepository) {
+    this.uploadURLRepository = uploadURLRepository;
+  }
 
   @Transactional
-  public List<UploadURL> findAll(){
+  public List<UploadURL> findAll() {
     return uploadURLRepository.findAll();
   }
 
   @Transactional
-  public List<UploadURL> findByUploadCahnnelId(Integer id){
+  public List<UploadURL> findByUploadCahnnelId(Integer id) {
     return uploadURLRepository.findByUploadChannelId(id);
   }
 
   @Transactional
-  public void save(UploadURL uploadURL){
+  public void save(UploadURL uploadURL) {
     uploadURLRepository.save(uploadURL);
   }
 
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   public void saveCloud(List<UploadURL> beans) {
-    if(beans != null && beans.size() > 0){
+    if (beans != null && beans.size() > 0) {
       uploadURLRepository.deleteAll();
       uploadURLRepository.saveAll(beans);
     }
   }
 
   @Transactional
-  public void deleteByChannelId(Integer uploadChannelId){
+  public void deleteByChannelId(Integer uploadChannelId) {
     uploadURLRepository.deleteByUploadChannelId(uploadChannelId);
   }
 

+ 18 - 187
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/ByteUtil.java

@@ -15,33 +15,6 @@ import java.util.Formatter;
  */
 public abstract class ByteUtil {
 
-  /**
-   * int类型转换byte[4]数组,数组内字节由高到低
-   *
-   * @param n 被转换int
-   * @return byte[4]
-   */
-  public static byte[] intToBytesFromHighToLow(@NotNull int n) {
-    byte[] result = new byte[4];
-    result[0] = (byte) ((n >> 24) & 0xFF);
-    result[1] = (byte) ((n >> 16) & 0xFF);
-    result[2] = (byte) ((n >> 8) & 0xFF);
-    result[3] = (byte) (n & 0xFF);
-    return result;
-  }
-
-  /**
-   * byte[4]数组类型转换int,数组内字节由高到低
-   *
-   * @param b 被转换的字节数组
-   * @return int
-   */
-  public static int bytesToIntFromHighToLow(@NotNull byte[] b) {
-
-    return (b[(0)] & 0xFF) << 24 | (b[(1)] & 0xFF) << 16 |
-      (b[(2)] & 0xFF) << 8 | b[3] & 0xFF;
-  }
-
 
   /**
    * int类型转换byte[4]数组,数组内字节由低到高
@@ -71,26 +44,6 @@ public abstract class ByteUtil {
   }
 
   /**
-   * 二进制转十六进制,数组内字节由高到低
-   *
-   * @param b 二进制数组
-   * @return 十六进制字符串
-   */
-  public static String bytesToHexStringFromHighToLow(@NotNull byte[] b) {
-    return DatatypeConverter.printHexBinary(b);
-  }
-
-  /**
-   * 十六进制转二进制,数组内字节由高到低
-   *
-   * @param hexString 十六进制字符串
-   * @return 二进制数组
-   */
-  public static byte[] hexStringToBytesFromHighToLow(@NotNull String hexString) {
-    return DatatypeConverter.parseHexBinary(hexString);
-  }
-
-  /**
    * 二进制转十六进制,数组内字节由低到高
    *
    * @param b 二进制数组
@@ -103,17 +56,6 @@ public abstract class ByteUtil {
   }
 
   /**
-   * 十六进制转二进制,数组内字节由低到高
-   *
-   * @param hexString 十六进制字符串
-   * @return 二进制数组
-   */
-  public static byte[] hexStringToBytesFromLowToHigh(@NotNull String hexString) {
-    byte[] dest = DatatypeConverter.parseHexBinary(hexString);
-    return ByteUtil.bytesFlipping(dest);
-  }
-
-  /**
    * float转换byte[4]数组,数组内字节由低到高
    *
    * @param f 被转换float
@@ -131,50 +73,6 @@ public abstract class ByteUtil {
   }
 
   /**
-   * byte[4]数组转换float,数组内字节由低到高
-   *
-   * @param b 被转换字节数组
-   * @return float
-   */
-  public static float bytesToFloatFromLowToHigh(@NotNull byte[] b) {
-    int l = b[(0)];
-    l &= 255;
-    l = l | b[(1)] << 8;
-    l &= 65535;
-    l = l | b[(2)] << 16;
-    l &= 16777215;
-    l = l | b[(3)] << 24;
-    return Float.intBitsToFloat(l);
-  }
-
-  /**
-   * float转换byte[4]数组,数组内字节由高到低
-   *
-   * @param f 被转换float
-   * @return byte[4]
-   */
-  public static byte[] floatToBytesFromHighToLow(@NotNull float f) {
-    int fbit = Float.floatToIntBits(f);
-
-    byte[] b = new byte[4];
-    for (int i = 0; i < 4; i++) {
-      b[i] = ((byte) (fbit >> 24 - i * 8));
-    }
-    return b;
-  }
-
-  /**
-   * byte[4]数组转换float,数组内字节由高到低
-   *
-   * @param b 被转换字节数组
-   * @return float
-   */
-  public static float bytesToFloatFromHighToLow(@NotNull byte[] b) {
-    byte[] dest = ByteUtil.bytesFlipping(b);
-    return ByteUtil.bytesToFloatFromLowToHigh(dest);
-  }
-
-  /**
    * 数组翻转
    *
    * @param res 原数组
@@ -234,20 +132,20 @@ public abstract class ByteUtil {
     int var3 = dec & 255;
     String var4 = Integer.toHexString(var2);
     String var5 = Integer.toHexString(var3);
-    if(var4.length() > 2) {
+    if (var4.length() > 2) {
       do {
-        if(var1 > 1) {
+        if (var1 > 1) {
           var2 >>= 8;
         }
         var4 = Integer.toHexString(var2 >> 8);
         var5 = var5 + Integer.toHexString(var2 & 255);
         ++var1;
-      } while(var4.length() > 2);
+      } while (var4.length() > 2);
     }
-    if(var4.length() < 2) {
+    if (var4.length() < 2) {
       var4 = "0" + var4;
     }
-    if(var5.length() < 2) {
+    if (var5.length() < 2) {
       var5 = "0" + var5;
     }
     return var5 + var4;
@@ -260,10 +158,10 @@ public abstract class ByteUtil {
    * @return 十六进制字符串表示形式
    */
   public static String byteToHexString(byte[] tmp) {
-    char hexdigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+    char[] hexdigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
     String s;
     // 用字节表示就是 16 个字节
-    char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符,
+    char[] str = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符,
     // 所以表示成 16 进制需要 32 个字符
     int k = 0; // 表示转换结果中对应的字符位置
     for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节
@@ -280,8 +178,7 @@ public abstract class ByteUtil {
   /**
    * 16进制的字符串表示转成字节数组
    *
-   * @param hexString
-   *            16进制格式的字符串
+   * @param hexString 16进制格式的字符串
    * @return 转换后的字节数组
    **/
   public static byte[] toByteArray(String hexString) {
@@ -302,12 +199,13 @@ public abstract class ByteUtil {
    * @param ba ba
    * @return string
    */
-  public static String Byte2String(byte[] ba){
-    if(ba == null || ba.length == 0)
-    { return null;}
+  public static String Byte2String(byte[] ba) {
+    if (ba == null || ba.length == 0) {
+      return null;
+    }
     Formatter f = new Formatter();
-    for(int i = 0; i < ba.length; ++i){
-      f.format("%02x ", ba[i]);
+    for (byte b : ba) {
+      f.format("%02x ", b);
     }
     return f.toString();
   }
@@ -318,82 +216,15 @@ public abstract class ByteUtil {
    * @param buf buf
    * @return string
    */
-  public static String ByteBuf2String(ByteBuf buf){
-    if(!buf.isReadable()){
+  public static String ByteBuf2String(ByteBuf buf) {
+    if (!buf.isReadable()) {
       return null;
     }
-    ByteBuf b1=buf.copy();
-    byte []bs=new byte[b1.readableBytes()];
+    ByteBuf b1 = buf.copy();
+    byte[] bs = new byte[b1.readableBytes()];
     b1.readBytes(bs);
     b1.release();
     return Byte2String(bs);
   }
 
-  public static void main(String[] args) {
-//    byte[] b = {73,2};
-//    byte[] c = bytesFlipping(b);
-//    String info = DatatypeConverter.printHexBinary(c);
-//    BigInteger bigint=new BigInteger(info, 16);
-//    int numb=bigint.intValue();
-//    System.out.println(numb);
-
-//    String[] returnMessage = {"10", "ctrl", "FF", "FF", "crc", "16"};
-
-//    Long a=1589130920L;
-//    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-//    DataOutputStream dos = new DataOutputStream(baos);
-//    try {
-//      dos.writeLong(a);
-//    } catch (IOException e) {
-//      e.printStackTrace();
-//    }
-////再读出来
-//    byte[] buf = baos.toByteArray();
-//    System.out.println(bytesToHexStringFromHighToLow(intToBytesFromLowToHigh(bytesToIntFromHighToLow(buf))));
-//
-//
-//    System.out.println(bytesToHexStringFromHighToLow(floatToBytesFromLowToHigh(a.floatValue())));
-//
-//    System.out.println(bytesToHexStringFromHighToLow(intToBytesFromLowToHigh(a.intValue())));
-//
-//
-//
-//    System.out.println(bytesToHexStringFromHighToLow(intToBytesFromLowToHigh(hexToDec(Long.toHexString(a)))));
-
-//    System.out.println(bytesToIntFromLowToHigh(hexStringToBytesFromLowToHigh(Long.toHexString(a))));
-// A8 36 B8 5E
-//    byte[] b = {(byte)0x3c,(byte)0x00,(byte)0x00,(byte)0x00};
-//    System.out.println(a.intValue());
-
-
-//    int a=145;
-//    System.out.println(decToHex(183));
-//
-//    int var1 = 1;
-//    int var2 = 183 >> 8;
-//    int var3 = 183 & 255;
-//    String var4 = Integer.toHexString(var2);
-//    String var5 = Integer.toHexString(var3);
-//    if(var4.length() > 2) {
-//      do {
-//        if(var1 > 1) {
-//          var2 >>= 8;
-//        }
-//        var4 = Integer.toHexString(var2 >> 8);
-//        var5 = var5 + Integer.toHexString(var2 & 255);
-//        ++var1;
-//      } while(var4.length() > 2);
-//    }
-//    if(var4.length() < 2) {
-//      var4 = "0" + var4;
-//    }
-//    if(var5.length() < 2) {
-//      var5 = "0" + var5;
-//    }
-//    System.out.println(var5 + var4);
-
-
-    int a=10;
-    System.out.println(decToHex(a));
-  }
 }

+ 12 - 14
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/FileConstant.java

@@ -19,30 +19,28 @@ import java.util.Map;
 @Slf4j
 public class FileConstant {
   /*待上报文件的缓存变量,Map<上报对象编号-文件类型-文件名,文件本地路径及文件名>*/
-  public static Map<String, UploadFileLog> readyUploadFileMap = new Hashtable<String, UploadFileLog>();
+  public static Map<String, UploadFileLog> readyUploadFileMap = new Hashtable<>();
   /*文件上报次数累计的缓存变量,Map<上报对象编号-文件类型-文件名,上报次数>*/
-  public static Map<String, FileMutableInteger> uploadCountMap = new Hashtable<String, FileMutableInteger>();
+  public static Map<String, FileMutableInteger> uploadCountMap = new Hashtable<>();
   /*文件内容缓存变量,Map<上报对象编号-文件类型-文件名,16进制文件内容>*/
-  public static Map<String, String> fileContentMap = new Hashtable<String, String>();
+  public static Map<String, String> fileContentMap = new Hashtable<>();
   /*文件内容及内容位置缓存变量,Map<上报对象编号-文件类型-文件名,map<16进制文件内容,内容在原来来文件的位置>>*/
-  public static Map<String, Map<String,String>> fileContentByIdxMap = new Hashtable<String, Map<String,String>>();
+  public static Map<String, Map<String, String>> fileContentByIdxMap = new Hashtable<>();
   /*netty服务实例集合<通道主键ID,netty服务端实例>*/
-  public static Map<String, NettyParent> nettyInstanceMap = new Hashtable<String,NettyParent>();
+  public static Map<String, NettyParent> nettyInstanceMap = new Hashtable<>();
   /*通道状态集合<上报对象id-通道id,通讯状态> 通讯状态:1通0不通*/
-  public static Map<String,String> channelStatusMap = new Hashtable<String,String>();
+  public static Map<String, String> channelStatusMap = new Hashtable<>();
   /*下载文件内容缓存变量,Map<上报对象编号-文件类型,16进制文件内容>*/
-  public static Map<String, String> downLoadFileContentMap = new Hashtable<String, String>();
+  public static Map<String, String> downLoadFileContentMap = new Hashtable<>();
   public static Map<String, Logger> uploadLogMap = new HashMap<>();
   /*验证对方报文回复正确性<通道主键ID,下一次交互的传输原因>*/
-  public static Map<String,Validate102Dto> validateMessage = new HashMap<>();
+  public static Map<String, Validate102Dto> validateMessage = new HashMap<>();
   /*遇到不正常回复时,将文件暂时放入再次上报变量,Map<上报对象编号-文件类型-文件名,"">*/
-  public static Map<String, String> againUploadFileMap = new Hashtable<String, String>();
+  public static Map<String, String> againUploadFileMap = new Hashtable<>();
   /*文件对应的生成时间,Map<上报对象编号-文件类型-文件名,日志表主键ID>*/
-  public static Map<String, Integer> fileShouldMomentMap = new Hashtable<String, Integer>();
+  public static Map<String, Integer> fileShouldMomentMap = new Hashtable<>();
   /*文件包次数Map<上报对象编号-文件类型-文件名,包次数>*/
-  public static Map<String, String> filePackageNumMap = new Hashtable<String, String>();
+  public static Map<String, String> filePackageNumMap = new Hashtable<>();
   /*保存102哪个通道在连接Map<Ip,端口>*/
-  public static Map<String, Integer> channelIpPortMap = new Hashtable<String, Integer>();
-  /*通道状态集合<上报对象id,状态> 通讯状态:1通0不通*/
-  public static Map<String,Long> channelTimeMap = new Hashtable<String,Long>();
+  public static Map<String, Integer> channelIpPortMap = new Hashtable<>();
 }

+ 1 - 16
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/FileMutableInteger.java

@@ -1,10 +1,5 @@
 package com.jiayue.ipfcst.fileupload.util;
 
-import com.jiayue.ipfcst.common.data.entity.UploadFileLogDetail;
-
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * 文件上报计数器
  *
@@ -12,17 +7,7 @@ import java.util.List;
  * @version 3.0
  */
 public class FileMutableInteger {
-  int value = 0;
-
-  List<UploadFileLogDetail> uploadFileLogDetail = new ArrayList<>();
-
-  public List<UploadFileLogDetail> getUploadFileLogDetail() {
-    return uploadFileLogDetail;
-  }
-
-  public void setUploadFileLogDetail(List<UploadFileLogDetail> uploadFileLogDetail) {
-    this.uploadFileLogDetail = uploadFileLogDetail;
-  }
+  int value;
 
   public FileMutableInteger(int val) {
     this.value = val;

+ 8 - 22
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/FileUtil.java

@@ -51,17 +51,17 @@ public class FileUtil {
 
   //文件内容md5加密
   public static String getMD5(byte[] fileByte) {
-    String md5 = new String();
+    String md5 = "";
     try {
       MessageDigest md = MessageDigest.getInstance("MD5");
       md.update(fileByte);
-      byte b[] = md.digest();
+      byte[] b = md.digest();
 
       int i;
 
-      StringBuffer buf = new StringBuffer("");
-      for (int offset = 0; offset < b.length; offset++) {
-        i = b[offset];
+      StringBuilder buf = new StringBuilder();
+      for (byte value : b) {
+        i = value;
         if (i < 0)
           i += 256;
         if (i < 16)
@@ -209,15 +209,6 @@ public class FileUtil {
   }
 
   /**
-   * 报表相对路径
-   *
-   * @return
-   */
-  public static String getreportFormPath() {
-    return createUploadAllDir("reportForm");
-  }
-
-  /**
    * 获取临时文件目录相对路径
    *
    * @return
@@ -226,12 +217,8 @@ public class FileUtil {
     return createUploadAllDir("tempFile");
   }
 
-  public static String getE46Path() {
-    return createUploadAllDir("HN");
-  }
-
   private static String createUploadAllDir(String dir) {
-    String path = "";
+    String path;
     if (System.getProperties().getProperty("file.separator").equals("\\")) {
       path = new File(getResourceBasePath()).getParentFile().getParentFile().getParentFile().getAbsolutePath() + File.separator + dir;
       try {
@@ -245,9 +232,8 @@ public class FileUtil {
         if (!b)
           log.error("目录创建失败" + path);
       }
-    }
-    else{
-      path = "/home/syjy/ipfcstV3/"+ dir;
+    } else {
+      path = "/home/syjy/ipfcstV3/" + dir;
     }
     return path;
   }

+ 3 - 4
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/IEC102Uitl.java

@@ -24,8 +24,8 @@ public class IEC102Uitl {
       iNum = iNum + 2;
     }
 
-    /**
-     * 用256求余最大是255,即16进制的FF
+    /*
+      用256求余最大是255,即16进制的FF
      */
     int iMod = iTotal % 256;
     String sHex = Integer.toHexString(iMod);
@@ -73,7 +73,6 @@ public class IEC102Uitl {
       return null;
     }
     String regex = "(.{2})";
-    String result = str.replaceAll(regex, "$1 ");
-    return result;
+    return str.replaceAll(regex, "$1 ");
   }
 }

+ 66 - 60
ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/controller/FTPController.java

@@ -5,7 +5,6 @@ import com.jiayue.ipfcst.ftpsftp.dto.FTPSFTPDto;
 import com.jiayue.ipfcst.ftpsftp.service.ContinueFTPService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.net.ftp.FTPFile;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -13,6 +12,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.List;
@@ -25,15 +26,16 @@ public class FTPController {
   private String remotePort;
   private String uploadUserName;
   private String uploadPassword;
-  @Autowired
   private final ContinueFTPService continueFTPService;
 
-  public FTPController(ContinueFTPService continueFTPService){
+  public FTPController(ContinueFTPService continueFTPService) {
     this.continueFTPService = continueFTPService;
   }
+
   /**
    * 连接FTP
-   * @param ftpsftpDtos
+   *
+   * @param ftpsftpDtos 入参
    * @return 返回所有目录
    */
   @PostMapping(value = "/continueFTP")
@@ -44,34 +46,34 @@ public class FTPController {
       //登陆
       continueFTPService.initFtpClient(ftpsftpDtos.getRemoteIp(), Integer.parseInt(ftpsftpDtos.getRemotePort()), ftpsftpDtos.getUploadUserName(), ftpsftpDtos.getUploadPassword());
       //获取目录下所有文件
-      FTPFile[] files =continueFTPService.listFiles(ftpsftpDtos.getServicePath());
+      FTPFile[] files = continueFTPService.listFiles(ftpsftpDtos.getServicePath());
       remoteIp = ftpsftpDtos.getRemoteIp();
       remotePort = ftpsftpDtos.getRemotePort();
       uploadUserName = ftpsftpDtos.getUploadUserName();
       uploadPassword = ftpsftpDtos.getUploadPassword();
-      for (int i = 0; i < files.length; i++) {
+      for (FTPFile file : files) {
         FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
-        String name = new String(files[i].getName().getBytes("iso-8859-1"),"UTF-8");
-        String s = files[i].getRawListing();
-        String subStrings = s.substring(0,10);
-        BigDecimal fileSize = new BigDecimal(files[i].getSize());
-        String fileSizes = fileSize.divide(new BigDecimal(1024)).divide(new BigDecimal(1024)).setScale(2, BigDecimal.ROUND_CEILING).toString();
-        Long lastTime = files[i].getTimestamp().getTimeInMillis()+files[i].getTimestamp().getTimeZone().getOffset(0);
+        String name = new String(file.getName().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
+        String s = file.getRawListing();
+        String subStrings = s.substring(0, 10);
+        BigDecimal fileSize = new BigDecimal(file.getSize());
+        String fileSizes = fileSize.divide(new BigDecimal(1024)).divide(new BigDecimal(1024)).setScale(2, RoundingMode.CEILING).toString();
+        Long lastTime = file.getTimestamp().getTimeInMillis() + file.getTimestamp().getTimeZone().getOffset(0);
 
         ftpsftpDto.setName(name);
-        if(files[i].isFile()){
-          ftpsftpDto.setFileSize(fileSizes+"MB");
-        }else{
+        if (file.isFile()) {
+          ftpsftpDto.setFileSize(fileSizes + "MB");
+        } else {
           ftpsftpDto.setFileSize("--");
         }
         ftpsftpDto.setLastModified(sdf.format(lastTime));
         ftpsftpDto.setJurisdiction(subStrings);
-        ftpsftpDto.setDirectory(files[i].isDirectory());
+        ftpsftpDto.setDirectory(file.isDirectory());
         FTPSFTPDtoList.add(ftpsftpDto);
       }
 
       return ResponseVO.success(FTPSFTPDtoList);
-    }catch (Exception e){
+    } catch (Exception e) {
       return ResponseVO.fail("连接失败,请检查配置信息");
     }
 
@@ -79,69 +81,69 @@ public class FTPController {
 
   /**
    * 根据传入的路径 返回上一级/进入下一级
+   *
    * @param ftpsftpDtos
    * @return
    */
   @PostMapping(value = "/openServicePath")
-  public ResponseVO openServicePath(@RequestBody FTPSFTPDto ftpsftpDtos){
+  public ResponseVO openServicePath(@RequestBody FTPSFTPDto ftpsftpDtos) {
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     List<FTPSFTPDto> FTPSFTPDtoList = new ArrayList<>();
-    try{
-      FTPFile[] files =continueFTPService.listFiles(ftpsftpDtos.getServicePath());
-      for (int i = 0; i < files.length; i++) {
+    try {
+      FTPFile[] files = continueFTPService.listFiles(ftpsftpDtos.getServicePath());
+      for (FTPFile file : files) {
         FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
-        String name = new String(files[i].getName().getBytes("iso-8859-1"),"UTF-8");
+        String name = new String(file.getName().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
 
-        String s = files[i].getRawListing();
-        String subStrings = s.substring(0,10);
-        BigDecimal fileSize = new BigDecimal(files[i].getSize());
-        String fileSizes = fileSize.divide(new BigDecimal(1024)).divide(new BigDecimal(1024)).setScale(2, BigDecimal.ROUND_CEILING).toString();
-        Long lastTime = files[i].getTimestamp().getTimeInMillis()+files[i].getTimestamp().getTimeZone().getOffset(0);
+        String s = file.getRawListing();
+        String subStrings = s.substring(0, 10);
+        BigDecimal fileSize = new BigDecimal(file.getSize());
+        String fileSizes = fileSize.divide(new BigDecimal(1024)).divide(new BigDecimal(1024)).setScale(2, RoundingMode.CEILING).toString();
+        Long lastTime = file.getTimestamp().getTimeInMillis() + file.getTimestamp().getTimeZone().getOffset(0);
 
         ftpsftpDto.setName(name);
-        if(files[i].isFile()){
+        if (file.isFile()) {
           ftpsftpDto.setFileSize(fileSizes);
-        }else{
+        } else {
           ftpsftpDto.setFileSize("--");
         }
         ftpsftpDto.setLastModified(sdf.format(lastTime));
         ftpsftpDto.setJurisdiction(subStrings);
-        ftpsftpDto.setDirectory(files[i].isDirectory());
+        ftpsftpDto.setDirectory(file.isDirectory());
         FTPSFTPDtoList.add(ftpsftpDto);
       }
       return ResponseVO.success(FTPSFTPDtoList);
-    }catch (Exception e){
+    } catch (Exception e) {
       return ResponseVO.fail("进入下一级目录失败");
     }
   }
 
   /**
    * 下载文件
+   *
    * @param request
    * @param response
-   * @param path 路径
-   * @param name 文件名
+   * @param name     文件名
    * @return
    */
   @PostMapping(value = "/downloadFile")
   public void download(HttpServletRequest request,
-                             HttpServletResponse response,
-                             String path,
-                             String name) throws IOException {
+                       HttpServletResponse response,
+                       String name) throws IOException {
     response.setContentType("text/html;charset=utf-8");
     try {
       request.setCharacterEncoding("UTF-8");
     } catch (UnsupportedEncodingException e) {
       log.error("系统错误:" + e.getMessage(), e);
     }
-    try{
+    try {
       InputStream ins = continueFTPService.downLoad(name);
       BufferedInputStream bins = new BufferedInputStream(ins);
       OutputStream outs = response.getOutputStream();
       BufferedOutputStream bouts = new BufferedOutputStream(outs);
       response.setHeader("Content-disposition", "attachment;filename=" + java.net.URLEncoder.encode(name, "UTF-8"));
       response.setContentType("application/x-msdownload");
-      int bytesRead = 0;
+      int bytesRead;
       byte[] buffer = new byte[8192];
       while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
         bouts.write(buffer, 0, bytesRead);
@@ -150,17 +152,17 @@ public class FTPController {
       ins.close();
       bins.close();
       bouts.close();
-      flush(remoteIp,remotePort, uploadUserName, uploadPassword);
-    }catch (Exception e){
+      flush(remoteIp, remotePort, uploadUserName, uploadPassword);
+    } catch (Exception e) {
       log.error("系统错误:" + e.getMessage(), e);
     }
 
   }
 
   @PostMapping(value = "/upload")
-  public ResponseVO upload(@RequestParam("path") String path,@RequestParam("file") MultipartFile file){
-    try{
-      continueFTPService.upload(path,file.getOriginalFilename(),file.getInputStream());
+  public ResponseVO upload(@RequestParam("path") String path, @RequestParam("file") MultipartFile file) {
+    try {
+      continueFTPService.upload(path, file.getOriginalFilename(), file.getInputStream());
       FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
       ftpsftpDto.setUploadPassword(uploadPassword);
       ftpsftpDto.setUploadUserName(uploadUserName);
@@ -168,13 +170,14 @@ public class FTPController {
       ftpsftpDto.setRemoteIp(remoteIp);
       ftpsftpDto.setServicePath(path);
       return openServicePath(ftpsftpDto);
-    }catch (Exception e){
-      return ResponseVO.fail("上传文件失败"+e);
+    } catch (Exception e) {
+      return ResponseVO.fail("上传文件失败" + e);
     }
   }
 
   /**
    * 关闭连接
+   *
    * @return
    * @throws IOException
    */
@@ -183,7 +186,7 @@ public class FTPController {
     try {
       continueFTPService.close();
       return ResponseVO.success("连接已关闭");
-    }catch (Exception e){
+    } catch (Exception e) {
       return ResponseVO.fail("无法关闭连接");
     }
 
@@ -191,21 +194,22 @@ public class FTPController {
 
   /**
    * 删除文件
+   *
    * @param name 文件名称
    * @param path 服务器路径
    * @return
    */
   @PostMapping(value = "/deleteFile")
-  public ResponseVO deleteFile(@RequestParam("name") String name,@RequestParam("path") String path){
-    try{
-      Boolean flag = false;
-      if(path.equals("/")){
-       flag = continueFTPService.delete(path,name);
-      }else{
-       flag = continueFTPService.delete(path+File.separator,name);
+  public ResponseVO deleteFile(@RequestParam("name") String name, @RequestParam("path") String path) {
+    try {
+      boolean flag;
+      if (path.equals("/")) {
+        flag = continueFTPService.delete(path, name);
+      } else {
+        flag = continueFTPService.delete(path + File.separator, name);
       }
-      if(!flag){
-        return  ResponseVO.fail("删除文件失败");
+      if (!flag) {
+        return ResponseVO.fail("删除文件失败");
       }
       FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
       ftpsftpDto.setUploadPassword(uploadPassword);
@@ -214,21 +218,23 @@ public class FTPController {
       ftpsftpDto.setRemoteIp(remoteIp);
       ftpsftpDto.setServicePath(path);
       return openServicePath(ftpsftpDto);
-    }catch (Exception e){
-      return ResponseVO.fail("删除文件失败"+e);
+    } catch (Exception e) {
+      return ResponseVO.fail("删除文件失败" + e);
     }
 
   }
+
   /**
    * 刷新连接
-   * @param host ip地址
-   * @param port 端口
+   *
+   * @param host     ip地址
+   * @param port     端口
    * @param userName 用户名
    * @param password 密码
    * @throws IOException
    */
   public void flush(String host, String port, String userName, String password) throws IOException {
     continueFTPService.close();
-    continueFTPService.initFtpClient(host,Integer.parseInt(port),userName,password);
+    continueFTPService.initFtpClient(host, Integer.parseInt(port), userName, password);
   }
 }

+ 55 - 49
ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/controller/SFTPController.java

@@ -29,11 +29,13 @@ public class SFTPController {
   @Autowired
   private final ContinueSFTPService continueSFTPService;
 
-  public SFTPController(ContinueSFTPService continueSFTPService){
+  public SFTPController(ContinueSFTPService continueSFTPService) {
     this.continueSFTPService = continueSFTPService;
   }
+
   /**
    * 连接SFTP
+   *
    * @param ftpsftpDtos
    * @return 返回所有目录
    */
@@ -43,34 +45,34 @@ public class SFTPController {
     List<FTPSFTPDto> FTPSFTPDtoList = new ArrayList<>();
     try {
       //登陆
-      continueSFTPService.login(ftpsftpDtos.getUploadUserName(), ftpsftpDtos.getUploadPassword(), ftpsftpDtos.getRemoteIp(),Integer.parseInt(ftpsftpDtos.getRemotePort()),"");
+      continueSFTPService.login(ftpsftpDtos.getUploadUserName(), ftpsftpDtos.getUploadPassword(), ftpsftpDtos.getRemoteIp(), Integer.parseInt(ftpsftpDtos.getRemotePort()));
       //获取目录下所有文件
-      ArrayList<ChannelSftp.LsEntry> ftpFileArr= continueSFTPService.listFiles(ftpsftpDtos.getServicePath());
+      ArrayList<ChannelSftp.LsEntry> ftpFileArr = continueSFTPService.listFiles(ftpsftpDtos.getServicePath());
       remoteIp = ftpsftpDtos.getRemoteIp();
       remotePort = ftpsftpDtos.getRemotePort();
       uploadUserName = ftpsftpDtos.getUploadUserName();
       uploadPassword = ftpsftpDtos.getUploadPassword();
-      for (int i = 0; i < ftpFileArr.size(); i++) {
+      for (ChannelSftp.LsEntry lsEntry : ftpFileArr) {
         FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
-        String name = ftpFileArr.get(i).getFilename();
-        SftpATTRS attrs = ftpFileArr.get(i).getAttrs();
+        String name = lsEntry.getFilename();
+        SftpATTRS attrs = lsEntry.getAttrs();
         BigDecimal fileSize = new BigDecimal(attrs.getSize());
         String fileSizes = fileSize.divide(new BigDecimal(1024)).divide(new BigDecimal(1024)).setScale(2, BigDecimal.ROUND_CEILING).toString();
         ftpsftpDto.setName(name);
         ftpsftpDto.setJurisdiction(attrs.getPermissionsString());
-        if(attrs.isDir()){
+        if (attrs.isDir()) {
           ftpsftpDto.setFileSize("--");
-        }else{
-          ftpsftpDto.setFileSize(fileSizes+"MB");
+        } else {
+          ftpsftpDto.setFileSize(fileSizes + "MB");
         }
-        Long time = attrs.getMTime()*1000l;
+        Long time = attrs.getMTime() * 1000L;
         ftpsftpDto.setLastModified(sdf.format(time));
         ftpsftpDto.setDirectory(attrs.isDir());
         FTPSFTPDtoList.add(ftpsftpDto);
       }
 
       return ResponseVO.success(FTPSFTPDtoList);
-    }catch (Exception e){
+    } catch (Exception e) {
       return ResponseVO.fail("连接失败,请检查配置信息");
     }
 
@@ -78,46 +80,46 @@ public class SFTPController {
 
   /**
    * 根据传入的路径 返回上一级/进入下一级
+   *
    * @param ftpsftpDtos
-   * @return
    */
   @PostMapping(value = "/openServicePath")
-  public ResponseVO openServicePath(@RequestBody FTPSFTPDto ftpsftpDtos){
+  public ResponseVO openServicePath(@RequestBody FTPSFTPDto ftpsftpDtos) {
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     List<FTPSFTPDto> FTPSFTPDtoList = new ArrayList<>();
-    try{
-      ArrayList<ChannelSftp.LsEntry> ftpFileArr =continueSFTPService.listFiles(ftpsftpDtos.getServicePath());
-      for (int i = 0; i < ftpFileArr.size(); i++) {
+    try {
+      ArrayList<ChannelSftp.LsEntry> ftpFileArr = continueSFTPService.listFiles(ftpsftpDtos.getServicePath());
+      for (ChannelSftp.LsEntry lsEntry : ftpFileArr) {
         FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
-        String name = ftpFileArr.get(i).getFilename();
-        SftpATTRS attrs = ftpFileArr.get(i).getAttrs();
+        String name = lsEntry.getFilename();
+        SftpATTRS attrs = lsEntry.getAttrs();
         BigDecimal fileSize = new BigDecimal(attrs.getSize());
         String fileSizes = fileSize.divide(new BigDecimal(1024)).divide(new BigDecimal(1024)).setScale(2, BigDecimal.ROUND_CEILING).toString();
         ftpsftpDto.setName(name);
         ftpsftpDto.setJurisdiction(attrs.getPermissionsString());
-        if(attrs.isDir()){
+        if (attrs.isDir()) {
           ftpsftpDto.setFileSize("--");
-        }else{
-          ftpsftpDto.setFileSize(fileSizes+"MB");
+        } else {
+          ftpsftpDto.setFileSize(fileSizes + "MB");
         }
-        Long time = attrs.getMTime()*1000l;
+        Long time = attrs.getMTime() * 1000L;
         ftpsftpDto.setLastModified(sdf.format(time));
         ftpsftpDto.setDirectory(attrs.isDir());
         FTPSFTPDtoList.add(ftpsftpDto);
       }
       return ResponseVO.success(FTPSFTPDtoList);
-    }catch (Exception e){
+    } catch (Exception e) {
       return ResponseVO.fail("进入下一级目录失败");
     }
   }
 
   /**
    * 下载文件
+   *
    * @param request
    * @param response
-   * @param path 路径
-   * @param name 文件名
-   * @return
+   * @param path     路径
+   * @param name     文件名
    */
   @PostMapping(value = "/downloadFile")
   public void download(HttpServletRequest request,
@@ -130,8 +132,8 @@ public class SFTPController {
     } catch (UnsupportedEncodingException e) {
       log.error("系统错误:" + e.getMessage(), e);
     }
-    try{
-      InputStream ins = continueSFTPService.download(path,name);
+    try {
+      InputStream ins = continueSFTPService.download(path, name);
 
       BufferedInputStream bins = new BufferedInputStream(ins);
       OutputStream outs = response.getOutputStream();
@@ -147,17 +149,17 @@ public class SFTPController {
       ins.close();
       bins.close();
       bouts.close();
-      flush(remoteIp,remotePort, uploadUserName, uploadPassword);
-    }catch (Exception e){
+      flush(remoteIp, remotePort, uploadUserName, uploadPassword);
+    } catch (Exception e) {
       log.error("系统错误:" + e.getMessage(), e);
     }
 
   }
 
   @PostMapping(value = "/upload")
-  public ResponseVO upload(@RequestParam("path") String path,@RequestParam("file") MultipartFile file){
-    try{
-      continueSFTPService.upload(path,file.getOriginalFilename(),file.getInputStream());
+  public ResponseVO upload(@RequestParam("path") String path, @RequestParam("file") MultipartFile file) {
+    try {
+      continueSFTPService.upload(path, file.getOriginalFilename(), file.getInputStream());
       FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
       ftpsftpDto.setUploadPassword(uploadPassword);
       ftpsftpDto.setUploadUserName(uploadUserName);
@@ -165,13 +167,14 @@ public class SFTPController {
       ftpsftpDto.setRemoteIp(remoteIp);
       ftpsftpDto.setServicePath(path);
       return openServicePath(ftpsftpDto);
-    }catch (Exception e){
-      return ResponseVO.fail("上传文件失败"+e);
+    } catch (Exception e) {
+      return ResponseVO.fail("上传文件失败" + e);
     }
   }
 
   /**
    * 关闭连接
+   *
    * @return
    * @throws IOException
    */
@@ -180,7 +183,7 @@ public class SFTPController {
     try {
       continueSFTPService.logout();
       return ResponseVO.success("连接已关闭");
-    }catch (Exception e){
+    } catch (Exception e) {
       return ResponseVO.fail("无法关闭连接");
     }
 
@@ -188,21 +191,22 @@ public class SFTPController {
 
   /**
    * 删除文件
+   *
    * @param name 文件名称
    * @param path 服务器路径
    * @return
    */
   @PostMapping(value = "/deleteFile")
-  public ResponseVO deleteFile(@RequestParam("name") String name,@RequestParam("path") String path){
-    try{
+  public ResponseVO deleteFile(@RequestParam("name") String name, @RequestParam("path") String path) {
+    try {
       Boolean flag = false;
-      if(path.equals("/")){
-        flag = continueSFTPService.delete(path,name);
-      }else{
-        flag = continueSFTPService.delete(path+File.separator,name);
+      if (path.equals("/")) {
+        flag = continueSFTPService.delete(path, name);
+      } else {
+        flag = continueSFTPService.delete(path + File.separator, name);
       }
-      if(!flag){
-        return  ResponseVO.fail("删除文件失败");
+      if (!flag) {
+        return ResponseVO.fail("删除文件失败");
       }
       FTPSFTPDto ftpsftpDto = new FTPSFTPDto();
       ftpsftpDto.setUploadPassword(uploadPassword);
@@ -211,21 +215,23 @@ public class SFTPController {
       ftpsftpDto.setRemoteIp(remoteIp);
       ftpsftpDto.setServicePath(path);
       return openServicePath(ftpsftpDto);
-    }catch (Exception e){
-      return ResponseVO.fail("删除文件失败"+e);
+    } catch (Exception e) {
+      return ResponseVO.fail("删除文件失败" + e);
     }
 
   }
+
   /**
    * 刷新连接
-   * @param host ip地址
-   * @param port 端口
+   *
+   * @param host     ip地址
+   * @param port     端口
    * @param userName 用户名
    * @param password 密码
    * @throws IOException
    */
   public void flush(String host, String port, String userName, String password) throws IOException {
     continueSFTPService.logout();
-    continueSFTPService.login(userName,password,host,Integer.parseInt(port),"");
+    continueSFTPService.login(userName, password, host, Integer.parseInt(port));
   }
 }

+ 23 - 22
ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/dto/FTPSFTPDto.java

@@ -1,32 +1,34 @@
 package com.jiayue.ipfcst.ftpsftp.dto;
+
 /**
- * FTPSFTP DTO
+ * FTP SFTP DTO
  *
  * @author whc
  * @version 2.0
  * @since 2021/4/13 15:36
  */
 public class FTPSFTPDto {
-    // 名称
-    private String name;
-    // 大小
-    private String fileSize;
-    // 最后修改日期
-    private String lastModified;
-    // 权限
-    private String jurisdiction;
-    // 是否是文件夹
-    private Boolean directory;
-    // 对方路径
-    private String servicePath;
-    // ip
-    private String remoteIp;
-    // 端口
-    private String remotePort;
-    // 用户名
-    private String uploadUserName;
-    // 密码
-    private String uploadPassword;
+  // 名称
+  private String name;
+  // 大小
+  private String fileSize;
+  // 最后修改日期
+  private String lastModified;
+  // 权限
+  private String jurisdiction;
+  // 是否是文件夹
+  private Boolean directory;
+  // 对方路径
+  private String servicePath;
+  // ip
+  private String remoteIp;
+  // 端口
+  private String remotePort;
+  // 用户名
+  private String uploadUserName;
+  // 密码
+  private String uploadPassword;
+
   public String getRemoteIp() {
     return remoteIp;
   }
@@ -69,7 +71,6 @@ public class FTPSFTPDto {
   }
 
 
-
   public Boolean getDirectory() {
     return directory;
   }

+ 53 - 75
ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/service/ContinueFTPService.java

@@ -5,7 +5,6 @@ import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPFile;
 import org.springframework.stereotype.Service;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
@@ -15,40 +14,35 @@ import java.nio.charset.StandardCharsets;
 public class ContinueFTPService {
   public FTPClient client;
 
-  /*public ContinueFTPService(String host,int port ,String username,  String password) throws IOException {
-    initFtpClient(host, port, username, password);
-  }
-  public ContinueFTPService(String host, String userName, String password)
-    throws SocketException, IOException {
-    initFtpClient(host, 21, userName, password);
-  }*/
 
   /**
    * 登录
-   * @param host
-   * @param port
-   * @param userName
-   * @param password
-   * @throws IOException
+   *
+   * @param host     ip地址
+   * @param port     远程端口
+   * @param userName 用户名
+   * @param password 密码
+   * @throws IOException 抛出异常
    */
   public void initFtpClient(String host, int port, String userName,
                             String password) throws IOException {
 
-    client =new FTPClient();//s生成一个新的client
-    client.connect(host,port);//链接
-    client.login(userName,password);//通过用户名和密码登录
+    client = new FTPClient();//s生成一个新的client
+    client.connect(host, port);//链接
+    client.login(userName, password);//通过用户名和密码登录
 
   }
 
   /**
    * 得到所有目录
-   * @param remotepath
-   * @return
+   *
+   * @param remotepath 远程文件地址
+   * @return 返回FTPFile[]
    */
   public FTPFile[] listFiles(String remotepath) throws IOException {
     client.enterLocalPassiveMode();
-    remotepath = new String(remotepath.getBytes(StandardCharsets.UTF_8),"iso-8859-1");
-    if (client == null){
+    remotepath = new String(remotepath.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
+    if (client == null) {
       return null;
     }
     client.changeWorkingDirectory(remotepath);//获取所有的目录
@@ -57,25 +51,26 @@ public class ContinueFTPService {
 
   /**
    * 上传
-   * @param remotepath(ftp的路径)
-   * @return上传是否成功
-   * @throws FileNotFoundException
+   *
+   * @param remotepath (ftp的路径)
+   * @return boolean 上传是否成功
+   * @throws IOException
    */
-  public boolean upload(String remotepath,String filename,InputStream inputStream) throws IOException {
-    if (null == client){//如果获取到的信息为空则返回false
+  public boolean upload(String remotepath, String filename, InputStream inputStream) throws IOException {
+    if (null == client) {//如果获取到的信息为空则返回false
       return false;
     }
-    boolean res = false;
+
     client.setFileType(FTPClient.BINARY_FILE_TYPE);//设置上传文件的类型
     client.changeWorkingDirectory(remotepath);//获取上传的路径地址
     String charSet = System.getProperties().get("file.encoding").toString();
-    String name = new String(filename.getBytes(charSet),"ISO-8859-1");
-    res=client.storeFile(name,inputStream);
-    return res;
+    String name = new String(filename.getBytes(charSet), StandardCharsets.ISO_8859_1);
+    return client.storeFile(name, inputStream);
   }
 
   /**
    * 下载
+   *
    * @param name 文件名称
    * @return 下载是否成功
    */
@@ -86,9 +81,9 @@ public class ContinueFTPService {
       client.setFileType(FTPClient.BINARY_FILE_TYPE);//设置下载文件的类型
       //获取系统字符集
       String charSet = System.getProperties().get("file.encoding").toString();
-      String fileName = new String(name.getBytes(charSet),"ISO-8859-1");
+      String fileName = new String(name.getBytes(charSet), StandardCharsets.ISO_8859_1);
       ins = client.retrieveFileStream(fileName);
-    }catch (Exception e){
+    } catch (Exception e) {
       log.error("FTP下载错误");
     }
     return ins;
@@ -96,33 +91,34 @@ public class ContinueFTPService {
 
   /**
    * 删除文件
+   *
    * @param remotepath ftp服务端路径
-   * @return
+   * @return boolean
    */
-  public boolean delete(String remotepath,String name) throws IOException {
+  public boolean delete(String remotepath, String name) throws IOException {
     client.changeWorkingDirectory(remotepath);
     String charSet = System.getProperties().get("file.encoding").toString();
-    String fileName = new String(name.getBytes(charSet),"ISO-8859-1");
-    return  client.deleteFile(remotepath+fileName);//删除文件是否成功
+    String fileName = new String(name.getBytes(charSet), StandardCharsets.ISO_8859_1);
+    return client.deleteFile(remotepath + fileName);//删除文件是否成功
   }
 
   /**
    * 创建目录
+   *
    * @param remotepath ftp服务端路径
-   * @return
+   * @return boolean
    */
   public boolean makeDirectory(String remotepath) throws IOException {
-    boolean res = false;
 
-    if (null == client){
-      return res;
+    if (null == client) {
+      return false;
     }
 
     String[] item = remotepath.split("/");//以‘/’分割成字符串数组
-    String currentPath="";
-    for (int i = 0; i <item.length-1 ; i++) {
+    String currentPath = "";
+    for (int i = 0; i < item.length - 1; i++) {
 
-      currentPath = currentPath +"/"+item[i];//创建目录
+      currentPath = currentPath + "/" + item[i];//创建目录
       client.makeDirectory(currentPath);
     }
     return client.makeDirectory(remotepath);
@@ -130,17 +126,18 @@ public class ContinueFTPService {
 
   /**
    * 删除文件
+   *
    * @param remotepath ftp端路径
-   * @return
+   * @return boolean
    */
   private boolean deleteDirectory(String remotepath) throws IOException {
-    boolean res= false;
-    FTPFile[] files= listFiles(remotepath);//获取文件数组
-    for (int i = 0; i <files.length ; i++) {
-      if (files[i].isDirectory()){ //如果是删除目录
-        deleteDirectory(remotepath+"/"+files[i].getName());//删除目录
-      }else {
-        client.deleteFile(remotepath+"/"+files[i].getName());//删除文件
+
+    FTPFile[] files = listFiles(remotepath);//获取文件数组
+    for (FTPFile file : files) {
+      if (file.isDirectory()) { //如果是删除目录
+        deleteDirectory(remotepath + "/" + file.getName());//删除目录
+      } else {
+        client.deleteFile(remotepath + "/" + file.getName());//删除文件
       }
 
     }
@@ -149,46 +146,27 @@ public class ContinueFTPService {
 
   /**
    * 重命名
+   *
    * @param remoteOldPath ftp旧名字文件
    * @param remoteNewPath ftp新名字文件
    * @return 是否修改名字成功
    */
-  public boolean replaceName(String remoteOldPath,String remoteNewPath) throws IOException {
+  public boolean replaceName(String remoteOldPath, String remoteNewPath) throws IOException {
 
-    if (null == client){
+    if (null == client) {
       return false;
     }
-    return client.rename(remoteOldPath,remoteNewPath);
+    return client.rename(remoteOldPath, remoteNewPath);
   }
 
   /**
    * 退出登录
-   * @throws IOException
+   *
+   * @throws IOException 异常
    */
   public void close() throws IOException {
     if (null != client)
       client.logout();
   }
 
-  public static void main (String[] args) {
-    try {
-
-      //ContinueFTPService ft = new ContinueFTPService("43.254.3.182", 21, "syjy", "^YHN7ujm");
-      //   System.out.print( ft.upload("D:\\7za.exe","/ftp"));
-      System.out.println("连接成功");
-      //FTPFile[] files = ft.listFiles("/");
-
-      //System.out.println(ft.upload("/Users/wanghongchen/Desktop/test.txt","/"));
-      /*for (int i = 0; i < files.length; i++) {
-        String name = new String(files[i].getName().getBytes("iso-8859-1"),"UTF-8");
-        System.out.println("内容有:" + name);
-      }*/
-      //ft.close();
-    }catch (Exception e){
-      System.out.println("连接失败"+e);
-    }
-    //System.out.println("删除文件:"+ft.delete("222.png"));
-  }
-
-
 }

+ 29 - 123
ipfcst-console/src/main/java/com/jiayue/ipfcst/ftpsftp/service/ContinueSFTPService.java

@@ -12,50 +12,15 @@ import java.util.Vector;
 @Service
 @Slf4j
 public class ContinueSFTPService {
-  private String Type = "sftp";
 
   private ChannelSftp sftp;
   private Session session;
-  private String username;
-  private String password;
-  private String privateKey;
-  private String host;
-  private int port;
-
-
-/*  public  ContinueSFTPService(String username, String password, String host, int port) throws JSchException {//port=22
-     this.username = username;
-     this.password = password;
-     this.privateKey = "";
-     this.host = host;
-     this.port = port;
-     login(this.username,this.password,this.host,this.port,"");
-  }*/
-
-
- /* *
-  public ContinueSFTPService(String username, String host, int port, String privateKey) {
-
-    this.username = username;
-
-    this.host = host;
-
-    this.port = port;
-
-    this.privateKey = privateKey;
-
-  }*/
-
-
-
 
   /**
-
    * 连接sftp服务器
-
    */
 
-  public void login(String username,String password,String host,int port,String privateKey){
+  public void login(String username, String password, String host, int port) {
 
     try {
 
@@ -73,7 +38,6 @@ public class ContinueSFTPService {
       session.setTimeout(100000);
 
 
-
       Properties config = new Properties();
 
       config.put("StrictHostKeyChecking", "no");
@@ -83,8 +47,8 @@ public class ContinueSFTPService {
       session.connect();
 
 
-
-      Channel channel = session.openChannel(Type);
+      String type = "sftp";
+      Channel channel = session.openChannel(type);
 
       channel.connect();
 
@@ -99,12 +63,10 @@ public class ContinueSFTPService {
   }
 
   /**
-
    * 关闭连接 server
-
    */
 
-  public void logout(){
+  public void logout() {
 
     if (sftp != null) {
 
@@ -129,42 +91,33 @@ public class ContinueSFTPService {
   }
 
   /**
-
    * 将输入流的数据上传到sftp作为文件。
-
-   * @param directory  上传到该目录
-
-   * @param sftpFileName  sftp端文件名
-
-   * @param input   输入流
-
+   *
+   * @param directory    上传到该目录
+   * @param sftpFileName sftp端文件名
+   * @param input        输入流
    */
 
-  public void upload(String directory, String sftpFileName, InputStream input) throws SftpException{
+  public void upload(String directory, String sftpFileName, InputStream input) throws SftpException {
 
-    try{
+    try {
       sftp.cd(directory);
       sftp.put(input, sftpFileName);  //上传文件
-    }catch (Exception e){
+    } catch (Exception e) {
       log.error("文件上传失败");
     }
   }
 
 
-
   /**
-
    * 下载文件。
-
-   * @param directory 下载目录
-
+   *
+   * @param directory    下载目录
    * @param downloadFile 下载的文件
-
-   * @param saveFile 存在本地的路径
-
+   * @param saveFile     存在本地的路径
    */
 
-  public void download(String directory, String downloadFile, String saveFile) throws SftpException, FileNotFoundException{
+  public void download(String directory, String downloadFile, String saveFile) throws SftpException, FileNotFoundException {
 
     if (directory != null && !"".equals(directory)) {
 
@@ -179,55 +132,38 @@ public class ContinueSFTPService {
   }
 
   /**
-
    * 下载文件
-
-   * @param directory 下载目录
-
+   *
+   * @param directory    下载目录
    * @param downloadFile 下载的文件名
-
    * @return 字节数组
-
    */
 
-  public InputStream download(String directory, String downloadFile) throws SftpException, IOException{
+  public InputStream download(String directory, String downloadFile) throws SftpException, IOException {
 
     if (directory != null && !"".equals(directory)) {
 
       sftp.cd(directory);
 
     }
-
-    InputStream is = sftp.get(downloadFile);
-
-
-
-    //byte[] fileData = IOUtils.toByteArray(is);
-
-
-
-    //return fileData;
-    return is;
+    return sftp.get(downloadFile);
   }
 
   /**
-
    * 删除文件
-
-   * @param directory 要删除文件所在目录
-
+   *
+   * @param directory  要删除文件所在目录
    * @param deleteFile 要删除的文件
-
    */
 
-  public Boolean delete(String directory, String deleteFile){
+  public Boolean delete(String directory, String deleteFile) {
 
     try {
       sftp.cd(directory);
 
       sftp.rm(deleteFile);
 
-    }catch (Exception e){
+    } catch (Exception e) {
       e.printStackTrace();
       return false;
     }
@@ -236,32 +172,24 @@ public class ContinueSFTPService {
   }
 
   /**
-
    * 列出目录下的文件
+   *
    * @param directory 要列出的目录
-   * @return
-
-
    */
 
   public ArrayList<ChannelSftp.LsEntry> listFiles(String directory) throws SftpException {
     ArrayList<ChannelSftp.LsEntry> files = new ArrayList<>();
     sftp.cd(directory);
     Vector lss = sftp.ls("*");
-    for (int i = 0; i < lss.size(); i++)
-    {
+    for (int i = 0; i < lss.size(); i++) {
       Object obj = lss.elementAt(i);
-      if (obj instanceof ChannelSftp.LsEntry)
-      {
+      if (obj instanceof ChannelSftp.LsEntry) {
         ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) obj;
-        if (true && !entry.getAttrs().isDir())
-        {
+        if (!entry.getAttrs().isDir()) {
           files.add(entry);
         }
-        if (true && entry.getAttrs().isDir())
-        {
-          if (!entry.getFilename().equals(".") && !entry.getFilename().equals(".."))
-          {
+        if (entry.getAttrs().isDir()) {
+          if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) {
             files.add(entry);
           }
         }
@@ -270,27 +198,5 @@ public class ContinueSFTPService {
     return files;
 
   }
-  public static void main (String[] args) {
-    try {
-      //String username, String password, String host, int port
-      /*ContinueSFTPService continueSFTPService=new ContinueSFTPService("root","Jydl*3377","192.168.9.103",22);
-
-      //login("root","Jydl*3377","192.168.9.103",22);
-      System.out.println("连接成功");
-      ArrayList<ChannelSftp.LsEntry> ftpFileArr = continueSFTPService.listFiles(File.separator+"usr");
-      for (int ii = 0; ii < ftpFileArr.size(); ii++) {
-        System.out.println("name == "+ ftpFileArr.get(ii).getFilename());
-        System.out.println("attrs"+ftpFileArr.get(ii).getAttrs());
-        System.out.println("Longname"+ftpFileArr.get(ii).getLongname());
-      }
-      continueSFTPService.logout();
-      System.out.println("连接已断开");*/
-    }catch (Exception e){
-      System.out.println("连接失败"+e);
-    }
-
-  }
-
-
 
 }

+ 13 - 17
ipfcst-console/src/test/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileServiceTest.java

@@ -2,8 +2,6 @@ package com.jiayue.ipfcst.fileupload.service;
 
 import com.alibaba.fastjson.JSON;
 import com.jiayue.ipfcst.BaseTest;
-import com.jiayue.ipfcst.common.core.exception.BusinessException;
-import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.WeatherStationStatusData;
 import com.jiayue.ipfcst.console.service.ElectricFieldService;
 import com.jiayue.ipfcst.console.util.RedisUtils;
@@ -11,11 +9,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import javax.xml.ws.Action;
-
-import java.util.*;
-
-import static org.junit.jupiter.api.Assertions.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 文件生成测试类
@@ -33,21 +29,21 @@ public class E63UploadFileServiceTest extends BaseTest {
   private RedisUtils redisUtils;
 
   @Test
-  public void testCreateFile() throws Exception{
-      e63UploadFileService.generateNbqOrFjFile(new Date());
+  public void testCreateFile() throws Exception {
+    e63UploadFileService.generateNbqOrFjFile(new Date());
   }
 
   @Test
-  public void testRedis() throws Exception{
-    Map<String,String> map = new HashMap<>();
-    map.put("globalR","534.89");
-    map.put("DirectR","472.52");
-    map.put("DiffuseR","62.37");
+  public void testRedis() throws Exception {
+    Map<String, String> map = new HashMap<>();
+    map.put("globalR", "534.89");
+    map.put("DirectR", "472.52");
+    map.put("DiffuseR", "62.37");
 
-    redisUtils.hmset("qxz-J00026-11111",map);
+    redisUtils.hmset("qxz-J00026-11111", map);
     System.out.println("===========================================================");
-    Map<String,String> getMap = redisUtils.hgetall("qxz-J00026-123");
-    System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:"+getMap.isEmpty());
+    Map<String, String> getMap = redisUtils.hgetall("qxz-J00026-123");
+    System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:" + getMap.isEmpty());
     getMap.keySet().forEach(key -> System.out.println("map.get(" + key + ") = " + map.get(key)));
 
     WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(getMap), WeatherStationStatusData.class);

+ 0 - 9
ipfcst-console/src/test/java/com/jiayue/ipfcst/fileupload/service/TestFtpClient.java

@@ -1,21 +1,12 @@
 package com.jiayue.ipfcst.fileupload.service;
 
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.IoUtil;
-import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.ftp.Ftp;
 import cn.hutool.extra.ftp.FtpConfig;
 import cn.hutool.extra.ftp.FtpMode;
-import com.jiayue.ipfcst.common.data.entity.UploadFileLog;
-import com.jiayue.ipfcst.common.data.entity.UploadURL;
-import com.jiayue.ipfcst.fileupload.util.FileConstant;
 
 import java.io.*;
 import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * TODO