crm
xuhy
2025-09-05 7dcc47fd202ae6827be18217f9676f7576bf91ce
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -3,6 +3,8 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.dto.WarehousingGoodsDto;
import com.ruoyi.system.dto.WarehousingGoodsNextDto;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TErpGoodsQuery;
@@ -123,7 +125,7 @@
                    tErpGoodsWarehouseVO.setNowNum(tErpSupplierWarehousingBatch.getWarehousingNumber());
                }
                tErpGoodsWarehouseVO.setUnitAmount(new BigDecimal(tErpSupplierWarehousing.getUnitAmount()*tErpGoodsWarehouseVO.getNowNum()).setScale(2, RoundingMode.HALF_UP).doubleValue());
                tErpGoodsWarehouseVO.setUnitAmount(tErpSupplierWarehousing.getUnitAmount().multiply(new BigDecimal(tErpGoodsWarehouseVO.getNowNum())).setScale(2, RoundingMode.HALF_UP).doubleValue());
                tErpGoodsWarehouseVOS.add(tErpGoodsWarehouseVO);
            }
            tErpGoodsWarehouseLastVO.setAllNum(tErpGoodsWarehouseVOS.stream().mapToInt(TErpGoodsWarehouseVO::getNowNum).sum());
@@ -138,10 +140,75 @@
    @Override
    public PageInfo<TErpGoodsWarehouseRecordLastVO> pageWarehouseList(TErpGoodsWarehouseQuery query, SysUser user) {
        TErpGoods goods = erpGoodsMapper.selectById(query.getGoodsId());
        PageInfo<TErpGoodsWarehouseRecordLastVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TErpGoodsWarehouseRecordLastVO> list = this.baseMapper.pageWarehouseList(query,pageInfo,user);
        String sTime=null;
        String eTime =null;
        if(query.getTime()!=null && !query.getTime().isEmpty()){
            String[] split = query.getTime().split(" - ");
            sTime = split[0] + " 00:00:00";
            eTime = split[1] + " 23:59:59";
        }
        List<TErpGoodsWarehouseRecordLastVO> list = this.baseMapper.pageWarehouseList(query,pageInfo,user,sTime,eTime);
        for (TErpGoodsWarehouseRecordLastVO tErpGoodsWarehouseRecordLastVO : list) {
            ArrayList<TErpGoodsWarehouseVO> tErpGoodsWarehouseVOS = new ArrayList<>();
            if(tErpGoodsWarehouseRecordLastVO.getCategory()==1){
                List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getWarehousingId, tErpGoodsWarehouseRecordLastVO.getId()));
                for (TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch : tErpSupplierWarehousingBatches) {
                    TErpGoodsWarehouseVO tErpGoodsWarehouseVO = new TErpGoodsWarehouseVO();
                    tErpGoodsWarehouseVO.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                    tErpGoodsWarehouseVO.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate());
                    tErpGoodsWarehouseVO.setExpiryDate(tErpSupplierWarehousingBatch.getExpiryDate());
                    tErpGoodsWarehouseVO.setNowNum(tErpSupplierWarehousingBatch.getWarehousingNumber());
                    tErpGoodsWarehouseVOS.add(tErpGoodsWarehouseVO);
                }
            }else {
                List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getOutboundId, tErpGoodsWarehouseRecordLastVO.getId()));
                for (TErpSupplierOutboundGoods tErpSupplierOutboundGoods1 : tErpSupplierOutboundGoods) {
                    TErpGoodsWarehouseVO tErpGoodsWarehouseVO = new TErpGoodsWarehouseVO();
                    String warehousingBatchId = tErpSupplierOutboundGoods1.getWarehousingBatchId();
                    TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(warehousingBatchId);
                    tErpGoodsWarehouseVO.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                    tErpGoodsWarehouseVO.setExpiryDate(tErpSupplierWarehousingBatch.getExpiryDate());
                    tErpGoodsWarehouseVO.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate());
                    tErpGoodsWarehouseVO.setNowNum(tErpSupplierOutboundGoods1.getOutboundCount());
                    tErpGoodsWarehouseVOS.add(tErpGoodsWarehouseVO);
                }
            }
            tErpGoodsWarehouseRecordLastVO.setAllNum(tErpGoodsWarehouseVOS.stream().mapToInt(TErpGoodsWarehouseVO::getNowNum).sum());
            tErpGoodsWarehouseRecordLastVO.setWarningInventory(goods.getWarningInventory());
            tErpGoodsWarehouseRecordLastVO.setList(tErpGoodsWarehouseVOS);
        return null;
        }
        pageInfo.setRecords( list);
        return pageInfo;
    }
    @Override
    public void warehousingGoods(List<WarehousingGoodsDto> dtos, SysUser user) {
        for (WarehousingGoodsDto dto : dtos) {
            TErpSupplierWarehousing tErpSupplierWarehousing = new TErpSupplierWarehousing();
            tErpSupplierWarehousing.setSupplierId(user.getUserId().toString());
            tErpSupplierWarehousing.setWarehouseId(dto.getWarehouseId());
            tErpSupplierWarehousing.setGoodsId(dto.getGoodsId());
            TErpGoods goods = erpGoodsMapper.selectById(dto.getGoodsId());
            tErpSupplierWarehousing.setGoodsName(goods.getGoodsName());
            tErpSupplierWarehousing.setGoodsCount(tErpSupplierWarehousing.getGoodsCount());
            tErpSupplierWarehousing.setUnitAmount(tErpSupplierWarehousing.getUnitAmount());
            tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousing.getTotalPrice());
            erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
            List<WarehousingGoodsNextDto> warehousingGoodsNextDtos = dto.getWarehousingGoodsNextDtos();
            for (WarehousingGoodsNextDto warehousingGoodsNextDto : warehousingGoodsNextDtos) {
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = new TErpSupplierWarehousingBatch();
                tErpSupplierWarehousingBatch.setWarehousingId(tErpSupplierWarehousing.getId());
                tErpSupplierWarehousingBatch.setWarehousingNumber(warehousingGoodsNextDto.getWarehousingNum());
                tErpSupplierWarehousingBatch.setBatchNumber(warehousingGoodsNextDto.getBatchNumber());
                tErpSupplierWarehousingBatch.setProductionDate(warehousingGoodsNextDto.getProductionDate().atStartOfDay());
                tErpSupplierWarehousingBatch.setExpiryDate(warehousingGoodsNextDto.getExpiryDate().atStartOfDay());
                erpSupplierWarehousingBatchMapper.insert(tErpSupplierWarehousingBatch);
            }
        }
    }
}