| | |
| | | import com.ruoyi.system.dto.AddProcurementDto; |
| | | import com.ruoyi.system.export.PlatformLedgerReportExport; |
| | | import com.ruoyi.system.export.ProcurementReportClinicExport; |
| | | import com.ruoyi.system.export.ProcurementReportDetailExport; |
| | | import com.ruoyi.system.export.ProcurementReportPlatformExport; |
| | | import com.ruoyi.system.export.ProcurementReportSupplierExport; |
| | | import com.ruoyi.system.mapper.*; |
| | |
| | | import com.ruoyi.system.query.PerformanceReportQuery; |
| | | import com.ruoyi.system.query.TErpGoodsQuery; |
| | | import com.ruoyi.system.query.TErpProcurementQuery; |
| | | import com.ruoyi.system.service.TErpGoodsService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TErpProcurementGoodsService; |
| | | import com.ruoyi.system.service.TErpProcurementService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.vo.*; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.client.HttpClient; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.conn.ClientConnectionManager; |
| | | import org.apache.http.conn.scheme.Scheme; |
| | | import org.apache.http.conn.scheme.SchemeRegistry; |
| | | import org.apache.http.conn.ssl.SSLSocketFactory; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.DefaultHttpClient; |
| | | 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.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.net.ssl.TrustManager; |
| | | import javax.net.ssl.X509TrustManager; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.security.PrivateKey; |
| | | import java.security.cert.X509Certificate; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | |
| | | @Resource |
| | | private TErpProcurementCommissionMapper erpProcurementCommissionMapper; |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | @Autowired |
| | | private TCrmBranchAreaMapper crmBranchAreaMapper; |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<TErpProcurementVo> pageList(TErpProcurementQuery query, SysUser user) { |
| | |
| | | TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmSupplier)){ |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmSupplier = crmSupplierMapper.selectById(sysUser.getObjectId()); |
| | | } |
| | | supplierClinicId = crmSupplier.getId(); |
| | | } |
| | | if (roleType == 5) { |
| | |
| | | TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmClinic)){ |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicMapper.selectById(sysUser.getObjectId()); |
| | | } |
| | | supplierClinicId = crmClinic.getId(); |
| | | } |
| | | |
| | |
| | | TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmSupplier)){ |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmSupplier = crmSupplierMapper.selectById(sysUser.getObjectId()); |
| | | } |
| | | supplierClinicId = crmSupplier.getId(); |
| | | } |
| | | if (roleType == 5) { |
| | |
| | | TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | // *** |
| | | if(Objects.isNull(crmClinic)){ |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicMapper.selectById(sysUser.getObjectId()); |
| | | } |
| | | supplierClinicId = crmClinic.getId(); |
| | | } |
| | | |
| | |
| | | ArrayList<TErpProcurementDetailNextVo> tErpProcurementDetailNextVos = new ArrayList<>(); |
| | | for (TErpProcurementGoods tErpProcurementGood : tErpProcurementGoods) { |
| | | TErpProcurementDetailNextVo tErpProcurementDetailNextVo = new TErpProcurementDetailNextVo(); |
| | | BeanUtils.copyProperties(tErpProcurementGood, tErpProcurementDetailNextVo); |
| | | tErpProcurementDetailNextVo.setGoodsName(tErpProcurementGood.getGoodsName()); |
| | | tErpProcurementDetailNextVo.setUnitName(tErpProcurementGood.getUnitName()); |
| | | tErpProcurementDetailNextVo.setNum(tErpProcurementGood.getPurchaseCount()); |
| | |
| | | @Override |
| | | public PageInfo<TErpGoods> pageGoodsPageList(TErpGoodsQuery query, SysUser user) { |
| | | PageInfo<TErpGoods> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | PageInfo<TErpGoods> p = erpGoodsMapper.selectPage(pageInfo, new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getState,1).eq(TErpGoods::getGoodsSource, 1).isNotNull(TErpGoods::getClinicPurchasePrice).orderByDesc(BaseModel::getCreateTime)); |
| | | |
| | | // 获取未禁用的供应商 |
| | | List<TCrmSupplier> suppliers = crmSupplierMapper.selectList(new LambdaQueryWrapper<TCrmSupplier>().eq(TCrmSupplier::getStatus, 1)); |
| | | if(suppliers.isEmpty()){ |
| | | return pageInfo; |
| | | } |
| | | PageInfo<TErpGoods> p = erpGoodsMapper.selectPage(pageInfo, new LambdaQueryWrapper<TErpGoods>() |
| | | .like(StringUtils.isNotBlank(query.getGoodsName()), TErpGoods::getGoodsName, query.getGoodsName()) |
| | | .like(StringUtils.isNotBlank(query.getGoodsIdCode()), TErpGoods::getGoodsIdCode, query.getGoodsIdCode()) |
| | | .like(StringUtils.isNotBlank(query.getQuasiNumber()), TErpGoods::getQuasiNumber, query.getQuasiNumber()) |
| | | .eq(StringUtils.isNotBlank(query.getTypeId()),TErpGoods::getTypeId, query.getTypeId()) |
| | | .eq(TErpGoods::getState,1) |
| | | .eq(TErpGoods::getGoodsSource, 1) |
| | | .in(TErpGoods::getSupplierClinicId, suppliers.stream().map(TCrmSupplier::getId).collect(Collectors.toList())) |
| | | .isNotNull(TErpGoods::getClinicPurchasePrice) |
| | | .orderByDesc(BaseModel::getCreateTime)); |
| | | List<TErpGoods> list = p.getRecords(); |
| | | |
| | | List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList()); |
| | |
| | | |
| | | @Override |
| | | public List<TErpGoodsVO> inventoryNotEnoughList(SysUser user) { |
| | | List<TErpGoodsVO> list = this.baseMapper.inventoryNotEnoughList(user); |
| | | // 查询诊所 |
| | | TCrmClinic crmClinic = crmClinicMapper.selectOne(new LambdaQueryWrapper<TCrmClinic>().eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("limit 1")); |
| | | if (Objects.isNull(crmClinic)) { |
| | | SysUser sysUser = sysUserService.selectUserById(user.getUserId()); |
| | | crmClinic = crmClinicMapper.selectById(sysUser.getObjectId()); |
| | | } |
| | | List<TErpGoodsVO> list = this.baseMapper.inventoryNotEnoughList(user,crmClinic.getId()); |
| | | List<String> typeIds = list.stream().map(TErpGoodsVO::getTypeId).collect(Collectors.toList()); |
| | | if (!typeIds.isEmpty()) { |
| | | List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); |
| | |
| | | List<AddProcurementDto> value = entry.getValue(); |
| | | TErpProcurement tErpProcurement = new TErpProcurement(); |
| | | tErpProcurement.setClinicId(clinicSupplierId); |
| | | tErpProcurement.setProcurementCode("C" + DateUtils.dateTimeNow()); |
| | | |
| | | tErpProcurement.setSupplierId(supplierClinicId); |
| | | |
| | | tErpProcurement.setTermNo(supplier.getTermNo()); |
| | |
| | | BigDecimal all = BigDecimal.ZERO; |
| | | |
| | | for (AddProcurementDto addProcurementDto : value) { |
| | | BigDecimal multiply = addProcurementDto.getGoodsSalesAmount().multiply(BigDecimal.valueOf(addProcurementDto.getPurchaseCount())); |
| | | all = all.add(multiply); |
| | | if(addProcurementDto.getGoodsSalesAmount()!= null && addProcurementDto.getPurchaseCount()!=null){ |
| | | BigDecimal multiply = addProcurementDto.getGoodsSalesAmount().multiply(BigDecimal.valueOf(addProcurementDto.getPurchaseCount())); |
| | | all = all.add(multiply); |
| | | } |
| | | |
| | | } |
| | | tErpProcurement.setPayMoney(all); |
| | | AddProcurementDto addProcurementDto = value.get(0); |
| | |
| | | TErpProcurementGoods tErpProcurementGoods = new TErpProcurementGoods(); |
| | | tErpProcurementGoods.setProcurementId(tErpProcurement.getId()); |
| | | TErpGoods goods = tErpGoods.stream().filter(e -> e.getId().equals(dto.getGoodsId())).findFirst().get(); |
| | | |
| | | BeanUtils.copyProperties(goods, tErpProcurementGoods); |
| | | if (goods.getContentState()==null || goods.getContentState()!=1) { |
| | | tErpProcurementGoods.setContent(null); |
| | | |
| | | } |
| | | |
| | | tErpProcurementGoods.setGoodsId(dto.getGoodsId()); |
| | | tErpProcurementGoods.setGoodsName(goods.getGoodsName()); |
| | | tErpProcurementGoods.setSupplierName(supplier.getSupplierName()); |
| | |
| | | } |
| | | tErpProcurementGoods.setPurchasePrice(dto.getGoodsSalesAmount()); |
| | | tErpProcurementGoods.setSalesAmount(dto.getSalesAmount()); |
| | | tErpProcurementGoods.setTotalPrice(dto.getGoodsSalesAmount().multiply(new BigDecimal(dto.getPurchaseCount()))); |
| | | if(dto.getPurchaseCount()!=null && dto.getGoodsSalesAmount()!=null){ |
| | | tErpProcurementGoods.setTotalPrice(dto.getGoodsSalesAmount().multiply(new BigDecimal(dto.getPurchaseCount()))); |
| | | } |
| | | |
| | | tErpProcurementGoods.setPurchaseCount(dto.getPurchaseCount()); |
| | | tErpProcurementGoods.setSupplierId(supplierClinicId); |
| | | tErpProcurementGoods.setRecvMerchantNo(supplier.getRecvMerchantNo()); |
| | | tErpProcurementGoods.setSupplierMoney(dto.getSalesAmount().subtract(dto.getPlatformCommissionPrice())); |
| | | supplierCommissionPrice = supplierCommissionPrice.add(tErpProcurementGoods.getSupplierMoney().multiply(BigDecimal.valueOf(dto.getPurchaseCount()))); |
| | | tErpProcurementGoods.setSupplierMoney(dto.getGoodsSalesAmount().subtract(dto.getPlatformCommissionPrice())); |
| | | if(dto.getPurchaseCount()!=null){ |
| | | supplierCommissionPrice = supplierCommissionPrice.add(tErpProcurementGoods.getSupplierMoney().multiply(BigDecimal.valueOf(dto.getPurchaseCount()))); |
| | | } |
| | | if (tErpProcurementGoods.getSupplierMoney().doubleValue() < 0) { |
| | | throw new RuntimeException("平台抽成不能大于售卖价格"); |
| | | } |
| | | add = add.add(dto.getPlatformCommissionPrice().multiply(BigDecimal.valueOf(dto.getPurchaseCount()))); |
| | | if(dto.getPurchaseCount()!=null){ |
| | | add = add.add(dto.getPlatformCommissionPrice().multiply(BigDecimal.valueOf(dto.getPurchaseCount()))); |
| | | } |
| | | tErpProcurementGoods1.add(tErpProcurementGoods); |
| | | } |
| | | BigDecimal bigDecimal = tErpProcurement.getPayMoney().multiply(BigDecimal.valueOf(0.0038)).setScale(2, RoundingMode.HALF_UP); |
| | |
| | | throw new RuntimeException("金额设置错误,请联系平台管理员"); |
| | | } |
| | | tErpProcurement.setSupplierMoney(supplierCommissionPrice); |
| | | this.save(tErpProcurement); |
| | | tErpProcurementGoods1.forEach(e -> e.setProcurementId(tErpProcurement.getId())); |
| | | |
| | | |
| | | // 获取上一条最新的数据 |
| | | TErpProcurement tErpProcurement1 = this.baseMapper.selectOne(new QueryWrapper<TErpProcurement>() |
| | | .orderByDesc("create_time") |
| | | .orderByDesc("procurement_code").last("limit 1")); |
| | | if(tErpProcurement1==null){ |
| | | tErpProcurement.setProcurementCode("C" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = tErpProcurement1.getProcurementCode(); |
| | | String datePart = "C" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpProcurement.setProcurementCode(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpProcurement.setProcurementCode(datePart + "00001"); |
| | | } |
| | | |
| | | } |
| | | try { |
| | | this.save(tErpProcurement); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | for (TErpProcurementGoods tErpProcurementGoods : tErpProcurementGoods1) { |
| | | tErpProcurementGoods.setId(null); |
| | | tErpProcurementGoods.setProcurementId(tErpProcurement.getId()); |
| | | } |
| | | erpProcurementGoodsService.saveBatch(tErpProcurementGoods1); |
| | | } |
| | | |
| | |
| | | TErpProcurement tErpProcurement = this.getById(id); |
| | | if (tErpProcurement.getWarehousingUserId()!=null && !tErpProcurement.getWarehousingUserId().isEmpty()) { |
| | | SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getWarehousingUserId())); |
| | | detailProcurementVO.setWarehousingUserName(sysUser.getUserName()); |
| | | detailProcurementVO.setWarehousingUserName(sysUser.getNickName()); |
| | | } |
| | | detailProcurementVO.setWarehousingTime(tErpProcurement.getWarehousingTime()); |
| | | |
| | |
| | | detailProcurementVO.setSendTime(tErpProcurement.getSendTime()); |
| | | TCrmSupplier supplier = crmSupplierMapper.selectById(tErpProcurement.getSupplierId()); |
| | | detailProcurementVO.setSupplierName(supplier.getSupplierName()); |
| | | detailProcurementVO.setUserName(sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getCreateId())).getUserName()); |
| | | detailProcurementVO.setUserName(sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getCreateId())).getNickName()); |
| | | TCrmClinic tCrmClinic = crmClinicMapper.selectById(tErpProcurement.getClinicId()); |
| | | detailProcurementVO.setClinicName(tCrmClinic.getClinicName()); |
| | | detailProcurementVO.setClinicAddress(tCrmClinic.getClinicAddress()); |
| | |
| | | ArrayList<DetailProcurementNextVO> detailProcurementNextVOS = new ArrayList<>(); |
| | | for (TErpProcurementGoods tErpProcurementGoods : list) { |
| | | DetailProcurementNextVO detailProcurementNextVO = new DetailProcurementNextVO(); |
| | | BeanUtils.copyProperties(tErpProcurementGoods, detailProcurementNextVO); |
| | | detailProcurementNextVO.setGoodsName(tErpProcurementGoods.getGoodsName()); |
| | | detailProcurementNextVO.setQuasiNumber(tErpProcurementGoods.getQuasiNumber()); |
| | | detailProcurementNextVO.setPackingUnitName(tErpProcurementGoods.getUnitName()); |
| | |
| | | if(count>=purchaseCount){ |
| | | // 添加出库记录 |
| | | TErpSupplierOutbound tErpSupplierOutbound= new TErpSupplierOutbound(); |
| | | tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing.getGoodsId()); |
| | | tErpSupplierOutbound.setSupplierId(tErpSupplierWarehousing.getSupplierId()); |
| | | tErpSupplierOutbound.setWarehouseId(tErpSupplierWarehousing.getWarehouseId()); |
| | | tErpSupplierOutbound.setOutboundType(7); |
| | | //TODO 确定这个是采购价还是销售价格 |
| | | tErpSupplierOutbound.setTotalMoney(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount))); |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()); |
| | | erpSupplierOutboundMapper.insert(tErpSupplierOutbound); |
| | | |
| | | TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).orderByDesc(TErpSupplierOutbound::getOutboundNumber).last("limit 1")); |
| | | if(last==null){ |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last.getOutboundNumber(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | try { |
| | | erpSupplierOutboundMapper.insert(tErpSupplierOutbound); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods(); |
| | | tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); |
| | |
| | | purchaseCount = purchaseCount - count; |
| | | // 添加出库记录 |
| | | TErpSupplierOutbound tErpSupplierOutbound= new TErpSupplierOutbound(); |
| | | tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing.getGoodsId()); |
| | | tErpSupplierOutbound.setSupplierId(tErpSupplierWarehousing.getSupplierId()); |
| | | tErpSupplierOutbound.setWarehouseId(tErpSupplierWarehousing.getWarehouseId()); |
| | | tErpSupplierOutbound.setOutboundType(7); |
| | | //TODO 确定这个是采购价还是销售价格 |
| | | tErpSupplierOutbound.setTotalMoney(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount))); |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()); |
| | | erpSupplierOutboundMapper.insert(tErpSupplierOutbound); |
| | | TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).orderByDesc(TErpSupplierOutbound::getOutboundNumber).last("limit 1")); |
| | | if(last==null){ |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last.getOutboundNumber(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | |
| | | erpSupplierOutboundMapper.insert(tErpSupplierOutbound); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods(); |
| | | tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); |
| | |
| | | public PageInfo<BranchPerformanceReportVO> branchPerformanceReport(PerformanceReportQuery query) { |
| | | |
| | | List<String> clinicIds = new ArrayList<>(); |
| | | List<TCrmBranchArea> crmBranchAreas = new ArrayList<>(); |
| | | if(StringUtils.isNotEmpty(query.getCityCode())){ |
| | | crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class) |
| | | .eq(TCrmBranchArea::getCityCode, query.getCityCode()) |
| | | .eq(TCrmBranchArea::getAreaType, 2)); |
| | | if(CollectionUtils.isEmpty(crmBranchAreas)){ |
| | | return new PageInfo<>(); |
| | | } |
| | | } |
| | | |
| | | if(StringUtils.isNotEmpty(query.getProvinceCode())){ |
| | | crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class) |
| | | .eq(TCrmBranchArea::getProvinceCode, query.getProvinceCode()) |
| | | .eq(TCrmBranchArea::getAreaType, 2)); |
| | | if(CollectionUtils.isEmpty(crmBranchAreas)){ |
| | | return new PageInfo<>(); |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(crmBranchAreas)){ |
| | | List<String> branchIds = crmBranchAreas.stream().map(TCrmBranchArea::getBranchId).collect(Collectors.toList()); |
| | | List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .in(TCrmClinic::getBranchId, branchIds)); |
| | | if(CollectionUtils.isEmpty(crmClinics)){ |
| | | return new PageInfo<>(); |
| | | } |
| | | List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList()); |
| | | clinicIds.addAll(ids); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(query.getBranchName())){ |
| | | // 查询分公司名称 |
| | |
| | | List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList()); |
| | | clinicIds.addAll(ids); |
| | | } |
| | | clinicIds = clinicIds.stream().distinct().collect(Collectors.toList()); |
| | | query.setClinicIds(clinicIds); |
| | | PageInfo<BranchPerformanceReportVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | |
| | |
| | | @Override |
| | | public List<BranchPerformanceReportVO> exportBranchPerformanceReport(PerformanceReportQuery query) { |
| | | List<String> clinicIds = new ArrayList<>(); |
| | | List<TCrmBranchArea> crmBranchAreas = new ArrayList<>(); |
| | | if(StringUtils.isNotEmpty(query.getCityCode())){ |
| | | crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class) |
| | | .eq(TCrmBranchArea::getCityCode, query.getCityCode()) |
| | | .eq(TCrmBranchArea::getAreaType, 2)); |
| | | } |
| | | |
| | | if(StringUtils.isNotEmpty(query.getProvinceCode())){ |
| | | crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class) |
| | | .eq(TCrmBranchArea::getProvinceCode, query.getProvinceCode()) |
| | | .eq(TCrmBranchArea::getAreaType, 2)); |
| | | } |
| | | if(!CollectionUtils.isEmpty(crmBranchAreas)){ |
| | | List<String> branchIds = crmBranchAreas.stream().map(TCrmBranchArea::getBranchId).collect(Collectors.toList()); |
| | | List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .in(TCrmClinic::getBranchId, branchIds)); |
| | | if(CollectionUtils.isEmpty(crmClinics)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList()); |
| | | clinicIds.addAll(ids); |
| | | } |
| | | if(StringUtils.isNotBlank(query.getBranchName())){ |
| | | // 查询分公司名称 |
| | | List<TCrmBranch> crmBranches = crmBranchMapper.selectList(Wrappers.lambdaQuery(TCrmBranch.class) |
| | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<ClinicProcurementReportDetailVO> clinicProcurementReportDetail(String id) { |
| | | return this.baseMapper.clinicProcurementReportDetail(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ProcurementReportDetailExport> exportProcurementReportDetail(List<String> procurementIds) { |
| | | return this.baseMapper.exportProcurementReportDetail(procurementIds); |
| | | } |
| | | |
| | | } |