修改提出的问题和新需求

This commit is contained in:
2025-07-31 10:35:51 +08:00
parent ecd499a497
commit 9b6f200292
12 changed files with 275 additions and 21 deletions

View File

@ -4,8 +4,10 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dw.domain.CjOption; import com.ruoyi.dw.domain.CjOption;
@ -13,6 +15,7 @@ import com.ruoyi.dw.domain.CjStudent;
import com.ruoyi.dw.domain.vo.OptionUserVo; import com.ruoyi.dw.domain.vo.OptionUserVo;
import com.ruoyi.dw.service.ICjOptionService; import com.ruoyi.dw.service.ICjOptionService;
import com.ruoyi.dw.service.ICjStudentService; import com.ruoyi.dw.service.ICjStudentService;
import com.ruoyi.system.service.ISysDeptService;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -41,6 +44,9 @@ public class CjOptionController extends BaseController
@Resource @Resource
private ICjStudentService cjStudentService; private ICjStudentService cjStudentService;
@Resource
private ISysDeptService sysDeptService;
/** /**
* 查询数据采集选项列表 * 查询数据采集选项列表
*/ */
@ -60,7 +66,13 @@ public class CjOptionController extends BaseController
public void export(HttpServletResponse response, @RequestBody OptionUserVo userVo) throws IOException public void export(HttpServletResponse response, @RequestBody OptionUserVo userVo) throws IOException
{ {
List<CjOption> listOption = cjOptionService.selectCjOptionByIds(userVo.getOptionId()); List<CjOption> listOption = cjOptionService.selectCjOptionByIds(userVo.getOptionId());
List<CjStudent> listStudent = cjStudentService.selectCjStudentByIds(userVo.getStudentId()); Long deptId = SecurityUtils.getLoginUser().getDeptId();
String zy = null;
if (deptId.intValue() != 100){
SysDept dept = sysDeptService.selectDeptById(deptId);
zy = dept.getDeptName();
}
List<CjStudent> listStudent = cjStudentService.selectCjStudentByIds(userVo.getStudentId(),zy);
// 设置响应头,通知浏览器下载 ZIP 文件 // 设置响应头,通知浏览器下载 ZIP 文件
String zipFileName = "export_data_" + System.currentTimeMillis() + ".zip"; String zipFileName = "export_data_" + System.currentTimeMillis() + ".zip";
response.setContentType("application/zip"); response.setContentType("application/zip");

View File

@ -78,7 +78,7 @@ public class CjStudentController extends BaseController
} }
/** /**
* 导采集学生信息列表 * 导采集学生信息列表
*/ */
@Log(title = "采集学生信息", businessType = BusinessType.EXPORT) @Log(title = "采集学生信息", businessType = BusinessType.EXPORT)
@PostMapping("/importData") @PostMapping("/importData")
@ -146,7 +146,7 @@ public class CjStudentController extends BaseController
public AjaxResult importData(MultipartFile file) { public AjaxResult importData(MultipartFile file) {
int successNum = cjStudentService.importData(file); int successNum = cjStudentService.importData(file);
if (successNum > 0) { if (successNum > 0) {
return AjaxResult.success(); return AjaxResult.success("导入成功");
}else { }else {
return AjaxResult.error("导入失败,请检查信息采集内容是否正确"); return AjaxResult.error("导入失败,请检查信息采集内容是否正确");
} }

View File

@ -4,8 +4,10 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dw.domain.CjOption; import com.ruoyi.dw.domain.CjOption;
@ -16,6 +18,7 @@ import com.ruoyi.dw.domain.vo.QuestionUserVo;
import com.ruoyi.dw.service.ICjStudentService; import com.ruoyi.dw.service.ICjStudentService;
import com.ruoyi.dw.service.IDwInfoService; import com.ruoyi.dw.service.IDwInfoService;
import com.ruoyi.dw.service.IDwQuestionService; import com.ruoyi.dw.service.IDwQuestionService;
import com.ruoyi.system.service.ISysDeptService;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -48,6 +51,9 @@ public class DwQuestionController extends BaseController
@Resource @Resource
private IDwInfoService dwInfoService; private IDwInfoService dwInfoService;
@Resource
private ISysDeptService sysDeptService;
/** /**
* 查询调查问卷问题列表 * 查询调查问卷问题列表
*/ */
@ -78,7 +84,13 @@ public class DwQuestionController extends BaseController
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, @RequestBody QuestionUserVo questionUserVo) throws IOException public void export(HttpServletResponse response, @RequestBody QuestionUserVo questionUserVo) throws IOException
{ {
List<CjStudent> listStudent = cjStudentService.selectCjStudentByIds(questionUserVo.getStudentId()); String zy = null;
Long deptId = SecurityUtils.getLoginUser().getDeptId();
if (deptId.intValue() != 100){
SysDept dept = sysDeptService.selectDeptById(deptId);
zy = dept.getDeptName();
}
List<CjStudent> listStudent = cjStudentService.selectCjStudentByIds(questionUserVo.getStudentId(), zy);
DwQuestion dwQuestion = new DwQuestion(); DwQuestion dwQuestion = new DwQuestion();
dwQuestion.setInfoId(questionUserVo.getInfoId()); dwQuestion.setInfoId(questionUserVo.getInfoId());
List<DwQuestion> listQuestion = dwQuestionService.selectDwQuestionList(dwQuestion); List<DwQuestion> listQuestion = dwQuestionService.selectDwQuestionList(dwQuestion);

View File

@ -0,0 +1,29 @@
package com.ruoyi.dw.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.dw.mapper.XyCheckMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/xy/check")
public class XyCheckController extends BaseController {
@Resource
private XyCheckMapper xyCheckMapper;
/**
* 根据专业关联表统计各个学院的调查问卷数量
* @return
*/
@GetMapping("/dwCount")
public AjaxResult dwCount() {
return AjaxResult.success(xyCheckMapper.selectXyCheckDw());
}
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.dw.domain.vo;
public class XyCheckDw {
private String xy;
private Integer dwCount;
public String getXy() {
return xy;
}
public void setXy(String xy) {
this.xy = xy;
}
public Integer getDwCount() {
return dwCount;
}
public void setDwCount(Integer dwCount) {
this.dwCount = dwCount;
}
}

View File

@ -28,8 +28,10 @@ public interface CjStudentMapper
*/ */
public List<CjStudent> selectCjStudentList(CjStudent cjStudent); public List<CjStudent> selectCjStudentList(CjStudent cjStudent);
public CjStudent selectCjStudentByXh(String xh);
public List<CjStudent> selectCjStudentByIds(@Param("ids") Long[] ids);
public List<CjStudent> selectCjStudentByIds(@Param("ids") Long[] ids,@Param("zy") String zy);
/** /**

View File

@ -0,0 +1,10 @@
package com.ruoyi.dw.mapper;
import com.ruoyi.dw.domain.vo.XyCheckDw;
import java.util.List;
public interface XyCheckMapper {
public List<XyCheckDw> selectXyCheckDw();
}

View File

@ -29,7 +29,7 @@ public interface ICjStudentService
public List<CjStudent> selectCjStudentList(CjStudent cjStudent); public List<CjStudent> selectCjStudentList(CjStudent cjStudent);
public List<CjStudent> selectCjStudentByIds(Long[] ids); public List<CjStudent> selectCjStudentByIds(Long[] ids ,String zy);
/** /**
* 查询荣誉学生信息列表 * 查询荣誉学生信息列表
* *
@ -81,6 +81,8 @@ public interface ICjStudentService
* @param file * @param file
* @return * @return
*/ */
public int importDataXcx(MultipartFile file);
public int importData(MultipartFile file); public int importData(MultipartFile file);
public int importCjStudent(MultipartFile file); public int importCjStudent(MultipartFile file);

View File

@ -1,9 +1,7 @@
package com.ruoyi.dw.service.impl; package com.ruoyi.dw.service.impl;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -58,8 +56,8 @@ public class CjStudentServiceImpl implements ICjStudentService
} }
@Override @Override
public List<CjStudent> selectCjStudentByIds(Long[] ids) { public List<CjStudent> selectCjStudentByIds(Long[] ids,String zy) {
return cjStudentMapper.selectCjStudentByIds(ids); return cjStudentMapper.selectCjStudentByIds(ids,zy);
} }
@Override @Override
@ -120,8 +118,10 @@ public class CjStudentServiceImpl implements ICjStudentService
return cjStudentMapper.confirmCjStudentByIds(ids); return cjStudentMapper.confirmCjStudentByIds(ids);
} }
@Override @Override
public int importData(MultipartFile file) { public int importDataXcx(MultipartFile file) {
try { try {
Workbook workbook = WorkbookFactory.create(file.getInputStream()); Workbook workbook = WorkbookFactory.create(file.getInputStream());
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
@ -208,6 +208,128 @@ public class CjStudentServiceImpl implements ICjStudentService
return -1; // 没有找到数字 return -1; // 没有找到数字
} }
@Override
public int importData(MultipartFile file) {
try {
Workbook workbook = WorkbookFactory.create(file.getInputStream());
Sheet sheet = workbook.getSheetAt(0);
int rows = sheet.getLastRowNum();
for (int i = 2; i <= rows; i++) {
Row row = sheet.getRow(i);
String xh = row.getCell(3).getStringCellValue().trim();
boolean isInsert = false;
CjStudent cjStudent = cjStudentMapper.selectCjStudentByXh(xh);
if (cjStudent == null){
cjStudent = new CjStudent();
isInsert = true;
}
Cell xmCell = row.getCell(1);
xmCell.setCellType(CellType.STRING);
cjStudent.setXm(xmCell.getStringCellValue().trim());
Cell xbCell = row.getCell(2);
xbCell.setCellType(CellType.STRING);
cjStudent.setXb(xbCell.getStringCellValue().trim());
cjStudent.setXh(xh);
Cell xyCell = row.getCell(4);
xyCell.setCellType(CellType.STRING);
cjStudent.setXy(xyCell.getStringCellValue().trim());
Cell zyCell = row.getCell(5);
zyCell.setCellType(CellType.STRING);
cjStudent.setZy(zyCell.getStringCellValue().trim());
Cell bjCell = row.getCell(6);
bjCell.setCellType(CellType.STRING);
cjStudent.setBj(bjCell.getStringCellValue().trim());
Cell bybfCell = row.getCell(7);
bybfCell.setCellType(CellType.STRING);
cjStudent.setBynf(Integer.valueOf(bybfCell.getStringCellValue()));
Cell zgxlCell = row.getCell(8);
zgxlCell.setCellType(CellType.STRING);
cjStudent.setZgyl(zgxlCell.getStringCellValue().trim());
Cell gzdwCell = row.getCell(9);
gzdwCell.setCellType(CellType.STRING);
cjStudent.setGzdw(gzdwCell.getStringCellValue().trim());
Cell dwxzCell = row.getCell(10);
dwxzCell.setCellType(CellType.STRING);
cjStudent.setDwxz(dwxzCell.getStringCellValue().trim());
Cell dwdzCell = row.getCell(11);
dwdzCell.setCellType(CellType.STRING);
cjStudent.setDwdz(dwdzCell.getStringCellValue().trim());
Cell czdCell = row.getCell(12);
czdCell.setCellType(CellType.STRING);
String czd = czdCell.getStringCellValue().trim();
Map<String, String> pac = extractProvinceAndCity(czd);
if (pac != null){
cjStudent.setSydsh(pac.get("province"));
cjStudent.setSydshi(pac.get("city"));
}
Cell zwjbCell = row.getCell(13);
zwjbCell.setCellType(CellType.STRING);
cjStudent.setZwjb(zwjbCell.getStringCellValue().trim());
Cell shjzCell = row.getCell(14);
shjzCell.setCellType(CellType.STRING);
cjStudent.setShjz(shjzCell.getStringCellValue().trim());
Cell dbryCell = row.getCell(15);
dbryCell.setCellType(CellType.STRING);
cjStudent.setDbry(dbryCell.getStringCellValue().trim());
Cell rysfzsCell = row.getCell(16);
rysfzsCell.setCellType(CellType.STRING);
String rysfzs = rysfzsCell.getStringCellValue().trim();
if ("".equals(rysfzs)){
cjStudent.setRysfzs(1L);
}else {
cjStudent.setRysfzs(0L);
}
Cell sjCell = row.getCell(17);
sjCell.setCellType(CellType.STRING);
cjStudent.setSj(sjCell.getStringCellValue());
Cell yxCell = row.getCell(18);
yxCell.setCellType(CellType.STRING);
cjStudent.setYx(yxCell.getStringCellValue().trim());
cjStudent.setSfqr(1L);
if (isInsert)
cjStudentMapper.insertCjStudent(cjStudent);
else
cjStudentMapper.updateCjStudent(cjStudent);
}
return rows-2;
}catch (IOException e) {
return -1;
}
}
/**
* 根据常驻地获取省市
* @param address
* @return
*/
private static Map<String, String> extractProvinceAndCity(String address) {
if (address == null || address.length() < 2) {
return null;
}
int provinceIndex = address.indexOf("");
int cityIndex = -1;
// 必须有"省",且"省"不能是最后一个字符
if (provinceIndex == -1 || provinceIndex == address.length() - 1) {
return null;
}
// 在"省"之后找"市"
cityIndex = address.indexOf("", provinceIndex + 1);
if (cityIndex == -1) {
return null;
}
String province = address.substring(0, provinceIndex + 1); // 包含"省"
String city = address.substring(provinceIndex + 1, cityIndex + 1); // 从省后到"市"结束
Map<String, String> result = new HashMap<>();
result.put("province", province);
result.put("city", city);
return result;
}
@Override @Override
public int importCjStudent(MultipartFile file) { public int importCjStudent(MultipartFile file) {
try { try {

View File

@ -62,14 +62,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectCjStudentByIds" parameterType="map" resultMap="CjStudentResult"> <select id="selectCjStudentByIds" resultMap="CjStudentResult">
<include refid="selectCjStudentVo"/> <include refid="selectCjStudentVo"/>
<if test="ids != null and ids.length > 0"> <where>
WHERE id IN <if test="ids != null and ids.length > 0">
<foreach item="id" collection="ids" open="(" separator="," close=")"> id IN
#{id} <foreach item="id" collection="ids" open="(" separator="," close=")">
</foreach> #{id}
</if> </foreach>
</if>
<if test="zy != null"> and xy = #{zy}</if>
</where>
</select>
<select id="selectCjStudentByXh" resultMap="CjStudentResult">
<include refid="selectCjStudentVo"/>
<where>
<if test="xh != null"> and xh = #{xh}</if>
</where>
limit 1
</select> </select>
<select id="selectRyStudentList" resultMap="CjStudentResult"> <select id="selectRyStudentList" resultMap="CjStudentResult">

View File

@ -47,13 +47,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertDwAnswerBatch" parameterType="list"> <insert id="insertDwAnswerBatch" parameterType="list">
insert into dw_answer insert into dw_answer
(info_id, question_id, answer) (info_id, question_id, answer,create_time)
VALUES VALUES
<foreach item="item" collection="list" separator=","> <foreach item="item" collection="list" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
#{item.infoId}, #{item.infoId},
#{item.questionId}, #{item.questionId},
#{item.answer} #{item.answer},
SYSDATE()
</trim> </trim>
</foreach> </foreach>
</insert> </insert>

View File

@ -0,0 +1,29 @@
<?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="com.ruoyi.dw.mapper.XyCheckMapper">
<resultMap type="XyCheckDw" id="xyCheckDw">
<result property="xy" column="xy" />
<result property="dwCount" column="dw_count" />
</resultMap>
<select id="selectXyCheckDw" resultMap="xyCheckDw">
SELECT
re.xy,re.order_index,
sum( re.dw_count ) as dw_count
FROM
(
SELECT
xy,order_index,
IFNULL( dw.dw_count, 0 ) AS dw_count
FROM
xy_zy xz
LEFT JOIN ( SELECT answer, count( 0 ) AS dw_count FROM dw_answer WHERE question_id IN ( 3, 43, 71 ) GROUP BY answer ) AS dw ON dw.answer = xz.zy
) AS re
GROUP BY re.xy,re.order_index
order by re.order_index
</select>
</mapper>