Kaynağa Gözat

增加文件日志查询相关代码

xusl 3 yıl önce
ebeveyn
işleme
a4971a5b3b
45 değiştirilmiş dosya ile 2313 ekleme ve 446 silme
  1. 1 1
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ClassUtil.java
  2. 6 5
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java
  3. 18 1
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateTimeUtil.java
  4. 86 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ManualUploadLog.java
  5. 6 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/ManualUploadLogRepository.java
  6. 4 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/UploadObjectRepository.java
  7. 12 7
      ipfcst-console/src/main/frontend/views/uploadFile/UploadFileChannel/index.vue
  8. 22 1
      ipfcst-console/src/main/frontend/views/uploadFile/queryUploadFile/index.vue
  9. 0 422
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/IEC102/ServerFor102NMService.java
  10. 0 2
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/IEC102/ServerFor102TransitHandler.java
  11. 302 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileChannelController.java
  12. 72 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileCodeController.java
  13. 120 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileLogController.java
  14. 32 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileLogDetailController.java
  15. 183 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadObjectController.java
  16. 43 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadURLController.java
  17. 9 7
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java
  18. 223 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadService.java
  19. 270 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadTransactionService.java
  20. 50 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogDetailService.java
  21. 516 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogService.java
  22. 36 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadObjectService.java
  23. 46 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadURLService.java
  24. 14 0
      ipfcst-console/src/main/resources/vms/CDQ.vm
  25. 8 0
      ipfcst-console/src/main/resources/vms/CDQFS.vm
  26. 8 0
      ipfcst-console/src/main/resources/vms/CDQFZD.vm
  27. 14 0
      ipfcst-console/src/main/resources/vms/CDQ_F.vm
  28. 9 0
      ipfcst-console/src/main/resources/vms/CDQ_USE.vm
  29. 9 0
      ipfcst-console/src/main/resources/vms/CDQ_USE_F.vm
  30. 27 0
      ipfcst-console/src/main/resources/vms/CFT.vm
  31. 14 0
      ipfcst-console/src/main/resources/vms/DQ.vm
  32. 8 0
      ipfcst-console/src/main/resources/vms/DQFS.vm
  33. 8 0
      ipfcst-console/src/main/resources/vms/DQFZD.vm
  34. 14 0
      ipfcst-console/src/main/resources/vms/DQ_F.vm
  35. 9 0
      ipfcst-console/src/main/resources/vms/DQ_USE.vm
  36. 9 0
      ipfcst-console/src/main/resources/vms/DQ_USE_F.vm
  37. 14 0
      ipfcst-console/src/main/resources/vms/FJ.vm
  38. 21 0
      ipfcst-console/src/main/resources/vms/INDICATORS.vm
  39. 11 0
      ipfcst-console/src/main/resources/vms/JSONLOG.vm
  40. 14 0
      ipfcst-console/src/main/resources/vms/NBQ.vm
  41. 15 0
      ipfcst-console/src/main/resources/vms/QXZ.vm
  42. 6 0
      ipfcst-console/src/main/resources/vms/SCF.vm
  43. 6 0
      ipfcst-console/src/main/resources/vms/SCG.vm
  44. 8 0
      ipfcst-console/src/main/resources/vms/THEROY.vm
  45. 10 0
      ipfcst-console/src/main/resources/vms/THEROY_F.vm

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

@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
  * @author L.cm
  */
 @UtilityClass
