| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | |
| | | 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; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TbCompanyServiceImpl extends ServiceImpl<TbCompanyMapper, TbCompany> implements TbCompanyService { |
| | | |
| | | @Autowired |
| | | private TbPermitService permitService; |
| | | |
| | | @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()){ |
| | | return page1; |
| | | } |
| | | queryWrapper.in(TbCompany::getId, tbPermits.stream().map(TbPermit::getCompanyId).collect(Collectors.toList())); |
| | | } |
| | | queryWrapper.eq(TbCompany::getCityCode,query.getCityCode()); |
| | | queryWrapper.eq(TbCompany::getAreaCode,query.getAreaCode()); |
| | | |
| | | if(query.getCompanyCategorys()!=null && query.getCompanyCategorys().size()>0){ |
| | | queryWrapper.in(TbCompany::getCompanyCategory, query.getCompanyCategorys()); |
| | | } |
| | | |
| | | if(query.getRegisteredCapitals()!=null && query.getRegisteredCapitals().size()>0){ |
| | | queryWrapper.in(TbCompany::getRegisteredCapital, query.getRegisteredCapitals()); |
| | | } |
| | | |
| | | if(query.getCompanyIndustryIds()!=null && query.getCompanyIndustryIds().size()>0){ |
| | | queryWrapper.in(TbCompany::getCompanyIndustryId, query.getCompanyIndustryIds()); |
| | | } |
| | | |
| | | if(query.getTaxpayerTypes()!=null && query.getTaxpayerTypes().size()>0){ |
| | | queryWrapper.in(TbCompany::getTaxpayerType, query.getTaxpayerTypes()); |
| | | } |
| | | if(query.getTaxCredits()!=null && query.getTaxCredits().size()>0){ |
| | | queryWrapper.in(TbCompany::getTaxCredit, query.getTaxCredits()); |
| | | } |
| | | |
| | | if(query.getHighTechEnterpriseTechnology()!=null){ |
| | | queryWrapper.eq(TbCompany::getHighTechEnterpriseTechnology, query.getHighTechEnterpriseTechnology()); |
| | | } |
| | | if(query.getSocialSecurity()!=null){ |
| | | queryWrapper.eq(TbCompany::getSocialSecurity, query.getSocialSecurity()); |
| | | } |
| | | if(query.getTendering()!=null){ |
| | | queryWrapper.eq(TbCompany::getTendering, query.getTendering()); |
| | | } |
| | | if(query.getHaveTrademark()!=null){ |
| | | queryWrapper.eq(TbCompany::getHaveTrademark, query.getHaveTrademark()); |
| | | } |
| | | if(query.getHavePatent()!=null){ |
| | | queryWrapper.eq(TbCompany::getHavePatent, query.getHavePatent()); |
| | | } |
| | | if(query.getHaveSoftWorks()!=null){ |
| | | queryWrapper.eq(TbCompany::getHaveSoftWorks, query.getHaveSoftWorks()); |
| | | } |
| | | if(query.getMoneySort()!=null && query.getMoneySort()==1){ |
| | | queryWrapper.orderByDesc(TbCompany::getSaleMoney); |
| | | }else if(query.getMoneySort()!=null && query.getMoneySort()==2){ |
| | | queryWrapper.orderByAsc(TbCompany::getSaleMoney); |
| | | }else { |
| | | queryWrapper.orderByDesc(TbCompany::getCreateTime); |
| | | } |
| | | Page<TbCompany> companyPage = this.baseMapper.selectPage(page, queryWrapper); |
| | | List<Integer> ids = companyPage.getRecords().stream().map(TbCompany::getCompanyIndustryId).collect(Collectors.toList()); |
| | | List<TbIndustry> tbIndustries = industryService.list(new LambdaQueryWrapper<TbIndustry>().in(TbIndustry::getId, ids)); |
| | | ArrayList<IndexCompanyListVo> list = new ArrayList<>(); |
| | | for (TbCompany record : companyPage.getRecords()) { |
| | | IndexCompanyListVo indexCompanyListVo = new IndexCompanyListVo(); |
| | | indexCompanyListVo.setId(record.getId()); |
| | | indexCompanyListVo.setCompanyName(record.getCompanyName()); |
| | | TbIndustry tbIndustry = tbIndustries.stream().filter(e -> e.getId().equals(record.getCompanyIndustryId())).findFirst().orElse(null); |
| | | indexCompanyListVo.setIndustryName(tbIndustry.getName()); |
| | | indexCompanyListVo.setEstablishTime(record.getEstablishTime()); |
| | | indexCompanyListVo.setTaxpayerType(record.getTaxpayerType()); |
| | | indexCompanyListVo.setTaxCredit(record.getTaxCredit()); |
| | | indexCompanyListVo.setCompanyCategory(record.getCompanyCategory()); |
| | | indexCompanyListVo.setHighTechEnterpriseTechnology(record.getHighTechEnterpriseTechnology()); |
| | | indexCompanyListVo.setPaidInFunds(record.getPaidInFunds()); |
| | | indexCompanyListVo.setRegisteredCapital(record.getRegisteredCapital()); |
| | | indexCompanyListVo.setSaleMoney(record.getSaleMoney()); |
| | | if(record.getUserId().equals(userId.toString())){ |
| | | indexCompanyListVo.setIsMyself(1); |
| | | } |
| | | list.add(indexCompanyListVo); |
| | | |
| | | } |
| | | BeanUtils.copyProperties(companyPage,page1); |
| | | 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); |
| | | } |
| | | } |