42 changed files with 1663 additions and 29 deletions
@ -0,0 +1,132 @@ |
|||||
|
package com.epmet.excel.handler; |
||||
|
|
||||
|
import com.alibaba.excel.context.AnalysisContext; |
||||
|
import com.alibaba.excel.read.listener.ReadListener; |
||||
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
||||
|
import com.epmet.commons.tools.exception.ValidateException; |
||||
|
import com.epmet.commons.tools.utils.ConvertUtils; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.result.IcCoverageCategoryDictListResultDTO; |
||||
|
import com.epmet.entity.IcCityManagementEntity; |
||||
|
import com.epmet.excel.IcCityManagementExcel; |
||||
|
import com.epmet.service.CoverageService; |
||||
|
import com.epmet.service.impl.IcCityManagementServiceImpl; |
||||
|
import lombok.Data; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 城市管理excel导入监听器 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Slf4j |
||||
|
public class IcCityManagementExcelImportListener implements ReadListener<IcCityManagementExcel> { |
||||
|
|
||||
|
//最大条数阈值
|
||||
|
public static final int MAX_THRESHOLD = 200; |
||||
|
private String currentUserId; |
||||
|
private String currentCustomerId; |
||||
|
private String currentAgencyId; |
||||
|
private String currentAgencyPids; |
||||
|
|
||||
|
//数据
|
||||
|
private List<IcCityManagementEntity> datas = new ArrayList<>(); |
||||
|
//错误项列表
|
||||
|
private List<IcCityManagementExcel.RowRemarkMessage> errorRows = new ArrayList<>(); |
||||
|
//其他被标记出来的列表列表
|
||||
|
private List<IcCityManagementExcel.RowRemarkMessage> otherRows = new ArrayList<>(); |
||||
|
private IcCityManagementServiceImpl IcCityManagementServiceImpl; |
||||
|
private CoverageService coverageService; |
||||
|
|
||||
|
public IcCityManagementExcelImportListener(String currentUserId, String currentCustomerId, String currentAgencyId, String currentAgencyPids, IcCityManagementServiceImpl IcCityManagementServiceImpl, CoverageService coverageService) { |
||||
|
this.currentUserId = currentUserId; |
||||
|
this.currentCustomerId = currentCustomerId; |
||||
|
this.currentAgencyId = currentAgencyId; |
||||
|
this.currentAgencyPids = currentAgencyPids; |
||||
|
this.IcCityManagementServiceImpl = IcCityManagementServiceImpl; |
||||
|
this.coverageService = coverageService; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void invoke(IcCityManagementExcel data, AnalysisContext context) { |
||||
|
|
||||
|
try { |
||||
|
// 先校验数据
|
||||
|
ValidatorUtils.validateEntity(data); |
||||
|
|
||||
|
// 去除前后空格
|
||||
|
if (StringUtils.isNotBlank(data.getName())) { |
||||
|
data.setName(data.getName().trim()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(data.getCategoryName())) { |
||||
|
data.setCategoryName(data.getCategoryName().trim()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(data.getAddress())) { |
||||
|
data.setAddress(data.getAddress().trim()); |
||||
|
} |
||||
|
|
||||
|
IcCityManagementEntity IcCityManagementEntity = ConvertUtils.sourceToTarget(data, IcCityManagementEntity.class); |
||||
|
IcCityManagementEntity.setSourceType("import"); |
||||
|
IcCityManagementEntity.setCategory(data.getCategoryName()); |
||||
|
IcCityManagementEntity.setAreaCovered(data.getAreaCoveredName()); |
||||
|
IcCityManagementEntity.setCapacity(data.getCapacityName()); |
||||
|
datas.add(IcCityManagementEntity); |
||||
|
|
||||
|
if (datas.size() == MAX_THRESHOLD) { |
||||
|
execPersist(); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
String errorMsg = null; |
||||
|
if (e instanceof ValidateException) { |
||||
|
errorMsg = ((ValidateException) e).getMsg(); |
||||
|
} else { |
||||
|
errorMsg = "未知错误"; |
||||
|
log.error("【城市管理导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); |
||||
|
} |
||||
|
|
||||
|
IcCityManagementExcel.RowRemarkMessage errorRow = new IcCityManagementExcel.RowRemarkMessage(); |
||||
|
errorRow.setName(data.getName()); |
||||
|
errorRow.setCategoryName(data.getCategoryName()); |
||||
|
errorRow.setAddress(data.getAddress()); |
||||
|
errorRow.setErrorInfo(errorMsg); |
||||
|
errorRows.add(errorRow); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void doAfterAllAnalysed(AnalysisContext context) { |
||||
|
// 最后几条达不到阈值,这里必须再调用一次
|
||||
|
execPersist(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行持久化 |
||||
|
*/ |
||||
|
private void execPersist() { |
||||
|
try { |
||||
|
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(currentCustomerId, "city_management"); |
||||
|
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getCategoryKey, IcCoverageCategoryDictListResultDTO::getCategoryName)); |
||||
|
datas.forEach(d -> { |
||||
|
d.setCategory(dictMap.get(d.getCategory())); |
||||
|
}); |
||||
|
IcCityManagementServiceImpl.insertBatch(datas); |
||||
|
|
||||
|
} finally { |
||||
|
datas.clear(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取错误行 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<IcCityManagementExcel.RowRemarkMessage> getErrorRows() { |
||||
|
return errorRows; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,132 @@ |
|||||
|
package com.epmet.excel.handler; |
||||
|
|
||||
|
import com.alibaba.excel.context.AnalysisContext; |
||||
|
import com.alibaba.excel.read.listener.ReadListener; |
||||
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
||||
|
import com.epmet.commons.tools.exception.ValidateException; |
||||
|
import com.epmet.commons.tools.utils.ConvertUtils; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.result.IcCoverageCategoryDictListResultDTO; |
||||
|
import com.epmet.entity.IcPublicServiceEntity; |
||||
|
import com.epmet.excel.IcPublicServiceExcel; |
||||
|
import com.epmet.service.CoverageService; |
||||
|
import com.epmet.service.impl.IcPublicServiceServiceImpl; |
||||
|
import lombok.Data; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 公共服务管理excel导入监听器 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Slf4j |
||||
|
public class IcPublicServiceExcelImportListener implements ReadListener<IcPublicServiceExcel> { |
||||
|
|
||||
|
//最大条数阈值
|
||||
|
public static final int MAX_THRESHOLD = 200; |
||||
|
private String currentUserId; |
||||
|
private String currentCustomerId; |
||||
|
private String currentAgencyId; |
||||
|
private String currentAgencyPids; |
||||
|
|
||||
|
//数据
|
||||
|
private List<IcPublicServiceEntity> datas = new ArrayList<>(); |
||||
|
//错误项列表
|
||||
|
private List<IcPublicServiceExcel.RowRemarkMessage> errorRows = new ArrayList<>(); |
||||
|
//其他被标记出来的列表列表
|
||||
|
private List<IcPublicServiceExcel.RowRemarkMessage> otherRows = new ArrayList<>(); |
||||
|
private IcPublicServiceServiceImpl IcPublicServiceServiceImpl; |
||||
|
private CoverageService coverageService; |
||||
|
|
||||
|
public IcPublicServiceExcelImportListener(String currentUserId, String currentCustomerId, String currentAgencyId, String currentAgencyPids, IcPublicServiceServiceImpl IcPublicServiceServiceImpl, CoverageService coverageService) { |
||||
|
this.currentUserId = currentUserId; |
||||
|
this.currentCustomerId = currentCustomerId; |
||||
|
this.currentAgencyId = currentAgencyId; |
||||
|
this.currentAgencyPids = currentAgencyPids; |
||||
|
this.IcPublicServiceServiceImpl = IcPublicServiceServiceImpl; |
||||
|
this.coverageService = coverageService; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void invoke(IcPublicServiceExcel data, AnalysisContext context) { |
||||
|
|
||||
|
try { |
||||
|
// 先校验数据
|
||||
|
ValidatorUtils.validateEntity(data); |
||||
|
|
||||
|
// 去除前后空格
|
||||
|
if (StringUtils.isNotBlank(data.getName())) { |
||||
|
data.setName(data.getName().trim()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(data.getCategoryName())) { |
||||
|
data.setCategoryName(data.getCategoryName().trim()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(data.getAddress())) { |
||||
|
data.setAddress(data.getAddress().trim()); |
||||
|
} |
||||
|
|
||||
|
IcPublicServiceEntity IcPublicServiceEntity = ConvertUtils.sourceToTarget(data, IcPublicServiceEntity.class); |
||||
|
IcPublicServiceEntity.setSourceType("import"); |
||||
|
IcPublicServiceEntity.setCategory(data.getCategoryName()); |
||||
|
IcPublicServiceEntity.setAreaCovered(data.getAreaCoveredName()); |
||||
|
IcPublicServiceEntity.setCapacity(data.getCapacityName()); |
||||
|
datas.add(IcPublicServiceEntity); |
||||
|
|
||||
|
if (datas.size() == MAX_THRESHOLD) { |
||||
|
execPersist(); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
String errorMsg = null; |
||||
|
if (e instanceof ValidateException) { |
||||
|
errorMsg = ((ValidateException) e).getMsg(); |
||||
|
} else { |
||||
|
errorMsg = "未知错误"; |
||||
|
log.error("【公共服务管理导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); |
||||
|
} |
||||
|
|
||||
|
IcPublicServiceExcel.RowRemarkMessage errorRow = new IcPublicServiceExcel.RowRemarkMessage(); |
||||
|
errorRow.setName(data.getName()); |
||||
|
errorRow.setCategoryName(data.getCategoryName()); |
||||
|
errorRow.setAddress(data.getAddress()); |
||||
|
errorRow.setErrorInfo(errorMsg); |
||||
|
errorRows.add(errorRow); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void doAfterAllAnalysed(AnalysisContext context) { |
||||
|
// 最后几条达不到阈值,这里必须再调用一次
|
||||
|
execPersist(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行持久化 |
||||
|
*/ |
||||
|
private void execPersist() { |
||||
|
try { |
||||
|
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(currentCustomerId, "public_service"); |
||||
|
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getCategoryKey, IcCoverageCategoryDictListResultDTO::getCategoryName)); |
||||
|
datas.forEach(d -> { |
||||
|
d.setCategory(dictMap.get(d.getCategory())); |
||||
|
}); |
||||
|
IcPublicServiceServiceImpl.insertBatch(datas); |
||||
|
|
||||
|
} finally { |
||||
|
datas.clear(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取错误行 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<IcPublicServiceExcel.RowRemarkMessage> getErrorRows() { |
||||
|
return errorRows; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,134 @@ |
|||||
|
package com.epmet.excel.handler; |
||||
|
|
||||
|
import com.alibaba.excel.context.AnalysisContext; |
||||
|
import com.alibaba.excel.read.listener.ReadListener; |
||||
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
||||
|
import com.epmet.commons.tools.exception.ValidateException; |
||||
|
import com.epmet.commons.tools.utils.ConvertUtils; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.result.IcCoverageCategoryDictListResultDTO; |
||||
|
import com.epmet.dto.result.IcSuperiorResourceListResultDTO; |
||||
|
import com.epmet.entity.IcSuperiorResourceEntity; |
||||
|
import com.epmet.excel.IcSuperiorResourceExcel; |
||||
|
import com.epmet.service.CoverageService; |
||||
|
import com.epmet.service.impl.IcSuperiorResourceServiceImpl; |
||||
|
import lombok.Data; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 优势资源管理excel导入监听器 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Slf4j |
||||
|
public class IcSuperiorResourceExcelImportListener implements ReadListener<IcSuperiorResourceExcel> { |
||||
|
|
||||
|
//最大条数阈值
|
||||
|
public static final int MAX_THRESHOLD = 200; |
||||
|
private String currentUserId; |
||||
|
private String currentCustomerId; |
||||
|
private String currentAgencyId; |
||||
|
private String currentAgencyPids; |
||||
|
|
||||
|
//数据
|
||||
|
private List<IcSuperiorResourceEntity> datas = new ArrayList<>(); |
||||
|
//错误项列表
|
||||
|
private List<IcSuperiorResourceExcel.RowRemarkMessage> errorRows = new ArrayList<>(); |
||||
|
//其他被标记出来的列表列表
|
||||
|
private List<IcSuperiorResourceExcel.RowRemarkMessage> otherRows = new ArrayList<>(); |
||||
|
private IcSuperiorResourceServiceImpl icSuperiorResourceServiceImpl; |
||||
|
private CoverageService coverageService; |
||||
|
|
||||
|
public IcSuperiorResourceExcelImportListener(String currentUserId, String currentCustomerId, String currentAgencyId, String currentAgencyPids, IcSuperiorResourceServiceImpl icSuperiorResourceServiceImpl, CoverageService coverageService) { |
||||
|
this.currentUserId = currentUserId; |
||||
|
this.currentCustomerId = currentCustomerId; |
||||
|
this.currentAgencyId = currentAgencyId; |
||||
|
this.currentAgencyPids = currentAgencyPids; |
||||
|
this.icSuperiorResourceServiceImpl = icSuperiorResourceServiceImpl; |
||||
|
this.coverageService = coverageService; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void invoke(IcSuperiorResourceExcel data, AnalysisContext context) { |
||||
|
|
||||
|
try { |
||||
|
// 先校验数据
|
||||
|
ValidatorUtils.validateEntity(data); |
||||
|
|
||||
|
// 去除前后空格
|
||||
|
if (StringUtils.isNotBlank(data.getName())) { |
||||
|
data.setName(data.getName().trim()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(data.getCategoryName())) { |
||||
|
data.setCategoryName(data.getCategoryName().trim()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(data.getAddress())) { |
||||
|
data.setAddress(data.getAddress().trim()); |
||||
|
} |
||||
|
|
||||
|
IcSuperiorResourceEntity icSuperiorResourceEntity = ConvertUtils.sourceToTarget(data, IcSuperiorResourceEntity.class); |
||||
|
icSuperiorResourceEntity.setSourceType("import"); |
||||
|
icSuperiorResourceEntity.setCategory(data.getCategoryName()); |
||||
|
icSuperiorResourceEntity.setAreaCovered(data.getAreaCoveredName()); |
||||
|
icSuperiorResourceEntity.setCapacity(data.getCapacityName()); |
||||
|
datas.add(icSuperiorResourceEntity); |
||||
|
|
||||
|
if (datas.size() == MAX_THRESHOLD) { |
||||
|
execPersist(); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
String errorMsg = null; |
||||
|
if (e instanceof ValidateException) { |
||||
|
errorMsg = ((ValidateException) e).getMsg(); |
||||
|
} else { |
||||
|
errorMsg = "未知错误"; |
||||
|
log.error("【优势资源管理导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); |
||||
|
} |
||||
|
|
||||
|
IcSuperiorResourceExcel.RowRemarkMessage errorRow = new IcSuperiorResourceExcel.RowRemarkMessage(); |
||||
|
errorRow.setName(data.getName()); |
||||
|
errorRow.setCategoryName(data.getCategoryName()); |
||||
|
errorRow.setAddress(data.getAddress()); |
||||
|
errorRow.setErrorInfo(errorMsg); |
||||
|
errorRows.add(errorRow); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void doAfterAllAnalysed(AnalysisContext context) { |
||||
|
// 最后几条达不到阈值,这里必须再调用一次
|
||||
|
execPersist(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行持久化 |
||||
|
*/ |
||||
|
private void execPersist() { |
||||
|
try { |
||||
|
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(currentCustomerId, "superior_resource"); |
||||
|
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getCategoryKey, IcCoverageCategoryDictListResultDTO::getCategoryName)); |
||||
|
datas.forEach(d -> { |
||||
|
d.setCategory(dictMap.get(d.getCategory())); |
||||
|
}); |
||||
|
icSuperiorResourceServiceImpl.insertBatch(datas); |
||||
|
|
||||
|
} finally { |
||||
|
datas.clear(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取错误行 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<IcSuperiorResourceExcel.RowRemarkMessage> getErrorRows() { |
||||
|
return errorRows; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,154 @@ |
|||||
|
package com.epmet.model; |
||||
|
|
||||
|
import com.alibaba.excel.context.AnalysisContext; |
||||
|
import com.alibaba.excel.event.AnalysisEventListener; |
||||
|
import com.epmet.commons.tools.constant.NumConstant; |
||||
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
||||
|
import com.epmet.commons.tools.exception.EpmetException; |
||||
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
||||
|
import com.epmet.commons.tools.utils.ConvertUtils; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.result.IcCoverageCategoryDictListResultDTO; |
||||
|
import com.epmet.entity.IcDangerousChemicalsEntity; |
||||
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
||||
|
import com.epmet.service.CoverageService; |
||||
|
import com.epmet.service.IcDangerousChemicalsService; |
||||
|
import lombok.Data; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||
|
import org.apache.commons.collections4.MapUtils; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2022/6/20 10:31 |
||||
|
* @DESC |
||||
|
*/ |
||||
|
@Data |
||||
|
@Slf4j |
||||
|
public class DangerousChemicalsImportListener extends AnalysisEventListener<DangerousChemicalsModel> { |
||||
|
|
||||
|
private IcDangerousChemicalsService icDangerousChemicalsService; |
||||
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
||||
|
private CoverageService coverageService; |
||||
|
private AgencyInfoCache agencyInfo; |
||||
|
|
||||
|
private List<DangerousChemicalsModel.RowRemarkMessage> errorRows = new ArrayList<>(); |
||||
|
private List<DangerousChemicalsModel.RowRemarkMessage> otherRows = new ArrayList<>(); |
||||
|
private List<IcDangerousChemicalsEntity> insertList = new ArrayList<>(); |
||||
|
|
||||
|
public DangerousChemicalsImportListener(AgencyInfoCache agencyInfo, IcDangerousChemicalsService icDangerousChemicalsService, CoverageService coverageService,EpmetAdminOpenFeignClient adminOpenFeignClient){ |
||||
|
this.agencyInfo = agencyInfo; |
||||
|
this.icDangerousChemicalsService = icDangerousChemicalsService; |
||||
|
this.coverageService = coverageService; |
||||
|
this.adminOpenFeignClient = adminOpenFeignClient; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void invoke(DangerousChemicalsModel data, AnalysisContext context) { |
||||
|
Integer rowNum = context.readRowHolder().getRowIndex() + NumConstant.ONE; |
||||
|
if (StringUtils.isBlank(data.getName())){ |
||||
|
DangerousChemicalsModel.RowRemarkMessage row = ConvertUtils.sourceToTarget(data, DangerousChemicalsModel.RowRemarkMessage.class); |
||||
|
row.setRowNum(rowNum); |
||||
|
row.setErrorInfo("企业名称不能为空"); |
||||
|
errorRows.add(row); |
||||
|
return; |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getCategoryName())){ |
||||
|
DangerousChemicalsModel.RowRemarkMessage row = ConvertUtils.sourceToTarget(data, DangerousChemicalsModel.RowRemarkMessage.class); |
||||
|
row.setRowNum(rowNum); |
||||
|
row.setErrorInfo("企业类型不能为空"); |
||||
|
errorRows.add(row); |
||||
|
return; |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getAddress())){ |
||||
|
DangerousChemicalsModel.RowRemarkMessage row = ConvertUtils.sourceToTarget(data, DangerousChemicalsModel.RowRemarkMessage.class); |
||||
|
row.setRowNum(rowNum); |
||||
|
row.setErrorInfo("经营地址不能为空"); |
||||
|
errorRows.add(row); |
||||
|
return; |
||||
|
} |
||||
|
if (data.getName().trim().length() > NumConstant.FIFTY){ |
||||
|
DangerousChemicalsModel.RowRemarkMessage row = ConvertUtils.sourceToTarget(data, DangerousChemicalsModel.RowRemarkMessage.class); |
||||
|
row.setRowNum(rowNum); |
||||
|
row.setErrorInfo("企业名称长度超出50字限制"); |
||||
|
errorRows.add(row); |
||||
|
} |
||||
|
if (data.getPrincipalMobile().trim().length() > NumConstant.FIFTY){ |
||||
|
DangerousChemicalsModel.RowRemarkMessage row = ConvertUtils.sourceToTarget(data, DangerousChemicalsModel.RowRemarkMessage.class); |
||||
|
row.setRowNum(rowNum); |
||||
|
row.setErrorInfo("联系电话长度超出50字限制"); |
||||
|
errorRows.add(row); |
||||
|
} |
||||
|
if (data.getAddress().trim().length() > NumConstant.FIFTY){ |
||||
|
DangerousChemicalsModel.RowRemarkMessage row = ConvertUtils.sourceToTarget(data, DangerousChemicalsModel.RowRemarkMessage.class); |
||||
|
row.setRowNum(rowNum); |
||||
|
row.setErrorInfo("经营地址长度超出50字限制"); |
||||
|
errorRows.add(row); |
||||
|
} |
||||
|
IcDangerousChemicalsEntity e = ConvertUtils.sourceToTarget(data, IcDangerousChemicalsEntity.class); |
||||
|
e.setSourceType("import"); |
||||
|
e.setAgencyId(agencyInfo.getId()); |
||||
|
e.setCustomerId(agencyInfo.getCustomerId()); |
||||
|
e.setAgencyIdPath(agencyInfo.getPids().equals(NumConstant.ZERO_STR) || agencyInfo.getPids().equals("") ? agencyInfo.getId() : agencyInfo.getPids().concat(":").concat(agencyInfo.getId())); |
||||
|
insertList.add(e); |
||||
|
if (insertList.size() == NumConstant.ONE_HUNDRED){ |
||||
|
execPersist(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void doAfterAllAnalysed(AnalysisContext context) { |
||||
|
execPersist(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Desc: 数据库插入 |
||||
|
*/ |
||||
|
private void execPersist() { |
||||
|
try { |
||||
|
if (CollectionUtils.isNotEmpty(insertList)) { |
||||
|
//危化品种类字典
|
||||
|
Result<Map<String, String>> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode()); |
||||
|
if (!statusRes.success()){ |
||||
|
throw new EpmetException("获取IC_DANGER_TYPE字典表失败"); |
||||
|
} |
||||
|
Map<String, String> statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>(16); |
||||
|
//企业类别字典数据
|
||||
|
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(agencyInfo.getCustomerId(), "dangerous_chemicals"); |
||||
|
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getCategoryKey, IcCoverageCategoryDictListResultDTO::getCategoryName)); |
||||
|
insertList.forEach(i -> { |
||||
|
statusMap.forEach((k,v) -> { |
||||
|
if (i.getDangerTypeName().equals(v)){ |
||||
|
i.setDangerType(k); |
||||
|
} |
||||
|
}); |
||||
|
dictMap.forEach((k,v) -> { |
||||
|
if (i.getCategoryName().equals(v)){ |
||||
|
i.setCategory(k); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
icDangerousChemicalsService.insertBatch(insertList); |
||||
|
} |
||||
|
} finally { |
||||
|
insertList.clear(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取错误行 |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<DangerousChemicalsModel.RowRemarkMessage> getErrorRows() { |
||||
|
return errorRows; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,91 @@ |
|||||
|
package com.epmet.model; |
||||
|
|
||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
|
import com.epmet.commons.tools.constant.NumConstant; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2022/6/20 10:33 |
||||
|
* @DESC |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DangerousChemicalsModel { |
||||
|
|
||||
|
@NotBlank(message = "企业名称为必填项") |
||||
|
@Length(max = 50,message = "企业名称长度超出50字限制") |
||||
|
@ExcelProperty(value = "企业名称") |
||||
|
private String name; |
||||
|
|
||||
|
@NotBlank(message = "企业类型为必填项") |
||||
|
@ExcelProperty(value = "企业类型") |
||||
|
private String categoryName; |
||||
|
|
||||
|
@ExcelProperty(value = "周边安全间距(公里)") |
||||
|
private String safeDistance = NumConstant.ZERO_STR; |
||||
|
|
||||
|
@ExcelProperty(value = "危化品种类") |
||||
|
private String dangerTypeName; |
||||
|
|
||||
|
@ExcelProperty(value = "负责人") |
||||
|
private String principalName; |
||||
|
|
||||
|
@Length(max = 50,message = "联系电话长度超出50字限制") |
||||
|
@ExcelProperty(value = "联系电话") |
||||
|
private String principalMobile; |
||||
|
|
||||
|
@Length(max = 50,message = "经营地址长度超出50字限制") |
||||
|
@ExcelProperty(value = "经营地址") |
||||
|
private String address; |
||||
|
|
||||
|
@ExcelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
@Data |
||||
|
public static class RowRemarkMessage { |
||||
|
|
||||
|
@ExcelProperty(value = "行号") |
||||
|
private Integer rowNum; |
||||
|
|
||||
|
@ColumnWidth(20) |
||||
|
@ExcelProperty(value = "企业名称") |
||||
|
private String name; |
||||
|
|
||||
|
@ColumnWidth(20) |
||||
|
@ExcelProperty(value = "企业类型") |
||||
|
private String categoryName; |
||||
|
|
||||
|
@ColumnWidth(20) |
||||
|
@ExcelProperty(value = "周边安全间距(公里)") |
||||
|
private String safeDistance = NumConstant.ZERO_STR; |
||||
|
|
||||
|
@ColumnWidth(20) |
||||
|
@ExcelProperty(value = "危化品种类") |
||||
|
private String dangerTypeName; |
||||
|
|
||||
|
@ColumnWidth(20) |
||||
|
@ExcelProperty(value = "负责人") |
||||
|
private String principalName; |
||||
|
|
||||
|
@ColumnWidth(20) |
||||
|
@ExcelProperty(value = "联系电话") |
||||
|
private String principalMobile; |
||||
|
|
||||
|
@ColumnWidth(40) |
||||
|
@ExcelProperty(value = "经营地址") |
||||
|
private String address; |
||||
|
|
||||
|
@ColumnWidth(60) |
||||
|
@ExcelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
@ColumnWidth(60) |
||||
|
@ExcelProperty("错误信息") |
||||
|
private String errorInfo; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,2 @@ |
|||||
|
ALTER TABLE `ic_event` |
||||
|
ADD COLUMN `DIFFICULT_POINT` varchar(3) NULL DEFAULT '0' COMMENT '是否标记难点堵点 0:否 1:是' AFTER `AUDIT_REASON`; |
||||
Loading…
Reference in new issue