|  |  |  | 
|---|
|  |  |  | package com.ruoyi.system.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.ruoyi.common.basic.PageInfo; | 
|---|
|  |  |  | import com.ruoyi.system.export.TCrmChangePointsBranchExport; | 
|---|
|  |  |  | import com.ruoyi.system.export.TCrmChangePointsClinicExport; | 
|---|
|  |  |  | import com.ruoyi.system.export.TCrmChangePointsSalespersonExport; | 
|---|
|  |  |  | import com.ruoyi.system.mapper.TCrmChangePointsMapper; | 
|---|
|  |  |  | import com.ruoyi.system.mapper.TCrmClinicMapper; | 
|---|
|  |  |  | import com.ruoyi.system.mapper.TErpProcurementMapper; | 
|---|
|  |  |  | import com.ruoyi.system.model.TCrmChangePoints; | 
|---|
|  |  |  | import com.ruoyi.system.model.TCrmClinic; | 
|---|
|  |  |  | import com.ruoyi.system.model.TErpProcurement; | 
|---|
|  |  |  | import com.ruoyi.system.model.TSysActivity; | 
|---|
|  |  |  | import com.ruoyi.system.query.TCrmChangePointsQuery; | 
|---|
|  |  |  | import com.ruoyi.system.service.TCrmChangePointsService; | 
|---|
|  |  |  | import com.ruoyi.system.vo.TCrmChangePointsVO; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class TCrmChangePointsServiceImpl extends ServiceImpl<TCrmChangePointsMapper, TCrmChangePoints> implements TCrmChangePointsService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TErpProcurementMapper erpProcurementMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TCrmClinicMapper crmClinicMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageInfo<TCrmChangePointsVO> pageListBranch(TCrmChangePointsQuery query) { | 
|---|
|  |  |  | PageInfo<TCrmChangePointsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); | 
|---|
|  |  |  | List<TCrmChangePointsVO> list = this.baseMapper.pageListBranch(query,pageInfo); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(list)){ | 
|---|
|  |  |  | return pageInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> procurementIds = list.stream().map(TCrmChangePointsVO::getProcurementId) | 
|---|
|  |  |  | .filter(Objects::nonNull).collect(Collectors.toList()); | 
|---|
|  |  |  | // 查询诊所 | 
|---|
|  |  |  | List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(procurementIds)){ | 
|---|
|  |  |  | List<TErpProcurement> erpProcurements = erpProcurementMapper.selectList(Wrappers.lambdaQuery(TErpProcurement.class).in(TErpProcurement::getId, procurementIds)); | 
|---|
|  |  |  | for (TCrmChangePointsVO tCrmChangePointsVO : list) { | 
|---|
|  |  |  | List<TErpProcurement> collect = erpProcurements.stream().filter(tErpProcurement -> tErpProcurement.getId().equals(tCrmChangePointsVO.getProcurementId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(collect)){ | 
|---|
|  |  |  | tCrmChangePointsVO.setProcurementCode(collect.get(0).getProcurementCode()); | 
|---|
|  |  |  | tCrmChangePointsVO.setPayMoney(collect.get(0).getPayMoney()); | 
|---|
|  |  |  | List<TCrmClinic> clinics = crmClinics.stream().filter(tCrmClinic -> tCrmClinic.getId().equals(collect.get(0).getClinicId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(clinics)){ | 
|---|
|  |  |  | tCrmChangePointsVO.setClinicName(clinics.get(0).getClinicName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | pageInfo.setRecords(list); | 
|---|
|  |  |  | return pageInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageInfo<TCrmChangePointsVO> pageListSalesperson(TCrmChangePointsQuery query) { | 
|---|
|  |  |  | PageInfo<TCrmChangePointsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); | 
|---|
|  |  |  | List<TCrmChangePointsVO> list = this.baseMapper.pageListSalesperson(query,pageInfo); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(list)){ | 
|---|
|  |  |  | return pageInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> procurementIds = list.stream().map(TCrmChangePointsVO::getProcurementId) | 
|---|
|  |  |  | .filter(Objects::nonNull).collect(Collectors.toList()); | 
|---|
|  |  |  | // 查询诊所 | 
|---|
|  |  |  | List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(procurementIds)){ | 
|---|
|  |  |  | List<TErpProcurement> erpProcurements = erpProcurementMapper.selectList(Wrappers.lambdaQuery(TErpProcurement.class).in(TErpProcurement::getId, procurementIds)); | 
|---|
|  |  |  | for (TCrmChangePointsVO tCrmChangePointsVO : list) { | 
|---|
|  |  |  | List<TErpProcurement> collect = erpProcurements.stream().filter(tErpProcurement -> tErpProcurement.getId().equals(tCrmChangePointsVO.getProcurementId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(collect)){ | 
|---|
|  |  |  | tCrmChangePointsVO.setProcurementCode(collect.get(0).getProcurementCode()); | 
|---|
|  |  |  | tCrmChangePointsVO.setPayMoney(collect.get(0).getPayMoney()); | 
|---|
|  |  |  | List<TCrmClinic> clinics = crmClinics.stream().filter(tCrmClinic -> tCrmClinic.getId().equals(collect.get(0).getClinicId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(clinics)){ | 
|---|
|  |  |  | tCrmChangePointsVO.setClinicName(clinics.get(0).getClinicName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | pageInfo.setRecords(list); | 
|---|
|  |  |  | return pageInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageInfo<TCrmChangePointsVO> pageListClinic(TCrmChangePointsQuery query) { | 
|---|
|  |  |  | PageInfo<TCrmChangePointsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); | 
|---|
|  |  |  | List<TCrmChangePointsVO> list = this.baseMapper.pageListClinic(query,pageInfo); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(list)){ | 
|---|
|  |  |  | return pageInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> procurementIds = list.stream().map(TCrmChangePointsVO::getProcurementId) | 
|---|
|  |  |  | .filter(Objects::nonNull).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(procurementIds)){ | 
|---|
|  |  |  | List<TErpProcurement> erpProcurements = erpProcurementMapper.selectList(Wrappers.lambdaQuery(TErpProcurement.class).in(TErpProcurement::getId, procurementIds)); | 
|---|
|  |  |  | for (TCrmChangePointsVO tCrmChangePointsVO : list) { | 
|---|
|  |  |  | List<TErpProcurement> collect = erpProcurements.stream().filter(tErpProcurement -> tErpProcurement.getId().equals(tCrmChangePointsVO.getProcurementId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(collect)){ | 
|---|
|  |  |  | tCrmChangePointsVO.setProcurementCode(collect.get(0).getProcurementCode()); | 
|---|
|  |  |  | tCrmChangePointsVO.setPayMoney(collect.get(0).getPayMoney()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | pageInfo.setRecords(list); | 
|---|
|  |  |  | return pageInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<TCrmChangePointsBranchExport> pageListBranchExport(TCrmChangePointsQuery query) { | 
|---|
|  |  |  | List<TCrmChangePointsBranchExport> list = this.baseMapper.pageListBranchExport(query); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(list)){ | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> procurementIds = list.stream().map(TCrmChangePointsBranchExport::getProcurementId) | 
|---|
|  |  |  | .filter(Objects::nonNull).collect(Collectors.toList()); | 
|---|
|  |  |  | // 查询诊所 | 
|---|
|  |  |  | List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(procurementIds)){ | 
|---|
|  |  |  | List<TErpProcurement> erpProcurements = erpProcurementMapper.selectList(Wrappers.lambdaQuery(TErpProcurement.class).in(TErpProcurement::getId, procurementIds)); | 
|---|
|  |  |  | for (TCrmChangePointsBranchExport crmChangePointsBranchExport : list) { | 
|---|
|  |  |  | List<TErpProcurement> collect = erpProcurements.stream().filter(tErpProcurement -> tErpProcurement.getId().equals(crmChangePointsBranchExport.getProcurementId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(collect)){ | 
|---|
|  |  |  | crmChangePointsBranchExport.setProcurementCode(collect.get(0).getProcurementCode()); | 
|---|
|  |  |  | crmChangePointsBranchExport.setPayMoney(collect.get(0).getPayMoney()); | 
|---|
|  |  |  | List<TCrmClinic> clinics = crmClinics.stream().filter(tCrmClinic -> tCrmClinic.getId().equals(collect.get(0).getClinicId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(clinics)){ | 
|---|
|  |  |  | crmChangePointsBranchExport.setClinicName(clinics.get(0).getClinicName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<TCrmChangePointsSalespersonExport> pageListSalespersonExport(TCrmChangePointsQuery query) { | 
|---|
|  |  |  | List<TCrmChangePointsSalespersonExport> list = this.baseMapper.pageListSalespersonExport(query); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(list)){ | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> procurementIds = list.stream().map(TCrmChangePointsSalespersonExport::getProcurementId) | 
|---|
|  |  |  | .filter(Objects::nonNull).collect(Collectors.toList()); | 
|---|
|  |  |  | // 查询诊所 | 
|---|
|  |  |  | List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(procurementIds)){ | 
|---|
|  |  |  | List<TErpProcurement> erpProcurements = erpProcurementMapper.selectList(Wrappers.lambdaQuery(TErpProcurement.class).in(TErpProcurement::getId, procurementIds)); | 
|---|
|  |  |  | for (TCrmChangePointsSalespersonExport crmChangePointsSalespersonExport : list) { | 
|---|
|  |  |  | List<TErpProcurement> collect = erpProcurements.stream().filter(tErpProcurement -> tErpProcurement.getId().equals(crmChangePointsSalespersonExport.getProcurementId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(collect)){ | 
|---|
|  |  |  | crmChangePointsSalespersonExport.setProcurementCode(collect.get(0).getProcurementCode()); | 
|---|
|  |  |  | crmChangePointsSalespersonExport.setPayMoney(collect.get(0).getPayMoney()); | 
|---|
|  |  |  | List<TCrmClinic> clinics = crmClinics.stream().filter(tCrmClinic -> tCrmClinic.getId().equals(collect.get(0).getClinicId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(clinics)){ | 
|---|
|  |  |  | crmChangePointsSalespersonExport.setClinicName(clinics.get(0).getClinicName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<TCrmChangePointsClinicExport> pageListClinicExport(TCrmChangePointsQuery query) { | 
|---|
|  |  |  | List<TCrmChangePointsClinicExport> list = this.baseMapper.pageListClinicExport(query); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(list)){ | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> procurementIds = list.stream().map(TCrmChangePointsClinicExport::getProcurementId) | 
|---|
|  |  |  | .filter(Objects::nonNull).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(procurementIds)){ | 
|---|
|  |  |  | List<TErpProcurement> erpProcurements = erpProcurementMapper.selectList(Wrappers.lambdaQuery(TErpProcurement.class).in(TErpProcurement::getId, procurementIds)); | 
|---|
|  |  |  | for (TCrmChangePointsClinicExport crmChangePointsClinicExport : list) { | 
|---|
|  |  |  | List<TErpProcurement> collect = erpProcurements.stream().filter(tErpProcurement -> tErpProcurement.getId().equals(crmChangePointsClinicExport.getProcurementId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(collect)){ | 
|---|
|  |  |  | crmChangePointsClinicExport.setProcurementCode(collect.get(0).getProcurementCode()); | 
|---|
|  |  |  | crmChangePointsClinicExport.setPayMoney(collect.get(0).getPayMoney()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|