From 37e2d3c73caac445d1d8e229747b439e3719c13b Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期二, 03 六月 2025 17:04:13 +0800
Subject: [PATCH] zjh20250603

---
 ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java |  160 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 153 insertions(+), 7 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java b/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java
index 5e4996b..89a05ba 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java
@@ -2,13 +2,24 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ltkj.common.core.domain.R;
+import com.ltkj.common.core.domain.entity.SysDictData;
+import com.ltkj.common.utils.SnowFlake;
 import com.ltkj.common.utils.uuid.UUID;
+import com.ltkj.hosp.domain.SysAttachment;
+import com.ltkj.hosp.mapper.TestMapper;
+import com.ltkj.hosp.service.ISysAttachmentService;
+import com.ltkj.system.service.ISysConfigService;
+import com.ltkj.system.service.ISysDictDataService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -41,6 +52,9 @@
     @Autowired
     private ServerConfig serverConfig;
 
+//    @Value("${path.xdtfilePath}")
+//    private String value;
+
     private static final String FILE_DELIMETER = ",";
 
     @Value("${photoPath}")
@@ -51,7 +65,14 @@
 
     @Value("${ltkj.profile}")
     String path;
-
+    @Autowired
+    private ISysAttachmentService sysAttachmentService;
+    @Autowired
+    private ISysDictDataService sysDictDataService;
+    @Autowired
+    private ISysConfigService configService;
+    @Autowired
+    private TestMapper testMapper;
 
     /**
      * 閫氱敤涓嬭浇璇锋眰
@@ -80,9 +101,8 @@
     }
 
     /**
-    *   閲嶆柊鍐欑殑涓婁紶鍥剧墖   閫傜敤浜庝綋妫�濂楅
-    */
-    // TODO: 2023/2/13 濂楅鍥剧墖涓婁紶  閮ㄧ讲鏈嶅姟鍣ㄤ慨鏀硅矾寰� 
+     *   閲嶆柊鍐欑殑涓婁紶鍥剧墖   閫傜敤浜庝綋妫�濂楅
+     */
     @PostMapping("/packageUpload")
     public AjaxResult packageUpload(@RequestBody MultipartFile file) {
         String fileName = file.getOriginalFilename();
@@ -108,7 +128,7 @@
         ajax.put("originalFilename", file.getOriginalFilename());
         return ajax;
     }
-    
+
     /**
      * 閫氱敤涓婁紶璇锋眰锛堝崟涓級
      */
@@ -133,6 +153,85 @@
         }
     }
 
