Browse Source

导入优化调整

dev
sunyuchao 4 years ago
parent
commit
abcb68b58e
  1. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java
  2. 51
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java
  3. 6
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java

@ -27,9 +27,9 @@ import lombok.Data;
@Data @Data
public class CommunitySelfOrgImportExcel { public class CommunitySelfOrgImportExcel {
@Excel(name = "组织名称", width = 40) /*@Excel(name = "组织名称", width = 40)
private String agencyName; private String agencyName;*/
@Excel(name = "社会组织名称", width = 40) @Excel(name = "社会组织名称", width = 40)
private String societyName; private String societyName;
@Excel(name = "错误信息", width = 50) @Excel(name = "错误信息", width = 50)
private String errorInfo; private String errorInfo;

51
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java

@ -478,8 +478,9 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
@Override @Override
//@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
@Async @Async
public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException { public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) {
try { try {
log.info("社会自组织导入,子线程开始执行");
List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>(); List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>();
CommunitySelfOrgImportExcel excel = null; CommunitySelfOrgImportExcel excel = null;
//1.读取Excel数据 //1.读取Excel数据
@ -489,7 +490,7 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
//打印失败的行 和失败的信息 //打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
excel = new CommunitySelfOrgImportExcel(); excel = new CommunitySelfOrgImportExcel();
excel.setAgencyName(entity.getOrganizationName()); //excel.setAgencyName(entity.getOrganizationName());
excel.setSocietyName(entity.getOrganizationName()); excel.setSocietyName(entity.getOrganizationName());
excel.setErrorInfo(entity.getErrorMsg()); excel.setErrorInfo(entity.getErrorMsg());
fileList.add(excel); fileList.add(excel);
@ -524,10 +525,11 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
if (!m && !t){ if (!m && !t){
errMsg.append("手机号码不合法;"); errMsg.append("手机号码不合法;");
bl.set(true); bl.set(true);
log.warn("手机号码不合法,自组织名称{}", obj.getOrganizationName());
} }
if(bl.get()){ if(bl.get()){
excel = new CommunitySelfOrgImportExcel(); excel = new CommunitySelfOrgImportExcel();
excel.setAgencyName(obj.getOrganizationName()); //excel.setAgencyName(obj.getOrganizationName());
excel.setSocietyName(obj.getOrganizationName()); excel.setSocietyName(obj.getOrganizationName());
excel.setErrorInfo(errMsg.toString()); excel.setErrorInfo(errMsg.toString());
fileList.add(excel); fileList.add(excel);
@ -542,22 +544,24 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
e.setOrgType(IcCommunitySelfOrganizationConstant.ORG_TYPE_AGENCY); e.setOrgType(IcCommunitySelfOrganizationConstant.ORG_TYPE_AGENCY);
e.setPid(agencyInfo.getPid()); e.setPid(agencyInfo.getPid());
e.setPids(agencyInfo.getPids()); e.setPids(agencyInfo.getPids());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); e.setOrganizationCreatedTime(DateUtils.parse(l.getOrganizationCreatedTime(), DATE_PATTERN));
try {
e.setOrganizationCreatedTime(sdf.parse(l.getOrganizationCreatedTime())); List<IcCommunitySelfOrganizationPersonnelEntity> persons = new ArrayList<>();
} catch (ParseException ex) { AtomicReference<Boolean> bl = new AtomicReference<>(false);
ex.printStackTrace(); StringBuffer msg = new StringBuffer("");
}
baseDao.insert(e);
if (CollectionUtils.isNotEmpty(l.getPersons())){ if (CollectionUtils.isNotEmpty(l.getPersons())){
l.getPersons().forEach(p -> { l.getPersons().forEach(p -> {
boolean m = PhoneValidatorUtils.isMobile(p.getPersonPhone()); boolean m = PhoneValidatorUtils.isMobile(p.getPersonPhone());
boolean t = PhoneValidatorUtils.isTel(p.getPersonPhone()); boolean t = PhoneValidatorUtils.isTel(p.getPersonPhone());
if (!m && !t){ if (!m && !t){
throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode()); bl.set(true);
msg.append("自组织下成员手机号错误;");
log.warn("自组织下成员手机号错误,自组织名称{}", l.getOrganizationName());
return;
//throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode());
} }
}); });
List<IcCommunitySelfOrganizationPersonnelEntity> persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class); persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class);
Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone)); Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone));
List<String> phones = new ArrayList<>(); List<String> phones = new ArrayList<>();
groupByPhone.forEach((k,v) -> { groupByPhone.forEach((k,v) -> {
@ -566,28 +570,43 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
} }
}); });
if (CollectionUtils.isNotEmpty(phones)){ if (CollectionUtils.isNotEmpty(phones)){
StringBuffer sb = new StringBuffer(); bl.set(true);
msg.append("自组织下成员手机号重复;");
log.warn("自组织下成员手机号重复,自组织名称{}", l.getOrganizationName());
/*StringBuffer sb = new StringBuffer();
phones.forEach(p -> { phones.forEach(p -> {
sb.append(p).append(","); sb.append(p).append(",");
}); });
String copywriter = sb.toString().substring(NumConstant.ZERO, sb.length() - NumConstant.ONE); String copywriter = sb.toString().substring(NumConstant.ZERO, sb.length() - NumConstant.ONE);
EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.setMsg(String.format(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getMsg(),copywriter)); EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.setMsg(String.format(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getMsg(),copywriter));
throw new RenException(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getCode()); throw new RenException(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getCode());*/
} }
}
if(bl.get()){
CommunitySelfOrgImportExcel ex = new CommunitySelfOrgImportExcel();
//ex.setAgencyName(l.getOrganizationName());
ex.setSocietyName(l.getOrganizationName());
ex.setErrorInfo(msg.toString());
fileList.add(ex);
return;
}
baseDao.insert(e);
if(CollectionUtils.isNotEmpty(persons)){
persons.forEach(p -> { persons.forEach(p -> {
p.setCustomerId(tokenDto.getCustomerId()); p.setCustomerId(tokenDto.getCustomerId());
p.setOrgId(e.getId()); p.setOrgId(e.getId());
}); });
personnelService.insertBatch(persons); personnelService.insertBatch(persons);
} }
}); });
} }
//4.错误数据生成文件,修改导入任务状态 //4.错误数据生成文件,修改导入任务状态
String url = erroeImport(fileList); String url = erroeImport(fileList);
upImportTask(url, taskId, tokenDto.getUserId(), true); upImportTask(url, taskId, tokenDto.getUserId(), true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【社会自组织信息导入】程序错误"); log.error("【社会自组织信息导入】程序错误:{}", errorMsg);
upImportTask(null, taskId, tokenDto.getUserId(), false); upImportTask(null, taskId, tokenDto.getUserId(), false);
} }
} }

6
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

@ -259,8 +259,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
@Override @Override
//@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
@Async @Async
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException { public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) {
try { try {
log.info("党员风采导入,子线程开始执行");
List<PartyMemberImportExcel> fileList = new ArrayList<>(); List<PartyMemberImportExcel> fileList = new ArrayList<>();
PartyMemberImportExcel excel = null; PartyMemberImportExcel excel = null;
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class);
@ -368,7 +369,8 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
String url = erroeImport(fileList); String url = erroeImport(fileList);
upImportTask(url, taskId, tokenDto.getUserId(), true); upImportTask(url, taskId, tokenDto.getUserId(), true);
} catch (Exception e) { } catch (Exception e) {
log.error("【党员风采信息导入】程序错误"); String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【党员风采信息导入】程序错误:{}", errorMsg);
upImportTask(null, taskId, tokenDto.getUserId(), false); upImportTask(null, taskId, tokenDto.getUserId(), false);
} }
} }

Loading…
Cancel
Save