From 312710045c2b5d84ed0dc97af4a4fe7704f619d5 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期五, 30 一月 2026 10:31:01 +0800
Subject: [PATCH] 增加定时校验网关是否在线

---
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java |  340 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 328 insertions(+), 12 deletions(-)

diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java
index 28379e8..8702908 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java
@@ -1,12 +1,24 @@
 package com.fzzy.igds.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fzzy.igds.domain.FileInfo;
+import com.fzzy.igds.domain.Quantity;
+import com.fzzy.igds.mapper.FileMapper;
+import com.fzzy.igds.utils.Base64Util;
+import com.fzzy.igds.utils.ContextUtil;
 import com.ruoyi.common.config.FrameworkConfig;
 import org.apache.commons.lang3.time.DateFormatUtils;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import com.ruoyi.common.utils.StringUtils;
-
+import javax.annotation.Resource;
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
 import java.io.File;
+import java.io.IOException;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @Description
@@ -16,14 +28,198 @@
 @Service
 public class FileService {
 
+    @Resource
+    private FileMapper fileMapper;
+
     /**
-     * 鑾峰彇鍑哄叆搴撴枃浠惰矾寰�
-     * @param date
+     * 鏍规嵁鏉′欢鑾峰彇闄勪欢淇℃伅
+     * @param companyId
+     * @param bizId
      * @return
      */
-    public String getInoutFilePath(Date date) {
-        if (null == date) date = new Date();
-        String basePath = FrameworkConfig.getProfile() + "INOUT/" + DateFormatUtils.format(date, "yyyyMM") + "/";
+    public List<FileInfo> listFile(String companyId, String bizId) {
+        if (StringUtils.isEmpty(companyId)) {
+            companyId = ContextUtil.getCompanyId();
+        }
+
+        if (StringUtils.isEmpty(bizId)){
+            return null;
+        }
+
+        QueryWrapper<FileInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("company_id", companyId);
+        queryWrapper.eq("biz_id", bizId);
+        queryWrapper.orderByAsc("create_time");
+
+        return fileMapper.selectList(queryWrapper);
+    }
+
+    /**
+     * 寮傛鎵ц闄勪欢淇濆瓨
+     * @param files     闄勪欢淇℃伅
+     * @param bizId     涓氬姟id
+     * @param bizTag    鏍囩
+     * @param pathTag   鏂囦欢璺緞鏍囪瘑
+     */
+    @Async
+    public void saveInoutFiles(List<FileInfo> files, String bizId, String bizTag, String pathTag) {
+
+        if (null == files || files.isEmpty()) {
+            return;
+        }
+
+        for (FileInfo data : files) {
+            // 濡傛灉娌℃湁闄勪欢鍚嶇О锛屽垯涓嶄繚瀛橀檮浠朵俊鎭�
+            if (StringUtils.isBlank(data.getFileName())) {
+                continue;
+            }
+
+            data.setId(ContextUtil.generateId());
+            data.setCreateTime(new Date());
+            data.setCreateBy(ContextUtil.getLoginUserName());
+            data.setCompanyId(ContextUtil.getCompanyId());
+
+            //鏂囦欢鍏ㄨ矾寰�
+            String filePath = getFileSavePath(pathTag) + data.getFileName();
+
+            filePath = filePath.replace(FrameworkConfig.getProfile(), "/profile/");
+            data.setFilePath(filePath);
+
+            if (StringUtils.isNotEmpty(bizId)) {
+                data.setBizId(bizId);
+            }
+            if (StringUtils.isNotEmpty(bizTag)) {
+                data.setBizTag(bizTag);
+            }
+
+            saveFile(data);
+        }
+    }
+
+    /**
+     *
+     * @param data
+     */
+    public void saveFile(FileInfo data) {
+
+        data.setUpdateTime(new Date());
+        data.setUpdateBy(ContextUtil.getLoginUserName());
+
+        if(StringUtils.isBlank(data.getId())){
+            data.setId(ContextUtil.UUID());
+            data.setCreateTime(new Date());
+            data.setCreateBy(ContextUtil.getLoginUserName());
+        }
+
+        fileMapper.insert(data);
+    }
+
+
+    /**
+     * 鏍规嵁鏉′欢鏌ヨ鏁版嵁
+     * @param companyId
+     * @param deptId
+     * @param bizId
+     * @return
+     */
+    public List<FileInfo> listFile(String companyId, String deptId, String bizId, String bizTag) {
+        QueryWrapper<FileInfo> queryWrapper = new QueryWrapper<>();
+        if (StringUtils.isNotBlank(companyId)) {
+            queryWrapper.eq("company_id", companyId);
+        }
+        if (StringUtils.isNotBlank(deptId)) {
+            queryWrapper.eq("dept_id", deptId);
+        }
+        if (StringUtils.isNotBlank(bizId)) {
+            queryWrapper.eq("biz_id", bizId);
+        }
+        if (StringUtils.isNotBlank(bizTag)) {
+            queryWrapper.eq("biz_tag", bizTag);
+        }
+        return fileMapper.selectList(queryWrapper);
+    }
+
+    /**
+     * 鏍规嵁绫诲瀷鑾峰彇鏂囦欢璺緞
+     * @param pathTag
+     * @return
+     */
+    public String getFileSavePath(String pathTag) {
+        if(StringUtils.isBlank(pathTag)){
+            pathTag = "COMMON";
+        }
+        if("EVENT".equals(pathTag)) return getEventFilePath();
+        if("SNAP".equals(pathTag)) return getSnapFilePath();
+        if("INOUT".equals(pathTag)) return getInoutFilePath();
+        if("PATROL".equals(pathTag)) return getPatrolFilePath();
+        if("DEPT".equals(pathTag)) return getDeptFilePath();
+        if("TEMP".equals(pathTag)) return getTempFilePath();
+        if("CONF".equals(pathTag)) return getConfPath();
+        if("TEMPLATE".equals(pathTag)) return getTemplateFilePath();
+        if("QUANTITY".equals(pathTag)) return getQuantityPath();
+        if("WORD".equals(pathTag)) return getWordPath();
+
+        return getCommonFilePath();
+    }
+
+    /**
+     * 鑾峰彇浜嬩欢鏂囦欢璺緞
+     * @return
+     */
+    public String getQuantityPath() {
+        String basePath = FrameworkConfig.getProfile() + "QUANTITY/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇浜嬩欢鏂囦欢璺緞
+     * @return
+     */
+    public String getEventFilePath() {
+        String basePath = FrameworkConfig.getProfile() + "EVENT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇鎶撴媿鏂囦欢璺緞
+     * @return
+     */
+    public String getSnapFilePath() {
+        String basePath = FrameworkConfig.getProfile() + "SNAP/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇宸℃鏂囦欢璺緞
+     * @return
+     */
+    public String getPatrolFilePath() {
+        String basePath = FrameworkConfig.getProfile() + "PATROL/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇鍑哄叆搴撴枃浠惰矾寰�
+     * @return
+     */
+    public String getInoutFilePath() {
+        String basePath = FrameworkConfig.getProfile() + "INOUT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
         File file = new File(basePath);
         if (!file.exists()) {
             file.mkdirs();
@@ -33,15 +229,11 @@
 
     /**
      * 鑾峰彇搴撳尯璺緞涓嬫枃浠�
-     * @param companyId
      * @return
      */
-    public String getDeptFilePath(String companyId) {
-        if (StringUtils.isEmpty(companyId)){
-            companyId = FrameworkConfig.getCompanyId();
-        }
+    public String getDeptFilePath() {
 
-        String basePath = FrameworkConfig.getProfile() + "IMG/"+ companyId + "/SECURITY/";
+        String basePath = FrameworkConfig.getProfile() + "IMG/"+ FrameworkConfig.getCompanyId() + "/SECURITY/";
 
         File file = new File(basePath);
         if (!file.exists()) {
@@ -49,4 +241,128 @@
         }
         return basePath;
     }
+
+    /**
+     * 鑾峰彇鍏叡璺緞
+     * @return
+     */
+    public String getCommonFilePath() {
+
+        String basePath = FrameworkConfig.getProfile() + "COMMON/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇涓存椂璺緞
+     * @return
+     */
+    public String getTempFilePath() {
+
+        String basePath = FrameworkConfig.getProfile() + "TEMP/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇妯℃澘璺緞
+     * @return
+     */
+    public String getConfPath() {
+
+        String basePath = FrameworkConfig.getProfile() + "CONF/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇妯℃澘璺緞锛氭墍鏈夋ā鏉跨粺涓�鏀惧湪TEMPLATE/鐩綍涓�
+     * @return
+     */
+    public String getTemplateFilePath() {
+        String basePath = FrameworkConfig.getProfile() + "TEMPLATE/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * 鑾峰彇word璺緞
+     * @return
+     */
+    public String getWordPath() {
+
+        String basePath = FrameworkConfig.getProfile()  + "WORD/";
+        File file = new File(basePath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return basePath;
+    }
+
+    /**
+     * base64杞浘鐗囦繚瀛�
+     * @param filePath
+     * @param imgData
+     */
+    public void baseImg2Disk(String filePath, String imgData) {
+        Base64Util.generateImage(imgData, filePath);
+    }
+
+    /**
+     * 鍘嬬缉鍥剧墖
+     *
+     * @param filePath   鍘嬬缉鍓嶈矾寰�
+     * @param scale      鍘嬬缉姣斾緥
+     * @param outputPath 鍘嬬缉鍚庤矾寰�
+     * @throws IOException
+     */
+    public void compressedImage(String filePath, double scale, String outputPath) throws IOException {
+        BufferedImage bufferedImage = ImageIO.read(new File(filePath));
+        int newWidth = (int) (bufferedImage.getWidth() * scale);
+        int newHeight = (int) (bufferedImage.getHeight() * scale);
+
+        //鍒涘缓鍘嬬缉鍚庣殑鍥剧墖
+        BufferedImage compressedImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB);
+        Graphics2D graphics2D = compressedImage.createGraphics();
+
+        //缁樺埗鍘熷鍥剧墖鍒板帇缂╁悗鐨勫浘鐗囦笂
+        graphics2D.drawImage(bufferedImage, 0, 0, newWidth, newHeight, null);
+        graphics2D.dispose();
+
+        ImageIO.write(compressedImage, "jpg", new File(outputPath));
+    }
+
+    /**
+     * 鍒ゆ柇璺緞涓嬫枃浠舵槸鍚﹀瓨鍦紝涓嶅瓨鍦ㄥ垯缁欓粯璁�
+     * @param imgPath
+     * @return
+     */
+    public String isImgExit(String imgPath, String tag) {
+        String path = "/img/img-fail.jpg";
+        if(StringUtils.isNotBlank(tag) && "dept".equals(tag)){
+            path = "/img/deptImg.jpg";
+        }
+        if(StringUtils.isNotBlank(imgPath)){
+            File file = new File(imgPath.replace("/profile", FrameworkConfig.getProfile()));
+            if(file.exists()){
+                path = imgPath;
+            }
+        }
+        return path;
+    }
+
+
 }

--
Gitblit v1.9.3