From 11ecb9ee39fc61af04cd8d462faf9dce496d1773 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期四, 11 九月 2025 15:19:53 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 158 insertions(+), 15 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 8801f37..23a295c 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 @@ -4,17 +4,22 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.uuid.IdUtils; +import com.ruoyi.system.dto.InventoryDto; +import com.ruoyi.system.dto.InventoryGoodsDto; import com.ruoyi.system.mapper.*; -import com.ruoyi.system.model.TErpGoods; -import com.ruoyi.system.model.TErpGoodsType; -import com.ruoyi.system.model.TErpGoodsUnit; -import com.ruoyi.system.model.TSysBanner; +import com.ruoyi.system.model.*; +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.TErpGoodsInventoryVO; import com.ruoyi.system.vo.TErpGoodsVO; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -36,17 +41,34 @@ @Resource private TErpGoodsUnitMapper erpGoodsUnitMapper; + @Resource + private TErpSupplierInventoryMapper erpSupplierInventoryMapper; + + @Resource + private TErpSupplierInventoryGoodsMapper erpSupplierInventoryGoodsMapper; + + @Resource + private TErpSupplierWarehousingMapper erpSupplierWarehousingMapper; + + @Resource + private TErpSupplierWarehousingBatchMapper erpSupplierWarehousingBatchMapper; + + @Resource + private TErpSupplierOutboundMapper erpSupplierOutboundMapper; + + @Resource + private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper; @Override public PageInfo<TErpGoodsVO> pageList(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()){ + 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()){ + 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())); @@ -59,12 +81,12 @@ @Override public List<TErpGoodsVO> listExport(TErpGoodsQuery query, SysUser user) { - List<TErpGoodsVO> list = this.baseMapper.listExport(query,user); - if(list.isEmpty()){ + List<TErpGoodsVO> list = this.baseMapper.listExport(query, user); + if (list.isEmpty()) { return list; } List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList()); - if(!typeIds.isEmpty()){ + 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())); @@ -72,15 +94,15 @@ } } List<String> lowUnitIds = list.stream().map(TErpGoods::getLowUnitId).collect(Collectors.toList()); - if(!lowUnitIds.isEmpty()){ + if (!lowUnitIds.isEmpty()) { List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(lowUnitIds); for (TErpGoodsVO tErpGoodsVO : list) { tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getLowUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setLowUnitName(t.getUnitName())); } } List<String> packingUnitId = list.stream().map(TErpGoods::getPackingUnitId).collect(Collectors.toList()); - if(!packingUnitId.isEmpty()){ - List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(lowUnitIds); + if (!packingUnitId.isEmpty()) { + List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId); for (TErpGoodsVO tErpGoodsVO : list) { tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName())); } @@ -89,12 +111,133 @@ } @Override - public boolean isExit(String goodsIdCode,String quasiNumber) { + 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)); - if(size>0){ + if (size > 0) { return true; } return false; } + + @Override + public PageInfo<TErpGoodsInventoryVO> pageInventoryGoodsPageList(TErpGoodsInventoryQuery query, SysUser user) { + PageInfo<TErpGoodsInventoryVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); + List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsPageList(query, pageInfo, user); + if (list.isEmpty()) { + return pageInfo; + } + List<String> typeIds = list.stream().map(TErpGoodsInventoryVO::getTypeId).collect(Collectors.toList()); + if (!typeIds.isEmpty()) { + List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); + for (TErpGoodsInventoryVO tErpGoodsVO : list) { + typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); + tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); + } + } + List<String> packingUnitId = list.stream().map(TErpGoodsInventoryVO::getPackingUnitId).collect(Collectors.toList()); + if (!packingUnitId.isEmpty()) { + List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId); + for (TErpGoodsInventoryVO tErpGoodsVO : list) { + tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName())); + } + } + pageInfo.setRecords(list); + return pageInfo; + } + + @Override + public void inventoryGoods(InventoryDto dto, SysUser user) { + TErpSupplierInventory tErpSupplierInventory = new TErpSupplierInventory(); + String s = DateUtils.dateTimeNow(); + tErpSupplierInventory.setInventoryNumber("P" + s); + tErpSupplierInventory.setWarehouseId(dto.getWarehouseId()); + tErpSupplierInventory.setSupplierId(String.valueOf(user.getUserId())); + erpSupplierInventoryMapper.insert(tErpSupplierInventory); + + List<InventoryGoodsDto> dtos = dto.getDtos(); + for (InventoryGoodsDto inventoryGoodsDto : dtos) { + // 根据入库批次id查询入库信息 + TErpSupplierWarehousing tErpSupplierWarehousing = new TErpSupplierWarehousing(); + TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(inventoryGoodsDto.getId()); + String warehousingId = tErpSupplierWarehousingBatch.getWarehousingId(); + TErpSupplierWarehousing tErpSupplierWarehousing1 = erpSupplierWarehousingMapper.selectById(warehousingId); + TErpGoods erpGoods = this.getById(tErpSupplierWarehousing1.getGoodsId()); + + // 盘点是盘亏盘盈 赢 + if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) { + // 添加入库信息 + tErpSupplierWarehousing.setWarehouseId(dto.getWarehouseId()); + tErpSupplierWarehousing.setSupplierId(String.valueOf(user.getUserId())); + 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()))); + // 当前年月日时分秒 + String time = DateUtils.dateTimeNow(); + tErpSupplierWarehousing.setWarehouseNo("G" + time); + tErpSupplierWarehousing.setType(2); + erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing); + + // 添加批次信息 + TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpSupplierWarehousingBatch(); + tErpSupplierWarehousingBatch1.setWarehousingId(tErpSupplierWarehousing.getId()); + tErpSupplierWarehousingBatch1.setWarehousingNumber(tErpSupplierWarehousing.getGoodsCount()); + tErpSupplierWarehousingBatch1.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber()); + tErpSupplierWarehousingBatch1.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate()); + tErpSupplierWarehousingBatch1.setExpiryDate(tErpSupplierWarehousingBatch.getExpiryDate()); + erpSupplierWarehousingBatchMapper.insert(tErpSupplierWarehousingBatch1); + + + // 添加盘点信息 + TErpSupplierInventoryGoods tErpSupplierInventoryGoods = new TErpSupplierInventoryGoods(); + tErpSupplierInventoryGoods.setInventoryId(tErpSupplierInventory.getId()); + tErpSupplierInventoryGoods.setWarehousingId(tErpSupplierWarehousing.getId()); + tErpSupplierInventoryGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch1.getId()); + tErpSupplierInventoryGoods.setInventoryCount(inventoryGoodsDto.getInventoryCount()); + tErpSupplierInventoryGoods.setDamagedCount(inventoryGoodsDto.getDamagedCount()); + tErpSupplierInventoryGoods.setInventoryType(1); + tErpSupplierInventoryGoods.setGoodsId(tErpSupplierWarehousing1.getGoodsId()); + erpSupplierInventoryGoodsMapper.insert(tErpSupplierInventoryGoods); + + } else { + + + TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound(); + tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); + tErpSupplierOutbound.setSupplierId(String.valueOf(user.getUserId())); + tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing1.getGoodsId()); + tErpSupplierOutbound.setOutboundType(6); + tErpSupplierOutbound.setOutboundNumber("G" + s); + int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount(); + tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); + tErpSupplierOutbound.setGoodsId(erpGoods.getId()); + erpSupplierOutboundMapper.insert(tErpSupplierOutbound); + + + TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods(); + tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); + tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing.getId()); + tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId()); + tErpSupplierOutboundGoods.setOutboundCount(count); + tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); + erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods); + + + // 添加盘点信息 + TErpSupplierInventoryGoods tErpSupplierInventoryGoods = new TErpSupplierInventoryGoods(); + tErpSupplierInventoryGoods.setInventoryId(tErpSupplierInventory.getId()); + tErpSupplierInventoryGoods.setWarehousingId(tErpSupplierOutbound.getId()); + tErpSupplierInventoryGoods.setWarehousingBatchId(tErpSupplierOutboundGoods.getId()); + tErpSupplierInventoryGoods.setInventoryCount(inventoryGoodsDto.getInventoryCount()); + tErpSupplierInventoryGoods.setDamagedCount(inventoryGoodsDto.getDamagedCount()); + tErpSupplierInventoryGoods.setInventoryType(2); + tErpSupplierInventoryGoods.setGoodsId(tErpSupplierWarehousing1.getGoodsId()); + erpSupplierInventoryGoodsMapper.insert(tErpSupplierInventoryGoods); + } + } + + + } } -- Gitblit v1.7.1