+    /**
+     * exe涓婁紶鍥剧墖鎺ュ彛
+     * @param file
+     * @param dictVal
+     * @param ip
+     * @return
+     */
+    @PostMapping("/uploadImgExe")
+    @ApiOperation(value = "EXE绋嬪簭寰幆璇诲彇鍥剧墖涓婁紶")
+    public AjaxResult uploadImgExe(@RequestPart("file") MultipartFile file,@RequestParam("val")String dictVal,@RequestParam("ip")String ip){
+        if (StrUtil.isBlank(dictVal))
+            return AjaxResult.error("绫诲瀷涓嶈兘涓虹┖");
+        try {
+            String exeimgsaveurl = configService.selectConfigByKey("exeimgsaveurl");
+            String filePath;
+            if (StrUtil.isNotBlank(exeimgsaveurl)){
+                filePath = exeimgsaveurl;
+            }else {
+                filePath = ltkjConfig.getUploadPath();
+            }
+            // 涓婁紶鏂囦欢璺緞
+
+            filePath+="/"+dictVal;
+            // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+            String fileName = FileUploadUtils.upload(filePath, file);
+            String url = serverConfig.getUrl() + fileName;
+            AjaxResult ajax = AjaxResult.success();
+            ajax.put("url", url);
+            //ajax.put("filePath", path+fileName);
+            ajax.put("fileName", fileName);
+            final String newFileName = FileUtils.getName(fileName);
+            ajax.put("newFileName", newFileName);
+            ajax.put("originalFilename", file.getOriginalFilename());
+            SysAttachment sysAttachment = new SysAttachment();
+            sysAttachment.setOldFileName(file.getOriginalFilename());
+            sysAttachment.setId(SnowFlake.getInstance().nextId());
+            sysAttachment.setFileName(newFileName);
+            sysAttachment.setFilePath(ltkjConfig.getUploadPath()+fileName.replace("/profileupload",""));
+            sysAttachment.setUrl(url);
+            sysAttachment.setSysDictVal(dictVal);
+            sysAttachment.setIp(ip);
+            final Map<String, String> map = FileUploadUtils.getFileSize(file);
+            sysAttachment.setFileSize(map.get("fileSizeBytes"));
+            sysAttachment.setFileSizeMb(map.get("fileSizeMB"));
+            sysAttachment.setFileSizeGb(map.get("fileSizeGB"));
+            sysAttachmentService.insertSysAttachment(sysAttachment);
+            return ajax;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error(e.getMessage());
+        }
+    }
+
+    /**
+     * 鑾峰彇exe绋嬪簭涓婁紶鍥剧墖鍒楄〃
+     * @param type
+     * @return
+     */
+    @GetMapping("/getExeUploadImgList")
+    public AjaxResult getExeUploadImgList(@RequestParam("type") String type){
+        if (StrUtil.isBlank(type)) return AjaxResult.error("绫诲瀷涓嶈兘涓虹┖");
+        List<Map<String, Object>> list = testMapper.getExeUploadImgListByGnLx(type);
+        return AjaxResult.success().put("data",list);
+    }
+
+    @GetMapping("/listExeVal")
+    public AjaxResult listExeDictVal(){
+        LambdaQueryWrapper<SysDictData> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SysDictData::getDictType,"sys_exe_img_type");
+        final List<SysDictData> list = sysDictDataService.list(queryWrapper);
+        ArrayList<HashMap<String, String>> hashMaps = new ArrayList<>();
+        for (SysDictData sysDictData : list) {
+            HashMap<String, String> hashMap = new HashMap<>();
+            hashMap.put("label",sysDictData.getDictLabel());
+            hashMap.put("value",sysDictData.getDictValue());
+            hashMaps.add(hashMap);
+        }
+        return AjaxResult.success().put("data",hashMaps);
+    }
 
     @GetMapping("/uploadFile")
     @ApiOperation(value = "閫氱敤鏂囦欢涓婁紶base64")
@@ -197,4 +296,51 @@
             log.error("涓嬭浇鏂囦欢澶辫触", e);
         }
     }
+
+
+    @DeleteMapping("/deletedFile")
+    @ApiOperation(value = "閫氱敤鏂囦欢鍒犻櫎鎺ュ彛")
+    public AjaxResult deletedFile(@RequestParam String url) {
+        //鏂囦欢鍚庣紑
+        File files=new File(url);
+        String name = files.getName();
+        File file=new File(photoPath+name);
+        if (file.exists()) {
+            if(file.delete()){
+                return AjaxResult.success("鍒犻櫎鎴愬姛");
+            }
+            return AjaxResult.error("鍒犻櫎澶辫触");
+        }
+        return AjaxResult.success("鍒犻櫎鎴愬姛");
+    }
+
+
+
+    /**
+     * 蹇冪數鍥炬姤鍛婁笂浼犲浘鐗囨柟娉�
+     */
+    @PostMapping("/uploadXdtFile")
+    @ApiOperation(value = "蹇冪數鍥炬姤鍛婁笂浼犲浘鐗囨柟娉�")
+    public AjaxResult uploadXdtFile(@ApiParam("鏂囦欢") @RequestPart("file") MultipartFile file,
+                                    @ApiParam("浣撴鍙�") String tjh,@ApiParam("椤圭洰id") String proId) throws Exception {
+        try {
+            // 涓婁紶鏂囦欢璺緞
+            String value = configService.selectConfigByKey("path_xdtfilePath");
+            String filePath = value + File.separator;
+            String outputFileName = tjh +"_" +proId;
+            // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+            String fileName = FileUploadUtils.upload(filePath,outputFileName, file);
+            String url = filePath + fileName;
+            Path path = Paths.get(url);
+            byte[] data = Files.readAllBytes(path);
+            String base64 = Base64.getEncoder().encodeToString(data);
+            AjaxResult ajax = AjaxResult.success();
+            ajax.put("url", url);
+            ajax.put("fileName", fileName);
+            ajax.put("base64", base64);
+            return ajax;
+        } catch (Exception e) {
+            return AjaxResult.error(e.getMessage());
+        }
+    }
 }

--
Gitblit v1.8.0