Browse Source

feature: 添加中医体质二维码接口

new-ays
wzz 3 months ago
parent
commit
a00f5a6c5b
  1. 44
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ZytzController.java
  2. 3
      acupuncture-admin/src/main/resources/application-dev.yml
  3. 3
      acupuncture-admin/src/main/resources/application-prod.yml
  4. 3
      acupuncture-admin/src/main/resources/application-stage.yml
  5. 26
      acupuncture-common/src/main/java/com/acupuncture/common/config/RuoYiConfig.java
  6. 37
      acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/ZytzDto.java
  7. 13
      acupuncture-system/src/main/java/com/acupuncture/system/service/ZytzService.java
  8. 54
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ZytzServiceImpl.java

44
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<String> getZytzQrcode(@RequestBody @Validated BaseDto<ZytzDto.ZytzQrcode> dto){
Long tenantId = SecurityUtils.getTenantId();
if(tenantId == null){
throw new BaseException("未找到tenantId");
}
return JsonResponse.ok(zytzService.getZytzQrcode(dto.getParam(), tenantId));
}
}

3
acupuncture-admin/src/main/resources/application-dev.yml

@ -67,3 +67,6 @@ file:
screenQrCodeTemplate: /home/acupuncture/server/profile/screenQrCodeTemplate.docx screenQrCodeTemplate: /home/acupuncture/server/profile/screenQrCodeTemplate.docx
hbTemplate: /home/acupuncture/server/profile/screenHbQrCodeTemplate.docx hbTemplate: /home/acupuncture/server/profile/screenHbQrCodeTemplate.docx
screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName&centerId=cId screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName&centerId=cId
zytz:
mobileUrl: https://test.tall.wiki/acupuncture/client/medicalEva

3
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&centerId=cId screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName&centerId=cId
pgTemplate: /home/acupuncture/server/profile/TreamtmentPgTemplate.docx pgTemplate: /home/acupuncture/server/profile/TreamtmentPgTemplate.docx
jmrsUrl: /home/acupuncture/server/profile/uploads/jmrsTemplate.docx jmrsUrl: /home/acupuncture/server/profile/uploads/jmrsTemplate.docx
zytz:
mobileUrl: https://nnzjpt.ylinno.com/acupuncture/clientssl/medicalEva

3
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&centerId=cId screenPath: http://test.tall.wiki/acupuncture/web-admin/screening/H5?hospitalId=hosId&hospitalName=hosName&centerId=cId
pgTemplate: /home/acupuncture/server/profile/TreamtmentPgTemplate.docx pgTemplate: /home/acupuncture/server/profile/TreamtmentPgTemplate.docx
jmrsUrl: /home/acupuncture/server/profile/uploads/jmrsTemplate.docx jmrsUrl: /home/acupuncture/server/profile/uploads/jmrsTemplate.docx
zytz:
mobileUrl: https://test.tall.wiki/acupuncture/client/medicalEva

26
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 profile;
/** 资源路径 */
private static String profileUrl;
/** 获取地址开关 */ /** 获取地址开关 */
private static boolean addressEnabled; private static boolean addressEnabled;
@ -70,6 +73,16 @@ public class RuoYiConfig
RuoYiConfig.profile = profile; RuoYiConfig.profile = profile;
} }
public static String getProfileUrl()
{
return profileUrl;
}
public void setProfileUrl(String profileUrl)
{
RuoYiConfig.profileUrl = profileUrl;
}
public static boolean isAddressEnabled() public static boolean isAddressEnabled()
{ {
return addressEnabled; return addressEnabled;
@ -119,4 +132,17 @@ public class RuoYiConfig
{ {
return getProfile() + "/upload"; return getProfile() + "/upload";
} }
/**
* 获取中医体质二维码存放路径
*/
public static String getZytzQrcodePath()
{
return getProfile() + "/zytz";
}
public static String getZytzQrcodeUrl()
{
return getProfileUrl() + "/zytz";
}
} }

37
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;
}
}

13
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);
}

54
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.");
}
}
}
Loading…
Cancel
Save