修改bug

This commit is contained in:
yangjun 2024-08-27 11:09:30 +08:00
parent c38b280ded
commit fed517eede
6 changed files with 146 additions and 57 deletions

View File

@ -484,31 +484,44 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
if(StringUtils.equals("pdf",nameLast)){
zyInfoStudent.setPdfPath(zyInfoStudent.getFilePath());
}else{
if(StringUtils.equals("local",uploadType)){
Global global = SpringContextHolder.getBean(Global.class);
FileUtil.mkdir(global.getContractDickPath());
String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
String docPath = upLoadPath+ File.separator+ zyInfoStudent.getFilePath();
String namePath = dd + ".pdf";
String pdfPath = global.getContractDickPath() + namePath;
System.out.println("filPath:"+zyInfoStudent.getFilePath());
System.out.println("docPath:"+docPath);
System.out.println("pdfPath:"+pdfPath);
PDFUtil.office2PDF(docPath,pdfPath);
zyInfoStudent.setPdfPath("contract/"+namePath);
}else{
ZykInfo zykInfo = new ZykInfo();
zykInfo.setBizId(zyInfoStudent.getId());
zykInfo.setBizTable("zy_jxdg");
zykInfo.setWjlx(WjlxEnum.JXDG.getType());
zykInfo.setRwbh(zyInfo.getRwbh());
zykInfo.setFileName(zyInfoStudent.getFilePath());
Map<String,String> map = zykService.saveToZykJxdg(zykInfo);
String fileName = map.get("data");
String pdfName = map.get("pdfData");
zyInfoStudent.setFilePath(fileName);
zyInfoStudent.setPdfPath(pdfName);
}
//目前作业都需要上传到文件服务器
ZykInfo zykInfo = new ZykInfo();
zykInfo.setBizId(zyInfoStudent.getId());
zykInfo.setBizTable("zy_jxdg");
zykInfo.setWjlx(WjlxEnum.JXDG.getType());
zykInfo.setRwbh(zyInfo.getRwbh());
zykInfo.setFileName(zyInfoStudent.getFilePath());
Map<String,String> map = zykService.saveToStufile(zykInfo);
String fileName = map.get("data");
String pdfName = map.get("pdfData");
zyInfoStudent.setFilePath(fileName);
zyInfoStudent.setPdfPath(pdfName);
// if(StringUtils.equals("local",uploadType)){
// Global global = SpringContextHolder.getBean(Global.class);
// FileUtil.mkdir(global.getContractDickPath());
// String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
// String docPath = upLoadPath+ File.separator+ zyInfoStudent.getFilePath();
// String namePath = dd + ".pdf";
// String pdfPath = global.getContractDickPath() + namePath;
// System.out.println("filPath:"+zyInfoStudent.getFilePath());
// System.out.println("docPath:"+docPath);
// System.out.println("pdfPath:"+pdfPath);
// PDFUtil.office2PDF(docPath,pdfPath);
// zyInfoStudent.setPdfPath("contract/"+namePath);
// }else{
// ZykInfo zykInfo = new ZykInfo();
// zykInfo.setBizId(zyInfoStudent.getId());
// zykInfo.setBizTable("zy_jxdg");
// zykInfo.setWjlx(WjlxEnum.JXDG.getType());
// zykInfo.setRwbh(zyInfo.getRwbh());
// zykInfo.setFileName(zyInfoStudent.getFilePath());
// Map<String,String> map = zykService.saveToZykJxdg(zykInfo);
// String fileName = map.get("data");
// String pdfName = map.get("pdfData");
// zyInfoStudent.setFilePath(fileName);
// zyInfoStudent.setPdfPath(pdfName);
// }
}
zyInfoStudent.setPublishTime(new Date());
boolean bol = zyInfoStudentService.updateById(zyInfoStudent, response);

View File

