| | |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.WxCpUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.util.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.personnel.dto.PersonTrainingRecordDto; |
| | | import com.ruoyi.personnel.dto.PersonTrainingRecordListDto; |
| | |
| | | |
| | | @Override |
| | | public void exportTrainingRecordAddTrainingDate(Integer userId, Integer trainingDate, HttpServletResponse response) { |
| | | if (userId == null) { |
| | | throw new ErrorException("缺少人员id"); |
| | | } |
| | | // 查询人员人信息 |
| | | PersonTrainingRecordListDto trainingRecordListDto = baseMapper.selectUserTraining(userId); |
| | | if (trainingRecordListDto == null) { |
| | | throw new ErrorException("人员不存在或已被删除,无法导出"); |
| | | } |
| | | |
| | | // 查询培训记录 |
| | | List<TrainingRecordPersonDetailedDto> personDetailedDtos = baseMapper.selectPersonDetailedDtosByTrainingDate(userId, trainingDate); |
| | |
| | | |
| | | // 获取路径 |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/training-record.docx"); |
| | | if (inputStream == null) { |
| | | throw new ErrorException("培训记录导出模板不存在"); |
| | | } |
| | | Configure configure = Configure.builder() |
| | | .bind("personnelDetailsLisat", new HackLoopTableRenderPolicy()) |
| | | .build(); |
| | |
| | | */ |
| | | @Override |
| | | public void trainingAndAssessmentRecordsAdded(PersonTrainingRecordSubmitDto personTrainingRecordSubmitDto) { |
| | | if (personTrainingRecordSubmitDto == null || personTrainingRecordSubmitDto.getTrainingDetailedId() == null) { |
| | | throw new ErrorException("缺少培训明细id"); |
| | | } |
| | | if (personTrainingRecordSubmitDto.getState() == null) { |
| | | throw new ErrorException("缺少培训状态"); |
| | | } |
| | | PersonTrainingDetailed personPersonnelCapacity = personTrainingDetailedService.getById(personTrainingRecordSubmitDto.getTrainingDetailedId()); |
| | | if (personPersonnelCapacity == null) { |
| | | throw new ErrorException("培训记录不存在或已被删除"); |
| | | } |
| | | boolean waitEvaluate = Integer.valueOf(2).equals(personTrainingRecordSubmitDto.getState()); |
| | | if (waitEvaluate && personTrainingRecordSubmitDto.getAssessmentUserId() == null) { |
| | | throw new ErrorException("请选择评价人"); |
| | | } |
| | | |
| | | personTrainingDetailedService.update(Wrappers.<PersonTrainingDetailed>lambdaUpdate() |
| | | .eq(PersonTrainingDetailed::getId, personTrainingRecordSubmitDto.getTrainingDetailedId()) |
| | | .set(PersonTrainingDetailed::getAssessmentMethod, personTrainingRecordSubmitDto.getAssessmentMethod()) |
| | |
| | | .set(PersonTrainingDetailed::getAssessmentUserId, personTrainingRecordSubmitDto.getAssessmentUserId()) |
| | | .set(PersonTrainingDetailed::getState, personTrainingRecordSubmitDto.getState())); |
| | | |
| | | // 发送消息通知 |
| | | if (personTrainingRecordSubmitDto.getState().equals(2)) { |
| | | PersonTrainingDetailed personPersonnelCapacity = personTrainingDetailedService.getById(personTrainingRecordSubmitDto.getTrainingDetailedId()); |
| | | |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | User user = userMapper.selectById(userId); |
| | | // 消息发送 |
| | | InformationNotification info = new InformationNotification(); |
| | | // 发送人 |
| | | info.setCreateUser(user.getName()); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNAS人员培训计划待评价"); |
| | | info.setContent("培训内容:" + personPersonnelCapacity.getTrainingContent() + "的人员培训待评价"); |
| | | info.setSenderId(userId); |
| | | // 接收人 |
| | | info.setConsigneeId(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // 发送企业微信通知 |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // 查询接收人 |
| | | User personnel = userMapper.selectById(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | |
| | | String message = ""; |
| | | message += "CNAS人员培训计划待评价"; |
| | | message += "\n请去资源管理-人员-人员培训计划"; |
| | | message += "\n" + "培训内容:" + personPersonnelCapacity.getTrainingContent() + "的人员培训待评价"; |
| | | //发送企业微信消息通知 |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | // 只有提交待评价时才通知评价人 |
| | | if (!waitEvaluate) { |
| | | return; |
| | | } |
| | | |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | User user = userMapper.selectById(userId); |
| | | // 消息发送 |
| | | InformationNotification info = new InformationNotification(); |
| | | // 发送人 |
| | | info.setCreateUser(user != null ? user.getName() : ""); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNAS人员培训计划待评价"); |
| | | info.setContent("培训内容:" + personPersonnelCapacity.getTrainingContent() + "的人员培训待评价"); |
| | | info.setSenderId(userId); |
| | | // 接收人 |
| | | info.setConsigneeId(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // 发送企业微信通知 |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // 查询接收人 |
| | | User personnel = userMapper.selectById(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | if (personnel == null || personnel.getAccount() == null || personnel.getAccount().trim().isEmpty()) { |
| | | return; |
| | | } |
| | | String message = ""; |
| | | message += "CNAS人员培训计划待评价"; |
| | | message += "\n请去资源管理-人员-人员培训计划"; |
| | | message += "\n" + "培训内容:" + personPersonnelCapacity.getTrainingContent() + "的人员培训待评价"; |
| | | //发送企业微信消息通知 |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |