Commit 5accba1e authored by 廖旭伟's avatar 廖旭伟

证照申请保存二维码

parent cc61569b
......@@ -59,7 +59,7 @@ public class ReadExcelPictureUtil {
File picDirF = null;
String imageName = new Date().getTime() + ".png";
String imagePath = "/file/uploadfile/"+imageName;
String imagePath = "/file/fileupload/"+imageName;
String filePath = root + imagePath;
FileOutputStream fout;
......@@ -101,7 +101,7 @@ public class ReadExcelPictureUtil {
String point = hSSFClientAnchor.getRow1() + "," + hSSFClientAnchor.getCol1();
String imageName = new Date().getTime() + ".png";
String imagePath = "/file/uploadfile/"+imageName;
String imagePath = "/file/fileupload/"+imageName;
String filePath = "D:/mortals/app/data/cpm" + imagePath;
FileOutputStream fout;
......
package com.mortals.xhx.module.certificate.service.impl;
import cn.hutool.core.text.StrSplitter;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.config.ConfigureBuilder;
import com.deepoove.poi.template.MetaTemplate;
import com.deepoove.poi.util.RegexUtils;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.ClassifyType;
import com.mortals.xhx.common.code.ComponentEnum;
import com.mortals.xhx.common.code.StatusEnum;
import com.mortals.xhx.common.formdesign.*;
import com.mortals.xhx.common.pdu.gen.component.ComponentCons;
import com.mortals.xhx.common.utils.ExcelUtil;
import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.certificate.dao.CertificateCatalogDao;
import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity;
......@@ -20,10 +33,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
......@@ -40,7 +50,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Value("${upload.path}")
private String filePath;
@Value("${upload.url:http://192.168.0.98:17216/cpm/file/commonupload?prePath=/file/uploadfile}")
@Value("${upload.url:http://192.168.0.98:17216/cpm/file/commonupload?prePath=/file/fileupload}")
private String uploadUrl;
@Value("${qrcode.url:http://rhpt.scjg.chengdu.gov.cn:8091/adap/spjy/process/generateQrCode.do?dto.applyId=}")
......@@ -52,9 +62,8 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Autowired
private CertificateChildService certificateChildService;
@Override
protected void saveBefore(CertificateCatalogEntity entity, Context context) throws AppException {
protected void validData(CertificateCatalogEntity entity, Context context) throws AppException {
if (StringUtils.isEmpty(entity.getCatalogName())) {
throw new AppException("目录名称不能为空");
}
......@@ -70,27 +79,29 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
if (entity.getIndustryId() == null) {
throw new AppException("所属行业不能为空");
}
}
@Override
protected void saveBefore(CertificateCatalogEntity entity, Context context) throws AppException {
validData(entity,context);
entity.setStatus(StatusEnum.ENABLE.getValue());
if(StringUtils.isNotEmpty(entity.getTemplateFileUrl())){
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson(entity,false);
}
}
@Override
protected void updateBefore(CertificateCatalogEntity entity, Context context) throws AppException {
if (StringUtils.isEmpty(entity.getCatalogName())) {
throw new AppException("目录名称不能为空");
}
if (StringUtils.isEmpty(entity.getCatalogCode())) {
throw new AppException("目录编码不能为空");
}
if (entity.getHolderType() == null) {
throw new AppException("持有者类型不能为空");
}
if (entity.getClassifyId() == null) {
throw new AppException("目录分类不能为空");
}
if (entity.getIndustryId() == null) {
throw new AppException("所属行业不能为空");
validData(entity,context);
CertificateCatalogEntity old = this.get(entity.getId());
if(!old.getTemplateFileUrl().equals(entity.getTemplateFileUrl())) {
if (StringUtils.isNotEmpty(entity.getTemplateFileUrl())) {
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson(entity, false);
}
}
}
......@@ -168,27 +179,118 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
super.removeAfter(ids, context, result);
}
private void parseDocxToJson(CertificateCatalogEntity entity,boolean onlyExcel) {
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
String filepath = rootPath + entity.getTemplateFileUrl();
ConfigureBuilder builder = Configure.builder();
builder.setValidErrorHandler(new Configure.DiscardHandler());
builder.useDefaultEL(false);
builder.buildGrammerRegex(RegexUtils.createGeneral("{{", "}}"));
//builder.buildGramer("[","]");
XWPFTemplate template = XWPFTemplate.compile(filepath, builder.build());
FormDesignRoot root = new FormDesignRoot();
FormDesignConfig config = new FormDesignConfig();
config.initAttribute();
root.setConfig(config);
List<ListItem> collect = new ArrayList<>();
HashSet<String> hs = new HashSet<>(); //去除重复标签
List<String> excelList = new ArrayList<>(); //Excel模板
// excelList.add("证照目录ID");
// excelList.add("证照编号");
// excelList.add("证照名称");
// excelList.add("颁发时间");
// excelList.add("取件人姓名");
// excelList.add("取件人证件号码");
// excelList.add("持有者名称");
// excelList.add("持有者证件号码");
// excelList.add("企业名称");
for (MetaTemplate item : template.getElementTemplates()) {
if(hs.contains(item.variable())){
continue;
}else {
hs.add(item.variable());
}
//识别简单输入
String val = StrUtil.strip(item.variable(), "{{", "}}");
excelList.add(val);
List<String> keys = StrSplitter.split(val, "_", true, true);
//切分分隔符后动态 创建组件 i_1_姓名(第一个代表类型,第二个如果是多个累加,第三个显示label)
if (keys.size() > 2) {
String label = keys.get(2);
String type = keys.get(0);
ComponentCons cons = new ComponentCons();
cons.setLabel(label);
cons.setVal(val);
cons.setEl(item.variable());
cons.setUploadFileUrl(uploadUrl);
if (type.equalsIgnoreCase(ComponentEnum.DYNAMIC_TABLE.getValue())) {
HashSet<String> dhs = new HashSet<>(); //去除重复标签
List<TableColItem> colList = new ArrayList<>();
//表格 结构化绑定数据
ConfigureBuilder builderTable = Configure.builder();
builderTable.setValidErrorHandler(new Configure.DiscardHandler());
builderTable.useDefaultEL(false);
builderTable.buildGramer("[", "]");
XWPFTemplate templateTable = XWPFTemplate.compile(filepath, builderTable.build());
public static void main(String[] args) {
// String excelFilePath = "D:/mortals/app/data/cpm/" + "excel/test1.xls";
// List<String> excelList = new ArrayList<>();
// excelList.add("i_1_姓名");
// excelList.add("i_2_性别");
// excelList.add("i_3_年龄");
// excelList.add("i_4_证件编号");
// excelList.add("i_5_证件名称");
//
// ExcelUtil.createCatalogTemplate(excelFilePath,excelList);
for (MetaTemplate col : templateTable.getElementTemplates()) {
if(dhs.contains(col.variable())){
continue;
}else {
dhs.add(col.variable());
}
String colVal = StrUtil.strip(col.variable(), "[", "]");
if (!StrUtil.startWith(colVal, label)) {
continue;
}
List<String> colKeys = StrSplitter.split(colVal, "_", true, true);
//提取当前table中的列元素
if (colKeys.size() > 3) {
String colLabel = colKeys.get(3);
String colType = colKeys.get(1);
TableColItem tableColItem = new TableColItem();
tableColItem.setLabel(colLabel);
tableColItem.setColType(colType);
tableColItem.setVal(colVal);
colList.add(tableColItem);
//System.out.println("列元素" + col.variable());
}
}
cons.setColList(colList);
DesignComponent designComponent = DesignComponent.createType(type);
ListItem listItem = designComponent.buildDefaultComponent(cons);
collect.add(listItem);
continue;
}
DesignComponent designComponent = DesignComponent.createType(type);
ListItem listItem = designComponent.buildDefaultComponent(cons);
if(type.equals(ComponentEnum.QRCODE.getValue())){
listItem.setValue(qrcode);
}
collect.add(listItem);
}
}
root.setList(collect);
String fileName = "file/fileupload/excel/"+entity.getCatalogName()+"_批量导入模板.xls";
String excelFilePath = rootPath + fileName;
ExcelUtil.createCatalogTemplate(excelFilePath, excelList);
entity.setExcelFile(fileName);
if(!onlyExcel) {
entity.setFormContent(JSON.toJSONString(root));
}
}
@Override
public void generateExcel(Long id, Context context) {
// CertificateCatalogEntity entity = dao.get(id);
// parseDocxToJson(entity,true);
// CertificateCatalogEntity updata = new CertificateCatalogEntity();
// updata.setId(entity.getId());
// updata.setExcelFile(entity.getExcelFile());
// updata.setUpdateTime(new Date());
// dao.update(updata);
CertificateCatalogEntity entity = dao.get(id);
parseDocxToJson(entity,true);
CertificateCatalogEntity updata = new CertificateCatalogEntity();
updata.setId(entity.getId());
updata.setExcelFile(entity.getExcelFile());
updata.setUpdateTime(new Date());
dao.update(updata);
}
}
\ No newline at end of file
......@@ -70,6 +70,7 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens
entity.setBusinessPlace(applyLogEntity.getBusinessPlace());
entity.setLicensedItems(applyLogEntity.getLicenseProject());
entity.setFormStyleContent(item.getTemplateContent());
entity.setFormContent(item.getFormContent());
entity.setProcessStatus(ProcessStatusEnum.未处理.getValue());
entity.setCreateTime(applyLogEntity.getCreateTime());
entity.setCreateUserId(applyLogEntity.getCreateUserId());
......
......@@ -25,4 +25,6 @@ public class ApplyLogVo extends BaseEntityLong {
/** 子证信息 */
List<ChildLicenseEntity> childLicense;
private String processStatus;
}
\ No newline at end of file
......@@ -128,6 +128,18 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
return query;
}
@Override
protected void findAfter(ApplyLogEntity params, PageInfo pageInfo, Context context, List<ApplyLogEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)){
for(ApplyLogEntity entity:list){
List<ChildLicenseEntity> childLicenseList = childLicenseService.find(new ChildLicenseQuery().applyId(entity.getId()));
Map<Integer,List<ChildLicenseEntity>> group = childLicenseList.stream().collect(Collectors.groupingBy(x->x.getProcessStatus()));
int pCount = group.get(1).size();
entity.setProcessStatus(pCount+"/"+childLicenseList.size());
}
}
}
@Override
protected void validData(ApplyLogEntity entity, Context context) throws AppException {
if(StringUtils.isEmpty(entity.getCertificateCode())){
......
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