-public class ClassUtil extends org.springframework.util.ClassUtils {
+public class ClassUtil extends ClassUtils {
 	private final ParameterNameDiscoverer PARAMETERNAMEDISCOVERER = new DefaultParameterNameDiscoverer();
 
 	/**

+ 6 - 5
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java

@@ -1,6 +1,7 @@
 package com.jiayue.ipfcst.common.core.util;
 
 import com.sun.istack.internal.NotNull;
+
 import java.util.Calendar;
 
 /**
@@ -35,7 +36,7 @@ public abstract class DateMomentUtil {
      * @return 时刻
      */
     public static int getMoment(@NotNull final Long dateTime, @NotNull final Long momentLength) {
-        return (int) ((dateTime - com.jiayue.ipfcst.common.core.util.DateMomentUtil.getDayStartTime(dateTime)) / momentLength) + 1;
+        return (int) ((dateTime - DateMomentUtil.getDayStartTime(dateTime)) / momentLength) + 1;
     }
 
     /**
@@ -52,9 +53,9 @@ public abstract class DateMomentUtil {
     public static long getMomentTime(@NotNull final Long dateTime, @NotNull final int signType, @NotNull final Long momentLength) throws Exception {
         if (24 * 3600 * 1000L % momentLength != 0)
             throw new Exception("时刻长度非法,时刻长度需要能够被一天整除");
-        int moment = com.jiayue.ipfcst.common.core.util.DateMomentUtil.getMoment(dateTime, momentLength);// 获取指定时间所在时刻数
+        int moment = DateMomentUtil.getMoment(dateTime, momentLength);// 获取指定时间所在时刻数
         long differentTime = moment * momentLength;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
-        long dayStartTime = com.jiayue.ipfcst.common.core.util.DateMomentUtil.getDayStartTime(dateTime);
+        long dayStartTime = DateMomentUtil.getDayStartTime(dateTime);
         switch (signType) {
             case 2:
                 return dayStartTime + differentTime;
@@ -77,7 +78,7 @@ public abstract class DateMomentUtil {
     public static long getDayFirstMomentTime(@NotNull final Long dateTime, @NotNull final int signType, @NotNull final Long momentLength) throws Exception {
         if (24 * 3600 * 1000L % momentLength != 0)
             throw new Exception("时刻长度非法,时刻长度需要能够被一天整除");
-        long dayStartTime = com.jiayue.ipfcst.common.core.util.DateMomentUtil.getDayStartTime(dateTime);
+        long dayStartTime = DateMomentUtil.getDayStartTime(dateTime);
         switch (signType) {
             case 2:
                 return dayStartTime + momentLength;
@@ -154,6 +155,6 @@ public abstract class DateMomentUtil {
      * @return 自然天数
      */
     public static Integer getDaysBetweenTwoDate(Long dateFrom, Long dateTo) {
-        return (int) ((com.jiayue.ipfcst.common.core.util.DateMomentUtil.getDayStartTime(dateTo) - com.jiayue.ipfcst.common.core.util.DateMomentUtil.getDayStartTime(dateFrom)) / (1000 * 60 * 60 * 24L));
+        return (int) ((DateMomentUtil.getDayStartTime(dateTo) - DateMomentUtil.getDayStartTime(dateFrom)) / (1000 * 60 * 60 * 24L));
     }
 }

+ 18 - 1
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateTimeUtil.java

@@ -182,7 +182,7 @@ public class DateTimeUtil {
      * @param dateDate
      * @return
      */
-    public static String dateToStrLong(java.util.Date dateDate) {
+    public static String dateToStrLong(Date dateDate) {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String dateString = formatter.format(dateDate);
         return dateString;
@@ -231,4 +231,21 @@ public class DateTimeUtil {
             return false;
         }
     }
+
+    /**
+     * 判断时间是不是今天
+     * @param date
+     * @return    是返回true,不是返回false
+     */
+    public static boolean isNow(Date date) {
+        //当前时间
+        Date now = new Date();
+        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
+        //获取今天的日期
+        String nowDay = sf.format(now);
+        //对比的时间
+        String day = sf.format(date);
+        return day.equals(nowDay);
+    }
+
 }

+ 86 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ManualUploadLog.java

@@ -0,0 +1,86 @@
+package com.jiayue.ipfcst.common.data.entity;
+
+import com.jiayue.ipfcst.common.data.abst.AbstractBaseEntity;
+import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * 手动上传文件记录
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/7/22 11:24
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Entity
+public class ManualUploadLog extends AbstractBaseEntity {
+
+
+    /**
+     * 编号
+     */
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO, generator = "myid")
+    @GenericGenerator(name = "myid", strategy = "com.jiayue.ipfcst.common.data.entity.id.CustomIDGenerator")
+    @Column
+    private Integer id;
+
+
+    /**
+     * 上报对象主键ID
+     */
+    @Column
+    private Integer uploadObjectId;
+
+    /**
+     * 上传时间
+     */
+    @Column
+    private Date uploadDate;
+
+    /**
+     * 上传目录
+     */
+    @Column
+    private String uploadCatalog;
+
+    /**
+     * 上报对象名称
+     */
+    @Column
+    private String uploadObjectName;
+
+    /**
+     * 上报对象编号
+     */
+    @Column
+    private String uploadObjectNo;
+
+    /**
+     * 文件名称
+     */
+    @Column
+    private String fileName;
+
+    /**
+     * 文件类型
+     */
+    @Column
+    @Enumerated(EnumType.STRING)
+    private FileTypeEnum fileTypeEnum;
+
+
+    /**
+     * 上报设备ID(指定气象站或测风塔)
+     */
+    @Column
+    private String uploadEquipmentID;
+
+
+}

+ 6 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/ManualUploadLogRepository.java

@@ -0,0 +1,6 @@
+package com.jiayue.ipfcst.common.data.repository;
+
+import com.jiayue.ipfcst.common.data.entity.ManualUploadLog;
+
+public interface ManualUploadLogRepository extends BaseRepository<ManualUploadLog,Integer> {
+}

+ 4 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/UploadObjectRepository.java

@@ -2,6 +2,8 @@ package com.jiayue.ipfcst.common.data.repository;
 
 import com.jiayue.ipfcst.common.data.entity.UploadObject;
 
+import java.util.List;
+
 /**
  * 上报对象表仓储
  *
@@ -11,4 +13,6 @@ import com.jiayue.ipfcst.common.data.entity.UploadObject;
 public interface UploadObjectRepository extends BaseRepository<UploadObject, Integer> {
 
     UploadObject findByObjectNo(String no);
+
+    List<UploadObject> findByStationCode(String stationCode);
 }

+ 12 - 7
ipfcst-console/src/main/frontend/views/uploadFile/UploadFileChannel/index.vue

@@ -573,6 +573,18 @@
                 </el-form-item>
               </el-col>
               <el-col :span="10" :offset="1">
+                <el-form-item label="场站编号:" prop="stationCode" label-width="150px" style="min-width: 110px">
+                  <el-input v-model="form.stationCode" placeholder="必填项" maxlength="32"/>
+                </el-form-item>
+              </el-col>
+            </el-row>
+            <el-row>
+              <el-col :span="10" :offset="1">
+                <el-form-item label="上报对象备注:" prop="uploadObjectRemarks" label-width="150px" style="min-width: 110px">
+                  <el-input v-model="form.uploadObjectRemarks" placeholder="选填项" maxlength="85"/>
+                </el-form-item>
+              </el-col>
+              <el-col :span="10" :offset="1">
                 <el-form-item label="上报嘉越D5000:" prop="uploadD5000" label-width="150px">
                   <el-select v-model="form.uploadD5000" placeholder="请选择" filterable style="width: 100%">
                     <el-option
@@ -584,13 +596,6 @@
                 </el-form-item>
               </el-col>
             </el-row>
-            <el-row>
-              <el-col :span="10" :offset="1">
-                <el-form-item label="上报对象备注:" prop="uploadObjectRemarks" label-width="150px" style="min-width: 110px">
-                  <el-input v-model="form.uploadObjectRemarks" placeholder="选填项" maxlength="85"/>
-                </el-form-item>
-              </el-col>
-            </el-row>
           </fieldset>
         </el-form>
         <span slot="footer" class="dialog-footer">

+ 22 - 1
ipfcst-console/src/main/frontend/views/uploadFile/queryUploadFile/index.vue

@@ -9,6 +9,15 @@
         size="small"
         @change="seachLogInfo"
       />
+      <span style="font-weight: bold;font-size: 14px">场站名称:</span>
+      <el-select v-model="stationCode" size="small">
+        <el-option
+          v-for="item in stationList"
+          :key="item.stationCode"
+          :label="item.name"
+          :value="item.id"
+        />
+      </el-select>
       <span style="font-weight: bold;font-size: 14px">上报对象:</span>
       <el-select v-model="uploadObjectId" size="small" @change="uploadObjectChange">
         <el-option
@@ -210,6 +219,7 @@ export default {
       uploadObjectId: '',
       uploadFileType: '',
       uploadList: [],
+      stationList: [],
       detaileTable: [],
       uploadFileTypeList: [],
       FileTypeList: [],
@@ -243,12 +253,13 @@ export default {
   },
   methods: {
     get() {
-      Promise.all([this.getAll(), this.getFileType(), this.getStatusEnum(), this.getProtocolEnum(), this.getFileTypeEnum()]).then((res) => {
+      Promise.all([this.getAll(), this.getFileType(), this.getStatusEnum(), this.getProtocolEnum(), this.getFileTypeEnum(), this.getStationList()]).then((res) => {
         this.uploadList = res[0]
         this.uploadFileTypeList = res[1]
         this.fileStatusEnum = res[2]
         this.uploadProtocolEnum = res[3]
         this.fileTypeEnum = res[4]
+        this.stationList = res[5]
         this.updateFilterEvent()
       })
     },
@@ -326,6 +337,16 @@ export default {
         })
       })
     },
+    getStationList() {
+      const a = this.$axios
+      return new Promise(function(resolve, reject) {
+        a.get('/uploadObject/getFileType').then(res => {
+          resolve(res.data)
+        }).catch((error) => {
+          this.$message.error('获取上报文件类型出错' + error)
+        })
+      })
+    },
     // 查询
     seachLogInfo() {
       this.loading = true

+ 0 - 422
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/IEC102/ServerFor102NMService.java

@@ -1,422 +0,0 @@
-package com.jiayue.ipfcst.fileupload.IEC102;
-
-import cn.hutool.core.map.MapUtil;
-import cn.hutool.core.util.ArrayUtil;
-import cn.hutool.core.util.StrUtil;
-import com.jiayue.ipfcst.common.data.entity.ElectricField;
-import com.jiayue.ipfcst.common.data.entity.UploadFileChannel;
-import com.jiayue.ipfcst.common.data.entity.UploadFileLog;
-import com.jiayue.ipfcst.common.data.entity.UploadObject;
-import com.jiayue.ipfcst.fileupload.dto.Validate102Dto;
-import com.jiayue.ipfcst.fileupload.util.FileConstant;
-import com.jiayue.ipfcst.fileupload.util.FileMutableInteger;
-import com.jiayue.ipfcst.fileupload.util.FileUtil;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * 102内蒙服务端业务处理类
- *
- * @author xsl
- * @version 3.0
- */
-@Service
-public class ServerFor102NMService extends Base102Service {
-  @Transactional(propagation = Propagation.REQUIRED)
-  public String handlerMessage(String receiveMessage, UploadObject uploadObject, UploadFileChannel uploadFileChannel, ElectricField electricField, Logger log, ChannelHandlerContext ctx) {
-    String[] rmArray = IEC102Uitl.stingToArray(receiveMessage);
-    String sendMessage = "";
-    String sendCtrlChinese = "";
-    String receiveCtrlChinese = "";
-
-    if (FileConstant.validateMessage.get(uploadFileChannel.getId()+"")!=null){
-      // 需要校验接收的帧是否正确
-      Validate102Dto validate102Dto = FileConstant.validateMessage.get(uploadFileChannel.getId()+"");
-      if (!validate102Dto.getMessageFirst().equals(rmArray[0])){
-        log.info(ctx.channel().remoteAddress()+" - "+"调度应该传"+validate102Dto.getMessageFirst()+"帧并且原因是"+validate102Dto.getMessageReason()+",实际传"+IEC102Uitl.delimiterStringBySpace(receiveMessage)+",断开通道重启");
-        channelCloseConnect(ctx,uploadObject,uploadFileChannel);
-        return "";
-      }
-    }
-
-    if ("10".equals(rmArray[0])) {
-      // 获取控制域,根据功能码判断业务流
-      String fc = rmArray[1].substring(1);
-      if (FileConstant.validateMessage.get(uploadFileChannel.getId()+"")!=null){
-        // 需要校验接收的帧是否正确
-        Validate102Dto validate102Dto = FileConstant.validateMessage.get(uploadFileChannel.getId()+"");
-        if (!fc.equals(validate102Dto.getMessageReason())){
-          log.info(ctx.channel().remoteAddress()+" - "+"调度应该传10原因是"+validate102Dto.getMessageReason()+",实际传"+IEC102Uitl.delimiterStringBySpace(receiveMessage)+",断开通道重启");
-          channelCloseConnect(ctx,uploadObject,uploadFileChannel);
-          return "";
-        }
-      }
-
-      if ("0".equals(fc)) {
-        receiveCtrlChinese = "复位通信";
-        // 回复链路
-        sendMessage = makeMessage10("00");
-        sendCtrlChinese = "确认复位";
-      } else if ("9".equals(fc)) {
-        receiveCtrlChinese = "召唤链路";
-        // 回复链路
-        sendMessage = makeMessage10("0B");
-        sendCtrlChinese = "回应链路请求帧";
-      } else if ("A".equals(fc)) {
-        receiveCtrlChinese = "召唤一级数据";
-        // 先判断文件上报次数累计的缓存变量是否存在
-        Map<String, FileMutableInteger> filterMap = FileConstant.uploadCountMap.entrySet().stream().filter(r -> uploadObject.getObjectNo().equals(r.getKey().substring(0, r.getKey().indexOf("@"))))
-          .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
-            (oldValue, newValue) -> oldValue, LinkedHashMap::new));
-        // 上报文件名
-        String fileNameKey = "";
-        String typeSign = "";
-        if (MapUtil.isNotEmpty(filterMap)) {
-          sendCtrlChinese = "子站向主站传输文件内容";
-          // 不是第一次要文件了
-          for (Map.Entry<String, FileMutableInteger> entry : filterMap.entrySet()) {
-            fileNameKey = entry.getKey();
-            log.info(ctx.channel().remoteAddress()+" - "+"上传文件===>"+entry.getKey());
-            typeSign = "199";
-            break;
-          }
-        } else {
-          sendCtrlChinese = "子站向主站传输基本文件信息";
-          // 从待上报的缓存中取一个文件放入次数变量中
-          Map<String, UploadFileLog> readyUploadFileMap = super.filterFileByObjectNo(uploadObject.getObjectNo(), FileConstant.readyUploadFileMap, log);
-          for (Map.Entry<String, UploadFileLog> entry : readyUploadFileMap.entrySet()) {
-            // 从待上报缓存中取一个加入到统计变量中
-            FileMutableInteger fileMutableInteger = new FileMutableInteger(0);
-            FileConstant.uploadCountMap.put(entry.getKey(), fileMutableInteger);
-            log.info(ctx.channel().remoteAddress()+" - "+"找到文件===>"+entry.getKey());
-            fileNameKey = entry.getKey();
-            typeSign = "198";
-            break;
-          }
-          Validate102Dto dto = new Validate102Dto();
-          dto.setMessageFirst("68");
-          dto.setMessageReason("07,0D");
-          FileConstant.validateMessage.put(uploadFileChannel.getId()+"",dto);
-        }
-        if ("".equals(fileNameKey)) {
-          sendCtrlChinese = "不正常的回复";
-          sendMessage = "1000FFFFFE16";
-          log.info(ctx.channel().remoteAddress()+" - "+"主站不正常的调用,导致取不到文件无法上报");
-        } else {
-          // 生成传输文件的68帧
-          sendMessage = uploadFile68(typeSign, fileNameKey, electricField, uploadObject, uploadFileChannel, log);
-        }
-      } else if ("B".equals(fc)) {
-        receiveCtrlChinese = "召唤二级数据";
-        // 获取此通道下的上报文件
-        Map<String, UploadFileLog> readyUploadFileMap = super.filterFileByObjectNo(uploadObject.getObjectNo(), FileConstant.readyUploadFileMap, log);
-
-        if (MapUtil.isNotEmpty(readyUploadFileMap)) {
-          // 文件缓存中有上报文件
-          sendMessage = makeMessage10("29");
-          sendCtrlChinese = "希望向主站传输一级数据";
-          Validate102Dto dto = new Validate102Dto();
-          dto.setMessageFirst("10");
-          dto.setMessageReason("A");
-          FileConstant.validateMessage.put(uploadFileChannel.getId()+"",dto);
-        } else {
-          // 没有文件
-          sendMessage = makeMessage10("09");
-          sendCtrlChinese = "没有文件需要上报";
-          Validate102Dto dto = new Validate102Dto();
-          dto.setMessageFirst("10");
-          dto.setMessageReason("B");
-          FileConstant.validateMessage.put(uploadFileChannel.getId()+"",dto);
-        }
-      }
-    } else {
-      // 68开头报文判断传输原因
-      String cot = rmArray[9];
-      if ("07".equals(cot)) {
-        receiveCtrlChinese = "主站允许本次文件请求";
-        sendMessage = "1020FFFF1E16";
-        sendCtrlChinese = "确认有一级数据";
-        Validate102Dto dto = new Validate102Dto();
-        dto.setMessageFirst("10");
-        dto.setMessageReason("A");
-        FileConstant.validateMessage.put(uploadFileChannel.getId()+"",dto);
-      } else {
-        if ("0A".equals(cot)) {
-          // 上报成功
-          receiveCtrlChinese = "文件成功接收结束";
-          super.totalFileUploadNums(uploadObject, uploadFileChannel, "", log);
-        } else {
-          // 上报失败
-          receiveCtrlChinese = "error";
-          if ("0D".equals(cot)) {
-            receiveCtrlChinese = "文件重复传输";
-          } else if ("0B".equals(cot)) {
-            receiveCtrlChinese = "文件名错误";
-          } else if ("0C".equals(cot)) {
-            receiveCtrlChinese = "文件过大(大于1MB)";
-          } else if ("0E".equals(cot)) {
-            receiveCtrlChinese = "文件类型错误";
-          } else if ("10".equals(cot)) {
-            receiveCtrlChinese = "文件接收错误(长度、MD5校验等),发送方准备重新传输该文件";
-          }
-          super.totalFileUploadNums(uploadObject, uploadFileChannel, receiveCtrlChinese, log);
-        }
-        sendCtrlChinese = "对上一条命令确认";
-        sendMessage = "1000FFFFFE16";
-        Validate102Dto dto = new Validate102Dto();
-        dto.setMessageFirst("10");
-        dto.setMessageReason("B");
-        FileConstant.validateMessage.put(uploadFileChannel.getId()+"",dto);
-      }
-    }
-    log.info(ctx.channel().remoteAddress()+" - "+"接收报文:[" + receiveCtrlChinese + "]" + IEC102Uitl.delimiterStringBySpace(receiveMessage));
-    log.info(ctx.channel().remoteAddress()+" - "+"发送报文:[" + sendCtrlChinese + "]" + IEC102Uitl.delimiterStringBySpace(sendMessage));
-    return sendMessage;
-  }
-
-  /**
-   * 生成10帧报文
-   * 格式说明:10|控制域|地址低字节|地址高字节|校验和|16
-   *
-   * @param ctrl 控制域字节
-   * @return 10帧报文
-   */
-  private String makeMessage10(String ctrl) {
-    String[] returnMessage = {"10", "ctrl", "FF", "FF", "crc", "16"};
-    String crc = IEC102Uitl.makeChecksum(ctrl + returnMessage[2] + returnMessage[3]);
-    returnMessage[1] = ctrl;
-    returnMessage[4] = crc;
-    String sendMessage = ArrayUtil.join(returnMessage, "");
-    return sendMessage.toUpperCase();
-  }
-
-  /**
-   * 传输文件的68帧报文
-   * crc校验和:从[控制域]到[校验和]之前
-   * 帧长:从[控制域]到[校验和]之前所有字节数
-   *
-   * @return 68帧报文
-   */
-  private String uploadFile68(String typeSign, String fileNameKey, ElectricField electricField, UploadObject uploadObject, UploadFileChannel uploadFileChannel, Logger log) {
-    String[] tempKey = new String[3];
-    tempKey[0] = fileNameKey.substring(0,fileNameKey.indexOf("@",0));
-    tempKey[1] = fileNameKey.substring(fileNameKey.indexOf("@",1)+1,fileNameKey.indexOf("@",2));
-    tempKey[2] = fileNameKey.substring(fileNameKey.indexOf("@",2)+1);
-    String charsetName = uploadObject.getUploadFileCharSetEnum().getMessage();
-    String sendMessage = "";
-    // 获取本地物理文件路径
-    String filePath = FileUtil.getFileUploadPath() + File.separator + "process" + File.separator + tempKey[0] + File.separator + tempKey[1] + File.separator + tempKey[2];
-
-    if ("198".equals(typeSign)) {
-      // 子站向主站传输文件基本信息(68|帧长低字节|帧长高字节|68|控制域|地址低字节|地址高字节|类型标识|可变限定词|传输原因|设备地址低字节|设备地址高字节|记录地址|文件名字节|文件类型|文件长度|文件内容MD5数字签名|校验和|16)
-      String[] returnMessage = {"68", "mlLow", "mlHeight", "68", "28", "FF", "FF", "C6", "01", "06", "FF", "FF", "00", "fileNameByte", "fileType", "fileContentAllLength", "fileContentMD5", "crc", "16"};
-      // 生成文件名
-      String fileName = tempKey[2];
-      byte[] tempFileNameBytes = null;
-      try {
-        tempFileNameBytes = fileName.getBytes(charsetName);
-      } catch (Exception e) {
-        log.error("转换文件名编码失败", e);
-      }
-      // 获取文件名称长度
-      String fileNameLength = uploadFileChannel.getUploadFileNameLengthEnum().getMessage();
-      String fileNameByte = ByteUtil.Byte2String(tempFileNameBytes);
-      returnMessage[13] = StrUtil.padAfter(fileNameByte.replace(" ", ""), Integer.parseInt(fileNameLength) * 2, '0');
-      // 生成类型标识
-      Map<String, Integer> codeMap = super.getFileCode();
-      returnMessage[14] = Integer.toHexString(codeMap.get(tempKey[1]));
-      String fileContentByte = "";
-      String tempContent = "";
-      try {
-        fileContentByte = nmCreateFileMessageHex(filePath, log, uploadObject.getId(), fileNameKey);
-        tempContent = new String(fileContentByte);
-        fileContentByte = ByteUtil.Byte2String(fileContentByte.getBytes(charsetName));
-      } catch (FileNotFoundException e) {
-        log.error("没找到文件", e);
-        totalFileUploadNums(uploadObject, uploadFileChannel, e.toString(), log);
-      } catch (Exception e) {
-        log.error("读取本地文件失败", e);
-        totalFileUploadNums(uploadObject, uploadFileChannel, e.toString(), log);
-      }
-      fileContentByte = fileContentByte.replaceAll(" ", "");
-      returnMessage[15] = ByteUtil.bytesToHexStringFromHighToLow(ByteUtil.intToBytesFromLowToHigh(fileContentByte.length() / 2));
-      try {
-        returnMessage[16] = FileUtil.getMD5(tempContent.getBytes(charsetName));
-      } catch (Exception e) {
-        log.error("文件内容加密MD5失败", e);
-      }
-      // 计算校验和,获取从[控制域]到[校验和]之前的报文
-      StringBuffer tempSB = new StringBuffer("");
-      for (int i = 4; i <= 16; i++) {
-        tempSB.append(returnMessage[i]);
-      }
-      returnMessage[17] = IEC102Uitl.makeChecksum(tempSB.toString());
-      // 计算报文的帧长
-      String ml = StrUtil.padAfter(ByteUtil.decToHex(tempSB.length() / 2), 4, '0');
-      String mlLow = ml.substring(0, 2);
-      String mlHeight = ml.substring(2);
-      returnMessage[1] = mlLow;
-      returnMessage[2] = mlHeight;
-      sendMessage = ArrayUtil.join(returnMessage, "");
-    } else {
-      // 子站向主站传输文件内容(68|帧长低字节|帧长高字节|68|控制域|地址低字节|地址高字节|类型标识|可变限定词|传输原因|设备地址低字节|设备地址高字节|记录地址|文件内容在文件的起始地址|本帧文件数据长度|文件数据|校验和|16)
-      String[] returnMessage = {"68", "mlLow", "mlHeight", "68", "ctrl", "FF", "FF", "C7", "01", "reason", "FF", "FF", "00", "fileContentStartIndex", "fileContentLength", "fileContentByte", "crc", "16"};
-      String fileContentStartIndex = "";
-      // 获取缓存中文件内容
-      Map<String, String> fileContentMap = new HashMap<>();
-
-      String fileContentByte = "";
-      if (FileConstant.fileContentByIdxMap.get(fileNameKey) == null) {
-        // 缓存中没有文件内容则新生成文件内容报文
-        try {
-          fileContentByte = nmCreateFileMessageHex(filePath, log, uploadObject.getId(), fileNameKey);
-          fileContentByte = ByteUtil.Byte2String(fileContentByte.getBytes(charsetName));
-        } catch (FileNotFoundException e) {
-          log.error("没找到文件", e);
-          totalFileUploadNums(uploadObject, uploadFileChannel, e.toString(), log);
-        } catch (Exception e) {
-          log.error("读取本地文件失败", e);
-          totalFileUploadNums(uploadObject, uploadFileChannel, e.toString(), log);
-        }
-        fileContentByte = fileContentByte.replaceAll(" ", "");
-        fileContentMap.put("contentByteIdx", "0");
-      } else {
-        fileContentMap = FileConstant.fileContentByIdxMap.get(fileNameKey);
-        fileContentByte = fileContentMap.get("fileContent");
-      }
-      // 获取通道单次文件传输字节
-      String singleByte = uploadFileChannel.getUploadFileSingleByteEnum().getMessage();
-      String ctrl = "";
-      String reason = "";
-      if (fileContentByte.length() <= Integer.parseInt(singleByte) * 2) {
-        // 一次可以传输完,生成控制域码
-        ctrl = "08";
-        reason = "08";
-
-        Integer idx = Integer.parseInt(fileContentMap.get("contentByteIdx"));
-        if (idx != 0) {
-          idx = idx + 1;
-        }
-        fileContentStartIndex = ByteUtil.bytesToHexStringFromHighToLow(ByteUtil.intToBytesFromLowToHigh(idx));
-        FileConstant.fileContentByIdxMap.remove(fileNameKey);
-        Validate102Dto dto = new Validate102Dto();
-        dto.setMessageFirst("68");
-        dto.setMessageReason("0A");
-        FileConstant.validateMessage.put(uploadFileChannel.getId()+"",dto);
-      } else {
-        // 生成不是最后一帧控制域码
-        ctrl = "28";
-        reason = "09";
-        // 将剩余的文件内容报文存入缓存中
-        Map<String, String> tempContentMap = new HashMap<>();
-        tempContentMap.put("fileContent", fileContentByte.substring(Integer.parseInt(singleByte) * 2));
-        // 上次字节结束的位置
-        Integer lastIdx = Integer.parseInt(fileContentMap.get("contentByteIdx"));
-        if (lastIdx == 0) {
-          tempContentMap.put("contentByteIdx", String.valueOf(Integer.parseInt(singleByte) - 1));
-          fileContentStartIndex = ByteUtil.bytesToHexStringFromHighToLow(ByteUtil.intToBytesFromLowToHigh(0));
-        } else {
-          tempContentMap.put("contentByteIdx", String.valueOf(lastIdx + Integer.parseInt(singleByte)));
-          fileContentStartIndex = ByteUtil.bytesToHexStringFromHighToLow(ByteUtil.intToBytesFromLowToHigh(lastIdx + 1));
-        }
-        FileConstant.fileContentByIdxMap.put(fileNameKey, tempContentMap);
-        fileContentByte = fileContentByte.substring(0, Integer.parseInt(singleByte) * 2);
-
-        Validate102Dto dto = new Validate102Dto();
-        dto.setMessageFirst("10");
-        dto.setMessageReason("A");
-        FileConstant.validateMessage.put(uploadFileChannel.getId()+"",dto);
-      }
-
-      returnMessage[4] = ctrl;
-      returnMessage[9] = reason;
-      returnMessage[13] = fileContentStartIndex;
-      returnMessage[14] = ByteUtil.decToHex(fileContentByte.length() / 2);
-      returnMessage[15] = fileContentByte;
-
-      // 计算校验和,获取从[控制域]到[校验和]之前的报文
-      StringBuffer tempSB = new StringBuffer("");
-      for (int i = 4; i <= 15; i++) {
-        tempSB.append(returnMessage[i]);
-      }
-      returnMessage[16] = IEC102Uitl.makeChecksum(tempSB.toString());
-      // 计算报文的帧长
-      String ml = StrUtil.padAfter(ByteUtil.decToHex(tempSB.length() / 2), 4, '0');
-      String mlLow = ml.substring(0, 2);
-      String mlHeight = ml.substring(2);
-      returnMessage[1] = mlLow;
-      returnMessage[2] = mlHeight;
-      sendMessage = ArrayUtil.join(returnMessage, "");
-    }
-    return sendMessage.toUpperCase();
-  }
-
-
-  /**
-   * 读取文件内容转16进制报文
-   *
-   * @param filePath
-   * @param log
-   * @return
-   */
-  private String nmCreateFileMessageHex(String filePath, Logger log, Integer uploadObjectId, String fileNameKey) throws Exception {
-    InputStreamReader isr = null;
-    String fileMessageHex = "";
-    try {
-      isr = new InputStreamReader(new FileInputStream(filePath), "UTF-8");
-      StringBuffer sb = new StringBuffer("");
-      int len1 = 0;
-      while ((len1 = isr.read()) != -1) {
-        sb.append((char) len1);
-      }
-      isr.close();
-      fileMessageHex = sb.toString();
-    } catch (Exception e) {
-      log.error("没找到文件", e);
-      throw e;
-    } finally {
-      if (isr != null) {
-        try {
-          isr.close();
-        } catch (IOException e) {
-          e.printStackTrace();
-        }
-      }
-    }
-    return fileMessageHex;
-  }
-
-  public void channelCloseConnect(ChannelHandlerContext ctx, UploadObject uploadObject, UploadFileChannel uploadFileChannel){
-    // 传输帧类型不对,断开通道重启
-    Iterator<Map.Entry<String, FileMutableInteger>> countMap = FileConstant.uploadCountMap.entrySet().iterator();
-    while (countMap.hasNext()){
-      Map.Entry<String, FileMutableInteger> entry = countMap.next();
-      String key = entry.getKey();
-      if (key.contains(uploadObject.getObjectNo() + "@")){
-        countMap.remove();
-      }
-    }
-
-    Iterator<Map.Entry<String, String>> contentMap = FileConstant.fileContentMap.entrySet().iterator();
-    while (contentMap.hasNext()){
-      Map.Entry<String,String> entry = contentMap.next();
-      String key = entry.getKey();
-      if (key.contains(uploadObject.getObjectNo() + "@")){
-        contentMap.remove();
-      }
-    }
-    FileConstant.validateMessage.remove(uploadFileChannel.getId()+"");
-    ctx.close();
-  }
-}
-

