|
|
@ -2,6 +2,7 @@ package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
@ -9,6 +10,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
|
import com.epmet.dao.IcNeighborHoodPropertyDao; |
|
|
|
import com.epmet.dao.IcPropertyManagementDao; |
|
|
|
import com.epmet.dto.IcNeighborHoodDTO; |
|
|
|
import com.epmet.dto.IcPropertyManagementDTO; |
|
|
|
import com.epmet.dto.form.IcPropertyManagementFormDTO; |
|
|
|
import com.epmet.dto.result.IcPropertyManagementResultDTO; |
|
|
@ -18,6 +20,8 @@ import com.epmet.service.PropertyManagementService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
@ -25,11 +29,15 @@ import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class PropertyManagementServiceImpl implements PropertyManagementService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 物业表 |
|
|
|
*/ |
|
|
|
@Resource |
|
|
|
private IcPropertyManagementDao icPropertyManagementDao; |
|
|
|
@Resource |
|
|
@ -57,43 +65,68 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
|
/** |
|
|
|
* 新增物业 |
|
|
|
* 名称客户下唯一 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public String add(IcPropertyManagementFormDTO formDTO) { |
|
|
|
//物业名字平台内唯一
|
|
|
|
//如果输入的物业名字已经存在,直接返回物业id
|
|
|
|
// 物业名字平台内唯一
|
|
|
|
// 如果输入的物业名字已经存在,直接返回物业id
|
|
|
|
formDTO.setName(formDTO.getName().trim()); |
|
|
|
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(formDTO.getCustomerId(),formDTO.getName(),null); |
|
|
|
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 |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(IcPropertyManagementFormDTO formDTO) { |
|
|
|
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(EpmetRequestHolder.getLoginUserCustomerId(),formDTO.getName(),formDTO.getId()); |
|
|
|
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(EpmetRequestHolder.getLoginUserCustomerId(), formDTO.getName(), formDTO.getId()); |
|
|
|
if (null != entity) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"物业名称已存在","物业名称已存在"); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "物业名称已存在", "物业名称已存在"); |
|
|
|
} |
|
|
|
LambdaUpdateWrapper<IcPropertyManagementEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
updateWrapper.eq(IcPropertyManagementEntity::getId, formDTO.getId()) |
|
|
|
.set(IcPropertyManagementEntity::getName, formDTO.getName()) |
|
|
|
.set(IcPropertyManagementEntity::getContactName, formDTO.getContactName()) |
|
|
|
.set(IcPropertyManagementEntity::getContactMobile, formDTO.getContactMobile()) |
|
|
|
.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); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
LambdaUpdateWrapper<IcPropertyManagementEntity> updateWrapper=new LambdaUpdateWrapper<>(); |
|
|
|
updateWrapper.eq(IcPropertyManagementEntity::getId,formDTO.getId()) |
|
|
|
.set(IcPropertyManagementEntity::getName,formDTO.getName()) |
|
|
|
.set(IcPropertyManagementEntity::getContactName,formDTO.getContactName()) |
|
|
|
.set(IcPropertyManagementEntity::getContactMobile,formDTO.getContactMobile()) |
|
|
|
.set(IcPropertyManagementEntity::getUpdatedTime,new Date()) |
|
|
|
.set(IcPropertyManagementEntity::getUpdatedBy,EpmetRequestHolder.getLoginUserId()); |
|
|
|
icPropertyManagementDao.update(null,updateWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -113,16 +146,55 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
|
|
|
|
|
/** |
|
|
|
* 物业管理-列表查询 |
|
|
|
* |
|
|
|
* @param pageNo |
|
|
|
* @param pageSize |
|
|
|
* @param name |
|
|
|
* @param name 物业名称 |
|
|
|
* @param contactName 物业联系人 |
|
|
|
* @param contactMobile 联系电话 |
|
|
|
* @param queryType 列表查询:page-query;导出:export |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<IcPropertyManagementDTO> page(Integer pageNo, Integer pageSize, String name,String contactName,String contactMobile) { |
|
|
|
PageHelper.startPage(pageNo,pageSize); |
|
|
|
List<IcPropertyManagementDTO> list=icPropertyManagementDao.queryList(EpmetRequestHolder.getLoginUserCustomerId(),name,contactName,contactMobile); |
|
|
|
public PageData<IcPropertyManagementDTO> page(Integer pageNo, Integer pageSize, String name, String contactName, String contactMobile, String queryType) { |
|
|
|
PageHelper.startPage(pageNo, pageSize); |
|
|
|
List<IcPropertyManagementDTO> list = icPropertyManagementDao.queryList(EpmetRequestHolder.getLoginUserCustomerId(), name, contactName, contactMobile); |
|
|
|
PageInfo<IcPropertyManagementDTO> pageInfo = new PageInfo<>(list); |
|
|
|
return new PageData<>(list, pageInfo.getTotal(),pageSize); |
|
|
|
// 导出时需要导出关联的小区名称
|
|
|
|
if ("export".equals(queryType)) { |
|
|
|
pageInfo.getList().forEach(result -> { |
|
|
|
List<IcNeighborHoodDTO> neighborHoodList = icNeighborHoodPropertyDao.getNeighborHoodList(result.getId()); |
|
|
|
List<String> neighborHoodNames = neighborHoodList.stream() |
|
|
|
.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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|