|
@@ -2,17 +2,19 @@ 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.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.form.BasicInfo;
|
|
|
+import com.pavis.app.saasbacken.form.OrgInfo;
|
|
|
import com.pavis.app.saasbacken.service.CategoryService;
|
|
|
import com.pavis.app.saasbacken.service.EnterpriseBasicInfoService;
|
|
|
import com.pavis.app.saasbacken.service.EnterpriseOtherInfoService;
|
|
|
import com.pavis.app.saasbacken.service.EsService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -23,7 +25,7 @@ import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 企业基本信息
|
|
|
+ * 企业基本信息
|
|
|
* </p>
|
|
|
*
|
|
|
* @author guan
|
|
@@ -50,32 +52,50 @@ public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicI
|
|
|
|
|
|
@Override
|
|
|
public List<EnterpriseBasicInfo> orgBasicAdd(List<Object> basicInfo) throws IOException {
|
|
|
- List<BasicInfo> basicInfos = JSONObject.parseArray(JSONObject.toJSONString(basicInfo), BasicInfo.class);
|
|
|
+ List<OrgInfo> basicInfos = JSONObject.parseArray(JSONObject.toJSONString(basicInfo), OrgInfo.class);
|
|
|
// 解析数据。
|
|
|
List<EnterpriseBasicInfo> addedBasicInfos = new ArrayList<>();
|
|
|
EnterpriseBasicInfo addBasicInfo;
|
|
|
// 企业其他数据
|
|
|
EnterpriseOtherInfo addOtherInfo;
|
|
|
List<EnterpriseOtherInfo> addOtherInfos = new ArrayList<>();
|
|
|
- for (BasicInfo info : basicInfos) {
|
|
|
+ for (OrgInfo info : basicInfos) {
|
|
|
+ // todo 根据企业id判断是新增或者更新。 企业名称和社会统一信用代码。
|
|
|
+ if (null == info.getId() && StringUtils.isEmpty(info.getId())) {
|
|
|
+ // id为空,进行新增操作。
|
|
|
+ log.info("新增操作", info.getId());
|
|
|
+ // 根据企业名称或者社会统一信用代码
|
|
|
+ List<EnterpriseBasicInfo> enterpriseBasicInfos = enterpriseBasicInfoMapper.selectList(new QueryWrapper<EnterpriseBasicInfo>().lambda()
|
|
|
+ .eq(EnterpriseBasicInfo::getUnifySocialCreditCode, info.getUnifySocialCreditCode()));
|
|
|
+ if (enterpriseBasicInfos.size() > 0) {
|
|
|
+ // 企业基本信息已存在,
|
|
|
+ info.setId(enterpriseBasicInfos.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 企业基本信息
|
|
|
addBasicInfo = new EnterpriseBasicInfo();
|
|
|
- BeanUtils.copyProperties(info,addBasicInfo);
|
|
|
-
|
|
|
+ IgnoreUtils.copyPropertiesIgnoreNull(info, addBasicInfo);
|
|
|
+
|
|
|
+ // 企业其他信息:
|
|
|
+ addOtherInfo = new EnterpriseOtherInfo();
|
|
|
+ IgnoreUtils.copyPropertiesIgnoreNull(info, addOtherInfo);
|
|
|
+ addOtherInfo.setEnterpriseId(info.getId());
|
|
|
+ // todo 待处理字段如:国高八大领域。
|
|
|
+ addOtherInfos.add(addOtherInfo);
|
|
|
|
|
|
// 所属行业 需要单独处理,做一下转换后进行存储。
|
|
|
- addBasicInfo.setIndustry(categoryService.dealCategory(info.getIndustry(),true));
|
|
|
+ addBasicInfo.setIndustry(categoryService.dealCategory(info.getIndustry(), true));
|
|
|
// 企业类型:国有企业 集体所有制企业 私营企业 股份制企业 联营企业 外商投资企业 港澳台企业 股份合作企业 有限责任公司 其他企业。
|
|
|
- addBasicInfo.setEnterpriseType(categoryService.dealCategory(info.getEnterpriseType(),true));
|
|
|
+ addBasicInfo.setEnterpriseType(categoryService.dealCategory(info.getEnterpriseType(), true));
|
|
|
// 机构类型:企业 高校 机构 园区 政府 其他。
|
|
|
- addBasicInfo.setResType(categoryService.dealCategory(info.getResType(),true));
|
|
|
+ addBasicInfo.setResType(categoryService.dealCategory(info.getResType(), true));
|
|
|
// 研发机构等级:国家级、省级、市级、区级等。
|
|
|
- addBasicInfo.setDevOrgLevel(categoryService.dealCategory(info.getDevOrgLevel(),true));
|
|
|
+ addBasicInfo.setDevOrgLevel(categoryService.dealCategory(info.getDevOrgLevel(), true));
|
|
|
// 是否规上: 前端传0 否 或 1 是。
|
|
|
// addBasicInfo.setIsGauge("");
|
|
|
// 企业资质:国高、市高、省科技型中小企业、高企培育、规上、科技型初创企业、高新潜力企业、创新引领企业。
|
|
|
- addBasicInfo.setQualifyInfo(categoryService.dealCategory(info.getQualifyInfo(),true));
|
|
|
-
|
|
|
+ addBasicInfo.setQualifyInfo(categoryService.dealCategory(info.getQualifyInfo(), true));
|
|
|
|
|
|
// todo 需要保存企业信息,再处理人员信息。
|
|
|
|
|
@@ -95,57 +115,84 @@ public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicI
|
|
|
}
|
|
|
log.info("addedBasicInfos before:{}", JSON.toJSONString(addedBasicInfos));
|
|
|
// 批量新增企业基本信息。
|
|
|
- boolean b = saveBatch(addedBasicInfos);
|
|
|
- log.info("save basic-org info res:{}",b);
|
|
|
+ boolean b = saveOrUpdateBatch(addedBasicInfos);
|
|
|
+ log.info("save basic-org info res:{}", b);
|
|
|
log.info("addedBasicInfos after:{}", JSON.toJSONString(addedBasicInfos));
|
|
|
+
|
|
|
+
|
|
|
+ List<EnterpriseOtherInfo> otherInfos = new ArrayList<>();
|
|
|
// 处理人员信息关联关系。
|
|
|
for (int i = 0; i < addedBasicInfos.size(); i++) {
|
|
|
+
|
|
|
+ System.err.println("*****************orgId:" + addedBasicInfos.get(i).getId());
|
|
|
+
|
|
|
// 1 企业联系人姓名及联系方式。
|
|
|
- String s1 = personalInfoService.dealPersonal(basicInfos.get(i).getContacts(), basicInfos.get(i).getContacts(),
|
|
|
- addedBasicInfos.get(i).getId(), "6", "1");
|
|
|
- addedBasicInfos.get(i).setContactsId(s1);
|
|
|
+ String contactsName = basicInfos.get(i).getContacts();
|
|
|
+ String contactsWay = basicInfos.get(i).getContactsWay();
|
|
|
+ String s1 = "";
|
|
|
+ if (StringUtils.isNotEmpty(contactsName) && StringUtils.isNotEmpty(contactsWay)) {
|
|
|
+ s1 = personalInfoService.dealPersonal(contactsName, contactsWay, addedBasicInfos.get(i).getId(), "6", "1");
|
|
|
+ addedBasicInfos.get(i).setContactsId(s1);
|
|
|
+ }
|
|
|
|
|
|
// 2 企业负责人/法定代表人姓名及联系方式。
|
|
|
- String s2 = personalInfoService.dealPersonal(basicInfos.get(i).getChargeDirectorName(), basicInfos.get(i).getContacts(),
|
|
|
- addedBasicInfos.get(i).getId(), "6", "2");
|
|
|
- addedBasicInfos.get(i).setChargeDirectorId(s1);
|
|
|
+ String chargeDirectorName = basicInfos.get(i).getChargeDirectorName();
|
|
|
+ String chargeDirectorWay = basicInfos.get(i).getChargeDirectorWay();
|
|
|
+ String s2 = "";
|
|
|
+ if (StringUtils.isNotEmpty(chargeDirectorName) && StringUtils.isNotEmpty(chargeDirectorWay)) {
|
|
|
+ s2 = personalInfoService.dealPersonal(chargeDirectorName, chargeDirectorWay, addedBasicInfos.get(i).getId(), "6", "2");
|
|
|
+ addedBasicInfos.get(i).setChargeDirectorId(s2);
|
|
|
+ }
|
|
|
|
|
|
// 3 研发负责人姓名及联系方式。
|
|
|
- String s3 = personalInfoService.dealPersonal(basicInfos.get(i).getResearchDevName(), basicInfos.get(i).getContacts(),
|
|
|
- addedBasicInfos.get(i).getId(), "6", "3");
|
|
|
- addedBasicInfos.get(i).setResearchDevDirectorId(s1);
|
|
|
+ String researchDevName = basicInfos.get(i).getResearchDevName();
|
|
|
+ String researchDevWay = basicInfos.get(i).getResearchDevWay();
|
|
|
+ String s3 = "";
|
|
|
+ if (StringUtils.isNotEmpty(researchDevName) && StringUtils.isNotEmpty(researchDevWay)) {
|
|
|
+ s3 = personalInfoService.dealPersonal(researchDevName, researchDevWay, addedBasicInfos.get(i).getId(), "6", "3");
|
|
|
+ addedBasicInfos.get(i).setResearchDevDirectorId(s3);
|
|
|
+ }
|
|
|
|
|
|
// 4 财务负责人姓名及联系方式。
|
|
|
- String s4 = personalInfoService.dealPersonal(basicInfos.get(i).getFinancialName(), basicInfos.get(i).getContacts(),
|
|
|
- addedBasicInfos.get(i).getId(), "6", "4");
|
|
|
- addedBasicInfos.get(i).setFinancialDirectorId(s1);
|
|
|
+ String financialName = basicInfos.get(i).getFinancialName();
|
|
|
+ String financialWay = basicInfos.get(i).getFinancialWay();
|
|
|
+ String s4 = "";
|
|
|
+ if (StringUtils.isNotEmpty(financialName) && StringUtils.isNotEmpty(financialWay)) {
|
|
|
+ s4 = personalInfoService.dealPersonal(financialName, financialWay, addedBasicInfos.get(i).getId(), "6", "4");
|
|
|
+ addedBasicInfos.get(i).setFinancialDirectorId(s4);
|
|
|
+ }
|
|
|
|
|
|
// 5 科技联络人姓名及联系方式。
|
|
|
- String s5 = personalInfoService.dealPersonal(basicInfos.get(i).getTechnicalName(), basicInfos.get(i).getContacts(),
|
|
|
- addedBasicInfos.get(i).getId(), "6", "5");
|
|
|
- addedBasicInfos.get(i).setTechnicalDirectorId(s1);
|
|
|
+ String technicalName = basicInfos.get(i).getTechnicalName();
|
|
|
+ String technicalWay = basicInfos.get(i).getTechnicalWay();
|
|
|
+ String s5 = "";
|
|
|
+ if (StringUtils.isNotEmpty(technicalName) && StringUtils.isNotEmpty(technicalWay)) {
|
|
|
+ s5 = personalInfoService.dealPersonal(technicalName, technicalWay, addedBasicInfos.get(i).getId(), "6", "5");
|
|
|
+ addedBasicInfos.get(i).setTechnicalDirectorId(s5);
|
|
|
+ }
|
|
|
|
|
|
- log.info("update addedBasicInfos:{}",JSON.toJSONString(addedBasicInfos));
|
|
|
+ log.info("deal personal s1:{},s2:{},s3:{},s4:{},s5:{}", s1, s2, s3, s4, s5);
|
|
|
|
|
|
+ // 企业其他信息待新增或更新。
|
|
|
+ otherInfos.add(addOtherInfos.get(i).setEnterpriseId(addedBasicInfos.get(i).getId()));
|
|
|
|
|
|
- // 企业其他信息:
|
|
|
- // 企业其他信息
|
|
|
- addOtherInfo = new EnterpriseOtherInfo();
|
|
|
- BeanUtils.copyProperties(addedBasicInfos.get(i),addOtherInfo);
|
|
|
- // todo 待处理字段如:国高八大领域。
|
|
|
- addOtherInfos.add(addOtherInfo);
|
|
|
}
|
|
|
|
|
|
- log.info("update addedBasicInfos:{}",JSON.toJSONString(addedBasicInfos));
|
|
|
+ log.info("update addedBasicInfos:{}", JSON.toJSONString(addedBasicInfos));
|
|
|
// 更新企业人员信息:
|
|
|
boolean b1 = saveOrUpdateBatch(addedBasicInfos);
|
|
|
- log.info("update basic-info res:{}",b1);
|
|
|
+ log.info("update basic-info res:{}", b1);
|
|
|
+ log.info("update basic-info:{}", JSON.toJSONString(addedBasicInfos));
|
|
|
|
|
|
- log.info("other-info:{}",JSON.toJSONString(addOtherInfos));
|
|
|
|
|
|
+ // 处理企业库其他信息
|
|
|
+ log.info("update addOtherInfos:{}", JSON.toJSONString(otherInfos));
|
|
|
+ // todo 根据企业id判断是否已存在数据,
|
|
|
+ // List<EnterpriseOtherInfo> enterpriseOtherInfos =
|
|
|
// 批量新增企业其他信息。
|
|
|
- boolean b2 = enterpriseOtherInfoService.saveOrUpdateBatch(addOtherInfos);
|
|
|
- log.info("save other-info res:{}",b2);
|
|
|
+ boolean b2 = enterpriseOtherInfoService.dealOtherInfos(otherInfos);
|
|
|
+ log.info("save other-info res:{}", b2);
|
|
|
+ log.info("update other-info:{}", JSON.toJSONString(otherInfos));
|
|
|
|
|
|
return esService.selEsByName(addedBasicInfos.get(0).getName());
|
|
|
}
|