From 97bb7a8832281eafe0ef947ea095258d355e52f5 Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期一, 30 十二月 2024 15:57:51 +0800 Subject: [PATCH] 无源器件的数采+电路模版查询 --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java | 106 +++++++++++++++-------------------------------------- 1 files changed, 30 insertions(+), 76 deletions(-) diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java index d7805c8..ca5212b 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java @@ -26,10 +26,7 @@ import com.itextpdf.text.pdf.PdfStamper; import com.yuanchu.mom.common.GetLook; import com.yuanchu.mom.common.PrintChina; -import com.yuanchu.mom.dto.InsReportDto; -import com.yuanchu.mom.dto.InsReportDto1; -import com.yuanchu.mom.dto.ReportPageDto; -import com.yuanchu.mom.dto.SampleProductDto; +import com.yuanchu.mom.dto.*; import com.yuanchu.mom.exception.ErrorException; import com.yuanchu.mom.mapper.*; import com.yuanchu.mom.pojo.*; @@ -44,6 +41,7 @@ import org.apache.logging.log4j.util.Strings; import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.ParagraphAlignment; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @@ -88,6 +86,9 @@ @Resource private InsReportMapper insReportMapper; + @Autowired + ProcessReportMapper1 processReportMapper; + @Value("${wordUrl}") private String wordUrl; @@ -99,9 +100,6 @@ @Resource private InsOrderMapper insOrderMapper; - - @Resource - private StandardMethodListMapper standardMethodListMapper; @Resource private InsOrderStateMapper insOrderStateMapper; @@ -142,19 +140,7 @@ map.put("head", PrintChina.printChina(ReportPageDto.class)); Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("pageInsReport"); if (map1.get("look") == 1) reportPageDto.setCreateUser(map1.get("userId")); - User user = userMapper.selectById(map1.get("userId"));//褰撳墠鐧诲綍鐨勪汉 - //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id - String departLimsId = user.getDepartLimsId(); - String laboratory = null; - if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) { - String[] split = departLimsId.split(","); - //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙) - String departLims = insOrderMapper.seldepLimsId(Integer.parseInt(split[split.length - 1])); - if (departLims.contains("瀹為獙瀹�")) { - laboratory = departLims; - } - } - map.put("body", insReportMapper.pageInsReport(page, QueryWrappers.queryWrappers(reportPageDto), laboratory)); + map.put("body", insReportMapper.pageInsReport(page, QueryWrappers.queryWrappers(reportPageDto))); return map; } @@ -251,15 +237,6 @@ } catch (Exception e) { throw new ErrorException("鎵句笉鍒版壒鍑嗕汉鐨勭鍚�"); } - //鑾峰彇鍦烘墍鐨勬姤鍛婁笓鐢ㄧ珷 - /* String sealUrl; - try { - String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory(); - sealUrl = insReportMapper.getLaboratoryByName(laboratory); - } catch (Exception e) { - throw new ErrorException("鎵句笉鍒版姤鍛婁笓鐢ㄧ珷"); - } - if (sealUrl == null) throw new ErrorException("鎵句笉鍒版姤鍛婁笓鐢ㄧ珷");*/ //绯荤粺鐢熸垚鎶ュ憡鍦板潃 String url = insReport.getUrl(); //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 @@ -271,11 +248,10 @@ put("seal2", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); }}, finalUrl); wordToPdf(finalUrl, sealUrl); - - InsOrder insOrder = new InsOrder(); - insOrder.setId(insReportMapper.selectById(id).getInsOrderId()); - insOrder.setState(4); - insOrderMapper.updateById(insOrder); + /*鏂板cnas7.8鎶ュ憡缁撴灉*/ + ProcessReport processReport = new ProcessReport(); + processReport.setInsReportCode(insReport.getCode()); + processReportMapper.insert(processReport); return insReportMapper.updateById(insReport); } @@ -345,7 +321,6 @@ if (files != null) { for (File f : files) { // 鏍规嵁鏂囦欢鍚嶆煡璇d - String name = f.getName(); InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().like(InsReport::getCode, f.getName().replace(".docx", ""))); if (ObjectUtils.isEmpty(insReport)) { throw new ErrorException("娌℃湁鎵惧埌 " + f.getName() + " 杩欎釜鏂囦欢瀵瑰簲鐨勬姤鍛婃暟鎹�"); @@ -386,30 +361,37 @@ @Override @Transactional(rollbackFor = Exception.class) public int isReport(InsReportDto insReportDto) { - //鍏堝垽鏂璁㈠崟鏄惁鍙互鍘荤敓浜ф姤鍛� - Long count = insOrderStateMapper.selectCount(Wrappers.<InsOrderState>lambdaQuery().eq(InsOrderState::getInsOrderId, insReportDto.getId()).eq(InsOrderState::getInsState, 5)); + //鍏堝垽鏂璁㈠崟鏄惁鍙互鍘荤敓浜ф姤鍛�(鏄惁缁撴潫璇曢獙) + Long count = insOrderStateMapper.selectCount(Wrappers.<InsOrderState>lambdaQuery() + .eq(InsOrderState::getInsOrderId, insReportDto.getId()).eq(InsOrderState::getInsState, 5)); if (count > 0) { if (insReportDto.getState() == 1) { List<InsReportDto1> insReportDto1s = insReportDto.getInsReportDto1s(); - wordUtils.generateReport(insReportDto.getId(), insReportDto1s); - } else { - //缁撴潫璁㈠崟 - InsOrder insOrder = new InsOrder(); - insOrder.setId(insReportDto.getId()); - insOrder.setState(4); - insOrderMapper.updateById(insOrder); + for (InsReportDto1 insReportDto1 : insReportDto1s) { + if (ObjectUtils.isNotEmpty(insReportDto1.getInsReportDto2s())){ + wordUtils.generateReport(insReportDto.getId(), insReportDto1); + } + } } } else { - throw new ErrorException("璇ヨ鍗曡繕鏈粨鏉熻瘯楠�,鏃犳硶鐢熶骇鎶ュ憡!"); + throw new ErrorException("璇ヨ鍗曡繕鏈粨鏉熻瘯楠�,鏃犳硶鐢熸垚鎶ュ憡!"); } return 0; } //鏌ュ嚭璇ヨ鍗曚笅姣忎釜绔欑偣涓嬬殑妫�楠屾鏁� @Override - public List<InsOrderState> getInsOrderStateCount(Integer id) { - List<InsOrderState> insOrderStates = insOrderStateMapper.getInsOrderStateCount(id); - return insOrderStates; + public List<InsOrderStateDto> getInsOrderStateCount(Integer id) { + List<InsOrderStateDto> insOrderStateDtos = new ArrayList<>(); + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, id)); + for (InsSample insSample : insSamples) { + InsOrderStateDto insOrderStateDto = new InsOrderStateDto(); + insOrderStateDto.setInsSample(insSample); + List<InsOrderState> insOrderStates = insOrderStateMapper.getInsOrderStateCount(id, insSample.getId()); + insOrderStateDto.setInsOrderStates(insOrderStates); + insOrderStateDtos.add(insOrderStateDto); + } + return insOrderStateDtos; } @@ -488,20 +470,6 @@ public String wordToPdf(String wordPath, String pdfPath, String sealUrl) { FileOutputStream os = null; try { - //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃 -// InputStream inputStream = this.getClass().getResourceAsStream("/lib/license.xml"); - /*String url; - try { - InputStream inputStream = this.getClass().getResourceAsStream("/lib/license.xml"); - File file = File.createTempFile("temp", ".tmp"); - OutputStream outputStream = new FileOutputStream(file); - IOUtils.copy(inputStream, outputStream); - url = file.getAbsolutePath(); - } catch (FileNotFoundException e) { - throw new ErrorException("鎵句笉鍒版ā鏉挎枃浠�"); - } catch (IOException e) { - throw new RuntimeException(e); - }*/ InputStream is = new ClassPathResource("/lib/license.xml").getInputStream(); License license = new License(); license.setLicense(is); @@ -514,24 +482,10 @@ os = new FileOutputStream(file); //瑕佽浆鎹㈢殑word鏂囦欢 com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); - TableCollection tables = doc.getFirstSection().getBody().getTables(); - for (Table table : tables) { - RowCollection rows = table.getRows(); - table.setAllowAutoFit(false); - for (Row row : rows) { - CellCollection cells = row.getCells(); - for (Cell cell : cells) { - CellFormat cellFormat = cell.getCellFormat(); - cellFormat.setFitText(false); //璁剧疆鑷�傚簲鍏抽棴 - cellFormat.setWrapText(true); // 璁剧疆鑷姩鎹㈣ - } - } - } doc.save(os, SaveFormat.PDF); //娣诲姞楠戠紳绔� stamperCheckMarkPDF(pdfPath.replace(".pdf", "-1.pdf"), pdfPath, imgUrl + "/" + sealUrl); - } catch (Exception e) { e.printStackTrace(); -- Gitblit v1.9.3