From 30272471be13ecb9a1a711a5c037fe27127c9056 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 11 二月 2023 13:38:24 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/sys/ReportService.java |   39 +++++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/lf/server/service/sys/ReportService.java b/src/main/java/com/lf/server/service/sys/ReportService.java
index df5813e..cb77083 100644
--- a/src/main/java/com/lf/server/service/sys/ReportService.java
+++ b/src/main/java/com/lf/server/service/sys/ReportService.java
@@ -1,10 +1,14 @@
 package com.lf.server.service.sys;
 
+import com.lf.server.entity.all.StaticData;
 import com.lf.server.entity.ctrl.CountEntity;
+import com.lf.server.entity.data.DownloadEntity;
 import com.lf.server.entity.sys.AttachEntity;
 import com.lf.server.entity.sys.ReportEntity;
+import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.*;
 import com.lf.server.mapper.sys.ReportMapper;
+import com.lf.server.service.data.DownloadService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -28,6 +32,9 @@
 
     @Autowired
     PathHelper pathHelper;
+
+    @Autowired
+    DownloadService downloadService;
 
     @Override
     public Integer selectCount(String name) {
@@ -101,7 +108,7 @@
     /**
      * 鍒涘缓鎶ュ憡
      */
-    public void createReport(ReportEntity re, HttpServletResponse res) throws Exception {
+    public void createReport(UserEntity ue, ReportEntity re, HttpServletResponse res) throws Exception {
         AttachEntity ae = attachService.selectByGuid(re.getGuid());
         if (null == ae) {
             return;
@@ -109,7 +116,7 @@
 
         String source = pathHelper.getConfig().getUploadPath() + File.separator + ae.getPath();
         String targetName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + FileHelper.getExtension(ae.getName());
-        String target = pathHelper.getShareFullPath() + File.separator + targetName;
+        String target = pathHelper.getDownloadFullPath() + File.separator + targetName;
 
         File sourceFile = new File(source);
         if (!sourceFile.exists() || sourceFile.isDirectory()) {
@@ -122,14 +129,18 @@
             return;
         }
 
-        WebHelper.download(target, targetName, res);
+        DownloadEntity de = getDownloadEntity(ue, target);
+        int rows = downloadService.insert(de);
+        if (rows > 0) {
+            WebHelper.download(target, targetName, res);
+        }
     }
 
     /**
      * 鐢熸垚鎶ュ憡
      */
     private void generateReport(String source, String target, ReportEntity re) {
-        if ("1".equals(re.getType())) {
+        if (StaticData.S1.equals(re.getType())) {
             switch (re.getCode()) {
                 case "countOperates ":
                     createCountOperatesWord(source, target);
@@ -202,4 +213,24 @@
 
         WordHelper.generateWord(source, target, null, addList);
     }
+
+    /**
+     * 鑾峰彇涓嬭浇瀹炰綋绫�
+     */
+    private DownloadEntity getDownloadEntity(UserEntity ue, String file) {
+        DownloadEntity de = new DownloadEntity();
+        de.setName(FileHelper.getFileName(file));
+        de.setType(6);
+        de.setSizes(FileHelper.sizeToMb(new File(file).length()));
+        de.setDepid(ue.getDepid());
+        de.setDcount(1);
+        de.setPwd(null);
+        de.setUrl(FileHelper.getRelativePath(file));
+        de.setDescr("缁熻鎶ュ憡");
+        de.setGuid(FileHelper.getFileMd5(file));
+        de.setCreateUser(ue.getId());
+        // de.setGeom(null)
+
+        return de;
+    }
 }

--
Gitblit v1.9.3