From cf9a5039e6db9d1d5963e3fe1a37d00169ec2ef7 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 25 六月 2025 11:18:22 +0800
Subject: [PATCH] 验收报告修改

---
 src/main/java/com/whyc/service/SoftcodeService.java |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/whyc/service/SoftcodeService.java b/src/main/java/com/whyc/service/SoftcodeService.java
index 1bd3f8c..e79fbc1 100644
--- a/src/main/java/com/whyc/service/SoftcodeService.java
+++ b/src/main/java/com/whyc/service/SoftcodeService.java
@@ -35,9 +35,9 @@
 
 
     //婧愮爜涓婁紶
-    public Response uploadCode(MultipartFile file, String softIds) throws IOException {
-        String[] softList=softIds.split(",");
-        String fileName = file.getOriginalFilename();
+    public Response uploadCode(MultipartFile file, String fileNames) throws IOException {
+        String[] nameList=fileNames.split(",");
+        String codeName = file.getOriginalFilename();
         Date date = new Date();
         String dateUnion = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(date);
         //瀛樺偍璺緞
@@ -48,16 +48,18 @@
         if(!softwareDirFile.exists()){
             softwareDirFile.mkdirs();
         }
-        String codeUrl=softcodeDir+File.separator+fileName;
+        String codeUrl=softcodeDir+File.separator+codeName;
         file.transferTo(new File(codeUrl));
-        if(softList.length>0){
-            for(String softId:softList){
+        if(nameList.length>0){
+            for(String name:nameList){
                 Softcode softcode=new Softcode();
-                softcode.setSoftId(softId);
-                softcode.setCodeUrl(softcodeHttpUrl+File.separator+fileName);
+                softcode.setFileName(name);
+                softcode.setCreateTime(new Date());
+                softcode.setCodeUrl(softcodeHttpUrl+File.separator+codeName);
+                softcode.setCodeName(codeName.substring(0,codeName.lastIndexOf(".")));
                 //鍒ゆ柇鏄惁瀛樺湪婧愮爜锛屽瓨鍦ㄤ慨鏀癸紝涓嶅瓨鍦ㄦ坊鍔�
-                if(mapper.selectOne(new QueryWrapper<Softcode>().eq("soft_id",softId))!=null){
-                    mapper.update(softcode,new UpdateWrapper<Softcode>().eq("soft_id",softId));
+                if(mapper.selectOne(new QueryWrapper<Softcode>().eq("file_name",name))!=null){
+                    mapper.update(softcode,new UpdateWrapper<Softcode>().eq("file_name",name));
                 }else{
                     mapper.insert(softcode);
                 }
@@ -68,18 +70,18 @@
 
 
     //鏍规嵁杞欢id瀹炵幇婧愮爜涓嬭浇
-    public void downLoadCode(HttpServletRequest req, HttpServletResponse resp, String softId) {
+    public void downLoadCode(HttpServletRequest req, HttpServletResponse resp, String fileName) {
         String fileDirName = FileDirPath.getFileDirName();
         QueryWrapper wrapper=new QueryWrapper();
-        wrapper.eq("soft_id",softId);
+        wrapper.eq("file_name",fileName);
         wrapper.last("limit 1");
         Softcode softcode=mapper.selectOne(wrapper);
 
-        String filename=softcode.getCodeUrl().substring(softcode.getCodeUrl().lastIndexOf("\\")+1);
+        String name=softcode.getCodeUrl().substring(softcode.getCodeUrl().lastIndexOf("\\")+1);
         try {
             // 杞爜闃叉涔辩爜
             //resp.addHeader("Content-Disposition", "attachment;filename=" + new String(softwareName.getBytes("UTF-8"), "ISO8859-1"));
-            resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode (filename, "utf-8"));
+            resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode (name, "utf-8"));
             OutputStream out = resp.getOutputStream();
             FileInputStream in = new FileInputStream(fileDirName+ File.separator+softcode.getCodeUrl());
             int len=0;
@@ -97,6 +99,6 @@
         }
         //璁板綍鏃ュ織
         logService.recordOperationLogDownLoad(ActionUtil.getUser().getId(),ActionUtil.getUser().getName(), UserOperation.TYPE_DOWNLOAD_SOFWARE.getType(),new Date(),req.getRemoteAddr()
-                ,filename,fileDirName+File.separator+softcode.getCodeUrl(),"",String.valueOf(softId),"");
+                ,name,fileDirName+File.separator+softcode.getCodeUrl(),"",name,"");
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1