Commit a5f39b7b authored by 廖旭伟's avatar 廖旭伟

增加合成word文件后转为PDF文件进行打印;二维码控件增加默认值;待打印文件列表返回值增加打印服务地址属性

parent 12cb4438
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
</profile> </profile>
<profile> <profile>
<id>test</id> <id>test</id>
<properties> <properties>
<profiles.active>test</profiles.active> <profiles.active>test</profiles.active>
<profiles.server.port>17216</profiles.server.port> <profiles.server.port>17216</profiles.server.port>
......
...@@ -380,4 +380,7 @@ public class ListItem{ ...@@ -380,4 +380,7 @@ public class ListItem{
@JSONField(name="limit") @JSONField(name="limit")
private Integer limit; private Integer limit;
@JSONField(name="value")
private Object value;
} }
\ No newline at end of file
...@@ -20,30 +20,31 @@ public class DesignQrcodeComponent extends DesignComponent { ...@@ -20,30 +20,31 @@ public class DesignQrcodeComponent extends DesignComponent {
ListItem columnsItem = new ListItem(); ListItem columnsItem = new ListItem();
columnsItem.setId(cons.getVal()); columnsItem.setId(cons.getVal());
columnsItem.set_id(cons.getVal()); columnsItem.set_id(cons.getVal());
columnsItem.setCompType("input"); columnsItem.setCompType("textarea");
columnsItem.setCompName(cons.getLabel());
columnsItem.setCompIcon("input");
columnsItem.setEle("el-input"); columnsItem.setEle("el-input");
columnsItem.setCompName("多行文本");
columnsItem.setCompIcon("textarea");
columnsItem.setViewType("text"); columnsItem.setViewType("text");
columnsItem.setType("textarea");
columnsItem.setConfig(true); columnsItem.setConfig(true);
columnsItem.setShowLabel(true); columnsItem.setShowLabel(true);
columnsItem.setLabel(cons.getLabel()); columnsItem.setLabel(cons.getLabel());
columnsItem.setLabelWidth(120); columnsItem.setLabelWidth(120);
columnsItem.setPlaceholder("请输入"+cons.getLabel()); columnsItem.setPlaceholder("请输入" + cons.getLabel());
columnsItem.setRequired(true); columnsItem.setRequired(true);
columnsItem.setMaxLength(50); columnsItem.setMaxLength(200);
columnsItem.setShowWordLimit(true);
columnsItem.setGutter(15); columnsItem.setGutter(15);
columnsItem.setSpan(24); columnsItem.setSpan(24);
columnsItem.setWidth("100%");
columnsItem.setClearable(true); columnsItem.setClearable(true);
columnsItem.setDisabled(false); columnsItem.setDisabled(false);
columnsItem.setReadonly(false); columnsItem.setReadonly(false);
columnsItem.setRows(4);
columnsItem.setStatus("normal"); columnsItem.setStatus("normal");
columnsItem.setPrefixIcon(""); //设置默认值
columnsItem.setRules(Lists.newArrayList()); columnsItem.setRules(Lists.newArrayList());
columnsItem.setRuleError("该字段不能为空");
columnsItem.setRulesType("default"); columnsItem.setRulesType("default");
columnsItem.setAppend("");
columnsItem.setPrepend("");
columnsItem.setLayout("colItem"); columnsItem.setLayout("colItem");
return columnsItem; return columnsItem;
} }
......
...@@ -216,5 +216,37 @@ public class WordUtil { ...@@ -216,5 +216,37 @@ public class WordUtil {
} }
public static String convertWordToPDF(String inputFile, String pdfPath) {
FileOutputStream os = null;
try {
long old = System.currentTimeMillis();
File file = new File(pdfPath); // 新建一个空白pdf文档
os = new FileOutputStream(file);
Document doc = new Document(inputFile); // Address是将要被转化的word文档
doc.save(os, SaveFormat.PDF);// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
// EPUB, XPS, SWF 相互转换
long now = System.currentTimeMillis();
System.out.println("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒"); // 转化用时
return pdfPath;
} catch (Exception e) {
e.printStackTrace();
throw new AppException(String.format("文件转换异常!", e.getMessage()));
}finally {
if (os != null) {
try {
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args){
String wordp = "D:\\mortals\\app\\data\\test\\1680172785313.docx";
String pdfP = "D:\\mortals\\app\\data\\test\\1680172785313.pdf";
convertWordToPDF(wordp,pdfP);
}
} }
...@@ -48,6 +48,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -48,6 +48,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@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/uploadfile}")
private String uploadUrl; private String uploadUrl;
@Value("${qrcode.url:http://rhpt.scjg.chengdu.gov.cn:8091/adap/spjy/process/generateQrCode.do?dto.applyId=}")
private String qrcode;
@Autowired @Autowired
private CertificateClassifyService certificateClassifyService; private CertificateClassifyService certificateClassifyService;
...@@ -76,6 +79,33 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -76,6 +79,33 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
} }
@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("所属行业不能为空");
}
CertificateCatalogEntity old = this.get(entity.getId());
if(!old.getTemplateUrl().equals(entity.getTemplateUrl())) {
if (StringUtils.isNotEmpty(entity.getTemplateUrl())) {
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson(entity, false);
}
}
}
// @Override // @Override
// protected void validData(CertificateCatalogEntity entity, Context context) throws AppException { // protected void validData(CertificateCatalogEntity entity, Context context) throws AppException {
// Map<String,Object> condition = new HashMap<>(); // Map<String,Object> condition = new HashMap<>();
...@@ -195,6 +225,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -195,6 +225,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
} }
DesignComponent designComponent = DesignComponent.createType(type); DesignComponent designComponent = DesignComponent.createType(type);
ListItem listItem = designComponent.buildDefaultComponent(cons); ListItem listItem = designComponent.buildDefaultComponent(cons);
if(type.equals(ComponentEnum.QRCODE.getValue())){
listItem.setValue(qrcode);
}
collect.add(listItem); collect.add(listItem);
} }
} }
...@@ -209,15 +242,15 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -209,15 +242,15 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
} }
public static void main(String[] args){ public static void main(String[] args){
String excelFilePath = "D:/mortals/app/data/cpm/" + "excel/test1.xls"; // String excelFilePath = "D:/mortals/app/data/cpm/" + "excel/test1.xls";
List<String> excelList = new ArrayList<>(); // List<String> excelList = new ArrayList<>();
excelList.add("i_1_姓名"); // excelList.add("i_1_姓名");
excelList.add("i_2_性别"); // excelList.add("i_2_性别");
excelList.add("i_3_年龄"); // excelList.add("i_3_年龄");
excelList.add("i_4_证件编号"); // excelList.add("i_4_证件编号");
excelList.add("i_5_证件名称"); // excelList.add("i_5_证件名称");
//
ExcelUtil.createCatalogTemplate(excelFilePath,excelList); // ExcelUtil.createCatalogTemplate(excelFilePath,excelList);
} }
@Override @Override
......
...@@ -13,6 +13,11 @@ import java.util.List; ...@@ -13,6 +13,11 @@ import java.util.List;
*/ */
@Data @Data
public class PrintWaitQueueVo extends BaseEntityLong { public class PrintWaitQueueVo extends BaseEntityLong {
/**
* 打印服务网络地址
*/
private String printerServiceUrl;
/** /**
* 打印机名称 * 打印机名称
*/ */
......
...@@ -194,7 +194,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap ...@@ -194,7 +194,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
CertificateCatalogEntity catalog = certificateCatalogService.get(applyLogEntity.getCatalogId()); CertificateCatalogEntity catalog = certificateCatalogService.get(applyLogEntity.getCatalogId());
applyLogEntity.setCatalogCode(catalog.getCatalogCode()); applyLogEntity.setCatalogCode(catalog.getCatalogCode());
DocTemplateVO docTemplate = new DocTemplateVO(catalog.getTemplateUrl(),applyLogEntity.getFormContent()); DocTemplateVO docTemplate = new DocTemplateVO(catalog.getTemplateUrl(),applyLogEntity.getFormContent());
return preview(docTemplate, context); return preview(docTemplate, context,false);
} }
@Override @Override
...@@ -206,12 +206,14 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap ...@@ -206,12 +206,14 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
CertificateCatalogEntity catalog = certificateCatalogService.get(applyLogEntity.getCatalogId()); CertificateCatalogEntity catalog = certificateCatalogService.get(applyLogEntity.getCatalogId());
applyLogEntity.setCatalogCode(catalog.getCatalogCode()); applyLogEntity.setCatalogCode(catalog.getCatalogCode());
applyLogEntity.setCatalogName(catalog.getCatalogName()); applyLogEntity.setCatalogName(catalog.getCatalogName());
applyLogEntity.setFormTemplate(catalog.getFormContent()); //applyLogEntity.setFormTemplate(catalog.getFormContent());
DocTemplateVO docTemplate = new DocTemplateVO(catalog.getTemplateUrl(),applyLogEntity.getFormContent()); DocTemplateVO docTemplate = new DocTemplateVO(catalog.getTemplateUrl(),applyLogEntity.getFormContent());
String paths = preview(docTemplate, context); String paths = preview(docTemplate, context,true);
String[] vals = paths.split(";"); String[] vals = paths.split(";");
applyLogEntity.setCertificateUrl(vals[0]); if(vals.length==3) {
applyLogEntity.setPreviewUrl(vals[1]); applyLogEntity.setCertificateUrl(vals[2]);
applyLogEntity.setPreviewUrl(vals[1]);
}
applyLogEntity.setCreateTime(new Date()); applyLogEntity.setCreateTime(new Date());
applyLogEntity.setRecordStatus(YesNoEnum.NO.getValue()); applyLogEntity.setRecordStatus(YesNoEnum.NO.getValue());
if(context!=null && context.getUser()!=null) { if(context!=null && context.getUser()!=null) {
...@@ -250,7 +252,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap ...@@ -250,7 +252,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
printWaitQueueService.creatWaitQueueByApply(applyLogEntity, GenerateStatus.ORIGINAL.getValue(),context); printWaitQueueService.creatWaitQueueByApply(applyLogEntity, GenerateStatus.ORIGINAL.getValue(),context);
} }
private String preview(DocTemplateVO docTemplate,Context context){ private String preview(DocTemplateVO docTemplate,Context context,boolean hasPDF){
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/"; String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
//转换表单参数为map集合 //转换表单参数为map集合
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
...@@ -353,9 +355,18 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap ...@@ -353,9 +355,18 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
} }
WordUtil.convertWordToJPEG(mergedoc, preView); WordUtil.convertWordToJPEG(mergedoc, preView);
log.info("preView:" + "/preview/" + fileName); log.info("preView:" + "/preview/" + fileName);
//下载地址拼装 if(hasPDF) {
String returnStr = mergedocPath + ";" + "/preview/" + fileName; String pdfName = mergedocPath.substring(0,mergedocPath.indexOf(".")) + ".pdf";
return returnStr; String pdfPath = rootPath + pdfName;
WordUtil.convertWordToPDF(mergedoc, pdfPath);
//下载地址拼装
String returnStr = mergedocPath + ";" + "/preview/" + fileName + ";" + pdfName;
return returnStr;
}else {
//下载地址拼装
String returnStr = mergedocPath + ";" + "/preview/" + fileName;
return returnStr;
}
} catch (Exception e) { } catch (Exception e) {
log.error("渲染模板失败:", e); log.error("渲染模板失败:", e);
} finally { } finally {
......
...@@ -9,10 +9,17 @@ import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity; ...@@ -9,10 +9,17 @@ import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity;
import com.mortals.xhx.module.certificate.model.CertificateClassifyQuery; import com.mortals.xhx.module.certificate.model.CertificateClassifyQuery;
import com.mortals.xhx.module.certificate.service.CertificateCatalogService; import com.mortals.xhx.module.certificate.service.CertificateCatalogService;
import com.mortals.xhx.module.certificate.service.CertificateClassifyService; import com.mortals.xhx.module.certificate.service.CertificateClassifyService;
import com.mortals.xhx.module.print.model.PrintCatalogEntity;
import com.mortals.xhx.module.print.model.PrintCatalogQuery;
import com.mortals.xhx.module.print.model.PrintServiceEntity;
import com.mortals.xhx.module.print.model.PrintServiceQuery;
import com.mortals.xhx.module.print.service.PrintCatalogService;
import com.mortals.xhx.module.print.service.PrintServiceService;
import com.mortals.xhx.module.record.dao.PrintLogDao; import com.mortals.xhx.module.record.dao.PrintLogDao;
import com.mortals.xhx.module.record.dao.RetainLogDao; import com.mortals.xhx.module.record.dao.RetainLogDao;
import com.mortals.xhx.module.record.model.*; import com.mortals.xhx.module.record.model.*;
import com.mortals.xhx.module.record.service.PrintLogService; import com.mortals.xhx.module.record.service.PrintLogService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -57,14 +64,40 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait ...@@ -57,14 +64,40 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait
private CertificateClassifyService certificateClassifyService; private CertificateClassifyService certificateClassifyService;
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private PrintServiceService printServiceService;
@Autowired
private PrintCatalogService printCatalogService;
@Override @Override
protected void findAfter(PrintWaitQueueEntity entity, Context context, List<PrintWaitQueueEntity> list) throws AppException { protected void findAfter(PrintWaitQueueEntity entity, Context context, List<PrintWaitQueueEntity> list) throws AppException {
//TODO 当前版本没有设置多个打印服务,默认只存在一个打印服务
List<PrintServiceEntity> printServiceEntities = printServiceService.find(new PrintServiceQuery());
PrintServiceEntity printServiceEntity = null;
if(CollectionUtils.isNotEmpty(printServiceEntities)){
printServiceEntity = printServiceEntities.get(0);
}
for(PrintWaitQueueEntity printWaitQueueEntity:list){ for(PrintWaitQueueEntity printWaitQueueEntity:list){
CertificateCatalogEntity catalogEntity = certificateCatalogService.get(printWaitQueueEntity.getCatalogId()); if(printServiceEntity!=null){
printWaitQueueEntity.setPaperSource(catalogEntity.getPaperSource()); PrintCatalogEntity printCatalogEntity = printCatalogService.selectOne(new PrintCatalogQuery().catalogId(printWaitQueueEntity.getCatalogId()).serviceId(printServiceEntity.getId()));
printWaitQueueEntity.setPrinterIp(catalogEntity.getPrinterIp()); if(printCatalogEntity!=null){
printWaitQueueEntity.setPrinterName(catalogEntity.getPrinterName()); printWaitQueueEntity.setPaperSource(printCatalogEntity.getPaperSource());
printWaitQueueEntity.setPrinterIp(printCatalogEntity.getPrinterIp());
printWaitQueueEntity.setPrinterName(printCatalogEntity.getPrinterName());
}else {
CertificateCatalogEntity catalogEntity = certificateCatalogService.get(printWaitQueueEntity.getCatalogId());
printWaitQueueEntity.setPaperSource(catalogEntity.getPaperSource());
printWaitQueueEntity.setPrinterIp(catalogEntity.getPrinterIp());
printWaitQueueEntity.setPrinterName(catalogEntity.getPrinterName());
}
printWaitQueueEntity.setPrinterServiceUrl(printServiceEntity.getServiceUrl());
}else {
CertificateCatalogEntity catalogEntity = certificateCatalogService.get(printWaitQueueEntity.getCatalogId());
printWaitQueueEntity.setPaperSource(catalogEntity.getPaperSource());
printWaitQueueEntity.setPrinterIp(catalogEntity.getPrinterIp());
printWaitQueueEntity.setPrinterName(catalogEntity.getPrinterName());
printWaitQueueEntity.setPrinterServiceUrl("http://127.0.0.1:8037");
}
} }
} }
...@@ -157,6 +190,7 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait ...@@ -157,6 +190,7 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait
Date now = new Date(); Date now = new Date();
retainLogEntity.setCatalogId(waitQueueEntity.getCatalogId()); retainLogEntity.setCatalogId(waitQueueEntity.getCatalogId());
retainLogEntity.setCatalogCode(waitQueueEntity.getCatalogCode()); retainLogEntity.setCatalogCode(waitQueueEntity.getCatalogCode());
retainLogEntity.setCatalogName(waitQueueEntity.getCatalogName());
retainLogEntity.setCertificateName(waitQueueEntity.getCertificateName()); retainLogEntity.setCertificateName(waitQueueEntity.getCertificateName());
retainLogEntity.setCertificateCode(waitQueueEntity.getCertificateCode()); retainLogEntity.setCertificateCode(waitQueueEntity.getCertificateCode());
retainLogEntity.setEnterpriseName(waitQueueEntity.getEnterpriseName()); retainLogEntity.setEnterpriseName(waitQueueEntity.getEnterpriseName());
...@@ -169,7 +203,7 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait ...@@ -169,7 +203,7 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait
PrintLogEntity printLogEntity = new PrintLogEntity(); PrintLogEntity printLogEntity = new PrintLogEntity();
printLogEntity.setCatalogId(waitQueueEntity.getCatalogId()); printLogEntity.setCatalogId(waitQueueEntity.getCatalogId());
printLogEntity.setCatalogCode(waitQueueEntity.getCatalogCode()); printLogEntity.setCatalogCode(waitQueueEntity.getCatalogCode());
printLogEntity.setCatalogName(waitQueueEntity.getCatalogName());
printLogEntity.setCertificateName(waitQueueEntity.getCertificateName()); printLogEntity.setCertificateName(waitQueueEntity.getCertificateName());
printLogEntity.setCertificateCode(waitQueueEntity.getCertificateCode()); printLogEntity.setCertificateCode(waitQueueEntity.getCertificateCode());
printLogEntity.setEnterpriseName(waitQueueEntity.getEnterpriseName()); printLogEntity.setEnterpriseName(waitQueueEntity.getEnterpriseName());
......
...@@ -71,11 +71,16 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL ...@@ -71,11 +71,16 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL
try { try {
String paths = this.service.previewOriginal(applyLogEntity, getContext()); String paths = this.service.previewOriginal(applyLogEntity, getContext());
String[] vals = paths.split(";"); String[] vals = paths.split(";");
ret.setCode(VALUE_RESULT_SUCCESS); if(vals.length>1) {
ret.setMsg("生成成功"); ret.setCode(VALUE_RESULT_SUCCESS);
//model.put("mergeDoc", vals[0]); ret.setMsg("生成成功");
model.put("preview", vals[1]); //model.put("mergeDoc", vals[0]);
ret.setData(model); model.put("preview", vals[1]);
ret.setData(model);
}else {
ret.setCode(VALUE_RESULT_FAILURE);
ret.setMsg("生成失败");
}
} catch (Exception e) { } catch (Exception e) {
log.error("合成表单异常", e); log.error("合成表单异常", e);
ret.setCode(VALUE_RESULT_FAILURE); ret.setCode(VALUE_RESULT_FAILURE);
......
...@@ -61,3 +61,5 @@ token: ...@@ -61,3 +61,5 @@ token:
upload: upload:
path: @profiles.filepath@ path: @profiles.filepath@
url: http://192.168.0.98:17216/cpm/file/commonupload?prePath=/file/uploadfile url: http://192.168.0.98:17216/cpm/file/commonupload?prePath=/file/uploadfile
qrcode:
url: http://rhpt.scjg.chengdu.gov.cn:8091/adap/spjy/process/generateQrCode.do?dto.applyId=
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