From 849ee6b0cb34f3c2e400d596da7384ce57721eb0 Mon Sep 17 00:00:00 2001
From: Null <281575458@qq.com>
Date: 星期四, 18 三月 2021 10:03:15 +0800
Subject: [PATCH] 车辆导入

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java
index f5b561c..6ad23d7 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java
@@ -24,9 +24,7 @@
 import org.springframework.util.ObjectUtils;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * @description:
@@ -42,6 +40,7 @@
     private ComMngStructAreaDAO comMngStructAreaDAO;
     @Resource
     private UserService userService;
+
 
     @Override
     public R addComMngCarApplet(ComMngCarAppletDTO comCvtBusinessDTO) {
@@ -140,13 +139,27 @@
 
     @Override
     public R listSaveMngCarExcelVO(List<ComMngCarExcelVO> list, Long communityId) {
+        //获取社区下所有的小区
+        List<ComMngStructAreaDO> comMngStructAreaDOs = comMngStructAreaDAO.selectList(new QueryWrapper<ComMngStructAreaDO>().lambda().eq(ComMngStructAreaDO::getCommunityId,communityId));
+        Map<String,ComMngStructAreaDO> areaMap = new HashMap<>(comMngStructAreaDOs.size());
+        comMngStructAreaDOs.forEach(comMngStructAreaDO->{
+            areaMap.put(comMngStructAreaDO.getAreaName(),comMngStructAreaDO);
+        });
         List<ComMngCarDO> comMngCarDOS = new ArrayList<>();
         list.forEach(vo->{
             int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>()
                     .lambda().eq(ComMngCarDO::getPlateNum, vo.getPlateNum()).and(wrapper->wrapper.eq(ComMngCarDO::getSource,2)));
-            if(count==0){
+            if(count==0 && areaMap.containsKey(vo.getAreaName())){
                 ComMngCarDO comMngCarDO = new ComMngCarDO();
                 BeanUtils.copyProperties(vo,comMngCarDO);
+                comMngCarDO.setCommunityId(communityId);
+                comMngCarDO.setAreaId(areaMap.get(vo.getAreaName()).getId());
+                R<SysUserVO> sysUserVOR = userService.getSysUserVOByPhone(vo.getMobile());
+                if(R.isOk(sysUserVOR)){
+                    SysUserVO sysUserVO = JSONObject.parseObject(JSONObject.toJSONString(sysUserVOR.getData()),SysUserVO.class);
+                    comMngCarDO.setUserId(sysUserVO.getUserId());
+                }
+                comMngCarDO.setSource(2);
                 comMngCarDOS.add(comMngCarDO);
             }
         });

--
Gitblit v1.7.1