Commit 96883dac authored by 廖旭伟's avatar 廖旭伟

bug修改

parent d5b27230
package com.mortals.xhx.module.certificate.model.vo;
import lombok.Data;
@Data
public class CertificateDocumentPdu {
Long id;
/**
* 站点id
*/
private Long siteId;
/**
* 部门id
*/
private Long deptId;
/**
* 部门名称
*/
private String deptName;
/**
* 子证名称
*/
private String documentName;
/**
* 简称
*/
private String shortName;
/**
* 状态,0:禁用1:启用
*/
private Integer status;
}
......@@ -2,6 +2,9 @@ package com.mortals.xhx.module.certificate.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity;
import com.mortals.xhx.module.certificate.dao.CertificateDocumentDao;
import java.util.List;
/**
* CertificateDocumentService
*
......@@ -13,4 +16,6 @@ import com.mortals.xhx.module.certificate.dao.CertificateDocumentDao;
public interface CertificateDocumentService extends ICRUDService<CertificateDocumentEntity,Long>{
CertificateDocumentDao getDao();
List<CertificateDocumentEntity> getListByCatalogId(Long catalogId);
}
\ No newline at end of file
package com.mortals.xhx.module.certificate.service.impl;
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.CertificateDocumentQuery;
import com.mortals.xhx.module.certificate.service.CertificateChildService;
import org.springframework.beans.BeanUtils;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -20,4 +30,14 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CertificateDocumentServiceImpl extends AbstractCRUDServiceImpl<CertificateDocumentDao, CertificateDocumentEntity, Long> implements CertificateDocumentService {
@Autowired
private CertificateChildService certificateChildService;
@Override
public List<CertificateDocumentEntity> getListByCatalogId(Long catalogId) {
List<CertificateChildEntity> childEntityList = certificateChildService.find(new CertificateChildQuery().catalogId(catalogId));
List<Long> documentIdList = childEntityList.stream().map(CertificateChildEntity::getDocumentId).collect(Collectors.toList());
List<CertificateDocumentEntity> documentEntityList = this.find(new CertificateDocumentQuery().idList(documentIdList).status(StatusEnum.ENABLE.getValue()));
return documentEntityList;
}
}
\ No newline at end of file
......@@ -18,5 +18,5 @@ public interface ChildLicenseService extends ICRUDService<ChildLicenseEntity,Lon
ChildLicenseDao getDao();
int createChildLicense(ApplyLogEntity applyLogEntity, Context context) throws AppException;
int createChildLicense(ApplyLogEntity applyLogEntity,Long oldApplyId, Context context) throws AppException;
}
\ No newline at end of file
package com.mortals.xhx.module.child.service.impl;
import com.mortals.xhx.common.code.ProcessStatusEnum;
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.model.CertificateDocumentQuery;
import com.mortals.xhx.module.certificate.service.CertificateChildService;
import com.mortals.xhx.module.certificate.service.CertificateDocumentService;
import com.mortals.xhx.module.child.model.ChildLicenseQuery;
import com.mortals.xhx.module.record.model.ApplyLogEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -41,12 +41,37 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens
@Autowired
private CertificateDocumentService certificateDocumentService;
@Override
public int createChildLicense(ApplyLogEntity applyLogEntity, Context context) throws AppException {
public int createChildLicense(ApplyLogEntity applyLogEntity, Long oldId, Context context) throws AppException {
int result = 0;
if(applyLogEntity.getCatalogId()!=null) {
Map<Long,Long> documentIdMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(applyLogEntity.getChildCertificate())){
applyLogEntity.getChildCertificate().forEach(i->{
if(i.getStatus()==1){
documentIdMap.put(i.getId(),i.getId());
}
});
}
boolean isAdd = true;
if(oldId!=null){
List<ChildLicenseEntity> oldChildList = this.find(new ChildLicenseQuery().applyId(oldId));
if(CollectionUtils.isNotEmpty(oldChildList)){
isAdd = false;
}
for(ChildLicenseEntity child:oldChildList){
child.setApplyId(applyLogEntity.getId());
if (documentIdMap.size() > 0 && documentIdMap.containsKey(child.getDocumentId())) {
child.setChildStatus(StatusEnum.ENABLE.getValue());
} else {
child.setChildStatus(StatusEnum.DISABLE.getValue());
}
}
this.update(oldChildList);
}
if(isAdd) {
List<CertificateChildEntity> childEntityList = certificateChildService.find(new CertificateChildQuery().catalogId(applyLogEntity.getCatalogId()));
List<Long> documentIdList = childEntityList.stream().map(CertificateChildEntity::getDocumentId).collect(Collectors.toList());
List<CertificateDocumentEntity> documentEntityList = certificateDocumentService.find(new CertificateDocumentQuery().idList(documentIdList));
List<CertificateDocumentEntity> documentEntityList = certificateDocumentService.find(new CertificateDocumentQuery().idList(documentIdList).status(StatusEnum.ENABLE.getValue()));
if (CollectionUtils.isNotEmpty(documentEntityList)) {
List<ChildLicenseEntity> childLicense = new ArrayList<>();
for (CertificateDocumentEntity item : documentEntityList) {
......@@ -74,11 +99,17 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens
entity.setProcessStatus(ProcessStatusEnum.未处理.getValue());
entity.setCreateTime(applyLogEntity.getCreateTime());
entity.setCreateUserId(applyLogEntity.getCreateUserId());
if (documentIdMap.size() > 0 && documentIdMap.containsKey(item.getId())) {
entity.setChildStatus(StatusEnum.ENABLE.getValue());
} else {
entity.setChildStatus(StatusEnum.DISABLE.getValue());
}
childLicense.add(entity);
}
this.dao.insertBatch(childLicense);
}
}
}
return result;
}
......
package com.mortals.xhx.module.record.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity;
import com.mortals.xhx.module.certificate.model.vo.CertificateDocumentPdu;
import com.mortals.xhx.module.child.model.ChildLicenseEntity;
import com.mortals.xhx.module.record.model.ApplyLogEntity;
import lombok.Data;
......@@ -25,6 +27,9 @@ public class ApplyLogVo extends BaseEntityLong {
/** 子证信息 */
List<ChildLicenseEntity> childLicense;
/** 子证联报状态 已联报数/子证总数 */
private String processStatus;
private List<CertificateDocumentPdu> childCertificate;
}
\ No newline at end of file
......@@ -24,9 +24,11 @@ import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.utils.*;
import com.mortals.xhx.module.certificate.model.*;
import com.mortals.xhx.module.certificate.model.vo.CertificateDocumentPdu;
import com.mortals.xhx.module.certificate.pdu.ApplyLogPdu;
import com.mortals.xhx.module.certificate.service.CertificateCatalogService;
import com.mortals.xhx.module.certificate.service.CertificateClassifyService;
import com.mortals.xhx.module.certificate.service.CertificateDocumentService;
import com.mortals.xhx.module.child.model.ChildLicenseEntity;
import com.mortals.xhx.module.child.model.ChildLicenseQuery;
import com.mortals.xhx.module.child.service.ChildLicenseService;
......@@ -86,8 +88,6 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
@Autowired
private UserService userService;
@Autowired
private CertificateClassifyService certificateClassifyService;
@Autowired
private ChildLicenseService childLicenseService;
@Override
......@@ -103,7 +103,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
public ApplyLogEntity get(Long key, Context context) throws AppException {
ApplyLogEntity entity = this.dao.get(key);
if(entity!=null){
List<ChildLicenseEntity> childs = childLicenseService.find(new ChildLicenseQuery().applyId(key).processStatus(ProcessStatusEnum.已处理.getValue()));
List<ChildLicenseEntity> childs = childLicenseService.find(new ChildLicenseQuery().applyId(key).processStatus(ProcessStatusEnum.已处理.getValue()).childStatus(StatusEnum.ENABLE.getValue()));
entity.setChildLicense(childs);
}
return entity;
......@@ -134,46 +134,67 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
if(CollectionUtils.isNotEmpty(list)){
for(ApplyLogEntity entity:list){
List<ChildLicenseEntity> childLicenseList = childLicenseService.find(new ChildLicenseQuery().applyId(entity.getId()));
if(CollectionUtils.isEmpty(childLicenseList)){
entity.setProcessStatus("0/0");
}else {
Map<Integer, List<ChildLicenseEntity>> group = childLicenseList.stream().collect(Collectors.groupingBy(x -> x.getProcessStatus()));
int pCount = CollectionUtils.isEmpty(group.get(1)) ? 0 : group.get(1).size();
entity.setProcessStatus(pCount + "/" + childLicenseList.size());
// if(CollectionUtils.isEmpty(childLicenseList)){
// entity.setProcessStatus("0/0");
// }else {
// Map<Integer, List<ChildLicenseEntity>> group = childLicenseList.stream().collect(Collectors.groupingBy(x -> x.getProcessStatus()));
// int pCount = CollectionUtils.isEmpty(group.get(1)) ? 0 : group.get(1).size();
// entity.setProcessStatus(pCount + "/" + childLicenseList.size());
// }
int childSum = 0;
int pCount = 0;
List<CertificateDocumentPdu> documentEntityList = new ArrayList<>();
for(ChildLicenseEntity item:childLicenseList){
CertificateDocumentEntity documentEntity = new CertificateDocumentEntity();
BeanUtils.copyProperties(item,documentEntity);
documentEntity.setId(item.getDocumentId());
documentEntity.setStatus(StatusEnum.DISABLE.getValue());
if(item.getChildStatus()==StatusEnum.ENABLE.getValue()){
documentEntity.setStatus(StatusEnum.ENABLE.getValue());
childSum++;
if(item.getProcessStatus()==ProcessStatusEnum.已处理.getValue().intValue()){
pCount++;
}
}
CertificateDocumentPdu pdu = new CertificateDocumentPdu();
BeanUtils.copyProperties(documentEntity, pdu);
documentEntityList.add(pdu);
}
entity.setProcessStatus(pCount + "/" + childSum);
entity.setChildCertificate(documentEntityList);
}
}
}
@Override
protected void validData(ApplyLogEntity entity, Context context) throws AppException {
if(StringUtils.isEmpty(entity.getCertificateCode())){
throw new AppException("许可证编号不能为空");
}
if(entity.getIssueTime()==null){
throw new AppException("制证时间不能为空");
}
if(StringUtils.isEmpty(entity.getLegalPerson())){
throw new AppException("法定代表人不能为空");
}
if(StringUtils.isEmpty(entity.getBusinessPlace())){
throw new AppException("经营场所不能为空");
}
if(StringUtils.isEmpty(entity.getAuthority())){
throw new AppException("制证机关不能为空");
}
if(StringUtils.isEmpty(entity.getSocialCode())){
throw new AppException("统一社会信用代码不能为空");
}
if(StringUtils.isEmpty(entity.getLicenseProject())){
throw new AppException("许可项目不能为空");
}
// if(StringUtils.isEmpty(entity.getCertificateCode())){
// throw new AppException("许可证编号不能为空");
// }
// if(entity.getIssueTime()==null){
// throw new AppException("制证时间不能为空");
// }
// if(StringUtils.isEmpty(entity.getLegalPerson())){
// throw new AppException("法定代表人不能为空");
// }
// if(StringUtils.isEmpty(entity.getBusinessPlace())){
// throw new AppException("经营场所不能为空");
// }
// if(StringUtils.isEmpty(entity.getAuthority())){
// throw new AppException("制证机关不能为空");
// }
// if(StringUtils.isEmpty(entity.getSocialCode())){
// throw new AppException("统一社会信用代码不能为空");
// }
// if(StringUtils.isEmpty(entity.getLicenseProject())){
// throw new AppException("许可项目不能为空");
// }
if(StringUtils.isEmpty(entity.getEnterpriseName())){
throw new AppException("市场主体名称不能为空");
}
if(StringUtils.isEmpty(entity.getIndustryName())){
throw new AppException("行业名称不能为空");
}
// if(StringUtils.isEmpty(entity.getIndustryName())){
// throw new AppException("行业名称不能为空");
// }
if(entity.getCatalogId()==null){
throw new AppException("目录ID不能为空");
}
......@@ -183,15 +204,21 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
private void createFormContent(ApplyLogEntity applyLogEntity){
JSONObject formContentJson = new JSONObject();
formContentJson.put("i_1_市场主体名称",applyLogEntity.getEnterpriseName());
formContentJson.put("i_2_许可证编号",applyLogEntity.getCertificateCode());
formContentJson.put("i_3_统一社会信用代码",applyLogEntity.getSocialCode());
formContentJson.put(" i_5_法定代表人(负责人)",applyLogEntity.getLegalPerson());
formContentJson.put("i_8_经营场所",applyLogEntity.getBusinessPlace());
formContentJson.put("i_9_行业类别",applyLogEntity.getIndustryName());
formContentJson.put("i_10_许可项目",applyLogEntity.getLicenseProject());
formContentJson.put("i_11_制证日期", DateUtils.getStrDate(applyLogEntity.getIssueTime()));
formContentJson.put("i_14_制证机关",applyLogEntity.getAuthority());
// formContentJson.put("i_2_许可证编号",applyLogEntity.getCertificateCode());
// formContentJson.put("i_3_统一社会信用代码",applyLogEntity.getSocialCode());
// formContentJson.put(" i_5_法定代表人(负责人)",applyLogEntity.getLegalPerson());
// formContentJson.put("i_8_经营场所",applyLogEntity.getBusinessPlace());
// formContentJson.put("i_9_行业类别",applyLogEntity.getIndustryName());
// formContentJson.put("i_10_许可项目",applyLogEntity.getLicenseProject());
// formContentJson.put("i_11_制证日期", DateUtils.getStrDate(applyLogEntity.getIssueTime()));
// formContentJson.put("i_14_制证机关",applyLogEntity.getAuthority());
formContentJson.put("@qrcode_1_二维码",applyLogEntity.getSocialCode());
if(CollectionUtils.isNotEmpty(applyLogEntity.getChildCertificate())){
for(int i = 0;i<applyLogEntity.getChildCertificate().size();i++){
int index = i+1;
formContentJson.put("i_"+ index +"_子证",applyLogEntity.getChildCertificate().get(i).getShortName());
}
}
applyLogEntity.setFormContent(formContentJson.toJSONString());
}
......@@ -280,7 +307,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
printWaitQueueService.remove(condition,context);
}
//插入子证联报
childLicenseService.createChildLicense(applyLogEntity,context);
childLicenseService.createChildLicense(applyLogEntity,oldId,context);
printWaitQueueService.creatWaitQueueByApply(applyLogEntity, GenerateStatus.ORIGINAL.getValue(),context);
applyLogEntity.setFormContent(null);
applyLogEntity.setFormTemplate(null);
......@@ -379,7 +406,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
printWaitQueueService.remove(condition,context);
}
//插入子证联报
childLicenseService.createChildLicense(applyLogEntity,context);
childLicenseService.createChildLicense(applyLogEntity,oldId,context);
printWaitQueueService.creatWaitQueueByApply(applyLogEntity, GenerateStatus.ORIGINAL.getValue(),context);
}
......@@ -639,7 +666,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
public ApplyLogEntity getBySocialCode(String socialCode) throws AppException {
ApplyLogEntity entity = this.selectOne(new ApplyLogQuery().socialCode(socialCode));
if(entity!=null){
List<ChildLicenseEntity> childs = childLicenseService.find(new ChildLicenseQuery().applyId(entity.getId()).processStatus(ProcessStatusEnum.已处理.getValue()));
List<ChildLicenseEntity> childs = childLicenseService.find(new ChildLicenseQuery().applyId(entity.getId()).processStatus(ProcessStatusEnum.已处理.getValue()).childStatus(StatusEnum.ENABLE.getValue()));
entity.setChildLicense(childs);
}
return entity;
......
......@@ -2,6 +2,8 @@ package com.mortals.xhx.module.record.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BaseEntity;
import com.mortals.framework.utils.ReflectUtils;
import com.mortals.framework.utils.poi.ExcelUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
......@@ -10,7 +12,12 @@ import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.utils.ImportExcelUtil;
import com.mortals.xhx.common.utils.ReadExcelPictureUtil;
import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity;
import com.mortals.xhx.module.certificate.model.CertificateDocumentQuery;
import com.mortals.xhx.module.certificate.model.vo.CertificateDocumentPdu;
import com.mortals.xhx.module.certificate.service.CertificateDocumentService;
import org.apache.poi.ss.usermodel.PictureData;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
......@@ -25,12 +32,10 @@ import com.mortals.xhx.module.record.model.ApplyLogEntity;
import com.mortals.xhx.module.record.service.ApplyLogService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
......@@ -48,6 +53,9 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL
@Value("${upload.path}")
private String filePath;
@Autowired
private CertificateDocumentService certificateDocumentService;
public ApplyLogController(){
super.setModuleDesc( "证照申请");
}
......@@ -196,4 +204,44 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL
return ret.toJSONString();
}
}
@PostMapping(value = "addInit")
@UnAuth
public String add(@RequestBody ApplyLogEntity params) {
Map<String, Object> model = new HashMap();
int code = 1;
Context context = this.getContext();
String busiDesc = "打开新增" + this.getModuleDesc() + "页面";
try {
this.addBefore(model);
ApplyLogEntity entity = new ApplyLogEntity();
entity.initAttrValue();
List<CertificateDocumentEntity> certificateDocumentEntityList = certificateDocumentService.getListByCatalogId(params.getCatalogId());
List<CertificateDocumentPdu> documentEntityList = new ArrayList<>();
for(CertificateDocumentEntity item:certificateDocumentEntityList){
CertificateDocumentPdu pdu = new CertificateDocumentPdu();
BeanUtils.copyProperties(item, pdu);
documentEntityList.add(pdu);
}
entity.setChildCertificate(documentEntityList);
model.put("entity", entity);
this.addAfter(model);
if (!ObjectUtils.isEmpty(context) && !ObjectUtils.isEmpty(context.getUser())) {
this.recordSysLog(this.request, busiDesc + " 【成功】");
}
} catch (Exception var7) {
code = -1;
this.doException(this.request, busiDesc, model, var7);
}
this.init(model, context);
JSONObject ret = new JSONObject();
ret.put("code", Integer.valueOf(code));
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
}
\ No newline at end of file
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