|
|
@ -35,6 +35,9 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class PropertyManagementServiceImpl implements PropertyManagementService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 物业表 |
|
|
|
*/ |
|
|
|
@Resource |
|
|
|
private IcPropertyManagementDao icPropertyManagementDao; |
|
|
|
@Resource |
|
|
@ -62,6 +65,7 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
|
/** |
|
|
|
* 新增物业 |
|
|
|
* 名称客户下唯一 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -73,15 +77,25 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
|
formDTO.setName(formDTO.getName().trim()); |
|
|
|
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(formDTO.getCustomerId(), formDTO.getName(), null); |
|
|
|
if (null != entity) { |
|
|
|
return entity.getId(); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "物业名称已存在", "物业名称已存在"); |
|
|
|
} |
|
|
|
IcPropertyManagementEntity icPropertyManagementEntity = ConvertUtils.sourceToTarget(formDTO, IcPropertyManagementEntity.class); |
|
|
|
icPropertyManagementDao.insert(icPropertyManagementEntity); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getNeighborHoodIdList())) { |
|
|
|
formDTO.getNeighborHoodIdList().forEach(neighborHoodId -> { |
|
|
|
// 插入小区物业关系表
|
|
|
|
IcNeighborHoodPropertyEntity neighborHoodPropertyEntity = new IcNeighborHoodPropertyEntity(); |
|
|
|
neighborHoodPropertyEntity.setPropertyId(icPropertyManagementEntity.getId()); |
|
|
|
neighborHoodPropertyEntity.setNeighborHoodId(neighborHoodId); |
|
|
|
icNeighborHoodPropertyDao.insert(neighborHoodPropertyEntity); |
|
|
|
}); |
|
|
|
} |
|
|
|
return icPropertyManagementEntity.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 物业管理-修改 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
@Override |
|
|
@ -99,6 +113,20 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
|
.set(IcPropertyManagementEntity::getUpdatedTime, new Date()) |
|
|
|
.set(IcPropertyManagementEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId()); |
|
|
|
icPropertyManagementDao.update(null, updateWrapper); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getNeighborHoodIdList())) { |
|
|
|
formDTO.getNeighborHoodIdList().forEach(neighborHoodId -> { |
|
|
|
LambdaQueryWrapper<IcNeighborHoodPropertyEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(IcNeighborHoodPropertyEntity::getPropertyId, formDTO.getId()) |
|
|
|
.eq(IcNeighborHoodPropertyEntity::getNeighborHoodId, neighborHoodId); |
|
|
|
if (icNeighborHoodPropertyDao.selectCount(queryWrapper) < 1) { |
|
|
|
// 插入小区物业关系表
|
|
|
|
IcNeighborHoodPropertyEntity neighborHoodPropertyEntity = new IcNeighborHoodPropertyEntity(); |
|
|
|
neighborHoodPropertyEntity.setPropertyId(formDTO.getId()); |
|
|
|
neighborHoodPropertyEntity.setNeighborHoodId(neighborHoodId); |
|
|
|
icNeighborHoodPropertyDao.insert(neighborHoodPropertyEntity); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -140,11 +168,33 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
|
.map(IcNeighborHoodDTO::getNeighborHoodName) |
|
|
|
.distinct().collect(Collectors.toList()); |
|
|
|
result.setNeighborHoodNames(CollectionUtils.isNotEmpty(neighborHoodList) ? StringUtils.join(neighborHoodNames, StrConstant.COMMA_ZH) : StrConstant.EPMETY_STR); |
|
|
|
result.setNeighborHoodList(neighborHoodList); |
|
|
|
}); |
|
|
|
} |
|
|
|
return new PageData<>(list, pageInfo.getTotal(), pageSize); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查看物业详情 |
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public IcPropertyManagementDTO getDetail(String id) { |
|
|
|
IcPropertyManagementEntity icPropertyManagementEntity = icPropertyManagementDao.selectById(id); |
|
|
|
if (null == icPropertyManagementEntity) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
IcPropertyManagementDTO resultDto = ConvertUtils.sourceToTarget(icPropertyManagementEntity, IcPropertyManagementDTO.class); |
|
|
|
List<IcNeighborHoodDTO> neighborHoodList = icNeighborHoodPropertyDao.getNeighborHoodList(id); |
|
|
|
List<String> neighborHoodNames = neighborHoodList.stream() |
|
|
|
.map(IcNeighborHoodDTO::getNeighborHoodName) |
|
|
|
.distinct().collect(Collectors.toList()); |
|
|
|
resultDto.setNeighborHoodNames(CollectionUtils.isNotEmpty(neighborHoodList) ? StringUtils.join(neighborHoodNames, StrConstant.COMMA_ZH) : StrConstant.EPMETY_STR); |
|
|
|
resultDto.setNeighborHoodList(neighborHoodList); |
|
|
|
return resultDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|