From 7e47eb88973dda29fdce1fae755e5ce899bcc504 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期日, 28 九月 2025 13:44:50 +0800 Subject: [PATCH] 诊所erp --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java | 31 +++++++++++++++++++++++++++---- ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml | 11 ++++++++--- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java | 14 +++++++++++++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java index 075277f..58a0076 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java @@ -164,7 +164,7 @@ @Override public boolean isExit(String goodsIdCode, String quasiNumber,String id) { - Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).ne(id!=null,TErpGoods::getId, id).eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber)); + Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).ne(id!=null,TErpGoods::getId, id).and(q -> q.eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber))); if (size > 0) { return true; } @@ -367,6 +367,18 @@ } wrapper.orderByDesc(BaseModel::getCreateTime); Page<TErpGoods> page = this.page(new Page<>(query.getPageNum(), query.getPageSize()), wrapper); + List<TErpGoods> records = page.getRecords(); + if(records.isEmpty()){ + return page; + } + List<String> packingUnitId = records.stream().map(TErpGoods::getPackingUnitId).collect(Collectors.toList()); + if(!packingUnitId.isEmpty()){ + List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId); + for (TErpGoods tErpGoods : records) { + tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoods.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoods.setPackingUnitName(t.getUnitName())); + } + } + page.setRecords( records); return page; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java index c3de1af..29b9c97 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java @@ -242,9 +242,9 @@ } List<String> supplierClinicId = list.stream().filter(e->e.getGoodsSource()==1).map(TErpGoods::getSupplierClinicId).collect(Collectors.toList()); if(!supplierClinicId.isEmpty()){ - List<TCrmClinic> crmClinics = crmClinicMapper.selectBatchIds(supplierClinicId); + List<TCrmSupplier> crmClinics = crmSupplierMapper.selectBatchIds(supplierClinicId); for (TErpGoods tErpGoodsVO : list) { - crmClinics.stream().filter(t -> t.getId().equals(tErpGoodsVO.getSupplierClinicId())).findFirst().ifPresent(t -> tErpGoodsVO.setSupplierName(t.getClinicName())); + crmClinics.stream().filter(t -> t.getId().equals(tErpGoodsVO.getSupplierClinicId())).findFirst().ifPresent(t -> tErpGoodsVO.setSupplierName(t.getSupplierName())); } } pageInfo.setRecords( list); @@ -254,6 +254,21 @@ @Override public List<TErpGoodsVO> inventoryNotEnoughList(SysUser user) { List<TErpGoodsVO> list = this.baseMapper.inventoryNotEnoughList(user); + List<String> typeIds = list.stream().map(TErpGoodsVO::getTypeId).collect(Collectors.toList()); + if(!typeIds.isEmpty()){ + List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); + for (TErpGoodsVO tErpGoodsVO : list) { + typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); + } + } + List<String> supplierClinicId = list.stream().filter(e->e.getGoodsSource()==1).map(TErpGoodsVO::getSupplierClinicId).collect(Collectors.toList()); + if(!supplierClinicId.isEmpty()){ + List<TCrmSupplier> crmSuppliers = crmSupplierMapper.selectBatchIds(supplierClinicId); + for (TErpGoodsVO tErpGoodsVO : list) { + crmSuppliers.stream().filter(t -> t.getId().equals(tErpGoodsVO.getSupplierClinicId())).findFirst().ifPresent(t -> tErpGoodsVO.setSupplierName(t.getSupplierName())); + } + } + return list; } @@ -284,7 +299,15 @@ tErpProcurement.setTermNo(supplier.getTermNo()); tErpProcurement.setMerchantNo(supplier.getRecvMerchantNo()); - tErpProcurement.setPayMoney(value.stream().map(AddProcurementDto::getSalesAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); + tErpProcurement.setCreateId(user.getUserId().toString()); + + BigDecimal all = BigDecimal.ZERO; + + for (AddProcurementDto addProcurementDto : value) { + BigDecimal multiply = addProcurementDto.getSalesAmount().multiply(BigDecimal.valueOf(addProcurementDto.getPurchaseCount())); + all = all.add(multiply); + } + tErpProcurement.setPayMoney(all); AddProcurementDto addProcurementDto = value.get(0); if(addProcurementDto.getState()!=null && addProcurementDto.getState()==1){ tErpProcurement.setStatus(1); @@ -317,7 +340,7 @@ if(tErpProcurementGoods.getSupplierMoney().doubleValue()<0){ throw new RuntimeException("平台抽成不能大于售卖价格"); } - add = add.add(dto.getPlatformCommissionPrice()); + 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); diff --git a/ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml index f198f29..339e59e 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml @@ -120,15 +120,20 @@ </select> <select id="warehousePageList" resultType="com.ruoyi.system.vo.TErpClinicWarehousePageListVO"> - select t1.id,t1.warehouse_no,t2.supplier_name,t3.procurement_code,t3.pay_money allTotalPrice,t1.create_time warehouseTime,t1.type + select t1.id,t1.warehouse_no, + case when t1.type =1 then t2.supplier_name else t4.supplier_name end as supplierName, + t3.procurement_code, + case when t1.type =1 then t3.pay_money else t1.total_price end as allTotalPrice, + t1.create_time warehouseTime,t1.type from t_erp_clinic_warehousing t1 left join t_erp_procurement t3 on t1.procurement_id = t3.id - left join t_crm_supplier t2 on t3.supplier_id = t2.id + left join t_crm_supplier t2 on t3.supplier_id = t2.id and t1.type =1 + left join t_crm_supplier t4 on t1.supplier_id = t4.id and t1.type !=1 where t1.disabled = 0 and t1.clinic_id = #{supplierClinicId} <if test="query.warehouseNo != null and query.warehouseNo != ''"> and t1.warehouse_no like concat('%',#{query.warehouseNo},'%') </if> <if test="query.supplierName != null and query.supplierName != ''"> - and t2.supplier_name like concat('%',#{query.supplierName},'%') + and (t2.supplier_name like concat('%',#{query.supplierName},'%') or t4.supplier_name like concat('%',#{query.supplierName},'%')) </if> <if test="sTime != null"> and t1.create_time between #{sTime} and #{eTime} -- Gitblit v1.7.1