From b5a87e4b0da54ad57f195e52cd06e7824e2e1f54 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 10 四月 2026 16:41:47 +0800
Subject: [PATCH] yys 1.app推送接口 2.数采缓存 3.数采历史数据

---
 src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java |  137 +++++++++++++++++++++-
 src/main/java/com/ruoyi/other/controller/PdaVersionController.java                  |   31 +++++
 src/main/java/com/ruoyi/other/mapper/PdaVersionMapper.java                          |    9 +
 src/main/java/com/ruoyi/common/enums/FileNameType.java                              |    3 
 src/main/java/com/ruoyi/other/pojo/TempFile.java                                    |   14 ++
 src/main/java/com/ruoyi/sales/pojo/CommonFile.java                                  |    2 
 src/main/java/com/ruoyi/http/service/controller/JclyController.java                 |   12 ++
 src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java                 |    5 
 src/main/java/com/ruoyi/other/service/PdaVersionService.java                        |   13 ++
 src/main/java/com/ruoyi/other/service/impl/PdaVersionServiceImpl.java               |   60 ++++++++++
 src/main/java/com/ruoyi/other/controller/TempFileController.java                    |    2 
 src/main/java/com/ruoyi/other/pojo/PdaVersion.java                                  |   60 ++++++++++
 12 files changed, 334 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/ruoyi/common/enums/FileNameType.java b/src/main/java/com/ruoyi/common/enums/FileNameType.java
index 7afc045..7f3cec1 100644
--- a/src/main/java/com/ruoyi/common/enums/FileNameType.java
+++ b/src/main/java/com/ruoyi/common/enums/FileNameType.java
@@ -14,7 +14,8 @@
     SHIP(9),//鍙戣揣鍙拌处
     INSPECTION_PRODUCTION_BEFORE(10),
     INSPECTION_PRODUCTION_AFTER(11),
-    INSPECTION(12);//宸℃ 鐢熶骇鍓�
+    INSPECTION(12),//宸℃ 鐢熶骇鍓�
+    APP(13);
 
     private final int value;
 
diff --git a/src/main/java/com/ruoyi/http/service/controller/JclyController.java b/src/main/java/com/ruoyi/http/service/controller/JclyController.java
index ed86d62..be9a721 100644
--- a/src/main/java/com/ruoyi/http/service/controller/JclyController.java
+++ b/src/main/java/com/ruoyi/http/service/controller/JclyController.java
@@ -7,6 +7,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.naming.ldap.PagedResultsControl;
@@ -48,4 +49,15 @@
         return AjaxResult.success(maps);
     }
 
+    /**
+     * 鑾峰彇鍘嗗彶鏁版嵁
+     */
+    @GetMapping("/getHistoryData")
+    public AjaxResult getHistoryData(@RequestParam(value = "guid") String guid,
+                                     @RequestParam(value = "startTime") long startTime,
+                                     @RequestParam(value = "endTime") long endTime) {
+        List<Map<String,String>> maps = realTimeEnergyConsumptionService.getHistoryData(guid, startTime, endTime);
+        return AjaxResult.success(maps);
+    }
+
 }
