Compare commits

...

3 Commits

31 changed files with 2490 additions and 2 deletions

View File

@ -0,0 +1,48 @@
package org.jeecg.modules.kc.grab.SynchronizationService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.kc.grab.SynchronizationService.base.BaseSync;
import org.jeecg.modules.kc.zyCcjg.service.IZyCcjgService;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map;
/**
* 作业查重接口
*/
@Slf4j
public class SyncZyCcjg extends BaseSync {
@Autowired
private IZyCcjgService zyCcjgService;
/**
* 若参数变量名修改 QuartzJobController中也需对应修改
*/
@Override
public void execute(JobExecutionContext jobExecutionContext) {
start();
run(getParamMap());
end();
}
/**
* 有参定时任务实现
* @param param
*/
public void run(Map<String, Object> param){
zyCcjgService.getCcjg();
}
/**
* 无参定时任务实现
*/
public void run(){
run(null);
}
}

View File

@ -32,6 +32,7 @@ import lombok.experimental.Accessors;
public class KcEvaluationsHisrecord implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
/**学年学期*/
@Excel(name = "学年学期", width = 15)
@ApiModelProperty(value = "学年学期")

View File

@ -0,0 +1,185 @@
package org.jeecg.modules.kc.kcXsktjxmydcp.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.kc.kcXsktjxmydcp.entity.KcXsktjxmydcp;
import org.jeecg.modules.kc.kcXsktjxmydcp.service.IKcXsktjxmydcpService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 学生课堂教学满意度测评
* @Author: jeecg-boot
* @Date: 2024-05-08
* @Version: V1.0
*/
@Api(tags="学生课堂教学满意度测评")
@RestController
@RequestMapping("/kcXsktjxmydcp/kcXsktjxmydcp")
@Slf4j
public class KcXsktjxmydcpController extends JeecgController<KcXsktjxmydcp, IKcXsktjxmydcpService> {
@Autowired
private IKcXsktjxmydcpService kcXsktjxmydcpService;
/**
* 分页列表查询
*
* @param kcXsktjxmydcp
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "学生课堂教学满意度测评-分页列表查询")
@ApiOperation(value="学生课堂教学满意度测评-分页列表查询", notes="学生课堂教学满意度测评-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<KcXsktjxmydcp>> queryPageList(KcXsktjxmydcp kcXsktjxmydcp,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<KcXsktjxmydcp> queryWrapper = QueryGenerator.initQueryWrapper(kcXsktjxmydcp, req.getParameterMap());
Page<KcXsktjxmydcp> page = new Page<KcXsktjxmydcp>(pageNo, pageSize);
IPage<KcXsktjxmydcp> pageList = kcXsktjxmydcpService.page(page, queryWrapper);
return Result.OK(pageList);
}
@ApiOperation(value="学生课堂教学满意度测评-分页列表查询", notes="学生课堂教学满意度测评-分页列表查询")
@GetMapping(value = "/groupByList")
public Result<IPage<KcXsktjxmydcp>> groupByList(KcXsktjxmydcp kcXsktjxmydcp,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<KcXsktjxmydcp> queryWrapper = QueryGenerator.initQueryWrapper(kcXsktjxmydcp, req.getParameterMap());
Page<KcXsktjxmydcp> page = new Page<KcXsktjxmydcp>(pageNo, pageSize);
IPage<KcXsktjxmydcp> pageList = kcXsktjxmydcpService.groupByList(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param kcXsktjxmydcp
* @return
*/
@AutoLog(value = "学生课堂教学满意度测评-添加")
@ApiOperation(value="学生课堂教学满意度测评-添加", notes="学生课堂教学满意度测评-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody KcXsktjxmydcp kcXsktjxmydcp) {
kcXsktjxmydcpService.save(kcXsktjxmydcp);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param kcXsktjxmydcp
* @return
*/
@AutoLog(value = "学生课堂教学满意度测评-编辑")
@ApiOperation(value="学生课堂教学满意度测评-编辑", notes="学生课堂教学满意度测评-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody KcXsktjxmydcp kcXsktjxmydcp) {
kcXsktjxmydcpService.updateById(kcXsktjxmydcp);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "学生课堂教学满意度测评-通过id删除")
@ApiOperation(value="学生课堂教学满意度测评-通过id删除", notes="学生课堂教学满意度测评-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
kcXsktjxmydcpService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "学生课堂教学满意度测评-批量删除")
@ApiOperation(value="学生课堂教学满意度测评-批量删除", notes="学生课堂教学满意度测评-批量删除")
@RequiresPermissions("kcXsktjxmydcp:kc_xsktjxmydcp:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.kcXsktjxmydcpService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "学生课堂教学满意度测评-通过id查询")
@ApiOperation(value="学生课堂教学满意度测评-通过id查询", notes="学生课堂教学满意度测评-通过id查询")
@GetMapping(value = "/queryById")
public Result<KcXsktjxmydcp> queryById(@RequestParam(name="id",required=true) String id) {
KcXsktjxmydcp kcXsktjxmydcp = kcXsktjxmydcpService.getById(id);
if(kcXsktjxmydcp==null) {
return Result.error("未找到对应数据");
}
return Result.OK(kcXsktjxmydcp);
}
/**
* 导出excel
*
* @param request
* @param kcXsktjxmydcp
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, KcXsktjxmydcp kcXsktjxmydcp) {
return super.exportXls(request, kcXsktjxmydcp, KcXsktjxmydcp.class, "学生课堂教学满意度测评");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, KcXsktjxmydcp.class);
}
}

View File

@ -0,0 +1,159 @@
package org.jeecg.modules.kc.kcXsktjxmydcp.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 学生课堂教学满意度测评
* @Author: jeecg-boot
* @Date: 2024-05-08
* @Version: V1.0
*/
@Data
@TableName("kc_xsktjxmydcp")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="kc_xsktjxmydcp对象", description="学生课堂教学满意度测评")
public class KcXsktjxmydcp implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@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;
/**updateTime*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "updateTime")
private java.util.Date updateTime;
/**开课通知单号*/
@Excel(name = "开课通知单号", width = 15)
@ApiModelProperty(value = "开课通知单号")
private java.lang.String kktzdh;
/**课程编号*/
@Excel(name = "课程编号", width = 15)
@ApiModelProperty(value = "课程编号")
private java.lang.String kcbh;
/**课程名称*/
@Excel(name = "课程名称", width = 15)
@ApiModelProperty(value = "课程名称")
private java.lang.String kcmc;
/**教工号*/
@Excel(name = "教工号", width = 15)
@ApiModelProperty(value = "教工号")
private java.lang.String jgh;
/**授课教师*/
@Excel(name = "授课教师", width = 15)
@ApiModelProperty(value = "授课教师")
private java.lang.String skjs;
/**开课单位*/
@Excel(name = "开课单位", width = 15)
@ApiModelProperty(value = "开课单位")
private java.lang.String kkdw;
/**实验学时*/
@Excel(name = "实验学时", width = 15)
@ApiModelProperty(value = "实验学时")
private java.lang.String sxxs;
/**实践学时*/
@Excel(name = "实践学时", width = 15)
@ApiModelProperty(value = "实践学时")
private java.lang.String sjxs;
/**讲座学时*/
@Excel(name = "讲座学时", width = 15)
@ApiModelProperty(value = "讲座学时")
private java.lang.String jzxs;
/**讲课学时*/
@Excel(name = "讲课学时", width = 15)
@ApiModelProperty(value = "讲课学时")
private java.lang.String jkxs;
/**学生人数*/
@Excel(name = "学生人数", width = 15)
@ApiModelProperty(value = "学生人数")
private java.lang.String xsrs;
/**样本总数*/
@Excel(name = "样本总数", width = 15)
@ApiModelProperty(value = "样本总数")
private java.lang.String ybzs;
/**参评率(%*/
@Excel(name = "参评率(%", width = 15)
@ApiModelProperty(value = "参评率(%")
private java.lang.String cpl;
/**有效数*/
@Excel(name = "有效数", width = 15)
@ApiModelProperty(value = "有效数")
private java.lang.String yxs;
/**综合评价*/
@Excel(name = "综合评价", width = 15)
@ApiModelProperty(value = "综合评价")
private java.lang.String zhpj;
/**重视学生的成长引领,关心学生的学习需求,乐于与学生交流。*/
@Excel(name = "重视学生的成长引领,关心学生的学习需求,乐于与学生交流。", width = 15)
@ApiModelProperty(value = "重视学生的成长引领,关心学生的学习需求,乐于与学生交流。")
private java.lang.String col1;
/**上课准备充分。课堂教学秩序良好。作业布置合理,反馈及时。*/
@Excel(name = "上课准备充分。课堂教学秩序良好。作业布置合理,反馈及时。", width = 15)
@ApiModelProperty(value = "上课准备充分。课堂教学秩序良好。作业布置合理,反馈及时。")
private java.lang.String col2;
/**教学目标明确,重点突出,逻辑性强*/
@Excel(name = "教学目标明确,重点突出,逻辑性强", width = 15)
@ApiModelProperty(value = "教学目标明确,重点突出,逻辑性强")
private java.lang.String col3;
/**教学内容清晰易懂,体现适当的深度、广度和前沿性。*/
@Excel(name = "教学内容清晰易懂,体现适当的深度、广度和前沿性。", width = 15)
@ApiModelProperty(value = "教学内容清晰易懂,体现适当的深度、广度和前沿性。")
private java.lang.String col4;
/**教学方法合理。教学媒体得当,课程资源丰富。*/
@Excel(name = "教学方法合理。教学媒体得当,课程资源丰富。", width = 15)
@ApiModelProperty(value = "教学方法合理。教学媒体得当,课程资源丰富。")
private java.lang.String col5;
/**教师知识渊博,教学水平高,教学特色鲜明,教学有吸引力。*/
@Excel(name = "教师知识渊博,教学水平高,教学特色鲜明,教学有吸引力。", width = 15)
@ApiModelProperty(value = "教师知识渊博,教学水平高,教学特色鲜明,教学有吸引力。")
private java.lang.String col6;
/**教学语言规范、准确,情绪饱满,热忱投入,为人师表*/
@Excel(name = "教学语言规范、准确,情绪饱满,热忱投入,为人师表", width = 15)
@ApiModelProperty(value = "教学语言规范、准确,情绪饱满,热忱投入,为人师表")
private java.lang.String col7;
/**教学中启发学生思考,引导自主学习,激发学习动力,鼓励创新探索。*/
@Excel(name = "教学中启发学生思考,引导自主学习,激发学习动力,鼓励创新探索。", width = 15)
@ApiModelProperty(value = "教学中启发学生思考,引导自主学习,激发学习动力,鼓励创新探索。")
private java.lang.String col8;
/**掌握了所学课程的基础知识和基本理论,能用所学知识解决实际问题。*/
@Excel(name = "掌握了所学课程的基础知识和基本理论,能用所学知识解决实际问题。", width = 15)
@ApiModelProperty(value = "掌握了所学课程的基础知识和基本理论,能用所学知识解决实际问题。")
private java.lang.String col9;
/**体会到本门课程学习的乐趣和挑战,理解课程内容的意义与价值。*/
@Excel(name = "体会到本门课程学习的乐趣和挑战,理解课程内容的意义与价值。", width = 15)
@ApiModelProperty(value = "体会到本门课程学习的乐趣和挑战,理解课程内容的意义与价值。")
private java.lang.String col10;
/**学年学期*/
@Excel(name = "学年学期", width = 15)
@ApiModelProperty(value = "学年学期")
private java.lang.String xnxq;
}

View File

@ -0,0 +1,22 @@
package org.jeecg.modules.kc.kcXsktjxmydcp.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.kc.kcXsktjxmydcp.entity.KcXsktjxmydcp;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 学生课堂教学满意度测评
* @Author: jeecg-boot
* @Date: 2024-05-08
* @Version: V1.0
*/
public interface KcXsktjxmydcpMapper extends BaseMapper<KcXsktjxmydcp> {
IPage<KcXsktjxmydcp> groupByList(Page<KcXsktjxmydcp> page, @Param(Constants.WRAPPER) QueryWrapper<KcXsktjxmydcp> queryWrapper);
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.kc.kcXsktjxmydcp.mapper.KcXsktjxmydcpMapper">
<select id="groupByList" resultType="org.jeecg.modules.kc.kcXsktjxmydcp.entity.KcXsktjxmydcp">
select * from (
select * from kc_xsktjxmydcp GROUP BY kktzdh,kcbh,kcmc,jgh,skjs,kkdw
) a
${ew.customSqlSegment}
</select>
</mapper>

View File

@ -0,0 +1,18 @@
package org.jeecg.modules.kc.kcXsktjxmydcp.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.kc.kcXsktjxmydcp.entity.KcXsktjxmydcp;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 学生课堂教学满意度测评
* @Author: jeecg-boot
* @Date: 2024-05-08
* @Version: V1.0
*/
public interface IKcXsktjxmydcpService extends IService<KcXsktjxmydcp> {
IPage<KcXsktjxmydcp> groupByList(Page<KcXsktjxmydcp> page, QueryWrapper<KcXsktjxmydcp> queryWrapper);
}

View File

@ -0,0 +1,26 @@
package org.jeecg.modules.kc.kcXsktjxmydcp.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.kc.kcXsktjxmydcp.entity.KcXsktjxmydcp;
import org.jeecg.modules.kc.kcXsktjxmydcp.mapper.KcXsktjxmydcpMapper;
import org.jeecg.modules.kc.kcXsktjxmydcp.service.IKcXsktjxmydcpService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 学生课堂教学满意度测评
* @Author: jeecg-boot
* @Date: 2024-05-08
* @Version: V1.0
*/
@Service
public class KcXsktjxmydcpServiceImpl extends ServiceImpl<KcXsktjxmydcpMapper, KcXsktjxmydcp> implements IKcXsktjxmydcpService {
@Override
public IPage<KcXsktjxmydcp> groupByList(Page<KcXsktjxmydcp> page, QueryWrapper<KcXsktjxmydcp> queryWrapper) {
return baseMapper.groupByList(page, queryWrapper);
}
}

View File

@ -257,7 +257,7 @@ public class KcKechengbiaoController extends JeecgController<KcKechengbiao, IKcK
queryWrapper.eq("jgh",sysUser.getUsername());
queryWrapper.orderByAsc("kcmc,week");
Page<KcKechengbiao> page = new Page<KcKechengbiao>(pageNo, pageSize);
IPage<KcKechengbiao> pageList = kcKechengbiaoService.page(page, queryWrapper);
IPage<KcKechengbiao> pageList = kcKechengbiaoService.getKechengbiaolist(page, queryWrapper);
return Result.OK(pageList);
}

View File

@ -39,4 +39,6 @@ public interface KcKechengbiaoMapper extends BaseMapper<KcKechengbiao> {
void updateAllFlag(KcKechengbiao kcKechengbiao);
void updateYxByXxhbkckb(KcKechengbiao kcbAll);
IPage<KcKechengbiao> getKechengbiaolist(Page<KcKechengbiao> page,@Param(Constants.WRAPPER) QueryWrapper<KcKechengbiao> queryWrapper);
}

View File

@ -54,7 +54,7 @@
<select id="listGroupBy" resultType="org.jeecg.modules.kc.ktgl.entity.KcKechengbiao">
select * from (
select kcbh,kcmc,kkdw,kcxz,szkc from kc_kechengbiao GROUP BY kcbh,kcmc,kkdw,kcxz,szkc
select kcbh,kcmc,kkdw,kcxz,szkc,xqxn from kc_kechengbiao GROUP BY kcbh,kcmc,kkdw,kcxz,szkc,xqxn
) a
${ew.customSqlSegment}
@ -136,4 +136,47 @@
and b.jkzc = substring(a.jkzc,2,length(a.jkzc)-2)
and a.XNXQ = b.xnxq
</update>
<select id="getKechengbiaolist" resultType="org.jeecg.modules.kc.ktgl.entity.KcKechengbiao">
SELECT
kcbh,
kcmc,
kkdw,
kcxz,
szkc,
xqxn,
rwbh,
skdd,
xkrs,
func_jc(GROUP_CONCAT( sksj
)) AS sksj
FROM
(
SELECT DISTINCT
kcbh,
kcmc,
kkdw,
kcxz,
szkc,
xqxn,
rwbh,
skdd,
xkrs,
concat (
WEEK,
REPLACE ( hh, '、', '' ))
AS sksj
FROM
kc_kechengbiao
${ew.customSqlSegment}
) t
GROUP BY
kcbh,
kcmc,
kkdw,
kcxz,
szkc,
xqxn
</select>
</mapper>

View File

@ -37,4 +37,6 @@ public interface IKcKechengbiaoService extends IService<KcKechengbiao> {
void updateAllFlag(KcKechengbiao kcKechengbiao);
void updateYxByXxhbkckb(KcKechengbiao kcbAll);
IPage<KcKechengbiao> getKechengbiaolist(Page<KcKechengbiao> page, QueryWrapper<KcKechengbiao> queryWrapper);
}

View File

@ -75,4 +75,9 @@ public class KcKechengbiaoServiceImpl extends ServiceImpl<KcKechengbiaoMapper, K
baseMapper.updateYxByXxhbkckb(kcbAll);
}
@Override
public IPage<KcKechengbiao> getKechengbiaolist(Page<KcKechengbiao> page, QueryWrapper<KcKechengbiao> queryWrapper) {
return baseMapper.getKechengbiaolist(page,queryWrapper);
}
}

