From 747746a781118ea174197de01f727e3ee5307c57 Mon Sep 17 00:00:00 2001 From: yangjun <1173114630@qq.com> Date: Sun, 14 Jul 2024 10:54:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/filter/StrAttackFilter.java | 4 +- .../impl/ZyInfoStudentServiceImpl.java | 62 ++++++++++--------- .../zyk/service/impl/ZykServiceImpl.java | 39 +++++++----- .../system/controller/CommonController.java | 2 +- 4 files changed, 60 insertions(+), 47 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/StrAttackFilter.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/StrAttackFilter.java index 8dc2e174..b535374d 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/StrAttackFilter.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/StrAttackFilter.java @@ -12,7 +12,7 @@ public class StrAttackFilter { public static String filter(String str) throws PatternSyntaxException { // 清除掉所有特殊字符 - String regEx = "[`_《》~!@#$%^&*()+=|{}':;',\\[\\].<>?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; + String regEx = "[`《》~!@#$%^&*()+=|{}':;',\\[\\].<>?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.replaceAll("").trim(); @@ -20,7 +20,7 @@ public class StrAttackFilter { public static String filter2(String str) throws PatternSyntaxException { // 清除掉所有特殊字符 - String regEx = "[`_《》~!@#$%^&*()+=|{}':;',\\[\\]<>?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; + String regEx = "[`《》~!@#$%^&*()+=|{}':;',\\[\\]<>?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.replaceAll("").trim(); diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java index fd2e7d89..af708e24 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.constant.CommonConstant; @@ -44,6 +45,7 @@ import java.util.*; * @Date: 2024-05-06 * @Version: V1.0 */ +@Slf4j @Service public class ZyInfoStudentServiceImpl extends ServiceImpl implements IZyInfoStudentService { @@ -188,7 +190,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"); + log.info("1111111111111111----------->"); } Map textMap = new HashMap(); //可以设置多个input的name,value @@ -207,7 +209,8 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+ret); + log.info("aigc1-------->"+ret); + log.error("aigcSave:ret-------->"+ret); JSONObject object= JSONObject.parseObject(ret); if("true".equals(object.getString("success"))){ @@ -216,7 +219,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+paperid); + log.info("2-------->"+paperid); ZyCcjg zyCcjg = new ZyCcjg(); zyCcjg.setZyStuId(zyInfoStudent.getId()); @@ -227,9 +230,9 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+message); + log.info("21-------->"+message); }else{ - System.out.println("3-------->"); + log.info("3-------->"); ZyCcjg zyCcjg = new ZyCcjg(); zyCcjg.setZyStuId(zyInfoStudent.getId()); @@ -269,7 +272,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"); + log.info("1111111111111111----------->"); } Map textMap = new HashMap(); String titlePar =fileName.substring(fileName.lastIndexOf("/")+1,fileName.length()); @@ -289,6 +292,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+ret); JSONObject object= JSONObject.parseObject(ret); if("true".equals(object.getString("success"))){ String listpaper = object.getString("datainfo"); @@ -305,9 +309,9 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+message); + log.info("21-------->"+message); }else{ - System.out.println("3-------->"); + log.info("3-------->"); ZyCcjg zyCcjg = new ZyCcjg(); zyCcjg.setZyStuId(zyInfoStudent.getId()); zyCcjg.setMessage(object.getString("message")); @@ -345,10 +349,11 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl fileMap = new HashMap(); fileMap.put("file", fileName); String contentType = "";//image/png - System.out.println("url--->"+url); - System.out.println("textMap--->"+textMap); - System.out.println("fileMap--->"+fileMap); + log.info("url--->"+url); + log.info("textMap--->"+textMap); + log.info("fileMap--->"+fileMap); String ret = formUpload(url, textMap, fileMap,contentType); + log.error("xnccSave:ret-------->"+ret); JSONObject object= JSONObject.parseObject(ret); if("true".equals(object.getString("success"))){ String listpaper = object.getString("datainfo"); @@ -366,11 +371,11 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+message); + log.info("21-------->"+message); } }else{ - System.out.println("3-------->"); + log.info("3-------->"); ZyCcjg zyCcjg = new ZyCcjg(); zyCcjg.setZyStuId(zyInfoStudent.getId()); zyCcjg.setMessage(object.getString("message")); @@ -409,7 +414,6 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"); } // String fileName = getFileName(zyInfoStudent.getFilePath(),response); Map textMap = new HashMap(); @@ -426,16 +430,16 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl fileMap = new HashMap(); fileMap.put("file", fileName); String contentType = "";//image/png - System.out.println("fileMap-------->"+fileMap); + log.error("fileMap-------->"+fileMap); String ret = formUpload(url, textMap, fileMap,contentType); - System.out.println("1-------->"+ret); + log.error("1-------->"+ret); JSONObject object= JSONObject.parseObject(ret); if("true".equals(object.getString("success"))){ String listpaper = object.getString("listpaper"); JSONArray jsonArray = (JSONArray) JSONArray.parse(listpaper); JSONObject object2= jsonArray.getJSONObject(0); String paperid = object2.getString("paperid"); - System.out.println("2-------->"+paperid); + log.info("2-------->"+paperid); ZyCcjg zyCcjg = new ZyCcjg(); zyCcjg.setZyStuId(zyInfoStudent.getId()); zyCcjg.setPaperid(paperid); @@ -444,10 +448,10 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+message); + log.info("21-------->"+message); return message; }else{ - System.out.println("3-------->"); + log.info("3-------->"); ZyCcjg zyCcjg = new ZyCcjg(); zyCcjg.setZyStuId(zyInfoStudent.getId()); zyCcjg.setMessage(object.getString("message")); @@ -481,22 +485,22 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"); + log.info("1111111111111111----------->"); }else if(CommonConstant.UPLOAD_TYPE_SFTP.equals(uploadType)){ - System.out.println("22222222222222----------->"); + log.info("22222222222222----------->"); InputStream inputStream = null; OutputStream outputStream = null; try{ - System.out.println("getFileName----------->"); + log.info("getFileName----------->"); int index = imgPath.lastIndexOf("/"); String path = "temp"; if(index != -1){ path = imgPath.substring(0,index); } - System.out.println("path----------->"+path); + log.info("path----------->"+path); Map map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath(path)); - System.out.println("map----------->"+map); + log.info("map----------->"+map); // if(!map.get("code").equals("0")){ // response.setStatus(404); //// throw new RuntimeException(map.get("msg")); @@ -507,7 +511,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+localFilePath); +// log.info("localFilePath----------->"+localFilePath); // // 设置强制下载不打开 // response.setContentType("application/force-download"); // response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); @@ -520,9 +524,9 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"+fileName); + log.info("fileName----------->"+fileName); }catch (Exception e){ - System.out.println("catch----------->"+e); + log.info("catch----------->"+e); // e.printStackTrace(); }finally { SFTPUtil.disChannel(); @@ -543,7 +547,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl"); + log.info("333333333333333----------->"); } return fileName; } @@ -673,7 +677,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl implements I if(!downloadMap.get("code").equals("0")){ return downloadMap; } - Global global = SpringContextHolder.getBean(Global.class); - String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss"); - String namePath = dd + ".pdf"; - String pdfPath = global.getContractDickPath() + namePath; - PDFUtil.office2PDF(downloadMap.get("data"),pdfPath); - Map uploadMap = uploadFileToSftp("contract/"+namePath); - if(!uploadMap.get("code").equals("0")){ - return uploadMap; - } - zykInfo.setPdfName(uploadMap.get("data")); Map map = fileHandleUtil.moveFiles(zykInfo); if(!map.get("code").equals("0")){ @@ -267,12 +258,30 @@ public class ZykServiceImpl extends ServiceImpl implements I }else{ map.put("data",""); } - if(StringUtils.isNotNull(map.get("pdfData"))){ - String pdfName = map.get("pdfData"); - zykInfo.setPdfName(pdfName); - }else{ - map.put("pdfData",""); + + + + String fileType = zykInfo.getFileName().substring(zykInfo.getFileName().lastIndexOf(".") + 1); + if(StringUtils.equals(fileType,"doc")||StringUtils.equals(fileType,"docx")){ + Global global = SpringContextHolder.getBean(Global.class); + String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss"); + String namePath = dd + ".pdf"; + String pdfPath = global.getContractDickPath() + namePath; + + PDFUtil.office2PDF(downloadMap.get("data"),pdfPath); + Map uploadMap = uploadFileToSftp("contract/"+namePath); + if(!uploadMap.get("code").equals("0")){ + return uploadMap; + } + zykInfo.setPdfName(uploadMap.get("data")); + if(StringUtils.isNotNull(map.get("pdfData"))){ + String pdfName = map.get("pdfData"); + zykInfo.setPdfName(pdfName); + }else{ + map.put("pdfData",""); + } } + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); zykInfo.setCreateBy(user.getUsername()); zykInfo.setCreateTime(new Date()); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java index 61b1f4b4..ec7f24ea 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java @@ -361,7 +361,7 @@ public class CommonController { if (orgName != null) { orgName = CommonUtils.getFileName(orgName); if(orgName.contains(SymbolConstant.SPOT)){ - fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf(".")); + fileName = orgName.substring(0, orgName.lastIndexOf(".")) + orgName.substring(orgName.lastIndexOf(".")); }else{ fileName = orgName+ "_" + System.currentTimeMillis(); }