diff --git a/src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java b/src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java
index 8b0b28a..7e535f9 100644
--- a/src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java
+++ b/src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java
@@ -10,10 +10,13 @@
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author :yys
@@ -23,11 +26,15 @@
 @Slf4j
 public class RealTimeEnergyConsumptionServiceImpl implements RealTimeEnergyConsumptionService {
 
+    private static final long REMOTE_CACHE_TTL_SECONDS = 10L;
+
     private static final String URL = "https://new.e-elitech.cn/api/data-api";
 
     private static final String TOKEN_URL = "/elitechAccess/getToken";
 
     private static final String REAL_TIME_URL = "/elitechAccess/v2/getRealTimeData";
+
+    private static final String REAL_HISTORY_URL = URL + "/elitechAccess/v2/getHistoryData";
 
     private static final String KET_ID = "75804708";
 
@@ -37,12 +44,13 @@
 
     private static final String PASS_WORD = "y17775163675";
 
+    private static final String REAL_TIME_CACHE_PREFIX = "JCLY:REAL_TIME:";
+
+    private static final String HISTORY_CACHE_PREFIX = "JCLY:HISTORY:";
+
     @Autowired
     private RedisTemplate<String, String> redisTemplate;
 
-    /**
-     * 鏍规嵁 paramCode 鎻愬彇鎺㈠ご鍙傛暟銆�
-     */
     private static JSONObject getProbeParam(JSONArray paramList, String targetCode) {
         if (paramList == null) {
             return new JSONObject();
@@ -56,9 +64,68 @@
         return new JSONObject();
     }
 
-    /**
-     * 瀹炴椂鑾峰彇娓╂箍搴︺�佸厜鐓с�佷簩姘у寲纰虫暟鎹��
-     */
+    public List<Map<String, String>> getHistoryData(String guid, long startTime, long endTime) {
+        List<Map<String, String>> resultList = new ArrayList<>();
+        String historyData = requestHistoryData(getToken(), guid, startTime, endTime);
+        Map<String, Object> resultMap = JSON.parseObject(historyData, Map.class);
+        if (!Integer.valueOf(0).equals(resultMap.get("code"))) {
+            return resultList;
+        }
+
+        JSONArray historyList = JSON.parseArray(String.valueOf(resultMap.get("data")));
+        if (historyList == null || historyList.isEmpty()) {
+            return resultList;
+        }
+
+        for (int i = 0; i < historyList.size(); i++) {
+            JSONObject historyObj = historyList.getJSONObject(i);
+            Map<String, String> historyItem = new HashMap<>();
+            historyItem.put("guid", firstNonBlank(
+                    historyObj.getString("deviceGuid"),
+                    historyObj.getString("guid"),
+                    guid
+            ));
+            historyItem.put("subUId", stringValue(historyObj.get("subUid")));
+            historyItem.put("monitorTimeStamp", stringValue(historyObj.get("monitorTimeStamp")));
+            historyItem.put("monitorTimeStr", historyObj.getString("monitorTimeStr"));
+            historyItem.put("position", historyObj.getString("position"));
+            historyItem.put("address", historyObj.getString("address"));
+
+            JSONArray paramList = historyObj.getJSONArray("data");
+            if (paramList != null && !paramList.isEmpty()) {
+                for (int j = 0; j < paramList.size(); j++) {
+                    JSONObject paramObj = paramList.getJSONObject(j);
+                    String paramName = paramObj.getString("paramName");
+                    String paramCode = paramObj.getString("paramCode");
+                    String value = paramObj.getString("value");
+                    String unitCode = paramObj.getString("unitCode");
+                    String fullValue = value == null ? null : value + (unitCode == null ? "" : unitCode);
+                    switch (paramName) {
+                        case "鎺㈠ご1":
+                            historyItem.put("light", fullValue);
+                            break;
+                        case "鎺㈠ご2":
+                            historyItem.put("temperature", fullValue);
+                            break;
+                        case "鎺㈠ご3":
+                            historyItem.put("humidity", fullValue);
+                            break;
+                        case "鎺㈠ご4":
+                            historyItem.put("co2", fullValue);
+                            break;
+                        default:
+                            if (paramCode != null) {
+                                historyItem.put(paramCode, fullValue);
+                            }
+                            break;
+                    }
+                }
+            }
+            resultList.add(historyItem);
+        }
+        return resultList;
+    }
+
     public List<Map<String, String>> getRealData(List<String> guidList) {
         log.info("寮�濮嬭幏鍙栧疄鏃舵暟鎹�");
         List<Map<String, String>> listMaps = new ArrayList<>();
@@ -78,6 +145,15 @@
             JSONObject deviceObj = deviceList.getJSONObject(deviceIndex);
             JSONArray paramList = deviceObj.getJSONArray("data");
             Map<String, String> deviceData = new HashMap<>();
+            String deviceGuid = firstNonBlank(
+                    deviceObj.getString("deviceGuid"),
+                    deviceObj.getString("guid"),
+                    deviceObj.getString("devGuid"),
+                    deviceObj.getString("sn")
+            );
+            if (deviceGuid != null) {
+                deviceData.put("guid", deviceGuid);
+            }
             for (String code : targetCodes) {
                 JSONObject paramObj = getProbeParam(paramList, code);
                 if (paramObj.isEmpty()) {
@@ -144,14 +220,61 @@
         return cleanedToken.isEmpty() ? null : cleanedToken;
     }
 
-    public static String getRealTimeData(String token, List<String> guidList) {
+    private String firstNonBlank(String... values) {
+        for (String value : values) {
+            if (value != null && !value.trim().isEmpty()) {
+                return value;
+            }
+        }
+        return null;
+    }
+
+    private String stringValue(Object value) {
+        return value == null ? null : String.valueOf(value);
+    }
+
+    public String getRealTimeData(String token, List<String> guidList) {
         Map<String, Object> param = new HashMap<>();
         param.put("keyId", KET_ID);
         param.put("keySecret", KEY_SECRET);
         param.put("deviceGuids", guidList);
         log.info("璇锋眰鍙傛暟锛歿}", JSON.toJSONString(param));
+        String cacheKey = REAL_TIME_CACHE_PREFIX + JSON.toJSONString(param);
+        String cachedResult = sanitizeToken(redisTemplate.opsForValue().get(cacheKey));
+        if (cachedResult != null) {
+            log.info("鍛戒腑瀹炴椂鏁版嵁缂撳瓨锛歿}", cacheKey);
+            return cachedResult;
+        }
         String result = HttpUtils.sendPostJson(URL + REAL_TIME_URL, JSON.toJSONString(param), token);
         log.info("杩斿洖缁撴灉锛歿}", result);
+        cacheRemoteResponse(cacheKey, result);
         return result;
     }
+
+    public String requestHistoryData(String token, String guid, long startTime, long endTime) {
+        Map<String, Object> param = new HashMap<>();
+        param.put("keyId", KET_ID);
+        param.put("keySecret", KEY_SECRET);
+        param.put("deviceGuid", guid);
+        param.put("startTime", startTime);
+        param.put("endTime", endTime);
+        log.info("鍘嗗彶鏁版嵁璇锋眰鍙傛暟锛歿}", JSON.toJSONString(param));
+        String cacheKey = HISTORY_CACHE_PREFIX + JSON.toJSONString(param);
+        String cachedResult = sanitizeToken(redisTemplate.opsForValue().get(cacheKey));
+        if (cachedResult != null) {
+            log.info("鍛戒腑鍘嗗彶鏁版嵁缂撳瓨锛歿}", cacheKey);
+            return cachedResult;
+        }
+        String result = HttpUtils.sendPostJson(REAL_HISTORY_URL, JSON.toJSONString(param), token);
+        log.info("鍘嗗彶鏁版嵁杩斿洖缁撴灉锛歿}", result);
+        cacheRemoteResponse(cacheKey, result);
+        return result;
+    }
+
+    private void cacheRemoteResponse(String cacheKey, String result) {
+        if (result == null || result.trim().isEmpty()) {
+            return;
+        }
+        redisTemplate.opsForValue().set(cacheKey, result, REMOTE_CACHE_TTL_SECONDS, TimeUnit.SECONDS);
+    }
 }
diff --git a/src/main/java/com/ruoyi/other/controller/PdaVersionController.java b/src/main/java/com/ruoyi/other/controller/PdaVersionController.java
new file mode 100644
index 0000000..831da33
--- /dev/null
+++ b/src/main/java/com/ruoyi/other/controller/PdaVersionController.java
@@ -0,0 +1,31 @@
+package com.ruoyi.other.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.other.pojo.PdaVersion;
+import com.ruoyi.other.service.PdaVersionService;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+@RestController
+@RequestMapping("/app")
+@AllArgsConstructor
+public class PdaVersionController {
+
+    private PdaVersionService pdaVersionService;
+
+    @ApiOperation("鏌ヨ鎵�鏈夌増鏈�")
+    @GetMapping("/getAllVersion")
+    public R getAllVersion(Page<PdaVersion> page, PdaVersion pdaVersion) {
+        return R.ok(pdaVersionService.getAllVersion(page, pdaVersion));
+    }
+
+    @ApiOperation("涓婁紶apk")
+    @PostMapping("/uploadApk")
+    public R uploadApk(@RequestParam("file") MultipartFile file, String name, String version) {
+        return R.ok(pdaVersionService.uploadApk(file, name, version));
+    }
+
+}
diff --git a/src/main/java/com/ruoyi/other/controller/TempFileController.java b/src/main/java/com/ruoyi/other/controller/TempFileController.java
index 1175eb0..1b69751 100644
--- a/src/main/java/com/ruoyi/other/controller/TempFileController.java
+++ b/src/main/java/com/ruoyi/other/controller/TempFileController.java
@@ -4,8 +4,6 @@
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.other.service.TempFileService;
 import com.ruoyi.purchase.dto.ProductRecordDto;
-import com.ruoyi.purchase.dto.TicketRegistrationDto;
-import com.ruoyi.purchase.service.ITicketRegistrationService;
 import com.ruoyi.purchase.service.impl.TicketRegistrationServiceImpl;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.PostMapping;
diff --git a/src/main/java/com/ruoyi/other/mapper/PdaVersionMapper.java b/src/main/java/com/ruoyi/other/mapper/PdaVersionMapper.java
new file mode 100644
index 0000000..d688651
--- /dev/null
+++ b/src/main/java/com/ruoyi/other/mapper/PdaVersionMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.other.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.other.pojo.PdaVersion;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface PdaVersionMapper extends BaseMapper<PdaVersion> {
+}
diff --git a/src/main/java/com/ruoyi/other/pojo/PdaVersion.java b/src/main/java/com/ruoyi/other/pojo/PdaVersion.java
new file mode 100644
index 0000000..d772071
--- /dev/null
+++ b/src/main/java/com/ruoyi/other/pojo/PdaVersion.java
@@ -0,0 +1,60 @@
+package com.ruoyi.other.pojo;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.sales.pojo.CommonFile;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@TableName("pda_version")
+@ApiModel(value = "PdaVersion", description = "PDA鐗堟湰淇℃伅琛�")
+public class PdaVersion implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("涓婚敭ID")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty("鍚嶇О")
+    private String name;
+
+    @ApiModelProperty("鐗堟湰鍙�")
+    private String version;
+
+    @ApiModelProperty("鍒涘缓鏃堕棿")
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty("鏇存柊鏃堕棿")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty("鍒涘缓浜�")
+    @TableField(fill = FieldFill.INSERT)
+    private Integer createUser;
+
+    @ApiModelProperty("鏇存柊浜�")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Integer updateUser;
+
+    @ApiModelProperty("绉熸埛ID")
+    @TableField(fill = FieldFill.INSERT)
+    private Long tenantId;
+
+    @TableField(exist = false)
+    private List<CommonFile> commonFileList;
+
+    @TableField(fill = FieldFill.INSERT)
+    private Long deptId;
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/other/pojo/TempFile.java b/src/main/java/com/ruoyi/other/pojo/TempFile.java
index bff7805..ab129e1 100644
--- a/src/main/java/com/ruoyi/other/pojo/TempFile.java
+++ b/src/main/java/com/ruoyi/other/pojo/TempFile.java
@@ -1,14 +1,18 @@
 package com.ruoyi.other.pojo;
 
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.time.LocalDateTime;
 
 @Data
 @TableName("temp_file")
-public class TempFile {
+public class TempFile implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @TableId
@@ -17,4 +21,12 @@
     private String tempPath;       // 涓存椂瀛樺偍璺緞
     private LocalDateTime expireTime; // 杩囨湡鏃堕棿
     private Integer type;       // 鍏宠仈琛ㄧ被鍨�
+    private Long fileSize;       // 鏂囦欢澶у皬
+    @ApiModelProperty(value = "鍒涘缓鐢ㄦ埛")
+    @TableField(fill = FieldFill.INSERT)
+    private Integer createUser;
+
+    @TableField(fill = FieldFill.INSERT)
+    private Long deptId;
+
 }
diff --git a/src/main/java/com/ruoyi/other/service/PdaVersionService.java b/src/main/java/com/ruoyi/other/service/PdaVersionService.java
new file mode 100644
index 0000000..39bc196
--- /dev/null
+++ b/src/main/java/com/ruoyi/other/service/PdaVersionService.java
@@ -0,0 +1,13 @@
+package com.ruoyi.other.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.other.pojo.PdaVersion;
+import org.springframework.web.multipart.MultipartFile;
+
+public interface PdaVersionService extends IService<PdaVersion> {
+    IPage<PdaVersion> getAllVersion(Page<PdaVersion> page, PdaVersion pdaVersion);
+
+    boolean uploadApk(MultipartFile file, String name, String version);
+}
diff --git a/src/main/java/com/ruoyi/other/service/impl/PdaVersionServiceImpl.java b/src/main/java/com/ruoyi/other/service/impl/PdaVersionServiceImpl.java
new file mode 100644
index 0000000..65b37e6
--- /dev/null
+++ b/src/main/java/com/ruoyi/other/service/impl/PdaVersionServiceImpl.java
@@ -0,0 +1,60 @@
+package com.ruoyi.other.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.enums.FileNameType;
+import com.ruoyi.other.mapper.PdaVersionMapper;
+import com.ruoyi.other.pojo.PdaVersion;
+import com.ruoyi.other.service.PdaVersionService;
+import com.ruoyi.other.service.TempFileService;
+import com.ruoyi.sales.service.impl.CommonFileServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+import org.springframework.web.multipart.MultipartFile;
+
+@Service
+@RequiredArgsConstructor
+@Transactional(rollbackFor = Exception.class)
+public class PdaVersionServiceImpl extends ServiceImpl<PdaVersionMapper, PdaVersion> implements PdaVersionService {
+
+    private final PdaVersionMapper pdaVersionMapper;
+
+    private final TempFileService tempFileService;
+
+    private final CommonFileServiceImpl commonFileService;
+
+    @Override
+    public IPage<PdaVersion> getAllVersion(Page<PdaVersion> page, PdaVersion pdaVersion) {
+        LambdaQueryWrapper<PdaVersion> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.orderByDesc(PdaVersion::getCreateTime);
+        Page<PdaVersion> pdaVersionPage = pdaVersionMapper.selectPage(page, queryWrapper);
+        pdaVersionPage.getRecords().forEach(item ->{
+            item.setCommonFileList(commonFileService.getFileListByBusinessId(item.getId(), FileNameType.APP.getValue()));
+        });
+        return pdaVersionPage;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean uploadApk(MultipartFile file, String name, String version) {
+        // 鍙傛暟鏍¢獙
+        Assert.notNull(file, "鏂囦欢涓嶈兘涓虹┖");
+        Assert.hasText(version, "鐗堟湰鍙蜂笉鑳戒负绌�");
+
+        try {
+            PdaVersion pdaVersion = new PdaVersion();
+            pdaVersion.setName(name);
+            pdaVersion.setVersion(version);
+            pdaVersionMapper.insert(pdaVersion);
+
+            tempFileService.uploadByCommon(file, FileNameType.APP.getValue(), pdaVersion.getId());
+            return true;
+        } catch (Exception e) {
+            throw new RuntimeException("涓婁紶APK澶辫触: " + e.getMessage());
+        }
+    }
+}
diff --git a/src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java b/src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java
index b8e0e2a..6d870af 100644
--- a/src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java
+++ b/src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java
@@ -9,16 +9,13 @@
 import com.ruoyi.sales.mapper.CommonFileMapper;
 import com.ruoyi.sales.pojo.CommonFile;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.catalina.util.URLEncoder;
 import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -76,6 +73,7 @@
         tempFileRecord.setTempPath(tempFilePath.toString());
         tempFileRecord.setExpireTime(LocalDateTime.now().plusHours(2)); // 2灏忔椂鍚庤繃鏈�
         tempFileRecord.setType(type);
+        tempFileRecord.setFileSize(file.getSize());
         tempFileMapper.insert(tempFileRecord);
         return tempFileRecord;
     }
@@ -151,6 +149,7 @@
                 fileRecord.setUrl(formalFilePath.toString());
                 fileRecord.setCreateTime(LocalDateTime.now());
                 fileRecord.setType(fileType);
+                fileRecord.setFileSize(tempFile.getFileSize());
                 commonFileMapper.insert(fileRecord);
 
                 // 鍒犻櫎涓存椂鏂囦欢璁板綍
diff --git a/src/main/java/com/ruoyi/sales/pojo/CommonFile.java b/src/main/java/com/ruoyi/sales/pojo/CommonFile.java
index 239fd0d..8f41021 100644
--- a/src/main/java/com/ruoyi/sales/pojo/CommonFile.java
+++ b/src/main/java/com/ruoyi/sales/pojo/CommonFile.java
@@ -30,6 +30,8 @@
     /** 鍏宠仈琛� */
     private Integer type;
 
+    private Long fileSize;       // 鏂囦欢澶у皬
+
     /** 鍒涘缓鏃堕棿 */
     @TableField(fill = FieldFill.INSERT)
     private LocalDateTime createTime;

--
Gitblit v1.9.3