From ae30ebfc3e4a38aed0d91a42da4a1544dbd87ba3 Mon Sep 17 00:00:00 2001 From: CeDo <cedoogle@gmail.com> Date: 星期四, 15 四月 2021 12:10:06 +0800 Subject: [PATCH] 社会调查问卷添加默认参数 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVillageServiceImpl.java | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVillageServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVillageServiceImpl.java index 227a37a..0770984 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVillageServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVillageServiceImpl.java @@ -13,9 +13,11 @@ 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; @@ -38,6 +40,8 @@ ComActVillageDAO comActVillageDAO; @Resource ComActDAO comActDAO; + @Resource + ComMngPopulationDAO populationDAO; @Override public R addComActVillage(ComMngVillageVO comMngVillageVO) { @@ -45,6 +49,7 @@ 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("实有房屋已经存在"); @@ -93,12 +98,18 @@ 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(); @@ -109,10 +120,10 @@ @Override public R listSaveVillage(List<ComMngVillageServeExcelVO> list, Long communityId) { //思路:获取社区下所有的实有房屋(小区),打印已经存在的重复数据 - List<ComMngVillageDO> comMngVillageDOs = comActVillageDAO.selectList(new QueryWrapper<ComMngVillageDO>().lambda().eq(ComMngVillageDO::getCommunityId, 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) { @@ -122,9 +133,9 @@ return R.fail("街路巷第" + index + "行为空!"); } //判断DB和exel数据重复判断 - boolean result = comMngVillageDOs.stream().allMatch(village -> village.getAlley().equals(vo.getAlley()) && village.getHouseNum().equals(vo.getHouseNum())); + boolean result = comMngVillageDOs.stream().anyMatch(village -> village.getAlley().equals(vo.getAlley()) && village.getHouseNum().intValue() == vo.getHouseNum().intValue()); if (result) { - return R.fail("导入街路巷已存在(" + vo.getAlley()+")"); + return R.fail("导入街路巷已存在(" + vo.getAlley() + ")"); } index++; } -- Gitblit v1.7.1