From b5ea43a2f02e7e26c9ff7a1f49b8129b356c40c5 Mon Sep 17 00:00:00 2001
From: DESKTOP-71BH0QO\L、ming <172680469@qq.com>
Date: 星期三, 07 四月 2021 11:13:48 +0800
Subject: [PATCH] fix:修改bug

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealCompanyServiceImpl.java |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealCompanyServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealCompanyServiceImpl.java
index 6ff8af5..0eb225b 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealCompanyServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealCompanyServiceImpl.java
@@ -27,7 +27,7 @@
  * @date: 2021/3/19 11:55
  */
 @Service
-public class ComMngRealCompanyServiceImpl extends ServiceImpl<ComMngRealCompanyDAO, ComMngRealCompanyDO>  implements ComMngRealCompanyService {
+public class ComMngRealCompanyServiceImpl extends ServiceImpl<ComMngRealCompanyDAO, ComMngRealCompanyDO> implements ComMngRealCompanyService {
 
     @Resource
     private ComMngRealCompanyDAO comMngRealCompanyDAO;
@@ -51,32 +51,32 @@
 
     @Override
     public R saveComMngRealCompany(ComMngRealCompanyVO comMngRealCompanyVO) {
-        if(null!=comMngRealCompanyVO.getId() && comMngRealCompanyVO.getId()!=0){
+        if (null != comMngRealCompanyVO.getId() && comMngRealCompanyVO.getId() != 0) {
             //修改
             ComMngRealCompanyDO comMngRealCompanyDO = comMngRealCompanyDAO.selectById(comMngRealCompanyVO.getId());
-            if(null==comMngRealCompanyDO){
+            if (null == comMngRealCompanyDO) {
                 return R.fail("该单位不存在");
             }
-            ComMngRealCompanyDO checkCreditCode = comMngRealCompanyDAO.selectOne(new QueryWrapper<ComMngRealCompanyDO>().lambda().eq(ComMngRealCompanyDO::getCreditCode,comMngRealCompanyVO.getCreditCode()));
-            if(null!=checkCreditCode && comMngRealCompanyDO.getId()!=checkCreditCode.getId()){
+            ComMngRealCompanyDO checkCreditCode = comMngRealCompanyDAO.selectOne(new QueryWrapper<ComMngRealCompanyDO>().lambda().eq(ComMngRealCompanyDO::getCreditCode, comMngRealCompanyVO.getCreditCode()));
+            if (null != checkCreditCode && comMngRealCompanyDO.getId() != checkCreditCode.getId()) {
                 return R.fail("该单位已存在,信用代码重复");
             }
 
-            BeanUtils.copyProperties(comMngRealCompanyVO,comMngRealCompanyDO);
+            BeanUtils.copyProperties(comMngRealCompanyVO, comMngRealCompanyDO);
             int update = comMngRealCompanyDAO.updateById(comMngRealCompanyDO);
-            if(update>0){
+            if (update > 0) {
                 return R.ok();
             }
-        }else{
+        } else {
             //新增
-            Integer count = comMngRealCompanyDAO.selectCount(new QueryWrapper<ComMngRealCompanyDO>().lambda().eq(ComMngRealCompanyDO::getCreditCode,comMngRealCompanyVO.getCreditCode()));
-            if(count>0){
+            Integer count = comMngRealCompanyDAO.selectCount(new QueryWrapper<ComMngRealCompanyDO>().lambda().eq(ComMngRealCompanyDO::getCreditCode, comMngRealCompanyVO.getCreditCode()));
+            if (count > 0) {
                 return R.fail("该单位已存在,信用代码重复");
             }
             ComMngRealCompanyDO comMngRealCompanyDO = new ComMngRealCompanyDO();
-            BeanUtils.copyProperties(comMngRealCompanyVO,comMngRealCompanyDO);
+            BeanUtils.copyProperties(comMngRealCompanyVO, comMngRealCompanyDO);
             int insert = comMngRealCompanyDAO.insert(comMngRealCompanyDO);
-            if(insert>0){
+            if (insert > 0) {
                 return R.ok();
             }
         }
@@ -87,11 +87,11 @@
     @Override
     public R deleteComMngRealCompany(Long id) {
         ComMngRealCompanyDO comMngRealCompanyDO = comMngRealCompanyDAO.selectById(id);
-        if(null==comMngRealCompanyDO){
+        if (null == comMngRealCompanyDO) {
             return R.fail("该单位不存在");
         }
         int delete = comMngRealCompanyDAO.deleteById(id);
-        if(delete>0){
+        if (delete > 0) {
             return R.ok();
         }
         return R.fail("删除失败");
@@ -100,29 +100,29 @@
     @Override
     public R detailComMngRealCompany(Long id) {
         ComMngRealCompanyDO comMngRealCompanyDO = comMngRealCompanyDAO.selectById(id);
-        if(null==comMngRealCompanyDO){
+        if (null == comMngRealCompanyDO) {
             return R.fail("该单位不存在");
         }
         ComMngRealCompanyVO comMngRealCompanyVO = new ComMngRealCompanyVO();
-        BeanUtils.copyProperties(comMngRealCompanyDO,comMngRealCompanyVO);
+        BeanUtils.copyProperties(comMngRealCompanyDO, comMngRealCompanyVO);
         return R.ok(comMngRealCompanyVO);
     }
 
     @Override
     public R listSaveMngRealCompanyExcelVO(List<ComMngRealCompanyExcelVO> list, Long communityId) {
-        StringBuffer message = new StringBuffer();
+        List<ComMngRealCompanyDO> dbComMngRealCompany = comMngRealCompanyDAO.selectList(new QueryWrapper<ComMngRealCompanyDO>().lambda());
         List<ComMngRealCompanyDO> comMngRealCompanyDOS = new ArrayList<>();
-        list.forEach(l->{
-            Integer count = comMngRealCompanyDAO.selectCount(new QueryWrapper<ComMngRealCompanyDO>().lambda().eq(ComMngRealCompanyDO::getCreditCode,l.getCreditCode()));
-            if(count==0){
+        list.forEach(l -> {
+            ComMngRealCompanyDO realCompany = dbComMngRealCompany.stream().filter(db -> db.getCreditCode().equals(l.getCreditCode())).findFirst().orElse(null);
+            if (realCompany == null) {
                 ComMngRealCompanyDO comMngRealCompanyDO = new ComMngRealCompanyDO();
-                BeanUtils.copyProperties(l,comMngRealCompanyDO);
+                BeanUtils.copyProperties(l, comMngRealCompanyDO);
                 comMngRealCompanyDO.setCommunityId(communityId);
                 comMngRealCompanyDOS.add(comMngRealCompanyDO);
             }
         });
         boolean batch = this.saveBatch(comMngRealCompanyDOS);
-        if(batch){
+        if (batch) {
             return R.ok();
         }
         return R.fail("请检查数据是否重复,格合是否正确");

--
Gitblit v1.7.1