8 changed files with 184 additions and 1 deletions
@ -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)); |
|||
} |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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); |
|||
} |
@ -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…
Reference in new issue