Commit a8e3a10d authored by 赵啸非's avatar 赵啸非

添加目录字段

parent cec8bf41
......@@ -55,9 +55,8 @@
<id>product</id>
<properties>
<profiles.active>product</profiles.active>
<profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15506</profiles.server.debug>
<profiles.filepath>/mortals/app/data/one</profiles.filepath>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.server-addr>192.168.0.250:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
</properties>
......
......@@ -19,5 +19,10 @@ public class CertificateDocumentVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */
private List <Long> idList;
/**
* 证照目录id
*/
private Long catalogId;
}
\ No newline at end of file
......@@ -20,10 +20,7 @@ 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;
import com.mortals.xhx.module.certificate.model.CertificateChildEntity;
import com.mortals.xhx.module.certificate.model.CertificateChildQuery;
import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity;
import com.mortals.xhx.module.certificate.model.*;
import com.mortals.xhx.module.certificate.service.CertificateCatalogService;
import com.mortals.xhx.module.certificate.service.CertificateChildService;
import com.mortals.xhx.module.certificate.service.CertificateClassifyService;
......@@ -34,6 +31,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -83,20 +81,20 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Override
protected void saveBefore(CertificateCatalogEntity entity, Context context) throws AppException {
validData(entity,context);
validData(entity, context);
entity.setStatus(StatusEnum.ENABLE.getValue());
if(StringUtils.isNotEmpty(entity.getTemplateFileUrl())){
if (StringUtils.isNotEmpty(entity.getTemplateFileUrl())) {
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson(entity,false);
parseDocxToJson(entity, false);
}
}
@Override
protected void updateBefore(CertificateCatalogEntity entity, Context context) throws AppException {
validData(entity,context);
validData(entity, context);
CertificateCatalogEntity old = this.get(entity.getId());
if(!old.getTemplateFileUrl().equals(entity.getTemplateFileUrl())) {
if (!old.getTemplateFileUrl().equals(entity.getTemplateFileUrl())) {
if (StringUtils.isNotEmpty(entity.getTemplateFileUrl())) {
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson(entity, false);
......@@ -116,8 +114,15 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Override
protected void findAfter(CertificateCatalogEntity params, PageInfo pageInfo, Context context, List<CertificateCatalogEntity> list) throws AppException {
if (CollectionUtils.isNotEmpty(list)) {
List<Long> classifIdList = list.parallelStream().map(CertificateCatalogEntity::getClassifyId).collect(Collectors.toList());
CertificateClassifyQuery certificateClassifyQuery = new CertificateClassifyQuery();
certificateClassifyQuery.setIdList(classifIdList);
Map<Long, CertificateClassifyEntity> collect = certificateClassifyService.find(certificateClassifyQuery, context).parallelStream()
.collect(Collectors.toMap(CertificateClassifyEntity::getId, Function.identity(), (n1, n2) -> n1));
for (CertificateCatalogEntity entity : list) {
CertificateClassifyEntity certificateClassifyEntity = certificateClassifyService.get(entity.getClassifyId());
CertificateClassifyEntity certificateClassifyEntity = collect.get(entity.getClassifyId());
// CertificateClassifyEntity certificateClassifyEntity = certificateClassifyService.get(entity.getClassifyId());
if (certificateClassifyEntity != null) {
entity.setClassifyType(certificateClassifyEntity.getClassifyType());
} else {
......@@ -138,7 +143,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
List<Long> idList = list.stream().map(i -> i.getId()).collect(Collectors.toList());
CertificateChildQuery certificateChildQuery = new CertificateChildQuery();
certificateChildQuery.setCatalogIdList(idList);
Map<Long, List<CertificateChildEntity>> certificateChildListMap = certificateChildService.find(certificateChildQuery).stream().collect(Collectors.groupingBy(CertificateChildEntity::getCatalogId));
Map<Long, List<CertificateChildEntity>> certificateChildListMap = certificateChildService.find(certificateChildQuery).parallelStream().collect(Collectors.groupingBy(CertificateChildEntity::getCatalogId));
list.forEach(item -> item.setCertificateChildList(certificateChildListMap.get(item.getId())));
}
......@@ -147,6 +152,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
if (!ObjectUtils.isEmpty(entity.getCertificateChildList())) {
entity.getCertificateChildList().stream().peek(item -> {
item.setCatalogId(entity.getId());
item.setCatalogName(entity.getCatalogName());
item.setCreateUserId(this.getContextUserId(context));
item.setCreateTime(new Date());
}).count();
......@@ -179,7 +185,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
super.removeAfter(ids, context, result);
}
private void parseDocxToJson(CertificateCatalogEntity entity,boolean onlyExcel) {
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();
......@@ -206,9 +212,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
// excelList.add("持有者证件号码");
// excelList.add("企业名称");
for (MetaTemplate item : template.getElementTemplates()) {
if(hs.contains(item.variable())){
if (hs.contains(item.variable())) {
continue;
}else {
} else {
hs.add(item.variable());
}
//识别简单输入
......@@ -236,9 +242,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
XWPFTemplate templateTable = XWPFTemplate.compile(filepath, builderTable.build());
for (MetaTemplate col : templateTable.getElementTemplates()) {
if(dhs.contains(col.variable())){
if (dhs.contains(col.variable())) {
continue;
}else {
} else {
dhs.add(col.variable());
}
String colVal = StrUtil.strip(col.variable(), "[", "]");
......@@ -266,18 +272,18 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
}
DesignComponent designComponent = DesignComponent.createType(type);
ListItem listItem = designComponent.buildDefaultComponent(cons);
if(type.equals(ComponentEnum.QRCODE.getValue())){
if (type.equals(ComponentEnum.QRCODE.getValue())) {
listItem.setValue(qrcode);
}
collect.add(listItem);
}
}
root.setList(collect);
String fileName = "file/fileupload/excel/"+entity.getCatalogName()+"_批量导入模板.xls";
String fileName = "file/fileupload/excel/" + entity.getCatalogName() + "_批量导入模板.xls";
String excelFilePath = rootPath + fileName;
ExcelUtil.createCatalogTemplate(excelFilePath, excelList);
entity.setExcelFile(fileName);
if(!onlyExcel) {
if (!onlyExcel) {
entity.setFormContent(JSON.toJSONString(root));
}
}
......@@ -286,7 +292,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Override
public void generateExcel(Long id, Context context) {
CertificateCatalogEntity entity = dao.get(id);
parseDocxToJson(entity,true);
parseDocxToJson(entity, true);
CertificateCatalogEntity updata = new CertificateCatalogEntity();
updata.setId(entity.getId());
updata.setExcelFile(entity.getExcelFile());
......
......@@ -5,14 +5,20 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.StatusEnum;
import com.mortals.xhx.module.certificate.model.CertificateChildEntity;
import com.mortals.xhx.module.certificate.model.CertificateChildQuery;
import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity;
import com.mortals.xhx.module.certificate.service.CertificateChildService;
import com.mortals.xhx.module.certificate.service.CertificateDocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
* 子证配置
......@@ -25,7 +31,8 @@ import java.util.Map;
public class CertificateDocumentController extends BaseCRUDJsonBodyMappingController<CertificateDocumentService,CertificateDocumentEntity,Long> {
@Autowired
private ParamService paramService;
private CertificateChildService certificateChildService;
public CertificateDocumentController(){
super.setModuleDesc( "子证配置");
......@@ -38,6 +45,18 @@ public class CertificateDocumentController extends BaseCRUDJsonBodyMappingContro
}
@Override
protected void doListBefore(CertificateDocumentEntity query, Map<String, Object> model, Context context) throws AppException {
if(!ObjectUtils.isEmpty(query.getCatalogId())){
List<Long> documentIdList = certificateChildService.find(new CertificateChildQuery().catalogId(query.getCatalogId())).stream()
.map(CertificateChildEntity::getDocumentId).collect(Collectors.toList());
if(!ObjectUtils.isEmpty(documentIdList)){
query.setIdList(documentIdList);
}
}
super.doListBefore(query, model, context);
}
@Override
protected void doListAfter(CertificateDocumentEntity query, List<CertificateDocumentEntity> list, Context context) throws AppException {
list.forEach(item->{
......
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