From dedb6f26be813caaa0d6ec828d39deaa18fddcb3 Mon Sep 17 00:00:00 2001
From: xyh <18782104331@139.com>
Date: 星期三, 16 六月 2021 20:17:31 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/test_excel610' into test_excel610

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActBuildingServiceImpl.java |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActBuildingServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActBuildingServiceImpl.java
index 77d75e2..aefbe50 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActBuildingServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActBuildingServiceImpl.java
@@ -1,11 +1,14 @@
 package com.panzhihua.service_community.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.panzhihua.common.model.vos.R;
 import com.panzhihua.common.model.vos.community.ComMngBuildingExcelVO;
+import com.panzhihua.common.model.vos.community.ComMngPopulationImportErrorVO;
 import com.panzhihua.common.utlis.Snowflake;
+import com.panzhihua.common.utlis.StringUtils;
 import com.panzhihua.service_community.dao.ComActDAO;
 import com.panzhihua.service_community.dao.ComActVillageDAO;
 import com.panzhihua.service_community.dao.ComMngBuildingDAO;
@@ -38,29 +41,45 @@
     private GridBuildRelationService gridBuildRelationService;
 
     @Override
-    public R batchSaveBuilding(List<ComMngBuildingExcelVO> newVoList, Long communityId, Long streetId) {
+    public R batchSaveBuilding(List<ComMngBuildingExcelVO> newVoList, Long communityId) {
         ArrayList<ComMngBuildingDO> list = Lists.newArrayList();
         List<GridBuildRelationDO> keyList = new ArrayList<>();
-        for (ComMngBuildingExcelVO vo : newVoList) {
-
-            ComMngVillageDO comMngVillageDO = comActVillageDAO.selectOne(new QueryWrapper<ComMngVillageDO>().eq("alley", vo.getAlley()).eq("house_num", vo.getDoorNo()).eq("community_id", communityId));
-            if (comMngVillageDO == null) {
+        List<ComMngPopulationImportErrorVO> errorList = new ArrayList<>();
+        ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
+        importErrorVO.setErrorMsg("重复楼栋");
+        StringBuilder sb = new StringBuilder();
+        for(ComMngBuildingExcelVO vo:newVoList){
+            ComMngVillageDO comMngVillageDO = comActVillageDAO.selectOne(new QueryWrapper<ComMngVillageDO>().eq("alley",vo.getAlley()).eq("house_num",vo.getDoorNo()).eq("community_id",communityId));
+            if(comMngVillageDO == null){
+                continue;
+            }
+            List<ComMngBuildingDO> buildingDOList = this.baseMapper.selectList(new QueryWrapper<ComMngBuildingDO>().eq("street_id",comMngVillageDO.getStreetId()).eq("act_id",communityId).eq("village_id",comMngVillageDO.getVillageId()).eq("name",vo.getName()));
+            if(buildingDOList.size() > 0){
+                sb.append("街路巷:").append(vo.getAlley()).append(",门牌号:").append(vo.getDoorNo()).append(",楼栋号:").append(vo.getName()).append(";");
                 continue;
             }
             ComMngBuildingDO comMngBuildingDO = new ComMngBuildingDO();
-            BeanUtils.copyProperties(vo, comMngBuildingDO);
+            BeanUtils.copyProperties(vo,comMngBuildingDO);
             comMngBuildingDO.setActId(comMngVillageDO.getCommunityId());
             comMngBuildingDO.setStreetId(comMngVillageDO.getStreetId());
             comMngBuildingDO.setVillageId(comMngVillageDO.getVillageId());
             ComActDO actDO = comActDAO.selectById(comMngVillageDO.getCommunityId());
             StringBuilder path = new StringBuilder();
-            path.append(vo.getAlley()).append(">").append(actDO.getName()).append(vo.getVillageName()).append(">").append(vo.getName());
+            path.append(vo.getAlley()).append(">").append(actDO.getName()).append(comMngVillageDO.getName()).append(">").append(vo.getName());
             comMngBuildingDO.setPath(path.toString());
             comMngBuildingDO.setGridId(vo.getGridId());
             list.add(comMngBuildingDO);
-            GridBuildRelationDO gridBuildRelation = getGridBuildRelationDO(communityId, streetId, vo, comMngBuildingDO);
+            GridBuildRelationDO gridBuildRelation = getGridBuildRelationDO(communityId, comMngVillageDO.getStreetId(), vo, comMngBuildingDO);
             keyList.add(gridBuildRelation);
         }
+
+        if(list.size()>0){
+            this.saveBatch(list);
+        }
+        if(sb.length() > 0 && !StringUtils.isEmpty(sb.toString())){
+            errorList.add(importErrorVO);
+            return R.fail(JSON.toJSONString(errorList));
+        }
         gridBuildRelationService.saveBatchGridBuildRelation(keyList);
         this.saveBatch(list);
         return R.ok();

--
Gitblit v1.7.1