From 2bab6bdfaa240bab8bf3197a4d43a27d352f16b6 Mon Sep 17 00:00:00 2001 From: CZT <czt18638530771@163.com> Date: 星期六, 15 七月 2023 00:07:38 +0800 Subject: [PATCH] 优化出入库补单文件上传-增加删除及名称命名 --- igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java b/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java index 4d1c07e..4c7df5e 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java @@ -1,6 +1,7 @@ package com.ld.igds.inout.view; import java.io.File; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -259,12 +260,18 @@ */ @FileResolver public String uploadImage(UploadFile file, Map<String, Object> parameter) { + //杞︾墝 String plateNum = (String) parameter.get("plateNum"); + //娴佺▼ + String bizTag = (String) parameter.get("bizTag"); String newFileName = null; try { String basePath = fileService.getInoutFilePath(new Date()); // 鑾峰彇鏂扮殑ID newFileName = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"); + if(StringUtils.isNotEmpty(bizTag)){ + newFileName = bizTag + "_" + newFileName; + } // 鏂囦欢鍚庣紑鍚� String suffixName = file.getFileName().substring(file.getFileName().lastIndexOf(".")); // 鍚堟垚鏂扮殑鏂囦欢鍚� @@ -278,4 +285,28 @@ return newFileName; } + /** + * inoutDataPR#delImage + * + * @param parameter + * @return + */ + @Expose + public String delImage(Map<String, Object> parameter) throws Exception { + + String fileName = (String) parameter.get("fileName"); + Date createTime = (Date) parameter.get("createTime"); + if (null == createTime) createTime = new Date(); + fileName = URLDecoder.decode(fileName, "UTF-8"); + + File file = new File(fileService.getInoutFilePath(createTime), fileName); + + if (!file.exists()) { + return "鍒犻櫎澶辫触锛岀郴缁熸湭鎵惧埌褰撳墠闄勪欢"; + } + + file.delete(); + return null; + } + } -- Gitblit v1.9.3