+ 0 - 2
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/IEC102/ServerFor102TransitHandler.java

@@ -40,8 +40,6 @@ public class ServerFor102TransitHandler extends ChannelInboundHandlerAdapter {
   @Autowired
   ServerFor102StandardService serverFor102StandardService = SpringContextHolder.getApplicationContext().getBean(ServerFor102StandardService.class);
   @Autowired
-  ServerFor102NMService serverFor102NMService = SpringContextHolder.getApplicationContext().getBean(ServerFor102NMService.class);
-  @Autowired
   ChannelDisconLogService channelDisconLogService = SpringContextHolder.getApplicationContext().getBean(ChannelDisconLogService.class);
   @Autowired
   AppenderFactory appenderFactory = SpringContextHolder.getApplicationContext().getBean(AppenderFactory.class);

+ 302 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileChannelController.java

@@ -0,0 +1,302 @@
+package com.jiayue.ipfcst.fileupload.controller;
+
+import com.jiayue.ipfcst.aop.SaveValidate;
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.constant.enums.*;
+import com.jiayue.ipfcst.common.data.entity.UploadFileChannel;
+import com.jiayue.ipfcst.common.data.repository.UploadURLRepository;
+import com.jiayue.ipfcst.fileupload.service.UploadFileChannelService;
+import com.jiayue.ipfcst.fileupload.service.UploadURLService;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 上报通道restful接口
+ */
+@RestController
+@Slf4j
+@RequestMapping("uploadFileChannel")
+public class UploadFileChannelController {
+
+  private final UploadFileChannelService uploadFileChannelService;
+  private final UploadURLService uploadURLService;
+  private final UploadURLRepository uploadURLRepository;
+
+  @Autowired
+  public UploadFileChannelController(UploadFileChannelService uploadFileChannelService, UploadURLService uploadURLService, UploadURLRepository uploadURLRepository) {
+    this.uploadFileChannelService = uploadFileChannelService;
+    this.uploadURLService = uploadURLService;
+    this.uploadURLRepository = uploadURLRepository;
+  }
+
+  /**
+   * 新增通道
+   *
+   * @param uploadFileChannel
+   * @return
+   */
+  @SneakyThrows
+  @PostMapping
+  @SaveValidate
+  public ResponseVO add(@RequestBody UploadFileChannel uploadFileChannel) {
+    UploadFileChannel save = uploadFileChannelService.save(uploadFileChannel);
+    return ResponseVO.success(save);
+  }
+
+  /**
+   * 修改通道
+   *
+   * @param uploadFileChannel
+   * @return
+   */
+  @SneakyThrows
+  @PutMapping
+  @SaveValidate
+  @Transactional
+  public ResponseVO update(@RequestBody UploadFileChannel uploadFileChannel) {
+
+    uploadFileChannelService.save(uploadFileChannel);
+    try {
+      if (uploadFileChannel.getBackupC()==null){
+        uploadURLRepository.deleteByUploadChannelId(uploadFileChannel.getId());
+      }
+    }catch (Exception e){
+      uploadURLRepository.deleteByUploadChannelId(uploadFileChannel.getId());
+    }
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 删除通道
+   *
+   * @param id
+   * @return
+   */
+  @SneakyThrows
+  @DeleteMapping("/{id}")
+  @SaveValidate
+  public ResponseVO delete(@PathVariable Integer id) {
+    UploadFileChannel uploadFileChannel = uploadFileChannelService.getById(id);
+    uploadFileChannelService.delete(uploadFileChannel);
+    uploadURLService.deleteByChannelId(id);
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 获取通道
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping
+  public ResponseVO get() {
+    List<UploadFileChannel> uploadFileChannels = uploadFileChannelService.get();
+    return ResponseVO.success(uploadFileChannels);
+
+  }
+
+//  /**
+//   * 获取通道(分页)
+//   */
+//  @SneakyThrows
+//  @GetMapping(value = "/{page}/{size}")
+//  public ResponseVO getPage(@PathVariable Integer page, @PathVariable Integer size) {
+//    UploadFileChannel uploadFileChannel = new UploadFileChannel();
+//    Page<UploadFileChannel> uploadFileChannels = uploadFileChannelService.getPage(uploadFileChannel, page, size);
+//    return ResponseVO.success(uploadFileChannels);
+//
+//  }
+
+
+  /**
+   * 获取通道状态枚举类型
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping(value = "/getChannelStatusEnum")
+  public ResponseVO getChannelStatusEnum() {
+    List<Map<String, Object>> list = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (ChannelStatusEnum e : ChannelStatusEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取通道状态枚举类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+
+  /**
+   * 获取上报协议枚举类
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping(value = "/getUploadProtocolEnum")
+  public ResponseVO getUploadProtocolEnum() {
+    List<Map<String, Object>> list = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (UploadProtocolEnum e : UploadProtocolEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取上报协议枚举类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+
+
+  /**
+   * 获取上报文件字符集
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping(value = "/getUploadFileCharSetEnum")
+  public ResponseVO getUploadFileCharSetEnum() {
+    List<Map<String, Object>> list = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (UploadFileCharSetEnum e : UploadFileCharSetEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取上报文件字符集类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+
+  /**
+   * 获取上报文件名称长度枚举
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping(value = "/getUploadFileNameLengthEnum")
+  public ResponseVO getUploadFileNameLengthEnum() {
+    List<Map<String, Object>> list = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (UploadFileNameLengthEnum e : UploadFileNameLengthEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取上报文件名称长度枚举类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+
+  /**
+   * 获取上报文件单次传输字节枚举类型
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping(value = "/getUploadFileSingleByteEnum")
+  public ResponseVO getUploadFileSingleByteEnum() {
+    List<Map<String, Object>> list = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (UploadFileSingleByteEnum e : UploadFileSingleByteEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取上报文件单次传输字节枚举类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+
+  /**
+   * 获取ftp模式
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping(value = "/getFtpPassiveModeEnum")
+  public ResponseVO getFtpPassiveModeEnum() {
+    List<Map<String, Object>> list = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (FtpPassiveModeEnum e : FtpPassiveModeEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取ftp模式类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+
+  /**
+   * 获取通道文件生成规则
+   *
+   * @return
+   */
+  @SneakyThrows
+  @GetMapping(value = "/getChannelFileRuleEnum")
+  public ResponseVO getChannelFileRuleEnum() {
+    List<Map<String, Object>> list = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (ChannelFileRuleEnum e : ChannelFileRuleEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取通道文件生成规则类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+}
+

+ 72 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileCodeController.java

@@ -0,0 +1,72 @@
+package com.jiayue.ipfcst.fileupload.controller;
+
+import com.jiayue.ipfcst.aop.SaveValidate;
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.UploadFileCode;
+import com.jiayue.ipfcst.fileupload.service.UploadFileCodeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("uploadFileCode")
+public class UploadFileCodeController {
+  @Autowired
+  private UploadFileCodeService uploadFileCodeService;
+
+
+  public UploadFileCodeController(UploadFileCodeService uploadFileCodeService){
+    this.uploadFileCodeService = uploadFileCodeService;
+  }
+
+  /**
+   * 获取文件类型code数据
+   *
+   * @return
+   */
+  @GetMapping
+  public ResponseVO getAll(){
+    List<UploadFileCode> uploadFileCodes = uploadFileCodeService.get();
+    return ResponseVO.success(uploadFileCodes);
+  }
+
+  /**
+   * 修改文件类型code数据
+   *
+   * @param uploadFileCode
+   * @return
+   */
+  @PostMapping
+  @SaveValidate
+  public ResponseVO update(@RequestBody UploadFileCode uploadFileCode){
+    return ResponseVO.success(uploadFileCodeService.save(uploadFileCode));
+  }
+
+  /**
+   * 新增文件类型code数据
+   * @param uploadFileCode
+   *
+   * @return
+   */
+  @PutMapping
+  @SaveValidate
+  public ResponseVO add(@RequestBody UploadFileCode uploadFileCode){
+    return ResponseVO.success(uploadFileCodeService.save(uploadFileCode));
+  }
+
+  /**
+   * 删除文件类型code数据
+   *
+   * @param id
+   * @return
+   */
+  @DeleteMapping("/{id}")
+  @SaveValidate
+  public ResponseVO delete(@PathVariable Integer id){
+    UploadFileCode uploadFileCode = new UploadFileCode();
+    uploadFileCode.setId(id);
+    uploadFileCodeService.delete(uploadFileCode);
+    return ResponseVO.success(1);
+  }
+}

+ 120 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileLogController.java

@@ -0,0 +1,120 @@
+package com.jiayue.ipfcst.fileupload.controller;
+
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.constant.enums.FileStatusEnum;
+import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
+import com.jiayue.ipfcst.common.data.constant.enums.UploadProtocolEnum;
+import com.jiayue.ipfcst.common.data.entity.UploadFileLog;
+import com.jiayue.ipfcst.fileupload.service.UploadFileLogService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("uploadFileLog")
+@Slf4j
+public class UploadFileLogController {
+
+  private final UploadFileLogService uploadFileLogService;
+
+  @Autowired
+  public UploadFileLogController(UploadFileLogService uploadFileLogService) {
+    this.uploadFileLogService = uploadFileLogService;
+  }
+
+  /**
+   * 根据上报对象,时间,文件类型,文件状态
+   *
+   * @param uploadObjectId 上报对象
+   * @param createTime     时间
+   * @param fileType       文件类型
+   * @param fileStatus     文件状态
+   * @return
+   */
+  @GetMapping("getFileLog/{uploadObjectId}/{createTime}/{fileType}/{fileStatus}")
+  public ResponseVO get(@PathVariable("uploadObjectId") Integer uploadObjectId, @PathVariable("createTime") String createTime,
+                        @PathVariable("fileType") String fileType, @PathVariable("fileStatus") String fileStatus, @PathVariable("stationCode") String stationCode) {
+    List<UploadFileLog> list = uploadFileLogService.queryFileLog(uploadObjectId, createTime, fileType, fileStatus,stationCode);
+    return ResponseVO.success(list);
+  }
+
+  @GetMapping("/getFileStatusEnum")
+  public ResponseVO getFileStatusEnum() {
+    List list = new ArrayList<>();
+    for (FileStatusEnum fileStatusEnum : FileStatusEnum.values()) {
+      Map map = new HashMap();
+      map.put("name", fileStatusEnum.name());
+      map.put("message", fileStatusEnum.getMessage());
+      list.add(map);
+    }
+    return ResponseVO.success(list);
+  }
+
+  @GetMapping("/getUploadProtocolEnum")
+  public ResponseVO getUploadProtocolEnum() {
+    List list = new ArrayList<>();
+    for (UploadProtocolEnum uploadProtocolEnum : UploadProtocolEnum.values()) {
+      Map map = new HashMap();
+      map.put("name", uploadProtocolEnum.name());
+      map.put("message", uploadProtocolEnum.getMessage());
+      list.add(map);
+    }
+    return ResponseVO.success(list);
+  }
+
+  @GetMapping("/getFileTypeEnum")
+  public ResponseVO getFileTypeEnum() {
+    List list = new ArrayList<>();
+    for (FileTypeEnum fileTypeEnum : FileTypeEnum.values()) {
+      Map map = new HashMap();
+      map.put("name", fileTypeEnum.name());
+      map.put("message", fileTypeEnum.getMessage());
+      list.add(map);
+    }
+    return ResponseVO.success(list);
+  }
+
+  @PostMapping("/uploadFile")
+  public ResponseVO uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("uploadObject") String id, @RequestParam("FileTypeEnum") String fileType) {
+    Integer objectId = Integer.parseInt(id);
+
+    Boolean b = uploadFileLogService.uploadFile(objectId, fileType, file);
+    if (b){
+      return ResponseVO.success("上传成功!");
+    }else {
+      return ResponseVO.fail("上传失败!");
+    }
+
+
+  }
+
+  @DeleteMapping("/{id}")
+  public ResponseVO deleteById(@PathVariable("id") Integer id){
+    uploadFileLogService.deleteById(id);
+    return ResponseVO.success(1);
+  }
+
+  @PostMapping("/cleanCache")
+  public ResponseVO cleanCache(@RequestBody UploadFileLog uploadFileLog){
+    uploadFileLogService.cleanCache(uploadFileLog);
+    return ResponseVO.success(1);
+  }
+
+
+  /**
+   * 文件补报
+   * @param uploadFileLog
+   * @return
+   */
+  @PostMapping("/report")
+  public ResponseVO report(@RequestBody UploadFileLog uploadFileLog){
+    uploadFileLogService.report(uploadFileLog);
+    return ResponseVO.success(1);
+  }
+}

+ 32 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadFileLogDetailController.java

@@ -0,0 +1,32 @@
+package com.jiayue.ipfcst.fileupload.controller;
+
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.UploadFileLogDetail;
+import com.jiayue.ipfcst.fileupload.service.UploadFileLogDetailService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("uploadFileLogDetail")
+@Slf4j
+public class UploadFileLogDetailController {
+  private final UploadFileLogDetailService uploadFileLogDetailService;
+  @Autowired
+  public UploadFileLogDetailController(UploadFileLogDetailService uploadFileLogDetailService){
+    this.uploadFileLogDetailService = uploadFileLogDetailService;
+  }
+
+  @GetMapping("/{uploadFileLogId}")
+  public ResponseVO getByFileLogId(@PathVariable("uploadFileLogId") Integer uploadFileLogId){
+    List<UploadFileLogDetail> list =uploadFileLogDetailService.getByFileLogId(uploadFileLogId);
+    return ResponseVO.success(list);
+  }
+  @DeleteMapping("/{uploadFileLogId}")
+  public ResponseVO deleteByUploadFileLogId(@PathVariable("uploadFileLogId") Integer uploadFileLogId){
+    uploadFileLogDetailService.deleteByUploadFileLogId(uploadFileLogId);
+    return ResponseVO.success(1);
+  }
+}

+ 183 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadObjectController.java

@@ -0,0 +1,183 @@
+package com.jiayue.ipfcst.fileupload.controller;
+
+import com.jiayue.ipfcst.aop.SaveValidate;
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
+import com.jiayue.ipfcst.common.data.entity.UploadFileChannel;
+import com.jiayue.ipfcst.common.data.entity.UploadObject;
+import com.jiayue.ipfcst.common.data.repository.UploadObjectRepository;
+import com.jiayue.ipfcst.fileupload.service.UploadFileChannelService;
+import com.jiayue.ipfcst.fileupload.service.UploadObjectService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@RestController
+@RequestMapping("uploadObject")
+@Slf4j
+public class UploadObjectController {
+  @Autowired
+  private final UploadObjectService uploadObjectService;
+  private final UploadFileChannelService uploadFileChannelService;
+
+  public UploadObjectController(UploadObjectService uploadObjectService, UploadFileChannelService uploadFileChannelService) {
+    this.uploadObjectService = uploadObjectService;
+    this.uploadFileChannelService = uploadFileChannelService;
+  }
+  @Autowired
+  UploadObjectRepository uploadObjectRepository;
+  /**
+   * 获取通道对象
+   *
+   * @return
+   */
+  @GetMapping()
+  public ResponseVO get() {
+    List list = new ArrayList();
+    List<UploadObject> uploadObjectList = uploadObjectService.get();
+    return ResponseVO.success(uploadObjectList);
+  }
+
+  /**
+   * 保存通道对象
+   *
+   * @param uploadObject
+   * @return
+   */
+  @PostMapping
+  @SaveValidate
+  public ResponseVO add(@RequestBody UploadObject uploadObject) {
+    try {
+      uploadObjectService.save(uploadObject);
+      return ResponseVO.success(1);
+    } catch (Exception be) {
+      log.error("保存通道对象出错" + be);
+      return ResponseVO.success("失败");
+    }
+  }
+
+  /**
+   * 保存通道对象
+   *
+   * @param uploadObject
+   * @return
+   */
+  @PutMapping
+  @SaveValidate
+  public ResponseVO update(@RequestBody UploadObject uploadObject) {
+    try {
+      uploadObjectService.save(uploadObject);
+      return ResponseVO.success(1);
+    } catch (Exception be) {
+      log.error("修改通道对象出错" + be);
+      return ResponseVO.success("失败");
+    }
+  }
+
+
+  /**
+   * 删除通道对象
+   *
+   * @param id
+   * @return
+   */
+  @DeleteMapping("/{id}")
+  @SaveValidate
+  public ResponseVO delete(@PathVariable Integer id) {
+    try {
+      uploadFileChannelService.deleteByObjId(id);
+      uploadObjectService.delete(id);
+
+      return ResponseVO.success(1);
+    } catch (Exception be) {
+      log.error("保存通道对象出错" + be);
+      return ResponseVO.success("失败");
+    }
+  }
+
+  /**
+   * 获取文件上报类型
+   */
+  @GetMapping("getFileType")
+  public ResponseVO getFileType() {
+    List list = new ArrayList();
+    try {
+      for (FileTypeEnum e : FileTypeEnum.values()) {
+        Map map = new HashMap();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        list.add(map);
+      }
+      return ResponseVO.success(list);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取通道文件上报类型异常");
+      return ResponseVO.fail(list);
+    }
+  }
+
+  /**
+   * 根据上报id来查询
+   * @param uploadObjectId
+   * @return UploadObject 上报对象
+   */
+  @GetMapping("getByuploadObjectId/{uploadObjectId}")
+  public ResponseVO getFileTypeByupId(@PathVariable("uploadObjectId") Integer uploadObjectId){
+    List list = new ArrayList();
+    UploadObject uploadObject = uploadObjectRepository.findById(uploadObjectId).get();
+    list.add(uploadObject);
+    return ResponseVO.success(list);
+  }
+
+  /**
+   * 获取对应省份的上报文件类型
+   */
+  @GetMapping("getFileTypeByProvince")
+  public ResponseVO getFileTypeByProvince(){
+    Map<String, String> uploadFileType = uploadObjectService.getUploadFileType();
+    List<Map<String, String>> list = new ArrayList<>();
+    for (String key : uploadFileType.keySet()) {
+      Map<String, String> map = new HashMap<>();
+      //map.keySet()返回的是所有key的值
+      String value = uploadFileType.get(key);//得到每个key多对用value的值
+      map.put("label", value);
+      map.put("key", key);
+      map.put("value", key);
+      list.add(map);
+    }
+    return ResponseVO.success(list);
+  }
+
+
+  /**
+   * 获取所有FTPSFTP通道 whc
+   */
+  @GetMapping("getFtpSftpChannel")
+  public ResponseVO getAllFtpSftp(){
+    //获取所有上报对象
+    List<UploadObject> uploadObjectList = uploadObjectService.get();
+    List<UploadFileChannel> uploadFileChannelList = new ArrayList<>();
+    // 过滤出ftp/sftp的上报对象
+    uploadObjectList = uploadObjectList.stream().filter(s -> s.getUploadProtocolEnum().toString().equals("E4") || s.getUploadProtocolEnum().toString().equals("E5")).collect(Collectors.toList());
+    if (uploadObjectList.size() > 0) {
+      // 获取通道信息
+      List<UploadFileChannel> uploadFileChannels = uploadFileChannelService.get();
+      //获取FTP/SFTP通道
+      for(int i =0 ; i<uploadObjectList.size();i++){
+        for(int j = 0 ; j<uploadFileChannels.size() ; j++){
+          if(uploadObjectList.get(i).getId().equals(uploadFileChannels.get(j).getUploadObjectId())){
+            uploadFileChannelList.add(uploadFileChannels.get(j));
+          }
+        }
+      }
+    }
+    return ResponseVO.success(uploadFileChannelList);
+  }
+}

+ 43 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadURLController.java

@@ -0,0 +1,43 @@
+package com.jiayue.ipfcst.fileupload.controller;
+
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.UploadURL;
+import com.jiayue.ipfcst.fileupload.service.UploadURLService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+public class UploadURLController {
+  @Autowired
+  private UploadURLService uploadURLService;
+
+  @GetMapping("/uploadURL/{uploadChannelId}")
+  @Transactional
+  public ResponseVO findByUploadChannelId(@PathVariable Integer uploadChannelId){
+    List<UploadURL> byUploadCahnnelId = uploadURLService.findByUploadCahnnelId(uploadChannelId);
+
+    return ResponseVO.success(byUploadCahnnelId);
+  }
+
+  @PostMapping("/uploadURL")
+  @Transactional
+  public ResponseVO save(@RequestBody UploadURL uploadURL){
+
+    uploadURLService.save(uploadURL);
+    return ResponseVO.success();
+  }
+
+
+  @DeleteMapping("/uploadURL/{id}")
+  @Transactional
+  public ResponseVO delete(@PathVariable Integer id){
+
+    uploadURLService.deleteByChannelId(id);
+    return ResponseVO.success();
+  }
+
+
+}

+ 9 - 7
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java

@@ -2,6 +2,7 @@ package com.jiayue.ipfcst.fileupload.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
+import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.ForecastPowerShortTermHis;
 import com.jiayue.ipfcst.common.data.service.uploadfilerule.E63UploadFileRuleService;
@@ -9,6 +10,7 @@ import com.jiayue.ipfcst.console.service.ForecastPowerShortTermService;
 import com.jiayue.ipfcst.console.service.ForecastPowerUltraShortTermService;
 import com.jiayue.ipfcst.fileupload.util.FileUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.time.DateFormatUtils;
 import org.apache.commons.lang.time.DateUtils;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
@@ -61,12 +63,12 @@ public class E63UploadFileService extends BaseUploadFileService {
     }
 
     // 循环场站生成短期
-    for (ElectricField electricField : electricFieldList) {
-      String stationCode = electricField.getStationCode();
+    for (ElectricField electricFieldInfo : electricFieldList) {
+      String stationCode = electricFieldInfo.getStationCode();
       try {
         Template template = null;
         // 获取短期模板
-        if (electricField.getElectricFieldTypeEnum().equals("E1")) {
+        if (electricFieldInfo.getElectricFieldTypeEnum().equals("E1")) {
           template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ.vm");
         } else {
           template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_F.vm");
@@ -91,7 +93,7 @@ public class E63UploadFileService extends BaseUploadFileService {
           // 结束时间(开始加24小时再减去1秒)
           Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
           // 生成上报文件名格式
-          fileName = e63UploadFileRuleService.getFileNameRule(electricField, "E1", startTime);
+          fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E1", startTime);
           if (getFileName(fileName, "E1", stationCode)) {
             // 查询短期预测功率
             List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime, stationCode);
@@ -118,13 +120,13 @@ public class E63UploadFileService extends BaseUploadFileService {
             template.merge(velocityContext, writer);
 
             // 将文件复制到上报路径中
-            super.copyUploadFile(writer, file, FileTypeEnum.E1.name(), null, date);
+            super.copyUploadFile(writer, file, FileTypeEnum.E1.name(), null, date,electricFieldInfo.getStationCode());
           }
         } else {
-          log.error(electricField.getStationCode() + "短期上报模板不存在!");
+          log.error(electricFieldInfo.getStationCode() + "短期上报模板不存在!");
         }
       } catch (Exception e) {
-        log.error(electricField.getStationCode() + "生成短期异常");
+        log.error(electricFieldInfo.getStationCode() + "生成短期异常");
         System.out.println(e.toString());
       }
 

+ 223 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadService.java

@@ -0,0 +1,223 @@
+package com.jiayue.ipfcst.fileupload.service;
+
+import ch.qos.logback.classic.Logger;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.extra.ftp.Ftp;
+import cn.hutool.extra.ftp.FtpConfig;
+import cn.hutool.extra.ftp.FtpMode;
+import cn.hutool.extra.ssh.Sftp;
+import com.jiayue.ipfcst.common.data.constant.enums.ChannelStatusEnum;
+import com.jiayue.ipfcst.common.data.entity.UploadFileChannel;
+import com.jiayue.ipfcst.common.data.entity.UploadFileLog;
+import com.jiayue.ipfcst.common.data.entity.UploadObject;
+import com.jiayue.ipfcst.common.data.entity.UploadURL;
+import com.jiayue.ipfcst.common.data.repository.UploadFileLogDetailRepository;
+import com.jiayue.ipfcst.common.data.repository.UploadFileLogRepository;
+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;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class FtpUploadService  {
+  @Autowired
+  UploadFileChannelService uploadFileChannelService;
+  @Autowired
+  UploadFileLogRepository uploadFileLogRepository;
+  @Autowired
+  UploadFileLogDetailRepository uploadFileLogDetailRepository;
+  @Autowired
+  UploadObjectService uploadObjectService;
+  @Autowired
+  FtpUploadTransactionService ftpUploadTransactionService;
+  @Autowired
+  AppenderFactory appenderFactory;
+  @Autowired
+  UploadURLRepository uploadURLRepository;
+
+  /**
+   * 开启FTP客户端上报文件
+   */
+  public void startFtpUpload() {
+    List<UploadObject> uploadObjectList = uploadObjectService.get();
+    // 过滤出ftp/sftp的上报对象
+    uploadObjectList = uploadObjectList.stream().filter(s -> s.getUploadProtocolEnum().toString().equals("E4") || s.getUploadProtocolEnum().toString().equals("E5")).collect(Collectors.toList());
+    if (uploadObjectList.size() > 0) {
+      // 获取通道信息
+      List<UploadFileChannel> uploadFileChannels = uploadFileChannelService.get();
+      // 遍历ftp的上报对象
+      for (UploadObject uploadObject : uploadObjectList) {
+        //找出可用的ftp通道
+        List<UploadFileChannel> uploadFileChannelList = uploadFileChannels.stream().filter(s -> s.getChannelStatusEnum().equals(ChannelStatusEnum.E1) && s.getUploadObjectId().equals(uploadObject.getId())).collect(Collectors.toList());
+        // 创建通道对应的日志
+        Logger logger = appenderFactory.getLogger(uploadObject.getUploadObjectName(), uploadObject.getUploadProtocolEnum().getMessage(),uploadObject.getObjectNo());
+
+        for (UploadFileChannel uploadFileChannel : uploadFileChannelList) {
+          List<UploadURL> uploadURLList = uploadURLRepository.findByUploadChannelId(uploadFileChannel.getId());
+
+          if (uploadObject.getUploadProtocolEnum().toString().equals("E4")){
+            // FTP方式上报
+            Ftp ftp = null;
+            try {
+              FtpMode mode = null;
+              if ("E1".equals(uploadFileChannel.getFtpPassiveModeEnum().toString())){
+                // 主动模式
+                mode = FtpMode.Active;
+              }
+              else{
+                // 被动模式
+                mode = FtpMode.Passive;
+              }
+
+              FtpConfig ftpConfig = new FtpConfig();
+              ftpConfig.setHost(uploadFileChannel.getRemoteIp());
+              ftpConfig.setPort(Integer.parseInt(uploadFileChannel.getRemotePort()));
+              ftpConfig.setPassword(uploadFileChannel.getUploadPassword());
+              ftpConfig.setUser(uploadFileChannel.getUploadUserName());
+              ftpConfig.setCharset(Charset.forName(uploadObject.getUploadFileCharSetEnum().getMessage()));
+              ftpConfig.setConnectionTimeout(5*1000L);
+              try {
+                ftp = new Ftp(ftpConfig, mode);
+                logger.info(uploadFileChannel.getChannelName()+"ftp客户端连接成功");
+                // 连接成功,设置通道状态
+                FileConstant.channelStatusMap.put(uploadObject.getId() + "-" + uploadFileChannel.getId(), "1");
+              }
+              catch (Exception e){
+                // 连接失败,设置通道状态
+                FileConstant.channelStatusMap.put(uploadObject.getId() + "-" + uploadFileChannel.getId(), "0");
+                throw e;
+              }
+
+              // 获取缓存中的上报文件
+              logger.debug("上报文件缓存数量:" + FileConstant.readyUploadFileMap.size());
+              Map<String, UploadFileLog> fileMap = new HashMap<>();
+              fileMap.putAll(FileConstant.readyUploadFileMap);
+              for (Map.Entry<String, UploadFileLog> entry : fileMap.entrySet()) {
+                String[] keys = entry.getKey().split("@");
+                if (keys[0].equals(uploadObject.getObjectNo())) {
+                  // 获取缓存中对应的上报对象的文件
+                  logger.info("在缓存中找到通道["+uploadFileChannel.getChannelName()+"]文件:"+keys[2]);
+                  ftpUploadTransactionService.singleUpload(uploadObject,uploadFileChannel,entry,ftp,null,keys,logger,uploadURLList);
+                }
+              }
+            }
+            catch (Exception e){
+              logger.error(uploadFileChannel.getChannelName()+"上报失败",e);
+              try {
+                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 = "";
+                while ((line = returnData.readLine()) != null) {
+                  returnMsg += line;
+                }
+
+                if(returnMsg.indexOf("100% loss")!=-1){
+                  logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接不畅通.");
+                }
+                else{
+                  logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接畅通.");
+                }
+
+                returnData.close();
+                r.close();
+                process.getInputStream().close();
+                process.getOutputStream().close();
+                process.destroy();
+
+              } catch (IOException ex) {
+                logger.error("ping对方ip执行失败",ex);
+              }
+            }
+            finally {
+              if (ftp!=null){
+                IoUtil.close(ftp);
+                logger.info(uploadFileChannel.getChannelName()+"ftp客户端关闭连接");
+              }
+            }
+          }
+          else{
+            // SFTP方式上报
+            Sftp sftp = null;
+            try{
+              try {
+                sftp = new Sftp(uploadFileChannel.getRemoteIp(), Integer.parseInt(uploadFileChannel.getRemotePort()),uploadFileChannel.getUploadUserName(),uploadFileChannel.getUploadPassword());
+                logger.info(uploadFileChannel.getChannelName()+":sftp连接创建成功");
+                // 连接成功,设置通道状态
+                FileConstant.channelStatusMap.put(uploadObject.getId() + "-" + uploadFileChannel.getId(), "1");
+              }
+              catch (Exception e){
+                logger.error(uploadFileChannel.getChannelName()+":sftp连接失败",e);
+                // 连接失败,设置通道状态
+                FileConstant.channelStatusMap.put(uploadObject.getId() + "-" + uploadFileChannel.getId(), "0");
+                throw e;
+              }
+              // 获取缓存中的上报文件
+              logger.debug("当前文件缓存数量:" + FileConstant.readyUploadFileMap.size());
+              Map<String, UploadFileLog> fileMap = new HashMap<>();
+              fileMap.putAll(FileConstant.readyUploadFileMap);
+              for (Map.Entry<String, UploadFileLog> entry : fileMap.entrySet()) {
+                String[] keys = entry.getKey().split("@");
+                if (keys[0].equals(uploadObject.getObjectNo())) {
+                  // 获取缓存中对应的上报对象的文件
+                  logger.info("在缓存中找到通道["+uploadFileChannel.getChannelName()+"]文件:"+keys[2]+",将文件送入到上报程序中。");
+                  ftpUploadTransactionService.singleUpload(uploadObject,uploadFileChannel,entry,null,sftp,keys,logger,uploadURLList);
+                }
+              }
+            }
+            catch (Exception e){
+              logger.error(uploadFileChannel.getChannelName()+"上报失败",e);
+              try {
+                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 = "";
+                while ((line = returnData.readLine()) != null) {
+                  returnMsg += line;
+                }
+
+                if(returnMsg.indexOf("100% loss")!=-1){
+                  logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接不畅通.");
+                }
+                else{
+                  logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接畅通.");
+                }
+
+                returnData.close();
+                r.close();
+                process.getInputStream().close();
+                process.getOutputStream().close();
+                process.destroy();
+
+              } catch (IOException ex) {
+                logger.error("ping对方ip执行失败",ex);
+              }
+            }
+            finally {
+              if (sftp!=null){
+                logger.info("sftp客户端关闭");
+                sftp.close();
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}

+ 270 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadTransactionService.java

@@ -0,0 +1,270 @@
+package com.jiayue.ipfcst.fileupload.service;
+
+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;
+import com.jiayue.ipfcst.common.data.repository.UploadFileLogRepository;
+import com.jiayue.ipfcst.fileupload.util.FileConstant;
+import com.jiayue.ipfcst.fileupload.util.FileMutableInteger;
+import com.jiayue.ipfcst.fileupload.util.FileUtil;
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * FTP、SFTP上报类
+ *
+ * @author xsl
+ * @version 3.0
+ */
+@Service
+public class FtpUploadTransactionService extends BaseUploadFileService {
+  @Autowired
+  UploadFileLogRepository uploadFileLogRepository;
+  @Autowired
+  UploadFileLogDetailRepository uploadFileLogDetailRepository;
+
+
+  @Transactional(propagation = Propagation.REQUIRED)
+  public void singleUpload(UploadObject uploadObject, UploadFileChannel uploadFileChannel, Map.Entry<String, UploadFileLog> entry, Ftp ftp, Sftp sftp, String[] keys, Logger logger, List<UploadURL> uploadURLList) {
+
+    if (FileConstant.uploadCountMap.get(entry.getKey()) == null) {
+      FileMutableInteger fileMutableInteger = new FileMutableInteger(0);
+      FileConstant.uploadCountMap.put(entry.getKey(), fileMutableInteger);
+    }
+
+    // 上报次数
+    Integer fileUploadCount = FileConstant.uploadCountMap.get(entry.getKey()).getValue();
+    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 {
+      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;
+          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());
+          // 是否每个文件类型一个路径
+          if (StrUtil.hasBlank(uploadFileChannel.getBackupC()) || "0".equals(uploadFileChannel.getBackupC())){
+            // 公用一个路径
+            isSuccess = ftp.upload(uploadFileChannel.getPathService(), uploadFileName, uploadFileIs);
+          }
+          else{
+            // 多路径
+            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);
+          throw e;
+        } finally {
+          if (isr != null) {
+            isr.close();
+          }
+          if (uploadFileIs != null) {
+            uploadFileIs.close();
+          }
+        }
+      } else {
+        InputStreamReader isr = null;
+        InputStream uploadFileIs = null;
+        try {
+          isr = new InputStreamReader(new FileInputStream(srcPath), "UTF-8");
+          StringBuffer sb = new StringBuffer("");
+          int len1 = 0;
+          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());
+
+          if (StrUtil.hasBlank(uploadFileChannel.getBackupC()) || "0".equals(uploadFileChannel.getBackupC())){
+            // 公用一个路径
+            sftp.getClient().put(uploadFileIs, uploadFileChannel.getPathService() + "/" + uploadFileName);
+          }
+          else{
+            // 多路径
+            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();
+          }
+          if (uploadFileIs != null) {
+            uploadFileIs.close();
+          }
+        }
+      }
+    } catch (Exception e) {
+      isSuccess = false;
+      logger.error("上报通道:" + uploadFileChannel.getChannelName() + "," + keys[2] + "上报失败", e);
+      Integer id = FileConstant.fileShouldMomentMap.get(entry.getKey());
+      UploadFileLog uploadFileLog = uploadFileLogRepository.findById(id).get();
+      UploadFileLogDetail uploadFileLogDetail = new UploadFileLogDetail();
+      uploadFileLogDetail.setUploadObjectName(uploadObject.getUploadObjectName());
+      uploadFileLogDetail.setUploadChanneId(uploadFileChannel.getId());
+      uploadFileLogDetail.setUploadChannelName(uploadFileChannel.getChannelName());
+      uploadFileLogDetail.setUploadFileLogId(uploadFileLog.getId());
+      uploadFileLogDetail.setFileName(keys[2]);
+      uploadFileLogDetail.setUploadTime(new Date().getTime());
+      uploadFileLogDetail.setFileStatusEnum(FileStatusEnum.E3);
+      uploadFileLogDetail.setUploadFailureReason(e.getMessage());
+      uploadFileLogDetailRepository.save(uploadFileLogDetail);
+    } finally {
+      logger.info("上报通道:" + keys[0] + "," + keys[2] + "上报次数:" + fileUploadCount);
+      try {
+        if (isSuccess) {
+          // 更新日志表
+          FileStatusEnum fileStatusEnum = null;
+          if ("1".equals(uploadObject.getUploadD5000())) {
+            // 上报给D5000
+            fileStatusEnum = FileStatusEnum.E5;
+          } else {
+            fileStatusEnum = FileStatusEnum.E2;
+          }
+          uploadFileLogRepository.updateFileUploadCount(fileStatusEnum, fileUploadCount, uploadObject.getId(), keys[2]);
+          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目录");
+
+          Integer id = FileConstant.fileShouldMomentMap.get(entry.getKey());
+          UploadFileLog uploadFileLog = uploadFileLogRepository.findById(id).get();
+          UploadFileLogDetail uploadFileLogDetail = new UploadFileLogDetail();
+          uploadFileLogDetail.setUploadObjectName(uploadObject.getUploadObjectName());
+          uploadFileLogDetail.setUploadFileLogId(uploadFileLog.getId());
+          uploadFileLogDetail.setUploadTime(System.currentTimeMillis());
+          uploadFileLogDetail.setFileName(keys[2]);
+          uploadFileLogDetail.setUploadChanneId(uploadFileChannel.getId());
+          uploadFileLogDetail.setUploadChannelName(uploadFileChannel.getChannelName());
+          uploadFileLogDetail.setFileStatusEnum(fileStatusEnum);
+          uploadFileLogDetailRepository.save(uploadFileLogDetail);
+
+          // 上传成功,删除缓存里的文件
+          FileConstant.readyUploadFileMap.remove(entry.getKey());
+          FileConstant.uploadCountMap.remove(entry.getKey());
+          FileConstant.fileShouldMomentMap.remove(entry.getKey());
+        } else {
+          logger.info("上报失败。。。。。。。。。。。。。");
+          try {
+            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 = "";
+            while ((line = returnData.readLine()) != null) {
+              returnMsg += line;
+            }
+
+            if(returnMsg.indexOf("100% loss")!=-1){
+              logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接不畅通.");
+            }
+            else{
+              logger.info("与 " +uploadFileChannel.getRemoteIp() +" 连接畅通.");
+            }
+
+            returnData.close();
+            r.close();
+            process.getInputStream().close();
+            process.getOutputStream().close();
+            process.destroy();
+
+          } catch (IOException e) {
+            logger.error("ping对方ip执行失败",e);
+          }
+          // 更新日志表
+          FileStatusEnum fileStatusEnum = null;
+          if ("1".equals(uploadObject.getUploadD5000())) {
+            // 上报给D5000
+            fileStatusEnum = FileStatusEnum.E6;
+          } else {
+            fileStatusEnum = FileStatusEnum.E3;
+          }
+          uploadFileLogRepository.updateFileUploadCount(fileStatusEnum, fileUploadCount, uploadObject.getId(), keys[2]);
+//          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());
+//          } else {
+//            FileMutableInteger fileMutableInteger = new FileMutableInteger(fileUploadCount);
+//            FileConstant.uploadCountMap.put(entry.getKey(), fileMutableInteger);
+//          }
+        }
+      } catch (Exception e) {
+        logger.error("sftp上报后finally里异常", e);
+      }
+    }
+  }
+
+  public void mkdirDir(String[] dirs, String tempPath, int length, int index, Sftp sftp) {
+    // 以"/a/b/c/d"为例按"/"分隔后,第0位是"";顾下标从1开始
+    index++;
+    if (index < length) {
+      // 目录不存在,则创建文件夹
+      tempPath += "/" + dirs[index];
+    }
+    try {
+      if (sftp.exist(tempPath)) {
+        if (index < length) {
+          mkdirDir(dirs, tempPath, length, index, sftp);
+        }
+      } else {
+        try {
+          sftp.mkdir(tempPath);
+          sftp.cd(tempPath);
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+        mkdirDir(dirs, tempPath, length, index, sftp);
+      }
+    } catch (Exception ex) {
+      try {
+        sftp.mkdir(tempPath);
+        sftp.cd(tempPath);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+      mkdirDir(dirs, tempPath, length, index, sftp);
+    }
+  }
+}

+ 50 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogDetailService.java

@@ -0,0 +1,50 @@
+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;
+
+import java.util.List;
+
+/**
+ * 上报日志明细service
+ * @author zy
+ * @version 3.0
+ */
+@Service
+@Slf4j
+public class UploadFileLogDetailService {
+  @Autowired
+  private UploadFileLogDetailRepository uploadFileLogDetailRepository;
+
+  /**
+   * 根据上报日志id查询明细
+   * @param uploadFileLogId
+   * @return UploadFileLogDetail 上报明细
+   *
+   */
+  public List<UploadFileLogDetail> getByFileLogId(Integer uploadFileLogId){
+    UploadFileLogDetail uploadFileLogDetail = new UploadFileLogDetail();
+    uploadFileLogDetail.setUploadFileLogId(uploadFileLogId);
+    List<UploadFileLogDetail> list = uploadFileLogDetailRepository.findAll(Example.of(uploadFileLogDetail));
+    return list;
+  }
+
+  /*
+  * 根据上报日志id删除明细
+  * */
+  public void deleteByUploadFileLogId(Integer uploadFileLogId){
+    try{
+      List<UploadFileLogDetail> list = getByFileLogId(uploadFileLogId);
+      for(UploadFileLogDetail uploadFileLogDetail : list){
+        uploadFileLogDetailRepository.deleteById(uploadFileLogDetail.getId());
+      }
+    }catch (Exception e){
+      log.info("根据上报日志id删除明细异常:"+e);
+    }
+
+  }
+}

+ 516 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogService.java

@@ -0,0 +1,516 @@
+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.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;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.persistence.criteria.Predicate;
+import java.io.File;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.toList;
+
+/**
+ * @author xsl
+ * @version 3.0
+ */
+@Service
+@Slf4j
+public class UploadFileLogService {
+  @Autowired
+  E63UploadFileService e63UploadFileService;
+  @Autowired
+  private E63UploadFileRuleService e63UploadFileRuleService;
+  @Autowired
+  private ElectricFieldService electricFieldService;
+  @Autowired
+  private UploadFileLogRepository uploadFileLogRepository;
+  @Autowired
+  private UploadObjectRepository uploadObjectRepository;
+  @Autowired
+  private QuartzRepository quartzRepository;
+  @Autowired
+  private ManualUploadLogRepository manualUploadLogRepository;
+
+  /**
+   * 文件日志查询
+   *
+   * @param uploadObjectId
+   * @param createTime
+   * @param fileType
+   * @param isUploadSuccess
+   * @return
+   */
+  public List<UploadFileLog> queryFileLog(Integer uploadObjectId, String createTime, String fileType, String isUploadSuccess, String stationCode) {
+    if ("ALL".equals(fileType)) {
+      fileType = "";
+    }
+
+    Specification<UploadFileLog> specification = this.getQuerySpecification(uploadObjectId, createTime, fileType,stationCode);
+    List<UploadFileLog> uploadFileLogList = uploadFileLogRepository.findAll(specification);
+
+    // 定义查询结果List
+    List<UploadFileLog> resultList = new ArrayList<>();
+    List<UploadObject> uploadObjectList = new ArrayList<>();
+    if (!"1".equals(isUploadSuccess)) {
+      if ("0".equals(isUploadSuccess)) {
+        resultList.addAll(uploadFileLogList.stream().filter(uploadFileLog -> !uploadFileLog.getFileStatusEnum().equals(FileStatusEnum.E2)).collect(toList()));
+      } else {
+        resultList.addAll(uploadFileLogList);
+      }
+
+      if (uploadObjectId.intValue() > 0) {
+        UploadObject uploadObject = uploadObjectRepository.findById(uploadObjectId).get();
+        uploadObjectList.add(uploadObject);
+      } else {
+        uploadObjectList = uploadObjectRepository.findAll();
+      }
+
+      List<Quartz> quartzList = quartzRepository.findAll();
+      for (UploadObject uploadObject : uploadObjectList) {
+        if (stationCode.equals(uploadObject.getStationCode())){
+          ElectricField electricField = electricFieldService.getSingleStation(stationCode);
+          if (!"".equals(fileType)) {
+            String executeClass = "com.jiayue.ipfcst.fileupload.job.UploadFile" + fileType + "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)), fileType, cronStr);
+            // 已经生成的文件
+            String finalFileType = fileType;
+            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())
+                .collect(Collectors.toList()).contains(item)).collect(Collectors.toList());
+
+            for (String noCreateFileName : noCreateFileNameList) {
+              UploadFileLog noCreateFileLog = new UploadFileLog();
+              noCreateFileLog.setUploadObjectNo(uploadObject.getObjectNo());
+              noCreateFileLog.setUploadObjectName(uploadObject.getUploadObjectName());
+              noCreateFileLog.setFileStatusEnum(FileStatusEnum.E4);
+              noCreateFileLog.setFileTypeEnum(FileTypeEnum.valueOf(fileType));
+              noCreateFileLog.setFileName(noCreateFileName);
+              noCreateFileLog.setUploadProtocolEnum(uploadObject.getUploadProtocolEnum());
+              resultList.add(noCreateFileLog);
+            }
+          } 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";
+              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<UploadFileLog> filterList = uploadFileLogList.stream().filter(uploadFileLog -> uploadFileLog.getFileTypeEnum().equals(FileTypeEnum.valueOf(uploadFileType))).collect(toList());
+              // 过滤出未生成的文件名称
+              List<String> noCreateFileNameList = shoudFileNameList.stream().filter(item ->
+                !filterList.stream().map(e -> e.getFileName())
+                  .collect(Collectors.toList()).contains(item)).collect(Collectors.toList());
+
+              for (String noCreateFileName : noCreateFileNameList) {
+                UploadFileLog noCreateFileLog = new UploadFileLog();
+                noCreateFileLog.setUploadObjectNo(uploadObject.getObjectNo());
+                noCreateFileLog.setUploadObjectName(uploadObject.getUploadObjectName());
+                noCreateFileLog.setFileStatusEnum(FileStatusEnum.E4);
+                noCreateFileLog.setFileTypeEnum(FileTypeEnum.valueOf(uploadFileType));
+                noCreateFileLog.setFileName(noCreateFileName);
+                noCreateFileLog.setUploadProtocolEnum(uploadObject.getUploadProtocolEnum());
+                resultList.add(noCreateFileLog);
+              }
+            }
+          }
+        }
+      }
+    } else {
+      // 上报成功的条件
+      resultList = uploadFileLogList.stream().filter(uploadFileLog -> uploadFileLog.getFileStatusEnum().equals(FileStatusEnum.E2)).collect(toList());
+    }
+
+    if (uploadObjectList.size() <= 0) {
+      uploadObjectList = uploadObjectRepository.findByStationCode(stationCode);
+    }
+    List<UploadFileLog> returnUploadFileList = new ArrayList<>();
+    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];
+          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())
+        .thenComparing(UploadFileLog::getFileTypeEnum).thenComparing(UploadFileLog::getFileName)).collect(Collectors.toList());
+
+    return sortResultList;
+  }
+
+  /**
+   * 封装文件日志查询条件
+   *
+   * @param uploadObjectId
+   * @param createTime
+   * @param fileType
+   * @return
+   */
+  private Specification<UploadFileLog> getQuerySpecification(Integer uploadObjectId, String createTime, String fileType,String stationCode) {
+    return (Specification<UploadFileLog>) (root, criteriaQuery, cb) -> {
+      List<Predicate> predicates = new ArrayList<>();
+      if (uploadObjectId.intValue() > 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'")));
+      }
+
+      if (StringUtils.isNotBlank(fileType)) {
+        predicates.add(cb.equal(root.get("fileTypeEnum").as(String.class), fileType));
+      }
+
+      if (StringUtils.isNotBlank(stationCode)) {
+        predicates.add(cb.equal(root.get("stationCode").as(String.class), stationCode));
+      }
+
+      return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+    };
+  }
+
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public boolean uploadFile(Integer objectId, String fileType, MultipartFile file) {
+    Long st = DateTimeUtil.getMillisecondsSubDay();
+    //明日凌晨
+    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;
+      File destDir = new File(destFileDir);
+      if (!destDir.exists()) {// 如果目录不存在则创建目录
+        boolean b = destDir.mkdirs();
+        if (!b) // 如果创建失败则抛出异常
+          throw new RuntimeException(destFileDir + " 目录创建失败");
+      }
+
+      File destFirFile = new File(destFileDir + File.separator + file.getOriginalFilename());
+      if (destFirFile.exists()) {
+        File reNameFile = new File(destFileDir + File.separator + file.getOriginalFilename() + "(被替换文件)");
+        if (reNameFile.exists()) {
+          reNameFile.delete();
+        }
+        boolean b = destFirFile.renameTo(reNameFile);
+        if (!b) {
+          return false;
+        }
+      }
+      file.transferTo(destFirFile);
+      if (uploadFileLog == null) {
+        UploadFileLog newUploadFileLog = new UploadFileLog();
+        newUploadFileLog.setUploadObjectId(uploadObject.getId());
+        newUploadFileLog.setUploadObjectName(uploadObject.getUploadObjectName());
+        newUploadFileLog.setUploadObjectNo(uploadObject.getObjectNo());
+        newUploadFileLog.setFileName(file.getOriginalFilename());
+        newUploadFileLog.setFileTypeEnum(FileTypeEnum.valueOf(fileType));
+        newUploadFileLog.setFileStatusEnum(FileStatusEnum.E1);
+        newUploadFileLog.setUploadProtocolEnum(uploadObject.getUploadProtocolEnum());
+        newUploadFileLog.setUploadCounter(0);
+        newUploadFileLog.setUploadFileEndTime(null);
+        newUploadFileLog.setFileRemarks("手动上传文件");
+        uploadFileLog = this.uploadFileLogRepository.save(newUploadFileLog);
+        String readyFileKey = uploadObject.getObjectNo() + "@" + fileType + "@" + file.getOriginalFilename();
+        FileConstant.readyUploadFileMap.put(readyFileKey, newUploadFileLog);
+        FileConstant.fileShouldMomentMap.put(readyFileKey, uploadFileLog.getId());
+        log.info("上报对象编号:" + uploadObject.getObjectNo() + ",上传文件" + file.getOriginalFilename() + "成功");
+      } else {
+        uploadFileLog.setUploadCounter(0);
+        String readyFileKey = uploadObject.getObjectNo() + "@" + fileType + "@" + file.getOriginalFilename();
+        FileConstant.readyUploadFileMap.put(readyFileKey, uploadFileLog);
+        FileConstant.fileShouldMomentMap.put(readyFileKey, uploadFileLog.getId());
+        log.info("上报对象编号:" + uploadObject.getObjectNo() + ",覆盖上传文件" + file.getOriginalFilename() + "成功");
+      }
+      ManualUploadLog manualUploadLog = new ManualUploadLog();
+      manualUploadLog.setFileName(uploadFileLog.getFileName());
+      manualUploadLog.setFileTypeEnum(uploadFileLog.getFileTypeEnum());
+      manualUploadLog.setUploadEquipmentID(uploadFileLog.getUploadEquipmentID());
+      manualUploadLog.setUploadObjectId(uploadFileLog.getUploadObjectId());
+      manualUploadLog.setUploadObjectName(uploadFileLog.getUploadObjectName());
+      manualUploadLog.setUploadObjectNo(uploadFileLog.getUploadObjectNo());
+      manualUploadLog.setUploadCatalog(destFileDir);
+      manualUploadLog.setUploadDate(new Date());
+      manualUploadLogRepository.save(manualUploadLog);
+      return true;
+    } catch (IOException e) {
+      log.info("手动上传上报文件发生错误!");
+      e.printStackTrace();
+      return false;
+    }
+  }
+
+  /*
+   * 根据id删除日志
+   */
+  public void deleteById(Integer id) {
+    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();
+        File destDir = new File(destFileDir);
+        if (destDir.exists()) {
+          File[] files = destDir.listFiles();
+          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() + File.separator + uploadFileLog.getFileTypeEnum().name();
+        File errDir = new File(errorFileDir);
+        if (errDir.exists()) {
+          File[] files = errDir.listFiles();
+          for (File file : files) {
+            if (uploadFileLog.getFileName().equals(file.getName())) {
+              file.delete();
+            }
+          }
+        }
+        String backFileDir = null;
+        // 备份文件目录
+        backFileDir = FileUtil.getFileUploadPath() + File.separator + "backups" + File.separator + uploadObject.getObjectNo() + File.separator + uploadFileLog.getFileTypeEnum().name();
+        File backDir = new File(backFileDir);
+        if (backDir.exists()) {
+          File[] files = backDir.listFiles();
+          for (File file : files) {
+            if (uploadFileLog.getFileName().equals(file.getName())) {
+              file.delete();
+            }
+          }
+        }
+      }
+
+      uploadFileLogRepository.deleteById(id);
+    } catch (Exception e) {
+      log.info("删除上报日志异常:" + e);
+    }
+  }
+
+  /*
+   * 清理缓存
+   */
+  public void cleanCache(UploadFileLog uploadFileLog) {
+    try {
+      String key = uploadFileLog.getUploadObjectNo() + "@" + uploadFileLog.getFileTypeEnum() + "@" + uploadFileLog.getFileName();
+      /*待上报文件的缓存变量*/
+      FileConstant.readyUploadFileMap.remove(key);
+      FileConstant.fileShouldMomentMap.remove(key);
+      /*文件上报次数累计的缓存变量*/
+      FileConstant.uploadCountMap.remove(key);
+      /*文件内容缓存变量*/
+      FileConstant.fileContentMap.remove(key);
+      /*文件内容及内容位置缓存变量*/
+      FileConstant.fileContentByIdxMap.remove(key);
+      /*遇到不正常回复时,将文件暂时放入再次上报变量*/
+      FileConstant.againUploadFileMap.remove(key);
+    } catch (Exception e) {
+      log.info("上报日志清除缓存异常:" + e);
+    }
+
+  }
+
+
+  /*
+   * 文件补报
+   */
+  public void report(UploadFileLog uploadFileLog) {
+
+      String pro = "";
+        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();
+        }
+      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()));
+          }
+
+          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.generateE1File(date);
+                break;
+//              case "E2":
+//                // 超短期
+//                e63UploadFileService.generateE2File(date);
+//                break;
+//              case "E3":
+//                // 理论功率
+//                e63UploadFileService.generateE3File(date);
+//                break;
+//              case "E6":
+//                // 气象站
+//                e63UploadFileService.generateE6File(date);
+//                break;
+//              case "E7":
+//                // 测风塔
+//                e63UploadFileService.generateE7File(date);
+//                break;
+//              case "E8":
+//                // 逆变器
+//                e63UploadFileService.generateE8File(date);
+//                break;
+//              case "E9":
+//                // 风机
+//                e63UploadFileService.generateE9File(date);
+//                break;
+//              case "E26":
+//                // 短期可用
+//                e63UploadFileService.generateE26File(date);
+//                break;
+//              case "E27":
+//                // 超短期可用
+//                e63UploadFileService.generateE27File(date);
+//                break;
+//              case "E29":
+//                // 短期预测风速风向
+//                e63UploadFileService.generateE29File(date);
+//                break;
+//              case "E45":
+//                // 超短期预测风速风向
+//                e63UploadFileService.generateE45File(date);
+//                break;
+//              case "E30":
+//                // 实测功率
+//                e63UploadFileService.generateE30File(date);
+//                break;
+//              case "E31":
+//                // 短期辐照度
+//                e63UploadFileService.generateE31File(date);
+//                break;
+//              case "E47":
+//                // 超短期辐照度
+//                e63UploadFileService.generateE47File(date);
+//                break;
+//              case "E32":
+//                // 短期日志
+//                e63UploadFileService.generateE32File(date);
+//                break;
+//              case "E33":
+//                // 超短期日志
+//                e63UploadFileService.generateE33File(date);
+//                break;
+//              case "E34":
+//                // 可用短期日志
+//                e63UploadFileService.generateE34File(date);
+//                break;
+//              case "E35":
+//                // 可用超短期日之
+//                e63UploadFileService.generateE35File(date);
+//                break;
+//              case "E36":
+//                // 气象站日志
+//                e63UploadFileService.generateE36File(date);
+//                break;
+//              case "E37":
+//                // 理论功率日志
+//                e63UploadFileService.generateE37File(date);
+//                break;
+//              case "E38":
+//                // 逆变器日志
+//                e63UploadFileService.generateE38File(date);
+//                break;
+//              case "E39":
+//                // 风机日志
+//                e63UploadFileService.generateE39File(date);
+//                break;
+//              case "E40":
+//                // 测风塔日志
+//                e63UploadFileService.generateE40File(date);
+//                break;
+//              case "E41":
+//                // 指标数据
+//                e63UploadFileService.generateE41File(date);
+//                break;
+//              case "E85":
+//                // 理论功率风
+//                e63UploadFileService.generateE85File(date);
+//                break;
+              default:
+                break;
+            }
+          }
+        }
+  }
+
+
+}

