ÎļþÃû´Ó cnas-require/src/main/java/com/ruoyi/require/service/impl/InsReportServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.require.service.impl; |
| | | package com.ruoyi.inspect.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.aspose.words.Document; |
| | | import com.aspose.words.License; |
| | | import com.aspose.words.SaveFormat; |
| | | import com.aspose.words.*; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | |
| | | import com.ruoyi.inspect.pojo.InsOrder; |
| | | import com.ruoyi.inspect.pojo.InsOrderState; |
| | | import com.ruoyi.inspect.pojo.InsReport; |
| | | import com.ruoyi.inspect.service.InsReportService; |
| | | import com.ruoyi.process.mapper.ProcessReportMapper; |
| | | import com.ruoyi.process.pojo.ProcessReport; |
| | | import com.ruoyi.require.service.InsReportService; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Slf4j |
| | | public class InsReportServiceImpl extends ServiceImpl<InsReportMapper, InsReport> |
| | | implements InsReportService { |
| | | |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | |
| | | |
| | | @Override |
| | | public IPage<ReportPageDto> pageInsReport(Page page, ReportPageDto reportPageDto) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | User user = userMapper.selectById(SecurityUtils.getUserId());//å½åç»å½ç人 |
| | | //è·åå½å人æå±å®éªå®¤id |
| | | String departLimsId = user.getDepartLimsId(); |
| | |
| | | wrapper.gt(reportPageDto.getCreateTimeRange().size()>1,"create_time",reportPageDto.getCreateTimeRange().get(0)) |
| | | .lt(reportPageDto.getCreateTimeRange().size()>1,"create_time",reportPageDto.getCreateTimeRange().get(1)); |
| | | } |
| | | return insReportMapper.pageInsReport(page, wrapper ,laboratory); |
| | | IPage<ReportPageDto> iPage = insReportMapper.pageInsReport(page, wrapper, laboratory); |
| | | return iPage; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int inReport(String url, Integer id) { |
| | |
| | | String url = ""; |
| | | // 0 ä¸è½½docx 1 ä¸è½½pdf |
| | | if(type == 0) { |
| | | url = Strings.isNotEmpty(insReport.getUrlS()) ? insReport.getUrlS() : insReport.getUrl(); |
| | | url = Strings.isNotEmpty(insReport.getUrlS()) ? insReport.getUrlS() : insReport.getUrl(); |
| | | }else { |
| | | url = insReport.getTempUrlPdf(); |
| | | } |
| | |
| | | insReport.setId(id); |
| | | insReport.setState(1); |
| | | insReport.setWriteTime(LocalDateTime.now());//æäº¤æ¶é´ |
| | | insReport.setWriteUserId(SecurityUtils.getUserId().intValue());//æäº¤äºº |
| | | insReport.setWriteUserId(Integer.getInteger(SecurityUtils.getUserId().toString()));//æäº¤äºº |
| | | //è·åæäº¤äººçç¾åå°å |
| | | String signatureUrl; |
| | | try { |
| | | signatureUrl = userMapper.selectById(SecurityUtils.getUserId().intValue()).getSignatureUrl(); |
| | | signatureUrl = userMapper.selectById(Integer.getInteger(SecurityUtils.getUserId().toString())).getSignatureUrl(); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("æ¾ä¸å°ç¼å¶äººçç¾å"); |
| | | } |
| | |
| | | if (ObjectUtils.isNotEmpty(examineTell)) { |
| | | insReport.setExamineTell(examineTell); |
| | | } |
| | | insReport.setExamineUserId(SecurityUtils.getUserId().intValue());//å®¡æ ¸äºº |
| | | insReport.setExamineUserId(Integer.getInteger(SecurityUtils.getUserId().toString()));//å®¡æ ¸äºº |
| | | insReport.setExamineTime(LocalDateTime.now());//å®¡æ ¸æ¶é´ |
| | | if (isExamine == 0) { |
| | | //å¦æå®¡æ ¸ä¸éè¿ |
| | |
| | | if (ObjectUtils.isNotEmpty(ratifyTell)) { |
| | | insReport.setRatifyTell(ratifyTell); |
| | | } |
| | | insReport.setRatifyUserId(SecurityUtils.getUserId().intValue());//æ¹å人 |
| | | insReport.setRatifyUserId(Integer.getInteger(SecurityUtils.getUserId().toString()));//æ¹å人 |
| | | insReport.setRatifyTime(LocalDateTime.now());//æ¹åæ¶é´ |
| | | if (isRatify == 0) { |
| | | //妿æ¹åä¸éè¿ |
| | |
| | | } |
| | | inReport("/word/" + pathName, insReport.getId()); |
| | | } |
| | | // File tempFile = null; |
| | | // File unzipDir = null; |
| | | // try { |
| | | // tempFile = File.createTempFile(wordUrl, ".zip"); |
| | | // file.transferTo(tempFile); |
| | | // |
| | | // unzipDir = new File("uploaded_files"); |
| | | // if (!unzipDir.exists()) { |
| | | // unzipDir.mkdir(); |
| | | // } |
| | | // unzip(tempFile, unzipDir); |
| | | // // å¤çè§£ååçæä»¶ |
| | | // File[] files = unzipDir.listFiles(); |
| | | // if (files != null) { |
| | | // for (File f : files) { |
| | | // // æ ¹æ®æä»¶åæ¥è¯¢id |
| | | // String name = f.getName(); |
| | | // String code = f.getName().replace(".docx", "").replace("JCZX", "JCZX/"); |
| | | // if(f.getName().lastIndexOf("_") != -1) { |
| | | // code = code.substring(f.getName().lastIndexOf("_") + 1); |
| | | // } |
| | | // //InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().eq(InsReport::getCode, f.getName().replace(".docx", "").replace("JCZX", "JCZX/"))); |
| | | // InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().eq(InsReport::getCode, code)); |
| | | // if (ObjectUtils.isEmpty(insReport)) { |
| | | // throw new ErrorException("æ²¡ææ¾å° " + f.getName() + " è¿ä¸ªæä»¶å¯¹åºçæ¥åæ°æ®"); |
| | | // } |
| | | // // 妿UrlSæå¼ å
å°è¯¥æä»¶å é¤ |
| | | // if(Strings.isNotEmpty(insReport.getUrlS())) { |
| | | // String url = wordUrl + File.separator + insReport.getUrlS().replace("/word/", ""); |
| | | // File file1 = new File(url); |
| | | // if(file1.exists()) { |
| | | // file1.delete(); |
| | | // } |
| | | // } |
| | | // String urlString; |
| | | // String pathName; |
| | | // try { |
| | | // String path = wordUrl; |
| | | // File realpath = new File(path); |
| | | // if (!realpath.exists()) { |
| | | // realpath.mkdirs(); |
| | | // } |
| | | // pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + insReport.getCode().replace("/", "") + ".docx"; |
| | | // urlString = realpath + "/" + pathName; |
| | | // // å¤å¶æä»¶å°æå®è·¯å¾ |
| | | // Files.copy(f.toPath(), new File(urlString).toPath(), StandardCopyOption.REPLACE_EXISTING); |
| | | // inReport("/word/" + pathName, insReport.getId()); |
| | | // } |
| | | // catch (IOException e) { |
| | | // throw new ErrorException("æä»¶ä¸ä¼ 失败"); |
| | | // } |
| | | // } |
| | | // } |
| | | // } catch (IOException e) { |
| | | // throw new ErrorException("æä»¶å¤ç失败"); |
| | | // } finally { |
| | | // if (tempFile != null && tempFile.exists()) { |
| | | // tempFile.delete(); |
| | | // } |
| | | // // éå½å é¤è§£åç®å½åå
¶ä¸çæä»¶ |
| | | // if (unzipDir.exists()) { |
| | | // deleteDirectory(unzipDir); // å 餿§çä¸´æ¶æä»¶å¤¹ |
| | | // } |
| | | // } |
| | | return 0; |
| | | } |
| | | |
| | |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | Integer insOrderId = insReportMapper.selectById(id).getInsOrderId(); |
| | | insOrderStateMapper.selectList(new LambdaQueryWrapper<InsOrderState>() |
| | | .eq(InsOrderState::getInsOrderId,insOrderId)) |
| | | .eq(InsOrderState::getInsOrderId,insOrderId)) |
| | | .forEach(insOrderState -> { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("label",insOrderState.getLaboratory()); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void batchApprovalReport(List<Integer> ids) { |
| | | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | Integer userId = Integer.parseInt(SecurityUtils.getUserId().toString()); |
| | | String key = SYNC_REPORT_KEY_PREFIX+userId; |
| | | //æ§è¡åå é¤ä¹åçkeys |
| | | deleteRedisKeys(key); |
| | |
| | | |
| | | @Override |
| | | public Map<String, Object> getBatchApprovalProgress() { |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | Integer userId = Integer.parseInt(SecurityUtils.getUserId().toString()); |
| | | String key = SYNC_REPORT_KEY_PREFIX + userId; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("hasProgress",false); |
| | |
| | | file = new File(pdfPath); |
| | | os = new FileOutputStream(file); |
| | | //è¦è½¬æ¢çwordæä»¶ |
| | | Document doc = new Document(wordPath); |
| | | com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); |
| | | doc.save(os, SaveFormat.PDF); |
| | | String name = file.getName(); |
| | | return file.getName(); |