| | |
| | | * @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; |
| | |
| | | |
| | | @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(); |
| | | } |
| | | } |
| | |
| | | @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); |
| | | } |
| | | }); |
| | | boolean batch = this.saveBatch(comMngRealCompanyDOS); |
| | | if(batch){ |
| | | if (batch) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("请检查数据是否重复,格合是否正确"); |