diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheNames.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheNames.java index 6436516..540bc77 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheNames.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheNames.java @@ -45,6 +45,11 @@ public interface CacheNames { */ String SYS_DEPT = "sys_dept#30d"; + /** + * 部门 + */ + String SYS_DEPT_CHILD = "sys_dept_child#20m"; + /** * OSS内容 */ diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/DeptService.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/DeptService.java index db9463e..166b892 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/DeptService.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/DeptService.java @@ -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为key,dictLabel为值组成的Map + */ + Map getChildrenDept(); + } diff --git a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/ExcelDownHandler.java b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/ExcelDownHandler.java index 0aca5d5..f8f3e51 100644 --- a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/ExcelDownHandler.java +++ b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/ExcelDownHandler.java @@ -104,11 +104,19 @@ public class ExcelDownHandler implements SheetWriteHandler { String dictType = format.dictType(); String converterExp = format.readConverterExp(); if (StrUtil.isNotBlank(dictType)) { - // 如果传递了字典名,则依据字典建立下拉 - Collection values = Optional.ofNullable(dictService.getAllDictByDictType(dictType)) - .orElseThrow(() -> new ServiceException(String.format("字典 %s 不存在", dictType))) - .values(); - options = new ArrayList<>(values); + //判断是类型还是部门 + if("dept".equals(dictType)){ + Collection values = Optional.ofNullable(deptService.getChildrenDept()) + .orElseThrow(() -> new ServiceException("不存在班级,请确认后再试")) + .values(); + options = new ArrayList<>(values); + }else { + // 如果传递了字典名,则依据字典建立下拉 + Collection 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); diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java index 1280d40..7c70e9d 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java @@ -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 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 exportCheck(BaseQueryBo bo) throws IOException { + int num = sysScalePublishService.checkWord(bo); + if (num == 0) { + return R.fail("本场次暂无完成的量测记录,请测评后再导出"); + } else { + return R.ok(); + } + } } diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/mapper/SysWarnRecordMapper.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/mapper/SysWarnRecordMapper.java index b193076..3f55847 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/mapper/SysWarnRecordMapper.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/mapper/SysWarnRecordMapper.java @@ -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 { - + @DataPermission({ + @DataColumn(key = "deptName", value = "d.dept_id"), + @DataColumn(key = "userName", value = "u.user_id") + }) Page selectPageWarnList(@Param("page") Page page, @Param(Constants.ENTITY) BaseQueryBo query); List selectEvaluationRecordListByWarnId(Long warnId); diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java index 6b845b7..881d380 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java @@ -53,5 +53,7 @@ public interface ISysScalePublishService { String getWordTemplate(BaseQueryBo bo) throws IOException; + int checkWord(BaseQueryBo bo); + } diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java index b98b148..4bf745d 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java @@ -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 factors = new LinkedList<>(); - String[] strings = new String[size]; - Double[] doubles = new Double[size]; + List strings = new ArrayList<>(); + List 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); diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java index c73ba33..fdf163d 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java @@ -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; diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysWarnRecordMapper.xml b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysWarnRecordMapper.xml index 275afac..8ff7fd3 100644 --- a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysWarnRecordMapper.xml +++ b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysWarnRecordMapper.xml @@ -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 u.nick_name like CONCAT('%', #{et.nickName}, '%') @@ -19,10 +20,10 @@ and u.intervene_status = #{et.interveneStatus} - and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') >= #{et.startTime} + and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') >= #{et.startTime} - and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') <= #{et.endTime} + and DATE_FORMAT(wr.warn_time, '%Y-%m-%d') <= #{et.endTime} order by wr.warn_time desc diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx b/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx index 45e0721..06af6b6 100644 Binary files a/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx and b/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx differ diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/word/~$rsonalTemplate.docx b/ruoyi-modules/rouyi-scale/src/main/resources/word/~$rsonalTemplate.docx new file mode 100644 index 0000000..aef1aef Binary files /dev/null and b/ruoyi-modules/rouyi-scale/src/main/resources/word/~$rsonalTemplate.docx differ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysStudentImportVo.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysStudentImportVo.java index 0673bd1..feca495 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysStudentImportVo.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysStudentImportVo.java @@ -27,6 +27,7 @@ public class SysStudentImportVo implements Serializable { * 部门ID */ @ExcelProperty(value = "部门名称") + @ExcelDictFormat(dictType = "dept") private String deptName; /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/listener/SysStudentImportListener.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/listener/SysStudentImportListener.java index 5eec510..5c81cce 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/listener/SysStudentImportListener.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/listener/SysStudentImportListener.java @@ -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").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功"); - } else { - failureNum++; - failureMsg.append("
").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("
").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功"); } else { failureNum++; - failureMsg.append("
").append(failureNum).append("、账号 ").append(userVo.getUserName()).append(" 查询不到部门"); + failureMsg.append("
").append(failureNum).append("、账号 ").append(userVo.getUserName()).append(" 已存在"); } } catch (Exception e) { failureNum++; diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java index 76bee72..e9d23c2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java @@ -51,4 +51,6 @@ public interface SysDeptMapper extends BaseMapperPlus { List findDeptNameByUserIds(String userIds); + + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysDeptService.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysDeptService.java index 82adb90..8dda22f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysDeptService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysDeptService.java @@ -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 selectChildDeptListByParentId(Long parentId); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java index 93f71de..404806b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java @@ -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().select(SysDept::getDeptId).eq(SysDept::getDeptName, deptName)); - if (ObjectUtil.isNotNull(sysDept)) { - return sysDept.getDeptId(); - } else { - return 0L; + public Map getChildrenDept() { + List deptList = SpringUtils.getAopProxy(this).selectChildDeptListByParentId(100L); + if (ObjectUtil.isEmpty(deptList)) { + return null; } + LinkedHashMap map = new LinkedHashMap<>(); + for (SysDept sysDept : deptList) { + List 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 selectChildDeptListByParentId(Long parentId) { + return baseMapper.selectList(new LambdaQueryWrapper() + .select(SysDept::getDeptId, SysDept::getDeptName) + .eq(SysDept::getParentId, parentId) + .orderByAsc(SysDept::getParentId) + .orderByAsc(SysDept::getOrderNum) + .orderByAsc(SysDept::getDeptId)); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index e1b495e..74bb91c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -43,4 +43,11 @@ where find_in_set(user_id, #{userIds}) group by d.dept_id + +