+ 36 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadObjectService.java

@@ -1,6 +1,7 @@
 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;
@@ -111,4 +112,39 @@ public class UploadObjectService extends BaseService {
     }
     return list;
   }
+
+  /**
+   * 获取省份对应上报文件类型
+   *
+   * @return 上报对象信息
+   */
+  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());
+    uploadFileTypeMap.put(FileTypeEnum.E3.toString(), FileTypeEnum.E3.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E6.toString(), FileTypeEnum.E6.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E7.toString(), FileTypeEnum.E7.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E8.toString(), FileTypeEnum.E8.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E9.toString(), FileTypeEnum.E9.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E26.toString(), FileTypeEnum.E26.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E27.toString(), FileTypeEnum.E27.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E29.toString(), FileTypeEnum.E29.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E30.toString(), FileTypeEnum.E30.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E31.toString(), FileTypeEnum.E31.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E32.toString(), FileTypeEnum.E32.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E33.toString(), FileTypeEnum.E33.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E34.toString(), FileTypeEnum.E34.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E35.toString(), FileTypeEnum.E35.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E36.toString(), FileTypeEnum.E36.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E37.toString(), FileTypeEnum.E37.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E38.toString(), FileTypeEnum.E38.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E39.toString(), FileTypeEnum.E39.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E40.toString(), FileTypeEnum.E34.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E41.toString(), FileTypeEnum.E41.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E45.toString(), FileTypeEnum.E45.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E47.toString(), FileTypeEnum.E47.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E85.toString(), FileTypeEnum.E85.getMessage());
+    return uploadFileTypeMap;
+  }
 }

