|
|
@ -133,9 +133,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result editAgency(EditAgencyFormDTO formDTO) { |
|
|
|
Result result = new Result(); |
|
|
|
CustomerAgencyEntity entity = new CustomerAgencyEntity(); |
|
|
|
entity.setId(formDTO.getAgencyId()); |
|
|
|
entity.setOrganizationName(formDTO.getAgencyName()); |
|
|
|
CustomerAgencyEntity entity = getUpdateEntity(formDTO); |
|
|
|
//1:更新当前组织信息
|
|
|
|
if (customerAgencyDao.updateById(entity) < NumConstant.ONE) { |
|
|
|
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|
@ -152,7 +150,6 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
List<CustomerAgencyEntity> editList = new ArrayList<>(); |
|
|
|
Date date = new Date(); |
|
|
|
agencyList.forEach(agency->{ |
|
|
|
CustomerAgencyEntity customerAgencyEntity = new CustomerAgencyEntity(); |
|
|
|
//3-1:查询当前组织的所有上级组织
|
|
|
|
List<String> listStr = Arrays.asList(agency.getPids().split(":")); |
|
|
|
List<ParentListResultDTO> parentList = customerAgencyDao.selectPAgencyById(listStr); |
|
|
@ -165,10 +162,20 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
allParentName.append("-").append(parents.getName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
customerAgencyEntity.setId(agency.getId()); |
|
|
|
CustomerAgencyEntity customerAgencyEntity = ConvertUtils.sourceToTarget(agency,CustomerAgencyEntity.class); |
|
|
|
customerAgencyEntity.setAllParentName(allParentName.toString()); |
|
|
|
customerAgencyEntity.setUpdatedBy(formDTO.getUserId()); |
|
|
|
customerAgencyEntity.setUpdatedTime(date); |
|
|
|
if (CustomerAgencyConstant.PROVINCE_LEVEL.equals(entity.getLevel())) { |
|
|
|
customerAgencyEntity.setProvince(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.CITY_LEVEL.equals(entity.getLevel())) { |
|
|
|
customerAgencyEntity.setCity(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.DISTRICT.equals(entity.getLevel())) { |
|
|
|
customerAgencyEntity.setDistrict(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.STREET_LEVEL.equals(entity.getLevel())) { |
|
|
|
customerAgencyEntity.setStreet(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.COMMUNITY_LEVEL.equals(entity.getLevel())) { |
|
|
|
customerAgencyEntity.setCommunity(entity.getOrganizationName()); |
|
|
|
} |
|
|
|
editList.add(customerAgencyEntity); |
|
|
|
}); |
|
|
|
//4:批量更新因一个组织名称变动而引起的其他组织字段值的变动
|
|
|
@ -182,6 +189,23 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private CustomerAgencyEntity getUpdateEntity(EditAgencyFormDTO formDTO) { |
|
|
|
CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getAgencyId()); |
|
|
|
entity.setOrganizationName(formDTO.getAgencyName()); |
|
|
|
if (CustomerAgencyConstant.PROVINCE_LEVEL.equals(entity.getLevel())) { |
|
|
|
entity.setProvince(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.CITY_LEVEL.equals(entity.getLevel())) { |
|
|
|
entity.setCity(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.DISTRICT.equals(entity.getLevel())) { |
|
|
|
entity.setDistrict(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.STREET_LEVEL.equals(entity.getLevel())) { |
|
|
|
entity.setStreet(entity.getOrganizationName()); |
|
|
|
} else if (CustomerAgencyConstant.COMMUNITY_LEVEL.equals(entity.getLevel())) { |
|
|
|
entity.setCommunity(entity.getOrganizationName()); |
|
|
|
} |
|
|
|
return entity; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|