liujie
2 天以前 283ea8cfd97f225d0451d57bf915e6f3a0f2041b
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpClinicWarehousingServiceImpl.java
@@ -8,6 +8,7 @@
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.dto.ClinicOutboundGoodsDto;
import com.ruoyi.system.dto.OutboundGoodsNextDto;
import com.ruoyi.system.dto.WarehouseGoodsDto;
import com.ruoyi.system.dto.clinicWarehouseGoodsDto;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.*;
@@ -182,6 +183,40 @@
                    inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount());
                    inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType());
                    inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount());
                }else {
                    TErpClinicOutbound tErpSupplierOutbound = erpClinicOutboundMapper.selectById(tErpSupplierInventoryGood.getWarehousingId());
                    List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getOutboundId, tErpSupplierOutbound.getId()));
                    for (TErpClinicOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) {
                        String warehousingId = tErpSupplierOutboundGood.getWarehousingId();
                        TErpClinicWarehousing tErpSupplierWarehousing = erpClinicWarehousingMapper.selectById(warehousingId);
                        String goodsId = tErpSupplierInventoryGood.getGoodsId();
                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                        inventoryDetailVo.setGoodsName(goods.getGoodsName());
                        TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId());
                        inventoryDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
                        inventoryDetailVo.setWarehouseNo(tErpSupplierWarehousing.getWarehouseNo());
                        TErpClinicOutboundGoods outboundGoods = erpClinicOutboundGoodsMapper.selectById(tErpSupplierInventoryGood.getWarehousingBatchId());
                        TErpClinicWarehousingBatch tErpSupplierWarehousingBatch = erpClinicWarehousingBatchMapper.selectById(outboundGoods.getWarehousingBatchId());
                        inventoryDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                        List<TErpClinicWarehousingBatch> tErpSupplierWarehousingBatches = erpClinicWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpClinicWarehousingBatch>().eq(TErpClinicWarehousingBatch::getBatchNumber, tErpSupplierWarehousingBatch.getBatchNumber()));
                        int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpClinicWarehousingBatch::getWarehousingNumber).sum();
                        List<String> collect = tErpSupplierWarehousingBatches.stream().map(TErpClinicWarehousingBatch::getId).collect(Collectors.toList());
                        if(!collect.isEmpty()){
                            List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods1 = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, collect));
                            int sum1 = tErpSupplierOutboundGoods1.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum();
                            sum = sum-sum1;
                        }
                        // sum = 剩余库存
                        inventoryDetailVo.setNowCount(sum);
                        inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount());
                        inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType());
                        inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount());
                    }
                }
                inventoryDetailVos.add(inventoryDetailVo);
@@ -238,6 +273,24 @@
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public List<TErpGoodsVO> pageList1(TErpGoodsQuery query, SysUser user) {
        List<TErpGoodsVO> list = this.baseMapper.pageList1(query,user);
        if(list.isEmpty()){
            return list;
        }
        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()));
                tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName());
            }
        }
        return list;
    }
    @Override
    public PageInfo<TErpClinicWarehousePageListVO> warehousePageList(TClinicWarehouseQuery query, SysUser user, String supplierClinicId) {
@@ -282,31 +335,29 @@
    }
    @Override
    public void warehouseGoods(List<clinicWarehouseGoodsDto> dtos, SysUser user, String supplierClinicId) {
    public void warehouseGoods(WarehouseGoodsDto dtos, SysUser user, String supplierClinicId) {
        // dtos根据供应商分组
        Map<String, List<clinicWarehouseGoodsDto>> collect = dtos.stream().collect(Collectors.groupingBy(clinicWarehouseGoodsDto::getSupplierId));
//        Map<String, List<clinicWarehouseGoodsDto>> collect = dtos.stream().collect(Collectors.groupingBy(clinicWarehouseGoodsDto::getSupplierId));
        for (Map.Entry<String, List<clinicWarehouseGoodsDto>> stringListEntry : collect.entrySet()) {
            String key = stringListEntry.getKey();
            List<clinicWarehouseGoodsDto> value = stringListEntry.getValue();
//        for (Map.Entry<String, List<clinicWarehouseGoodsDto>> stringListEntry : collect.entrySet()) {
            TErpClinicWarehousing tErpClinicWarehousing = new TErpClinicWarehousing();
            tErpClinicWarehousing.setClinicId(supplierClinicId);
            tErpClinicWarehousing.setCreateId(user.getUserId().toString());
            tErpClinicWarehousing.setWarehouseNo("G"+ DateUtils.dateTimeNow());
            tErpClinicWarehousing.setCreateTime(LocalDateTime.now());
            tErpClinicWarehousing.setSupplierId(key);
            tErpClinicWarehousing.setType(3);
            tErpClinicWarehousing.setStatus(dtos.getStatus());
            this.save(tErpClinicWarehousing);
            BigDecimal totalPrice = new BigDecimal(0);
            for (clinicWarehouseGoodsDto dto : value) {
            for (clinicWarehouseGoodsDto dto : dtos.getDtos()) {
                TErpClinicWarehousingBatch tErpClinicWarehousingBatch = new TErpClinicWarehousingBatch();
                tErpClinicWarehousingBatch.setWarehousingId(tErpClinicWarehousing.getId());
                tErpClinicWarehousingBatch.setWarehousingNumber(dto.getPurchaseCount());
                tErpClinicWarehousingBatch.setBatchNumber(dto.getBatchNumber());
                tErpClinicWarehousingBatch.setProductionDate(dto.getProductionDate());
                tErpClinicWarehousingBatch.setExpiryDate(dto.getExpiryDate());
                tErpClinicWarehousingBatch.setProductionDate(dto.getProductionDate().atStartOfDay());
                tErpClinicWarehousingBatch.setExpiryDate(dto.getExpiryDate().atStartOfDay());
                tErpClinicWarehousingBatch.setGoodsId(dto.getId());
                TErpGoods goods = erpGoodsMapper.selectById(dto.getId());
                tErpClinicWarehousingBatch.setGoodsName(goods.getGoodsName());
@@ -324,7 +375,7 @@
            tErpClinicWarehousing.setTotalPrice(totalPrice);
            this.updateById(tErpClinicWarehousing);
        }
//        }
    }