View File

@ -0,0 +1,178 @@
package org.jeecg.modules.kc.zyCcjg.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.kc.zyCcjg.entity.ZyCcjg;
import org.jeecg.modules.kc.zyCcjg.service.IZyCcjgService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 查重结果
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
@Api(tags="查重结果")
@RestController
@RequestMapping("/zyCcjg/zyCcjg")
@Slf4j
public class ZyCcjgController extends JeecgController<ZyCcjg, IZyCcjgService> {
@Autowired
private IZyCcjgService zyCcjgService;
/**
* 分页列表查询
*
* @param zyCcjg
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "查重结果-分页列表查询")
@ApiOperation(value="查重结果-分页列表查询", notes="查重结果-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<ZyCcjg>> queryPageList(ZyCcjg zyCcjg,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<ZyCcjg> queryWrapper = QueryGenerator.initQueryWrapper(zyCcjg, req.getParameterMap());
Page<ZyCcjg> page = new Page<ZyCcjg>(pageNo, pageSize);
IPage<ZyCcjg> pageList = zyCcjgService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param zyCcjg
* @return
*/
@AutoLog(value = "查重结果-添加")
@ApiOperation(value="查重结果-添加", notes="查重结果-添加")
@RequiresPermissions("zyCcjg:zy_ccjg:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody ZyCcjg zyCcjg) {
zyCcjgService.save(zyCcjg);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param zyCcjg
* @return
*/
@AutoLog(value = "查重结果-编辑")
@ApiOperation(value="查重结果-编辑", notes="查重结果-编辑")
@RequiresPermissions("zyCcjg:zy_ccjg:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody ZyCcjg zyCcjg) {
zyCcjgService.updateById(zyCcjg);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "查重结果-通过id删除")
@ApiOperation(value="查重结果-通过id删除", notes="查重结果-通过id删除")
@RequiresPermissions("zyCcjg:zy_ccjg:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
zyCcjgService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "查重结果-批量删除")
@ApiOperation(value="查重结果-批量删除", notes="查重结果-批量删除")
@RequiresPermissions("zyCcjg:zy_ccjg:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.zyCcjgService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "查重结果-通过id查询")
@ApiOperation(value="查重结果-通过id查询", notes="查重结果-通过id查询")
@GetMapping(value = "/queryById")
public Result<ZyCcjg> queryById(@RequestParam(name="id",required=true) String id) {
ZyCcjg zyCcjg = zyCcjgService.getById(id);
if(zyCcjg==null) {
return Result.error("未找到对应数据");
}
return Result.OK(zyCcjg);
}
/**
* 导出excel
*
* @param request
* @param zyCcjg
*/
@RequiresPermissions("zyCcjg:zy_ccjg:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, ZyCcjg zyCcjg) {
return super.exportXls(request, zyCcjg, ZyCcjg.class, "查重结果");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("zyCcjg:zy_ccjg:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, ZyCcjg.class);
}
}

View File

@ -0,0 +1,146 @@
package org.jeecg.modules.kc.zyCcjg.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 查重结果
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
@Data
@TableName("zy_ccjg")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="zy_ccjg对象", description="查重结果")
public class ZyCcjg implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@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;
/**updateTime*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "updateTime")
private java.util.Date updateTime;
/**学生作业*/
@Excel(name = "学生作业", width = 15)
@ApiModelProperty(value = "学生作业")
private java.lang.String zyStuId;
/**文档id
*/
@Excel(name = "文档id", width = 15)
@ApiModelProperty(value = "文档id")
private java.lang.String paperid;
/**报告编号*/
@Excel(name = "报告编号", width = 15)
@ApiModelProperty(value = "报告编号")
private java.lang.String paperguid;
/**文件名
*/
@Excel(name = "文件名", width = 15)
@ApiModelProperty(value = "文件名")
private java.lang.String papertitle;
/**检测状态(1:检测中,2:检测完成,3:检测失败,0:未检测)
*/
@Excel(name = "检测状态(1:检测中,2:检测完成,3:检测失败,0:未检测)", width = 15)
@ApiModelProperty(value = "检测状态(1:检测中,2:检测完成,3:检测失败,0:未检测)")
private java.lang.String filestateid;
/**检测进度*/
@Excel(name = "检测进度", width = 15)
@ApiModelProperty(value = "检测进度")
private java.lang.String detectprogress;
/**相似率
*/
@Excel(name = "相似率", width = 15)
@ApiModelProperty(value = "相似率")
private java.lang.String percentage;
/**引用率*/
@Excel(name = "引用率", width = 15)
@ApiModelProperty(value = "引用率")
private java.lang.String quotepercentage;
/**复写率*/
@Excel(name = "复写率", width = 15)
@ApiModelProperty(value = "复写率")
private java.lang.String duplicatepercentage;
/**自写率*/
@Excel(name = "自写率", width = 15)
@ApiModelProperty(value = "自写率")
private java.lang.String ownpercentage;
/**文档检测完成时间
*/
@Excel(name = "文档检测完成时间", width = 15)
@ApiModelProperty(value = "文档检测完成时间")
private java.lang.String checkdate;
/**论文字数
*/
@Excel(name = "论文字数", width = 15)
@ApiModelProperty(value = "论文字数")
private java.lang.String paperword;
/**在线报告查看地址*/
@Excel(name = "在线报告查看地址", width = 15)
@ApiModelProperty(value = "在线报告查看地址")
private java.lang.String paperviewurl;
/**报告下载地址
*/
@Excel(name = "报告下载地址", width = 15)
@ApiModelProperty(value = "报告下载地址")
private java.lang.String paperdownurl;
/**他引率
*/
@Excel(name = "他引率", width = 15)
@ApiModelProperty(value = "他引率")
private java.lang.String otherquoterate;
/**自引率
*/
@Excel(name = "自引率", width = 15)
@ApiModelProperty(value = "自引率")
private java.lang.String selfquoterate;
/**专业术语率
*/
@Excel(name = "专业术语率", width = 15)
@ApiModelProperty(value = "专业术语率")
private java.lang.String proWordRate;
/**查重类型0外网 1内网 2aigc*/
@Excel(name = "查重类型0外网 1内网 2aigc", width = 15)
@ApiModelProperty(value = "查重类型0外网 1内网 2aigc")
private java.lang.String ccType;
private java.lang.String bdkbs;//比对库标识
private java.lang.String aiRate;//疑似ai全文占比
private java.lang.String humanRate;//人工占比
private java.lang.String message;//
private java.lang.String paichupercentage;//他引率
private java.lang.String authorpercentage;//专业术语率
@TableField(exist = false)
private String cateid;
}

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.kc.zyCcjg.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.kc.zyCcjg.entity.ZyCcjg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 查重结果
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
public interface ZyCcjgMapper extends BaseMapper<ZyCcjg> {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.kc.zyCcjg.mapper.ZyCcjgMapper">
</mapper>

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.kc.zyCcjg.service;
import org.jeecg.modules.kc.zyCcjg.entity.ZyCcjg;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 查重结果
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
public interface IZyCcjgService extends IService<ZyCcjg> {
void getCcjg();
}

View File

@ -0,0 +1,485 @@
package org.jeecg.modules.kc.zyCcjg.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.kc.blZycc.entity.BlZycc;
import org.jeecg.modules.kc.zyCcjg.entity.ZyCcjg;
import org.jeecg.modules.kc.zyCcjg.mapper.ZyCcjgMapper;
import org.jeecg.modules.kc.zyCcjg.service.IZyCcjgService;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
import org.jeecg.modules.kc.zyInfo.service.IZyInfoService;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import org.jeecg.modules.kc.zyInfoStudent.service.IZyInfoStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.activation.MimetypesFileTypeMap;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Description: 查重结果
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
@Service
public class ZyCcjgServiceImpl extends ServiceImpl<ZyCcjgMapper, ZyCcjg> implements IZyCcjgService {
private static String uploadpath;
@Value("${jeecg.path.upload}")
public void setUploadPath(String uploadPath) {
this.uploadpath = uploadPath;
}
private static String weipuId;
@Value("${weipu.userId}")
public void setWeipuId(String weipuId) {
this.weipuId = weipuId;
}
private static String weipuKey;
@Value("${weipu.userKey}")
public void setWeipuKey(String weipuKey) {
this.weipuKey = weipuKey;
}
@Autowired
private IZyInfoService zyInfoService;
@Autowired
private IZyInfoStudentService zyInfoStudentService;
@Override
public void getCcjg() {
QueryWrapper<ZyCcjg> zyCcjgQueryWrapper = new QueryWrapper<>();
zyCcjgQueryWrapper.in("filestateid",0,1,3);//检测状态(1:检测中,2:检测完成,3:检测失败,0:未检测)
List<ZyCcjg> list = baseMapper.selectList(zyCcjgQueryWrapper);
for(ZyCcjg par : list){
//查重类型0外网 1内网 2aigc
if(StringUtils.equals(par.getCcType(), "0")){
wwCxjcjg(par);
}else if(StringUtils.equals(par.getCcType(), "1")){
xfwbdCxjcjg(par);
}else if(StringUtils.equals(par.getCcType(), "2")){
aigcCxjcjg(par);
}
}
}
public Map<String,String> aigcCxjcjg(ZyCcjg zyCcjg) {
String url = "https://vims.fanyu.com/tool/AIGCCheck/searchPaper";
//文件路径文件存在不存在的话需要先下载下来
String paperid = zyCcjg.getPaperid();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("userid", weipuId);
textMap.put("sign", sign);
textMap.put("paperids", paperid);//资源id,可多个用逗号分割
String contentType = "";//image/png
Map<String, String> fileMap = new HashMap<String, String>();
String ret = formUpload(url, textMap, fileMap,contentType);
System.out.println("1-------->"+ret);
JSONObject object= JSONObject.parseObject(ret);
if("true".equals(object.getString("success"))){
//{"success":true,"message":"查询成功", "datalist":[{"dataid":568,"message":"","paperguid":"5c384d6bd69y9ba9","papertitle":"","filestateid":2,"paperword":1958,"percentage":0,"duplicatepercentage":0,"quotepercentage":0,"paichupercentage":0,"selfyypercentage":0,"ownpercentage":100,"authorpercentage":0,"checkdate":"2024-04-13 13:51:51","paperviewurl":"https://vims.fanyu.com/toole/smallcheck/getonlineurl?guid=5c384d6bd69y9ba9","paperdownurl":"https://vims.fanyu.com/toole/smallcheck/getdownloadurl?guid=5c384d6bd69y9ba9"}]}
//filestateid 检测状态{0未检测,1检测中,2检测完成, 3检测失败}
String listpaper = object.getString("listpaper");
JSONArray jsonArray = (JSONArray) JSONArray.parse(listpaper);
JSONObject object2= jsonArray.getJSONObject(0);
String filestateid = object2.getString("filestateid");
if(StringUtils.equals(filestateid,"0")){
System.out.println(paperid+":未检测");
}else if(StringUtils.equals(filestateid,"1")){
System.out.println(paperid+":检测中");
}else if(StringUtils.equals(filestateid,"2")){
System.out.println(paperid+":检测完成");
}else if(StringUtils.equals(filestateid,"3")){
System.out.println(paperid+":检测失败;"+object2.getString("message"));
}else{
System.out.println(paperid+":当前状态:"+filestateid+""+object2.getString("message"));
}
System.out.println("listpaper----->"+listpaper);//结果结合
System.out.println("object2----->"+object2);//实际单挑数据结果
Map<String,String> map = new HashMap<String,String>();
zyCcjg.setPaperguid(object2.getString("paperguid"));//报告编号
zyCcjg.setPapertitle(object2.getString("papertitle"));//论文标题
zyCcjg.setFilestateid(object2.getString("filestateid"));//检测状态0:未检测1:检测中2:检测完成3:检测失败
zyCcjg.setCheckdate(object2.getString("checkdate"));//检测时间
zyCcjg.setPaperword(object2.getString("paperword"));//论文字数
zyCcjg.setAiRate(object2.getString("aiRate"));//疑似ai全文占比
zyCcjg.setHumanRate(object2.getString("humanRate"));//人工占比
zyCcjg.setPaperviewurl(object2.getString("paperviewurl"));//报告在线查看地址
zyCcjg.setPaperdownurl(object2.getString("paperdownurl"));//报告下载地址
zyCcjg.setMessage(object2.getString("message"));
baseMapper.updateById(zyCcjg);
//----------计算通过率--------------
if(StringUtils.equals("2",object2.getString("filestateid"))){
String stuId = zyCcjg.getZyStuId();
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(stuId);
ZyInfo zyInfo = zyInfoService.getById(zyInfoStudent.getMainId());
Double tgl = 0.0;
if(zyInfo.getAigctgl()>0){
tgl = zyInfo.getAigctgl();
}
Double cctgl = 0.0;
if(StringUtils.isNotEmpty(object2.getString("aiRate"))){
cctgl = Double.parseDouble(object2.getString("aiRate"));
}
if(tgl > cctgl || tgl == 0){
zyInfoStudent.setAigcsftg("通过");
}else{
zyInfoStudent.setAigcsftg("未通过");
}
zyInfoStudent.setAigcxsl(cctgl+"");
zyInfoStudentService.updateById(zyInfoStudent);
}
//----------计算通过率--------------
map.put("success","true");
map.put("message",object.getString("message"));
return map;
}else{
System.out.println("3-------->");
Map<String,String> map = new HashMap<String,String>();
map.put("success","false");
map.put("message",object.getString("message"));
return map;
}
}
public Map<String,String> wwCxjcjg(ZyCcjg zyCcjg) {
String url = "https://vims.fanyu.com/toole/jianceorgan/paperlist.aspx";
//文件路径文件存在不存在的话需要先下载下来
String paperid = zyCcjg.getPaperid();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("userid", weipuId);
textMap.put("sign", sign);
textMap.put("paperids", paperid);//资源id,可多个用逗号分割
String contentType = "";//image/png
Map<String, String> fileMap = new HashMap<String, String>();
String ret = formUpload(url, textMap, fileMap,contentType);
System.out.println("1-------->"+ret);
JSONObject object= JSONObject.parseObject(ret);
if("true".equals(object.getString("success"))){
//{"success":true,"message":"查询成功", "datalist":[{"dataid":568,"message":"","paperguid":"5c384d6bd69y9ba9","papertitle":"","filestateid":2,"paperword":1958,"percentage":0,"duplicatepercentage":0,"quotepercentage":0,"paichupercentage":0,"selfyypercentage":0,"ownpercentage":100,"authorpercentage":0,"checkdate":"2024-04-13 13:51:51","paperviewurl":"https://vims.fanyu.com/toole/smallcheck/getonlineurl?guid=5c384d6bd69y9ba9","paperdownurl":"https://vims.fanyu.com/toole/smallcheck/getdownloadurl?guid=5c384d6bd69y9ba9"}]}
//filestateid 检测状态{0未检测,1检测中,2检测完成, 3检测失败}
String listpaper = object.getString("listpaper");
JSONArray jsonArray = (JSONArray) JSONArray.parse(listpaper);
JSONObject object2= jsonArray.getJSONObject(0);
String filestateid = object2.getString("filestateid");
if(StringUtils.equals(filestateid,"0")){
System.out.println(paperid+":未检测");
}else if(StringUtils.equals(filestateid,"1")){
System.out.println(paperid+":检测中");
}else if(StringUtils.equals(filestateid,"2")){
System.out.println(paperid+":检测完成");
}else if(StringUtils.equals(filestateid,"3")){
System.out.println(paperid+":检测失败;"+object2.getString("message"));
}else{
System.out.println(paperid+":当前状态:"+filestateid+""+object2.getString("message"));
}
System.out.println("listpaper----->"+listpaper);//结果结合
System.out.println("object2----->"+object2);//实际单挑数据结果
Map<String,String> map = new HashMap<String,String>();
zyCcjg.setPaperguid(object2.getString("paperguid"));//报告编号
zyCcjg.setPapertitle(object2.getString("papertitle"));//论文标题
zyCcjg.setFilestateid(object2.getString("filestateid"));//检测状态0:未检测1:检测中2:检测完成3:检测失败
zyCcjg.setCheckdate(object2.getString("checkdate"));//检测时间
zyCcjg.setPaperword(object2.getString("paperword"));//论文字数
zyCcjg.setPaperviewurl(object2.getString("paperviewurl"));//报告在线查看地址
zyCcjg.setPaperdownurl(object2.getString("paperdownurl"));//报告下载地址
zyCcjg.setMessage(object2.getString("message"));
zyCcjg.setDuplicatepercentage(object2.getString("duplicatepercentage"));//复写率
zyCcjg.setPaichupercentage(object2.getString("paichupercentage"));//他引率
zyCcjg.setOwnpercentage(object2.getString("ownpercentage"));//自写率
zyCcjg.setPercentage(object2.getString("percentage"));//相似率
zyCcjg.setQuotepercentage(object2.getString("quotepercentage"));//引用率
zyCcjg.setSelfquoterate(object2.getString("selfyypercentage"));//自引率
zyCcjg.setAuthorpercentage(object2.getString("authorpercentage"));//专业术语率
baseMapper.updateById(zyCcjg);
//----------计算通过率--------------
if(StringUtils.equals("2",object2.getString("filestateid"))) {
String stuId = zyCcjg.getZyStuId();
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(stuId);
ZyInfo zyInfo = zyInfoService.getById(zyInfoStudent.getMainId());
Double tgl = 0.0;
if (zyInfo.getWwtgl() > 0) {
tgl = zyInfo.getWwtgl();
}
Double cctgl = 0.0;
if (StringUtils.isNotEmpty(object2.getString("percentage"))) {
cctgl = Double.parseDouble(object2.getString("percentage"));
}
if (tgl > cctgl || tgl == 0) {
zyInfoStudent.setWwsftg("通过");
} else {
zyInfoStudent.setWwsftg("未通过");
}
zyInfoStudent.setWwxsl(cctgl + "");
zyInfoStudentService.updateById(zyInfoStudent);
}
//----------计算通过率--------------
map.put("success","true");
map.put("message",object.getString("message"));
return map;
}else{
System.out.println("3-------->");
Map<String,String> map = new HashMap<String,String>();
map.put("success","false");
map.put("message",object.getString("message"));
return map;
}
}
//小范围比对查询检测结果
public Map<String,String> xfwbdCxjcjg(ZyCcjg zyCcjg) {
String url = "https://vims.fanyu.com/toole/smallcheck/searchCheckStatus";
//文件路径文件存在不存在的话需要先下载下来
String paperid = zyCcjg.getPaperid();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("userid", weipuId);
textMap.put("sign", sign);
textMap.put("cateid", zyCcjg.getBdkbs());//比对库的id
textMap.put("dataids", paperid);//资源id
String contentType = "";//image/png
Map<String, String> fileMap = new HashMap<String, String>();
String ret = formUpload(url, textMap, fileMap,contentType);
System.out.println("1-------->"+ret);
JSONObject object= JSONObject.parseObject(ret);
if("true".equals(object.getString("success"))){
//{"success":true,"message":"查询成功", "datalist":[{"dataid":568,"message":"","paperguid":"5c384d6bd69y9ba9","papertitle":"","filestateid":2,"paperword":1958,"percentage":0,"duplicatepercentage":0,"quotepercentage":0,"paichupercentage":0,"selfyypercentage":0,"ownpercentage":100,"authorpercentage":0,"checkdate":"2024-04-13 13:51:51","paperviewurl":"https://vims.fanyu.com/toole/smallcheck/getonlineurl?guid=5c384d6bd69y9ba9","paperdownurl":"https://vims.fanyu.com/toole/smallcheck/getdownloadurl?guid=5c384d6bd69y9ba9"}]}
//filestateid 检测状态{0未检测,1检测中,2检测完成, 3检测失败}
String listpaper = object.getString("datalist");
JSONArray jsonArray = (JSONArray) JSONArray.parse(listpaper);
JSONObject object2= jsonArray.getJSONObject(0);
String filestateid = object2.getString("filestateid");
if(StringUtils.equals(filestateid,"0")){
System.out.println(paperid+":未检测");
}else if(StringUtils.equals(filestateid,"1")){
System.out.println(paperid+":检测中");
}else if(StringUtils.equals(filestateid,"2")){
System.out.println(paperid+":检测完成");
}else if(StringUtils.equals(filestateid,"3")){
System.out.println(paperid+":检测失败;"+object2.getString("message"));
}else{
System.out.println(paperid+":当前状态:"+filestateid+""+object2.getString("message"));
}
System.out.println("listpaper----->"+listpaper);//结果结合
System.out.println("object2----->"+object2);//实际单挑数据结果
Map<String,String> map = new HashMap<String,String>();
zyCcjg.setPaperguid(object2.getString("paperguid"));//报告编号
zyCcjg.setPapertitle(object2.getString("papertitle"));//论文标题
zyCcjg.setFilestateid(object2.getString("filestateid"));//检测状态0:未检测1:检测中2:检测完成3:检测失败
zyCcjg.setCheckdate(object2.getString("checkdate"));//检测时间
zyCcjg.setPaperword(object2.getString("paperword"));//论文字数
zyCcjg.setPaperviewurl(object2.getString("paperviewurl"));//报告在线查看地址
zyCcjg.setPaperdownurl(object2.getString("paperdownurl"));//报告下载地址
zyCcjg.setMessage(object2.getString("message"));
zyCcjg.setDuplicatepercentage(object2.getString("duplicatepercentage"));//复写率
zyCcjg.setPaichupercentage(object2.getString("paichupercentage"));//他引率
zyCcjg.setOwnpercentage(object2.getString("ownpercentage"));//自写率
zyCcjg.setPercentage(object2.getString("percentage"));//相似率
zyCcjg.setQuotepercentage(object2.getString("quotepercentage"));//引用率
zyCcjg.setSelfquoterate(object2.getString("selfyypercentage"));//自引率
zyCcjg.setAuthorpercentage(object2.getString("authorpercentage"));//专业术语率
baseMapper.updateById(zyCcjg);
//----------计算通过率--------------
if(StringUtils.equals("2",object2.getString("filestateid"))) {
String stuId = zyCcjg.getZyStuId();
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(stuId);
ZyInfo zyInfo = zyInfoService.getById(zyInfoStudent.getMainId());
Double tgl = 0.0;
if (zyInfo.getNwtgl() > 0) {
tgl = zyInfo.getNwtgl();
}
Double cctgl = 0.0;
if (StringUtils.isNotEmpty(object2.getString("percentage"))) {
cctgl = Double.parseDouble(object2.getString("percentage"));
}
if (tgl > cctgl || tgl == 0) {
zyInfoStudent.setNwsftg("通过");
} else {
zyInfoStudent.setNwsftg("未通过");
}
zyInfoStudent.setNwxsl(cctgl + "");
zyInfoStudentService.updateById(zyInfoStudent);
}
//----------计算通过率--------------
map.put("success","true");
map.put("message",object.getString("message"));
return map;
}else{
System.out.println("3-------->");
Map<String,String> map = new HashMap<String,String>();
map.put("success","false");
map.put("message",object.getString("message"));
return map;
}
}
//生成sign
public static String getSign() {
String userid = weipuId;
String key = weipuKey;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
String time = sdf.format( new Date());
String md5Text = userid + key + time;
String sign = org.springframework.util.DigestUtils.md5DigestAsHex((md5Text).getBytes()).toLowerCase();
return sign;
}
/**
* 上传图片
* @param urlStr
* @param textMap
* @param fileMap
* @param contentType 没有传入文件类型默认采用application/octet-stream
* contentType非空采用filename匹配默认的图片类型
* @return 返回response数据
*/
@SuppressWarnings("rawtypes")
public static String formUpload(String urlStr, Map<String, String> textMap,
Map<String, String> fileMap,String contentType) {
String res = "";
HttpURLConnection conn = null;
// boundary就是request头和上传文件内容的分隔符
String BOUNDARY = "---------------------------123821742118716";
try {
URL url = new URL(urlStr);
conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(30000);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Type","multipart/form-data; boundary=" + BOUNDARY);
OutputStream out = new DataOutputStream(conn.getOutputStream());
// text
if (textMap != null) {
StringBuffer strBuf = new StringBuffer();
Iterator iter = textMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String inputName = (String) entry.getKey();
String inputValue = (String) entry.getValue();
if (inputValue == null) {
continue;
}
strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n");
strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"\r\n\r\n");
strBuf.append(inputValue);
}
out.write(strBuf.toString().getBytes(StandardCharsets.UTF_8));
}
// file
if (fileMap != null) {
Iterator iter = fileMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String inputName = (String) entry.getKey();
String inputValue = (String) entry.getValue();
if (inputValue == null) {
continue;
}
File file = new File(inputValue);
String filename = file.getName();
//没有传入文件类型同时根据文件获取不到类型默认采用application/octet-stream
contentType = new MimetypesFileTypeMap().getContentType(file);
//contentType非空采用filename匹配默认的图片类型
if(!"".equals(contentType)){
if (filename.endsWith(".png")) {
contentType = "image/png";
}else if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".jpe")) {
contentType = "image/jpeg";
}else if (filename.endsWith(".gif")) {
contentType = "image/gif";
}else if (filename.endsWith(".ico")) {
contentType = "image/image/x-icon";
}
}
if (contentType == null || "".equals(contentType)) {
contentType = "application/octet-stream";
}
StringBuffer strBuf = new StringBuffer();
strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n");
strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"; filename=\"" + filename + "\"\r\n");
strBuf.append("Content-Type:" + contentType + "\r\n\r\n");
out.write(strBuf.toString().getBytes());
DataInputStream in = new DataInputStream(new FileInputStream(file));
int bytes = 0;
byte[] bufferOut = new byte[1024];
while ((bytes = in.read(bufferOut)) != -1) {
out.write(bufferOut, 0, bytes);
}
in.close();
}
}
byte[] endData = ("\r\n--" + BOUNDARY + "--\r\n").getBytes();
out.write(endData);
out.flush();
out.close();
// 读取返回数据
StringBuffer strBuf = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
strBuf.append(line).append("\n");
}
res = strBuf.toString();
reader.close();
reader = null;
} catch (Exception e) {
System.out.println("发送POST请求出错。" + urlStr);
e.printStackTrace();
} finally {
if (conn != null) {
conn.disconnect();
conn = null;
}
}
return res;
}
}

