feat:修改模板,使用数字或者直接传模板名称进行选择
This commit is contained in:
parent
6df8da44a7
commit
86bf02cf02
|
@ -0,0 +1,63 @@
|
||||||
|
package com.dpkj.modules.print.enums;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dpkj.common.exception.RRException;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum ReceiptTemplateEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自足挂号模板
|
||||||
|
*/
|
||||||
|
REGISTER("1", "register", "自助挂号的"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 住院缴费的模板
|
||||||
|
*/
|
||||||
|
HOSPITAL_PAYMENT("2", "hospitalPayment", "住院缴费的小票"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门诊缴费的模板
|
||||||
|
*/
|
||||||
|
OUTPATIENT_PAYMENT("3", "outpatientPayment", "门诊缴费的小票"),
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String templateName;
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
|
||||||
|
ReceiptTemplateEnum(String code, String templateName, String desc){
|
||||||
|
this.code = code;
|
||||||
|
this.templateName = templateName;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过code获取模板名称
|
||||||
|
* @param code code/也有可能直接是一个名称
|
||||||
|
* @return 模板的名称
|
||||||
|
*/
|
||||||
|
public static String getTemplateName(String code){
|
||||||
|
if (code == null || "".equals(code)) {
|
||||||
|
throw new RRException("模板名称不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = null;
|
||||||
|
for (ReceiptTemplateEnum enumEntity : ReceiptTemplateEnum.values()) {
|
||||||
|
String enumCode = enumEntity.getCode();
|
||||||
|
if ( enumCode.equals(code)){
|
||||||
|
name = enumEntity.getTemplateName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return name == null ? code : name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -33,11 +33,14 @@ public class RegisterServiceImpl implements PrintService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LexMarkResultDTO<LexMarkResultDTO.Param> printImage(JSONObject data, String template, int width, int height, String saveDir) {
|
public LexMarkResultDTO<LexMarkResultDTO.Param> printImage(JSONObject data, String template, int width, int height, String saveDir) {
|
||||||
|
// 获取模板
|
||||||
|
String templateName = ReceiptTemplateEnum.getTemplateName(template);
|
||||||
|
|
||||||
this.getStatus();
|
this.getStatus();
|
||||||
StringBuilder filePath = new StringBuilder(saveDir);
|
StringBuilder filePath = new StringBuilder(saveDir);
|
||||||
// 校验是否选中了模板,如果没选中模板的话则不需要另外生成了
|
// 校验是否选中了模板,如果没选中模板的话则不需要另外生成了
|
||||||
if ( !StringUtils.isEmpty(template) && !StringUtils.isEmpty(saveDir)){
|
if ( !StringUtils.isEmpty(templateName) && !StringUtils.isEmpty(saveDir)){
|
||||||
byte[] image = new TemplateUtils().generateReceiptImage(data, template, width, height, filePath);
|
byte[] image = new TemplateUtils().generateReceiptImage(data, templateName, width, height, filePath);
|
||||||
}else {
|
}else {
|
||||||
throw new RRException("模板渲染错误");
|
throw new RRException("模板渲染错误");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue