| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.community.ComMngRealCompanyBelongsDTO; |
| | | import com.panzhihua.common.model.dtos.community.ExportRealCompanyExcelDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComMngRealCompanyDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngCarVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngRealCompanyBelongsVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngRealCompanyExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngRealCompanyVO; |
| | | import com.panzhihua.service_community.dao.ComMngRealCompanyDAO; |
| | | import com.panzhihua.service_community.model.dos.ComMngRealCompanyDO; |
| | | import com.panzhihua.service_community.service.ComMngRealCompanyService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @description: 实有单位 |
| | |
| | | * @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; |
| | |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComMngRealCompanyVO> iPage = comMngRealCompanyDAO.pageQueryComMngRealCompany(page, pageComMngRealCompanyDTO); |
| | | IPage<ComMngRealCompanyVO> iPage = |
| | | comMngRealCompanyDAO.pageQueryComMngRealCompany(page, pageComMngRealCompanyDTO); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @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{ |
| | | //新增 |
| | | Integer count = comMngRealCompanyDAO.selectCount(new QueryWrapper<ComMngRealCompanyDO>().lambda().eq(ComMngRealCompanyDO::getCreditCode,comMngRealCompanyVO.getCreditCode())); |
| | | if(count>0){ |
| | | } else { |
| | | // 新增 |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | @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("删除失败"); |
| | |
| | | @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 |
| | |
| | | List<ComMngRealCompanyExcelVO> list = comMngRealCompanyDAO.exportRealCompanyExcel(exportRealCompanyExcelDTO); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @Override |
| | | public R belongsComMngRealCompany(ComMngRealCompanyBelongsDTO comMngRealCompanyBelongsDTO) { |
| | | ComMngRealCompanyBelongsVO comMngRealCompanyBelongsVO = |
| | | comMngRealCompanyDAO.queryComMngRealCompanyBelongs(comMngRealCompanyBelongsDTO); |
| | | return R.ok(comMngRealCompanyBelongsVO); |
| | | } |
| | | |
| | | @Override |
| | | public R getComMngRealCompanyTotalByAdmin(Long communityId) { |
| | | return R.ok(this.baseMapper.getComMngRealCompanyTotalByAdmin(communityId)); |
| | | } |
| | | |
| | | } |