forked from liweijie/education
部分功能重写,增加,去除冗余
This commit is contained in:
+40
-2
@@ -1,6 +1,7 @@
|
||||
package com.roomroot.jwgl.service;
|
||||
|
||||
import com.roomroot.jwgl.entity.XKZYXX;
|
||||
import com.roomroot.jwgl.entity.ZYB;
|
||||
import com.roomroot.jwgl.unit.PageQuery;
|
||||
import com.roomroot.jwgl.unit.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -8,8 +9,7 @@ import org.springframework.stereotype.Service;
|
||||
/**
|
||||
* 学科专业管理服务接口
|
||||
* <p>
|
||||
* 提供学科、专业的增加、删除(逻辑删除)、更新、分页查询等功能。
|
||||
* 对应数据表:学科专业信息
|
||||
* 学科目录对应表:学科专业信息;专业对应表:专业表。
|
||||
* </p>
|
||||
*/
|
||||
@Service
|
||||
@@ -51,4 +51,42 @@ public interface DisciplineService {
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<XKZYXX> pageList(PageQuery query, XKZYXX xkzyxx);
|
||||
|
||||
/**
|
||||
* 新增专业
|
||||
*
|
||||
* @param entity 专业表实体
|
||||
*/
|
||||
void addMajor(ZYB entity);
|
||||
|
||||
/**
|
||||
* 停用(逻辑删除)专业
|
||||
*
|
||||
* @param zydh 专业代号
|
||||
*/
|
||||
void deleteMajor(String zydh);
|
||||
|
||||
/**
|
||||
* 更新专业
|
||||
*
|
||||
* @param entity 专业表实体(须含专业代号)
|
||||
*/
|
||||
void updateMajor(ZYB entity);
|
||||
|
||||
/**
|
||||
* 按专业代号查询专业
|
||||
*
|
||||
* @param zydh 专业代号
|
||||
* @return 专业表实体
|
||||
*/
|
||||
ZYB getMajorById(String zydh);
|
||||
|
||||
/**
|
||||
* 分页查询专业
|
||||
*
|
||||
* @param query 分页参数
|
||||
* @param cond 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<ZYB> pageMajor(PageQuery query, ZYB cond);
|
||||
}
|
||||
|
||||
+75
-2
@@ -1,10 +1,15 @@
|
||||
package com.roomroot.jwgl.service;
|
||||
|
||||
import com.roomroot.jwgl.entity.XYXX;
|
||||
import com.roomroot.jwgl.entity.XYDB;
|
||||
import com.roomroot.jwgl.entity.XYXJYDSQB;
|
||||
import com.roomroot.jwgl.entity.XYXJYJJGB;
|
||||
import com.roomroot.jwgl.entity.XYXJYJTJB;
|
||||
import com.roomroot.jwgl.entity.XYKCCJ;
|
||||
import com.roomroot.jwgl.entity.XYKCGCCJ;
|
||||
import com.roomroot.jwgl.unit.PageQuery;
|
||||
import com.roomroot.jwgl.unit.PageResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
@@ -36,8 +41,6 @@ public interface StudentRecordsService {
|
||||
/** 学籍异动——留级 */
|
||||
void retainGrade(String bh);
|
||||
|
||||
/** 学籍异动——降级 */
|
||||
void downgrade(String bh);
|
||||
|
||||
/** 学籍异动——退学 */
|
||||
void dropOut(String bh);
|
||||
@@ -54,4 +57,74 @@ public interface StudentRecordsService {
|
||||
|
||||
/** 导出学员课程成绩 Excel */
|
||||
void exportGradesExcel(String xybh, HttpServletResponse response);
|
||||
|
||||
/** 导出学员课程过程成绩 Excel */
|
||||
void exportProcessGradesExcel(String xybh, HttpServletResponse response);
|
||||
|
||||
// ========== 学员学籍异动申请 ==========
|
||||
|
||||
/** 新增学员学籍异动申请(后台自动写入创建时间、修改时间,状态默认待审核) */
|
||||
void addApplication(XYXJYDSQB entity);
|
||||
|
||||
/** 删除学员学籍异动申请 */
|
||||
void deleteApplication(String bh);
|
||||
|
||||
/** 修改学员学籍异动申请(后台自动更新修改时间) */
|
||||
void updateApplication(XYXJYDSQB entity);
|
||||
|
||||
/** 查询学员学籍异动申请详情 */
|
||||
XYXJYDSQB getApplicationById(String bh);
|
||||
|
||||
/** 分页查询学员学籍异动申请列表 */
|
||||
PageResult<XYXJYDSQB> pageApplication(PageQuery query, XYXJYDSQB cond);
|
||||
|
||||
// ========== 学员学籍预警条件管理 ==========
|
||||
|
||||
/** 新增学员学籍预警条件(后台自动写入修改时间) */
|
||||
void addWarningCondition(XYXJYJTJB entity);
|
||||
|
||||
/** 修改学员学籍预警条件(后台自动更新修改时间) */
|
||||
void updateWarningCondition(XYXJYJTJB entity);
|
||||
|
||||
/** 查询学员学籍预警条件详情 */
|
||||
XYXJYJTJB getWarningConditionById(String bh);
|
||||
|
||||
/** 分页查询学员学籍预警条件列表 */
|
||||
PageResult<XYXJYJTJB> pageWarningCondition(PageQuery query, XYXJYJTJB cond);
|
||||
|
||||
// ========== 学员学籍预警结果管理 ==========
|
||||
|
||||
/** 查询学员学籍预警结果详情 */
|
||||
XYXJYJJGB getWarningResultById(String bh);
|
||||
|
||||
/** 分页查询学员学籍预警结果列表(查看是否有学员触发预警条件) */
|
||||
PageResult<XYXJYJJGB> pageWarningResult(PageQuery query, XYXJYJJGB cond);
|
||||
|
||||
// ========== 班次管理(学员队表 XYDB)==========
|
||||
|
||||
/** 新增班次(学员队) */
|
||||
void addTeam(XYDB entity);
|
||||
|
||||
/** 删除班次(学员队) */
|
||||
void deleteTeam(String xydbh);
|
||||
|
||||
/** 修改班次(学员队) */
|
||||
void updateTeam(XYDB entity);
|
||||
|
||||
/** 根据学员队编号查询班次(学员队) */
|
||||
XYDB getTeamById(String xydbh);
|
||||
|
||||
/** 分页条件查询班次(学员队)列表 */
|
||||
PageResult<XYDB> pageTeam(PageQuery query, XYDB cond);
|
||||
|
||||
/** 从 Excel(.xls/.xlsx) 导入班次(学员队)数据 */
|
||||
int importTeam(MultipartFile file) throws Exception;
|
||||
|
||||
/** 导出班次(学员队)数据到 Excel(.xls) */
|
||||
void exportTeam(XYDB cond, HttpServletResponse response) throws Exception;
|
||||
|
||||
// ========== 学员信息批量导入 ==========
|
||||
|
||||
/** 从 Excel(.xls/.xlsx) 批量导入学员信息 */
|
||||
int importStudents(MultipartFile file) throws Exception;
|
||||
}
|
||||
|
||||
+194
-2
@@ -2,23 +2,33 @@ package com.roomroot.jwgl.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.roomroot.common.exception.ServiceException;
|
||||
import com.roomroot.common.utils.StringUtils;
|
||||
import com.roomroot.jwgl.entity.XKZYXX;
|
||||
import com.roomroot.jwgl.entity.ZYB;
|
||||
import com.roomroot.jwgl.mapper.XKZYXXMapper;
|
||||
import com.roomroot.jwgl.mapper.ZYBMapper;
|
||||
import com.roomroot.jwgl.service.DisciplineService;
|
||||
import com.roomroot.jwgl.unit.PageQuery;
|
||||
import com.roomroot.jwgl.unit.PageResult;
|
||||
import com.roomroot.jwgl.utils.UuidUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.roomroot.jwgl.utils.BasicManagementConstants.BAD_REQUEST;
|
||||
import static com.roomroot.jwgl.utils.BasicManagementConstants.CONFLICT;
|
||||
import static com.roomroot.jwgl.utils.BasicManagementConstants.NOT_FOUND;
|
||||
|
||||
/**
|
||||
* 学科专业管理服务实现类
|
||||
* <p>
|
||||
* 实现学科、专业的增加、删除(逻辑删除)、更新、分页查询等功能。
|
||||
* 逻辑删除将 停用 字段置为 1(停用=0为启用,停用=1为已停用/删除)。
|
||||
* 学科目录对应表:学科专业信息;专业对应表:专业表。
|
||||
* 专业删除为逻辑删除(停用=true)。
|
||||
* </p>
|
||||
*/
|
||||
@Service
|
||||
@@ -27,6 +37,9 @@ public class DisciplineServiceImpl implements DisciplineService {
|
||||
@Resource
|
||||
private XKZYXXMapper xkzyxxMapper;
|
||||
|
||||
@Resource
|
||||
private ZYBMapper zybMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(XKZYXX entity) {
|
||||
@@ -66,4 +79,183 @@ public class DisciplineServiceImpl implements DisciplineService {
|
||||
return new PageResult<>(result.getRecords(), result.getTotal(),
|
||||
query.getPageNum(), query.getPageSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addMajor(ZYB entity) {
|
||||
if (entity == null) {
|
||||
throw new ServiceException("专业信息不能为空", BAD_REQUEST);
|
||||
}
|
||||
validateMajor(entity, true);
|
||||
if (StringUtils.isEmpty(entity.getZydh())) {
|
||||
entity.setZydh(UuidUtil.getOriginalUUID());
|
||||
}
|
||||
assertMajorCodeUnique(entity.getZydh());
|
||||
fillMajorDefaults(entity);
|
||||
zybMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteMajor(String zydh) {
|
||||
if (StringUtils.isEmpty(zydh)) {
|
||||
throw new ServiceException("专业代号不能为空", BAD_REQUEST);
|
||||
}
|
||||
ZYB existing = zybMapper.selectById(zydh);
|
||||
if (existing == null) {
|
||||
throw new ServiceException("专业不存在", NOT_FOUND);
|
||||
}
|
||||
if (Boolean.TRUE.equals(existing.getTy())) {
|
||||
return;
|
||||
}
|
||||
ZYB update = new ZYB();
|
||||
update.setZydh(zydh);
|
||||
update.setTy(true);
|
||||
update.setTysj(LocalDateTime.now());
|
||||
zybMapper.updateById(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateMajor(ZYB entity) {
|
||||
if (entity == null || StringUtils.isEmpty(entity.getZydh())) {
|
||||
throw new ServiceException("专业代号不能为空", BAD_REQUEST);
|
||||
}
|
||||
validateMajor(entity, false);
|
||||
ZYB existing = zybMapper.selectById(entity.getZydh());
|
||||
if (existing == null) {
|
||||
throw new ServiceException("专业不存在", NOT_FOUND);
|
||||
}
|
||||
entity.setQysj(existing.getQysj());
|
||||
if (Boolean.TRUE.equals(entity.getTy()) && !Boolean.TRUE.equals(existing.getTy())) {
|
||||
entity.setTysj(LocalDateTime.now());
|
||||
}
|
||||
if (Boolean.FALSE.equals(entity.getTy())) {
|
||||
entity.setTysj(null);
|
||||
}
|
||||
zybMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZYB getMajorById(String zydh) {
|
||||
if (StringUtils.isEmpty(zydh)) {
|
||||
throw new ServiceException("专业代号不能为空", BAD_REQUEST);
|
||||
}
|
||||
return zybMapper.selectById(zydh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ZYB> pageMajor(PageQuery query, ZYB cond) {
|
||||
int pageNum = query.getPageNum() == null ? 1 : query.getPageNum();
|
||||
int pageSize = query.getPageSize() == null ? 20 : query.getPageSize();
|
||||
Page<ZYB> page = new Page<>(pageNum, pageSize);
|
||||
LambdaQueryWrapper<ZYB> wrapper = new LambdaQueryWrapper<>();
|
||||
if (cond != null) {
|
||||
wrapper.like(StringUtils.isNotEmpty(cond.getZymc()), ZYB::getZymc, cond.getZymc());
|
||||
wrapper.like(StringUtils.isNotEmpty(cond.getZyfx()), ZYB::getZyfx, cond.getZyfx());
|
||||
wrapper.like(StringUtils.isNotEmpty(cond.getZydm()), ZYB::getZydm, cond.getZydm());
|
||||
wrapper.eq(StringUtils.isNotEmpty(cond.getPxlx()), ZYB::getPxlx, cond.getPxlx());
|
||||
wrapper.eq(StringUtils.isNotEmpty(cond.getPxcc()), ZYB::getPxcc, cond.getPxcc());
|
||||
wrapper.eq(StringUtils.isNotEmpty(cond.getPxlx2()), ZYB::getPxlx2, cond.getPxlx2());
|
||||
wrapper.eq(StringUtils.isNotEmpty(cond.getXnz()), ZYB::getXnz, cond.getXnz());
|
||||
wrapper.eq(StringUtils.isNotEmpty(cond.getXkzyxxbsh()), ZYB::getXkzyxxbsh, cond.getXkzyxxbsh());
|
||||
wrapper.eq(cond.getTy() != null, ZYB::getTy, cond.getTy());
|
||||
}
|
||||
wrapper.orderByAsc(ZYB::getXhbs);
|
||||
Page<ZYB> result = zybMapper.selectPage(page, wrapper);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal(), pageNum, pageSize);
|
||||
}
|
||||
|
||||
private void fillMajorDefaults(ZYB entity) {
|
||||
if (entity.getTy() == null) {
|
||||
entity.setTy(false);
|
||||
}
|
||||
if (entity.getQysj() == null && !Boolean.TRUE.equals(entity.getTy())) {
|
||||
entity.setQysj(LocalDateTime.now());
|
||||
}
|
||||
if (Boolean.TRUE.equals(entity.getTy()) && entity.getTysj() == null) {
|
||||
entity.setTysj(LocalDateTime.now());
|
||||
}
|
||||
if (entity.getZgzy() == null) {
|
||||
entity.setZgzy(false);
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getZybsh())) {
|
||||
entity.setZybsh(entity.getZydh());
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getGfmc())) {
|
||||
entity.setGfmc(entity.getZymc());
|
||||
}
|
||||
if (entity.getZybb() == null) {
|
||||
entity.setZybb("");
|
||||
}
|
||||
if (entity.getPxlx2() == null) {
|
||||
entity.setPxlx2("");
|
||||
}
|
||||
if (entity.getXylb() == null) {
|
||||
entity.setXylb("");
|
||||
}
|
||||
if (entity.getZdyfl() == null) {
|
||||
entity.setZdyfl("");
|
||||
}
|
||||
if (entity.getJclb() == null) {
|
||||
entity.setJclb("");
|
||||
}
|
||||
if (entity.getXtms() == null) {
|
||||
entity.setXtms("");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateMajor(ZYB entity, boolean creating) {
|
||||
if (creating) {
|
||||
requireText(entity.getZymc(), "专业名称");
|
||||
requireText(entity.getZydm(), "专业代码");
|
||||
requireText(entity.getXnz(), "学年制");
|
||||
if (entity.getXqs() == null) {
|
||||
throw new ServiceException("学期数不能为空", BAD_REQUEST);
|
||||
}
|
||||
requireText(entity.getPxcc(), "培训层次");
|
||||
requireText(entity.getPxlx(), "培训类型");
|
||||
}
|
||||
assertMaxLength(entity.getZydh(), 50, "专业代号");
|
||||
assertMaxLength(entity.getZymc(), 250, "专业名称");
|
||||
assertMaxLength(entity.getZyfx(), 50, "专业方向");
|
||||
assertMaxLength(entity.getXnz(), 50, "学年制");
|
||||
assertMaxLength(entity.getZybz(), 100, "专业备注");
|
||||
assertMaxLength(entity.getZydm(), 50, "专业代码");
|
||||
assertMaxLength(entity.getZybb(), 50, "专业版本");
|
||||
assertMaxLength(entity.getJxgljgbh(), 50, "教学管理机构编号");
|
||||
assertMaxLength(entity.getPxcc(), 50, "培训层次");
|
||||
assertMaxLength(entity.getPxlx(), 50, "培训类型");
|
||||
assertMaxLength(entity.getXkzyxxbsh(), 50, "学科专业信息标识号");
|
||||
assertMaxLength(entity.getPxlx2(), 50, "培训类型2");
|
||||
assertMaxLength(entity.getXylb(), 50, "学员类别");
|
||||
assertMaxLength(entity.getZdyfl(), 50, "自定义分类");
|
||||
assertMaxLength(entity.getZybsh(), 50, "专业标识号");
|
||||
assertMaxLength(entity.getJc(), 50, "简称");
|
||||
assertMaxLength(entity.getJclb(), 50, "节次类别");
|
||||
assertMaxLength(entity.getXtms(), 50, "系统模式");
|
||||
assertMaxLength(entity.getJsonzd(), 4000, "json字典");
|
||||
assertMaxLength(entity.getGfmc(), 250, "规范名称");
|
||||
assertMaxLength(entity.getPymb(), 500, "培养目标");
|
||||
}
|
||||
|
||||
private void requireText(String value, String fieldName) {
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
throw new ServiceException(fieldName + "不能为空", BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertMaxLength(String value, int max, String fieldName) {
|
||||
if (value != null && value.length() > max) {
|
||||
throw new ServiceException(fieldName + "长度不能超过" + max + "个字符", BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertMajorCodeUnique(String zydh) {
|
||||
Long count = zybMapper.selectCount(
|
||||
new LambdaQueryWrapper<ZYB>().eq(ZYB::getZydh, zydh));
|
||||
if (count != null && count > 0) {
|
||||
throw new ServiceException("专业代号已存在", CONFLICT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ public class LogServiceImpl implements LogService {
|
||||
@Transactional
|
||||
public void addLog(SSKCB_RZ entity) {
|
||||
fillNotNullDefaults(entity);
|
||||
entity.setCjsj(LocalDateTime.now());
|
||||
sskcbRzMapper.insert(entity);
|
||||
}
|
||||
|
||||
|
||||
+438
-12
@@ -1,25 +1,44 @@
|
||||
package com.roomroot.jwgl.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.roomroot.jwgl.entity.XYXX;
|
||||
import com.roomroot.jwgl.entity.XYDB;
|
||||
import com.roomroot.jwgl.entity.XYXJYDSQB;
|
||||
import com.roomroot.jwgl.entity.XYXJYJJGB;
|
||||
import com.roomroot.jwgl.entity.XYXJYJTJB;
|
||||
import com.roomroot.jwgl.entity.XYKCCJ;
|
||||
import com.roomroot.jwgl.entity.XYKCGCCJ;
|
||||
import com.roomroot.jwgl.mapper.XYXXMapper;
|
||||
import com.roomroot.jwgl.mapper.XYDBMapper;
|
||||
import com.roomroot.jwgl.mapper.XYXJYDSQBMapper;
|
||||
import com.roomroot.jwgl.mapper.XYXJYJJGBMapper;
|
||||
import com.roomroot.jwgl.mapper.XYXJYJTJBMapper;
|
||||
import com.roomroot.jwgl.mapper.XYKCCJMapper;
|
||||
import com.roomroot.jwgl.mapper.XYKCGCCJMapper;
|
||||
import com.roomroot.jwgl.service.StudentRecordsService;
|
||||
import com.roomroot.jwgl.unit.PageQuery;
|
||||
import com.roomroot.jwgl.unit.PageResult;
|
||||
import com.roomroot.jwgl.utils.ExcelParseUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 学员档案管理服务实现类
|
||||
@@ -30,6 +49,18 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
|
||||
@Resource
|
||||
private XYXXMapper xyxxMapper;
|
||||
|
||||
@Resource
|
||||
private XYDBMapper xydbMapper;
|
||||
|
||||
@Resource
|
||||
private XYXJYDSQBMapper xyxjydsqbMapper;
|
||||
|
||||
@Resource
|
||||
private XYXJYJJGBMapper xyxjyjjgbMapper;
|
||||
|
||||
@Resource
|
||||
private XYXJYJTJBMapper xyxjyjtjbMapper;
|
||||
|
||||
@Resource
|
||||
private XYKCCJMapper xykccjMapper;
|
||||
|
||||
@@ -39,6 +70,9 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(XYXX xyxx) {
|
||||
xyxx.setTxzt(0);
|
||||
xyxx.setLjzt(0);
|
||||
xyxx.setFbzt(0);
|
||||
xyxxMapper.insert(xyxx);
|
||||
}
|
||||
|
||||
@@ -47,7 +81,7 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
|
||||
public void delete(String bh) {
|
||||
XYXX xyxx = new XYXX();
|
||||
xyxx.setBh(bh);
|
||||
xyxx.setTxzt("退学");
|
||||
xyxx.setTxzt(1);
|
||||
xyxxMapper.updateById(xyxx);
|
||||
}
|
||||
|
||||
@@ -65,35 +99,77 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
|
||||
@Override
|
||||
public PageResult<XYXX> pageList(PageQuery query, XYXX xyxx) {
|
||||
Page<XYXX> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
Page<XYXX> result = xyxxMapper.selectPageList(page, xyxx);
|
||||
Page<XYXX> result = xyxxMapper.selectPage(page, buildQueryWrapper(xyxx));
|
||||
return new PageResult<>(result.getRecords(), result.getTotal(),
|
||||
query.getPageNum(), query.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 全字段动态查询条件。
|
||||
* <p>
|
||||
* 姓名(xm)、联系电话(lxdh)、通信地址(txdz) 使用模糊查询(LIKE),
|
||||
* 其它字段只要传值就作为等值条件(EQ)参与查询。
|
||||
* 空串和 null 均不作为条件。
|
||||
* </p>
|
||||
*/
|
||||
private QueryWrapper<XYXX> buildQueryWrapper(XYXX query) {
|
||||
QueryWrapper<XYXX> wrapper = new QueryWrapper<>();
|
||||
if (query == null) {
|
||||
return wrapper;
|
||||
}
|
||||
// 需要模糊匹配的字段(属性名)
|
||||
Set<String> fuzzyFields = Set.of("xm", "lxdh", "txdz");
|
||||
for (Field field : XYXX.class.getDeclaredFields()) {
|
||||
Object value = getFieldValue(field, query);
|
||||
if (value == null || !(value instanceof String) || ((String) value).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String column = resolveColumn(field);
|
||||
if (fuzzyFields.contains(field.getName())) {
|
||||
wrapper.like(column, (String) value);
|
||||
} else {
|
||||
wrapper.eq(column, (String) value);
|
||||
}
|
||||
}
|
||||
wrapper.orderByAsc("学号");
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private Object getFieldValue(Field field, Object target) {
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
return field.get(target);
|
||||
} catch (IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveColumn(Field field) {
|
||||
TableField tableField = field.getAnnotation(TableField.class);
|
||||
if (tableField != null && tableField.value() != null && !tableField.value().isEmpty()) {
|
||||
return tableField.value();
|
||||
}
|
||||
return field.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void retainGrade(String bh) {
|
||||
XYXX xyxx = new XYXX();
|
||||
xyxx.setBh(bh);
|
||||
xyxx.setLjzt("留级");
|
||||
//留级
|
||||
xyxx.setLjzt(1);
|
||||
xyxxMapper.updateById(xyxx);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void downgrade(String bh) {
|
||||
XYXX xyxx = new XYXX();
|
||||
xyxx.setBh(bh);
|
||||
xyxx.setLjzt("降级");
|
||||
xyxxMapper.updateById(xyxx);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void dropOut(String bh) {
|
||||
XYXX xyxx = new XYXX();
|
||||
xyxx.setBh(bh);
|
||||
xyxx.setTxzt("退学");
|
||||
//退学
|
||||
xyxx.setTxzt(1);
|
||||
xyxxMapper.updateById(xyxx);
|
||||
}
|
||||
|
||||
@@ -194,4 +270,354 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
|
||||
throw new RuntimeException("导出 Excel 失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportProcessGradesExcel(String xybh, HttpServletResponse response) {
|
||||
XYXX student = xyxxMapper.selectById(xybh);
|
||||
if (student == null) {
|
||||
throw new RuntimeException("学员不存在");
|
||||
}
|
||||
|
||||
List<XYKCGCCJ> grades = xykgccjMapper.selectByStudentId(xybh);
|
||||
|
||||
try (Workbook workbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = workbook.createSheet("课程过程成绩");
|
||||
|
||||
Font headerFont = workbook.createFont();
|
||||
headerFont.setBold(true);
|
||||
headerFont.setFontHeightInPoints((short) 12);
|
||||
CellStyle headerStyle = workbook.createCellStyle();
|
||||
headerStyle.setFont(headerFont);
|
||||
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
headerStyle.setBorderBottom(BorderStyle.THIN);
|
||||
headerStyle.setBorderTop(BorderStyle.THIN);
|
||||
headerStyle.setBorderLeft(BorderStyle.THIN);
|
||||
headerStyle.setBorderRight(BorderStyle.THIN);
|
||||
|
||||
CellStyle dataStyle = workbook.createCellStyle();
|
||||
dataStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
dataStyle.setBorderBottom(BorderStyle.THIN);
|
||||
dataStyle.setBorderTop(BorderStyle.THIN);
|
||||
dataStyle.setBorderLeft(BorderStyle.THIN);
|
||||
dataStyle.setBorderRight(BorderStyle.THIN);
|
||||
|
||||
// 学员信息行
|
||||
Row infoRow = sheet.createRow(0);
|
||||
infoRow.createCell(0).setCellValue("学员:" + student.getXm());
|
||||
infoRow.createCell(1).setCellValue("学号:" + student.getXh());
|
||||
|
||||
// 表头
|
||||
String[] headers = {"年度", "科目编号", "原始成绩", "最终成绩", "补考1",
|
||||
"补考2", "补考3", "补考次数", "考试情况", "备注"};
|
||||
Row headerRow = sheet.createRow(2);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = headerRow.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
cell.setCellStyle(headerStyle);
|
||||
}
|
||||
|
||||
// 数据行
|
||||
int rowIdx = 3;
|
||||
for (XYKCGCCJ g : grades) {
|
||||
Row row = sheet.createRow(rowIdx++);
|
||||
row.createCell(0).setCellValue(g.getNd() != null ? g.getNd().toString() : "");
|
||||
row.createCell(1).setCellValue(g.getKmbh() != null ? g.getKmbh() : "");
|
||||
row.createCell(2).setCellValue(g.getYscj() != null ? g.getYscj() : "");
|
||||
row.createCell(3).setCellValue(g.getZzcj() != null ? g.getZzcj().toString() : "");
|
||||
row.createCell(4).setCellValue(g.getBkcj1() != null ? g.getBkcj1().toString() : "");
|
||||
row.createCell(5).setCellValue(g.getBkcj2() != null ? g.getBkcj2().toString() : "");
|
||||
row.createCell(6).setCellValue(g.getBkcj3() != null ? g.getBkcj3().toString() : "");
|
||||
row.createCell(7).setCellValue(g.getBkcs() != null ? g.getBkcs().toString() : "");
|
||||
row.createCell(8).setCellValue(g.getKsqk() != null ? g.getKsqk() : "");
|
||||
row.createCell(9).setCellValue(g.getBz() != null ? g.getBz() : "");
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
row.getCell(i).setCellStyle(dataStyle);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + URLEncoder.encode(
|
||||
student.getXm() + "_课程过程成绩.xlsx", "UTF-8"));
|
||||
workbook.write(response.getOutputStream());
|
||||
response.getOutputStream().flush();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("导出 Excel 失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 学员学籍异动申请 ==========
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addApplication(XYXJYDSQB entity) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
entity.setCjsj(now);
|
||||
entity.setXgsj(now);
|
||||
// 状态默认待审核(0)
|
||||
if (entity.getZt() == null || entity.getZt().isEmpty()) {
|
||||
entity.setZt("0");
|
||||
}
|
||||
xyxjydsqbMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteApplication(String bh) {
|
||||
xyxjydsqbMapper.deleteById(bh);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateApplication(XYXJYDSQB entity) {
|
||||
if (entity.getBh() == null || entity.getBh().isEmpty()) {
|
||||
throw new RuntimeException("异动申请编号不能为空");
|
||||
}
|
||||
// 后台自动更新修改时间,不修改创建时间
|
||||
entity.setXgsj(LocalDateTime.now());
|
||||
xyxjydsqbMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XYXJYDSQB getApplicationById(String bh) {
|
||||
return xyxjydsqbMapper.selectById(bh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<XYXJYDSQB> pageApplication(PageQuery query, XYXJYDSQB cond) {
|
||||
Page<XYXJYDSQB> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
LambdaQueryWrapper<XYXJYDSQB> wrapper = new LambdaQueryWrapper<>();
|
||||
if (cond != null) {
|
||||
wrapper.eq(isNotBlank(cond.getBh()), XYXJYDSQB::getBh, cond.getBh());
|
||||
wrapper.eq(isNotBlank(cond.getXybh()), XYXJYDSQB::getXybh, cond.getXybh());
|
||||
wrapper.eq(isNotBlank(cond.getSqlx()), XYXJYDSQB::getSqlx, cond.getSqlx());
|
||||
wrapper.eq(isNotBlank(cond.getZt()), XYXJYDSQB::getZt, cond.getZt());
|
||||
}
|
||||
wrapper.orderByDesc(XYXJYDSQB::getCjsj);
|
||||
Page<XYXJYDSQB> result = xyxjydsqbMapper.selectPage(page, wrapper);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal(),
|
||||
query.getPageNum(), query.getPageSize());
|
||||
}
|
||||
|
||||
private boolean isNotBlank(String value) {
|
||||
return value != null && !value.isEmpty();
|
||||
}
|
||||
|
||||
// ========== 学员学籍预警条件管理 ==========
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addWarningCondition(XYXJYJTJB entity) {
|
||||
if (entity.getBh() == null || entity.getBh().isEmpty()) {
|
||||
throw new RuntimeException("预警条件编号不能为空");
|
||||
}
|
||||
// 后台自动写入修改时间
|
||||
entity.setTy(0);
|
||||
entity.setXgsj(LocalDateTime.now());
|
||||
xyxjyjtjbMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateWarningCondition(XYXJYJTJB entity) {
|
||||
if (entity.getBh() == null || entity.getBh().isEmpty()) {
|
||||
throw new RuntimeException("预警条件编号不能为空");
|
||||
}
|
||||
// 后台自动更新修改时间
|
||||
entity.setXgsj(LocalDateTime.now());
|
||||
xyxjyjtjbMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XYXJYJTJB getWarningConditionById(String bh) {
|
||||
return xyxjyjtjbMapper.selectById(bh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<XYXJYJTJB> pageWarningCondition(PageQuery query, XYXJYJTJB cond) {
|
||||
Page<XYXJYJTJB> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
LambdaQueryWrapper<XYXJYJTJB> wrapper = new LambdaQueryWrapper<>();
|
||||
if (cond != null) {
|
||||
wrapper.eq(isNotBlank(cond.getBh()), XYXJYJTJB::getBh, cond.getBh());
|
||||
wrapper.like(isNotBlank(cond.getMc()), XYXJYJTJB::getMc, cond.getMc());
|
||||
wrapper.eq(isNotBlank(cond.getPxlx()), XYXJYJTJB::getPxlx, cond.getPxlx());
|
||||
wrapper.eq(isNotBlank(cond.getPxcc()), XYXJYJTJB::getPxcc, cond.getPxcc());
|
||||
wrapper.eq(cond.getTy() != null, XYXJYJTJB::getTy, cond.getTy());
|
||||
}
|
||||
wrapper.orderByDesc(XYXJYJTJB::getXgsj);
|
||||
Page<XYXJYJTJB> result = xyxjyjtjbMapper.selectPage(page, wrapper);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal(),
|
||||
query.getPageNum(), query.getPageSize());
|
||||
}
|
||||
|
||||
// ========== 学员学籍预警结果管理 ==========
|
||||
|
||||
@Override
|
||||
public XYXJYJJGB getWarningResultById(String bh) {
|
||||
return xyxjyjjgbMapper.selectById(bh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<XYXJYJJGB> pageWarningResult(PageQuery query, XYXJYJJGB cond) {
|
||||
Page<XYXJYJJGB> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
LambdaQueryWrapper<XYXJYJJGB> wrapper = new LambdaQueryWrapper<>();
|
||||
if (cond != null) {
|
||||
wrapper.eq(isNotBlank(cond.getBh()), XYXJYJJGB::getBh, cond.getBh());
|
||||
wrapper.eq(cond.getNd() != null, XYXJYJJGB::getNd, cond.getNd());
|
||||
wrapper.eq(isNotBlank(cond.getYjtjbh()), XYXJYJJGB::getYjtjbh, cond.getYjtjbh());
|
||||
wrapper.eq(isNotBlank(cond.getXybh()), XYXJYJJGB::getXybh, cond.getXybh());
|
||||
wrapper.eq(cond.getFb() != null, XYXJYJJGB::getFb, cond.getFb());
|
||||
}
|
||||
wrapper.orderByDesc(XYXJYJJGB::getCjsj);
|
||||
Page<XYXJYJJGB> result = xyxjyjjgbMapper.selectPage(page, wrapper);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal(),
|
||||
query.getPageNum(), query.getPageSize());
|
||||
}
|
||||
|
||||
// ========== 班次管理(学员队表 XYDB)==========
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addTeam(XYDB entity) {
|
||||
if (entity.getXydbh() == null || entity.getXydbh().isEmpty()) {
|
||||
throw new RuntimeException("学员队编号不能为空");
|
||||
}
|
||||
xydbMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteTeam(String xydbh) {
|
||||
xydbMapper.deleteById(xydbh);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateTeam(XYDB entity) {
|
||||
if (entity.getXydbh() == null || entity.getXydbh().isEmpty()) {
|
||||
throw new RuntimeException("学员队编号不能为空");
|
||||
}
|
||||
xydbMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XYDB getTeamById(String xydbh) {
|
||||
return xydbMapper.selectById(xydbh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<XYDB> pageTeam(PageQuery query, XYDB cond) {
|
||||
Page<XYDB> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
Page<XYDB> result = xydbMapper.selectPageList(page, cond);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal(),
|
||||
query.getPageNum(), query.getPageSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int importTeam(MultipartFile file) throws Exception {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new RuntimeException("导入文件不能为空");
|
||||
}
|
||||
List<XYDB> list = ExcelParseUtil.parseXYDBExcel(
|
||||
file.getInputStream(), file.getOriginalFilename());
|
||||
if (list.isEmpty()) {
|
||||
throw new RuntimeException("Excel中无有效数据");
|
||||
}
|
||||
for (XYDB entity : list) {
|
||||
xydbMapper.insert(entity);
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportTeam(XYDB cond, HttpServletResponse response) throws Exception {
|
||||
LambdaQueryWrapper<XYDB> wrapper = new LambdaQueryWrapper<>();
|
||||
if (cond != null) {
|
||||
wrapper.like(isNotBlank(cond.getXydmc()), XYDB::getXydmc, cond.getXydmc());
|
||||
wrapper.eq(isNotBlank(cond.getNj()), XYDB::getNj, cond.getNj());
|
||||
wrapper.eq(isNotBlank(cond.getZydh()), XYDB::getZydh, cond.getZydh());
|
||||
wrapper.eq(isNotBlank(cond.getRwlb()), XYDB::getRwlb, cond.getRwlb());
|
||||
wrapper.eq(isNotBlank(cond.getXydlx()), XYDB::getXydlx, cond.getXydlx());
|
||||
}
|
||||
wrapper.orderByAsc(XYDB::getXh);
|
||||
List<XYDB> list = xydbMapper.selectList(wrapper);
|
||||
|
||||
String[] headers = {
|
||||
"学员队编号", "学员队名称", "学员队人数", "年级", "专业代号", "专业教室编号", "备注",
|
||||
"在校状态", "序号", "任务类别", "虚实类型", "入学日期", "毕业日期", "学员队类型",
|
||||
"培训任务标识号", "节次类别", "系统模式", "JSONZD", "简称", "所属单位", "主体培训任务"
|
||||
};
|
||||
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + URLEncoder.encode("班次信息.xls", StandardCharsets.UTF_8));
|
||||
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
||||
Sheet sheet = workbook.createSheet("班次信息");
|
||||
Row headerRow = sheet.createRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
headerRow.createCell(i).setCellValue(headers[i]);
|
||||
}
|
||||
int rowIdx = 1;
|
||||
for (XYDB t : list) {
|
||||
Row row = sheet.createRow(rowIdx++);
|
||||
row.createCell(0).setCellValue(nvl(t.getXydbh()));
|
||||
row.createCell(1).setCellValue(nvl(t.getXydmc()));
|
||||
row.createCell(2).setCellValue(t.getXydrs() != null ? t.getXydrs().toString() : "");
|
||||
row.createCell(3).setCellValue(nvl(t.getNj()));
|
||||
row.createCell(4).setCellValue(nvl(t.getZydh()));
|
||||
row.createCell(5).setCellValue(nvl(t.getZyjsbh()));
|
||||
row.createCell(6).setCellValue(nvl(t.getBz()));
|
||||
row.createCell(7).setCellValue(nvl(t.getZxzt()));
|
||||
row.createCell(8).setCellValue(nvl(t.getXh()));
|
||||
row.createCell(9).setCellValue(nvl(t.getRwlb()));
|
||||
row.createCell(10).setCellValue(t.getXslx() != null ? t.getXslx().toString() : "");
|
||||
row.createCell(11).setCellValue(t.getRxrq() != null ? t.getRxrq().toString() : "");
|
||||
row.createCell(12).setCellValue(t.getByrq() != null ? t.getByrq().toString() : "");
|
||||
row.createCell(13).setCellValue(nvl(t.getXydlx()));
|
||||
row.createCell(14).setCellValue(nvl(t.getPxrwbsh()));
|
||||
row.createCell(15).setCellValue(nvl(t.getJclb()));
|
||||
row.createCell(16).setCellValue(nvl(t.getXtms()));
|
||||
row.createCell(17).setCellValue(nvl(t.getJsonzd()));
|
||||
row.createCell(18).setCellValue(nvl(t.getJc()));
|
||||
row.createCell(19).setCellValue(nvl(t.getSsdw()));
|
||||
row.createCell(20).setCellValue(t.getZtpxrw() != null ? t.getZtpxrw().toString() : "");
|
||||
}
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
OutputStream os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 学员信息批量导入 ==========
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int importStudents(MultipartFile file) throws Exception {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new RuntimeException("导入文件不能为空");
|
||||
}
|
||||
List<XYXX> list = ExcelParseUtil.parseXYXXExcel(
|
||||
file.getInputStream(), file.getOriginalFilename());
|
||||
if (list.isEmpty()) {
|
||||
throw new RuntimeException("Excel中无有效数据");
|
||||
}
|
||||
for (XYXX entity : list) {
|
||||
xyxxMapper.insert(entity);
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
private String nvl(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -7,6 +7,7 @@ import com.roomroot.jwgl.mapper.ZYBMapper;
|
||||
import com.roomroot.jwgl.service.TrainingProgramService;
|
||||
import com.roomroot.jwgl.unit.PageQuery;
|
||||
import com.roomroot.jwgl.unit.PageResult;
|
||||
import com.roomroot.jwgl.utils.UuidUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -30,6 +31,12 @@ public class TrainingProgramServiceImpl implements TrainingProgramService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(ZYB entity) {
|
||||
if (entity.getZydh() == null || entity.getZydh().isEmpty()) {
|
||||
entity.setZydh(UuidUtil.getOriginalUUID());
|
||||
}
|
||||
if (entity.getZybsh() == null || entity.getZybsh().isEmpty()) {
|
||||
entity.setZybsh(entity.getZydh());
|
||||
}
|
||||
entity.setTy(false);
|
||||
entity.setQysj(LocalDateTime.now());
|
||||
zybMapper.insert(entity);
|
||||
|
||||
Reference in New Issue
Block a user