+ 46 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadURLService.java

@@ -0,0 +1,46 @@
+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;
+
+import java.util.List;
+
+@Service
+public class UploadURLService {
+  @Autowired
+  private UploadURLRepository uploadURLRepository;
+
+  @Transactional
+  public List<UploadURL> findAll(){
+    return uploadURLRepository.findAll();
+  }
+
+  @Transactional
+  public List<UploadURL> findByUploadCahnnelId(Integer id){
+    return uploadURLRepository.findByUploadChannelId(id);
+  }
+
+  @Transactional
+  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){
+      uploadURLRepository.deleteAll();
+      uploadURLRepository.saveAll(beans);
+    }
+  }
+
+  @Transactional
+  public void deleteByChannelId(Integer uploadChannelId){
+    uploadURLRepository.deleteByUploadChannelId(uploadChannelId);
+  }
+
+
+}

+ 14 - 0
ipfcst-console/src/main/resources/vms/CDQ.vm

@@ -0,0 +1,14 @@
+// ${currentTime}
+<! Entity=${sign} type=CDQ time='${uploadTime}' !>
+
+<RunningCapacity::${sign}>
+@id    实时开机容量
+#1      ${capacity}
+</RunningCapacity::${sign}>
+
+<UltraShortTermForcast::${sign}>
+@id   超短期预测功率
+#foreach( $cdq in $vList )
+#${velocityCount}  ${cdq.ableValue}
+#end
+</UltraShortTermForcast::${sign}>

