From c1233db43e24655c28d6bfaab853df068f05c0ba Mon Sep 17 00:00:00 2001 From: value <z1292839451@163.com> Date: 星期四, 06 六月 2024 11:17:52 +0800 Subject: [PATCH] pdf转换 --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 41 insertions(+), 4 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 52eded4..b8f0b85 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 @@ -95,7 +95,12 @@ insReport.setWriteUserId(getLook.selectPowerByMethodAndUserId(null).get("userId"));//鎻愪氦浜� insReport.setWriteTime(LocalDateTime.now());//鎻愪氦鏃堕棿 //鑾峰彇鎻愪氦浜虹殑绛惧悕鍦板潃 - String signatureUrl = userMapper.selectById(insReport.getWriteUserId()).getSignatureUrl(); + String signatureUrl; + try { + signatureUrl = userMapper.selectById(insReport.getWriteUserId()).getSignatureUrl(); + }catch (Exception e){ + throw new ErrorException("鎵句笉鍒扮紪鍒朵汉鐨勭鍚�"); + } //绯荤粺鐢熸垚鎶ュ憡鍦板潃 String url = insReport.getUrl(); //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 @@ -122,7 +127,12 @@ return insReportMapper.updateById(insReport); } //鑾峰彇瀹℃牳浜虹殑绛惧悕鍦板潃 - String signatureUrl = userMapper.selectById(insReport.getExamineUserId()).getSignatureUrl(); + String signatureUrl; + try { + signatureUrl = userMapper.selectById(insReport.getExamineUserId()).getSignatureUrl(); + }catch (Exception e){ + throw new ErrorException("鎵句笉鍒板鏍镐汉鐨勭鍚�"); + } //绯荤粺鐢熸垚鎶ュ憡鍦板潃 String url = insReport.getUrl(); //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 @@ -149,14 +159,29 @@ insReport.setState(0);//鎻愪氦鐘舵�佹敼涓哄緟鎻愪氦 return insReportMapper.updateById(insReport); } - //鑾峰彇瀹℃牳浜虹殑绛惧悕鍦板潃 - String signatureUrl = userMapper.selectById(insReport.getRatifyUserId()).getSignatureUrl(); + //鑾峰彇鎵瑰噯浜虹殑绛惧悕鍦板潃 + String signatureUrl; + try { + signatureUrl = userMapper.selectById(insReport.getRatifyUserId()).getSignatureUrl(); + }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(); //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 String urlS = insReport.getUrlS(); wordInsertUrl(new HashMap<String, Object>(){{ put("ratifyUrl", Pictures.ofLocal(imgUrl+"/"+signatureUrl).create()); + put("seal1", Pictures.ofLocal(imgUrl+"/"+sealUrl).create()); + put("seal2", Pictures.ofLocal(imgUrl+"/"+sealUrl).create()); }}, (urlS==null?url:urlS).replace("/word", wordUrl)); wordToPdf((urlS == null ? url : urlS).replace("/word", wordUrl)); InsOrder insOrder = new InsOrder(); @@ -198,6 +223,18 @@ 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); -- Gitblit v1.9.3