| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.panzhihua.service_community.dao.ComMngPopulationHouseUserDAO; |
| | | import com.panzhihua.service_community.model.dos.ComMngPopulationHouseUserDO; |
| | | import com.panzhihua.service_community.service.ComMngPopulationHouseUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComMngPopulationHouseUserServiceImpl extends ServiceImpl<ComMngPopulationHouseUserDAO, ComMngPopulationHouseUserDO> implements ComMngPopulationHouseUserService { |
| | | public class ComMngPopulationHouseUserServiceImpl extends |
| | | ServiceImpl<ComMngPopulationHouseUserDAO, ComMngPopulationHouseUserDO> implements ComMngPopulationHouseUserService { |
| | | |
| | | /** |
| | | * 批量向房屋新增人员 |
| | | * @param housePopulationDTO 请求参数 |
| | | * @return 添加结果 |
| | | * |
| | | * @param housePopulationDTO |
| | | * 请求参数 |
| | | * @return 添加结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R addBuildingHousePopulation(AddComMngHousePopulationDTO housePopulationDTO){ |
| | | public R addBuildingHousePopulation(AddComMngHousePopulationDTO housePopulationDTO) { |
| | | List<ComMngPopulationHouseUserDO> populationHouseUserDOList = new ArrayList<>(); |
| | | if(!housePopulationDTO.getPopulationIds().isEmpty()){ |
| | | if (!housePopulationDTO.getPopulationIds().isEmpty()) { |
| | | housePopulationDTO.getPopulationIds().forEach(housePopulationId -> { |
| | | ComMngPopulationHouseUserDO populationHouseUserDO = this.baseMapper.selectOne( |
| | | new QueryWrapper<ComMngPopulationHouseUserDO>().lambda() |
| | | .eq(ComMngPopulationHouseUserDO::getHouseId,housePopulationDTO.getHouseId()) |
| | | .eq(ComMngPopulationHouseUserDO::getPopulId,housePopulationId)); |
| | | if(populationHouseUserDO == null){ |
| | | ComMngPopulationHouseUserDO populationHouseUserDO = |
| | | this.baseMapper.selectOne(new QueryWrapper<ComMngPopulationHouseUserDO>().lambda() |
| | | .eq(ComMngPopulationHouseUserDO::getHouseId, housePopulationDTO.getHouseId()) |
| | | .eq(ComMngPopulationHouseUserDO::getPopulId, housePopulationId)); |
| | | if (populationHouseUserDO == null) { |
| | | populationHouseUserDO = new ComMngPopulationHouseUserDO(); |
| | | populationHouseUserDO.setId(Snowflake.getId()); |
| | | populationHouseUserDO.setHouseId(housePopulationDTO.getHouseId()); |
| | |
| | | populationHouseUserDO.setRelationId(ComMngPopulationHouseUserDO.relationId.zizhu); |
| | | populationHouseUserDO.setStartAt(new Date()); |
| | | populationHouseUserDO.setCreateAt(new Date()); |
| | | if(housePopulationDTO.getType().equals(AddComMngHousePopulationDTO.type.hz)){ |
| | | if (housePopulationDTO.getType().equals(AddComMngHousePopulationDTO.type.hz)) { |
| | | populationHouseUserDO.setRelation(ComMngPopulationHouseUserDO.relation.hz); |
| | | } |
| | | populationHouseUserDOList.add(populationHouseUserDO); |
| | | }else{ |
| | | if(housePopulationDTO.getType().equals(AddComMngHousePopulationDTO.type.hz)){ |
| | | } else { |
| | | if (housePopulationDTO.getType().equals(AddComMngHousePopulationDTO.type.hz)) { |
| | | populationHouseUserDO.setRelation(ComMngPopulationHouseUserDO.relation.hz); |
| | | } |
| | | populationHouseUserDO.setRelationId(ComMngPopulationHouseUserDO.relationId.zizhu); |
| | |
| | | |
| | | /** |
| | | * 批量删除房屋内人员 |
| | | * @param housePopulationDTO 请求参数 |
| | | * @return 删除结果 |
| | | * |
| | | * @param housePopulationDTO |
| | | * 请求参数 |
| | | * @return 删除结果 |
| | | */ |
| | | @Override |
| | | public R delBuildingHousePopulation(DelComMngHousePopulationDTO housePopulationDTO){ |
| | | public R delBuildingHousePopulation(DelComMngHousePopulationDTO housePopulationDTO) { |
| | | |
| | | ComMngPopulationHouseUserDO houseUserDO = this.baseMapper.selectById(housePopulationDTO.getHousePopulationId()); |
| | | if(houseUserDO == null){ |
| | | if (houseUserDO == null) { |
| | | return R.fail("未查询到居住用户数据"); |
| | | } |
| | | if(housePopulationDTO.getType().equals(DelComMngHousePopulationDTO.type.hz)){ |
| | | if(houseUserDO.getRelationId() == null || !houseUserDO.getRelationId().equals(ComMngPopulationHouseUserDO.relationId.zizhu)){ |
| | | if (housePopulationDTO.getType().equals(DelComMngHousePopulationDTO.type.hz)) { |
| | | if (houseUserDO.getRelationId() == null |
| | | || !houseUserDO.getRelationId().equals(ComMngPopulationHouseUserDO.relationId.zizhu)) { |
| | | this.baseMapper.deleteById(housePopulationDTO.getHousePopulationId()); |
| | | }else{ |
| | | } else { |
| | | this.baseMapper.delBuildingHousePopulationRelation(housePopulationDTO.getHousePopulationId()); |
| | | } |
| | | }else{ |
| | | if(houseUserDO.getRelation() == null || !houseUserDO.getRelation().equals(ComMngPopulationHouseUserDO.relation.hz)){ |
| | | } else { |
| | | if (houseUserDO.getRelation() == null |
| | | || !houseUserDO.getRelation().equals(ComMngPopulationHouseUserDO.relation.hz)) { |
| | | this.baseMapper.deleteById(housePopulationDTO.getHousePopulationId()); |
| | | }else{ |
| | | } else { |
| | | this.baseMapper.delBuildingHousePopulationRelationId(housePopulationDTO.getHousePopulationId()); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R getVillagePopulationHouseAdmin(PageComMngVillagePopulationHouseDTO villagePopulationDTO){ |
| | | return R.ok(this.baseMapper.getVillagePopulationHouseAdmin(new Page(villagePopulationDTO.getPageNum(),villagePopulationDTO.getPageSize()),villagePopulationDTO)); |
| | | public R getVillagePopulationHouseAdmin(PageComMngVillagePopulationHouseDTO villagePopulationDTO) { |
| | | return R.ok(this.baseMapper.getVillagePopulationHouseAdmin( |
| | | new Page(villagePopulationDTO.getPageNum(), villagePopulationDTO.getPageSize()), villagePopulationDTO)); |
| | | } |
| | | |
| | | } |