Merge branch 'master' of http://47.115.223.229:8888/yangjun/dbsd_kczx_java
This commit is contained in:
commit
bd01bab979
|
@ -19,7 +19,7 @@ import java.util.Properties;
|
|||
public class SFTPUtil {
|
||||
private static long count = 3;
|
||||
private static long count1 = 0;
|
||||
private static long sleepTime = 1800000;//30分钟
|
||||
private static long sleepTime = 1000;//1秒
|
||||
private static final Logger logger = LoggerFactory.getLogger(SFTPUtil.class);
|
||||
private static Session sshSession = null;
|
||||
private static ChannelSftp sftp = null;
|
||||
|
@ -228,7 +228,7 @@ public class SFTPUtil {
|
|||
public static Map<String,String> download(SftpConfig sftpConfig, String directory, String downloadFile, String saveFile) {
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put("code","0");
|
||||
map.put("msg","删除成功");
|
||||
map.put("msg","下载成功");
|
||||
try{
|
||||
if(sftp == null){
|
||||
getChannelSftp(sftpConfig);
|
||||
|
@ -270,6 +270,72 @@ public class SFTPUtil {
|
|||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* @param directory 下载目录
|
||||
* @param saveFile 存在本地的路径
|
||||
*/
|
||||
public static Map<String,String> download(SftpConfig sftpConfig, String directory, String saveFile) {
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put("code","0");
|
||||
map.put("msg","下载成功");
|
||||
String[] df = getDirectoryAndFileName(directory);
|
||||
|
||||
File localDirFile = new File(saveFile);
|
||||
// 判断本地目录是否存在,不存在需要新建各级目录
|
||||
if (!localDirFile.exists()) {
|
||||
localDirFile.mkdirs();
|
||||
}
|
||||
|
||||
String newName = CommonUtils.getFileName(df[1]);
|
||||
String newDownloadFile = saveFile.concat(File.separator).concat(newName);
|
||||
|
||||
File localFile = new File(newDownloadFile);
|
||||
// 判断本地目录是否存在,不存在需要新建各级目录
|
||||
if (localFile.exists()) {
|
||||
map.put("fileName",newDownloadFile);
|
||||
return map;
|
||||
}
|
||||
|
||||
try{
|
||||
if(sftp == null){
|
||||
getChannelSftp(sftpConfig);
|
||||
if(sftp == null){
|
||||
map.put("code","1");
|
||||
map.put("msg","sftp链接异常:");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
OutputStream output = null;
|
||||
try {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("开始获取远程文件:[{}]---->[{}]", new Object[]{directory, saveFile});
|
||||
}
|
||||
// sftp.cd(directory);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("打开远程文件:[{}]", new Object[]{directory});
|
||||
}
|
||||
output = new FileOutputStream(localFile);
|
||||
sftp.get(directory, output);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("文件下载成功");
|
||||
}
|
||||
map.put("fileName",newDownloadFile);
|
||||
} catch (Exception e) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("文件下载出现异常,[{}]", e);
|
||||
}
|
||||
throw new RuntimeException("文件下载出现异常,[{}]", e);
|
||||
} finally {
|
||||
closeStream(null,output);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
map.put("code","1");
|
||||
map.put("msg","sftp异常:" + e.getMessage());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 网页下载文件
|
||||
* @param response
|
||||
|
@ -301,7 +367,7 @@ public class SFTPUtil {
|
|||
// e1.printStackTrace();
|
||||
// throw new Exception(StringUtils.format("sftp exception,sftp exception。 ", e1.getMessage()));
|
||||
} finally {
|
||||
closeStream(inputStream,outputStream);
|
||||
closeStream(null,outputStream);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -371,7 +437,7 @@ public class SFTPUtil {
|
|||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (Exception ee) {
|
||||
}
|
||||
}
|
||||
|
@ -467,6 +533,7 @@ public class SFTPUtil {
|
|||
String path = sb.toString();
|
||||
path = path.substring(0,path.length()-1);
|
||||
map.put("data",path);
|
||||
logger.info("移动文件成功....");
|
||||
} catch (Exception e1) {
|
||||
map.put("code","1");
|
||||
map.put("msg",e1.getMessage());
|
||||
|
|
|
@ -119,6 +119,12 @@
|
|||
from wjx_wjxx a
|
||||
inner join wjx_djxx b on a.vid = b.vid
|
||||
where a.id = #{params.id}
|
||||
<if test="params.userId!=null and params.userId != ''">
|
||||
and b.user_id like concat('%',#{params.userId},'%')
|
||||
</if>
|
||||
<if test="params.userName!=null and params.userName != ''">
|
||||
and b.user_name like concat('%',#{params.userName},'%')
|
||||
</if>
|
||||
order by b.user_id
|
||||
</select>
|
||||
|
||||
|
@ -132,6 +138,12 @@
|
|||
) y
|
||||
on y.KCAPZBBH = x.rwbh
|
||||
WHERE x.id = #{params.id}
|
||||
<if test="params.userId!=null and params.userId != ''">
|
||||
and y.xh like concat('%',#{params.userId},'%')
|
||||
</if>
|
||||
<if test="params.userName!=null and params.userName != ''">
|
||||
and y.xm like concat('%',#{params.userName},'%')
|
||||
</if>
|
||||
and y.xh not in(
|
||||
select user_id from wjx_djxx c where c.vid = x.vid
|
||||
)
|
||||
|
@ -149,6 +161,12 @@
|
|||
on y.KCAPZBBH = a.rwbh
|
||||
left join wjx_djxx b on a.vid = b.vid and y.xh = b.user_id
|
||||
where a.id = #{params.id}
|
||||
<if test="params.userId!=null and params.userId != ''">
|
||||
and y.xh like concat('%',#{params.userId},'%')
|
||||
</if>
|
||||
<if test="params.userName!=null and params.userName != ''">
|
||||
and y.xm like concat('%',#{params.userName},'%')
|
||||
</if>
|
||||
order by b.total_score desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -3,7 +3,7 @@
|
|||
<mapper namespace="org.jeecg.modules.kc.wjxWjxxTmlb.mapper.WjxWjxxTmlbMapper">
|
||||
|
||||
<select id="distinctList" resultType="org.jeecg.modules.kc.wjxWjxxTmlb.entity.WjxWjxxTmlb">
|
||||
select distinct max(id) id,wj_title,wj_score,wj_sytype,wj_type from wjx_wjxx_tmlb
|
||||
select distinct max(id) id,wj_title,wj_score,wj_sytype,wj_type,wj_answer from wjx_wjxx_tmlb
|
||||
${ew.customSqlSegment}
|
||||
|
||||
</select>
|
||||
|
|
|
@ -84,6 +84,11 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
|
|||
|
||||
@Value("${jeecg.path.upload}")
|
||||
private String upLoadPath;
|
||||
|
||||
|
||||
@Value(value="${jeecg.uploadType}")
|
||||
private String uploadType;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
|
@ -107,6 +112,24 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
|
|||
QueryWrapper<ZyInfoStudent> queryWrapper = QueryGenerator.initQueryWrapper("a",zyInfoStudent, req.getParameterMap());
|
||||
Page<ZyInfoStudent> page = new Page<ZyInfoStudent>(pageNo, pageSize);
|
||||
IPage<ZyInfoStudent> pageList = zyInfoStudentService.page(page, queryWrapper);
|
||||
for(ZyInfoStudent ZyInfoStudentPar:pageList.getRecords()){
|
||||
List<ZyInfoStudent> list = zyInfoStudentService.getCcjg(ZyInfoStudentPar);
|
||||
for(ZyInfoStudent par:list){
|
||||
if(StringUtils.equals(par.getCcType(),"0")){//外网
|
||||
ZyInfoStudentPar.setWwpaperdownurl(par.getPaperdownurl());
|
||||
ZyInfoStudentPar.setWwpaperviewurl(par.getPaperviewurl());
|
||||
}else if(StringUtils.equals(par.getCcType(),"1")){//作业
|
||||
ZyInfoStudentPar.setZypaperdownurl(par.getPaperdownurl());
|
||||
ZyInfoStudentPar.setZypaperviewurl(par.getPaperviewurl());
|
||||
}else if(StringUtils.equals(par.getCcType(),"2")){//aigc
|
||||
ZyInfoStudentPar.setAigcpaperdownurl(par.getPaperdownurl());
|
||||
ZyInfoStudentPar.setAigcpaperviewurl(par.getPaperviewurl());
|
||||
}else if(StringUtils.equals(par.getCcType(),"3")){//学校
|
||||
ZyInfoStudentPar.setXxpaperdownurl(par.getPaperdownurl());
|
||||
ZyInfoStudentPar.setXxpaperviewurl(par.getPaperviewurl());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
|
@ -230,7 +253,6 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
|
|||
* @param request
|
||||
* @param zyInfoStudent
|
||||
*/
|
||||
@RequiresPermissions("zyInfoStudent:zy_info_student:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, ZyInfoStudent zyInfoStudent) {
|
||||
return super.exportXls(request, zyInfoStudent, ZyInfoStudent.class, "学生提交作业");
|
||||
|
@ -262,37 +284,34 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
|
|||
if(StringUtils.equals("pdf",nameLast)){
|
||||
zyInfoStudent.setPdfPath(zyInfoStudent.getFilePath());
|
||||
}else{
|
||||
// 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);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
zyInfoStudentService.updateById(zyInfoStudent);
|
||||
|
||||
|
||||
|
||||
|
||||
//作业代办提醒
|
||||
ZyDbtx zyDbtx = new ZyDbtx();
|
||||
zyDbtx.setCreateBy(zyInfo.getCreateBy());
|
||||
|
|
|
@ -34,14 +34,6 @@ public class ZyInfoStudent implements Serializable {
|
|||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**createBy*/
|
||||
@ApiModelProperty(value = "createBy")
|
||||
private java.lang.String createBy;
|
||||
/**createTime*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "createTime")
|
||||
private java.util.Date createTime;
|
||||
/**updateBy*/
|
||||
@ApiModelProperty(value = "updateBy")
|
||||
private java.lang.String updateBy;
|
||||
|
@ -50,44 +42,57 @@ public class ZyInfoStudent implements Serializable {
|
|||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "updateTime")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
|
||||
@Excel(name = "学生姓名", width = 15)
|
||||
@ApiModelProperty(value = "studentName")
|
||||
private java.lang.String studentName;
|
||||
@Excel(name = "学生学号", width = 15)
|
||||
@ApiModelProperty(value = "createBy")
|
||||
private java.lang.String createBy;
|
||||
@Excel(name = "提交时间", width = 15,format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "createTime")
|
||||
private java.util.Date createTime;
|
||||
@Excel(name = "评分", width = 15)
|
||||
private java.lang.String score;
|
||||
/**外网相似律*/
|
||||
@Excel(name = "外网相似律", width = 15)
|
||||
@ApiModelProperty(value = "外网相似律")
|
||||
private java.lang.String wwxsl;
|
||||
/**内网相似律*/
|
||||
@Excel(name = "内网相似律", width = 15)
|
||||
@ApiModelProperty(value = "内网相似律")
|
||||
private java.lang.String nwxsl;
|
||||
/**aigc相似律*/
|
||||
@Excel(name = "aigc相似律", width = 15)
|
||||
@ApiModelProperty(value = "aigc相似律")
|
||||
private java.lang.String aigcxsl;
|
||||
@Excel(name = "存档类型", width = 15)
|
||||
@Dict(dicCode = "cdlx")
|
||||
private String cdlx;//存档类型
|
||||
|
||||
|
||||
|
||||
/**作业名称*/
|
||||
@Excel(name = "作业名称", width = 15)
|
||||
@ApiModelProperty(value = "作业名称")
|
||||
private java.lang.String mainId;
|
||||
/**作业附件*/
|
||||
@Excel(name = "作业附件", width = 15)
|
||||
@ApiModelProperty(value = "作业附件")
|
||||
private java.lang.String filePath;
|
||||
/**外网相似律*/
|
||||
@Excel(name = "外网相似律", width = 15)
|
||||
@ApiModelProperty(value = "外网相似律")
|
||||
private java.lang.String wwxsl;
|
||||
/**内网相似律*/
|
||||
@Excel(name = "内网相似律", width = 15)
|
||||
@ApiModelProperty(value = "内网相似律")
|
||||
private java.lang.String nwxsl;
|
||||
/**aigc相似律*/
|
||||
@Excel(name = "aigc相似律", width = 15)
|
||||
@ApiModelProperty(value = "aigc相似律")
|
||||
private java.lang.String aigcxsl;
|
||||
/**外网是否通过*/
|
||||
@Excel(name = "外网是否通过", width = 15)
|
||||
@ApiModelProperty(value = "外网是否通过")
|
||||
private java.lang.String wwsftg;
|
||||
/**内网是否通过*/
|
||||
@Excel(name = "内网是否通过", width = 15)
|
||||
@ApiModelProperty(value = "内网是否通过")
|
||||
private java.lang.String nwsftg;
|
||||
/**aigc是否通过*/
|
||||
@Excel(name = "aigc是否通过", width = 15)
|
||||
@ApiModelProperty(value = "aigc是否通过")
|
||||
private java.lang.String aigcsftg;
|
||||
private java.lang.String studentName;
|
||||
private java.lang.String score;
|
||||
|
||||
private java.lang.String pdfPath;
|
||||
private String scoreFabu;
|
||||
@Dict(dicCode = "cdlx")
|
||||
private String cdlx;//存档类型
|
||||
|
||||
@TableField(exist = false)
|
||||
private String catename;
|
||||
|
@ -104,4 +109,29 @@ public class ZyInfoStudent implements Serializable {
|
|||
private String zyname;
|
||||
@TableField(exist = false)
|
||||
private String teacherNo;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private String ccType;
|
||||
@TableField(exist = false)
|
||||
private String paperviewurl;
|
||||
@TableField(exist = false)
|
||||
private String paperdownurl;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String wwpaperviewurl;//外网预览
|
||||
@TableField(exist = false)
|
||||
private String wwpaperdownurl;//外网下载
|
||||
@TableField(exist = false)
|
||||
private String zypaperviewurl;//作业预览
|
||||
@TableField(exist = false)
|
||||
private String zypaperdownurl;//作业下载
|
||||
@TableField(exist = false)
|
||||
private String xxpaperviewurl;//学校预览
|
||||
@TableField(exist = false)
|
||||
private String xxpaperdownurl;//学校下载
|
||||
@TableField(exist = false)
|
||||
private String aigcpaperviewurl;//aigc预览
|
||||
@TableField(exist = false)
|
||||
private String aigcpaperdownurl;//aigc外网下载
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 学生提交作业
|
||||
* @Author: jeecg-boot
|
||||
|
@ -19,4 +21,6 @@ public interface ZyInfoStudentMapper extends BaseMapper<ZyInfoStudent> {
|
|||
void deleteMainId(@Param("mainId") String id);
|
||||
|
||||
IPage<ZyInfoStudent> cdxxlist(Page<ZyInfoStudent> page,@Param(Constants.WRAPPER) QueryWrapper<ZyInfoStudent> queryWrapper);
|
||||
|
||||
List<ZyInfoStudent> getCcjg(ZyInfoStudent zyInfoStudent);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,28 @@
|
|||
left join zy_info b on a.main_id = b.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectList" resultType="org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent">
|
||||
select a.*,b.wwcc,b.nwcc,b.aigccc,b.title as zyname from zy_info_student a
|
||||
left join zy_info b on a.main_id = b.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="cdxxlist" resultType="org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent">
|
||||
select a.*,b.wwcc,b.nwcc,b.aigccc,b.title as zyname from zy_info_student a
|
||||
left join zy_info b on a.main_id = b.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getCcjg" resultType="org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent">
|
||||
select * from zy_ccjg a
|
||||
inner join
|
||||
(SELECT cc_type,max(checkdate) checkdate,zy_stu_id
|
||||
FROM zy_ccjg
|
||||
WHERE zy_stu_id = #{id} AND filestateid = '2'
|
||||
GROUP BY cc_type,zy_stu_id) t
|
||||
on a.cc_type = t.cc_type
|
||||
and a.checkdate = t.checkdate
|
||||
and a.zy_stu_id = t.zy_stu_id
|
||||
</select>
|
||||
</mapper>
|
|
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 学生提交作业
|
||||
* @Author: jeecg-boot
|
||||
|
@ -23,4 +25,6 @@ public interface IZyInfoStudentService extends IService<ZyInfoStudent> {
|
|||
void editFabu(ZyInfoStudent zyInfoStudent);
|
||||
|
||||
IPage<ZyInfoStudent> cdxxlist(Page<ZyInfoStudent> page, QueryWrapper<ZyInfoStudent> queryWrapper);
|
||||
|
||||
List<ZyInfoStudent> getCcjg(ZyInfoStudent zyInfoStudent);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,7 @@ import java.net.HttpURLConnection;
|
|||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 学生提交作业
|
||||
|
@ -131,6 +128,11 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
|
|||
return baseMapper.cdxxlist(page,queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ZyInfoStudent> getCcjg(ZyInfoStudent zyInfoStudent) {
|
||||
return baseMapper.getCcjg(zyInfoStudent);
|
||||
}
|
||||
|
||||
//aigc提交
|
||||
private void aigcSave(ZyInfoStudent zyInfoStudent) {
|
||||
String url = "https://vims.fanyu.com/tool/AIGCCheck/paperSubmit";
|
||||
|
|
|
@ -62,6 +62,10 @@ public class ZyJxdgController extends JeecgController<ZyJxdg, IZyJxdgService> {
|
|||
private String upLoadPath;
|
||||
@Autowired
|
||||
private IZykService zykService;
|
||||
|
||||
|
||||
@Value(value="${jeecg.uploadType}")
|
||||
private String uploadType;
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
|
@ -107,33 +111,39 @@ public class ZyJxdgController extends JeecgController<ZyJxdg, IZyJxdgService> {
|
|||
if(StringUtils.equals("pdf",nameLast)){
|
||||
zyJxdg.setPdfPath(zyJxdg.getFilePath());
|
||||
}else{
|
||||
Global global = SpringContextHolder.getBean(Global.class);
|
||||
FileUtil.mkdir(global.getContractDickPath());
|
||||
String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
||||
String docPath = upLoadPath+ File.separator+ zyJxdg.getFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
System.out.println("filPath:"+zyJxdg.getFilePath());
|
||||
System.out.println("docPath:"+docPath);
|
||||
System.out.println("pdfPath:"+pdfPath);
|
||||
PDFUtil.office2PDF(docPath,pdfPath);
|
||||
zyJxdg.setPdfPath("contract/"+namePath);
|
||||
}
|
||||
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+ zyJxdg.getFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
PDFUtil.office2PDF(docPath,pdfPath);
|
||||
zyJxdg.setPdfPath("contract/"+namePath);
|
||||
}else if(StringUtils.equals("sftp",uploadType)){
|
||||
|
||||
}
|
||||
}
|
||||
}else if(StringUtils.isNotEmpty(zyJxdg.getJxrlFilePath())){
|
||||
|
||||
String nameLast = zyJxdg.getJxrlFilePath().substring(zyJxdg.getJxrlFilePath().lastIndexOf(".")+1);
|
||||
if(StringUtils.equals("pdf",nameLast)){
|
||||
zyJxdg.setJxrlPdfPath(zyJxdg.getJxrlFilePath());
|
||||
}else{
|
||||
Global global = SpringContextHolder.getBean(Global.class);
|
||||
FileUtil.mkdir(global.getContractDickPath());
|
||||
String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
||||
String docPath = upLoadPath+ File.separator+ zyJxdg.getJxrlFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
PDFUtil.office2PDF(docPath,pdfPath);
|
||||
zyJxdg.setJxrlPdfPath("contract/"+namePath);
|
||||
|
||||
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+ zyJxdg.getJxrlFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
PDFUtil.office2PDF(docPath,pdfPath);
|
||||
zyJxdg.setJxrlPdfPath("contract/"+namePath);
|
||||
}else if(StringUtils.equals("sftp",uploadType)){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -170,18 +180,21 @@ public class ZyJxdgController extends JeecgController<ZyJxdg, IZyJxdgService> {
|
|||
update.set("file_path",zyJxdg.getFilePath());
|
||||
update.set("pdf_path",zyJxdg.getFilePath());
|
||||
}else{
|
||||
Global global = SpringContextHolder.getBean(Global.class);
|
||||
FileUtil.mkdir(global.getContractDickPath());
|
||||
String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
||||
String docPath = upLoadPath+ File.separator+ zyJxdg.getFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
System.out.println("filPath:"+zyJxdg.getFilePath());
|
||||
System.out.println("docPath:"+docPath);
|
||||
System.out.println("pdfPath:"+pdfPath);
|
||||
PDFUtil.office2PDF(docPath,pdfPath);
|
||||
zyJxdg.setPdfPath("contract/"+namePath);
|
||||
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 + zyJxdg.getFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
System.out.println("filPath:" + zyJxdg.getFilePath());
|
||||
System.out.println("docPath:" + docPath);
|
||||
System.out.println("pdfPath:" + pdfPath);
|
||||
PDFUtil.office2PDF(docPath, pdfPath);
|
||||
zyJxdg.setPdfPath("contract/" + namePath);
|
||||
}else if(StringUtils.equals("sftp",uploadType)){
|
||||
|
||||
}
|
||||
update.set("file_path",zyJxdg.getFilePath());
|
||||
update.set("pdf_path",zyJxdg.getPdfPath());
|
||||
}
|
||||
|
@ -193,15 +206,18 @@ public class ZyJxdgController extends JeecgController<ZyJxdg, IZyJxdgService> {
|
|||
update.set("jxrl_file_path",zyJxdg.getJxrlFilePath());
|
||||
update.set("jxrl_pdf_path",zyJxdg.getJxrlFilePath());
|
||||
}else{
|
||||
Global global = SpringContextHolder.getBean(Global.class);
|
||||
FileUtil.mkdir(global.getContractDickPath());
|
||||
String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
||||
String docPath = upLoadPath+ File.separator+ zyJxdg.getJxrlFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
PDFUtil.office2PDF(docPath,pdfPath);
|
||||
zyJxdg.setJxrlPdfPath("contract/"+namePath);
|
||||
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 + zyJxdg.getJxrlFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
PDFUtil.office2PDF(docPath, pdfPath);
|
||||
zyJxdg.setJxrlPdfPath("contract/" + namePath);
|
||||
}else {
|
||||
|
||||
}
|
||||
update.set("jxrl_file_path",zyJxdg.getJxrlFilePath());
|
||||
update.set("jxrl_pdf_path",zyJxdg.getJxrlPdfPath());
|
||||
}
|
||||
|
@ -323,51 +339,35 @@ public class ZyJxdgController extends JeecgController<ZyJxdg, IZyJxdgService> {
|
|||
if(StringUtils.equals("pdf",nameLast)){
|
||||
zyJxdg.setPdfPath(zyJxdg.getFilePath());
|
||||
}else{
|
||||
// Global global = SpringContextHolder.getBean(Global.class);
|
||||
// FileUtil.mkdir(global.getContractDickPath());
|
||||
// String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
||||
//// String docPath = upLoadPath+ File.separator+ zyJxdg.getFilePath();
|
||||
// String docPath = zyJxdg.getFilePath();
|
||||
// String namePath = dd + ".pdf";
|
||||
// String pdfPath = global.getContractDickPath() + namePath;
|
||||
// Map<String,String> map = zykService.downloadRemoteFile(docPath);
|
||||
// PDFUtil.office2PDF(map.get("data"),pdfPath);
|
||||
// zyJxdg.setPdfPath("contract/"+namePath);
|
||||
|
||||
ZykInfo zykInfo = new ZykInfo();
|
||||
zykInfo.setBizId(zyJxdg.getId());
|
||||
zykInfo.setBizTable("zy_jxdg");
|
||||
zykInfo.setWjlx(WjlxEnum.JXDG.getType());
|
||||
zykInfo.setRwbh(zyJxdg.getRwbh());
|
||||
zykInfo.setFileName(zyJxdg.getFilePath());
|
||||
Map<String,String> map = zykService.saveToZykJxdg(zykInfo);
|
||||
String fileName = map.get("data");
|
||||
String pdfName = map.get("pdfData");
|
||||
zyJxdg.setFilePath(fileName);
|
||||
zyJxdg.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 = zyJxdg.getFilePath();
|
||||
String docPath = upLoadPath + File.separator + zyJxdg.getFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
// Map<String, String> map = zykService.downloadRemoteFile(docPath);
|
||||
PDFUtil.office2PDF(docPath, pdfPath);
|
||||
zyJxdg.setPdfPath("contract/" + namePath);
|
||||
}else if(StringUtils.equals("sftp",uploadType)){
|
||||
ZykInfo zykInfo = new ZykInfo();
|
||||
zykInfo.setBizId(zyJxdg.getId());
|
||||
zykInfo.setBizTable("zy_jxdg");
|
||||
zykInfo.setWjlx(WjlxEnum.JXDG.getType());
|
||||
zykInfo.setRwbh(zyJxdg.getRwbh());
|
||||
zykInfo.setFileName(zyJxdg.getFilePath());
|
||||
Map<String,String> map = zykService.saveToZykJxdg(zykInfo);
|
||||
String fileName = map.get("data");
|
||||
String pdfName = map.get("pdfData");
|
||||
zyJxdg.setFilePath(fileName);
|
||||
zyJxdg.setPdfPath(pdfName);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
zyJxdg.setPdfPath(null);
|
||||
}
|
||||
//--------上传ftp工具---------------
|
||||
// Map<String,String> saveToZyk(ZykInfo zykInfo);
|
||||
// if(StringUtils.isNotEmpty(zyJxdg.getFilePath())){
|
||||
// ZykInfo zykInfo = new ZykInfo();
|
||||
// zykInfo.setBizId(zyJxdg.getId());
|
||||
// zykInfo.setBizTable("zy_jxdg");
|
||||
// zykInfo.setWjlx(WjlxEnum.JXDG.getType());
|
||||
// zykInfo.setRwbh(zyJxdg.getRwbh());
|
||||
// zykInfo.setFileName(zyJxdg.getFilePath());
|
||||
// zykInfo.setPdfName(zyJxdg.getPdfPath());
|
||||
// Map<String,String> map = zykService.saveToZyk(zykInfo);
|
||||
// String fileName = map.get("data");
|
||||
// String pdfName = map.get("pdfData");
|
||||
// zyJxdg.setFilePath(fileName);
|
||||
// zyJxdg.setPdfPath(pdfName);
|
||||
// }
|
||||
//--------上传ftp工具---------------
|
||||
|
||||
|
||||
if(isAdd){
|
||||
KcKechengbiao kcKechengbiao = new KcKechengbiao();
|
||||
kcKechengbiao.setRwbh(zyJxdg.getRwbh());
|
||||
|
@ -400,37 +400,33 @@ public class ZyJxdgController extends JeecgController<ZyJxdg, IZyJxdgService> {
|
|||
if(StringUtils.equals("pdf",nameLast)){
|
||||
zyJxdg.setJxrlPdfPath(zyJxdg.getJxrlFilePath());
|
||||
}else{
|
||||
// Global global = SpringContextHolder.getBean(Global.class);
|
||||
// FileUtil.mkdir(global.getContractDickPath());
|
||||
// String dd = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
||||
// String docPath = upLoadPath+ File.separator+ zyJxdg.getJxrlFilePath();
|
||||
// String namePath = dd + ".pdf";
|
||||
// String pdfPath = global.getContractDickPath() + namePath;
|
||||
// PDFUtil.office2PDF(docPath,pdfPath);
|
||||
// zyJxdg.setJxrlPdfPath("contract/"+namePath);
|
||||
|
||||
|
||||
|
||||
ZykInfo zykInfo = new ZykInfo();
|
||||
zykInfo.setBizId(zyJxdg.getId());
|
||||
zykInfo.setBizTable("zy_jxdg");
|
||||
zykInfo.setWjlx(WjlxEnum.JXRL.getType());
|
||||
zykInfo.setRwbh(zyJxdg.getRwbh());
|
||||
zykInfo.setFileName(zyJxdg.getJxrlFilePath());
|
||||
Map<String,String> map = zykService.saveToZykJxdg(zykInfo);
|
||||
String fileName = map.get("data");
|
||||
String pdfName = map.get("pdfData");
|
||||
zyJxdg.setJxrlFilePath(fileName);
|
||||
zyJxdg.setJxrlPdfPath(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 + zyJxdg.getJxrlFilePath();
|
||||
String namePath = dd + ".pdf";
|
||||
String pdfPath = global.getContractDickPath() + namePath;
|
||||
PDFUtil.office2PDF(docPath, pdfPath);
|
||||
zyJxdg.setJxrlPdfPath("contract/" + namePath);
|
||||
}else if(StringUtils.equals("sftp",uploadType)){
|
||||
ZykInfo zykInfo = new ZykInfo();
|
||||
zykInfo.setBizId(zyJxdg.getId());
|
||||
zykInfo.setBizTable("zy_jxdg");
|
||||
zykInfo.setWjlx(WjlxEnum.JXRL.getType());
|
||||
zykInfo.setRwbh(zyJxdg.getRwbh());
|
||||
zykInfo.setFileName(zyJxdg.getJxrlFilePath());
|
||||
Map<String,String> map = zykService.saveToZykJxdg(zykInfo);
|
||||
String fileName = map.get("data");
|
||||
String pdfName = map.get("pdfData");
|
||||
zyJxdg.setJxrlFilePath(fileName);
|
||||
zyJxdg.setJxrlPdfPath(pdfName);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
zyJxdg.setJxrlPdfPath(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(StringUtils.isEmpty(zyJxdg.getId())){
|
||||
zyJxdgService.save(zyJxdg);
|
||||
}else{
|
||||
|
|
|
@ -5,15 +5,28 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.util.AntPathMatcher;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.util.DySmsHelper;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.zyk.entity.ZykInfo;
|
||||
import org.jeecg.modules.zyk.service.IZykService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 资源库信息
|
||||
|
@ -27,6 +40,8 @@ import java.util.Arrays;
|
|||
@Slf4j
|
||||
public class ZykController extends JeecgController<ZykInfo, IZykService> {
|
||||
|
||||
private final static Logger logger= LoggerFactory.getLogger(ZykController.class);
|
||||
|
||||
@Autowired
|
||||
private IZykService zykService;
|
||||
|
||||
|
@ -89,71 +104,74 @@ public class ZykController extends JeecgController<ZykInfo, IZykService> {
|
|||
return Result.OK(res);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 预览图片&下载文件
|
||||
// * 请求地址:http://localhost:8080/common/static/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
|
||||
// * @param request
|
||||
// * @param response
|
||||
// */
|
||||
// @GetMapping(value = "/static/**")
|
||||
// public void view(HttpServletRequest request, HttpServletResponse response) {
|
||||
// // ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
// String filePath = extractPathFromPattern(request);
|
||||
// if(oConvertUtils.isEmpty(filePath) || CommonConstant.STRING_NULL.equals(filePath)){
|
||||
// return;
|
||||
// }
|
||||
// // 其余处理略
|
||||
// InputStream inputStream = null;
|
||||
// OutputStream outputStream = null;
|
||||
// try {
|
||||
// filePath = filePath.replace("..", "").replace("../","");
|
||||
// if (filePath.endsWith(SymbolConstant.COMMA)) {
|
||||
// filePath = filePath.substring(0, filePath.length() - 1);
|
||||
// }
|
||||
// Map<String,String> map = zykService.downloadRemoteFile(filePath);
|
||||
// if(!map.get("code").equals("0")){
|
||||
// throw new RuntimeException(map.get("msg"));
|
||||
// }
|
||||
// String localFilePath = map.get("data");
|
||||
// File file = new File(localFilePath);
|
||||
// if(!file.exists()){
|
||||
// response.setStatus(404);
|
||||
// throw new RuntimeException("文件["+filePath+"]不存在..");
|
||||
// }
|
||||
// // 设置强制下载不打开
|
||||
// response.setContentType("application/force-download");
|
||||
// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
// inputStream = new BufferedInputStream(new FileInputStream(localFilePath));
|
||||
// outputStream = response.getOutputStream();
|
||||
// byte[] buf = new byte[1024];
|
||||
// int len;
|
||||
// while ((len = inputStream.read(buf)) > 0) {
|
||||
// outputStream.write(buf, 0, len);
|
||||
// }
|
||||
// response.flushBuffer();
|
||||
// } catch (IOException e) {
|
||||
// log.error("预览文件失败" + e.getMessage());
|
||||
// response.setStatus(404);
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (inputStream != null) {
|
||||
// try {
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
// if (outputStream != null) {
|
||||
// try {
|
||||
// outputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* 预览图片&下载文件
|
||||
* 请求地址:http://localhost:8080/common/static/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping(value = "/static/**")
|
||||
public void view(HttpServletRequest request, HttpServletResponse response) {
|
||||
logger.info("zyk/zykInfo/static/SFTP下载 ..."+new Date());
|
||||
// ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
String filePath = extractPathFromPattern(request);
|
||||
if(oConvertUtils.isEmpty(filePath) || CommonConstant.STRING_NULL.equals(filePath)){
|
||||
return;
|
||||
}
|
||||
// 其余处理略
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
filePath = filePath.replace("..", "").replace("../","");
|
||||
if (filePath.endsWith(SymbolConstant.COMMA)) {
|
||||
filePath = filePath.substring(0, filePath.length() - 1);
|
||||
}
|
||||
Map<String,String> map = zykService.downloadRemoteFile(filePath);
|
||||
if(!map.get("code").equals("0")){
|
||||
throw new RuntimeException(map.get("msg"));
|
||||
}
|
||||
String localFilePath = map.get("data");
|
||||
File file = new File(localFilePath);
|
||||
if(!file.exists()){
|
||||
response.setStatus(404);
|
||||
throw new RuntimeException("文件["+filePath+"]不存在..");
|
||||
}
|
||||
// 设置强制下载不打开
|
||||
response.setContentType("application/force-download");
|
||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
inputStream = new BufferedInputStream(new FileInputStream(localFilePath));
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
log.error("预览文件失败" + e.getMessage());
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @GetMapping(value = "/static/**")
|
||||
// public void view(HttpServletRequest request, HttpServletResponse response) {
|
||||
// logger.info("SFTP下载 ..."+new Date());
|
||||
// // ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
// String filePath = extractPathFromPattern(request);
|
||||
// if(oConvertUtils.isEmpty(filePath) || CommonConstant.STRING_NULL.equals(filePath)){
|
||||
|
@ -171,16 +189,16 @@ public class ZykController extends JeecgController<ZykInfo, IZykService> {
|
|||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 把指定URL后的字符串全部截断当成参数
|
||||
// * 这么做是为了防止URL中包含中文或者特殊字符(/等)时,匹配不了的问题
|
||||
// * @param request
|
||||
// * @return
|
||||
// */
|
||||
// private static String extractPathFromPattern(final HttpServletRequest request) {
|
||||
// String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
||||
// String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
|
||||
// return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
|
||||
// }
|
||||
/**
|
||||
* 把指定URL后的字符串全部截断当成参数
|
||||
* 这么做是为了防止URL中包含中文或者特殊字符(/等)时,匹配不了的问题
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private static String extractPathFromPattern(final HttpServletRequest request) {
|
||||
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
||||
String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
|
||||
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ZykServiceImpl extends ServiceImpl<ZykMapper, ZykInfo> implements I
|
|||
// Map<String,String> map = fileHandleUtil.uploadFile(zykInfo);
|
||||
Map<String,String> map = fileHandleUtil.moveFiles(zykInfo);
|
||||
if(!map.get("code").equals("0")){
|
||||
return map.get("msg").toString();
|
||||
return map.get("msg");
|
||||
}
|
||||
if(StringUtils.isNotNull(map.get("data"))){
|
||||
String fileName = map.get("data");
|
||||
|
@ -250,12 +250,12 @@ public class ZykServiceImpl extends ServiceImpl<ZykMapper, ZykInfo> implements I
|
|||
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"));
|
||||
// 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")){
|
||||
|
|
|
@ -102,15 +102,15 @@ public class FileHandleUtil {
|
|||
|
||||
public Map<String,String> download(String directory, String downloadFile){
|
||||
Map<String,String> map = SFTPUtil.download(sftpConfig,directory,downloadFile,getDownloadPath("temp"));
|
||||
// SFTPUtil.disChannel();
|
||||
// SFTPUtil.disSession();
|
||||
SFTPUtil.disChannel();
|
||||
SFTPUtil.disSession();
|
||||
return map;
|
||||
}
|
||||
|
||||
public void downloadRes(String downloadFile,HttpServletResponse response) throws Exception{
|
||||
SFTPUtil.writeFileToRes(sftpConfig,downloadFile,response);
|
||||
SFTPUtil.disChannel();
|
||||
SFTPUtil.disSession();
|
||||
// SFTPUtil.disChannel();
|
||||
// SFTPUtil.disSession();
|
||||
}
|
||||
|
||||
public Map<String,String> moveFile(ZykInfo zykInfo){
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import cn.hutool.core.io.FastByteArrayOutputStream;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
|
@ -17,13 +15,11 @@ import org.jeecg.common.constant.SymbolConstant;
|
|||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.*;
|
||||
import org.jeecg.common.util.filter.FileTypeFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -36,7 +32,6 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -54,9 +49,14 @@ import java.util.stream.Collectors;
|
|||
@RequestMapping("/sys/common")
|
||||
public class CommonController {
|
||||
|
||||
private final static Logger logger= LoggerFactory.getLogger(CommonController.class);
|
||||
|
||||
@Value(value = "${jeecg.path.upload}")
|
||||
private String uploadpath;
|
||||
|
||||
@Value(value = "${jeecg.path.webapp}")
|
||||
private String downloadpath;
|
||||
|
||||
/**
|
||||
* 本地:local minio:minio 阿里:alioss
|
||||
*/
|
||||
|
@ -110,8 +110,8 @@ public class CommonController {
|
|||
}
|
||||
/**
|
||||
* 文件上传统一方法
|
||||
* @param request
|
||||
* @param response
|
||||
* @param bizPath
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public String upload(String bizPath, MultipartFile file) throws Exception {
|
||||
|
@ -470,7 +470,30 @@ public class CommonController {
|
|||
}
|
||||
if(CommonConstant.UPLOAD_TYPE_SFTP.equals(uploadType)) {
|
||||
try{
|
||||
SFTPUtil.writeFileToRes(sftpConfig,imgPath,response);
|
||||
logger.info("/sys/common/static/SFTP下载 ..."+new Date());
|
||||
// SFTPUtil.writeFileToRes(sftpConfig,imgPath,response);
|
||||
Map<String,String> map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath("temp"));
|
||||
if(!map.get("code").equals("0")){
|
||||
response.setStatus(404);
|
||||
throw new RuntimeException(map.get("msg"));
|
||||
}
|
||||
String localFilePath = map.get("fileName");
|
||||
File file = new File(localFilePath);
|
||||
if(!file.exists()){
|
||||
response.setStatus(404);
|
||||
throw new RuntimeException("文件["+imgPath+"]不存在..");
|
||||
}
|
||||
// 设置强制下载不打开
|
||||
response.setContentType("application/force-download");
|
||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
inputStream = new BufferedInputStream(new FileInputStream(localFilePath));
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
}catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
}finally {
|
||||
|
@ -512,7 +535,7 @@ public class CommonController {
|
|||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
// log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -600,4 +623,23 @@ public class CommonController {
|
|||
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件真实路径
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
private String getDownloadPath(String path){
|
||||
String filePath = "";
|
||||
if(org.jeecg.common.util.text.StringUtils.isEmpty(path)){
|
||||
return "";
|
||||
}
|
||||
int idx = path.indexOf(downloadpath);
|
||||
if(idx==-1){
|
||||
filePath = downloadpath + File.separator + path;
|
||||
}else{
|
||||
filePath = path;
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ spring:
|
|||
url: jdbc:mysql://127.0.0.1:3306/course_information_center_jeecg_db?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: root
|
||||
# password: ABCabc@123
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 多数据源配置
|
||||
# multi-oracle:
|
||||
|
@ -176,8 +177,8 @@ jeecg:
|
|||
# 签名拦截接口
|
||||
signUrls: /sys/dict/getDictItems/*,/sys/dict/loadDict/*,/sys/dict/loadDictOrderByValue/*,/sys/dict/loadDictItem/*,/sys/dict/loadTreeData,/sys/api/queryTableDictItemsByCode,/sys/api/queryFilterTableDictInfo,/sys/api/queryTableDictByKeys,/sys/api/translateDictFromTable,/sys/api/translateDictFromTableByKeys
|
||||
#local、minio、alioss
|
||||
# uploadType: local
|
||||
uploadType: sftp
|
||||
uploadType: local
|
||||
# uploadType: sftp
|
||||
# 前端访问地址
|
||||
domainUrl:
|
||||
pc: http://localhost:3100
|
||||
|
|
|
@ -175,8 +175,8 @@ jeecg:
|
|||
# 签名拦截接口
|
||||
signUrls: /sys/dict/getDictItems/*,/sys/dict/loadDict/*,/sys/dict/loadDictOrderByValue/*,/sys/dict/loadDictItem/*,/sys/dict/loadTreeData,/sys/api/queryTableDictItemsByCode,/sys/api/queryFilterTableDictInfo,/sys/api/queryTableDictByKeys,/sys/api/translateDictFromTable,/sys/api/translateDictFromTableByKeys
|
||||
#local\minio\alioss
|
||||
# uploadType: local
|
||||
uploadType: sftp
|
||||
uploadType: local
|
||||
# uploadType: sftp
|
||||
# 前端访问地址
|
||||
domainUrl:
|
||||
pc: http://210.47.17.166
|
||||
|
@ -347,10 +347,10 @@ wjx:
|
|||
url: https://www.wjx.cn/openapi/default.aspx
|
||||
#SFTP
|
||||
sftp:
|
||||
hostname: 192.168.2.200
|
||||
hostname: 210.47.29.99
|
||||
port: 22
|
||||
username: sftp
|
||||
password: sftp
|
||||
password: Nenujwc@99
|
||||
timeout: 1000
|
||||
uploadpath: /kczx
|
||||
fullpath: /home/sftp
|
Loading…
Reference in New Issue