From 672ce84d5ce6545a0e81709ea736c69cbbef8c1a Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期四, 24 四月 2025 18:12:47 +0800 Subject: [PATCH] zjh20250424 --- ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java | 103 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 98 insertions(+), 5 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 a881d73..9f1dbfd 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,21 @@ 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 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.service.ISysAttachmentService; +import com.ltkj.system.service.ISysDictDataService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -41,6 +49,9 @@ @Autowired private ServerConfig serverConfig; + @Value("${path.xdtfilePath}") + private String value; + private static final String FILE_DELIMETER = ","; @Value("${photoPath}") @@ -51,6 +62,10 @@ @Value("${ltkj.profile}") String path; + @Autowired + private ISysAttachmentService sysAttachmentService; + @Autowired + private ISysDictDataService sysDictDataService; /** @@ -80,8 +95,8 @@ } /** - * 閲嶆柊鍐欑殑涓婁紶鍥剧墖 閫傜敤浜庝綋妫�濂楅 - */ + * 閲嶆柊鍐欑殑涓婁紶鍥剧墖 閫傜敤浜庝綋妫�濂楅 + */ @PostMapping("/packageUpload") public AjaxResult packageUpload(@RequestBody MultipartFile file) { String fileName = file.getOriginalFilename(); @@ -107,7 +122,7 @@ ajax.put("originalFilename", file.getOriginalFilename()); return ajax; } - + /** * 閫氱敤涓婁紶璇锋眰锛堝崟涓級 */ @@ -132,6 +147,55 @@ } } + @PostMapping("/uploadImgExe") + @ApiOperation(value = "EXE绋嬪簭寰幆璇诲彇鍥剧墖涓婁紶") + public AjaxResult uploadImgExe(@RequestPart("file") MultipartFile file,@RequestParam("val")String dictVal,@RequestParam("ip")String ip){ + try { + // 涓婁紶鏂囦欢璺緞 + String filePath = ltkjConfig.getUploadPath(); + // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О + 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.setId(SnowFlake.getInstance().nextId()); + sysAttachment.setFileName(newFileName); + sysAttachment.setFilePath(fileName); + 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()); + } + } + + @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") @@ -213,4 +277,33 @@ } 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 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