修改bug

This commit is contained in:
yangjun 2024-07-14 10:54:20 +08:00
parent f36b70b8b9
commit 747746a781
4 changed files with 60 additions and 47 deletions

View File

@ -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();

View File

@ -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<ZyInfoStudentMapper, ZyInfoStudent> implements IZyInfoStudentService {
@ -188,7 +190,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
System.out.println("1111111111111111----------->");
log.info("1111111111111111----------->");
}
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
@ -207,7 +209,8 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
fileMap.put("file", fileName);
String contentType = "";//image/png
String ret = formUpload(url, textMap, fileMap,contentType);
System.out.println("aigc1-------->"+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<ZyInfoStudentMapper, Z
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());
@ -227,9 +230,9 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
//提交后直接开始检测
String message = aigcKsjc(zyCcjg);
System.out.println("21-------->"+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<ZyInfoStudentMapper, Z
String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
System.out.println("1111111111111111----------->");
log.info("1111111111111111----------->");
}
Map<String, String> textMap = new HashMap<String, String>();
String titlePar =fileName.substring(fileName.lastIndexOf("/")+1,fileName.length());
@ -289,6 +292,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
fileMap.put("file", fileName);
String contentType = "";//image/png
String ret = formUpload(url, textMap, fileMap,contentType);
log.error("nwccSave:ret-------->"+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<ZyInfoStudentMapper, Z
//提交后直接开始检测
String message = xfwbdKsjc(zyCcjg,"1");
System.out.println("21-------->"+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<ZyInfoStudentMapper, Z
Map<String, String> fileMap = new HashMap<String, String>();
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<ZyInfoStudentMapper, Z
zyCcjgMapper.insert(zyCcjg);
//提交后直接开始检测
String message = xfwbdKsjc(zyCcjg,"0");
System.out.println("21-------->"+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<ZyInfoStudentMapper, Z
String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
System.out.println("1111111111111111----------->");
}
// String fileName = getFileName(zyInfoStudent.getFilePath(),response);
Map<String, String> textMap = new HashMap<String, String>();
@ -426,16 +430,16 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
Map<String, String> fileMap = new HashMap<String, String>();
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<ZyInfoStudentMapper, Z
zyCcjgMapper.insert(zyCcjg);
//提交后直接开始检测
String message = wwKsjc(zyCcjg);
System.out.println("21-------->"+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<ZyInfoStudentMapper, Z
String fileName = "";
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = imgPath;
System.out.println("1111111111111111----------->");
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<String,String> 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<ZyInfoStudentMapper, Z
// response.setStatus(404);
//// throw new RuntimeException("文件["+imgPath+"]不存在..");
// }
// System.out.println("localFilePath----------->"+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<ZyInfoStudentMapper, Z
// }
// response.flushBuffer();
fileName = localFilePath;
System.out.println("fileName----------->"+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<ZyInfoStudentMapper, Z
}
}
}else{
System.out.println("333333333333333----------->");
log.info("333333333333333----------->");
}
return fileName;
}
@ -673,7 +677,7 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
reader.close();
reader = null;
} catch (Exception e) {
System.out.println("发送POST请求出错。" + urlStr);
log.info("发送POST请求出错。" + urlStr);
e.printStackTrace();
} finally {
if (conn != null) {

View File

@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -245,17 +246,7 @@ public class ZykServiceImpl extends ServiceImpl<ZykMapper, ZykInfo> 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<String,String> uploadMap = uploadFileToSftp("contract/"+namePath);
if(!uploadMap.get("code").equals("0")){
return uploadMap;
}
zykInfo.setPdfName(uploadMap.get("data"));
Map<String,String> map = fileHandleUtil.moveFiles(zykInfo);
if(!map.get("code").equals("0")){
@ -267,12 +258,30 @@ public class ZykServiceImpl extends ServiceImpl<ZykMapper, ZykInfo> 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<String,String> 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());

View File

@ -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();
}