heheng
2025-03-06 8b1d6e1b442c1909bd747805bd1845b40caabe0c
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatServiceImpl.java
@@ -46,6 +46,7 @@
    @Autowired
    private HzWarehouseMapper warehouseMapper;
    @Override
    public CommonPage selectHazmatList(HzHazmat hzHazmat) {
        if(hzHazmat.getWarehouseId()==null||hzHazmat.getBasicId()==null){
@@ -74,19 +75,28 @@
        if(!hazmatList.isEmpty()) {
            List<Long> warehouseIds = hazmatList.stream().map(HzHazmatWarehouseVO::getWarehouseId).collect(Collectors.toList());
            List<Long> basicIds = hazmatList.stream().map(HzHazmatWarehouseVO::getBasicId).collect(Collectors.toList());
            List<Integer> cupboardIds = hazmatList.stream().map(HzHazmatWarehouseVO::getCupboardId).collect(Collectors.toList());
            List<HzHazmatBasic> hazmatBasicList = hazmatBasicMapper.selectHazmatBasicListByIds(basicIds);
            List<HzWarehouse> warehouseList = warehouseMapper.selectWarehouseListByIds(warehouseIds);
            List<HzWarehouseCupboard> hzWarehouseCupboards = warehouseMapper.selectByCupboardIds(cupboardIds);
            Map<Long,HzHazmatBasic> hazmatBasicMap=hazmatBasicList.stream().collect(Collectors.toMap(HzHazmatBasic::getId, item->item));
            Map<Long,HzWarehouse> warehouseMap=warehouseList.stream().collect(Collectors.toMap(HzWarehouse::getId, item->item));
            Map<Integer, HzWarehouseCupboard> cupboardMap = hzWarehouseCupboards.stream().collect(Collectors.toMap(HzWarehouseCupboard::getId, item -> item));
            for(HzHazmatWarehouseVO hazmatWarehouseVO:hazmatList){
                HzHazmatBasic hazmatBasic=hazmatBasicMap.get(hazmatWarehouseVO.getBasicId());
                HzWarehouse warehouse=warehouseMap.get(hazmatWarehouseVO.getWarehouseId());
                HzWarehouseCupboard hzWarehouseCupboard = cupboardMap.get(hazmatWarehouseVO.getCupboardId());
                if(hazmatBasic!=null){
                    hazmatWarehouseVO.setHazmatBasic(hazmatBasic);
                }
                if(warehouse!=null){
                    hazmatWarehouseVO.setWarehouseName(warehouse.getName());
                }
                if (hzWarehouseCupboard != null){
                    hazmatWarehouseVO.setCupboardName(hzWarehouseCupboard.getCupboardName());
                }
            }
        }
        IdTableNameHandler.removeCurrentId();
@@ -153,7 +163,7 @@
        }
        checkUserAllowed(hazmat,currentUser);
        //获取变动前仓库库存
        int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId());
        int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId(),hazmat.getCupboardId());
        //生成流向
        BigDecimal remaining=hazmat.getRemaining();
@@ -185,6 +195,7 @@
        HzWarehouseRecord warehouseRecord = new HzWarehouseRecord()
                .setWarehouseId(hazmat.getWarehouseId())
                .setBasicId(hazmat.getBasicId())
                .setCupboardId(hazmat.getCupboardId())
                .setCreateId(currentUser.getId())
                .setNum(-1)
                .setState(OperateStatusEnum.USING.getCode())
@@ -220,7 +231,7 @@
        }
        checkUserAllowed(dbhazmat,currentUser);
        //获取变动前仓库库存
        int count = baseMapper.selectHazmatCountOfWarehouse(dbhazmat.getWarehouseId(), dbhazmat.getBasicId(), currentUser.getCompanyId());
        int count = baseMapper.selectHazmatCountOfWarehouse(dbhazmat.getWarehouseId(), dbhazmat.getBasicId(), currentUser.getCompanyId(),dbhazmat.getCupboardId());
        hazmat.setState(HazmatStatusEnum.USEWAREHOUSEIN.getCode());
        hazmat.setUpdateBy(currentUser.getUsername());
        updateById(hazmat);
@@ -239,6 +250,7 @@
        HzWarehouseRecord warehouseRecord = new HzWarehouseRecord()
                .setWarehouseId(dbhazmat.getWarehouseId())
                .setBasicId(dbhazmat.getBasicId())
                .setCupboardId(hazmat.getCupboardId())
                .setCreateId(currentUser.getId())
                .setNum(1)
                .setState(OperateStatusEnum.RETURN.getCode())
@@ -289,7 +301,7 @@
        }
        checkUserAllowed(hazmat,currentUser);
        //获取变动前仓库库存
        int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId());
        int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId(),hazmat.getCupboardId());
        hazmat.setState(HazmatStatusEnum.DISCARD.getCode());
        hazmat.setUpdateBy(currentUser.getUsername());
        updateById(hazmat);
@@ -308,6 +320,7 @@
        HzWarehouseRecord warehouseRecord = new HzWarehouseRecord()
                .setWarehouseId(hazmat.getWarehouseId())
                .setBasicId(hazmat.getBasicId())
                .setCupboardId(hazmat.getCupboardId())
                .setCreateId(currentUser.getId())
                .setNum(-1)
                .setState(OperateStatusEnum.DISCARD.getCode())