From de91c84954157bb9f8b6d938cbe0b1b51fb6e65d Mon Sep 17 00:00:00 2001
From: CeDo <cedoogle@gmail.com>
Date: 星期五, 07 五月 2021 15:23:57 +0800
Subject: [PATCH] bugfixed:新增便民服务商家 报错
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealCompanyServiceImpl.java | 53 +++++++++++++++++++++++++++++------------------------
1 files changed, 29 insertions(+), 24 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..736004d 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
@@ -1,4 +1,5 @@
package com.panzhihua.service_community.service.impl;
+import java.util.Date;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -27,7 +28,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 +52,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 +88,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,32 +101,36 @@
@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);
+ }else{
+ BeanUtils.copyProperties(l, realCompany);
+ realCompany.setCommunityId(communityId);
+ comMngRealCompanyDOS.add(realCompany);
}
});
- boolean batch = this.saveBatch(comMngRealCompanyDOS);
- if(batch){
+ boolean batch = this.saveOrUpdateBatch(comMngRealCompanyDOS);
+ if (batch) {
return R.ok();
}
- return R.fail("请检查数据是否重复,格合是否正确");
+ return R.fail("请检查格式是否正确");
}
@Override
--
Gitblit v1.7.1