From 9256180bd57599b0fb64e4627aeff7c5d65186ef Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期二, 30 九月 2025 17:42:20 +0800 Subject: [PATCH] 诊所erp --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java | 73 +++++++++++++++++++++++++++++++++--- 1 files changed, 66 insertions(+), 7 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 85fa2bd..0e261e4 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 @@ -14,12 +14,15 @@ import com.ruoyi.system.mapper.*; import com.ruoyi.system.model.*; import com.ruoyi.system.query.TClinicGoodsWarehouseQuery; +import com.ruoyi.system.query.TErpGoodsAdminQuery; import com.ruoyi.system.query.TErpGoodsInventoryQuery; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.service.TErpGoodsService; import com.ruoyi.system.service.TErpSupplierInventoryGoodsService; import com.ruoyi.system.vo.*; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; @@ -101,8 +104,51 @@ typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); } } + List<String> collect = list.stream().filter(e -> e.getGoodsSource() == 1).map(TErpGoods::getSupplierClinicId).collect(Collectors.toList()); + if (!collect.isEmpty()) { + List<TCrmSupplier> crmClinics = crmSupplierMapper.selectBatchIds(collect); + for (TErpGoodsVO tErpGoodsVO : list) { + crmClinics.stream().filter(t -> t.getId().equals(tErpGoodsVO.getSupplierClinicId())).findFirst().ifPresent(t -> tErpGoodsVO.setSupplierName(t.getSupplierName())); + } + } pageInfo.setRecords(list); + return pageInfo; + } + @Override + public PageInfo<TErpGoodsVO> pageList1(TErpGoodsQuery query, SysUser user) { + PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); + List<TErpGoodsVO> list = this.baseMapper.pageList(query, pageInfo, user); + if (list.isEmpty()) { + return pageInfo; + } + List<String> typeIds = list.stream().map(TErpGoods::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())); + } + } + + pageInfo.setRecords(list); + return pageInfo; + } + + @Override + public PageInfo<TErpGoodsVO> pageAdminList(TErpGoodsAdminQuery query) { + PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); + List<TErpGoodsVO> list = this.baseMapper.pageAdminList(query, pageInfo); + if (list.isEmpty()) { + return pageInfo; + } + List<String> typeIds = list.stream().map(TErpGoods::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())); + } + } + pageInfo.setRecords( list); return pageInfo; } @@ -138,12 +184,11 @@ } @Override - public boolean isExit(String goodsIdCode, String quasiNumber) { - Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber)); + public boolean isExit(String goodsIdCode, String quasiNumber,String id) { + 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; } - return false; } @@ -343,6 +388,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; } @@ -379,6 +436,7 @@ outboundGoodsDetailVo.setCreateBy(tErpClinicOutbound.getCreateBy()); outboundGoodsDetailVo.setOutboundType(tErpClinicOutbound.getOutboundType()); outboundGoodsDetailVo.setOrderNumber(tErpClinicOutbound.getOrderNumber()); + outboundGoodsDetailVo.setOutboundReason(tErpClinicOutbound.getOutboundReason()); if(tErpClinicOutbound.getOutboundType()==6){ TErpClinicInventory tErpClinicInventory = erpClinicInventoryMapper.selectById(tErpClinicOutbound.getInventoryId()); outboundGoodsDetailVo.setInventoryNumber(tErpClinicInventory.getInventoryNumber()); @@ -393,7 +451,7 @@ outboundGoodsDetailNextVo.setWarehouseNo(tErpClinicWarehousing.getWarehouseNo()); outboundGoodsDetailNextVo.setGoodsId(outboundGoods.getGoodsId()); - TErpGoods goods = erpGoodsMapper.selectById(outboundGoods.getGoodsId()); + TErpGoods goods = erpGoodsMapper.getGoodsById(outboundGoods.getGoodsId()); outboundGoodsDetailNextVo.setGoodsName(goods.getGoodsName()); outboundGoodsDetailNextVo.setTypeId(goods.getTypeId()); @@ -423,6 +481,7 @@ } @Override + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void inventoryGoods(InventoryDto dto, SysUser user) { Integer roleType = user.getRoleType(); String supplierClinicId = null; @@ -464,8 +523,8 @@ tErpSupplierWarehousing.setGoodsId(tErpSupplierWarehousing1.getGoodsId()); tErpSupplierWarehousing.setGoodsName(erpGoods.getGoodsName()); tErpSupplierWarehousing.setGoodsCount(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum()); - tErpSupplierWarehousing.setUnitAmount(erpGoods.getSalesAmount()); - tErpSupplierWarehousing.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(tErpSupplierWarehousing.getGoodsCount()))); + tErpSupplierWarehousing.setUnitAmount(tErpSupplierWarehousing1.getUnitAmount()); + tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(tErpSupplierWarehousing.getGoodsCount()))); // 当前年月日时分秒 String time = DateUtils.dateTimeNow(); tErpSupplierWarehousing.setWarehouseNo("G" + time); @@ -511,7 +570,7 @@ tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId()); tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId()); tErpSupplierOutboundGoods.setOutboundCount(count); - tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); + tErpSupplierOutboundGoods.setTotalPrice(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count))); erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods); -- Gitblit v1.7.1