From a4e834783593c00e9b80ade7418c443a48ff0347 Mon Sep 17 00:00:00 2001 From: hejinbo Date: Thu, 16 Nov 2023 10:42:19 +0800 Subject: [PATCH] zancun --- .../DeptIdentifyController.java | 2 +- .../service/impl/DeptIdentifyServiceImpl.java | 10 ++++- .../utils/ImageToBase64Converter.java | 30 +++++++++++++++ .../ruoyi/wisdomarbitrate/utils/MyTest.java | 37 ------------------- 4 files changed, 39 insertions(+), 40 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java index 9c0c1a5..13df556 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java @@ -30,7 +30,7 @@ public class DeptIdentifyController extends BaseController { } /** - * 查询部门认证数据 + * 查询机构信息 */ @GetMapping("/list") public TableDataInfo list(DeptIdentify deptIdentify) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java index 3b95eb2..4792ed9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java @@ -135,13 +135,13 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { //创建机构图片印章 // String annexPath = "D:\\develop\\2.jpg"; String sealName = "自定义" + UUID.randomUUID() + ""; //自定义印章印章名称不能重复,所以用UUID确保唯一性 - EsignHttpResponse response = SignAward.createOrgByImage(identify,sealName,annexPath); + EsignHttpResponse response = SignAward.createOrgByImage(identify, sealName, annexPath); JSONObject jsonObject = JSONObject.parseObject(response.getBody()); int code = jsonObject.getIntValue("code"); if (code == 0) { //业务码,0表示成功,非0表示异常。 String sealId = jsonObject.getJSONObject("data").getString("sealId"); //保存到表里 - SealManage sealManage = new SealManage(); + SealManage sealManage = new SealManage(); sealManage.setIdentifyId(identify.getId()); sealManage.setSealName(sealName); sealManage.setSealId(sealId); @@ -297,6 +297,12 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { if (identifyType == null) { deptIdentify.setIdentifyType(1); // 设置机构默认为仲裁机构 } + //先查询看数据库里有没有相同的机构经办人 + List deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentify); + if (deptIdentifies != null && deptIdentifies.size() > 0) { + //说明之前新增过 + return AjaxResult.error("信息重复"); + } deptIdentify.setIdentifyStatus(0); //设置认证状态默认为未认证 deptIdentify.setIsUse(0); //设置认证状态默认为未认证 int i = deptIdentifyMapper.insertDeptIdentify(deptIdentify);//设置机构默认为未启用 diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java new file mode 100644 index 0000000..752b36b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java @@ -0,0 +1,30 @@ +package com.ruoyi.wisdomarbitrate.utils; + +import java.io.BufferedInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Base64; + +public class ImageToBase64Converter { + public static String imageToBase64(String imagePath) throws Exception { + Path path = Paths.get(imagePath); + byte[] imageBytes = Files.readAllBytes(path); + String base64Image = Base64.getEncoder().encodeToString(imageBytes); + return base64Image; + } + + public static void main(String[] args) { + String imagePath = "D:\\develop\\2.jpg"; + try { + String base64Image = imageToBase64(imagePath); + System.out.println(base64Image); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java deleted file mode 100644 index 586b79b..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ruoyi.wisdomarbitrate.utils; - -import java.io.BufferedInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -public class MyTest { - public static void download(String fileUrl, String saveFilePath) throws IOException { - URL url = new URL(fileUrl); - InputStream inputStream = url.openStream(); - BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); - FileOutputStream fileOutputStream = new FileOutputStream(saveFilePath); - - byte[] buffer = new byte[1024]; - int bytesRead = 0; - while ((bytesRead = bufferedInputStream.read(buffer, 0, buffer.length)) != -1) { - fileOutputStream.write(buffer, 0, bytesRead); - } - - fileOutputStream.close(); - bufferedInputStream.close(); - inputStream.close(); - } - - public static void main(String[] args) { - String fileUrl = "https://esignoss.esign.cn/1111563786/0e16cc53-fe2e-403b-b901-587778a8ea92/3ed8f1b0bd2640e895fcfbaffdec0a1e.pdf?Expires=1698742492&OSSAccessKeyId=LTAI4G23YViiKnxTC28ygQzF&Signature=K%2Bb5k7DqNmaxeu%2Fct5qis4qor7s%3D"; - String saveFilePath = "D:\\home\\example.pdf"; - try { - download(fileUrl, saveFilePath); - System.out.println("File downloaded successfully."); - } catch (IOException e) { - e.printStackTrace(); - } - } -}