renqianlong 1 anno fa
parent
commit
5f826dff77

+ 1 - 1
zhongzheng-admin-business/src/main/java/com/zhongzheng/controller/company/CompanyCertificateController.java

@@ -112,6 +112,6 @@ public class CompanyCertificateController extends BaseController {
     @PostMapping("/importCertificateList")
     public AjaxResult<Void> importDataBackList(ExcelCompanyCertificateBo bo) throws Exception
     {
-        return toAjax(iCompanyCertificateService.importCertificateExcel(bo)? 1 : 0);
+        return AjaxResult.success(iCompanyCertificateService.importCertificateExcel(bo));
     }
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/company/service/ICompanyCertificateService.java

@@ -54,5 +54,5 @@ public interface ICompanyCertificateService extends IService<CompanyCertificate>
 	 * @param file 主键集合
 	 * @return
 	 */
-	Boolean importCertificateExcel(ExcelCompanyCertificateBo bo);
+	String importCertificateExcel(ExcelCompanyCertificateBo bo);
 }

+ 143 - 119
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/company/service/impl/CompanyCertificateServiceImpl.java

@@ -24,6 +24,7 @@ import com.zhongzheng.modules.bs.company.domain.CompanyCertificate;
 import com.zhongzheng.modules.bs.company.mapper.CompanyCertificateMapper;
 import com.zhongzheng.modules.bs.company.vo.CompanyCertificateVo;
 import com.zhongzheng.modules.bs.company.service.ICompanyCertificateService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -312,8 +313,9 @@ public class CompanyCertificateServiceImpl extends ServiceImpl<CompanyCertificat
         return null;
     }
 
+    @Transactional
     @Override
