|
@ -135,40 +135,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
CustomerAgencyEntity originalEntity = customerAgencyDao.selectById(formDTO.getAgencyId()); |
|
|
CustomerAgencyEntity originalEntity = customerAgencyDao.selectById(formDTO.getAgencyId()); |
|
|
//当前客户下,同级组织中,组织名称不允许重复
|
|
|
//当前客户下,同级组织中,组织名称不允许重复
|
|
|
customerAgencyService.checkAgencyName(formDTO.getAgencyName(),originalEntity.getCustomerId(),originalEntity.getLevel(),originalEntity.getId()); |
|
|
customerAgencyService.checkAgencyName(formDTO.getAgencyName(),originalEntity.getCustomerId(),originalEntity.getLevel(),originalEntity.getId()); |
|
|
|
|
|
|
|
|
if (formDTO.getAreaCodeSwitch().equals(CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN)) { |
|
|
|
|
|
//开关开启,areaCode,areaName必填
|
|
|
|
|
|
if(!formDTO.getAreaCode().equals(originalEntity.getAreaCode())){ |
|
|
|
|
|
//重新选择了新的area_code
|
|
|
|
|
|
CustomerAgencyDTO parent = customerAgencyService.get(originalEntity.getPid()); |
|
|
|
|
|
if (null == parent ||StringUtils.isBlank(parent.getAreaCode())) { |
|
|
|
|
|
throw new RenException(EpmetErrorCode.SET_PARENT_AREA_CODE.getCode(),EpmetErrorCode.SET_PARENT_AREA_CODE.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
originalEntity.setParentAreaCode(parent.getAreaCode()); |
|
|
|
|
|
if (!"other".equals(formDTO.getAreaCode())) { |
|
|
|
|
|
//校验areaCode是否被使用过
|
|
|
|
|
|
List<String> agencyIds = customerAgencyDao.selectAgencyIdsByAreaCode(formDTO.getAreaCode(),formDTO.getAgencyId()); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(agencyIds)) { |
|
|
|
|
|
//已经被占用,提示
|
|
|
|
|
|
throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
originalEntity.setAreaCode(formDTO.getAreaCode()); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//如果选择的是other,需要自定义一个编码
|
|
|
|
|
|
AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO(); |
|
|
|
|
|
addAreaCodeFormDTO.setCurrentAreaLevel(originalEntity.getLevel()); |
|
|
|
|
|
addAreaCodeFormDTO.setParentAreaCode(parent.getAreaCode()); |
|
|
|
|
|
addAreaCodeFormDTO.setName(formDTO.getAgencyName()); |
|
|
|
|
|
Result<String> addAreaCodeResult = epmetCommonServiceOpenFeignClient.addAreaCode(addAreaCodeFormDTO); |
|
|
|
|
|
if (!addAreaCodeResult.success() || StringUtils.isBlank(addAreaCodeResult.getData())) { |
|
|
|
|
|
throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
originalEntity.setAreaCode(addAreaCodeResult.getData()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
originalEntity.setOrganizationName(formDTO.getAgencyName()); |
|
|
originalEntity.setOrganizationName(formDTO.getAgencyName()); |
|
|
|
|
|
|
|
|
//1:更新当前组织信息
|
|
|
//1:更新当前组织信息
|
|
|
if (customerAgencyDao.updateById(originalEntity) < NumConstant.ONE) { |
|
|
if (customerAgencyDao.updateById(originalEntity) < NumConstant.ONE) { |
|
|
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|