+ 8 - 0
ipfcst-console/src/main/resources/vms/CDQFS.vm

@@ -0,0 +1,8 @@
+// ${currentTime}
+<! Entity=${sign}  type=CDQFS  time='${uploadTime}'  !>
+<UltraShortTermForcast::${sign}>
+@id  超短期预测风速 超短期预测风向
+#foreach( $dqfs in $vList )
+#${velocityCount}  ${dqfs.ws10}  ${dqfs.wd10}
+#end
+</UltraShortTermForcast::${sign}>

+ 8 - 0
ipfcst-console/src/main/resources/vms/CDQFZD.vm

@@ -0,0 +1,8 @@
+// ${currentTime}
+<! Entity=${sign} type=CDQFZD time='${uploadTime}' !>
+<UltraShortTermForcast::${sign}>
+@id   超短期预测辐照度
+#foreach( $dq in $vList )
+#${velocityCount}  ${dq.swr}
+#end
+</UltraShortTermForcast::${sign}>

+ 14 - 0
ipfcst-console/src/main/resources/vms/CDQ_F.vm

@@ -0,0 +1,14 @@
+// ${currentTime}
+<! Entity=${sign}  type=CDQ  time='${uploadTime}' !>
+
+<RunningCapacity::${sign}>
+@id   实时开机容量
+#1    ${capacity}
+</RunningCapacity::${sign}>
+
+<UltraShortTermForcast::${sign}>
+@id   超短期预测功率
+#foreach( $cdq in $vList )
+#${velocityCount}    ${cdq.ableValue}
+#end
+</UltraShortTermForcast::${sign}>

