From 68d8b72a646b4022e8a842f153ba9475e74803bc Mon Sep 17 00:00:00 2001
From: DESKTOP-71BH0QO\L、ming <172680469@qq.com>
Date: 星期一, 29 三月 2021 16:23:41 +0800
Subject: [PATCH] ADD:实有房屋相关接口

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVillageServiceImpl.java |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 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 4dbf0e4..6437ed0 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,27 +5,39 @@
 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.ComMngVolunteerMngDAO;
+import com.panzhihua.service_community.model.dos.ComActDO;
+import com.panzhihua.service_community.model.dos.ComActDiscussDO;
 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;
 
     @Override
     public R addComActVillage(ComMngVillageVO comMngVillageVO) {
@@ -38,6 +50,8 @@
             return R.fail("实有房屋已经存在");
         }
         BeanUtils.copyProperties(comMngVillageVO, comMngVillageDO);
+        ComActDO comActDO = comActDAO.selectById(comMngVillageDO.getCommunityId());
+        comMngVillageDO.setStreetId(comActDO.getStreetId());
         int insert = comActVillageDAO.insert(comMngVillageDO);
         if (insert > 0) {
             param.eq(ComMngVillageDO::getAlley, comMngVillageVO.getAlley());
@@ -75,7 +89,7 @@
         page.setSize(pageSize);
         page.setCurrent(pageNum);
         LambdaQueryWrapper<ComMngVillageDO> userLambdaQueryWrapper = Wrappers.lambdaQuery();
-        if (!pageComMngVillageDTO.getAlley().isEmpty()) {
+        if (pageComMngVillageDTO.getAlley() != null) {
             userLambdaQueryWrapper.like(ComMngVillageDO::getAlley, pageComMngVillageDTO.getAlley());
         }
         Page userPage = new Page(pageNum, pageSize);
@@ -91,4 +105,23 @@
         }
         return R.fail();
     }
+
+    @Override
+    public R listSaveVillage(List<ComMngVillageServeExcelVO> list, Long communityId) {
+        //获取社区下所有的实有房屋(小区),打印已经存在的重复数据
+        List<ComMngVillageDO> comMngVillageDOs = comActVillageDAO.selectList(new QueryWrapper<ComMngVillageDO>().lambda().eq(ComMngVillageDO::getCommunityId, communityId));
+        List<String> alleyList = list.stream().map(vo -> vo.getAlley()).collect(Collectors.toList());
+        List<Integer> houseNumList = list.stream().map(vo -> vo.getHouseNum()).collect(Collectors.toList());
+        List<ComMngVillageDO> resultList = comMngVillageDOs.stream().filter(village -> alleyList.contains(village.getAlley()) && houseNumList.contains(village.getAlley())).collect(Collectors.toList());
+        if (resultList != null && resultList.size() > 0) {
+            List<String> repeatList = resultList.stream().map(ComMngVillageDO::getAlley).collect(Collectors.toList());
+            return R.fail("导入实有房屋,存在数据重复:" + repeatList.toArray());
+        }
+        ArrayList<ComMngVillageDO> comMngVillageDOS = Lists.newArrayList();
+        BeanUtils.copyProperties(list, comMngVillageDOS);
+        /*this.saveBatch(comMngCarDOS);
+        return R.ok("共计导入车辆数量:" + comMngCarDOS.size());*/
+        System.out.println(comMngVillageDOS);
+        return null;
+    }
 }

--
Gitblit v1.7.1