| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean importQualityMonitor(MultipartFile file, QualityMonitor monitor) { |
| | | public QualityMonitor importQualityMonitor(MultipartFile file, QualityMonitor monitor) { |
| | | // 当前登录用户 |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | // 文件名称 |
| | |
| | | qualityMonitor.setWriteUserId(userId); |
| | | qualityMonitor.setExamineUserId(monitor.getExamineUserId()); |
| | | qualityMonitor.setWriteTime(LocalDateTime.now()); |
| | | qualityMonitor.setWorkflowStatus("PENDING_REVIEW"); |
| | | // 导入只生成草稿,导入的质控项目还需要补全检测标准、检测员等信息; |
| | | // 审核通知在编制人点击“提交审核”时统一发送。 |
| | | qualityMonitor.setWorkflowStatus("DRAFT"); |
| | | baseMapper.insert(qualityMonitor); |
| | | |
| | | User user = userMapper.selectById(userId); |
| | | // 消息发送 |
| | | InformationNotification info = new InformationNotification(); |
| | | // 发送人 |
| | | info.setCreateUser(user.getName()); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNAS质量监控计划审核通知"); |
| | | info.setContent(fileName + "质量监控计划待审核"); |
| | | info.setSenderId(userId); |
| | | // 接收人 |
| | | info.setConsigneeId(monitor.getExamineUserId()); |
| | | info.setJumpPath(MenuJumpPathConstants.QUALITY_MONITOR); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // 发送企业微信通知 |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // 查询发送人 |
| | | User people = userMapper.selectById(monitor.getExamineUserId()); |
| | | String message = ""; |
| | | message += "CNAS质量监控计划审核通知"; |
| | | message += "\n请去过程要求-质量监控计划"; |
| | | message += "\n" + fileName + "质量监控计划待审核"; |
| | | //发送企业微信消息通知 |
| | | try { |
| | | WxCpUtils.inform(people.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | |
| | | |
| | | List<QualityMonitorDetails> detailsUploadList = new ArrayList<>(); |
| | | |
| | |
| | | // 对象复制 |
| | | QualityMonitorDetails monitorDetails = new QualityMonitorDetails(); |
| | | BeanUtils.copyProperties(detailsUpload, monitorDetails); |
| | | monitorDetails.setMonitorWay(normalizeMonitorWay(detailsUpload.getMonitorWay())); |
| | | monitorDetails.setQualityMonitorId(qualityMonitor.getQualityMonitorId()); |
| | | if (!detailsUpload.getCompletionMonth().matches("\\d{4}-\\d{2}")) { |
| | | throw new ErrorException("完成时限格式应为yyyy-MM"); |
| | |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return true; |
| | | return qualityMonitor; |
| | | } |
| | | |
| | | /** |
| | | * 质控方式统一用“、”分隔,兼容导入模板里常见的逗号/分号写法。 |
| | | */ |
| | | private String normalizeMonitorWay(String value) { |
| | | if (StringUtils.isBlank(value)) { |
| | | return value; |
| | | } |
| | | return java.util.Arrays.stream(value.split("[、,,;;]")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::isNotBlank) |
| | | .distinct() |
| | | .collect(Collectors.joining("、")); |
| | | } |
| | | |
| | | /** |
| | |
| | | try { |
| | | response.setContentType("application/msword"); |
| | | String fileName = URLEncoder.encode( |
| | | "质量监控实施计划", "UTF-8"); |
| | | "质量控制措施", "UTF-8"); |
| | | response.setHeader("Content-disposition", |
| | | "attachment;filename=" + fileName + ".docx"); |
| | | OutputStream os = response.getOutputStream(); |
| | |
| | | try { |
| | | response.setContentType("application/msword"); |
| | | String fileName = URLEncoder.encode( |
| | | "监控评价", "UTF-8"); |
| | | "质量控制评价记录", "UTF-8"); |
| | | response.setHeader("Content-disposition", |
| | | "attachment;filename=" + fileName + ".docx"); |
| | | OutputStream os = response.getOutputStream(); |