From b9ee8fe325fa9746b284d3487df96d93d84d6473 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期三, 12 五月 2021 18:05:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/test' into test
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVillageServiceImpl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 97 insertions(+), 16 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 2fce7d1..da1869d 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
@@ -5,21 +5,24 @@
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.common.model.vos.community.ComStreetVO;
import com.panzhihua.service_community.dao.ComActDAO;
-import com.panzhihua.service_community.dao.ComMngVillageDAO;
+import com.panzhihua.service_community.dao.ComActVillageDAO;
+import com.panzhihua.service_community.dao.ComMngPopulationDAO;
import com.panzhihua.service_community.model.dos.ComActDO;
+import com.panzhihua.service_community.model.dos.ComMngPopulationDO;
import com.panzhihua.service_community.model.dos.ComMngVillageDO;
-import com.panzhihua.service_community.model.dos.ComStreetDO;
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.List;
/**
@@ -27,25 +30,36 @@
* @description: 实有房屋
**/
@Service
-public class ComMngVillageServiceImpl implements ComMngVillageService {
+public class ComMngVillageServiceImpl extends ServiceImpl<ComActVillageDAO, ComMngVillageDO> implements ComMngVillageService {
@Resource
- ComMngVillageDAO comMngVillageDAO;
+ ComActVillageDAO comActVillageDAO;
+ @Resource
+ ComActDAO comActDAO;
+ @Resource
+ ComMngPopulationDAO populationDAO;
@Override
- public R addComMngVillage(ComMngVillageVO comMngVillageVO) {
+ public R addComActVillage(ComMngVillageVO comMngVillageVO) {
ComMngVillageDO comMngVillageDO = new ComMngVillageDO();
LambdaQueryWrapper<ComMngVillageDO> param = new QueryWrapper<ComMngVillageDO>().lambda();
param.eq(ComMngVillageDO::getCommunityId, comMngVillageVO.getCommunityId());
- Integer resultCount = comMngVillageDAO.selectCount(param);
+ 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);
- int insert = comMngVillageDAO.insert(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());
param.eq(ComMngVillageDO::getHouseNum, comMngVillageVO.getHouseNum());
- ComMngVillageDO comMngVillageDO1 = comMngVillageDAO.selectOne(param);
+ ComMngVillageDO comMngVillageDO1 = comActVillageDAO.selectOne(param);
BeanUtils.copyProperties(comMngVillageDO1, comMngVillageVO);
return R.ok(comMngVillageVO);
}
@@ -53,19 +67,19 @@
}
@Override
- public R listComMngVillage(ComMngVillageVO comMngVillageVO) {
+ public R listComActVillage(ComMngVillageVO comMngVillageVO) {
List<ComMngVillageDO> vos = Lists.newArrayList();
LambdaQueryWrapper<ComMngVillageDO> param = new QueryWrapper<ComMngVillageDO>().lambda();
param.eq(ComMngVillageDO::getAlley, comMngVillageVO.getAlley());
param.eq(ComMngVillageDO::getCommunityId, comMngVillageVO.getCommunityId());
- List<ComMngVillageDO> comMngVillageDOS = comMngVillageDAO.selectList(param);
+ List<ComMngVillageDO> comMngVillageDOS = comActVillageDAO.selectList(param);
BeanUtils.copyProperties(vos, comMngVillageDOS);
return R.ok(vos);
}
@Override
- public R pageComMngVillage(PageComMngVillageDTO pageComMngVillageDTO) {
+ public R pageComActVillage(PageComMngVillageDTO pageComMngVillageDTO) {
Page page = new Page<>();
Long pageNum = pageComMngVillageDTO.getPageNum();
Long pageSize = pageComMngVillageDTO.getPageSize();
@@ -78,20 +92,87 @@
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 = comMngVillageDAO.selectPage(userPage, userLambdaQueryWrapper);
+ IPage<ComMngVillageDO> doPager = comActVillageDAO.selectPage(userPage, userLambdaQueryWrapper.orderByDesc(ComMngVillageDO::getCreateAt));
return R.ok(doPager);
}
@Override
- public R delecComMngVillage(List<Long> Ids) {
- int delete = comMngVillageDAO.deleteBatchIds(Ids);
+ 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());
+ }
+
+ @Override
+ public R editVillage(Long villageId, ComMngVillageVO comMngVillageVO) {
+ ComMngVillageDO comMngVillageDO = this.baseMapper.selectById(villageId);
+ if (comMngVillageDO == null) {
+ return R.fail("id有误!");
+ }
+ BeanUtils.copyProperties(comMngVillageVO, comMngVillageDO);
+ ComActDO comActDO = comActDAO.selectById(comMngVillageDO.getCommunityId());
+ if (comActDO == null || comActDO.getStreetId() == null) {
+ return R.fail("社区没有绑定街道,请绑定后操作!");
+ }
+ comMngVillageDO.setStreetId(comActDO.getStreetId());
+ int update = this.baseMapper.update(comMngVillageDO, new LambdaQueryWrapper<ComMngVillageDO>()
+ .eq(ComMngVillageDO::getVillageId, villageId));
+ if(update>0){
+ return R.ok(comMngVillageVO);
+ }
+ return R.fail();
+ }
}
--
Gitblit v1.7.1