学生信息导入优化,添加班级信息;个测导出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_CHILD = "sys_dept_child#20m";
/**
* OSS内容
*/

View File

@ -1,5 +1,7 @@
package org.dromara.common.core.service;
import java.util.Map;
/**
* 通用 部门服务
*
@ -15,4 +17,12 @@ public interface DeptService {
*/
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 converterExp = format.readConverterExp();
if (StrUtil.isNotBlank(dictType)) {
// 如果传递了字典名则依据字典建立下拉
Collection<String> values = Optional.ofNullable(dictService.getAllDictByDictType(dictType))
.orElseThrow(() -> new ServiceException(String.format("字典 %s 不存在", dictType)))
.values();
options = new ArrayList<>(values);
//判断是类型还是部门
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))
.orElseThrow(() -> new ServiceException(String.format("字典 %s 不存在", dictType)))
.values();
options = new ArrayList<>(values);
}
} else if (StrUtil.isNotBlank(converterExp)) {
// 如果指定了确切的值则直接解析确切的值
options = StrUtil.split(converterExp, format.separator(), true, true);

View File

@ -100,7 +100,6 @@ public class ScalePublishController extends BaseController {
/**
* 中止记录
*
*/
@SaCheckPermission("scale:publish:edit")
@Log(title = "中止量表发布", businessType = BusinessType.UPDATE)
@ -111,7 +110,6 @@ public class ScalePublishController extends BaseController {
/**
* 开始记录
*
*/
@SaCheckPermission("scale:publish:edit")
@Log(title = "中止量表发布", businessType = BusinessType.UPDATE)
@ -130,6 +128,7 @@ public class ScalePublishController extends BaseController {
public R<Void> delete(@NotNull(message = "主键不能为空") @PathVariable Long batchNo) {
return toAjax(sysScalePublishService.deleteById(batchNo));
}
/**
* 导出量测记录列表
*/
@ -142,7 +141,7 @@ public class ScalePublishController extends BaseController {
String pdfPath = pdf.getPath();
File pdfFile = new File(pdfPath);
AsposeUtil.wordToPdf(filePath, pdfFile);
FileUtils.setAttachmentResponseHeader(response, bo.getSessionName() + "的报告");
FileUtils.setAttachmentResponseHeader(response, bo.getSessionName() + "的报告");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
try (InputStream inputStream = new FileInputStream(pdfFile)) {
int available = inputStream.available();
@ -155,4 +154,18 @@ public class ScalePublishController extends BaseController {
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 org.apache.ibatis.annotations.Mapper;
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.scale.domain.SysWarnRecord;
import org.dromara.scale.domain.bo.BaseQueryBo;
@ -22,7 +24,10 @@ import java.util.List;
*/
@Mapper
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);
List<SysEvaluationRecordVo> selectEvaluationRecordListByWarnId(Long warnId);

View File

@ -53,5 +53,7 @@ public interface ISysScalePublishService {
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 lombok.RequiredArgsConstructor;
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.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -37,6 +38,7 @@ import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.rmi.ServerException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@ -59,6 +61,8 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
private final ISysConfigService configService;
private final DeptService deptService;
/**
* 查询量测记录
*/
@ -123,7 +127,8 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
SysUserVo user = userMapper.selectVoById(userId);
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()) ? "" : "");
SysScaleVo scale = scaleMapper.selectVoById(scaleId);
@ -142,8 +147,8 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
//一并处理数据
int size = answerVos.size();
LinkedList<WordFactor> factors = new LinkedList<>();
String[] strings = new String[size];
Double[] doubles = new Double[size];
List<String> strings = new ArrayList<>();
List<Double> doubles = new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < size; i++) {
WordEvaluationFactor answerVo = answerVos.get(i);
@ -193,18 +198,18 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
}
if (!"总分".equals(answerVo.getFactorName())) {
//雷达图使用
strings[i] = answerVo.getFactorName();
doubles[i] = score;
strings.add(answerVo.getFactorName());
doubles.add(score);
}
}
wordData.setFactor(factorTable);
wordData.setFactors(factors);
//处理雷达图
if (strings.length >1) {
if (strings.size() > 1) {
ChartMultiSeriesRenderData chart = Charts
.ofMultiSeries(scale.getScaleName(), strings)
.addSeries("因子项", doubles)
.ofMultiSeries(scale.getScaleName(), strings.toArray(String[]::new))
.addSeries("因子项", doubles.toArray(Double[]::new))
.create();
WordRadar radar = new WordRadar();
radar.setRadarChart(chart);

View File

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

View File

@ -8,6 +8,7 @@
from sys_warn_record wr
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_dept d on d.dept_id = u.dept_id
<where>
<if test="et.nickName != null and et.nickName != ''">
u.nick_name like CONCAT('%', #{et.nickName}, '%')
@ -19,10 +20,10 @@
and u.intervene_status = #{et.interveneStatus}
</if>
<if test="et.startTime != null and et.startTime != ''">
and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') &gt;= #{et.startTime}
and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') &gt;= #{et.startTime}
</if>
<if test="et.endTime != null and et.endTime != ''">
and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') &lt;= #{et.endTime}
and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') &lt;= #{et.endTime}
</if>
</where>
order by wr.warn_time desc

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package org.dromara.system.service;
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.vo.SysDeptVo;
@ -115,6 +116,12 @@ public interface ISysDeptService {
*/
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.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
/**
* 部门管理 服务实现
@ -138,6 +136,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return dept;
}
/**
* 通过部门ID查询部门名称
*
@ -326,13 +325,33 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return baseMapper.deleteById(deptId);
}
@Override
public Long selectIdByName(String deptName) {
SysDept sysDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>().select(SysDept::getDeptId).eq(SysDept::getDeptName, deptName));
if (ObjectUtil.isNotNull(sysDept)) {
return sysDept.getDeptId();
} else {
return 0L;
public Map<String, String> getChildrenDept() {
List<SysDept> deptList = SpringUtils.getAopProxy(this).selectChildDeptListByParentId(100L);
if (ObjectUtil.isEmpty(deptList)) {
return null;
}
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})
group by d.dept_id
</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>