From e899d2709f21b322232fb64778fef296233be3f0 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 25 八月 2025 14:39:41 +0800
Subject: [PATCH] 修改了代码

---
 archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java |   72 ++++++++++++++++++++++++++++++++++--
 1 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
index 4036f57..94c8977 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
@@ -11,13 +11,17 @@
 import com.ruoyi.common.utils.MapUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.domain.ArchiveRecords;
 import com.ruoyi.domain.Archiverecordstouser;
+import com.ruoyi.domain.vo.AnalysisResult;
+import com.ruoyi.domain.vo.ArchiveInfoVo;
 import com.ruoyi.mapper.ArchiveRecordsMapper;
 import com.ruoyi.mapper.ArchiverecordstouserMapper;
 import com.ruoyi.service.IArchiveRecordsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 妗f璁板綍Service涓氬姟灞傚鐞�
@@ -166,6 +170,10 @@
 
         Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
         archiveRecords.setCreateTime(date);
+
+
+        archiveRecords.setRecordStatus("鏈綍鍏�");
+      //  archiveRecords
         boolean res = this.save(archiveRecords);
         if(res)
             return 1;
@@ -198,11 +206,13 @@
     @Override
     public int deleteArchiveRecordsByIds(Long[] ids)
     {
-        if (this.removeByIds(Arrays.asList(ids))) {
-            return 1;
+        Long res = 0L;
+        for(Long id: ids)
+        {
+           this.baseMapper.updateAllInfoById(id);
+
         }
-        else
-            return 0;
+        return 1;
     }
 
     /**
@@ -216,4 +226,58 @@
     {
         return 0;
     }
+
+    @Override
+    public ArchiveInfoVo selectByRecordId(Long id) {
+        return this.baseMapper.findByRecordId(id);
+    }
+
+    @Override
+    public AjaxResult importExcel(MultipartFile file) {
+        ExcelUtil<ArchiveRecords> util = new ExcelUtil<>(ArchiveRecords.class);
+        List<ArchiveRecords> dataList = null;
+        try {
+            dataList = util.importExcel(file.getInputStream());
+        } catch (Exception e) {
+            throw new RuntimeException("娌℃湁鎸夌収瑙勫垯瀵煎叆鏁版嵁");
+        }
+
+        assert dataList != null;
+
+        for (ArchiveRecords archiveRecords : dataList) {
+           // physcialService.mySave(physcial);
+            this.mySave(archiveRecords);
+        }
+
+        return AjaxResult.success();
+    }
+
+    @Override
+    public List<AnalysisResult> statisticAya() {
+        return this.baseMapper.statisticAyasis();
+    }
+
+
+    public AjaxResult mySave(ArchiveRecords archiveRecords) {
+
+
+        //妫�鏌ユ槸鍚︽湁閲嶅鏁版嵁鎻掑叆
+        LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId,archiveRecords.getRecordId());
+        List<ArchiveRecords> list = list(lqw);
+        if (list.size() > 0) {
+          //  throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
+            //濡傛灉鏈夐噸澶嶆暟鎹紝鍒欐牴鎹畆ecordId杩涜鏁版嵁淇敼
+            this.baseMapper.update(archiveRecords, lqw);
+            return AjaxResult.success();
+        }
+        else {
+            if (save(archiveRecords)) {
+                return AjaxResult.success();
+            } else {
+                return AjaxResult.error();
+            }
+        }
+
+    }
 }

--
Gitblit v1.9.1