@ -230,13 +230,11 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
private void aigcSave(ZyInfoStudent zyInfoStudent,HttpServletResponse response) {
String url = "https://vims.fanyu.com/tool/AIGCCheck/paperSubmit";
//文件路径文件存在不存在的话需要先下载下来
// String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
// String fileName = getFileName(zyInfoStudent.getFilePath(),response);
String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
log.info("1111111111111111----------->");
}
// String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
// fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
// }
String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
@ -312,13 +310,11 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
private void nwccSave(ZyInfoStudent zyInfoStudent,HttpServletResponse response) {
String url = "https://vims.fanyu.com/toole/smallcheck/submitData";
//文件路径文件存在不存在的话需要先下载下来
// String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
// String fileName = getFileName(zyInfoStudent.getFilePath(),response);
String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
log.info("1111111111111111----------->");
}
// String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
// fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
// }
String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
Map<String, String> textMap = new HashMap<String, String>();
String titlePar =fileName.substring(fileName.lastIndexOf("/")+1,fileName.length());
String title = titlePar.split("_")[0];
@ -370,13 +366,11 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
private void xnccSave(ZyInfoStudent zyInfoStudent,String type,HttpServletResponse response) {
String url = "https://vims.fanyu.com/toole/smallcheck/submitData";
//文件路径文件存在不存在的话需要先下载下来
// String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
// String filePath = zyInfoStudent.getFilePath();
// String fileName = getFileName(filePath,response);
String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
}
// String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
// fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
// }
String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
Map<String, String> textMap = new HashMap<String, String>();
String titlePar =fileName.substring(fileName.lastIndexOf("/")+1,fileName.length());
String title = titlePar.split("_")[0];
@ -456,11 +450,11 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String url = "https://vims.fanyu.com/toole/jianceorgan/papersubmit.aspx";
//文件路径文件存在不存在的话需要先下载下来
String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
}
// String fileName = getFileName(zyInfoStudent.getFilePath(),response);
// String fileName = downloadpath+"/"+ zyInfoStudent.getFilePath();
// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
// fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
// }
String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();

View File

@ -59,4 +59,6 @@ public interface IZykService extends IService<ZykInfo> {
void disConnect();
void saveLocal(ZykInfo zykInfo);
Map<String, String> saveToStufile(ZykInfo zykInfo);
}

View File

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.SFTPUtil;
import org.jeecg.common.util.SftpConfig;
import org.jeecg.common.util.SpringContextHolder;
import org.jeecg.common.util.text.StringUtils;
import org.jeecg.modules.kc.ktgl.entity.KcKechengbiao;
@ -18,14 +20,16 @@ import org.jeecg.modules.zyk.service.IZykService;
import org.jeecg.modules.zyk.utils.FileHandleUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
/**
* @Description: 资源库信息
@ -45,6 +49,15 @@ public class ZykServiceImpl extends ServiceImpl<ZykMapper, ZykInfo> implements I
@Autowired
private ZykMapper zykMapper;
@Autowired
SftpConfig sftpConfig;
private static String uploadpath;
@Value("${jeecg.path.upload}")
public void setUploadPath(String uploadPath) {
this.uploadpath = uploadPath;
}
@Override
@ -355,4 +368,71 @@ public class ZykServiceImpl extends ServiceImpl<ZykMapper, ZykInfo> implements I
zykInfo.setId(id.toString());
zykMapper.addInfo(zykInfo);
}
@Override
public Map<String, String> saveToStufile(ZykInfo zykInfo) {
String bizPath = "";
MultipartFile file = null;
try {
file = this.convert(uploadpath+"/"+zykInfo.getFileName());
} catch (IOException e) {
throw new RuntimeException(e);
}
this.uploadSftp(file,bizPath);
// Map<String,String> downloadMap = downloadRemoteFile(zykInfo.getFileName());
// if(!downloadMap.get("code").equals("0")){
// return downloadMap;
// }
Map<String,String> map = new HashMap<>();
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(zykInfo.getFileName(),pdfPath);
Map<String,String> uploadMap = uploadFileToSftp("contract/"+namePath);
if(!uploadMap.get("code").equals("0")){
return uploadMap;
}
zykInfo.setPdfName(uploadMap.get("data"));
if(StringUtils.isNotNull(uploadMap.get("data"))){
String pdfName = uploadMap.get("data");
zykInfo.setPdfName(pdfName);
map.put("pdfData",uploadMap.get("data"));
}else{
map.put("pdfData","");
}
}
return map;
}
public static MultipartFile convert(String path) throws IOException {
File file = new File(path);
FileInputStream input = new FileInputStream(file);
MultipartFile multipartFile = new MockMultipartFile("file",file.getName(), "text/plain", input);
return multipartFile;
}
private String uploadSftp(MultipartFile mf, String bizPath){
try {
Map<String,String> uploadMap = SFTPUtil.upload(sftpConfig,mf,bizPath);
SFTPUtil.disChannel();
SFTPUtil.disSession();
if(uploadMap.get("code").equals("0")){
return uploadMap.get("data");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}finally {
SFTPUtil.disChannel();
SFTPUtil.disSession();
}
return "";
}
}

View File

@ -348,4 +348,4 @@ sftp:
password: sftp
timeout: 1000
uploadpath: kczx
fullpath: /home/sftp
fullpath: /data

View File

@ -354,4 +354,4 @@ sftp:
password: Nenujwc@99
timeout: 1000
uploadpath: kczx
fullpath: /home/sftp
fullpath: /data