From a00f5a6c5b1686011af4f155c799bdd57dd951d9 Mon Sep 17 00:00:00 2001 From: wzz Date: Sun, 6 Apr 2025 20:26:55 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=B7=BB=E5=8A=A0=E4=B8=AD=E5=8C=BB?= =?UTF-8?q?=E4=BD=93=E8=B4=A8=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/web/ZytzController.java | 44 +++++++++++++++ .../src/main/resources/application-dev.yml | 5 +- .../src/main/resources/application-prod.yml | 3 ++ .../src/main/resources/application-stage.yml | 3 ++ .../common/config/RuoYiConfig.java | 26 +++++++++ .../system/domain/dto/ZytzDto.java | 37 +++++++++++++ .../system/service/ZytzService.java | 13 +++++ .../system/service/impl/ZytzServiceImpl.java | 54 +++++++++++++++++++ 8 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ZytzController.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/ZytzDto.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/service/ZytzService.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ZytzServiceImpl.java diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ZytzController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ZytzController.java new file mode 100644 index 00000000..829ac2a0 --- /dev/null +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ZytzController.java @@ -0,0 +1,44 @@ +package com.acupuncture.web.controller.web; + +import com.acupuncture.common.core.domain.BaseDto; +import com.acupuncture.common.core.domain.JsonResponse; +import com.acupuncture.common.exception.base.BaseException; +import com.acupuncture.common.utils.SecurityUtils; +import com.acupuncture.system.domain.dto.PmsTreatmentDto; +import com.acupuncture.system.domain.dto.ZytzDto; +import com.acupuncture.system.service.ZytzService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author zhangsan + * @description + * @date 2025/4/6 18:37 + */ + +@Slf4j +@Api(tags = "中医体质测评相关") +@RestController +@RequestMapping("/zytz") +public class ZytzController { + @Resource + private ZytzService zytzService; + + @ApiOperation("生成中医体质辨识二维码") + @PostMapping("/qrcode") + public JsonResponse getZytzQrcode(@RequestBody @Validated BaseDto dto){ + Long tenantId = SecurityUtils.getTenantId(); + if(tenantId == null){ + throw new BaseException("未找到tenantId"); + } + return JsonResponse.ok(zytzService.getZytzQrcode(dto.getParam(), tenantId)); + } +} diff --git a/acupuncture-admin/src/main/resources/application-dev.yml b/acupuncture-admin/src/main/resources/application-dev.yml index a020b54a..6d6d6007 100644 --- a/acupuncture-admin/src/main/resources/application-dev.yml +++ b/acupuncture-admin/src/main/resources/application-dev.yml @@ -66,4 +66,7 @@ file: wxQrCodeTemplate: /home/acupuncture/server/profile/wxQrCodeTemplate.docx screenQrCodeTemplate: /home/acupuncture/server/profile/screenQrCodeTemplate.docx hbTemplate: /home/acupuncture/server/profile/screenHbQrCodeTemplate.docx - screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName¢erId=cId \ No newline at end of file + screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName¢erId=cId + +zytz: + mobileUrl: https://test.tall.wiki/acupuncture/client/medicalEva \ No newline at end of file diff --git a/acupuncture-admin/src/main/resources/application-prod.yml b/acupuncture-admin/src/main/resources/application-prod.yml index df8ba8d3..b918ac8b 100644 --- a/acupuncture-admin/src/main/resources/application-prod.yml +++ b/acupuncture-admin/src/main/resources/application-prod.yml @@ -90,3 +90,6 @@ file: screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName¢erId=cId pgTemplate: /home/acupuncture/server/profile/TreamtmentPgTemplate.docx jmrsUrl: /home/acupuncture/server/profile/uploads/jmrsTemplate.docx + +zytz: + mobileUrl: https://nnzjpt.ylinno.com/acupuncture/clientssl/medicalEva diff --git a/acupuncture-admin/src/main/resources/application-stage.yml b/acupuncture-admin/src/main/resources/application-stage.yml index bd811e86..d2fe88cd 100644 --- a/acupuncture-admin/src/main/resources/application-stage.yml +++ b/acupuncture-admin/src/main/resources/application-stage.yml @@ -68,3 +68,6 @@ file: screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName¢erId=cId pgTemplate: /home/acupuncture/server/profile/TreamtmentPgTemplate.docx jmrsUrl: /home/acupuncture/server/profile/uploads/jmrsTemplate.docx + +zytz: + mobileUrl: https://test.tall.wiki/acupuncture/client/medicalEva \ No newline at end of file diff --git a/acupuncture-common/src/main/java/com/acupuncture/common/config/RuoYiConfig.java b/acupuncture-common/src/main/java/com/acupuncture/common/config/RuoYiConfig.java index 9509d51d..468ec2b8 100644 --- a/acupuncture-common/src/main/java/com/acupuncture/common/config/RuoYiConfig.java +++ b/acupuncture-common/src/main/java/com/acupuncture/common/config/RuoYiConfig.java @@ -24,6 +24,9 @@ public class RuoYiConfig /** 上传路径 */ private static String profile; + /** 资源路径 */ + private static String profileUrl; + /** 获取地址开关 */ private static boolean addressEnabled; @@ -70,6 +73,16 @@ public class RuoYiConfig RuoYiConfig.profile = profile; } + public static String getProfileUrl() + { + return profileUrl; + } + + public void setProfileUrl(String profileUrl) + { + RuoYiConfig.profileUrl = profileUrl; + } + public static boolean isAddressEnabled() { return addressEnabled; @@ -119,4 +132,17 @@ public class RuoYiConfig { return getProfile() + "/upload"; } + + /** + * 获取中医体质二维码存放路径 + */ + public static String getZytzQrcodePath() + { + return getProfile() + "/zytz"; + } + + public static String getZytzQrcodeUrl() + { + return getProfileUrl() + "/zytz"; + } } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/ZytzDto.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/ZytzDto.java new file mode 100644 index 00000000..86dd98d6 --- /dev/null +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/ZytzDto.java @@ -0,0 +1,37 @@ +package com.acupuncture.system.domain.dto; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import com.acupuncture.common.constant.UserConstants; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * @Author zzc + * @Package com.acupuncture.system.domain.dto + * @Date 2025/2/11 15:05 + * @description: + */ +public class ZytzDto { + @Data + public static class ZytzQrcode { + //诊疗档案id + @NotNull(message = "id不能为空") + private Long id; + //患者姓名 + private String name; + //患者电话 + private String phone; + //是否总是重新生成(1总是重新生成),测试用 + int rewrite = 0; + } +} diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/ZytzService.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/ZytzService.java new file mode 100644 index 00000000..c7ca1416 --- /dev/null +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/ZytzService.java @@ -0,0 +1,13 @@ +package com.acupuncture.system.service; + +import com.acupuncture.system.domain.dto.AmsWxQrCodeDto; +import com.acupuncture.system.domain.dto.ZytzDto; +import com.acupuncture.system.domain.po.AmsScreenWxQrCode; +import com.acupuncture.system.domain.vo.AmsWxQrCodeVo; + +import java.io.IOException; +import java.util.List; + +public interface ZytzService { + String getZytzQrcode(ZytzDto.ZytzQrcode dto, Long tenantId); +} diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ZytzServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ZytzServiceImpl.java new file mode 100644 index 00000000..e081472e --- /dev/null +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ZytzServiceImpl.java @@ -0,0 +1,54 @@ +package com.acupuncture.system.service.impl; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.qrcode.QrCodeUtil; +import com.acupuncture.common.config.RuoYiConfig; +import com.acupuncture.common.exception.base.BaseException; +import com.acupuncture.system.domain.dto.ZytzDto; +import com.acupuncture.system.service.ZytzService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.io.File; + +/** + * @author zhangsan + * @description + * @date 2025/4/6 18:40 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class ZytzServiceImpl implements ZytzService { + @Value("${zytz.mobileUrl}") + private String zytzMobileUrl; + + @Override + public String getZytzQrcode(ZytzDto.ZytzQrcode dto, Long tenantId) { + String qrcodePath = RuoYiConfig.getZytzQrcodePath() + "/" + dto.getId() + ".png"; + String qrcodeUrl = RuoYiConfig.getZytzQrcodeUrl() + "/" + dto.getId() + ".png"; + String url = StrUtil.format("{}?id={}&name={}&phone={}&tenantId={}", + zytzMobileUrl, dto.getId(), dto.getName(), dto.getPhone(), tenantId); + log.info("qrcodePath:{}", qrcodePath); + log.info("qrcodeUrl:{}", qrcodeUrl); + log.info("url:{}", url); + + //存在则直接返回 + if (FileUtil.exist(qrcodePath) && dto.getRewrite() != 1) { + log.info("zytz qrcode exists."); + return qrcodeUrl; + } + + //不存在或者rewrite=1 + File file = QrCodeUtil.generate(url, 450, 450, new File(qrcodePath)); + if(FileUtil.exist(qrcodePath)){ + return qrcodeUrl; + }else{ + throw new BaseException("QrCodeUtil.generate failed."); + } + } +}