修改bug

This commit is contained in:
yangjun 2024-12-09 08:23:28 +08:00
parent 91e21dd8f6
commit 7ccaca977e
22 changed files with 876 additions and 66 deletions

View File

@ -733,7 +733,13 @@ public class SFTPUtil {
// }
/**
* ftp上传文件
* @param sftpConfig ftp配置
* @param localFile 本地存储地址
* @param sftpFile sftp存储地址
* @return
*/
public static Map<String,String> upload(SftpConfig sftpConfig, String localFile, String sftpFile) {
Map<String,String> map = new HashMap<String,String>();
map.put("code","0");
@ -750,7 +756,7 @@ public class SFTPUtil {
mkdirs(sftpConfig.getFullpath());
} catch (SftpException e2) {
map.put("code", "1");
map.put("msg", "sftp创建" + sftpConfig.getUploadpath() + "文件路径失败");
map.put("msg", "sftp创建" + sftpConfig.getFullpath() + "文件路径失败");
}
}
try {
@ -774,9 +780,9 @@ public class SFTPUtil {
String aaa[] = sftpFile.split("/");
String wwqName = aaa[aaa.length -1];
for(int i=0;i<aaa.length -1;i++){
allPath = allPath+"/"+aaa[i];
try {
sftp.cd(aaa[i]);
allPath = allPath+"/"+aaa[i];
} catch (SftpException e1) {
try {
mkdirs(aaa[i]);

View File

@ -205,6 +205,14 @@ public class SyncKcktStat extends BaseSync {
kcKetangbiaoService.update(KcKetangbiaoUpdateWrapper);
}
//--------------------20241204添加修改课堂表的kechengbiaoid字段-------------------------
try {
String skrq = DateUtils.formatDate(dateNow,"yyyy-MM-dd");
kcKetangbiaoService.updateKechengbiaoid(skrq);
} catch (Exception e){
e.printStackTrace();
}
//--------------------20241204添加修改课堂表的kechengbiaoid字段-------------------------
//---------------------20240416新增手动调停课逻辑------------------

View File

@ -75,9 +75,6 @@ public class SyncTJzgXskc extends BaseSync {
List<Xxhbuser> outUserDataList = Lists.newArrayList();
Map<String, Xxhbuser> outUserDataMap = Maps.newHashMap();
//List<KcExportConfigTpkwcqkjzglx> outExportConfigTpkwcqkjzglxDataList = Lists.newArrayList();
// Map<String,KcExportConfigTpkwcqkjzglx> outExportConfigTpkwcqkjzglxDataMap = Lists.newArrayList();
//清洗数据
inDataList.forEach(x -> {
String timestamps = DateUtil.format(x.getTimestamps(), DatePattern.NORM_DATETIME_PATTERN);
@ -89,8 +86,6 @@ public class SyncTJzgXskc extends BaseSync {
Xxhbuser xxhbuser = BeanUtil.toBean(x, Xxhbuser.class);
xxhbuser.setTimestamps(timestamps);
outUserDataMap.put(xxhbuser.getGh(),xxhbuser);
//outExportConfigTpkwcqkjzglxDataList.add(BeanUtil.toBean(x, KcExportConfigTpkwcqkjzglx.class));
});
//保存到胃
@ -140,6 +135,7 @@ public class SyncTJzgXskc extends BaseSync {
// String endSj = DateUtil.format(endSjDate,DatePattern.NORM_DATETIME_FORMAT);
xqxn = common.getTitle();
ectQw.eq("xqxn",xqxn);
ectQw.in("zt","在职","退休");
} else {
xqxn = null;
}
@ -151,7 +147,6 @@ public class SyncTJzgXskc extends BaseSync {
Map<String,KcExportConfigTpkwcqkjzglx> saveMap = Maps.newHashMap();
//outExportConfigTpkwcqkjzglxDataList
oldExportConfigTpkwcqkjzglxList.forEach(x -> {
if(outUserDataMap.containsKey(x.getGh())){
Xxhbuser data = outUserDataMap.get(x.getGh());

View File

@ -72,4 +72,5 @@ public interface KcKetangbiaoMapper extends BaseMapper<KcKetangbiao> {
List<KcKetangbiaoNum> getKccountExportList(KcKetangbiaoNum kcKetangbiao);
void updateKechengbiaoid( @Param("skrq") String skrq);
}

View File

@ -807,4 +807,11 @@
) t GROUP BY xqxn,kkdw
</select>
<update id="updateKechengbiaoid">
update kc_ketangbiao a
LEFT JOIN kc_kechengbiao b on a.kcmc = b.kcmc and a.rwbh = b.rwbh and a.skjs = b.skjs and a.hh = b.hh
set a.kechengbiao1 = b.id , a.kechengbiaoid = b.id where skrq = #{skrq} and b.flag = 0
</update>
</mapper>

View File

@ -74,4 +74,5 @@ public interface IKcKetangbiaoService extends IService<KcKetangbiao> {
List<KcKetangbiaoNum> getKccountExportList(KcKetangbiaoNum object);
void updateKechengbiaoid(String skrq);
}

View File

@ -186,4 +186,9 @@ public class KcKetangbiaoServiceImpl extends ServiceImpl<KcKetangbiaoMapper, KcK
return baseMapper.getKccountExportList(object);
}
@Override
public void updateKechengbiaoid(String skrq) {
baseMapper.updateKechengbiaoid(skrq);
}
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.kc.wjxWjxx.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -14,6 +15,8 @@ import org.jeecg.common.util.text.StringUtils;
import org.jeecg.modules.kc.grab.imports.entity.Xxhbbks;
import org.jeecg.modules.kc.grab.imports.service.IXxhbbksService;
import org.jeecg.modules.kc.kcWechatSendLog.entity.KcWechatSendLog;
import org.jeecg.modules.kc.ktgl.entity.KcKechengbiao;
import org.jeecg.modules.kc.ktgl.service.IKcKechengbiaoService;
import org.jeecg.modules.kc.wjxDjxx.entity.WjxDjxx;
import org.jeecg.modules.kc.wjxDjxx.entity.WjxDjxxTmxx;
import org.jeecg.modules.kc.wjxDjxx.mapper.WjxDjxxMapper;
@ -28,6 +31,7 @@ import org.jeecg.modules.kc.wjxWjxxTmlb.entity.WjxWjxxTmxx;
import org.jeecg.modules.kc.wjxWjxxTmlb.mapper.WjxWjxxTmlbMapper;
import org.jeecg.modules.kc.wjxWjxxTmlb.mapper.WjxWjxxTmxxMapper;
import org.jeecg.modules.kc.zyDbtx.entity.ZyDbtx;
import org.jeecg.modules.kc.zyDbtx.service.IZyDbtxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ -62,6 +66,11 @@ public class WjxWjxxServiceImpl extends ServiceImpl<WjxWjxxMapper, WjxWjxx> impl
@Autowired
private IXxhbbksService xxhbbksService;
@Autowired
private IZyDbtxService zyDbtxService;
@Autowired
private IKcKechengbiaoService kcKechengbiaoService;
@Override
public Page<WjxWjxx> findPage(WjxWjxx wjxWjxx, Page<WjxWjxx> page){
List<WjxWjxx> list = baseMapper.findPage(page,wjxWjxx);
@ -467,27 +476,39 @@ public class WjxWjxxServiceImpl extends ServiceImpl<WjxWjxxMapper, WjxWjxx> impl
for(WjxWjxx wjxWjxx : list){
fbwj(wjxWjxx.getId(),wjxWjxx.getAtype());
// QueryWrapper<Xxhbbks> queryWrapper2 = new QueryWrapper<>();
// queryWrapper2.apply("a.xh = b.xh");
// queryWrapper2.eq("b.KCAPZBBH",wjxWjxx.getRwbh());
// List<Xxhbbks> list2 = xxhbbksService.getXsxkbAllList(queryWrapper2);
// String type = "";
// String content = "";
//
//// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// content = "教师发起了["+wjxWjxx.getKcmc()+"]课程“"+wjxWjxx.getTitle()+"”测验,该测验完成时间: "+DateUtils.formatDate(wjxWjxx.getStartTime(),"yyyy-MM-dd")+" ~ "+DateUtils.formatDate(wjxWjxx.getEndTime(),"yyyy-MM-dd")+",请及时完成";
// for(Xxhbbks xxhbbks:list2){
//
// try {
// KcWechatSendLog kcWechatSendLog = new KcWechatSendLog();
// kcWechatSendLog.setOpenid(xxhbbks.getXh());
// // kcWechatSendLog.setOpenid("2016900057");//指定曹老师账号
// kcWechatSendLog.setYtkcs(content);
//// sendWxmessage(kcWechatSendLog);
// }catch (Exception e){
// e.printStackTrace();
// }
// }
QueryWrapper<Xxhbbks> queryWrapper2 = new QueryWrapper<>();
queryWrapper2.apply("a.xh = b.xh");
queryWrapper2.eq("b.KCAPZBBH",wjxWjxx.getRwbh());
List<Xxhbbks> list2 = xxhbbksService.getXsxkbAllList(queryWrapper2);
QueryWrapper<KcKechengbiao> kcKechengbiaoQueryWrapper = new QueryWrapper<>();
kcKechengbiaoQueryWrapper.eq("rwbh",wjxWjxx.getRwbh());
kcKechengbiaoQueryWrapper.eq("jgh",wjxWjxx.getCreateBy());
kcKechengbiaoQueryWrapper.eq("xqxn",wjxWjxx.getXqxn());
kcKechengbiaoQueryWrapper.last("limit 1");
KcKechengbiao kcKechengbiao = kcKechengbiaoService.getOne(kcKechengbiaoQueryWrapper);
String content = kcKechengbiao.getSkjs()+"教师发起了["+wjxWjxx.getKcmc()+"]课程“"+wjxWjxx.getTitle()+"”测验,该测验完成时间: "+DateUtils.formatDate(wjxWjxx.getStartTime(),"yyyy-MM-dd")+" ~ "+DateUtils.formatDate(wjxWjxx.getEndTime(),"yyyy-MM-dd")+",请及时完成";
for(Xxhbbks xxhbbks:list2){
try {
//作业代办提醒
ZyDbtx zyDbtx = new ZyDbtx();
zyDbtx.setCreateBy(xxhbbks.getXh());
zyDbtx.setType("2");//0发布作业 1评分 2测验 3问卷 4讨论 5学生提交作业 6学生提交测验 7学生提交问卷
zyDbtx.setMainId(wjxWjxx.getId());
zyDbtx.setRwbh(wjxWjxx.getRwbh());
zyDbtx.setContent(content);
zyDbtx.setFlag("0");
zyDbtx.setFbr(wjxWjxx.getCreateBy());
zyDbtxService.save(zyDbtx);
}catch (Exception e){
e.printStackTrace();
}
}
}

View File

@ -96,6 +96,7 @@ public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> impleme
QueryWrapper<ZyDbtx> zyDbtxQueryWrapper = new QueryWrapper<>();
zyDbtxQueryWrapper.eq("type",zyInfo.getZyLeixing());//发送作业
zyDbtxQueryWrapper.eq("rwbh",zyInfo.getRwbh());
zyDbtxQueryWrapper.eq("main_id",zyInfo.getId());
List<ZyDbtx> dbtxlist = zyDbtxService.list(zyDbtxQueryWrapper);
String xharrs[] = new String[dbtxlist.size()];
for(int i=0;i<dbtxlist.size();i++){

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.kc.zyInfoStudent.controller;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -614,18 +615,7 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
e.printStackTrace();
}
return Result.OK("上传成功!");
}
@PostMapping(value = "/uploadSckhcl2")
public Result<String> uploadSckhcl2(@RequestParam(name="ids",required=true) String ids) {
try {
zyInfoStudentService.batchZyinfoKhcl(ids);
}catch (Exception e) {
e.printStackTrace();
}
return Result.OK("上传成功!");
return Result.OK("考核材料上传成功!");
}
@ -1209,4 +1199,29 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
}
/**
* 重新提交因为检测次数不足导致的错误
* @param response
* @return
*/
@RequestMapping(value = "/cxtjByJccsbz", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> cxtjByJccsbz(HttpServletResponse response) {
List<ZyInfoStudent> list =zyInfoStudentService.cxtjByJccsbz();
for(ZyInfoStudent zyInfoStudent:list){
zyInfoStudentService.sysWpKsjc(zyInfoStudent, response);
}
return Result.OK("提交成功!");
}
/**
* 获取维普查重次数
* @return
*/
@GetMapping(value = "/getWpSycccs")
public Result<List<JSONObject>> queryById() {
List<JSONObject> zyInfoStudent = zyInfoStudentService.getWpSycccs();
return Result.OK(zyInfoStudent);
}
}

View File

@ -127,6 +127,7 @@ public class ZyInfoStudent implements Serializable {
private String pyFilePath;//批阅附件
private String sfsckhcl;//是否上传考核材料0否 1是
private String fwqPath;//文件服务器存储地址
private String pyFwqFilePath;//评阅附件存储地址
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Excel(name = "考核材料提交时间", width = 15,format = "yyyy-MM-dd HH:mm:ss")

View File

@ -48,4 +48,6 @@ public interface ZyInfoStudentMapper extends BaseMapper<ZyInfoStudent> {
List<ZyInfoStudent> getDocNoPdfList();
List<ZyInfoStudent> cxccByZyId(@Param("zyInfoStudent") ZyInfoStudent zyInfoStudent2);
List<ZyInfoStudent> cxtjByJccsbz();
}

View File

@ -174,4 +174,9 @@
where a.main_id = #{zyInfoStudent.mainId} and a.file_path is not null and b.id is null
</select>
<select id="cxtjByJccsbz" resultType="org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent">
select a.* from zy_info_student a ,
(select distinct zy_stu_id from zy_ccjg where message = '大学生版,检测次数不足') b where a.id = b.zy_stu_id and a.file_path is not null
</select>
</mapper>

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.kc.zyInfoStudent.service;
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;
@ -10,6 +11,7 @@ import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudentSys;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* @Description: 学生提交作业
@ -54,4 +56,10 @@ public interface IZyInfoStudentService extends IService<ZyInfoStudent> {
ZyInfoStudent scccjg(ZyInfoStudent zyInfoStudent, HttpServletRequest req, HttpServletResponse response);
void batchZyinfoKhcl(String ids);
List<ZyInfoStudent> cxtjByJccsbz();
void sysWpKsjc(ZyInfoStudent zyInfoStudent, HttpServletResponse response);
List<JSONObject> getWpSycccs();
}

View File

@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.constant.CommonConstant;
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.modules.kc.ktgl.entity.KcKechengbiao;
@ -278,10 +279,13 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
}
@Override
@Transactional
public void batchZyinfoKhcl(String ids) {
try {
String idsList[] = ids.split(",");
String yyyy = DateUtils.formatDate(new Date(),"yyyy");
String mm = DateUtils.formatDate(new Date(),"MM");
if(idsList.length>0){
for(String zyId:idsList){
ZyInfo zyInfo = zyInfoService.getById(zyId);
@ -295,34 +299,45 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
zyInfo.setSfsckhclTime(new Date());
zyInfoService.updateById(zyInfo);
QueryWrapper<ZyInfoStudent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("main_id",zyId);
queryWrapper.isNotNull("file_path");
queryWrapper.eq("a.main_id",zyId);
queryWrapper.isNotNull("a.file_path");
List<ZyInfoStudent> list = baseMapper.selectList(queryWrapper);
for(ZyInfoStudent zyInfoStudentPar2:list){
if(StringUtils.isNotEmpty(zyInfoStudentPar2.getFilePath())){
//上传文件
Map<String,String> uploadMap = SFTPUtil.upload(sftpConfig,upLoadPath+"/"+zyInfoStudentPar2.getFilePath(),zyInfoStudentPar2.getFilePath());
zyInfoStudentPar2.setSfsckhcl("1");
zyInfoStudentPar2.setFwqPath(uploadMap.get("data"));
zyInfoStudentPar2.setKhclTime(new Date());
baseMapper.updateById(zyInfoStudentPar2);
//上传作业文件
Map<String,String> uploadMap = SFTPUtil.upload(sftpConfig,upLoadPath+"/"+zyInfoStudentPar2.getFilePath(),yyyy+"/"+mm+"/"+zyInfo.getRwbh()+"/"+zyInfoStudentPar2.getFilePath().replace("temp/","/"));
ZyInfoScjl zyInfoScjl = new ZyInfoScjl();
zyInfoScjl.setZyId(zyInfo.getId());
zyInfoScjl.setZyName(zyInfo.getTitle());
zyInfoScjl.setZyLeixing(zyInfo.getZyLeixing());
zyInfoScjl.setZyZb(zyInfo.getScore());
zyInfoScjl.setJgh(kcKechengbiao.getJgh());
zyInfoScjl.setSkjs(kcKechengbiao.getSkjs());
zyInfoScjl.setSkdd(kcKechengbiao.getSkdd());
zyInfoScjl.setKkdw(kcKechengbiao.getKkdw());
zyInfoScjl.setKkdwid(kcKechengbiao.getKkdwid());
zyInfoScjl.setKcxz(kcKechengbiao.getKcxz());
zyInfoScjl.setXnxq(zyInfo.getXnxq());
zyInfoScjl.setFilePath(zyInfoStudentPar2.getFwqPath());
zyInfoScjl.setStudentNo(zyInfoStudentPar2.getCreateBy());
zyInfoScjl.setStudentName(zyInfoStudentPar2.getStudentName());
zyInfoScjlService.save(zyInfoScjl);
if(StringUtils.isNotEmpty(zyInfoStudentPar2.getPyFilePath())){
//上传评阅附件
Map<String,String> uploadMap2 = SFTPUtil.upload(sftpConfig,upLoadPath+"/"+zyInfoStudentPar2.getPyFilePath(),yyyy+"/"+mm+"/"+zyInfo.getRwbh()+"/"+zyInfoStudentPar2.getPyFilePath().replace("temp/","/"));
if(StringUtils.equals(uploadMap2.get("code"),"0")){
zyInfoStudentPar2.setPyFwqFilePath(uploadMap2.get("data"));
}
}
if(StringUtils.equals(uploadMap.get("code"),"0")){
zyInfoStudentPar2.setSfsckhcl("1");
zyInfoStudentPar2.setFwqPath(uploadMap.get("data"));
zyInfoStudentPar2.setKhclTime(new Date());
baseMapper.updateById(zyInfoStudentPar2);
ZyInfoScjl zyInfoScjl = new ZyInfoScjl();
zyInfoScjl.setZyId(zyInfo.getId());
zyInfoScjl.setZyName(zyInfo.getTitle());
zyInfoScjl.setZyLeixing(zyInfo.getZyLeixing());
zyInfoScjl.setZyZb(zyInfo.getScore());
zyInfoScjl.setJgh(kcKechengbiao.getJgh());
zyInfoScjl.setSkjs(kcKechengbiao.getSkjs());
zyInfoScjl.setSkdd(kcKechengbiao.getSkdd());
zyInfoScjl.setKkdw(kcKechengbiao.getKkdw());
zyInfoScjl.setKkdwid(kcKechengbiao.getKkdwid());
zyInfoScjl.setKcxz(kcKechengbiao.getKcxz());
zyInfoScjl.setXnxq(zyInfo.getXnxq());
zyInfoScjl.setFilePath(zyInfoStudentPar2.getFwqPath());
zyInfoScjl.setStudentNo(zyInfoStudentPar2.getCreateBy());
zyInfoScjl.setStudentName(zyInfoStudentPar2.getStudentName());
zyInfoScjlService.save(zyInfoScjl);
}
}
}
}
@ -332,6 +347,79 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
}
}
@Override
public List<ZyInfoStudent> cxtjByJccsbz() {
return baseMapper.cxtjByJccsbz();
}
@Override
public void sysWpKsjc(ZyInfoStudent zyInfoStudent, HttpServletResponse response) {
String fileName = getFileName(zyInfoStudent.getFilePath(),response);
zyInfoStudent.setFilePath(fileName);
ZyInfo zyInfo = zyInfoService.getById(zyInfoStudent.getMainId());
String cateid = zyInfo.getId()+""+zyInfo.getTitle();
String catename = zyInfo.getTitle();
zyInfoStudent.setCateid(cateid);
zyInfoStudent.setCatename(catename);
//删除维普已经提交的文档
delSysweipulunwen(zyInfoStudent, response);
//外网查重及提交检测
if(StringUtils.equals(zyInfo.getWwcc(),"true")){
wwccSave(zyInfoStudent,response);
}
// //内网查重及提交检测
// if(StringUtils.equals(zyInfo.getNwcc(),"true")){
// nwccSave(zyInfoStudent,response);
// }
//aigc查重及提交检测
if(StringUtils.equals(zyInfo.getAigccc(),"true")){
aigcSave(zyInfoStudent,response);
}
// //校内查重及提交检测
// if(StringUtils.equals(zyInfo.getXncc(),"true")){
// zyInfoStudent.setCateid("DBSDQXZYBDK001");
// zyInfoStudent.setCatename("东北师大全校作业比对库");
// xnccSave(zyInfoStudent,"1",response);//提交比对
// }
}
@Override
public List<JSONObject> getWpSycccs() {
List<JSONObject> list = new ArrayList<>();
String url = "https://vims.fanyu.com/toole/jianceorgan/papercheckcount.aspx";
JSONObject object= getSycs(url,"1");
object.put("name","外网检测");
JSONObject object2= getSycs(url,"3");
object2.put("name","AIGC检测");
list.add(object);
list.add(object2);
return list;
}
public JSONObject getSycs(String url,String type){
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("sign", sign);
textMap.put("userid", weipuId);
textMap.put("type", type);
String contentType = "";//image/png
String ret = formUpload(url, textMap, null,contentType);
log.error("1-------->"+ret);
JSONObject object= JSONObject.parseObject(ret);
return object;
}
private void delweipulunwen(ZyInfoStudent zyInfoStudent, HttpServletResponse response) {
zyInfoStudent.setQueryType("0");//外网查重数据
String paperids = baseMapper.getWpFile(zyInfoStudent);
@ -364,6 +452,38 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
zyCcjgMapper.deleteByZystuid(zyInfoStudent.getId());
}
private void delSysweipulunwen(ZyInfoStudent zyInfoStudent, HttpServletResponse response) {
zyInfoStudent.setQueryType("0");//外网查重数据
String paperids = baseMapper.getWpFile(zyInfoStudent);
if(StringUtils.isNotEmpty(paperids)){
String url = "https://vims.fanyu.com/toole/jianceorgan/paperdel.aspx";
delWpFile(url,paperids, response);
}
// zyInfoStudent.setQueryType("1");//内网查重数据-作业内查重
// Map<String,String> paperids1 = baseMapper.getXfwWpFile(zyInfoStudent);
// if(paperids1 != null){
// String dataids = paperids1.get("paperid");
// String bdkbs = paperids1.get("bdkbs");
// String url = "https://vims.fanyu.com/toole/smallcheck/delData";
// delXfwWpFile(url,bdkbs,dataids, response);
// }
// zyInfoStudent.setQueryType("3");//内网查重数据-全校内比对
// Map<String,String> paperids3 = baseMapper.getXfwWpFile(zyInfoStudent);
// if(paperids3 != null){
// String dataids = paperids3.get("paperid");
// String bdkbs = paperids3.get("bdkbs");
// String url = "https://vims.fanyu.com/toole/smallcheck/delData";
// delXfwWpFile(url,bdkbs,dataids, response);
// }
zyInfoStudent.setQueryType("2");//aigc查重数据
String paperids2 = baseMapper.getWpFile(zyInfoStudent);
if(StringUtils.isNotEmpty(paperids2)){
String url = "https://vims.fanyu.com/tool/AIGCCheck/paperDel";
delWpFile(url,paperids2, response);
}
zyCcjgMapper.deleteByZystuid(zyInfoStudent.getId());
}
//aigc提交
private void aigcSave(ZyInfoStudent zyInfoStudent,HttpServletResponse response) {
String url = "https://vims.fanyu.com/tool/AIGCCheck/paperSubmit";

View File

@ -0,0 +1,62 @@
package org.jeecg.modules.wps.controller;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Map;
public class HttpClientPOSTExample {
public static void main(String[] args) {
try {
String drive_id = "test1111";
String parent_id = "test1112";
URL url = new URL("https://openapi.wps.cn/v7/drives/"+drive_id+"/files/"+parent_id+"/create");
// 打开连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置请求方法为POST
connection.setRequestMethod("POST");
// 设置请求头例如内容类型和认证信息
Map<String,String> map = KsoSign.getAuthorization();
// String credentials = apiKey + ":" + secretKey;
// String basicAuth = "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes()));
connection.setRequestProperty("Authorization", map.get("authorization"));
connection.setRequestProperty("Content-Type", "application/json");
// 发送POST请求的数据
String postData = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
byte[] outputInBytes = postData.getBytes(StandardCharsets.UTF_8);
connection.setDoOutput(true);
// 写入数据到请求体
try (OutputStream out = connection.getOutputStream()) {
out.write(outputInBytes);
}
// 获取响应码
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// 读取响应内容
if (responseCode == HttpURLConnection.HTTP_OK) {
// 处理响应内容
// String response = new String(connection.getInputStream(), StandardCharsets.UTF_8);
// System.out.println(response);
} else {
// 处理错误响应
// String errorResponse = new String(connection.getErrorStream().readAllBytes(), StandardCharsets.UTF_8);
// System.out.println("Error Response: " + errorResponse);
}
// 关闭连接
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,48 @@
package org.jeecg.modules.wps.controller;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;
public class HttpsPostRequest {
public static void main(String[] args) throws Exception {
String targetURL = "https://openapi.wps.cn/oauth2/token";
URL url = new URL(targetURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置请求方法为POST
connection.setRequestMethod("POST");
// 设置通用请求属性
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// 如果需要添加认证
// String authentication = "username:password";
// String encodedAuthentication = new String(Base64.getEncoder().encode(authentication.getBytes()));
// connection.setRequestProperty ("Authorization", "Basic " + encodedAuthentication);
// 发送POST请求必须设置如下两行
connection.setDoOutput(true);
connection.setDoInput(true);
// 发送请求参数
String jsonInputString = "{\"grant_type\":\"client_credentials\",\"client_id\":\"SX20241118WSUGQN\",\"client_secret\":\"IbRfANAvtsOoSAeKASHfiOMYlBpeVTqg\"}";
try(OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes();
os.write(input, 0, input.length);
}
// 获取响应码
int responseCode = connection.getResponseCode();
System.out.println("POST Response Code :: " + responseCode);
// 根据需要处理响应内容
if (responseCode == HttpURLConnection.HTTP_OK) {
// 处理响应
}
// 关闭连接
connection.disconnect();
}
}

View File

@ -0,0 +1,184 @@
package org.jeecg.modules.wps.controller;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.util.*;
public class KsoSign {
private final String accessKey;
private final String secretKey;
public KsoSign(String accessKey, String secretKey) {
this.accessKey = accessKey;
this.secretKey = secretKey;
}
public static final class Out {
private final String date; // X-Kso-Date
private final String authorization; // X-Kso-Authorization
public Out(String date, String authorization) {
this.date = date;
this.authorization = authorization;
}
public String getDate() {
return date;
}
public String getAuthorization() {
return authorization;
}
}
public Out kso1Sign(String method, String uri, String contentType, String ksoDate, byte[] requestBody) throws NoSuchAlgorithmException, InvalidKeyException {
String ksoSignature = getKso1Signature(method, uri, contentType, ksoDate, requestBody);
String authorization = String.format("KSO-1 %s:%s", accessKey, ksoSignature);
return new Out(ksoDate, authorization);
}
private String getKso1Signature(String method, String uri, String contentType, String ksoDate, byte[] requestBody) throws NoSuchAlgorithmException, InvalidKeyException {
String sha256Hex = "";
if (requestBody != null && requestBody.length > 0) {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(requestBody);
sha256Hex = bytesToHex(hash);
}
System.out.println("sha256: " + sha256Hex);
String dataToSign = "KSO-1" + method + uri + contentType + ksoDate + sha256Hex;
Mac mac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
mac.init(secretKeySpec);
byte[] macBytes = mac.doFinal(dataToSign.getBytes(StandardCharsets.UTF_8));
return bytesToHex(macBytes);
}
private String bytesToHex(byte[] bytes) {
StringBuilder result = new StringBuilder();
for (byte b : bytes) {
result.append(String.format("%02x", b));
}
return result.toString();
}
/**
* 获取签名
* @return
*/
public static Map<String,String> getAuthorization(){
Map<String,String> map = new HashMap<>();
// final String accessKey = "SX20241118WSUGQN";
// final String secretKey = "IbRfANAvtsOoSAeKASHfiOMYlBpeVTqg";
final String accessKey = "AK20241118LLGJYF";
final String secretKey = "ce3e6d90a27c1ef238ce1b0b81a8d902";
final String method = "POST";
final String uri = "/v7/test/body";
final String contentType = "application/json";
final String contentDate = new Date().toString();
final byte[] requestBody = "{\"key\": \"value\"}".getBytes(StandardCharsets.UTF_8);
KsoSign kso = new KsoSign(accessKey, secretKey);
try {
KsoSign.Out out = kso.kso1Sign(method, uri, contentType, contentDate, requestBody);
System.out.println(out.getDate());
System.out.println(out.getAuthorization());
String data = out.getDate();
String authorization = out.getAuthorization();
map.put("data",data);
map.put("authorization",authorization);
return map;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 获取token
* @return
* @throws IOException
*/
public static Map<String,String> getToken() throws IOException {
String httpsURL = "https://openapi.wps.cn/oauth2/token";
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(httpsURL);
// 设置请求头
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
// 创建请求内容
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("grant_type", "client_credentials"));
params.add(new BasicNameValuePair("client_id", "AK20241118LLGJYF"));
params.add(new BasicNameValuePair("client_secret", "ce3e6d90a27c1ef238ce1b0b81a8d902"));
HttpEntity entity = new UrlEncodedFormEntity(params,"UTF-8");
System.out.println("entity "+entity.toString());
httpPost.setEntity(entity);
// 发送请求并获取响应
CloseableHttpResponse response = httpClient.execute(httpPost);
// 打印响应状态
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
// 获取响应内容并关闭
String responseBody = EntityUtils.toString(response.getEntity());
System.out.println("responseBody : "+responseBody);
// 关闭HttpClient和response
httpClient.close();
response.close();
Map<String,String> map = new HashMap<>();
if(response.getStatusLine().getStatusCode() == 200){
JSONObject jsonObject = JSONObject.parseObject(responseBody);
map.put("code","200");
map.put("access_token",jsonObject.getString("access_token"));
map.put("msg","获取token成功");
}else{
map.put("code","500");
map.put("msg","获取token失败");
}
return map;
}
public static void main(String[] args) throws Exception {
//------------------获取token----------------------------
Map<String,String> mapToken = getToken();//获取token
System.out.println("code---" + mapToken.get("code"));
System.out.println("access_token---" + mapToken.get("access_token"));
//------------------获取token----------------------------
//------------------获取Authorization----------------------------
Map<String,String> mapAuthorization = getAuthorization();
//------------------获取Authorization----------------------------
}
}

View File

@ -0,0 +1,224 @@
package org.jeecg.modules.wps.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.kc.kcCasusers.entity.KcCasusers;
import org.jeecg.modules.kc.kcCasusers.service.IKcCasusersService;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import org.jeecg.modules.kc.zyInfoStudent.service.IZyInfoStudentService;
import org.jeecg.modules.kc.zyZyxx.entity.ZyZyxx;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.wps.entity.WpsEnti;
import org.jeecg.modules.wps.entity.WpsUploadEnti;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
* @Description: kc_casusers
* @Author: jeecg-boot
* @Date: 2023-05-22
* @Version: V1.0
*/
@RestController
@RequestMapping("/v3/3rd")
@Slf4j
public class WpsController extends JeecgController<KcCasusers, IKcCasusersService> {
@Autowired
private IZyInfoStudentService zyInfoStudentService;
@Autowired
private ISysUserService sysUserService;
/**
* 文档预览
* @param fileId
* @return
*/
@RequestMapping(value = "/files/{fileId}", method = {RequestMethod.GET})
public Map<String,Object> files(@PathVariable("fileId") String fileId) {
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(fileId);
WpsEnti map = new WpsEnti();
map.setId(zyInfoStudent.getId());
map.setName(zyInfoStudent.getFilePath());
map.setVersion(1);
map.setSize(1);
map.setName(zyInfoStudent.getFilePath().substring(zyInfoStudent.getFilePath().lastIndexOf("/")+1));
Long createTime = zyInfoStudent.getCreateTime().getTime()/1000;
Long updateTime = zyInfoStudent.getUpdateTime().getTime()/1000;
map.setCreate_time(Integer.parseInt(createTime+""));
map.setModify_time(Integer.parseInt(updateTime+""));
map.setCreator_id(zyInfoStudent.getCreateBy());
map.setModifier_id(zyInfoStudent.getUpdateBy());
Map<String,Object> mapRet = new HashMap<>();
mapRet.put("code",0);
mapRet.put("data",map);
return mapRet;
}
/**
* 文件下载地址
* @param fileId
* @return
*/
@RequestMapping(value = "/files/{fileId}/download", method = {RequestMethod.GET})
public Map<String,Object> download(@PathVariable("fileId") String fileId) {
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(fileId);
Map<String,Object> mapRet = new HashMap<>();
Map<String,Object> mapRet2 = new HashMap<>();
// https://kczxcs.nenu.edu.cn/jeecg-boot/sys/common/static/temp/QA%E4%BD%9C%E4%B8%9A%E7%B3%BB%E7%BB%9F%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98_1733101749150.docx
mapRet2.put("url","https://kczxcs.nenu.edu.cn/jeecg-boot/sys/common/static/"+zyInfoStudent.getFilePath());
mapRet.put("code",0);
mapRet.put("data",mapRet2);
return mapRet;
}
/**
* 获取文档用户权限
* @param fileId
* @return
*/
@RequestMapping(value = "/files/{fileId}/permission", method = {RequestMethod.GET})
public Map<String,Object> permission(@PathVariable("fileId") String fileId) {
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(fileId);
Map<String,Object> mapRet = new HashMap<>();
Map<String,Object> mapRet2 = new HashMap<>();
mapRet.put("code",0);
mapRet2.put("comment",1);
// mapRet2.put("copy",1);
mapRet2.put("download",1);
mapRet2.put("history",1);
mapRet2.put("print",1);
mapRet2.put("read",1);
// mapRet2.put("rename",1);
// mapRet2.put("saveas",1);
mapRet2.put("update",1);
mapRet2.put("user_id",zyInfoStudent.getCreateBy());
mapRet.put("data",mapRet2);
return mapRet;
}
/**
* 文档预览
* @param fileId
* @return
*/
@RequestMapping(value = "/files/{fileId}/versions", method = {RequestMethod.GET})
public Map<String,Object> versions(@PathVariable("fileId") String fileId) {
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(fileId);
WpsEnti map = new WpsEnti();
map.setId(zyInfoStudent.getId());
map.setName(zyInfoStudent.getFilePath());
map.setVersion(1);
map.setSize(1);
map.setName(zyInfoStudent.getFilePath().substring(zyInfoStudent.getFilePath().lastIndexOf("/")+1));
Long createTime = zyInfoStudent.getCreateTime().getTime()/1000;
Long updateTime = zyInfoStudent.getUpdateTime().getTime()/1000;
map.setCreate_time(Integer.parseInt(createTime+""));
map.setModify_time(Integer.parseInt(updateTime+""));
map.setCreator_id(zyInfoStudent.getCreateBy());
map.setModifier_id(zyInfoStudent.getUpdateBy());
Map<String,Object> mapRet = new HashMap<>();
mapRet.put("code",0);
mapRet.put("data",map);
return mapRet;
}
@GetMapping(value = "/users")
public Map<String, Object> users(@RequestParam(name="user_ids",required=true) String user_ids) {
System.out.println("user_ids : " + user_ids);
String userIds[] = user_ids.split(",");
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> mapRet = new HashMap<>();
mapRet.put("code",0);
for(String userId : userIds){
SysUser sysUser = sysUserService.getUserByName(userId);
System.out.println("sysUser : " + sysUser);
Map<String,Object> map = new HashMap<>();
map.put("id",sysUser.getUsername());
map.put("name",sysUser.getRealname());
list.add(map);
}
mapRet.put("data",list);
return mapRet;
}
/**
* 准备上传阶段
* @param fileId
* @return
*/
@RequestMapping(value = "/files/{fileId}/upload/prepare", method = {RequestMethod.GET})
public Map<String,Object> prepare(@PathVariable("fileId") String fileId) {
Map<String,Object> mapRet = new HashMap<>();
mapRet.put("code",0);
Map<String,Object> mapRet2 = new HashMap<>();
String jmArr[] = {"sha1"};
mapRet2.put("digest_types",jmArr);
mapRet.put("data",mapRet2);
mapRet.put("message","");
return mapRet;
}
@RequestMapping(value = "/files/{fileId}/upload/address", method = {RequestMethod.POST})
public Map<String,Object> address(@PathVariable("fileId") String fileId, @RequestBody WpsUploadEnti wpsUploadEnti) {
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(fileId);
Map<String,Object> mapRet = new HashMap<>();
mapRet.put("code",0);
Map<String,Object> mapRet2 = new HashMap<>();
mapRet2.put("url","https://kczxcs.nenu.edu.cn/jeecg-boot/sys/common/static/"+zyInfoStudent.getFilePath());
mapRet2.put("method","POST");
mapRet.put("data",mapRet2);
mapRet.put("message","");
return mapRet;
}
@RequestMapping(value = "/files/{fileId}/upload/complete", method = {RequestMethod.POST})
public Map<String,Object> complete(@PathVariable("fileId") String fileId, @RequestBody WpsUploadEnti wpsUploadEnti,HttpServletRequest request, HttpServletResponse response) {
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(fileId);
Map<String,Object> mapRet = new HashMap<>();
mapRet.put("code",0);
WpsEnti map = new WpsEnti();
map.setId(zyInfoStudent.getId());
map.setName(zyInfoStudent.getFilePath());
map.setVersion(2);
map.setSize(1);
map.setName(zyInfoStudent.getFilePath().substring(zyInfoStudent.getFilePath().lastIndexOf("/")+1));
Long createTime = zyInfoStudent.getCreateTime().getTime()/1000;
Long updateTime = zyInfoStudent.getUpdateTime().getTime()/1000;
map.setCreate_time(Integer.parseInt(createTime+""));
map.setModify_time(Integer.parseInt(updateTime+""));
map.setCreator_id(zyInfoStudent.getCreateBy());
map.setModifier_id(zyInfoStudent.getUpdateBy());
mapRet.put("data",map);
mapRet.put("message","");
return mapRet;
}
}

View File

@ -0,0 +1,51 @@
package org.jeecg.modules.wps.controller;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.util.*;
public class WpsToken {
public static void main(String[] args) throws Exception {
String httpsURL = "https://openapi.wps.cn/oauth2/token";
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(httpsURL);
// 设置请求头
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
// 创建请求内容
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("grant_type", "client_credentials"));
params.add(new BasicNameValuePair("client_id", "AK20241118LLGJYF"));
params.add(new BasicNameValuePair("client_secret", "ce3e6d90a27c1ef238ce1b0b81a8d902"));
HttpEntity entity = new UrlEncodedFormEntity(params,"UTF-8");
System.out.println("entity "+entity.toString());
httpPost.setEntity(entity);
// 发送请求并获取响应
CloseableHttpResponse response = httpClient.execute(httpPost);
// 打印响应状态
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
// 获取响应内容并关闭
String responseBody = EntityUtils.toString(response.getEntity());
System.out.println("responseBody : "+responseBody);
// 关闭HttpClient和response
httpClient.close();
response.close();
}
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.wps.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class WpsEnti {
private String id;
private String name;
private Integer version;
private Integer size;
private Integer create_time;
private Integer modify_time;
private String creator_id;
private String modifier_id;
}

View File

@ -0,0 +1,26 @@
package org.jeecg.modules.wps.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Map;
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class WpsUploadEnti {
private String file_id;
private String name;
private Integer size;
private Map<String,String> digest;
private boolean is_manual;
private Integer attachment_size;
private String content_type;
private Object request;
private Object response;
private Integer status_code;
private Map<String,String> headers;
private byte body;
private Map<String,String> send_back_params;
}