危化品全生命周期管理后端
heheng
2025-02-26 996c091a4913ac768324b7ea69a8494ba9d6ece0
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();
@@ -220,7 +230,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);
@@ -289,7 +299,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);