+ 9 - 0
ipfcst-console/src/main/resources/vms/CDQ_USE.vm

@@ -0,0 +1,9 @@
+// ${currentTime}
+<! Entity=${sign} type=CDQ_USE time='${uploadTime}' !>
+
+<UltraShortTermForcast::${sign}>
+@id   超短期可用功率
+#foreach( $cdq in $vList )
+#${velocityCount}	${cdq.ableValue}
+#end
+</UltraShortTermForcast::${sign}>

+ 9 - 0
ipfcst-console/src/main/resources/vms/CDQ_USE_F.vm

@@ -0,0 +1,9 @@
+// ${currentTime}
+<! Entity=${sign}  type=CDQ_USE  time='${uploadTime}' !>
+
+<UltraShortTermForcast::${sign}>
+@id   超短期可用功率
+#foreach( $cdq in $vList )
+#${velocityCount}    ${cdq.ableValue}
+#end
+</UltraShortTermForcast::${sign}>

+ 27 - 0
ipfcst-console/src/main/resources/vms/CFT.vm

@@ -0,0 +1,27 @@
+// ${currentTime}
+<! Entity=${sign}  type=CFT  time='${uploadTime}' !>
+
+<MastData::${sign}>
+@id   属性项        数值
+#1    WS_10        ${WS_10}
+#2    WD_10        ${WD_10}
+#3    WS_30        ${WS_30}
+#4    WD_30        ${WD_30}
+#5    WS_50        ${WS_50}
+#6    WD_50        ${WD_50}
+#7    WS_60        ${WS_60}
+#8    WD_60        ${WD_60}
+#9    WS_70        ${WS_70}
+#10   WS_70        ${WD_70}
+#11   WS_80        ${WS_80}
+#12   WD_80        ${WD_80}
+#13   WS_90        ${WS_90}
+#14   WD_90        ${WD_90}
+#15   WS_100       ${WS_100}
+#16   WD_100       ${WD_100}
+#17   WS_HubHeight ${WS_HubHeight}
+#18   WD_HubHeight ${WD_HubHeight}
+#19   T_8         ${T_8}
+#20   P_8         ${P_8}
+#21   H_8         ${RH_8}
+</MastData::${sign}>

