From 06e6109018ab55278c0e3a01ae84c87205aac72f Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Wed, 21 Aug 2024 14:38:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=AB=AF=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SystemHomePageServiceImpl.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/homepage/impl/SystemHomePageServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/homepage/impl/SystemHomePageServiceImpl.java index 3013a52f..1951ca4d 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/homepage/impl/SystemHomePageServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/homepage/impl/SystemHomePageServiceImpl.java @@ -96,7 +96,12 @@ public class SystemHomePageServiceImpl implements SystemHomePageService { signPatientCount.setTime(localDate); signPatientCount.setPatientCount(createPatientCount + patientPreHospitalizationCount); signPatientCount.setSignPatientCount(signPatient); - signPatientCount.setProportion(new BigDecimal(i).divide(new BigDecimal(createPatientCount), 2, RoundingMode.HALF_UP)); + //除法运算 + if (createPatientCount != 0) { + signPatientCount.setProportion(new BigDecimal(i).divide(new BigDecimal(createPatientCount), 2, RoundingMode.HALF_UP)); + } else { + signPatientCount.setProportion(BigDecimal.ZERO); + } signPatientCounts.add(signPatientCount); } return signPatientCounts; @@ -120,10 +125,18 @@ public class SystemHomePageServiceImpl implements SystemHomePageService { BigDecimal appletPushSign = signPatientManageRouteNodeMapper.selectNodeCount(null, null, 0L); //全部 BigDecimal all = common.add(AI).add(messagePushSign).add(appletPushSign); - serviceModeStatisticsList.add(new ServiceModeStatistics("AI", AI.divide(all, 2, RoundingMode.HALF_UP), AI)); - serviceModeStatisticsList.add(new ServiceModeStatistics("短信", messagePushSign.divide(all, 2, RoundingMode.HALF_UP), messagePushSign)); - serviceModeStatisticsList.add(new ServiceModeStatistics("微信", appletPushSign.divide(all, 2, RoundingMode.HALF_UP), appletPushSign)); - serviceModeStatisticsList.add(new ServiceModeStatistics("人工随访", common.divide(all, 2, RoundingMode.HALF_UP), common)); + //除法运算 + if (all.equals(BigDecimal.ZERO)) { + serviceModeStatisticsList.add(new ServiceModeStatistics("AI", BigDecimal.ZERO, AI)); + serviceModeStatisticsList.add(new ServiceModeStatistics("短信", BigDecimal.ZERO, messagePushSign)); + serviceModeStatisticsList.add(new ServiceModeStatistics("微信", BigDecimal.ZERO, appletPushSign)); + serviceModeStatisticsList.add(new ServiceModeStatistics("人工随访", BigDecimal.ZERO, common)); + } else { + serviceModeStatisticsList.add(new ServiceModeStatistics("AI", AI.divide(all, 2, RoundingMode.HALF_UP), AI)); + serviceModeStatisticsList.add(new ServiceModeStatistics("短信", messagePushSign.divide(all, 2, RoundingMode.HALF_UP), messagePushSign)); + serviceModeStatisticsList.add(new ServiceModeStatistics("微信", appletPushSign.divide(all, 2, RoundingMode.HALF_UP), appletPushSign)); + serviceModeStatisticsList.add(new ServiceModeStatistics("人工随访", common.divide(all, 2, RoundingMode.HALF_UP), common)); + } return serviceModeStatisticsList; } From 277faba22c9b19ceb4be57965c04001351005fed Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Thu, 22 Aug 2024 15:20:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=B4=A0=E6=9D=90=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=BF=AE=E5=BB=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xinelu/common/utils/file/ImageResize.java | 41 +++++++++++++++++++ .../impl/FileUplooadServiceImpl.java | 8 +++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 postdischarge-common/src/main/java/com/xinelu/common/utils/file/ImageResize.java diff --git a/postdischarge-common/src/main/java/com/xinelu/common/utils/file/ImageResize.java b/postdischarge-common/src/main/java/com/xinelu/common/utils/file/ImageResize.java new file mode 100644 index 00000000..cf9f762c --- /dev/null +++ b/postdischarge-common/src/main/java/com/xinelu/common/utils/file/ImageResize.java @@ -0,0 +1,41 @@ +package com.xinelu.common.utils.file; + +import com.xinelu.common.config.SystemBusinessConfig; +import com.xinelu.common.constant.Constants; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; + +/** + * 图片裁剪 + * + * @author: zh + * @create: 2024-08-22 + **/ +public class ImageResize { + + public static void scaledDown(String pictureName) { + try { + pictureName = pictureName.replaceAll(Constants.RESOURCE_PREFIX, SystemBusinessConfig.getProfile()); + File inputFile = new File(pictureName); + BufferedImage inputImage = ImageIO.read(inputFile); + if (inputImage.getWidth() < 1080) { + return; + } + // 新的宽度 + int newWidth = 1080; + int newHeight = (int) ((double) inputImage.getHeight() / inputImage.getWidth() * newWidth); + // 计算新的高度 + BufferedImage outputImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = outputImage.createGraphics(); + g2d.drawImage(inputImage, 0, 0, newWidth, newHeight, null); + g2d.dispose(); + File outputFile = new File(pictureName); + ImageIO.write(outputImage, "jpg", outputFile); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientinformed/impl/FileUplooadServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientinformed/impl/FileUplooadServiceImpl.java index bc55d8df..7e906b67 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientinformed/impl/FileUplooadServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientinformed/impl/FileUplooadServiceImpl.java @@ -5,13 +5,15 @@ import com.xinelu.common.constant.FileUploadPathConstants; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.file.FileUploadUtils; +import com.xinelu.common.utils.file.ImageResize; import com.xinelu.common.utils.file.MimeTypeUtils; import com.xinelu.manage.service.signpatientinformed.IFileUploadService; -import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; + /** * @description: 文件上传Service业务层处理 * @author: haown @@ -63,6 +65,10 @@ public class FileUplooadServiceImpl implements IFileUploadService { if (StringUtils.isBlank(pictureName)) { throw new ServiceException("文件上传失败,请联系管理员!"); } + if (type.equals(FileUploadPathConstants.MATERIALS_COVER_TYPE)){ + //裁剪图片 + ImageResize.scaledDown(pictureName); + } AjaxResult ajax = AjaxResult.success("上传成功!"); ajax.put("imgUrl", pictureName); return ajax;