导入信息采集数据信息
This commit is contained in:
@ -9,10 +9,12 @@ import com.ruoyi.common.enums.BusinessType;
|
|||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.dw.domain.CjStudent;
|
import com.ruoyi.dw.domain.CjStudent;
|
||||||
|
import com.ruoyi.dw.domain.DwInfo;
|
||||||
import com.ruoyi.dw.service.ICjStudentService;
|
import com.ruoyi.dw.service.ICjStudentService;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -110,4 +112,20 @@ public class CjStudentController extends BaseController
|
|||||||
public AjaxResult confirmStudent(@PathVariable Long[] ids) {
|
public AjaxResult confirmStudent(@PathVariable Long[] ids) {
|
||||||
return toAjax(cjStudentService.confirmCjStudent(ids));
|
return toAjax(cjStudentService.confirmCjStudent(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入调查问卷数据
|
||||||
|
* @param file
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@PostMapping("/import")
|
||||||
|
public AjaxResult importData(MultipartFile file) throws Exception{
|
||||||
|
int successNum = cjStudentService.importData(file);
|
||||||
|
if (successNum > 0) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
}else {
|
||||||
|
return AjaxResult.error("导入失败,请检查信息采集内容是否正确");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
|||||||
* @author sunyg
|
* @author sunyg
|
||||||
* @date 2025-06-26
|
* @date 2025-06-26
|
||||||
*/
|
*/
|
||||||
public class CjStudent extends BaseEntity
|
public class CjStudent
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class CjStudent extends BaseEntity
|
|||||||
|
|
||||||
/** 毕业年份 */
|
/** 毕业年份 */
|
||||||
@Excel(name = "毕业年份")
|
@Excel(name = "毕业年份")
|
||||||
private Long bynf;
|
private int bynf;
|
||||||
|
|
||||||
/** 最高学历 */
|
/** 最高学历 */
|
||||||
@Excel(name = "最高学历")
|
@Excel(name = "最高学历")
|
||||||
@ -76,9 +76,6 @@ public class CjStudent extends BaseEntity
|
|||||||
@Excel(name = "荣誉是否展示")
|
@Excel(name = "荣誉是否展示")
|
||||||
private Long rysfzs;
|
private Long rysfzs;
|
||||||
|
|
||||||
/** 荣誉 */
|
|
||||||
private String ry;
|
|
||||||
|
|
||||||
/** 手机 */
|
/** 手机 */
|
||||||
@Excel(name = "手机")
|
@Excel(name = "手机")
|
||||||
private String sj;
|
private String sj;
|
||||||
@ -135,12 +132,12 @@ public class CjStudent extends BaseEntity
|
|||||||
return zy;
|
return zy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBynf(Long bynf)
|
public void setBynf(int bynf)
|
||||||
{
|
{
|
||||||
this.bynf = bynf;
|
this.bynf = bynf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getBynf()
|
public int getBynf()
|
||||||
{
|
{
|
||||||
return bynf;
|
return bynf;
|
||||||
}
|
}
|
||||||
@ -281,14 +278,6 @@ public class CjStudent extends BaseEntity
|
|||||||
this.sydshi = sydshi;
|
this.sydshi = sydshi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRy() {
|
|
||||||
return ry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRy(String ry) {
|
|
||||||
this.ry = ry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getXy() {
|
public String getXy() {
|
||||||
return xy;
|
return xy;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,13 @@ public interface CjStudentMapper
|
|||||||
*/
|
*/
|
||||||
public int insertCjStudent(CjStudent cjStudent);
|
public int insertCjStudent(CjStudent cjStudent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入
|
||||||
|
* @param cjStudents
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int insertCjStudentBatch(List<CjStudent> cjStudents);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改采集学生信息
|
* 修改采集学生信息
|
||||||
*
|
*
|
||||||
|
@ -2,6 +2,7 @@ package com.ruoyi.dw.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.dw.domain.CjStudent;
|
import com.ruoyi.dw.domain.CjStudent;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采集学生信息Service接口
|
* 采集学生信息Service接口
|
||||||
@ -65,4 +66,11 @@ public interface ICjStudentService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int confirmCjStudent(Long[] ids);
|
public int confirmCjStudent(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入调查问卷数据
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int importData(MultipartFile file);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package com.ruoyi.dw.service.impl;
|
package com.ruoyi.dw.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
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.ruoyi.dw.mapper.CjStudentMapper;
|
import com.ruoyi.dw.mapper.CjStudentMapper;
|
||||||
import com.ruoyi.dw.domain.CjStudent;
|
import com.ruoyi.dw.domain.CjStudent;
|
||||||
import com.ruoyi.dw.service.ICjStudentService;
|
import com.ruoyi.dw.service.ICjStudentService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采集学生信息Service业务层处理
|
* 采集学生信息Service业务层处理
|
||||||
@ -19,6 +26,9 @@ public class CjStudentServiceImpl implements ICjStudentService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CjStudentMapper cjStudentMapper;
|
private CjStudentMapper cjStudentMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询采集学生信息
|
* 查询采集学生信息
|
||||||
*
|
*
|
||||||
@ -96,4 +106,76 @@ public class CjStudentServiceImpl implements ICjStudentService
|
|||||||
return cjStudentMapper.confirmCjStudentByIds(ids);
|
return cjStudentMapper.confirmCjStudentByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int importData(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
Workbook workbook = WorkbookFactory.create(file.getInputStream());
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
int rows = sheet.getLastRowNum();
|
||||||
|
if (rows <= 0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
List<CjStudent> list = new ArrayList<>();
|
||||||
|
for (int i = 1; i <= rows; i++) {
|
||||||
|
//第一个调查问卷问题
|
||||||
|
Row row = sheet.getRow(i);
|
||||||
|
String id = row.getCell(0).getStringCellValue();
|
||||||
|
if (redisCache.hasKey(id)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CjStudent cjStudent = new CjStudent();
|
||||||
|
Cell cell15 = row.getCell(15);
|
||||||
|
cjStudent.setXm(cell15.getStringCellValue());
|
||||||
|
Cell cell16 = row.getCell(16);
|
||||||
|
cjStudent.setXb(cell16.getStringCellValue());
|
||||||
|
Cell cell17 = row.getCell(17);
|
||||||
|
cjStudent.setZy(cell17.getStringCellValue());
|
||||||
|
Cell cell18 = row.getCell(18);
|
||||||
|
cjStudent.setXy(cell18.getStringCellValue());
|
||||||
|
Cell cell19 = row.getCell(19);
|
||||||
|
cjStudent.setSydsh(cell19.getStringCellValue());
|
||||||
|
Cell cell20 = row.getCell(20);
|
||||||
|
cjStudent.setSydshi(cell20.getStringCellValue());
|
||||||
|
Cell cell21 = row.getCell(21);
|
||||||
|
cjStudent.setBynf(Integer.valueOf(cell21.getStringCellValue()));
|
||||||
|
Cell cell22 = row.getCell(22);
|
||||||
|
cjStudent.setZgyl(cell22.getStringCellValue());
|
||||||
|
Cell cell23 = row.getCell(23);
|
||||||
|
cjStudent.setGzdw(cell23.getStringCellValue());
|
||||||
|
Cell cell24 = row.getCell(24);
|
||||||
|
cjStudent.setDwxz(cell24.getStringCellValue());
|
||||||
|
Cell cell25 = row.getCell(25);
|
||||||
|
cjStudent.setDwdz(cell25.getStringCellValue());
|
||||||
|
Cell cell26 = row.getCell(26);
|
||||||
|
cjStudent.setZwjb(cell26.getStringCellValue());
|
||||||
|
Cell cell27 = row.getCell(27);
|
||||||
|
cjStudent.setShjz(cell27.getStringCellValue());
|
||||||
|
Cell cell28 = row.getCell(28);
|
||||||
|
cjStudent.setDbry(cell28.getStringCellValue());
|
||||||
|
Cell cell29 = row.getCell(29);
|
||||||
|
String sfzs = cell29.getStringCellValue();
|
||||||
|
if (sfzs.equals("是")){
|
||||||
|
cjStudent.setRysfzs(1L);
|
||||||
|
}else {
|
||||||
|
cjStudent.setRysfzs(0L);
|
||||||
|
}
|
||||||
|
Cell cell30 = row.getCell(30);
|
||||||
|
cjStudent.setSj(cell30.getStringCellValue());
|
||||||
|
Cell cell31 = row.getCell(31);
|
||||||
|
cjStudent.setYx(cell31.getStringCellValue());
|
||||||
|
cjStudent.setSfqr(1L);
|
||||||
|
cjStudent.setQt("");
|
||||||
|
list.add(cjStudent);
|
||||||
|
redisCache.setCacheObject(id, true);
|
||||||
|
}
|
||||||
|
if (list.isEmpty()){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
cjStudentMapper.insertCjStudentBatch(list);
|
||||||
|
return rows;
|
||||||
|
}catch (Exception e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="shjz" column="shjz" />
|
<result property="shjz" column="shjz" />
|
||||||
<result property="dbry" column="dbry" />
|
<result property="dbry" column="dbry" />
|
||||||
<result property="rysfzs" column="rysfzs" />
|
<result property="rysfzs" column="rysfzs" />
|
||||||
<result property="ry" column="ry" />
|
|
||||||
<result property="sj" column="sj" />
|
<result property="sj" column="sj" />
|
||||||
<result property="yx" column="yx" />
|
<result property="yx" column="yx" />
|
||||||
<result property="qt" column="qt" />
|
<result property="qt" column="qt" />
|
||||||
@ -29,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectCjStudentVo">
|
<sql id="selectCjStudentVo">
|
||||||
select id, xm,sydsh, sydshi, xb, zy,xy, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs, ry,sj, yx, qt, sfqr from cj_student
|
select id, xm, xb, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr from cj_student
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectCjStudentList" parameterType="CjStudent" resultMap="CjStudentResult">
|
<select id="selectCjStudentList" parameterType="CjStudent" resultMap="CjStudentResult">
|
||||||
@ -80,7 +79,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="shjz != null">shjz,</if>
|
<if test="shjz != null">shjz,</if>
|
||||||
<if test="dbry != null">dbry,</if>
|
<if test="dbry != null">dbry,</if>
|
||||||
<if test="rysfzs != null">rysfzs,</if>
|
<if test="rysfzs != null">rysfzs,</if>
|
||||||
<if test="ry != null">ry,</if>
|
|
||||||
<if test="sj != null">sj,</if>
|
<if test="sj != null">sj,</if>
|
||||||
<if test="yx != null">yx,</if>
|
<if test="yx != null">yx,</if>
|
||||||
<if test="qt != null">qt,</if>
|
<if test="qt != null">qt,</if>
|
||||||
@ -103,13 +101,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="dbry != null">#{dbry},</if>
|
<if test="dbry != null">#{dbry},</if>
|
||||||
<if test="rysfzs != null">#{rysfzs},</if>
|
<if test="rysfzs != null">#{rysfzs},</if>
|
||||||
<if test="ry != null">#{ry},</if>
|
<if test="ry != null">#{ry},</if>
|
||||||
<if test="sj != null">#{sj},</if>
|
|
||||||
<if test="yx != null">#{yx},</if>
|
<if test="yx != null">#{yx},</if>
|
||||||
<if test="qt != null">#{qt},</if>
|
<if test="qt != null">#{qt},</if>
|
||||||
<if test="sfqr != null">#{sfqr},</if>
|
<if test="sfqr != null">#{sfqr},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertCjStudentBatch" parameterType="list">
|
||||||
|
insert into cj_student
|
||||||
|
(xm, xb, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr)
|
||||||
|
VALUES
|
||||||
|
<foreach item="item" collection="list" separator=",">
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
#{item.xm},
|
||||||
|
#{item.xb},
|
||||||
|
#{item.zy},
|
||||||
|
#{item.xy},
|
||||||
|
#{item.sydsh},
|
||||||
|
#{item.sydshi},
|
||||||
|
#{item.bynf},
|
||||||
|
#{item.zgyl},
|
||||||
|
#{item.gzdw},
|
||||||
|
#{item.dwxz},
|
||||||
|
#{item.dwdz},
|
||||||
|
#{item.zwjb},
|
||||||
|
#{item.shjz},
|
||||||
|
#{item.dbry},
|
||||||
|
#{item.rysfzs},
|
||||||
|
#{item.sj},
|
||||||
|
#{item.yx},
|
||||||
|
#{item.qt},
|
||||||
|
#{item.sfqr}
|
||||||
|
</trim>
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateCjStudent" parameterType="CjStudent">
|
<update id="updateCjStudent" parameterType="CjStudent">
|
||||||
update cj_student
|
update cj_student
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
@ -127,7 +153,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="shjz != null">shjz = #{shjz},</if>
|
<if test="shjz != null">shjz = #{shjz},</if>
|
||||||
<if test="dbry != null">dbry = #{dbry},</if>
|
<if test="dbry != null">dbry = #{dbry},</if>
|
||||||
<if test="rysfzs != null">rysfzs = #{rysfzs},</if>
|
<if test="rysfzs != null">rysfzs = #{rysfzs},</if>
|
||||||
<if test="ry != null">ry = #{ry},</if>
|
|
||||||
<if test="sj != null">sj = #{sj},</if>
|
<if test="sj != null">sj = #{sj},</if>
|
||||||
<if test="yx != null">yx = #{yx},</if>
|
<if test="yx != null">yx = #{yx},</if>
|
||||||
<if test="qt != null">qt = #{qt},</if>
|
<if test="qt != null">qt = #{qt},</if>
|
||||||
|
Reference in New Issue
Block a user