|
|
@ -2,6 +2,7 @@ package com.epmet.excel.handler; |
|
|
|
|
|
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
|
import com.alibaba.excel.read.listener.ReadListener; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
@ -13,6 +14,7 @@ import com.epmet.entity.IcEnterpriseEntity; |
|
|
|
import com.epmet.excel.EnterpriseImportExcelDTO; |
|
|
|
import com.epmet.service.impl.IcEnterpriseServiceImpl; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
@ -31,9 +33,9 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI |
|
|
|
private Map<String, String> placeTypeMap; |
|
|
|
private Map<String, String> scaleMap; |
|
|
|
private Map<String,String> gridMap; |
|
|
|
//数据
|
|
|
|
private List<IcEnterpriseEntity> datas = new ArrayList<>(); |
|
|
|
|
|
|
|
//要插入的数据
|
|
|
|
private List<IcEnterpriseEntity> insertDatas = new ArrayList<>(); |
|
|
|
private List<IcEnterpriseEntity> updateDatas = new ArrayList<>(); |
|
|
|
//错误项列表
|
|
|
|
private List<EnterpriseImportExcelDTO.ErrorRow> errorRows = new ArrayList<>(); |
|
|
|
|
|
|
@ -84,10 +86,25 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI |
|
|
|
enterpriseEntity.setLatitude(StrConstant.EPMETY_STR); |
|
|
|
//规模
|
|
|
|
enterpriseEntity.setScale(scaleMap.get(data.getScaleName())); |
|
|
|
enterpriseEntity.setSourceType("import"); |
|
|
|
datas.add(enterpriseEntity); |
|
|
|
|
|
|
|
if (datas.size() == MAX_THRESHOLD) { |
|
|
|
|
|
|
|
//网格id+场所名称
|
|
|
|
List<IcEnterpriseEntity> originList=icEnterpriseServiceImpl.selectForUniqueName(enterpriseEntity.getGridId(),enterpriseEntity.getPlaceOrgName(),null); |
|
|
|
if(CollectionUtils.isEmpty(originList)){ |
|
|
|
enterpriseEntity.setSourceType("import"); |
|
|
|
insertDatas.add(enterpriseEntity); |
|
|
|
}else{ |
|
|
|
IcEnterpriseEntity origin=originList.get(NumConstant.ZERO); |
|
|
|
enterpriseEntity.setId(origin.getId()); |
|
|
|
enterpriseEntity.setSourceType(origin.getSourceType()); |
|
|
|
updateDatas.add(enterpriseEntity); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (insertDatas.size() == MAX_THRESHOLD) { |
|
|
|
execPersist(); |
|
|
|
} |
|
|
|
if (updateDatas.size() == MAX_THRESHOLD) { |
|
|
|
execPersist(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
@ -122,9 +139,10 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI |
|
|
|
*/ |
|
|
|
private void execPersist() { |
|
|
|
try { |
|
|
|
icEnterpriseServiceImpl.insertBatch(datas); |
|
|
|
icEnterpriseServiceImpl.insertBatch(insertDatas); |
|
|
|
icEnterpriseServiceImpl.updateBatchById(updateDatas); |
|
|
|
} finally { |
|
|
|
datas.clear(); |
|
|
|
insertDatas.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|