学生信息导入优化,添加班级信息;个测导出bug优化;团体导出添加判断接口;干预/预警列表添加数据权限

This commit is contained in:
cjw 2024-06-07 11:05:25 +08:00
parent 8ac8a81644
commit 6a70b64dfa
17 changed files with 133 additions and 49 deletions

View File

@ -45,6 +45,11 @@ public interface CacheNames {
*/ */
String SYS_DEPT = "sys_dept#30d"; String SYS_DEPT = "sys_dept#30d";
/**
* 部门
*/
String SYS_DEPT_CHILD = "sys_dept_child#20m";
/** /**
* OSS内容 * OSS内容
*/ */

View File

@ -1,5 +1,7 @@
package org.dromara.common.core.service; package org.dromara.common.core.service;
import java.util.Map;
/** /**
* 通用 部门服务 * 通用 部门服务
* *
@ -15,4 +17,12 @@ public interface DeptService {
*/ */
String selectDeptNameByIds(String deptIds); String selectDeptNameByIds(String deptIds);
/**
* 获取所有的叶子部门
*
* @return dictValue为keydictLabel为值组成的Map
*/
Map<String, String> getChildrenDept();
} }

View File

@ -104,11 +104,19 @@ public class ExcelDownHandler implements SheetWriteHandler {
String dictType = format.dictType(); String dictType = format.dictType();
String converterExp = format.readConverterExp(); String converterExp = format.readConverterExp();
if (StrUtil.isNotBlank(dictType)) { if (StrUtil.isNotBlank(dictType)) {
//判断是类型还是部门
if("dept".equals(dictType)){
Collection<String> values = Optional.ofNullable(deptService.getChildrenDept())
.orElseThrow(() -> new ServiceException("不存在班级,请确认后再试"))
.values();
options = new ArrayList<>(values);
}else {
// 如果传递了字典名则依据字典建立下拉 // 如果传递了字典名则依据字典建立下拉
Collection<String> values = Optional.ofNullable(dictService.getAllDictByDictType(dictType)) Collection<String> values = Optional.ofNullable(dictService.getAllDictByDictType(dictType))
.orElseThrow(() -> new ServiceException(String.format("字典 %s 不存在", dictType))) .orElseThrow(() -> new ServiceException(String.format("字典 %s 不存在", dictType)))
.values(); .values();
options = new ArrayList<>(values); options = new ArrayList<>(values);
}
} else if (StrUtil.isNotBlank(converterExp)) { } else if (StrUtil.isNotBlank(converterExp)) {
// 如果指定了确切的值则直接解析确切的值 // 如果指定了确切的值则直接解析确切的值
options = StrUtil.split(converterExp, format.separator(), true, true); options = StrUtil.split(converterExp, format.separator(), true, true);

View File

@ -100,7 +100,6 @@ public class ScalePublishController extends BaseController {
/** /**
* 中止记录 * 中止记录
*
*/ */
@SaCheckPermission("scale:publish:edit") @SaCheckPermission("scale:publish:edit")
@Log(title = "中止量表发布", businessType = BusinessType.UPDATE) @Log(title = "中止量表发布", businessType = BusinessType.UPDATE)
@ -111,7 +110,6 @@ public class ScalePublishController extends BaseController {
/** /**
* 开始记录 * 开始记录
*
*/ */
@SaCheckPermission("scale:publish:edit") @SaCheckPermission("scale:publish:edit")
@Log(title = "中止量表发布", businessType = BusinessType.UPDATE) @Log(title = "中止量表发布", businessType = BusinessType.UPDATE)
@ -130,6 +128,7 @@ public class ScalePublishController extends BaseController {
public R<Void> delete(@NotNull(message = "主键不能为空") @PathVariable Long batchNo) { public R<Void> delete(@NotNull(message = "主键不能为空") @PathVariable Long batchNo) {
return toAjax(sysScalePublishService.deleteById(batchNo)); return toAjax(sysScalePublishService.deleteById(batchNo));
} }
/** /**
* 导出量测记录列表 * 导出量测记录列表
*/ */
@ -155,4 +154,18 @@ public class ScalePublishController extends BaseController {
FileUtil.del(pdfPath); FileUtil.del(pdfPath);
} }
} }
/**
* 导出量测记录列表
*/
@SaCheckPermission("scale:publish:export")
@GetMapping("/export/check")
public R<Void> exportCheck(BaseQueryBo bo) throws IOException {
int num = sysScalePublishService.checkWord(bo);
if (num == 0) {
return R.fail("本场次暂无完成的量测记录,请测评后再导出");
} else {
return R.ok();
}
}
} }

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.dromara.common.mybatis.annotation.DataColumn;
import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.scale.domain.SysWarnRecord; import org.dromara.scale.domain.SysWarnRecord;
import org.dromara.scale.domain.bo.BaseQueryBo; import org.dromara.scale.domain.bo.BaseQueryBo;
@ -22,7 +24,10 @@ import java.util.List;
*/ */
@Mapper @Mapper
public interface SysWarnRecordMapper extends BaseMapperPlus<SysWarnRecord, SysWarnRecordVo> { public interface SysWarnRecordMapper extends BaseMapperPlus<SysWarnRecord, SysWarnRecordVo> {
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
Page<SysWarnRecordVo> selectPageWarnList(@Param("page") Page<SysWarnRecord> page, @Param(Constants.ENTITY) BaseQueryBo query); Page<SysWarnRecordVo> selectPageWarnList(@Param("page") Page<SysWarnRecord> page, @Param(Constants.ENTITY) BaseQueryBo query);
List<SysEvaluationRecordVo> selectEvaluationRecordListByWarnId(Long warnId); List<SysEvaluationRecordVo> selectEvaluationRecordListByWarnId(Long warnId);

View File

@ -53,5 +53,7 @@ public interface ISysScalePublishService {
String getWordTemplate(BaseQueryBo bo) throws IOException; String getWordTemplate(BaseQueryBo bo) throws IOException;
int checkWord(BaseQueryBo bo);
} }

View File

@ -12,6 +12,7 @@ import com.deepoove.poi.data.style.BorderStyle;
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy; import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.dromara.common.core.service.DeptService;
import org.dromara.common.core.utils.DateUtils; import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -37,6 +38,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.rmi.ServerException; import java.rmi.ServerException;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -59,6 +61,8 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
private final ISysConfigService configService; private final ISysConfigService configService;
private final DeptService deptService;
/** /**
* 查询量测记录 * 查询量测记录
*/ */
@ -123,7 +127,8 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
SysUserVo user = userMapper.selectVoById(userId); SysUserVo user = userMapper.selectVoById(userId);
wordData.setNickName(user.getNickName()); wordData.setNickName(user.getNickName());
wordData.setDeptName(user.getDept().getDeptName()); String s = deptService.selectDeptNameByIds(Long.toString(user.getDeptId()));
wordData.setDeptName(s);
wordData.setSex("0".equals(user.getSex()) ? "" : ""); wordData.setSex("0".equals(user.getSex()) ? "" : "");
SysScaleVo scale = scaleMapper.selectVoById(scaleId); SysScaleVo scale = scaleMapper.selectVoById(scaleId);
@ -142,8 +147,8 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
//一并处理数据 //一并处理数据
int size = answerVos.size(); int size = answerVos.size();
LinkedList<WordFactor> factors = new LinkedList<>(); LinkedList<WordFactor> factors = new LinkedList<>();
String[] strings = new String[size]; List<String> strings = new ArrayList<>();
Double[] doubles = new Double[size]; List<Double> doubles = new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
WordEvaluationFactor answerVo = answerVos.get(i); WordEvaluationFactor answerVo = answerVos.get(i);
@ -193,18 +198,18 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
} }
if (!"总分".equals(answerVo.getFactorName())) { if (!"总分".equals(answerVo.getFactorName())) {
//雷达图使用 //雷达图使用
strings[i] = answerVo.getFactorName(); strings.add(answerVo.getFactorName());
doubles[i] = score; doubles.add(score);
} }
} }
wordData.setFactor(factorTable); wordData.setFactor(factorTable);
wordData.setFactors(factors); wordData.setFactors(factors);
//处理雷达图 //处理雷达图
if (strings.length >1) { if (strings.size() > 1) {
ChartMultiSeriesRenderData chart = Charts ChartMultiSeriesRenderData chart = Charts
.ofMultiSeries(scale.getScaleName(), strings) .ofMultiSeries(scale.getScaleName(), strings.toArray(String[]::new))
.addSeries("因子项", doubles) .addSeries("因子项", doubles.toArray(Double[]::new))
.create(); .create();
WordRadar radar = new WordRadar(); WordRadar radar = new WordRadar();
radar.setRadarChart(chart); radar.setRadarChart(chart);

View File

@ -453,6 +453,12 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
return wordPath; return wordPath;
} }
@Override
public int checkWord(BaseQueryBo bo) {
//查询前置用来判断
return recordMapper.selectCompleteNumByBatchNo(bo.getBatchNo());
}
private int processHalfUpPercent(int num, int total) { private int processHalfUpPercent(int num, int total) {
if (total == 0) { if (total == 0) {
return 0; return 0;

View File

@ -8,6 +8,7 @@
from sys_warn_record wr from sys_warn_record wr
left join sys_scale_publish sp on sp.batch_no = wr.batch_no left join sys_scale_publish sp on sp.batch_no = wr.batch_no
left join sys_user u on u.user_id = wr.user_id left join sys_user u on u.user_id = wr.user_id
left join sys_dept d on d.dept_id = u.dept_id
<where> <where>
<if test="et.nickName != null and et.nickName != ''"> <if test="et.nickName != null and et.nickName != ''">
u.nick_name like CONCAT('%', #{et.nickName}, '%') u.nick_name like CONCAT('%', #{et.nickName}, '%')

View File

@ -27,6 +27,7 @@ public class SysStudentImportVo implements Serializable {
* 部门ID * 部门ID
*/ */
@ExcelProperty(value = "部门名称") @ExcelProperty(value = "部门名称")
@ExcelDictFormat(dictType = "dept")
private String deptName; private String deptName;
/** /**

View File

@ -8,6 +8,7 @@ import com.alibaba.excel.event.AnalysisEventListener;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.SpringUtils; import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.ValidatorUtils; import org.dromara.common.core.utils.ValidatorUtils;
import org.dromara.common.excel.core.ExcelListener; import org.dromara.common.excel.core.ExcelListener;
import org.dromara.common.excel.core.ExcelResult; import org.dromara.common.excel.core.ExcelResult;
@ -16,7 +17,6 @@ import org.dromara.system.domain.bo.SysUserBo;
import org.dromara.system.domain.vo.SysStudentImportVo; import org.dromara.system.domain.vo.SysStudentImportVo;
import org.dromara.system.domain.vo.SysUserVo; import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.service.ISysConfigService; import org.dromara.system.service.ISysConfigService;
import org.dromara.system.service.ISysDeptService;
import org.dromara.system.service.ISysUserService; import org.dromara.system.service.ISysUserService;
import java.util.List; import java.util.List;
@ -31,8 +31,6 @@ public class SysStudentImportListener extends AnalysisEventListener<SysStudentIm
private final ISysUserService userService; private final ISysUserService userService;
private final ISysDeptService deptService;
private final String password; private final String password;
private final Long operUserId; private final Long operUserId;
@ -45,7 +43,6 @@ public class SysStudentImportListener extends AnalysisEventListener<SysStudentIm
public SysStudentImportListener() { public SysStudentImportListener() {
String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword"); String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword");
this.userService = SpringUtils.getBean(ISysUserService.class); this.userService = SpringUtils.getBean(ISysUserService.class);
this.deptService = SpringUtils.getBean(ISysDeptService.class);
this.password = BCrypt.hashpw(initPassword); this.password = BCrypt.hashpw(initPassword);
this.operUserId = LoginHelper.getUserId(); this.operUserId = LoginHelper.getUserId();
} }
@ -54,14 +51,14 @@ public class SysStudentImportListener extends AnalysisEventListener<SysStudentIm
public void invoke(SysStudentImportVo userVo, AnalysisContext context) { public void invoke(SysStudentImportVo userVo, AnalysisContext context) {
SysUserVo sysUser = this.userService.selectUserByUserName(userVo.getUserName()); SysUserVo sysUser = this.userService.selectUserByUserName(userVo.getUserName());
try { try {
Long deptId = this.deptService.selectIdByName(userVo.getDeptName());
if (deptId != 0) {
// 验证是否存在这个用户 // 验证是否存在这个用户
if (ObjectUtil.isNull(sysUser)) { if (ObjectUtil.isNull(sysUser)) {
SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class); SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class);
ValidatorUtils.validate(user); ValidatorUtils.validate(user);
user.setPassword(password); user.setPassword(password);
user.setDeptId(deptId); if (StringUtils.isNotEmpty(userVo.getDeptName())) {
user.setDeptId(Long.parseLong(userVo.getDeptName()));
}
user.setCreateBy(operUserId); user.setCreateBy(operUserId);
userService.insertUser(user); userService.insertUser(user);
successNum++; successNum++;
@ -70,10 +67,6 @@ public class SysStudentImportListener extends AnalysisEventListener<SysStudentIm
failureNum++; failureNum++;
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(userVo.getUserName()).append(" 已存在"); failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(userVo.getUserName()).append(" 已存在");
} }
} else {
failureNum++;
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(userVo.getUserName()).append(" 查询不到部门");
}
} catch (Exception e) { } catch (Exception e) {
failureNum++; failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + userVo.getUserName() + " 导入失败:"; String msg = "<br/>" + failureNum + "、账号 " + userVo.getUserName() + " 导入失败:";

View File

@ -51,4 +51,6 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
List<String> findDeptNameByUserIds(String userIds); List<String> findDeptNameByUserIds(String userIds);
} }

View File

@ -1,6 +1,7 @@
package org.dromara.system.service; package org.dromara.system.service;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.bo.SysDeptBo; import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.domain.vo.SysDeptVo; import org.dromara.system.domain.vo.SysDeptVo;
@ -115,6 +116,12 @@ public interface ISysDeptService {
*/ */
int deleteDeptById(Long deptId); int deleteDeptById(Long deptId);
Long selectIdByName(String deptName); /**
* 根据角色ID查询部门树信息
*
* @param parentId 角色ID
* @return 选中部门列表
*/
List<SysDept> selectChildDeptListByParentId(Long parentId);
} }

View File

@ -32,9 +32,7 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
/** /**
* 部门管理 服务实现 * 部门管理 服务实现
@ -138,6 +136,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return dept; return dept;
} }
/** /**
* 通过部门ID查询部门名称 * 通过部门ID查询部门名称
* *
@ -326,13 +325,33 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return baseMapper.deleteById(deptId); return baseMapper.deleteById(deptId);
} }
@Override @Override
public Long selectIdByName(String deptName) { public Map<String, String> getChildrenDept() {
SysDept sysDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>().select(SysDept::getDeptId).eq(SysDept::getDeptName, deptName)); List<SysDept> deptList = SpringUtils.getAopProxy(this).selectChildDeptListByParentId(100L);
if (ObjectUtil.isNotNull(sysDept)) { if (ObjectUtil.isEmpty(deptList)) {
return sysDept.getDeptId(); return null;
} else {
return 0L;
} }
LinkedHashMap<String, String> map = new LinkedHashMap<>();
for (SysDept sysDept : deptList) {
List<SysDept> depts = SpringUtils.getAopProxy(this).selectChildDeptListByParentId(sysDept.getDeptId());
if (ObjectUtil.isNotEmpty(depts)) {
for (SysDept dept : depts) {
map.put(Long.toString(dept.getDeptId()), dept.getDeptName());
}
}
}
return map;
}
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_CHILD, key = "#parentId")
@Override
public List<SysDept> selectChildDeptListByParentId(Long parentId) {
return baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId, SysDept::getDeptName)
.eq(SysDept::getParentId, parentId)
.orderByAsc(SysDept::getParentId)
.orderByAsc(SysDept::getOrderNum)
.orderByAsc(SysDept::getDeptId));
} }
} }

View File

@ -43,4 +43,11 @@
where find_in_set(user_id, #{userIds}) where find_in_set(user_id, #{userIds})
group by d.dept_id group by d.dept_id
</select> </select>
<select id="selectChildListByParentId" resultType="java.lang.Long">
select dept_id
from sys_dept
where parent_id = #{parentId}
order by parent_id, order_num, dept_id
</select>
</mapper> </mapper>