|
|
@ -431,21 +431,8 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
} |
|
|
|
AddAgencyResultDTO resultDTO = new AddAgencyResultDTO(); |
|
|
|
resultDTO.setAreaCodeSwitch(formDTO.getAreaCodeSwitch()); |
|
|
|
CustomerAgencyEntity insertEntity=this.constructInsertEntity(formDTO,parent); |
|
|
|
//判断areaCodeSwitch:open: 选择地区编码必填;closed: 无需选择地区编码
|
|
|
|
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); |
|
|
|
insertEntity.setOrganizationName(formDTO.getAgencyName()); |
|
|
|
insertEntity.setTotalUser(NumConstant.ZERO); |
|
|
|
insertEntity.setPid(parent.getId()); |
|
|
|
insertEntity.setCustomerId(parent.getCustomerId()); |
|
|
|
insertEntity.setParentAreaCode(parent.getAreaCode()); |
|
|
|
if (StringUtils.isBlank(parent.getPid()) || NumConstant.ZERO_STR.equals(parent.getPid())) { |
|
|
|
//如果上级是根级组织
|
|
|
|
insertEntity.setPids(parent.getId()); |
|
|
|
insertEntity.setAllParentName(parent.getOrganizationName()); |
|
|
|
} else { |
|
|
|
insertEntity.setPids(parent.getPids().concat(StrConstant.COLON).concat(parent.getId())); |
|
|
|
insertEntity.setAllParentName(parent.getAllParentName().concat(StrConstant.HYPHEN).concat(parent.getOrganizationName())); |
|
|
|
} |
|
|
|
if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) { |
|
|
|
//校验areaCode是否被使用过
|
|
|
|
if (!"other".equals(formDTO.getAreaCode())) { |
|
|
@ -474,4 +461,40 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) { |
|
|
|
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); |
|
|
|
insertEntity.setOrganizationName(formDTO.getAgencyName()); |
|
|
|
insertEntity.setTotalUser(NumConstant.ZERO); |
|
|
|
insertEntity.setPid(parent.getId()); |
|
|
|
insertEntity.setCustomerId(parent.getCustomerId()); |
|
|
|
insertEntity.setParentAreaCode(parent.getAreaCode()); |
|
|
|
if (StringUtils.isBlank(parent.getPid()) || NumConstant.ZERO_STR.equals(parent.getPid())) { |
|
|
|
//如果上级是根级组织
|
|
|
|
insertEntity.setPids(parent.getId()); |
|
|
|
insertEntity.setAllParentName(parent.getOrganizationName()); |
|
|
|
} else { |
|
|
|
insertEntity.setPids(parent.getPids().concat(StrConstant.COLON).concat(parent.getId())); |
|
|
|
insertEntity.setAllParentName(parent.getAllParentName().concat(StrConstant.HYPHEN).concat(parent.getOrganizationName())); |
|
|
|
} |
|
|
|
switch(parent.getLevel()) |
|
|
|
{ |
|
|
|
case CustomerAgencyConstant.PROVINCE_LEVEL: |
|
|
|
insertEntity.setLevel(CustomerAgencyConstant.CITY_LEVEL); |
|
|
|
break; |
|
|
|
case CustomerAgencyConstant.CITY_LEVEL: |
|
|
|
insertEntity.setLevel(CustomerAgencyConstant.DISTRICT); |
|
|
|
break; |
|
|
|
case CustomerAgencyConstant.DISTRICT: |
|
|
|
insertEntity.setLevel(CustomerAgencyConstant.STREET_LEVEL); |
|
|
|
break; |
|
|
|
case CustomerAgencyConstant.STREET_LEVEL: |
|
|
|
insertEntity.setLevel(CustomerAgencyConstant.COMMUNITY_LEVEL); |
|
|
|
break; |
|
|
|
default: |
|
|
|
log.info("parent.getLevel()="+parent.getLevel()); |
|
|
|
break; |
|
|
|
} |
|
|
|
return insertEntity; |
|
|
|
} |
|
|
|
|
|
|
|
} |