+ 14 - 0
ipfcst-console/src/main/resources/vms/DQ.vm

@@ -0,0 +1,14 @@
+// ${currentTime}
+<!Entity=${sign} type=DQ time='${uploadTime}' !>
+
+<Capacity::${sign}>
+@id   装机容量
+#1    ${capacity}
+</Capacity::${sign}>
+
+<ShortTermForcast::${sign}>
+@id        短期预测功率        预计开机容量
+#foreach( $dq in $vList )
+#${velocityCount}       ${dq.ableValue}       ${dq.capacity}
+#end
+</ShortTermForcast::${sign}>

+ 8 - 0
ipfcst-console/src/main/resources/vms/DQFS.vm

@@ -0,0 +1,8 @@
+//  ${currentTime}
+<! Entity=${sign} type=DQFS  time='${uploadTime}'  !>
+<ShortTermForcast::${sign}>
+@id  短期预测风速  短期预测风向
+#foreach( $dqfs in $vList )
+#${velocityCount}	${dqfs.ws10}	${dqfs.wd10}
+#end
+</ShortTermForcast::${sign}>

+ 8 - 0
ipfcst-console/src/main/resources/vms/DQFZD.vm

@@ -0,0 +1,8 @@
+// ${currentTime}
+<! Entity=${sign}  type=DQFZD  time='${uploadTime}' !>
+<ShortTermForcast::${sign}>
+@id 短期预测辐照度
+#foreach( $dq in $vList )
+#${velocityCount}   ${dq.swr}
+#end
+</ShortTermForcast::${sign}>

+ 14 - 0
ipfcst-console/src/main/resources/vms/DQ_F.vm

@@ -0,0 +1,14 @@
+// ${currentTime}
+<! Entity=${sign}  type=DQ  time='${uploadTime}' !>
+
+<Capacity::${sign}>
+@id   装机容量
+#1    ${capacity}
+</Capacity::${sign}>
+
+<ShortTermForcast::${sign}>
+@id 短期预测功率 预计开机容量
+#foreach( $dq in $vList )
+#${velocityCount}   ${dq.ableValue}   ${dq.capacity}
+#end
+</ShortTermForcast::${sign}>

+ 9 - 0
ipfcst-console/src/main/resources/vms/DQ_USE.vm

@@ -0,0 +1,9 @@
+// ${currentTime}
+<!Entity=${sign} type=DQ_USE time='${uploadTime}' !>
+
+<ShortTermForcast::${sign}>
+@id        短期可用功率
+#foreach( $dq in $vList )
+#${velocityCount}       ${dq.ableValue}
+#end
+</ShortTermForcast::${sign}>

+ 9 - 0
ipfcst-console/src/main/resources/vms/DQ_USE_F.vm

@@ -0,0 +1,9 @@
+// ${currentTime}
+<! Entity=${sign}  type=DQ_USE time='${uploadTime}' !>
+
+<ShortTermForcast::${sign}>
+@id 短期可用功率
+#foreach( $dq in $vList )
+#${velocityCount}   ${dq.ableValue}
+#end
+</ShortTermForcast::${sign}>

+ 14 - 0
ipfcst-console/src/main/resources/vms/FJ.vm

@@ -0,0 +1,14 @@
+//${currentTime}
+<!	Entity=${sign}	type=FJ	time='${uploadTime}'	!>
+
+<RatedCapacity::${sign}>
+@id	机组额定容量总加
+#1	${capacity}
+</RatedCapacity::${sign}>
+
+<FANDATA::${sign}>
+@	标识	风电场名称	风机集电线名称	风机名称	风机类型	额定容量	是否样板机	运行状态	有功功率	无功功率	电压	电流	功率因数	机头风速	机头风向	当日发电量	累计发电量	发电机转速	浆距角
+#foreach( $fj in $vList )
+#	${velocityCount}	${fj.elName}	${fj.collectorCircuit}	${fj.name}	${fj.modelNumber}	${fj.RatedCapacity}	${fj.sample}	${fj.dtaStatus}	${fj.ActivePower}	${fj.ReActivePower}	${fj.Voltage}	${fj.GalvanicCurrent}	${fj.PowerFactor}	${fj.WS}	${fj.WD}	${fj.DayElectricQuantity}	${fj.GeneratingCap}	${fj.RotationlSpeed}	${fj.PropellerPitchAngle}
+#end
+</FANDATA::${sign}>

+ 21 - 0
ipfcst-console/src/main/resources/vms/INDICATORS.vm

@@ -0,0 +1,21 @@
+{
+  "gid": "${gid}",
+  "date": "${date}",
+  "data": [
+    {
+      "rateType": "${dq}",
+      "reportrate": "${dqReportrate}",
+      "accurate": "${dqAccurate}"
+    },
+    {
+      "rateType": "${cdq}",
+      "reportrate": "${cdqReportrate}",
+      "accurate": "${cdqAccurate}"
+    }
+  ],
+  "singlePoint": {
+#foreach( $val in $vList )
+    ${val.name}: ${val.value}
+#end
+  }
+}

+ 11 - 0
ipfcst-console/src/main/resources/vms/JSONLOG.vm

@@ -0,0 +1,11 @@
+{
+  "gid": "${gid}",
+  "type": "${type}",
+  "source": "${source}",
+  "service": "${service}",
+  "since": "${since}",
+  "timestamp": "${timestamp}",
+  "file": "${file}",
+  "status": "${status}",
+  "reporttype": "${reporttype}"
+}

+ 14 - 0
ipfcst-console/src/main/resources/vms/NBQ.vm

@@ -0,0 +1,14 @@
+//${currentTime}
+<! Entity=${sign} type=NBQ time='${uploadTime}' !>
+
+<RatedCapacity::${sign}>
+@id	额定容量总加
+#1	${capacity}
+</RatedCapacity::${sign}>
+
+<FANDATA::${sign}>
+@	标识	光伏站名称	光伏集电线名称	逆变器名称	逆变器类型	额定容量	是否样板机	有功功率	无功功率	电压	电流	功率因数	当日发电量	累计发电量	是否组串式逆变器	运行状态
+#foreach( $nbq in $vList )
+# ${velocityCount} ${nbq.czmc} ${nbq.CollectorCircuit} ${nbq.name} ${nbq.modelNumber} ${nbq.RatedCapacity} ${nbq.sample} ${nbq.NbqActivePower} ${nbq.NbqReActivePower} ${nbq.Voltage} ${nbq.GalvanicCurrent} ${nbq.PowerFactor} ${nbq.NbqDailyOutPut} ${nbq.GeneratingCap} ${nbq.IsString} ${nbq.status}
+#end
+</FANDATA::${sign}>

+ 15 - 0
ipfcst-console/src/main/resources/vms/QXZ.vm

@@ -0,0 +1,15 @@
+// ${currentTime}
+<! Entity=${sign}  type=QX  time='${uploadTime}' !>
+
+<MastData::${sign}>
+@id	属性项	数值
+#1	GlobalR	${GlobalR}
+#2	DirectR	${DirectR}
+#3	DiffuseR	${DiffuseR}
+#4	AirT	${AirT}
+#5	CellT	${CellT}
+#6	WS	${WS}
+#7	WD	${WD}
+#8	P	${P}
+#9	RH	${RH}
+</MastData::${sign}>

+ 6 - 0
ipfcst-console/src/main/resources/vms/SCF.vm

@@ -0,0 +1,6 @@
+// ${currentTime}
+<! Entity=${sign} type=SC time='${uploadTime}' !>
+<MastData::${sign}>
+@id 属性项 数值
+#1 SC ${value}
+</MastData::${sign}>

+ 6 - 0
ipfcst-console/src/main/resources/vms/SCG.vm

@@ -0,0 +1,6 @@
+// ${currentTime}
+<! Entity=${sign}  type=SC  time='${uploadTime}' !>
+<MastData::${sign}>
+@id  属性项   数值
+#1    SC     ${value}
+</MastData::${sign}>

+ 8 - 0
ipfcst-console/src/main/resources/vms/THEROY.vm

@@ -0,0 +1,8 @@
+// ${currentTime}
+<! Entity=${sign} type=THEROY time='${uploadTime}' !>
+
+<THEROY::${sign}>
+@id  描述 理论功率值
+#1 样板机法   ${ableValueAfter}
+#2 辐照仪法   ${theoryValueAfter}
+</THEROY::${sign}>

+ 10 - 0
ipfcst-console/src/main/resources/vms/THEROY_F.vm

@@ -0,0 +1,10 @@
+// ${currentTime}
+<! Entity=${sign}  type=THEROY  time='${uploadTime}' !>
+
+<THEROY::${sign}>
+@id  描述 理论功率值
+#1 样板机法   ${referencePowerBySampleAfter}
+#2 测风法   ${referencePowerByMeasuringAfter}
+#3 机头风速(所有风机)   ${theoryValueAfter}
+#4 机头风速(除检修的风机外)   ${ableValueAfter}
+</THEROY::${sign}>