|
|
@ -161,11 +161,11 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
@Override |
|
|
|
public void addCommunitySelfOrganization(TokenDto tokenDto, AddCommunitySelfOrganizationFormDTO formDTO) { |
|
|
|
String customerId = tokenDto.getCustomerId(); |
|
|
|
boolean mobile = PhoneValidatorUtils.isMobile(formDTO.getPrincipalPhone()); |
|
|
|
/*boolean mobile = PhoneValidatorUtils.isMobile(formDTO.getPrincipalPhone()); |
|
|
|
boolean tel = PhoneValidatorUtils.isTel(formDTO.getPrincipalPhone()); |
|
|
|
if (!mobile && !tel){ |
|
|
|
throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode()); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
LambdaQueryWrapper<IcCommunitySelfOrganizationEntity> l = new LambdaQueryWrapper<>(); |
|
|
|
l.eq(IcCommunitySelfOrganizationEntity::getOrganizationName,formDTO.getOrganizationName()) |
|
|
|
.eq(IcCommunitySelfOrganizationEntity::getCustomerId,customerId) |
|
|
@ -200,13 +200,16 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
baseDao.insert(orgEntity); |
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getOrganizationPersonnel())){ |
|
|
|
// 号码校验
|
|
|
|
formDTO.getOrganizationPersonnel().forEach(p -> { |
|
|
|
/** |
|
|
|
* 2022-06-14 需求变动 去掉号码校验 |
|
|
|
*/ |
|
|
|
/*formDTO.getOrganizationPersonnel().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()); |
|
|
|
} |
|
|
|
}); |
|
|
|
});*/ |
|
|
|
List<IcCommunitySelfOrganizationPersonnelEntity> persons = ConvertUtils.sourceToTarget(formDTO.getOrganizationPersonnel(), IcCommunitySelfOrganizationPersonnelEntity.class); |
|
|
|
Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone)); |
|
|
|
List<String> phones = new ArrayList<>(); |
|
|
@ -243,11 +246,11 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void editCommunitySelfOrganization(TokenDto tokenDto, EditCommunitySelfOrganizationFormDTO formDTO) { |
|
|
|
boolean m = PhoneValidatorUtils.isMobile(formDTO.getPrincipalPhone()); |
|
|
|
/*boolean m = PhoneValidatorUtils.isMobile(formDTO.getPrincipalPhone()); |
|
|
|
boolean t = PhoneValidatorUtils.isTel(formDTO.getPrincipalPhone()); |
|
|
|
if (!m && !t){ |
|
|
|
throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode()); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
LambdaQueryWrapper<IcCommunitySelfOrganizationEntity> l = new LambdaQueryWrapper<>(); |
|
|
|
l.eq(IcCommunitySelfOrganizationEntity::getOrganizationName,formDTO.getOrganizationName()) |
|
|
|
.eq(IcCommunitySelfOrganizationEntity::getCustomerId,tokenDto.getCustomerId()) |
|
|
@ -263,13 +266,16 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
baseDao.updateCommunitySelfOrganization(e); |
|
|
|
personnelService.deleteByOrgId(formDTO.getOrgId()); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getOrganizationPersonnel())){ |
|
|
|
formDTO.getOrganizationPersonnel().forEach(p -> { |
|
|
|
/** |
|
|
|
* 2022-06-14 需求变动 去掉号码校验 |
|
|
|
*/ |
|
|
|
/*formDTO.getOrganizationPersonnel().forEach(p -> { |
|
|
|
boolean mobile = PhoneValidatorUtils.isMobile(p.getPersonPhone()); |
|
|
|
boolean tel = PhoneValidatorUtils.isTel(p.getPersonPhone()); |
|
|
|
if (!mobile && !tel){ |
|
|
|
throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode()); |
|
|
|
} |
|
|
|
}); |
|
|
|
});*/ |
|
|
|
List<IcCommunitySelfOrganizationPersonnelEntity> persons = ConvertUtils.sourceToTarget(formDTO.getOrganizationPersonnel(), IcCommunitySelfOrganizationPersonnelEntity.class); |
|
|
|
Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone)); |
|
|
|
List<String> phones = new ArrayList<>(); |
|
|
@ -504,16 +510,18 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>(); |
|
|
|
CommunitySelfOrgImportExcel excel = null; |
|
|
|
//1.读取Excel数据
|
|
|
|
ExcelImportResult<ImportCommunitySelfOrganization> testExcelImportResult = ExcelPoiUtils.importExcelMore(inputStream,0,2,ImportCommunitySelfOrganization.class); |
|
|
|
ExcelImportResult<ImportCommunitySelfOrganization> testExcelImportResult = ExcelPoiUtils.importExcel1(inputStream,0,2,ImportCommunitySelfOrganization.class); |
|
|
|
//2.存在错误行数据时存入错误数据集合中
|
|
|
|
for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { |
|
|
|
//打印失败的行 和失败的信息
|
|
|
|
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); |
|
|
|
excel = new CommunitySelfOrgImportExcel(); |
|
|
|
//excel.setAgencyName(entity.getOrganizationName());
|
|
|
|
excel.setSocietyName(entity.getOrganizationName()); |
|
|
|
excel.setErrorInfo(entity.getErrorMsg()); |
|
|
|
fileList.add(excel); |
|
|
|
if(CollectionUtils.isNotEmpty(testExcelImportResult.getFailList())){ |
|
|
|
for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { |
|
|
|
//打印失败的行 和失败的信息
|
|
|
|
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); |
|
|
|
excel = new CommunitySelfOrgImportExcel(); |
|
|
|
//excel.setAgencyName(entity.getOrganizationName());
|
|
|
|
excel.setSocietyName(entity.getOrganizationName()); |
|
|
|
excel.setErrorInfo(entity.getErrorMsg()); |
|
|
|
fileList.add(excel); |
|
|
|
} |
|
|
|
} |
|
|
|
//正确行数据集合
|
|
|
|
List<ImportCommunitySelfOrganization> list = testExcelImportResult.getList(); |
|
|
@ -539,14 +547,17 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
bl.set(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
// //手机号不合规
|
|
|
|
// boolean m = PhoneValidatorUtils.isMobile(obj.getPrincipalPhone());
|
|
|
|
// boolean t = PhoneValidatorUtils.isTel(obj.getPrincipalPhone());
|
|
|
|
// if (!m && !t){
|
|
|
|
// errMsg.append("手机号码不合法;");
|
|
|
|
// bl.set(true);
|
|
|
|
// log.warn("手机号码不合法,自组织名称{}", obj.getOrganizationName());
|
|
|
|
// }
|
|
|
|
//手机号不合规
|
|
|
|
/** |
|
|
|
* 2022-06-14 需求变动 去掉号码校验 |
|
|
|
*/ |
|
|
|
/*boolean m = PhoneValidatorUtils.isMobile(obj.getPrincipalPhone()); |
|
|
|
boolean t = PhoneValidatorUtils.isTel(obj.getPrincipalPhone()); |
|
|
|
if (!m && !t){ |
|
|
|
errMsg.append("手机号码不合法;"); |
|
|
|
bl.set(true); |
|
|
|
log.warn("手机号码不合法,自组织名称{}", obj.getOrganizationName()); |
|
|
|
}*/ |
|
|
|
if(bl.get()){ |
|
|
|
excel = new CommunitySelfOrgImportExcel(); |
|
|
|
//excel.setAgencyName(obj.getOrganizationName());
|
|
|
@ -565,22 +576,23 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
e.setOrgType(IcCommunitySelfOrganizationConstant.ORG_TYPE_AGENCY); |
|
|
|
e.setPid(agencyInfo.getPid()); |
|
|
|
e.setPids(agencyInfo.getPids()); |
|
|
|
e.setOrganizationCreatedTime(StringUtils.isNotBlank(l.getOrganizationCreatedTime()) ? DateUtils.parse(l.getOrganizationCreatedTime(), DATE_PATTERN) : new Date()); |
|
|
|
e.setOrganizationCreatedTime(StringUtils.isNotBlank(l.getOrganizationCreatedTime()) ? DateUtils.stringToDate(l.getOrganizationCreatedTime(), DATE_PATTERN) : new Date()); |
|
|
|
//赋值分类编码,excel输入的是分类名称,需要找到admin字典库中的key
|
|
|
|
String categoryName=l.getCategoryCode(); |
|
|
|
for (String key : categoryMap.keySet()) { |
|
|
|
log.info("*******key="+key+";categoryMap.get(key)="+categoryMap.get(key)+";e.getCategoryCode()="+e.getCategoryCode()); |
|
|
|
if (StringUtils.isNotBlank(categoryMap.get(key)) && categoryMap.get(key).equals(e.getCategoryCode())) { |
|
|
|
if (StringUtils.isNotBlank(categoryMap.get(key)) && categoryMap.get(key).equals(categoryName)) { |
|
|
|
e.setCategoryCode(key); |
|
|
|
break; |
|
|
|
}else{ |
|
|
|
e.setCategoryCode(StrConstant.EPMETY_STR); |
|
|
|
} |
|
|
|
} |
|
|
|
//未匹配到分类默认是其他
|
|
|
|
if(categoryName.equals(e.getCategoryCode())){ |
|
|
|
e.setCategoryCode(SelfOrgCategoryEnum.OTHER.getCode()); |
|
|
|
} |
|
|
|
List<IcCommunitySelfOrganizationPersonnelEntity> persons = new ArrayList<>(); |
|
|
|
AtomicReference<Boolean> bl = new AtomicReference<>(false); |
|
|
|
StringBuffer msg = new StringBuffer(""); |
|
|
|
if (CollectionUtils.isNotEmpty(l.getPersons())){ |
|
|
|
l.getPersons().forEach(p -> { |
|
|
|
/*l.getPersons().forEach(p -> { |
|
|
|
boolean m = PhoneValidatorUtils.isMobile(p.getPersonPhone()); |
|
|
|
boolean t = PhoneValidatorUtils.isTel(p.getPersonPhone()); |
|
|
|
if (!m && !t){ |
|
|
@ -590,7 +602,7 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo |
|
|
|
return; |
|
|
|
//throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode());
|
|
|
|
} |
|
|
|
}); |
|
|
|
});*/ |
|
|
|
persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class); |
|
|
|
Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone)); |
|
|
|
List<String> phones = new ArrayList<>(); |
|
|
|