| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.dto.EditCompanyDto; |
| | | import com.ruoyi.system.dto.PushCompanyDto; |
| | | import com.ruoyi.system.mapper.TbCompanyMapper; |
| | | import com.ruoyi.system.mapper.TbOpeningBankMapper; |
| | | import com.ruoyi.system.model.TbCompany; |
| | | import com.ruoyi.system.model.TbIndustry; |
| | | import com.ruoyi.system.model.TbOpeningBank; |
| | | import com.ruoyi.system.model.TbPermit; |
| | | import com.ruoyi.system.query.CompanyListQuery; |
| | | import com.ruoyi.system.query.MyPushCompanyListQuery; |
| | | import com.ruoyi.system.service.TbCompanyService; |
| | | import com.ruoyi.system.service.TbIndustryService; |
| | | import com.ruoyi.system.service.TbOpeningBankService; |
| | | import com.ruoyi.system.service.TbPermitService; |
| | | import com.ruoyi.system.vo.IndexCompanyListVo; |
| | | import com.ruoyi.system.vo.MyPushCompanyListVo; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | private TbIndustryService industryService; |
| | | |
| | | @Autowired |
| | | private TbOpeningBankService openingBankService; |
| | | |
| | | @Override |
| | | public Page<IndexCompanyListVo> getCompanyList(CompanyListQuery query, Long userId) { |
| | | Page<TbCompany> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | Page<IndexCompanyListVo> page1 = new Page<>(); |
| | | LambdaQueryWrapper<TbCompany> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(TbCompany::getIsDelete,0); |
| | | queryWrapper.eq(TbCompany::getStatus,1); |
| | | if(query.getCertificateNames()!=null && query.getCertificateNames().size()>0){ |
| | | List<TbPermit> tbPermits = permitService.list(new LambdaQueryWrapper<TbPermit>().in(TbPermit::getName, query.getCertificateNames())); |
| | | if(tbPermits.isEmpty()){ |
| | |
| | | page1.setRecords(list); |
| | | return page1; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
| | | public void pushCompany(PushCompanyDto dto, Long userId) { |
| | | TbCompany tbCompany = new TbCompany(); |
| | | BeanUtils.copyProperties(dto,tbCompany); |
| | | tbCompany.setUserId(userId.toString()); |
| | | this.save(tbCompany); |
| | | |
| | | List<TbPermit> permits = dto.getPermits(); |
| | | for (TbPermit permit : permits) { |
| | | permit.setCompanyId(tbCompany.getId()); |
| | | permitService.save(permit); |
| | | } |
| | | List<TbOpeningBank> openingBanks = dto.getOpeningBanks(); |
| | | for (TbOpeningBank openingBank : openingBanks) { |
| | | openingBank.setCompanyId(tbCompany.getId()); |
| | | openingBankService.save(openingBank); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
| | | public void editCompany(EditCompanyDto dto, TbCompany company ,Long userId) { |
| | | BeanUtils.copyProperties(dto,company); |
| | | company.setUserId(userId.toString()); |
| | | this.updateById(company); |
| | | permitService.remove(new LambdaQueryWrapper<TbPermit>().eq(TbPermit::getCompanyId,dto.getId())); |
| | | openingBankService.remove(new LambdaQueryWrapper<TbOpeningBank>().eq(TbOpeningBank::getCompanyId,dto.getId())); |
| | | List<TbPermit> permits = dto.getPermits(); |
| | | for (TbPermit permit : permits) { |
| | | permit.setCompanyId(company.getId()); |
| | | permitService.save(permit); |
| | | } |
| | | List<TbOpeningBank> openingBanks = dto.getOpeningBanks(); |
| | | for (TbOpeningBank openingBank : openingBanks) { |
| | | openingBank.setCompanyId(company.getId()); |
| | | openingBankService.save(openingBank); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Page<MyPushCompanyListVo> getMyPushCompanyList(MyPushCompanyListQuery query, Long userId) { |
| | | Page<MyPushCompanyListVo> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | return this.baseMapper.getMyPushCompanyList(page,query,userId); |
| | | } |
| | | } |