| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.panzhihua.common.model.dtos.community.PageComMngVillageDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngVillageServeExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngVillageVO; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComActVillageDAO; |
| | | import com.panzhihua.service_community.dao.ComMngPopulationDAO; |
| | | import com.panzhihua.service_community.dao.ComMngVolunteerMngDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ComActDiscussDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngPopulationDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngVillageDO; |
| | | import com.panzhihua.service_community.service.ComMngVillageService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author: llming |
| | | * @description: 实有房屋 |
| | | **/ |
| | | @Service |
| | | public class ComMngVillageServiceImpl implements ComMngVillageService { |
| | | public class ComMngVillageServiceImpl extends ServiceImpl<ComActVillageDAO, ComMngVillageDO> implements ComMngVillageService { |
| | | @Resource |
| | | ComActVillageDAO comActVillageDAO; |
| | | @Resource |
| | | ComActDAO comActDAO; |
| | | @Resource |
| | | ComMngPopulationDAO populationDAO; |
| | | |
| | | @Override |
| | | public R addComActVillage(ComMngVillageVO comMngVillageVO) { |
| | |
| | | LambdaQueryWrapper<ComMngVillageDO> param = new QueryWrapper<ComMngVillageDO>().lambda(); |
| | | param.eq(ComMngVillageDO::getCommunityId, comMngVillageVO.getCommunityId()); |
| | | param.eq(ComMngVillageDO::getAlley, comMngVillageVO.getAlley()); |
| | | param.eq(ComMngVillageDO::getHouseNum, comMngVillageVO.getHouseNum()); |
| | | Integer resultCount = comActVillageDAO.selectCount(param); |
| | | if (resultCount > 0) { |
| | | return R.fail("实有房屋已经存在"); |
| | | } |
| | | BeanUtils.copyProperties(comMngVillageVO, comMngVillageDO); |
| | | ComActDO comActDO = comActDAO.selectById(comMngVillageDO.getCommunityId()); |
| | | if (comActDO == null || comActDO.getStreetId() == null) { |
| | | return R.fail("社区没有绑定街道,请绑定后操作!"); |
| | | } |
| | | comMngVillageDO.setStreetId(comActDO.getStreetId()); |
| | | int insert = comActVillageDAO.insert(comMngVillageDO); |
| | | if (insert > 0) { |
| | | param.eq(ComMngVillageDO::getAlley, comMngVillageVO.getAlley()); |
| | |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | LambdaQueryWrapper<ComMngVillageDO> userLambdaQueryWrapper = Wrappers.lambdaQuery(); |
| | | if (!pageComMngVillageDTO.getAlley().isEmpty()) { |
| | | if(pageComMngVillageDTO.getCommunityId() != null){ |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getCommunityId,pageComMngVillageDTO.getCommunityId()); |
| | | } |
| | | if (pageComMngVillageDTO.getAlley() != null) { |
| | | userLambdaQueryWrapper.like(ComMngVillageDO::getAlley, pageComMngVillageDTO.getAlley()); |
| | | } |
| | | Page userPage = new Page(pageNum, pageSize); |
| | | IPage<ComMngVillageDO> doPager = comActVillageDAO.selectPage(userPage, userLambdaQueryWrapper); |
| | | IPage<ComMngVillageDO> doPager = comActVillageDAO.selectPage(userPage, userLambdaQueryWrapper.orderByDesc(ComMngVillageDO::getCreateAt)); |
| | | return R.ok(doPager); |
| | | } |
| | | |
| | | @Override |
| | | public R delecComActVillage(List<Long> Ids) { |
| | | LambdaQueryWrapper<ComMngPopulationDO> paramWrapper = Wrappers.lambdaQuery(); |
| | | paramWrapper.in(ComMngPopulationDO::getVillageId, Ids); |
| | | ComMngPopulationDO mngPopulationDO = populationDAO.selectOne(paramWrapper); |
| | | if (mngPopulationDO != null) { |
| | | return R.fail("无法删除,已绑定实有人口!"); |
| | | } |
| | | int delete = comActVillageDAO.deleteBatchIds(Ids); |
| | | if (delete > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R listSaveVillage(List<ComMngVillageServeExcelVO> list, Long communityId) { |
| | | //思路:获取社区下所有的实有房屋(小区),打印已经存在的重复数据 |
| | | if (list.size() == 0) { |
| | | return R.fail("数据为空!"); |
| | | } |
| | | List<ComMngVillageDO> comMngVillageDOs = comActVillageDAO.selectList(new QueryWrapper<ComMngVillageDO>().lambda().eq(ComMngVillageDO::getCommunityId, communityId)); |
| | | int index = 2; |
| | | for (ComMngVillageServeExcelVO vo : list) { |
| | | if (vo.getHouseNum() == null) { |
| | | return R.fail("门牌号第" + index + "行为空!"); |
| | | } |
| | | if (vo.getAlley() == null) { |
| | | return R.fail("街路巷第" + index + "行为空!"); |
| | | } |
| | | //判断DB和exel数据重复判断 |
| | | boolean result = comMngVillageDOs.stream().anyMatch(village -> village.getAlley().equals(vo.getAlley()) && village.getHouseNum().intValue() == vo.getHouseNum().intValue()); |
| | | if (result) { |
| | | return R.fail("导入街路巷已存在(" + vo.getAlley() + ")"); |
| | | } |
| | | index++; |
| | | } |
| | | ComActDO comActDO = comActDAO.selectById(communityId); |
| | | if(comActDO.getStreetId()==null||comActDO.getStreetId().toString().equals("")){ |
| | | return R.fail("请绑定街道,再操作!"); |
| | | } |
| | | ArrayList<ComMngVillageDO> comMngVillageDOS = Lists.newArrayList(); |
| | | list.forEach(vo -> { |
| | | ComMngVillageDO comMngVillageDO = new ComMngVillageDO(); |
| | | BeanUtils.copyProperties(vo, comMngVillageDO); |
| | | comMngVillageDO.setCommunityId(comActDO.getCommunityId()); |
| | | comMngVillageDO.setStreetId(comActDO.getStreetId()); |
| | | comMngVillageDOS.add(comMngVillageDO); |
| | | }); |
| | | this.saveBatch(comMngVillageDOS); |
| | | return R.ok("共计导入实有房屋数量:" + comMngVillageDOS.size()); |
| | | } |
| | | } |