|
@@ -3,15 +3,15 @@ package com.pavis.app.saasbacken.service.impl.base;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
|
|
+import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pavis.app.saasbacken.common.IgnoreUtils;
|
|
|
import com.pavis.app.saasbacken.dao.EnterpriseBasicInfoMapper;
|
|
|
-import com.pavis.app.saasbacken.entity.EnterpriseBasicInfo;
|
|
|
-import com.pavis.app.saasbacken.entity.EnterpriseOtherInfo;
|
|
|
-import com.pavis.app.saasbacken.entity.ResourceLibrary;
|
|
|
-import com.pavis.app.saasbacken.entity.TaxInfo;
|
|
|
+import com.pavis.app.saasbacken.entity.*;
|
|
|
import com.pavis.app.saasbacken.form.OrgInfo;
|
|
|
import com.pavis.app.saasbacken.service.*;
|
|
|
+import com.pavis.app.saasbacken.utils.CommonUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -57,6 +57,138 @@ public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicI
|
|
|
@Autowired
|
|
|
private TaxInfoService taxInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrgRelPersonalService orgRelPersonalService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<EnterpriseBasicInfo> basicAdd(List<Object> basicInfo) throws IOException {
|
|
|
+ List<OrgInfo> basicInfos = JSONObject.parseArray(JSONObject.toJSONString(basicInfo), OrgInfo.class);
|
|
|
+
|
|
|
+ // 企业基本信息。
|
|
|
+ List<EnterpriseBasicInfo> addBasicInfos = new ArrayList<>();
|
|
|
+ EnterpriseBasicInfo addBasicInfo;
|
|
|
+
|
|
|
+ // 企业其他信息。
|
|
|
+ List<EnterpriseOtherInfo> addOtherInfos = new ArrayList<>();
|
|
|
+ EnterpriseOtherInfo addOtherInfo;
|
|
|
+
|
|
|
+ // 企业税务数据。
|
|
|
+ List<TaxInfo> addTaxInfos = new ArrayList<>();
|
|
|
+
|
|
|
+ // 人员信息。
|
|
|
+ List<PersonalInfo> addPersonalInfos = new ArrayList<>();
|
|
|
+
|
|
|
+ // 企业与人员关联关系。
|
|
|
+ List<OrgRelPersonal> addOrgRelPersonals = new ArrayList<>();
|
|
|
+
|
|
|
+ for (OrgInfo info : basicInfos) {
|
|
|
+ // 根据企业id是否为空判断企业信息是否已存在,决定是新增还是更新。
|
|
|
+ if (null == info.getId() || StringUtils.isEmpty(info.getId())){
|
|
|
+ // 自动生成主键id。
|
|
|
+ String id = CommonUtils.initId();
|
|
|
+ info.setId(id);
|
|
|
+ log.info("企业基本信息不存在,手动生成主键id:{}",id);
|
|
|
+ // 企业没有主键id,根据社会统一信用代码检索数据库中是否已存在企业基本信息。
|
|
|
+ List<EnterpriseBasicInfo> selectBasicLists = enterpriseBasicInfoMapper.selectList(new QueryWrapper<EnterpriseBasicInfo>().lambda()
|
|
|
+ .eq(EnterpriseBasicInfo::getUnifySocialCreditCode, info.getUnifySocialCreditCode()));
|
|
|
+ if (selectBasicLists.size() > 0) {
|
|
|
+ // 企业基本信息已存在,设置info的主键id值为已存在的企业基本信息的主键id。
|
|
|
+ log.info("企业基本信息已存在,获取主键id:{}",selectBasicLists.get(0).getId());
|
|
|
+ info.setId(selectBasicLists.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化企业基本信息。
|
|
|
+ addBasicInfo = new EnterpriseBasicInfo();
|
|
|
+ IgnoreUtils.copyPropertiesIgnoreNull(info, addBasicInfo);
|
|
|
+
|
|
|
+ // 企业其他信息。
|
|
|
+ addOtherInfo = new EnterpriseOtherInfo();
|
|
|
+ IgnoreUtils.copyPropertiesIgnoreNull(info, addOtherInfo);
|
|
|
+ addOtherInfo.setEnterpriseId(info.getId());
|
|
|
+ addOtherInfos.add(addOtherInfo);
|
|
|
+
|
|
|
+ // 企业税务数据。
|
|
|
+ addTaxInfos.add(TaxInfo.builder().enterpriseId(info.getId()).taxYear(info.getNearlyThree()).annualRevenue(info.getAnnualRevenueThree()).rdDeductible(info.getRdDeductibleThree()).build());
|
|
|
+ addTaxInfos.add(TaxInfo.builder().enterpriseId(info.getId()).taxYear(info.getNearlyTwo()).annualRevenue(info.getAnnualRevenueTwo()).rdDeductible(info.getRdDeductibleTwo()).build());
|
|
|
+ addTaxInfos.add(TaxInfo.builder().enterpriseId(info.getId()).taxYear(info.getNearlyOne()).annualRevenue(info.getAnnualRevenueOne()).rdDeductible(info.getRdDeductibleOne()).build());
|
|
|
+
|
|
|
+ // 企业人员信息。
|
|
|
+ addPersonalInfos = personalInfoService.dealPersonInfo(basicInfos);
|
|
|
+ // 企业人员关联关系。
|
|
|
+ addOrgRelPersonals = orgRelPersonalService.dealOrgRel(basicInfos, addPersonalInfos);
|
|
|
+
|
|
|
+ // 各种字段处理。
|
|
|
+ // 所属行业 需要单独处理,做一下转换后进行存储。
|
|
|
+ addBasicInfo.setIndustry(categoryService.dealCategory(info.getIndustry(), true));
|
|
|
+ // 企业类型:国有企业 集体所有制企业 私营企业 股份制企业 联营企业 外商投资企业 港澳台企业 股份合作企业 有限责任公司 其他企业。
|
|
|
+ addBasicInfo.setEnterpriseType(categoryService.dealCategory(info.getEnterpriseType(), true));
|
|
|
+ // 机构类型:企业 高校 机构 园区 政府 其他。
|
|
|
+ addBasicInfo.setResType(categoryService.dealCategory(info.getResType(), true));
|
|
|
+ // 研发机构等级:国家级、省级、市级、区级等。
|
|
|
+ addBasicInfo.setDevOrgLevel(categoryService.dealCategory(info.getDevOrgLevel(), true));
|
|
|
+ // 是否规上: 前端传0 否 或 1 是。
|
|
|
+ // addBasicInfo.setIsGauge("");
|
|
|
+ // 企业资质:国高、市高、省科技型中小企业、高企培育、规上、科技型初创企业、高新潜力企业、创新引领企业。
|
|
|
+ addBasicInfo.setQualifyInfo(categoryService.dealCategory(info.getQualifyInfo(), true));
|
|
|
+
|
|
|
+ // todo 需要保存企业信息,再处理人员信息。
|
|
|
+
|
|
|
+ // todo 企业负责人/法人信息关联id,需要将联系人信息新增至人员信息表。同时应该配置至企业与人员信息关联关系表。
|
|
|
+ addBasicInfo.setChargeDirectorId("");
|
|
|
+ // 企业联系人
|
|
|
+ addBasicInfo.setContactsId("");
|
|
|
+ // 研发负责人信息关联id
|
|
|
+ addBasicInfo.setResearchDevDirectorId("");
|
|
|
+ // 财务负责人信息关联id
|
|
|
+ addBasicInfo.setFinancialDirectorId("");
|
|
|
+ // 科技联络人信息关联id
|
|
|
+ addBasicInfo.setTechnicalDirectorId("");
|
|
|
+ // todo 还要考虑到企业库的其他信息的录入,主要包含了高企管理相关录入信息。
|
|
|
+ // 行业领域也由节点管理员进行配置。
|
|
|
+ addBasicInfos.add(addBasicInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+ // 批量新增或更新企业基本信息。
|
|
|
+ boolean basic = saveOrUpdateBatch(addBasicInfos);
|
|
|
+ log.info("save-or-update basic res:{}",basic);
|
|
|
+
|
|
|
+ // 批量新增或更新税务信息。
|
|
|
+ boolean tax = taxInfoService.saveOrUpdateBatch(addTaxInfos);
|
|
|
+ log.info("save-update tax res:{}",tax);
|
|
|
+
|
|
|
+ // 批量新增或更新企业其他信息。
|
|
|
+ boolean other = enterpriseOtherInfoService.dealOtherInfos(addOtherInfos);
|
|
|
+ log.info("save-update other res:{}", other);
|
|
|
+
|
|
|
+ // 批量新增或更新人企业人员信息。
|
|
|
+ boolean personal = personalInfoService.saveOrUpdateBatch(addPersonalInfos);
|
|
|
+ log.info("save-update personal res:{}", personal);
|
|
|
+ boolean orgRel = orgRelPersonalService.saveOrUpdateBatch(addOrgRelPersonals);
|
|
|
+ log.info("save-update orgRel res:{}", orgRel);
|
|
|
+
|
|
|
+ // 同步基本信息、其他信息至es库。
|
|
|
+ List<ResourceLibrary> basicResourceLibraries = resourceLibraryService.dealBasicResourceLib(addBasicInfos,addTaxInfos);
|
|
|
+ boolean b3 = resourceLibraryService.saveOrUpdateBatch(basicResourceLibraries);
|
|
|
+ log.info("save-or-update resourcelib-basic-data res:{}",b3);
|
|
|
+ List<ResourceLibrary> otherResourceLibraries = resourceLibraryService.dealOtherResourceLib(addOtherInfos);
|
|
|
+ boolean b4 = resourceLibraryService.saveOrUpdateBatch(otherResourceLibraries);
|
|
|
+ log.info("save-or-update resourcelib-other-data res:{}",b4);
|
|
|
+
|
|
|
+ List<ResourceLibrary> resourceLibraries = new ArrayList<>();
|
|
|
+ for (EnterpriseBasicInfo info : addBasicInfos) {
|
|
|
+ List<ResourceLibrary> resourceLibs = resourceLibraryService.selByUniqueId(info.getId());
|
|
|
+ if (resourceLibs.size() > 0){
|
|
|
+ resourceLibraries.add(resourceLibs.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步信息至es库。
|
|
|
+ esService.saveResourceLibsToEs(resourceLibraries);
|
|
|
+
|
|
|
+ return esService.selEsByName(addBasicInfos.get(0).getName());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<EnterpriseBasicInfo> orgBasicAdd(List<Object> basicInfo) throws IOException {
|
|
|
List<OrgInfo> basicInfos = JSONObject.parseArray(JSONObject.toJSONString(basicInfo), OrgInfo.class);
|
|
@@ -89,6 +221,7 @@ public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicI
|
|
|
addBasicInfo = new EnterpriseBasicInfo();
|
|
|
IgnoreUtils.copyPropertiesIgnoreNull(info, addBasicInfo);
|
|
|
|
|
|
+
|
|
|
// 企业其他信息:
|
|
|
addOtherInfo = new EnterpriseOtherInfo();
|
|
|
IgnoreUtils.copyPropertiesIgnoreNull(info, addOtherInfo);
|
|
@@ -229,6 +362,7 @@ public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicI
|
|
|
System.err.println("########################:" + otherInfos.get(0).getId());
|
|
|
|
|
|
// 同步其他信息至资源库。
|
|
|
+
|
|
|
List<ResourceLibrary> otherResourceLibraries = resourceLibraryService.dealOtherResourceLib(otherInfos);
|
|
|
boolean b4 = resourceLibraryService.saveOrUpdateBatch(otherResourceLibraries);
|
|
|
log.info("save-or-update resourcelib-other-data res:{}",b4);
|
|
@@ -246,4 +380,14 @@ public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicI
|
|
|
|
|
|
return esService.selEsByName(addedBasicInfos.get(0).getName());
|
|
|
}
|
|
|
+
|
|
|
+ // public
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ IdentifierGenerator identifierGenerator=new DefaultIdentifierGenerator();
|
|
|
+ System.out.println(identifierGenerator.nextId(new Object())); // 1468486128042225666
|
|
|
+ String s = CommonUtils.initId();
|
|
|
+ System.err.println(s);
|
|
|
+
|
|
|
+ }
|
|
|
}
|