|
@ -1,19 +1,24 @@ |
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
import com.epmet.dao.IcNeighborHoodPropertyDao; |
|
|
import com.epmet.dao.IcNeighborHoodPropertyDao; |
|
|
import com.epmet.dao.IcPropertyManagementDao; |
|
|
import com.epmet.dao.IcPropertyManagementDao; |
|
|
|
|
|
import com.epmet.dto.IcPropertyManagementDTO; |
|
|
import com.epmet.dto.form.IcPropertyManagementFormDTO; |
|
|
import com.epmet.dto.form.IcPropertyManagementFormDTO; |
|
|
import com.epmet.dto.result.IcPropertyManagementResultDTO; |
|
|
import com.epmet.dto.result.IcPropertyManagementResultDTO; |
|
|
import com.epmet.entity.IcNeighborHoodPropertyEntity; |
|
|
import com.epmet.entity.IcNeighborHoodPropertyEntity; |
|
|
import com.epmet.entity.IcPropertyManagementEntity; |
|
|
import com.epmet.entity.IcPropertyManagementEntity; |
|
|
import com.epmet.service.PropertyManagementService; |
|
|
import com.epmet.service.PropertyManagementService; |
|
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
@ -28,9 +33,15 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
@Resource |
|
|
@Resource |
|
|
private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao; |
|
|
private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查询当前客户下的物业 |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<IcPropertyManagementResultDTO> getList() { |
|
|
public List<IcPropertyManagementResultDTO> getList() { |
|
|
List<IcPropertyManagementEntity> propertyManagementEntityList = icPropertyManagementDao.selectList(null); |
|
|
LambdaQueryWrapper<IcPropertyManagementEntity> queryWrapper=new LambdaQueryWrapper<>(); |
|
|
|
|
|
queryWrapper.eq(IcPropertyManagementEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
|
|
|
|
|
List<IcPropertyManagementEntity> propertyManagementEntityList = icPropertyManagementDao.selectList(queryWrapper); |
|
|
List<IcPropertyManagementResultDTO> list = new ArrayList<>(); |
|
|
List<IcPropertyManagementResultDTO> list = new ArrayList<>(); |
|
|
propertyManagementEntityList.forEach(item->{ |
|
|
propertyManagementEntityList.forEach(item->{ |
|
|
IcPropertyManagementResultDTO propertyManagementResultDTO = new IcPropertyManagementResultDTO(); |
|
|
IcPropertyManagementResultDTO propertyManagementResultDTO = new IcPropertyManagementResultDTO(); |
|
@ -41,13 +52,19 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 新增物业 |
|
|
|
|
|
* 名称客户下唯一 |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public String add(IcPropertyManagementFormDTO formDTO) { |
|
|
public String add(IcPropertyManagementFormDTO formDTO) { |
|
|
//物业名字平台内唯一
|
|
|
//物业名字平台内唯一
|
|
|
//如果输入的物业名字已经存在,直接返回物业id
|
|
|
//如果输入的物业名字已经存在,直接返回物业id
|
|
|
formDTO.setName(formDTO.getName().trim()); |
|
|
formDTO.setName(formDTO.getName().trim()); |
|
|
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(formDTO.getName()); |
|
|
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(formDTO.getCustomerId(),formDTO.getName(),null); |
|
|
if (null != entity) { |
|
|
if (null != entity) { |
|
|
return entity.getId(); |
|
|
return entity.getId(); |
|
|
} |
|
|
} |
|
@ -59,17 +76,34 @@ public class PropertyManagementServiceImpl implements PropertyManagementService |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void update(IcPropertyManagementFormDTO formDTO) { |
|
|
public void update(IcPropertyManagementFormDTO formDTO) { |
|
|
|
|
|
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(EpmetRequestHolder.getLoginUserCustomerId(),formDTO.getName(),formDTO.getId()); |
|
|
|
|
|
if (null != entity) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"物业名称已存在","物业名称已存在"); |
|
|
|
|
|
} |
|
|
IcPropertyManagementEntity icPropertyManagementEntity = ConvertUtils.sourceToTarget(formDTO, IcPropertyManagementEntity.class); |
|
|
IcPropertyManagementEntity icPropertyManagementEntity = ConvertUtils.sourceToTarget(formDTO, IcPropertyManagementEntity.class); |
|
|
icPropertyManagementDao.updateById(icPropertyManagementEntity); |
|
|
icPropertyManagementDao.updateById(icPropertyManagementEntity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 单个删除 |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void delete(IcPropertyManagementFormDTO formDTO) { |
|
|
public void delete(IcPropertyManagementFormDTO formDTO) { |
|
|
List<IcNeighborHoodPropertyEntity> list = icNeighborHoodPropertyDao.selectList(new QueryWrapper<IcNeighborHoodPropertyEntity>().lambda().eq(IcNeighborHoodPropertyEntity::getPropertyId, formDTO.getId())); |
|
|
LambdaQueryWrapper<IcNeighborHoodPropertyEntity> queryWrapper=new LambdaQueryWrapper<>(); |
|
|
if(!CollectionUtils.isEmpty(list)){ |
|
|
queryWrapper.eq(IcNeighborHoodPropertyEntity::getPropertyId,formDTO.getId()); |
|
|
throw new RenException("物业存在与小区关联,无法删除"); |
|
|
if (icNeighborHoodPropertyDao.selectCount(queryWrapper) > 0) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"物业存在与小区关联,无法删除","已与小区关联,无法删除"); |
|
|
} |
|
|
} |
|
|
icPropertyManagementDao.deleteById(formDTO.getId()); |
|
|
icPropertyManagementDao.deleteById(formDTO.getId()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public PageData<IcPropertyManagementDTO> page(Integer pageNo, Integer pageSize, String name) { |
|
|
|
|
|
PageHelper.startPage(pageNo,pageSize); |
|
|
|
|
|
List<IcPropertyManagementDTO> list=icPropertyManagementDao.queryList(EpmetRequestHolder.getLoginUserCustomerId(),name); |
|
|
|
|
|
PageInfo<IcPropertyManagementDTO> pageInfo = new PageInfo<>(list); |
|
|
|
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|