学生导入接口
This commit is contained in:
parent
97e8f30549
commit
0ef7780459
|
@ -32,6 +32,11 @@
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>-->
|
</dependency>-->
|
||||||
<!--达梦数据库 -->
|
<!--达梦数据库 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.dameng</groupId>
|
<groupId>com.dameng</groupId>
|
||||||
<artifactId>Dm8JdbcDriver18</artifactId>
|
<artifactId>Dm8JdbcDriver18</artifactId>
|
||||||
|
|
|
@ -0,0 +1,177 @@
|
||||||
|
package org.jeecg.modules.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
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 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.jeecg.modules.entity.Cet4_major;
|
||||||
|
import org.jeecg.modules.service.ICet4MajorService;
|
||||||
|
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.servlet.ModelAndView;
|
||||||
|
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: cet4_major
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2024-10-23
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Api(tags = "cet4_major")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/com/cet4Major")
|
||||||
|
@Slf4j
|
||||||
|
public class Cet4MajorController extends JeecgController<Cet4_major, ICet4MajorService> {
|
||||||
|
@Autowired
|
||||||
|
private ICet4MajorService cet4MajorService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param cet4Major
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "cet4_major-分页列表查询")
|
||||||
|
@ApiOperation(value = "cet4_major-分页列表查询", notes = "cet4_major-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<Cet4_major>> queryPageList(Cet4_major cet4Major,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<Cet4_major> queryWrapper = QueryGenerator.initQueryWrapper(cet4Major, req.getParameterMap());
|
||||||
|
Page<Cet4_major> page = new Page<Cet4_major>(pageNo, pageSize);
|
||||||
|
IPage<Cet4_major> pageList = cet4MajorService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param cet4Major
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cet4_major-添加")
|
||||||
|
@ApiOperation(value = "cet4_major-添加", notes = "cet4_major-添加")
|
||||||
|
@RequiresPermissions("com:cet4_major:add")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody Cet4_major cet4Major) {
|
||||||
|
cet4MajorService.save(cet4Major);
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param cet4Major
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cet4_major-编辑")
|
||||||
|
@ApiOperation(value = "cet4_major-编辑", notes = "cet4_major-编辑")
|
||||||
|
@RequiresPermissions("com:cet4_major:edit")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody Cet4_major cet4Major) {
|
||||||
|
cet4MajorService.updateById(cet4Major);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cet4_major-通过id删除")
|
||||||
|
@ApiOperation(value = "cet4_major-通过id删除", notes = "cet4_major-通过id删除")
|
||||||
|
@RequiresPermissions("com:cet4_major:delete")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
cet4MajorService.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cet4_major-批量删除")
|
||||||
|
@ApiOperation(value = "cet4_major-批量删除", notes = "cet4_major-批量删除")
|
||||||
|
@RequiresPermissions("com:cet4_major:deleteBatch")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||||
|
this.cet4MajorService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "cet4_major-通过id查询")
|
||||||
|
@ApiOperation(value = "cet4_major-通过id查询", notes = "cet4_major-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<Cet4_major> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
Cet4_major cet4Major = cet4MajorService.getById(id);
|
||||||
|
if (cet4Major == null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(cet4Major);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param cet4Major
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("com:cet4_major:exportXls")
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, Cet4_major cet4Major) {
|
||||||
|
return super.exportXls(request, cet4Major, Cet4_major.class, "cet4_major");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("com:cet4_major:importExcel")
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
return cet4MajorService.importStudentData(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("downloadTemplate")
|
||||||
|
@ApiOperation("四六级导入数据文件模版")
|
||||||
|
public Result<?> downloadTemplate(HttpServletResponse response) {
|
||||||
|
return cet4MajorService.downloadTemplate(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("loadTable")
|
||||||
|
@ApiOperation("加载表格")
|
||||||
|
public Result<?> loadTable() {
|
||||||
|
return cet4MajorService.loadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,73 +0,0 @@
|
||||||
package org.jeecg.modules.controller;
|
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
|
||||||
import org.jeecg.modules.entity.Cet4_major;
|
|
||||||
import org.jeecg.modules.entity.Cet_4;
|
|
||||||
import org.jeecg.modules.service.impl.CetMajorServiceImpl;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created with IntelliJ IDEA.
|
|
||||||
*
|
|
||||||
* @Author: Cool
|
|
||||||
* @Date: 2024/10/16/17:58
|
|
||||||
* @Description: 学生信息Controller
|
|
||||||
*/
|
|
||||||
@Api(tags = "cetStudent")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/cetStudent")
|
|
||||||
@Slf4j
|
|
||||||
public class CetStudentController extends JeecgController<Cet4_major, CetMajorServiceImpl> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CetMajorServiceImpl cetMajorService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出excel
|
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @param
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("cet:cetStudent:exportXls")
|
|
||||||
@RequestMapping(value = "/exportXls")
|
|
||||||
public ModelAndView exportXls(HttpServletRequest request, Cet4_major major) {
|
|
||||||
return super.exportXls(request, major, Cet4_major.class, "cet_4");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过excel导入数据
|
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @param response
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("cet:cetStudent:importExcel")
|
|
||||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
||||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
return super.importExcel(request, response, Cet4_major.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping("downloadTemplate")
|
|
||||||
@ApiOperation("四六级导入数据文件模版")
|
|
||||||
public Result<?> downloadTemplate(HttpServletResponse response) {
|
|
||||||
return cetMajorService.downloadTemplate(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping("loadTable")
|
|
||||||
@ApiOperation("加载表格")
|
|
||||||
public Result<?> loadTable() {
|
|
||||||
return cetMajorService.loadTable();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +1,78 @@
|
||||||
package org.jeecg.modules.entity;
|
package org.jeecg.modules.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cet4_major
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2024-10-23
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("cet4_major")
|
@TableName("cet4_major")
|
||||||
public class Cet4_major {
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="cet4_major对象", description="cet4_major")
|
||||||
|
public class Cet4_major implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**id*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Excel(name = "学号", width = 15)
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
private String id;
|
private String id;
|
||||||
|
/**name*/
|
||||||
|
@Excel(name = "姓名", width = 15)
|
||||||
|
@ApiModelProperty(value = "name")
|
||||||
private String name;
|
private String name;
|
||||||
|
/**college*/
|
||||||
|
@Excel(name = "上课院系", width = 15)
|
||||||
|
@ApiModelProperty(value = "college")
|
||||||
private String college;
|
private String college;
|
||||||
private String major_id;
|
/**majorId*/
|
||||||
|
@Excel(name = "专业号", width = 15)
|
||||||
|
@ApiModelProperty(value = "majorId")
|
||||||
|
private String majorId;
|
||||||
|
/**majorname*/
|
||||||
|
@Excel(name = "专业名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "majorname")
|
||||||
private String majorname;
|
private String majorname;
|
||||||
private String class_name;
|
/**className*/
|
||||||
|
@Excel(name = "班级", width = 15)
|
||||||
|
@ApiModelProperty(value = "className")
|
||||||
|
private String className;
|
||||||
|
/**educate*/
|
||||||
|
@Excel(name = "学制", width = 15)
|
||||||
|
@ApiModelProperty(value = "educate")
|
||||||
private String educate;
|
private String educate;
|
||||||
|
/**entrydate*/
|
||||||
|
@Excel(name = "当前所在级", width = 15)
|
||||||
|
@ApiModelProperty(value = "entrydate")
|
||||||
private String entrydate;
|
private String entrydate;
|
||||||
|
/**campus*/
|
||||||
|
@Excel(name = "校区", width = 15)
|
||||||
|
@ApiModelProperty(value = "campus")
|
||||||
private String campus;
|
private String campus;
|
||||||
|
/**state*/
|
||||||
|
@Excel(name = "在校状态", width = 15)
|
||||||
|
@ApiModelProperty(value = "state")
|
||||||
private String state;
|
private String state;
|
||||||
|
/**level*/
|
||||||
|
@Excel(name = "培养层次", width = 15)
|
||||||
|
@ApiModelProperty(value = "level")
|
||||||
private String level;
|
private String level;
|
||||||
|
/**category*/
|
||||||
|
@Excel(name = "学生类别", width = 15)
|
||||||
|
@ApiModelProperty(value = "category")
|
||||||
private String category;
|
private String category;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
package org.jeecg.modules.pojo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: Cool
|
||||||
|
* @Date: 2024/10/23/20:35
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CetStudent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ExcelProperty("学号")
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* name
|
||||||
|
*/
|
||||||
|
@ExcelProperty("姓名")
|
||||||
|
@ApiModelProperty(value = "name")
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* college
|
||||||
|
*/
|
||||||
|
@ExcelProperty("上课院系")
|
||||||
|
@ApiModelProperty(value = "college")
|
||||||
|
private String college;
|
||||||
|
/**
|
||||||
|
* majorId
|
||||||
|
*/
|
||||||
|
@ExcelProperty("专业号")
|
||||||
|
@ApiModelProperty(value = "majorId")
|
||||||
|
private String majorId;
|
||||||
|
/**
|
||||||
|
* majorname
|
||||||
|
*/
|
||||||
|
@ExcelProperty("专业名称")
|
||||||
|
@ApiModelProperty(value = "majorname")
|
||||||
|
private String majorname;
|
||||||
|
/**
|
||||||
|
* className
|
||||||
|
*/
|
||||||
|
@ExcelProperty("班级")
|
||||||
|
@ApiModelProperty(value = "className")
|
||||||
|
private String className;
|
||||||
|
/**
|
||||||
|
* educate
|
||||||
|
*/
|
||||||
|
@ExcelProperty("学制")
|
||||||
|
@ApiModelProperty(value = "educate")
|
||||||
|
private String educate;
|
||||||
|
/**
|
||||||
|
* entrydate
|
||||||
|
*/
|
||||||
|
@ExcelProperty("当前所在级")
|
||||||
|
@ApiModelProperty(value = "entrydate")
|
||||||
|
private String entrydate;
|
||||||
|
/**
|
||||||
|
* campus
|
||||||
|
*/
|
||||||
|
@ExcelProperty("校区")
|
||||||
|
@ApiModelProperty(value = "campus")
|
||||||
|
private String campus;
|
||||||
|
/**
|
||||||
|
* state
|
||||||
|
*/
|
||||||
|
@ExcelProperty("在校状态")
|
||||||
|
@ApiModelProperty(value = "state")
|
||||||
|
private String state;
|
||||||
|
/**
|
||||||
|
* level
|
||||||
|
*/
|
||||||
|
@ExcelProperty("培养层次")
|
||||||
|
@ApiModelProperty(value = "level")
|
||||||
|
private String level;
|
||||||
|
/**
|
||||||
|
* category
|
||||||
|
*/
|
||||||
|
@ExcelProperty("学生类别")
|
||||||
|
@ApiModelProperty(value = "category")
|
||||||
|
private String category;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.jeecg.modules.service;
|
||||||
|
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.entity.Cet4_major;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cet4_major
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2024-10-23
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface ICet4MajorService extends IService<Cet4_major> {
|
||||||
|
|
||||||
|
Result<?> downloadTemplate(HttpServletResponse response);
|
||||||
|
|
||||||
|
Result<?> loadTable();
|
||||||
|
|
||||||
|
Result<?> importStudentData(HttpServletRequest request);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,147 @@
|
||||||
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.entity.Cet4_major;
|
||||||
|
import org.jeecg.modules.mapper.Cet4_majorMapper;
|
||||||
|
import org.jeecg.modules.pojo.CetStudent;
|
||||||
|
import org.jeecg.modules.service.ICet4MajorService;
|
||||||
|
import org.jeecg.modules.utils.ExportUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cet4_major
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2024-10-23
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class Cet4MajorServiceImpl extends ServiceImpl<Cet4_majorMapper, Cet4_major> implements ICet4MajorService {
|
||||||
|
private final String CET_STUDENT_IMPORT_TEMPLATE = "template/cetStudentImportTemplate.xls";
|
||||||
|
private final String CET_STUDENT_FILE_TEMPLATE_NAME = "四六级学生信息导入模版.xlsx";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> downloadTemplate(HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
ExportUtil.downloadExcelTemplate(response, CET_STUDENT_FILE_TEMPLATE_NAME, CET_STUDENT_IMPORT_TEMPLATE);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> loadTable() {
|
||||||
|
QueryWrapper<Cet4_major> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.select("entrydate", "count(*) as studentNumber")
|
||||||
|
.groupBy("entrydate");
|
||||||
|
List<Map<String, Object>> list = this.listMaps(wrapper);
|
||||||
|
// 倒序排序
|
||||||
|
list = list.stream().filter(e -> e.get("entrydate") != null).collect(Collectors.toList());
|
||||||
|
list.sort(Comparator.comparing((Map<String, Object> o) -> ((String) o.get("entrydate"))).reversed());
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("data", list);
|
||||||
|
return Result.OK(jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> importStudentData(HttpServletRequest request) {
|
||||||
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||||
|
// 获取上传文件对象
|
||||||
|
MultipartFile file = entity.getValue();
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
// 文件为空,进行处理(例如,返回错误信息)
|
||||||
|
return Result.error("上传的文件为空!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
/**'
|
||||||
|
* 1. 读取表格
|
||||||
|
*/
|
||||||
|
ArrayList<CetStudent> furnitureArrayList = new ArrayList<>();
|
||||||
|
//使用EasyExcel读取excel文件
|
||||||
|
EasyExcel.read(file.getInputStream(), CetStudent.class, new AnalysisEventListener<CetStudent>() {
|
||||||
|
@Override
|
||||||
|
public void invoke(CetStudent furniture, AnalysisContext analysisContext) {
|
||||||
|
System.out.println(furniture);
|
||||||
|
// 将读取到的数据存储到 list 集合里
|
||||||
|
furnitureArrayList.add(furniture);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
// 读取完后的操作
|
||||||
|
}
|
||||||
|
}).excelType(ExcelTypeEnum.XLS).sheet().doRead();
|
||||||
|
System.out.println(furnitureArrayList);
|
||||||
|
/**
|
||||||
|
* 将表格list用set为实体类
|
||||||
|
*/
|
||||||
|
ArrayList<Cet4_major> rmsFurnitureArrayList = new ArrayList<>();
|
||||||
|
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||||
|
for (CetStudent cetStudent : furnitureArrayList) {
|
||||||
|
Cet4_major cet4Major = new Cet4_major();
|
||||||
|
cet4Major.setMajorId(cetStudent.getMajorId());
|
||||||
|
cet4Major.setMajorname(cetStudent.getMajorname());
|
||||||
|
cet4Major.setId(cetStudent.getId());
|
||||||
|
cet4Major.setName(cetStudent.getName());
|
||||||
|
cet4Major.setCollege(cetStudent.getCollege());
|
||||||
|
cet4Major.setClassName(cetStudent.getClassName());
|
||||||
|
cet4Major.setEducate(cetStudent.getEducate());
|
||||||
|
cet4Major.setEntrydate(cetStudent.getEntrydate());
|
||||||
|
cet4Major.setCampus(cetStudent.getCampus());
|
||||||
|
cet4Major.setState(cetStudent.getState());
|
||||||
|
cet4Major.setLevel(cetStudent.getLevel());
|
||||||
|
cet4Major.setCategory(cetStudent.getCategory());
|
||||||
|
|
||||||
|
rmsFurnitureArrayList.add(cet4Major);
|
||||||
|
}
|
||||||
|
System.out.println(rmsFurnitureArrayList.size());
|
||||||
|
/**
|
||||||
|
* 遍历list save
|
||||||
|
*/
|
||||||
|
saveBatch(rmsFurnitureArrayList, 10000);
|
||||||
|
System.out.println("插入成功");
|
||||||
|
Timestamp timestamp2 = new Timestamp(System.currentTimeMillis());
|
||||||
|
long millisecondsDiff = timestamp2.getTime() - timestamp.getTime();
|
||||||
|
long secondsDiff = millisecondsDiff / 1000;
|
||||||
|
System.out.println("时间差为:" + secondsDiff + " 秒");
|
||||||
|
return Result.ok("文件导入成功!数据行数:" + rmsFurnitureArrayList.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
||||||
|
String msg = e.getMessage();
|
||||||
|
log.error(msg, e);
|
||||||
|
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
|
||||||
|
return Result.error("文件导入失败:有重复数据!");
|
||||||
|
} else {
|
||||||
|
return Result.error("文件导入失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
file.getInputStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.error("文件导入失败!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,52 +0,0 @@
|
||||||
package org.jeecg.modules.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
|
||||||
import org.jeecg.modules.entity.Cet4_major;
|
|
||||||
import org.jeecg.modules.mapper.Cet4_majorMapper;
|
|
||||||
import org.jeecg.modules.utils.ExportUtil;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created with IntelliJ IDEA.
|
|
||||||
*
|
|
||||||
* @Author: Cool
|
|
||||||
* @Date: 2024/10/11/15:52
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Slf4j
|
|
||||||
public class CetMajorServiceImpl extends ServiceImpl<Cet4_majorMapper, Cet4_major> {
|
|
||||||
private final String CET_STUDENT_IMPORT_TEMPLATE = "template/cetStudentImportTemplate.xls";
|
|
||||||
private final String CET_STUDENT_FILE_TEMPLATE_NAME = "四六级学生信息导入模版.xlsx";
|
|
||||||
|
|
||||||
public Result<?> downloadTemplate(HttpServletResponse response) {
|
|
||||||
try {
|
|
||||||
ExportUtil.downloadExcelTemplate(response, CET_STUDENT_FILE_TEMPLATE_NAME, CET_STUDENT_IMPORT_TEMPLATE);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result<?> loadTable() {
|
|
||||||
QueryWrapper<Cet4_major> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.select("entrydate", "count(*) as count");
|
|
||||||
List<Map<String, Object>> list = this.listMaps(wrapper);
|
|
||||||
// 倒序排序
|
|
||||||
list.sort(Comparator.comparing((Map<String, Object> o) -> ((String) o.get("entrydate"))).reversed());
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
jsonObject.put("data", list);
|
|
||||||
return Result.OK(jsonObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,7 +18,6 @@ import org.jeecg.modules.mapper.Cet_4Mapper;
|
||||||
import org.jeecg.modules.service.CenterService;
|
import org.jeecg.modules.service.CenterService;
|
||||||
import org.jeecg.modules.service.CetCleanService;
|
import org.jeecg.modules.service.CetCleanService;
|
||||||
import org.jeecg.modules.service.ICet_4Service;
|
import org.jeecg.modules.service.ICet_4Service;
|
||||||
import org.jeecg.modules.utils.DateUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.jeecg.modules.service.impl;
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
@ -12,15 +11,14 @@ import org.jeecg.modules.entity.Cet_4;
|
||||||
import org.jeecg.modules.entity.Cet_6;
|
import org.jeecg.modules.entity.Cet_6;
|
||||||
import org.jeecg.modules.mapper.Cet_6Mapper;
|
import org.jeecg.modules.mapper.Cet_6Mapper;
|
||||||
import org.jeecg.modules.service.CenterService;
|
import org.jeecg.modules.service.CenterService;
|
||||||
|
import org.jeecg.modules.service.ICet4MajorService;
|
||||||
import org.jeecg.modules.service.ICet_6Service;
|
import org.jeecg.modules.service.ICet_6Service;
|
||||||
import org.jeecg.modules.utils.DateUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -36,13 +34,12 @@ public class Cet_6ServiceImpl extends ServiceImpl<Cet_6Mapper, Cet_6> implements
|
||||||
@Resource
|
@Resource
|
||||||
Cet_6Mapper cet6Mapper;
|
Cet_6Mapper cet6Mapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ICet4MajorService cet4MajorService;
|
||||||
@Autowired
|
@Autowired
|
||||||
Cet_4ServiceImpl cet4Service;
|
Cet_4ServiceImpl cet4Service;
|
||||||
@Autowired
|
@Autowired
|
||||||
CenterService centerService;
|
CenterService centerService;
|
||||||
@Autowired
|
|
||||||
CetMajorServiceImpl cetMajorService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<JSONObject> getRate(Cet_6 cet) {
|
public Result<JSONObject> getRate(Cet_6 cet) {
|
||||||
|
@ -94,9 +91,8 @@ public class Cet_6ServiceImpl extends ServiceImpl<Cet_6Mapper, Cet_6> implements
|
||||||
Set<String> passStudent = list.stream().map(Cet_6::getId).collect(Collectors.toSet());
|
Set<String> passStudent = list.stream().map(Cet_6::getId).collect(Collectors.toSet());
|
||||||
log.info("六级通过人数,{}", passStudent.size());
|
log.info("六级通过人数,{}", passStudent.size());
|
||||||
LambdaQueryWrapper<Cet4_major> majorWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Cet4_major> majorWrapper = new LambdaQueryWrapper<>();
|
||||||
majorWrapper.eq(Cet4_major::getEntrydate, "2020")
|
majorWrapper.eq(Cet4_major::getEntrydate, "2020").eq(Cet4_major::getState, "在校");
|
||||||
.eq(Cet4_major::getState, "在校");
|
List<Cet4_major> majorList = cet4MajorService.list(majorWrapper);
|
||||||
List<Cet4_major> majorList = cetMajorService.list(majorWrapper);
|
|
||||||
Set<String> allStudent = majorList.stream().map(Cet4_major::getId).collect(Collectors.toSet());
|
Set<String> allStudent = majorList.stream().map(Cet4_major::getId).collect(Collectors.toSet());
|
||||||
log.info("所有学生人数{}", allStudent.size());
|
log.info("所有学生人数{}", allStudent.size());
|
||||||
log.info("通过率,{}", (double) passStudent.size() / allStudent.size());
|
log.info("通过率,{}", (double) passStudent.size() / allStudent.size());
|
||||||
|
@ -113,8 +109,7 @@ public class Cet_6ServiceImpl extends ServiceImpl<Cet_6Mapper, Cet_6> implements
|
||||||
public Result<JSONObject> loadImportDataList() {
|
public Result<JSONObject> loadImportDataList() {
|
||||||
// 创建 QueryWrapper
|
// 创建 QueryWrapper
|
||||||
QueryWrapper<Cet_6> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Cet_6> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.select("batch", "COUNT(*) AS count")
|
queryWrapper.select("batch", "COUNT(*) AS count").groupBy("batch");
|
||||||
.groupBy("batch");
|
|
||||||
|
|
||||||
// 执行查询,获取结果列表
|
// 执行查询,获取结果列表
|
||||||
List<Map<String, Object>> list = this.listMaps(queryWrapper);
|
List<Map<String, Object>> list = this.listMaps(queryWrapper);
|
||||||
|
|
|
@ -45,8 +45,8 @@ spring:
|
||||||
clean-disabled: true
|
clean-disabled: true
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 10MB
|
max-file-size: 50MB
|
||||||
max-request-size: 10MB
|
max-request-size: 50MB
|
||||||
mail:
|
mail:
|
||||||
host: smtp.163.com
|
host: smtp.163.com
|
||||||
username: jeecgos@163.com
|
username: jeecgos@163.com
|
||||||
|
|
|
@ -45,8 +45,8 @@ spring:
|
||||||
clean-disabled: true
|
clean-disabled: true
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 10MB
|
max-file-size: 50MB
|
||||||
max-request-size: 10MB
|
max-request-size: 50MB
|
||||||
mail:
|
mail:
|
||||||
host: smtp.163.com
|
host: smtp.163.com
|
||||||
username: jeecgos@163.com
|
username: jeecgos@163.com
|
||||||
|
|
Loading…
Reference in New Issue