View File

@ -0,0 +1,206 @@
package org.jeecg.modules.kc.zyInfo.controller;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.kc.kcSysConfig.entity.KcSysConfig;
import org.jeecg.modules.kc.kcSysConfig.service.IKcSysConfigService;
import org.jeecg.modules.kc.kcXqxnHistory.entity.KcXqxnHistory;
import org.jeecg.modules.kc.kcXqxnHistory.service.IKcXqxnHistoryService;
import org.jeecg.modules.kc.ktgl.entity.KcKechengbiao;
import org.jeecg.modules.kc.ktgl.service.IKcKechengbiaoService;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
import org.jeecg.modules.kc.zyInfo.service.IZyInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 作业发布
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
@Api(tags="作业发布")
@RestController
@RequestMapping("/zyInfo/zyInfo")
@Slf4j
public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
@Autowired
private IZyInfoService zyInfoService;
@Autowired
private IKcSysConfigService kcSysConfigService;
@Autowired
private IKcKechengbiaoService kcKechengbiaoService;
/**
* 分页列表查询
*
* @param zyInfo
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "作业发布-分页列表查询")
@ApiOperation(value="作业发布-分页列表查询", notes="作业发布-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<ZyInfo>> queryPageList(ZyInfo zyInfo,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<ZyInfo> queryWrapper = QueryGenerator.initQueryWrapper(zyInfo, req.getParameterMap());
if(StringUtils.isNotEmpty(zyInfo.getSflssj())){
String date = DateUtils.formatDate(new Date(),"yyyy-MM-dd");
if(StringUtils.equals("0",zyInfo.getSflssj())){//不是历史
queryWrapper.ge("end_time",date);
}else{//历史作业
queryWrapper.lt("end_time",date);
}
}
Page<ZyInfo> page = new Page<ZyInfo>(pageNo, pageSize);
IPage<ZyInfo> pageList = zyInfoService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param zyInfo
* @return
*/
@AutoLog(value = "作业发布-添加")
@ApiOperation(value="作业发布-添加", notes="作业发布-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody ZyInfo zyInfo) {
KcSysConfig kcSysConfig = kcSysConfigService.getById("1");
QueryWrapper<KcKechengbiao> kcKechengbiaoQueryWrapper = new QueryWrapper<>();
kcKechengbiaoQueryWrapper.eq("xqxn",kcSysConfig.getFlag1());
kcKechengbiaoQueryWrapper.eq("rwbh",zyInfo.getRwbh());
kcKechengbiaoQueryWrapper.last("limit 1");
KcKechengbiao kcKechengbiao = kcKechengbiaoService.getOne(kcKechengbiaoQueryWrapper);
zyInfo.setXnxq(kcSysConfig.getFlag1());
zyInfo.setZyStatus("0");
zyInfo.setXkxs(kcKechengbiao.getXkrs());
zyInfoService.save(zyInfo);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param zyInfo
* @return
*/
@AutoLog(value = "作业发布-编辑")
@ApiOperation(value="作业发布-编辑", notes="作业发布-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody ZyInfo zyInfo) {
zyInfoService.updateById(zyInfo);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "作业发布-通过id删除")
@ApiOperation(value="作业发布-通过id删除", notes="作业发布-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
zyInfoService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "作业发布-批量删除")
@ApiOperation(value="作业发布-批量删除", notes="作业发布-批量删除")
@RequiresPermissions("zyInfo:zy_info:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.zyInfoService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "作业发布-通过id查询")
@ApiOperation(value="作业发布-通过id查询", notes="作业发布-通过id查询")
@GetMapping(value = "/queryById")
public Result<ZyInfo> queryById(@RequestParam(name="id",required=true) String id) {
ZyInfo zyInfo = zyInfoService.getById(id);
if(zyInfo==null) {
return Result.error("未找到对应数据");
}
return Result.OK(zyInfo);
}
/**
* 导出excel
*
* @param request
* @param zyInfo
*/
@RequiresPermissions("zyInfo:zy_info:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, ZyInfo zyInfo) {
return super.exportXls(request, zyInfo, ZyInfo.class, "作业发布");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("zyInfo:zy_info:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, ZyInfo.class);
}
}

View File

@ -0,0 +1,122 @@
package org.jeecg.modules.kc.zyInfo.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 作业发布
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
@Data
@TableName("zy_info")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="zy_info对象", description="作业发布")
public class ZyInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@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;
/**updateTime*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "updateTime")
private java.util.Date updateTime;
/**作业名称*/
@Excel(name = "作业名称", width = 15)
@ApiModelProperty(value = "作业名称")
private java.lang.String title;
/**类型*/
@Excel(name = "类型", width = 15, dicCode = "zy_type")
@Dict(dicCode = "zy_type")
@ApiModelProperty(value = "类型")
private java.lang.String zyType;
/**描述*/
@Excel(name = "描述", width = 15)
@ApiModelProperty(value = "描述")
private java.lang.String content;
/**开始时间*/
@Excel(name = "开始时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "开始时间")
private java.util.Date startTime;
/**结束时间*/
@Excel(name = "结束时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "结束时间")
private java.util.Date endTime;
/**状态*/
@Excel(name = "状态", width = 15)
@ApiModelProperty(value = "状态")
@Dict(dicCode = "zy_status")
private java.lang.String zyStatus;
/**学年学期*/
@Excel(name = "学年学期", width = 15)
@ApiModelProperty(value = "学年学期")
private java.lang.String xnxq;
/**外网是否查重*/
@Excel(name = "外网是否查重", width = 15, dicCode = "yn")
@Dict(dicCode = "yn")
@ApiModelProperty(value = "外网是否查重")
private java.lang.String wwcc;
/**外网通过率*/
@Excel(name = "外网通过率", width = 15)
@ApiModelProperty(value = "外网通过率")
private java.lang.Double wwtgl;
/**内网查重*/
@Excel(name = "内网查重", width = 15, dicCode = "yn")
@Dict(dicCode = "yn")
@ApiModelProperty(value = "内网查重")
private java.lang.String nwcc;
/**内网通过率*/
@Excel(name = "内网通过率", width = 15)
@ApiModelProperty(value = "内网通过率")
private java.lang.Double nwtgl;
/**aigc查重*/
@Excel(name = "aigc查重", width = 15, dicCode = "yn")
@Dict(dicCode = "yn")
@ApiModelProperty(value = "aigc查重")
private java.lang.String aigccc;
/**aigc通过率*/
@Excel(name = "aigc通过率", width = 15)
@ApiModelProperty(value = "aigc通过率")
private java.lang.Double aigctgl;
private java.lang.String rwbh;
private java.lang.String filePath;
private java.lang.String xkxs;//选课学生
@TableField(exist = false)
private String sflssj;//是否历史数据
}

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.kc.zyInfo.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 作业发布
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
public interface ZyInfoMapper extends BaseMapper<ZyInfo> {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.kc.zyInfo.mapper.ZyInfoMapper">
</mapper>

View File

@ -0,0 +1,14 @@
package org.jeecg.modules.kc.zyInfo.service;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 作业发布
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
public interface IZyInfoService extends IService<ZyInfo> {
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.kc.zyInfo.service.impl;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
import org.jeecg.modules.kc.zyInfo.mapper.ZyInfoMapper;
import org.jeecg.modules.kc.zyInfo.service.IZyInfoService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 作业发布
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
@Service
public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> implements IZyInfoService {
}

View File

@ -0,0 +1,175 @@
package org.jeecg.modules.kc.zyInfoStudent.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import org.jeecg.modules.kc.zyInfoStudent.service.IZyInfoStudentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 学生提交作业
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
@Api(tags="学生提交作业")
@RestController
@RequestMapping("/zyInfoStudent/zyInfoStudent")
@Slf4j
public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyInfoStudentService> {
@Autowired
private IZyInfoStudentService zyInfoStudentService;
/**
* 分页列表查询
*
* @param zyInfoStudent
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "学生提交作业-分页列表查询")
@ApiOperation(value="学生提交作业-分页列表查询", notes="学生提交作业-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<ZyInfoStudent>> queryPageList(ZyInfoStudent zyInfoStudent,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<ZyInfoStudent> queryWrapper = QueryGenerator.initQueryWrapper(zyInfoStudent, req.getParameterMap());
Page<ZyInfoStudent> page = new Page<ZyInfoStudent>(pageNo, pageSize);
IPage<ZyInfoStudent> pageList = zyInfoStudentService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param zyInfoStudent
* @return
*/
@AutoLog(value = "学生提交作业-添加")
@ApiOperation(value="学生提交作业-添加", notes="学生提交作业-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody ZyInfoStudent zyInfoStudent) {
zyInfoStudentService.save(zyInfoStudent);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param zyInfoStudent
* @return
*/
@AutoLog(value = "学生提交作业-编辑")
@ApiOperation(value="学生提交作业-编辑", notes="学生提交作业-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody ZyInfoStudent zyInfoStudent) {
zyInfoStudentService.updateById(zyInfoStudent);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "学生提交作业-通过id删除")
@ApiOperation(value="学生提交作业-通过id删除", notes="学生提交作业-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
zyInfoStudentService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "学生提交作业-批量删除")
@ApiOperation(value="学生提交作业-批量删除", notes="学生提交作业-批量删除")
@RequiresPermissions("zyInfoStudent:zy_info_student:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.zyInfoStudentService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "学生提交作业-通过id查询")
@ApiOperation(value="学生提交作业-通过id查询", notes="学生提交作业-通过id查询")
@GetMapping(value = "/queryById")
public Result<ZyInfoStudent> queryById(@RequestParam(name="id",required=true) String id) {
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(id);
if(zyInfoStudent==null) {
return Result.error("未找到对应数据");
}
return Result.OK(zyInfoStudent);
}
/**
* 导出excel
*
* @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, "学生提交作业");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("zyInfoStudent:zy_info_student:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, ZyInfoStudent.class);
}
}

View File

@ -0,0 +1,93 @@
package org.jeecg.modules.kc.zyInfoStudent.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 学生提交作业
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
@Data
@TableName("zy_info_student")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="zy_info_student对象", description="学生提交作业")
public class ZyInfoStudent implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@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;
/**updateTime*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "updateTime")
private java.util.Date updateTime;
/**作业名称*/
@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;
@TableField(exist = false)
private String catename;
@TableField(exist = false)
private String cateid;
}

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.kc.zyInfoStudent.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 学生提交作业
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
public interface ZyInfoStudentMapper extends BaseMapper<ZyInfoStudent> {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.kc.zyInfoStudent.mapper.ZyInfoStudentMapper">
</mapper>

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.kc.zyInfoStudent.service;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 学生提交作业
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
public interface IZyInfoStudentService extends IService<ZyInfoStudent> {
public boolean save(ZyInfoStudent zyInfoStudent);
}

View File

@ -0,0 +1,431 @@
package org.jeecg.modules.kc.zyInfoStudent.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.kc.blZycc.entity.BlZycc;
import org.jeecg.modules.kc.kcSysConfig.entity.KcSysConfig;
import org.jeecg.modules.kc.kcSysConfig.service.IKcSysConfigService;
import org.jeecg.modules.kc.ktgl.entity.KcKechengbiao;
import org.jeecg.modules.kc.ktgl.service.IKcKechengbiaoService;
import org.jeecg.modules.kc.zyCcjg.entity.ZyCcjg;
import org.jeecg.modules.kc.zyCcjg.mapper.ZyCcjgMapper;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
import org.jeecg.modules.kc.zyInfo.service.IZyInfoService;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import org.jeecg.modules.kc.zyInfoStudent.mapper.ZyInfoStudentMapper;
import org.jeecg.modules.kc.zyInfoStudent.service.IZyInfoStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.activation.MimetypesFileTypeMap;
import java.io.*;
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;
/**
* @Description: 学生提交作业
* @Author: jeecg-boot
* @Date: 2024-05-06
* @Version: V1.0
*/
@Service
public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, ZyInfoStudent> implements IZyInfoStudentService {
@Autowired
private IZyInfoService zyInfoService;
@Autowired
private ZyCcjgMapper zyCcjgMapper;
@Autowired
private IKcKechengbiaoService kcKechengbiaoService;
private static String uploadpath;
@Value("${jeecg.path.upload}")
public void setUploadPath(String uploadPath) {
this.uploadpath = uploadPath;
}
private static String weipuId;
@Value("${weipu.userId}")
public void setWeipuId(String weipuId) {
this.weipuId = weipuId;
}
private static String weipuKey;
@Value("${weipu.userKey}")
public void setWeipuKey(String weipuKey) {
this.weipuKey = weipuKey;
}
@Override
public boolean save(ZyInfoStudent zyInfoStudent) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
zyInfoStudent.setStudentName(sysUser.getRealname());
baseMapper.insert(zyInfoStudent);
ZyInfo zyInfo = zyInfoService.getById(zyInfoStudent.getMainId());
String rwbh = zyInfo.getRwbh();
// KcSysConfig kcSysConfig = kcSysConfigService.getById("1");
QueryWrapper<KcKechengbiao> kcKechengbiaoQueryWrapper = new QueryWrapper<>();
kcKechengbiaoQueryWrapper.eq("xqxn",zyInfo.getXnxq());
kcKechengbiaoQueryWrapper.eq("rwbh",rwbh);
kcKechengbiaoQueryWrapper.last("limit 1");
KcKechengbiao kcKechengbiao = kcKechengbiaoService.getOne(kcKechengbiaoQueryWrapper);
String cateid = kcKechengbiao.getKcbh()+""+kcKechengbiao.getKcmc();
String catename = kcKechengbiao.getKcmc();
zyInfoStudent.setCateid(cateid);
zyInfoStudent.setCatename(catename);
//外网查重及提交检测
if(StringUtils.equals(zyInfo.getWwcc(),"1")){
wwccSave(zyInfoStudent);
}
//内网查重及提交检测
if(StringUtils.equals(zyInfo.getNwcc(),"1")){
nwccSave(zyInfoStudent);
}
//aigc查重及提交检测
if(StringUtils.equals(zyInfo.getAigccc(),"1")){
aigcSave(zyInfoStudent);
}
return true;
}
//aigc提交
private void aigcSave(ZyInfoStudent zyInfoStudent) {
String url = "https://vims.fanyu.com/tool/AIGCCheck/paperSubmit";
//文件路径文件存在不存在的话需要先下载下来
String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("userid", weipuId);
textMap.put("sign", sign);
String titlePar =fileName.substring(fileName.lastIndexOf("/")+1,fileName.length());
String title = titlePar.split("_")[0];
textMap.put("title", title);
textMap.put("number", "202405112244");
textMap.put("author", "测试作者B");
//设置file的name路径
Map<String, String> fileMap = new HashMap<String, String>();
fileMap.put("file", fileName);
String contentType = "";//image/png
String ret = formUpload(url, textMap, fileMap,contentType);
System.out.println("1-------->"+ret);
JSONObject object= JSONObject.parseObject(ret);
if("true".equals(object.getString("success"))){
String listpaper = object.getString("listPaper");
JSONArray jsonArray = (JSONArray) JSONArray.parse(listpaper);
JSONObject object2= jsonArray.getJSONObject(0);
String paperid = object2.getString("paperid");
System.out.println("2-------->"+paperid);
ZyCcjg zyCcjg = new ZyCcjg();
zyCcjg.setZyStuId(zyInfoStudent.getId());
zyCcjg.setPaperid(paperid);
zyCcjg.setCcType("2");//查重类型0外网 1内网 2aigc
zyCcjg.setFilestateid("1");
zyCcjgMapper.insert(zyCcjg);
//提交后直接开始检测
String message = aigcKsjc(zyCcjg);
System.out.println("21-------->"+message);
}else{
System.out.println("3-------->");
}
}
//aigc开始检测
public String aigcKsjc(ZyCcjg zyCcjg) {
String url = "https://vims.fanyu.com/tool/AIGCCheck/paperBeginCheck\n";
//文件路径文件存在不存在的话需要先下载下来
String paperid = zyCcjg.getPaperid();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("userid", weipuId);
textMap.put("sign", sign);
textMap.put("paperids", paperid);//资源id
String contentType = "";//image/png
Map<String, String> fileMap = new HashMap<String, String>();
String ret = formUpload(url, textMap, fileMap,contentType);
JSONObject object= JSONObject.parseObject(ret);
String message = object.getString("message");
return message;
}
//小范围提交校园内网提交
private void nwccSave(ZyInfoStudent zyInfoStudent) {
String url = "https://vims.fanyu.com/toole/smallcheck/submitData";
//文件路径文件存在不存在的话需要先下载下来
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];
//可以设置多个input的namevalue
String sign = getSign();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
textMap.put("sign", sign);
textMap.put("userid", weipuId);
textMap.put("title", title);//标题
textMap.put("author", sysUser.getRealname());//作者
textMap.put("cateid", zyInfoStudent.getCateid());//范围库唯一标识
textMap.put("catename", zyInfoStudent.getCatename());//范围库名称
textMap.put("number", sysUser.getUsername());//学号
//设置file的name路径
Map<String, String> fileMap = new HashMap<String, String>();
fileMap.put("file", fileName);
String contentType = "";//image/png
String ret = formUpload(url, textMap, fileMap,contentType);
JSONObject object= JSONObject.parseObject(ret);
if("true".equals(object.getString("success"))){
String listpaper = object.getString("datainfo");
JSONObject object2= JSON.parseObject(listpaper);
String dataid = object2.getString("dataid");//资源id 后续提交比对/删除文档会试用
ZyCcjg zyCcjg = new ZyCcjg();
zyCcjg.setZyStuId(zyInfoStudent.getId());
zyCcjg.setPaperid(dataid);
zyCcjg.setCcType("1");//查重类型0外网 1内网 2aigc
zyCcjg.setFilestateid("1");
zyCcjg.setBdkbs(zyInfoStudent.getCateid());
zyCcjgMapper.insert(zyCcjg);
//提交后直接开始检测
String message = xfwbdKsjc(zyCcjg);
System.out.println("21-------->"+message);
}else{
System.out.println("3-------->");
}
}
//小范围对比开始检测
public String xfwbdKsjc(ZyCcjg zyCcjg) {
String url = "https://vims.fanyu.com/toole/smallcheck/beginCheck";
//文件路径文件存在不存在的话需要先下载下来
String paperid = zyCcjg.getPaperid();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("sign", sign);
textMap.put("userid", weipuId);
textMap.put("cateid", zyCcjg.getBdkbs());//比对库的id
textMap.put("dataids", paperid);//资源id
String contentType = "";//image/png
Map<String, String> fileMap = new HashMap<String, String>();
String ret = formUpload(url, textMap, fileMap,contentType);
JSONObject object= JSONObject.parseObject(ret);
String message = object.getString("message");
return message;
}
//外网查重提交方法
private String wwccSave(ZyInfoStudent zyInfoStudent) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String url = "https://vims.fanyu.com/toole/jianceorgan/papersubmit.aspx";
//文件路径文件存在不存在的话需要先下载下来
String fileName = uploadpath+"/"+ zyInfoStudent.getFilePath();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("sign", sign);
textMap.put("userid", weipuId);
String titlePar =fileName.substring(fileName.lastIndexOf("/")+1,fileName.length());
String title = titlePar.split("_")[0];
textMap.put("title", title);
textMap.put("number", sysUser.getUsername());
textMap.put("author", sysUser.getRealname());
//设置file的name路径
Map<String, String> fileMap = new HashMap<String, String>();
fileMap.put("file", fileName);
String contentType = "";//image/png
String ret = formUpload(url, textMap, fileMap,contentType);
System.out.println("1-------->"+ret);
JSONObject object= JSONObject.parseObject(ret);
if("true".equals(object.getString("success"))){
String listpaper = object.getString("listpaper");
JSONArray jsonArray = (JSONArray) JSONArray.parse(listpaper);
JSONObject object2= jsonArray.getJSONObject(0);
String paperid = object2.getString("paperid");
System.out.println("2-------->"+paperid);
ZyCcjg zyCcjg = new ZyCcjg();
zyCcjg.setZyStuId(zyInfoStudent.getId());
zyCcjg.setPaperid(paperid);
zyCcjg.setCcType("0");//查重类型0外网 1内网 2aigc
zyCcjg.setFilestateid("1");
zyCcjgMapper.insert(zyCcjg);
//提交后直接开始检测
String message = wwKsjc(zyCcjg);
System.out.println("21-------->"+message);
return message;
}else{
System.out.println("3-------->");
return "false";
}
}
//外网开始检测
public String wwKsjc(ZyCcjg zyCcjg) {
String url = "https://vims.fanyu.com/toole/jianceorgan/paperbegincheck.aspx";
//文件路径文件存在不存在的话需要先下载下来
String paperid = zyCcjg.getPaperid();
Map<String, String> textMap = new HashMap<String, String>();
//可以设置多个input的namevalue
String sign = getSign();
textMap.put("userid", weipuId);
textMap.put("sign", sign);
textMap.put("paperids", paperid);//资源id
String contentType = "";//image/png
Map<String, String> fileMap = new HashMap<String, String>();
String ret = formUpload(url, textMap, fileMap,contentType);
JSONObject object= JSONObject.parseObject(ret);
String message = object.getString("message");
return message;
}
//生成sign
public static String getSign() {
String userid = weipuId;
String key = weipuKey;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
String time = sdf.format( new Date());
String md5Text = userid + key + time;
String sign = org.springframework.util.DigestUtils.md5DigestAsHex((md5Text).getBytes()).toLowerCase();
return sign;
}
//推送轻求
public static String formUpload(String urlStr, Map<String, String> textMap, Map<String, String> fileMap,String contentType) {
String res = "";
HttpURLConnection conn = null;
// boundary就是request头和上传文件内容的分隔符
String BOUNDARY = "---------------------------123821742118716";
try {
URL url = new URL(urlStr);
conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(30000);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Type","multipart/form-data; boundary=" + BOUNDARY);
OutputStream out = new DataOutputStream(conn.getOutputStream());
// text
if (textMap != null) {
StringBuffer strBuf = new StringBuffer();
Iterator iter = textMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String inputName = (String) entry.getKey();
String inputValue = (String) entry.getValue();
if (inputValue == null) {
continue;
}
strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n");
strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"\r\n\r\n");
strBuf.append(inputValue);
}
out.write(strBuf.toString().getBytes(StandardCharsets.UTF_8));
}
// file
if (fileMap != null) {
Iterator iter = fileMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String inputName = (String) entry.getKey();
String inputValue = (String) entry.getValue();
if (inputValue == null) {
continue;
}
File file = new File(inputValue);
String filename = file.getName();
//没有传入文件类型同时根据文件获取不到类型默认采用application/octet-stream
contentType = new MimetypesFileTypeMap().getContentType(file);
//contentType非空采用filename匹配默认的图片类型
if(!"".equals(contentType)){
if (filename.endsWith(".png")) {
contentType = "image/png";
}else if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".jpe")) {
contentType = "image/jpeg";
}else if (filename.endsWith(".gif")) {
contentType = "image/gif";
}else if (filename.endsWith(".ico")) {
contentType = "image/image/x-icon";
}
}
if (contentType == null || "".equals(contentType)) {
contentType = "application/octet-stream";
}
StringBuffer strBuf = new StringBuffer();
strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n");
strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"; filename=\"" + filename + "\"\r\n");
strBuf.append("Content-Type:" + contentType + "\r\n\r\n");
out.write(strBuf.toString().getBytes());
DataInputStream in = new DataInputStream(new FileInputStream(file));
int bytes = 0;
byte[] bufferOut = new byte[1024];
while ((bytes = in.read(bufferOut)) != -1) {
out.write(bufferOut, 0, bytes);
}
in.close();
}
}
byte[] endData = ("\r\n--" + BOUNDARY + "--\r\n").getBytes();
out.write(endData);
out.flush();
out.close();
// 读取返回数据
StringBuffer strBuf = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
strBuf.append(line).append("\n");
}
res = strBuf.toString();
reader.close();
reader = null;
} catch (Exception e) {
System.out.println("发送POST请求出错。" + urlStr);
e.printStackTrace();
} finally {
if (conn != null) {
conn.disconnect();
conn = null;
}
}
return res;
}
}