-    public Boolean importCertificateExcel(ExcelCompanyCertificateBo bo) {
+    public String importCertificateExcel(ExcelCompanyCertificateBo bo) {
         if (bo.getCertificateType() == null) {
             throw new CustomException("企业证书类型为空");
         }
@@ -321,6 +323,7 @@ public class CompanyCertificateServiceImpl extends ServiceImpl<CompanyCertificat
         if (ObjectUtil.isEmpty(companyCertificateVos)) {
             throw new CustomException("文档数据为空");
         }
+        List<Company> errorCompanies = new ArrayList<>();
         ExcelCompanyCertificateVo vo = new ExcelCompanyCertificateVo();
         //判断不同证书类型 1:营业执照 2:资质证书 3:安全生产许可证 4:其他证书
         switch (bo.getCertificateType()) {
@@ -328,40 +331,44 @@ public class CompanyCertificateServiceImpl extends ServiceImpl<CompanyCertificat
                 companyCertificateVos.forEach(item -> {
                     if (ObjectUtil.isAllNotEmpty(item.getCompanyName(), item.getDocumentTypeName())) {
                         List<Company> companyList = iCompanyService.list(new LambdaQueryWrapper<Company>().eq(Company::getCompanyName, item.getCompanyName()).eq(Company::getStatus, 1));
-                        if (ObjectUtil.isNotEmpty(companyList)) {
-                            Company company = companyList.get(0);
-                            CompanyCertificate companyCertificate = new CompanyCertificate();
-                            companyCertificate.setCertificateType(bo.getCertificateType());
-                            companyCertificate.setCompanyId(company.getCompanyId());
-                            companyCertificate.setCompanyName(item.getCompanyName());
-                            Integer documentTypeByName = getDocumentTypeByName(item.getDocumentTypeName());
-                            companyCertificate.setDocumentType(documentTypeByName);
-                            Integer companyType = getCompanyTypeByName(item.getCompanyTypeName());
-                            companyCertificate.setCompanyType(Long.valueOf(companyType));
-                            if (ObjectUtil.isNotEmpty(item.getEstablishDateName())) {
-                                String establishDateName = item.getEstablishDateName();
-                                Long dateTimeSec = DateUtils.dateTimeSec("yyyy/MM/dd", establishDateName);
-                                companyCertificate.setEstablishDate(dateTimeSec);
-                            }
-                            if (ObjectUtil.isNotEmpty(item.getOperateDateName())) {
-                                if (item.getOperateDateName().equals("长期")) {
-                                    companyCertificate.setOperateFlag(1);
-                                } else {
-                                    String operateDateName = item.getOperateDateName();
-                                    Long operateDate = DateUtils.dateTimeSec("yyyy/MM/dd", operateDateName);
-                                    companyCertificate.setEstablishDate(operateDate);
+                        try {
+                            if (ObjectUtil.isNotEmpty(companyList)) {
+                                Company company = companyList.get(0);
+                                CompanyCertificate companyCertificate = new CompanyCertificate();
+                                companyCertificate.setCertificateType(bo.getCertificateType());
+                                companyCertificate.setCompanyId(company.getCompanyId());
+                                companyCertificate.setCompanyName(item.getCompanyName());
+                                Integer documentTypeByName = getDocumentTypeByName(item.getDocumentTypeName());
+                                companyCertificate.setDocumentType(documentTypeByName);
+                                Integer companyType = getCompanyTypeByName(item.getCompanyTypeName());
+                                companyCertificate.setCompanyType(Long.valueOf(companyType));
+                                if (ObjectUtil.isNotEmpty(item.getEstablishDateName())) {
+                                    String establishDateName = item.getEstablishDateName();
+                                    Long dateTimeSec = DateUtils.dateTimeSec("yyyy/MM/dd", establishDateName);
+                                    companyCertificate.setEstablishDate(dateTimeSec);
+                                }
+                                if (ObjectUtil.isNotEmpty(item.getOperateDateName())) {
+                                    if (item.getOperateDateName().equals("长期")) {
+                                        companyCertificate.setOperateFlag(1);
+                                    } else {
+                                        String operateDateName = item.getOperateDateName();
+                                        Long operateDate = DateUtils.dateTimeSec("yyyy/MM/dd", operateDateName);
+                                        companyCertificate.setEstablishDate(operateDate);
+                                    }
                                 }
+                                companyCertificate.setCreditCode(item.getCreditCode());
+                                companyCertificate.setRegisteredCapital(item.getRegisteredCapital());
+                                companyCertificate.setLegalRepresentative(item.getLegalRepresentative());
+                                companyCertificate.setCompanyAddress(item.getCompanyAddress());
+                                companyCertificate.setRegistrationAuthority(item.getRegistrationAuthority());
+                                companyCertificate.setExperienceScope(item.getExperienceScope());
+                                companyCertificate.setCreateTime(DateUtils.getNowTime());
+                                companyCertificate.setUpdateTime(DateUtils.getNowTime());
+                                this.baseMapper.insert(companyCertificate);
                             }
-                            companyCertificate.setCreditCode(item.getCreditCode());
-                            companyCertificate.setRegisteredCapital(item.getRegisteredCapital());
-                            companyCertificate.setLegalRepresentative(item.getLegalRepresentative());
-                            companyCertificate.setCompanyAddress(item.getCompanyAddress());
-                            companyCertificate.setRegistrationAuthority(item.getRegistrationAuthority());
-                            companyCertificate.setExperienceScope(item.getExperienceScope());
-                            companyCertificate.setCreateTime(DateUtils.getNowTime());
-                            companyCertificate.setUpdateTime(DateUtils.getNowTime());
-                            int insert = this.baseMapper.insert(companyCertificate);
-                            vo.setSaveStatus(insert);
+                            errorCompanies.addAll(companyList);
+                        }catch (Exception e){
+                            throw new CustomException("存在错误公司名称");
                         }
                     }
                 });
@@ -409,44 +416,11 @@ public class CompanyCertificateServiceImpl extends ServiceImpl<CompanyCertificat
                 ExcelCompanyCertificateVo excelCompanyCertificateVo = certificateVos.get(0);
                 if (ObjectUtil.isAllNotEmpty(excelCompanyCertificateVo.getCompanyName(), excelCompanyCertificateVo.getDocumentTypeName())) {
                     List<Company> companyList = iCompanyService.list(new LambdaQueryWrapper<Company>().eq(Company::getCompanyName, excelCompanyCertificateVo.getCompanyName()).eq(Company::getStatus, 1));
-                    if (ObjectUtil.isNotEmpty(companyList)) {
-                        Company company = companyList.get(0);
-                        CompanyCertificate companyCertificate = new CompanyCertificate();
-                        companyCertificate.setCertificateType(bo.getCertificateType());
-                        companyCertificate.setCompanyId(company.getCompanyId());
-                        companyCertificate.setCompanyName(company.getCompanyName());
-                        companyCertificate.setCreditCode(company.getCreditCode());
-                        companyCertificate.setCompanyType(company.getCompanyType());
-                        companyCertificate.setRegisteredCapital(company.getRegisteredCapital());
-                        companyCertificate.setLegalRepresentative(company.getLegalRepresentative());
-                        companyCertificate.setCompanyAddress(company.getCompanyAddress());
-                        companyCertificate.setEstablishDate(company.getEstablishDate());
-                        companyCertificate.setOperateDate(company.getOperateDate());
-                        companyCertificate.setRegistrationAuthority(company.getRegistrationAuthority());
-                        companyCertificate.setEffectiveFlag(excelCompanyCertificateVo.getEffectiveFlag());
-                        companyCertificate.setExperienceScope(company.getExperienceScope());
-                        companyCertificate.setCertificateName(excelCompanyCertificateVo.getCertificateName());
-                        companyCertificate.setText(excelCompanyCertificateVo.getText());
-                        companyCertificate.setCertificateNumber(excelCompanyCertificateVo.getCertificateNumber());
-                        companyCertificate.setIssuanceDate(excelCompanyCertificateVo.getIssuanceDate());
-                        companyCertificate.setEffectiveDate(excelCompanyCertificateVo.getEffectiveDate());
-                        companyCertificate.setIssuingAuthority(excelCompanyCertificateVo.getIssuingAuthority());
-                        companyCertificate.setCreateTime(DateUtils.getNowTime());
-                        companyCertificate.setUpdateTime(DateUtils.getNowTime());
-                        vo.setSaveStatus(this.baseMapper.insert(companyCertificate));
-                    }
-                }
-                break;
-            case 3:
-                companyCertificateVos.forEach(item -> {
-                    if (ObjectUtil.isAllNotEmpty(item.getCompanyName(), item.getCertificateNumber())) {
-                        List<Company> companyList = iCompanyService.list(new LambdaQueryWrapper<Company>().eq(Company::getCompanyName, item.getCompanyName()).eq(Company::getStatus, 1));
+                    try{
                         if (ObjectUtil.isNotEmpty(companyList)) {
                             Company company = companyList.get(0);
                             CompanyCertificate companyCertificate = new CompanyCertificate();
                             companyCertificate.setCertificateType(bo.getCertificateType());
-                            companyCertificate.setCompanyName(item.getCompanyName());
-                            companyCertificate.setCertificateNumber(item.getCertificateNumber());
                             companyCertificate.setCompanyId(company.getCompanyId());
                             companyCertificate.setCompanyName(company.getCompanyName());
                             companyCertificate.setCreditCode(company.getCreditCode());
@@ -457,26 +431,70 @@ public class CompanyCertificateServiceImpl extends ServiceImpl<CompanyCertificat
                             companyCertificate.setEstablishDate(company.getEstablishDate());
                             companyCertificate.setOperateDate(company.getOperateDate());
                             companyCertificate.setRegistrationAuthority(company.getRegistrationAuthority());
+                            companyCertificate.setEffectiveFlag(excelCompanyCertificateVo.getEffectiveFlag());
                             companyCertificate.setExperienceScope(company.getExperienceScope());
-                            if (ObjectUtil.isNotEmpty(item.getIssuanceDateName())) {
-                                String issuanceDateName = item.getIssuanceDateName();
-                                Long dateTimeSec = DateUtils.dateTimeSec("yyyy/MM/dd", issuanceDateName);
-                                companyCertificate.setIssuanceDate(dateTimeSec);
-                            }
-                            if (ObjectUtil.isNotEmpty(item.getEffectiveDateName())) {
-                                if (item.getEffectiveDateName().equals("长期")) {
-                                    companyCertificate.setEffectiveFlag(1);
-                                } else {
-                                    String effectiveDateName = item.getEffectiveDateName();
-                                    Long operateDate = DateUtils.dateTimeSec("yyyy/MM/dd", effectiveDateName);
-                                    companyCertificate.setEffectiveDate(operateDate);
-                                }
-                            }
-                            companyCertificate.setIssuingAuthority(item.getIssuingAuthority());
+                            companyCertificate.setCertificateName(excelCompanyCertificateVo.getCertificateName());
+                            companyCertificate.setText(excelCompanyCertificateVo.getText());
+                            companyCertificate.setCertificateNumber(excelCompanyCertificateVo.getCertificateNumber());
+                            companyCertificate.setIssuanceDate(excelCompanyCertificateVo.getIssuanceDate());
+                            companyCertificate.setEffectiveDate(excelCompanyCertificateVo.getEffectiveDate());
+                            companyCertificate.setIssuingAuthority(excelCompanyCertificateVo.getIssuingAuthority());
                             companyCertificate.setCreateTime(DateUtils.getNowTime());
                             companyCertificate.setUpdateTime(DateUtils.getNowTime());
-                            vo.setSaveStatus(this.baseMapper.insert(companyCertificate));
+                            this.baseMapper.insert(companyCertificate);
                         }
+                        errorCompanies.addAll(companyList);
+                    }catch (Exception e){
+                        throw new CustomException("存在错误公司名称");
+                    }
+                }
+                break;
+            case 3:
+                companyCertificateVos.forEach(item -> {
+                    if (ObjectUtil.isAllNotEmpty(item.getCompanyName(), item.getCertificateNumber())) {
+                        List<Company> companyList = iCompanyService.list(new LambdaQueryWrapper<Company>().eq(Company::getCompanyName, item.getCompanyName()).eq(Company::getStatus, 1));
+                        try{
+                            if (ObjectUtil.isNotEmpty(companyList)) {
+                                Company company = companyList.get(0);
+                                CompanyCertificate companyCertificate = new CompanyCertificate();
+                                companyCertificate.setCertificateType(bo.getCertificateType());
+                                companyCertificate.setCompanyName(item.getCompanyName());
+                                companyCertificate.setCertificateNumber(item.getCertificateNumber());
+                                companyCertificate.setCompanyId(company.getCompanyId());
+                                companyCertificate.setCompanyName(company.getCompanyName());
+                                companyCertificate.setCreditCode(company.getCreditCode());
+                                companyCertificate.setCompanyType(company.getCompanyType());
+                                companyCertificate.setRegisteredCapital(company.getRegisteredCapital());
+                                companyCertificate.setLegalRepresentative(company.getLegalRepresentative());
+                                companyCertificate.setCompanyAddress(company.getCompanyAddress());
+                                companyCertificate.setEstablishDate(company.getEstablishDate());
+                                companyCertificate.setOperateDate(company.getOperateDate());
+                                companyCertificate.setRegistrationAuthority(company.getRegistrationAuthority());
+                                companyCertificate.setExperienceScope(company.getExperienceScope());
+                                if (ObjectUtil.isNotEmpty(item.getIssuanceDateName())) {
+                                    String issuanceDateName = item.getIssuanceDateName();
+                                    Long dateTimeSec = DateUtils.dateTimeSec("yyyy/MM/dd", issuanceDateName);
+                                    companyCertificate.setIssuanceDate(dateTimeSec);
+                                }
+                                if (ObjectUtil.isNotEmpty(item.getEffectiveDateName())) {
+                                    if (item.getEffectiveDateName().equals("长期")) {
+                                        companyCertificate.setEffectiveFlag(1);
+                                    } else {
+                                        String effectiveDateName = item.getEffectiveDateName();
+                                        Long operateDate = DateUtils.dateTimeSec("yyyy/MM/dd", effectiveDateName);
+                                        companyCertificate.setEffectiveDate(operateDate);
+                                    }
+                                }
+                                companyCertificate.setIssuingAuthority(item.getIssuingAuthority());
+                                companyCertificate.setCreateTime(DateUtils.getNowTime());
+                                companyCertificate.setUpdateTime(DateUtils.getNowTime());
+                                this.baseMapper.insert(companyCertificate);
+                            }
+                            errorCompanies.addAll(companyList);
+                        }catch (Exception e){
+                            throw new CustomException("存在错误公司名称");
+                        }
+
                     }
                 });
                 break;
@@ -484,49 +502,55 @@ public class CompanyCertificateServiceImpl extends ServiceImpl<CompanyCertificat
                 companyCertificateVos.forEach(item -> {
                     if (ObjectUtil.isAllNotEmpty(item.getCompanyName(), item.getCertificateNumber())) {
                         List<Company> companyList = iCompanyService.list(new LambdaQueryWrapper<Company>().eq(Company::getCompanyName, item.getCompanyName()).eq(Company::getStatus, 1));
-                        if (ObjectUtil.isNotEmpty(companyList)) {
-                            Company company = companyList.get(0);
-                            CompanyCertificate companyCertificate = new CompanyCertificate();
-                            companyCertificate.setCertificateType(bo.getCertificateType());
-                            companyCertificate.setCompanyId(company.getCompanyId());
-                            companyCertificate.setCompanyName(company.getCompanyName());
-                            companyCertificate.setCreditCode(company.getCreditCode());
-                            companyCertificate.setCompanyType(company.getCompanyType());
-                            companyCertificate.setRegisteredCapital(company.getRegisteredCapital());
-                            companyCertificate.setLegalRepresentative(company.getLegalRepresentative());
-                            companyCertificate.setCompanyAddress(company.getCompanyAddress());
-                            companyCertificate.setEstablishDate(company.getEstablishDate());
-                            companyCertificate.setOperateDate(company.getOperateDate());
-                            companyCertificate.setRegistrationAuthority(company.getRegistrationAuthority());
-                            companyCertificate.setExperienceScope(company.getExperienceScope());
-                            companyCertificate.setCertificateName(item.getCertificateName());
-                            if (ObjectUtil.isNotEmpty(item.getIssuanceDateName())) {
-                                String issuanceDateName = item.getIssuanceDateName();
-                                Long dateTimeSec = DateUtils.dateTimeSec("yyyy/MM/dd", issuanceDateName);
-                                companyCertificate.setIssuanceDate(dateTimeSec);
-                            }
-                            if (ObjectUtil.isNotEmpty(item.getEffectiveDateName())) {
-                                if (item.getEffectiveDateName().equals("长期")) {
-                                    companyCertificate.setEffectiveFlag(1);
-                                } else {
-                                    String effectiveDateName = item.getEffectiveDateName();
-                                    Long operateDate = DateUtils.dateTimeSec("yyyy/MM/dd", effectiveDateName);
-                                    companyCertificate.setEffectiveDate(operateDate);
+                        try {
+                            if (ObjectUtil.isNotEmpty(companyList)) {
+                                Company company = companyList.get(0);
+                                CompanyCertificate companyCertificate = new CompanyCertificate();
+                                companyCertificate.setCertificateType(bo.getCertificateType());
+                                companyCertificate.setCompanyId(company.getCompanyId());
+                                companyCertificate.setCompanyName(company.getCompanyName());
+                                companyCertificate.setCreditCode(company.getCreditCode());
+                                companyCertificate.setCompanyType(company.getCompanyType());
+                                companyCertificate.setRegisteredCapital(company.getRegisteredCapital());
+                                companyCertificate.setLegalRepresentative(company.getLegalRepresentative());
+                                companyCertificate.setCompanyAddress(company.getCompanyAddress());
+                                companyCertificate.setEstablishDate(company.getEstablishDate());
+                                companyCertificate.setOperateDate(company.getOperateDate());
+                                companyCertificate.setRegistrationAuthority(company.getRegistrationAuthority());
+                                companyCertificate.setExperienceScope(company.getExperienceScope());
+                                companyCertificate.setCertificateName(item.getCertificateName());
+                                if (ObjectUtil.isNotEmpty(item.getIssuanceDateName())) {
+                                    String issuanceDateName = item.getIssuanceDateName();
+                                    Long dateTimeSec = DateUtils.dateTimeSec("yyyy/MM/dd", issuanceDateName);
+                                    companyCertificate.setIssuanceDate(dateTimeSec);
+                                }
+                                if (ObjectUtil.isNotEmpty(item.getEffectiveDateName())) {
+                                    if (item.getEffectiveDateName().equals("长期")) {
+                                        companyCertificate.setEffectiveFlag(1);
+                                    } else {
+                                        String effectiveDateName = item.getEffectiveDateName();
+                                        Long operateDate = DateUtils.dateTimeSec("yyyy/MM/dd", effectiveDateName);
+                                        companyCertificate.setEffectiveDate(operateDate);
+                                    }
                                 }
+                                companyCertificate.setIssuingAuthority(item.getIssuingAuthority());
+                                companyCertificate.setCreateTime(DateUtils.getNowTime());
+                                companyCertificate.setUpdateTime(DateUtils.getNowTime());
+                                this.baseMapper.insert(companyCertificate);
                             }
-                            companyCertificate.setIssuingAuthority(item.getIssuingAuthority());
-                            companyCertificate.setCreateTime(DateUtils.getNowTime());
-                            companyCertificate.setUpdateTime(DateUtils.getNowTime());
-                            vo.setSaveStatus(this.baseMapper.insert(companyCertificate));
+                            errorCompanies.addAll(companyList);
+                        }catch (Exception e){
+                            throw new CustomException("存在错误公司名称");
                         }
+
                     }
                 });
                 break;
         }
-        if (vo.getSaveStatus() == 1) {
-            return true;
-        } else {
-            return false;
+        if (!errorCompanies.isEmpty()){
+            return "false";
+        }else {
+            return "true";
         }
     }
 }