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