Commit 12cb4438 authored by 廖旭伟's avatar 廖旭伟

增加二维码控件

parent ebb4b7b1
......@@ -178,7 +178,12 @@
<artifactId>hutool-all</artifactId>
<version>5.7.14</version>
</dependency>
</dependencies>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>
<build>
<resources>
......
......@@ -18,7 +18,8 @@ public enum ComponentEnum {
DATE("date", "日期选择栏"),
AREA("area", "区域选择栏"),
IMAGE("@image", "图片选择"),
DYNAMIC_TABLE("dt", "动态表格");
DYNAMIC_TABLE("dt", "动态表格"),
QRCODE("@qrcode", "二维码输入框");
private String value;
private String desc;
......
......@@ -42,6 +42,9 @@ public abstract class DesignComponent {
// else if (type.equals(ComponentEnum.AREA.getValue())) {
// return new AreaComponent(type);
// }
else if (type.equals(ComponentEnum.QRCODE.getValue())) {
return new DesignQrcodeComponent(type);
}
else {
throw new AppException(String.format("不支持当前组件类型,Type:%s", type));
}
......
package com.mortals.xhx.common.formdesign.component;
import com.google.common.collect.Lists;
import com.mortals.xhx.common.code.ComponentEnum;
import com.mortals.xhx.common.formdesign.DesignComponent;
import com.mortals.xhx.common.formdesign.ListItem;
import com.mortals.xhx.common.pdu.gen.component.ComponentCons;
/**
* 二维码输入框
*/
public class DesignQrcodeComponent extends DesignComponent {
public DesignQrcodeComponent(String type) {
super(type);
}
@Override
public ListItem buildDefaultComponent(ComponentCons cons) {
ListItem columnsItem = new ListItem();
columnsItem.setId(cons.getVal());
columnsItem.set_id(cons.getVal());
columnsItem.setCompType("input");
columnsItem.setCompName(cons.getLabel());
columnsItem.setCompIcon("input");
columnsItem.setEle("el-input");
columnsItem.setViewType("text");
columnsItem.setConfig(true);
columnsItem.setShowLabel(true);
columnsItem.setLabel(cons.getLabel());
columnsItem.setLabelWidth(120);
columnsItem.setPlaceholder("请输入"+cons.getLabel());
columnsItem.setRequired(true);
columnsItem.setMaxLength(50);
columnsItem.setGutter(15);
columnsItem.setSpan(24);
columnsItem.setWidth("100%");
columnsItem.setClearable(true);
columnsItem.setDisabled(false);
columnsItem.setReadonly(false);
columnsItem.setStatus("normal");
columnsItem.setPrefixIcon("");
columnsItem.setRules(Lists.newArrayList());
columnsItem.setRulesType("default");
columnsItem.setAppend("");
columnsItem.setPrepend("");
columnsItem.setLayout("colItem");
return columnsItem;
}
@Override
public String getType() {
return ComponentEnum.QRCODE.getValue();
}
}
......@@ -21,10 +21,7 @@ import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.utils.ExportDocUtil;
import com.mortals.xhx.common.utils.ImageBase64;
import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.common.utils.WordUtil;
import com.mortals.xhx.common.utils.*;
import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity;
import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity;
import com.mortals.xhx.module.certificate.pdu.ApplyLogPdu;
......@@ -209,6 +206,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
CertificateCatalogEntity catalog = certificateCatalogService.get(applyLogEntity.getCatalogId());
applyLogEntity.setCatalogCode(catalog.getCatalogCode());
applyLogEntity.setCatalogName(catalog.getCatalogName());
applyLogEntity.setFormTemplate(catalog.getFormContent());
DocTemplateVO docTemplate = new DocTemplateVO(catalog.getTemplateUrl(),applyLogEntity.getFormContent());
String paths = preview(docTemplate, context);
String[] vals = paths.split(";");
......@@ -306,6 +304,25 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
if (entry.getKey().indexOf("dt_") != -1) {
builder.bind(entry.getKey(), new MultipleRowTableRenderPolicy());
}
//二维码输入框处理
if (entry.getKey().indexOf("@qrcode") != -1) {
try {
String filePath = rootPath+"file/qrcode/";
String qrcodeName = new Date().getTime() + ".png";
File pathDir = new File(filePath);
if (!pathDir.exists()) {
pathDir.mkdirs();
}
String imagepath = filePath+qrcodeName;
QrCodeUtil.generateQrCodeFile(entry.getValue().toString(),imagepath);
PictureRenderData pictureRenderData = Pictures.ofStream(new FileInputStream(imagepath), PictureType.PNG)
.size(100, 100).create();
addMap.put(StrUtil.removePrefixIgnoreCase(entry.getKey(),"@"),pictureRenderData);
//entry.setValue(pictureRenderData);
} catch (FileNotFoundException e) {
log.error("error", e);
}
}
});
if(addMap.size()>0){
data.putAll(addMap);
......@@ -330,6 +347,10 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
//转换预览图片
String fileName = RandomUtil.randomNumbers(12) + ".jpg";
String preView = this.filePath + "/preview/" + fileName;
File preViewPathDir = new File(this.filePath + "/preview/");
if (!preViewPathDir.exists()) {
preViewPathDir.mkdirs();
}
WordUtil.convertWordToJPEG(mergedoc, preView);
log.info("preView:" + "/preview/" + fileName);
//下载地址拼装
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment