package org.jeecg.modules.lsw.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.modules.base.entity.Factory; import org.jeecg.modules.base.entity.LineSideWarehouse; import org.jeecg.modules.base.enums.ProductionTypeEnum; import org.jeecg.modules.base.service.IFactoryService; import org.jeecg.modules.base.service.ILineSideWarehouseService; import org.jeecg.modules.lsw.entity.LswMaterial; import org.jeecg.modules.lsw.entity.LswMaterialInventory; import org.jeecg.modules.lsw.enums.MaterialCategoryEnum; import org.jeecg.modules.lsw.enums.MaterialInventoryStatusEnum; import org.jeecg.modules.lsw.mapper.LswMaterialInventoryMapper; import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; import org.jeecg.modules.lsw.service.ILswMaterialService; import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; import org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO; import org.jeecg.modules.lsw.vo.MaterialInventoryVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @Description: 物料库存信息 * @Author: jeecg-boot * @Date: 2025-06-30 * @Version: V1.0 */ @Service public class LswMaterialInventoryServiceImpl extends ServiceImpl implements ILswMaterialInventoryService { @Autowired private LswMaterialInventoryMapper lswMaterialInventoryMapper; @Autowired private ILswMaterialService materialService; @Autowired private ILineSideWarehouseService lineSideWarehouseService; @Autowired private IFactoryService factoryService; @Override public List selectLineSideMaterialInventoryByMaterialNumber(List bomMaterialNumberList, String factoryId) { return lswMaterialInventoryMapper.selectLineSideMaterialInventoryByMaterialNumber(bomMaterialNumberList, factoryId); } @Override public List statisticsInventory(String materialId) { return lswMaterialInventoryMapper.statisticsInventory(materialId); } @Override public LswMaterialInventory queryByMaterialNumberAndBatchNumber(String materialNumber, String batchNumber, String warehouseId) { LswMaterial material = materialService.queryByMaterialNumber(materialNumber); if (material == null) { return null; } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(LswMaterialInventory::getWarehouseId, warehouseId); queryWrapper.eq(LswMaterialInventory::getMaterialId, material.getId()); queryWrapper.eq(LswMaterialInventory::getBatchNumber, batchNumber); queryWrapper.eq(LswMaterialInventory::getInventoryStatus, MaterialInventoryStatusEnum.NORMAL.name()); return lswMaterialInventoryMapper.selectOne(queryWrapper); } @Override public List queryMaterialInventory(String factoryId) { Factory factory = factoryService.getById(factoryId); if (factory == null) { return Collections.emptyList(); } LineSideWarehouse warehouse = lineSideWarehouseService.queryByFactoryId(factoryId); if (warehouse == null) { return Collections.emptyList(); } List materialCategory = new ArrayList<>(); if (ProductionTypeEnum.ASSEMBLE.name().equals(factory.getProductionType())) { materialCategory.add(MaterialCategoryEnum.OUTER_FLANGE.name()); materialCategory.add(MaterialCategoryEnum.INNER_FLANGE.name()); materialCategory.add(MaterialCategoryEnum.SMALL_INNER_RING.name()); materialCategory.add(MaterialCategoryEnum.STEEL_BALL.name()); materialCategory.add(MaterialCategoryEnum.COMPONENTS.name()); } else if (ProductionTypeEnum.INNERFLANGE.name().equals(factory.getProductionType())) { materialCategory.add(MaterialCategoryEnum.BLANK.name()); } else if (ProductionTypeEnum.OUTERFLANGE.name().equals(factory.getProductionType())) { materialCategory.add(MaterialCategoryEnum.BLANK.name()); } else if (ProductionTypeEnum.HEATTREATMENT.name().equals(factory.getProductionType())) { materialCategory.add(MaterialCategoryEnum.BLANK.name()); } return lswMaterialInventoryMapper.queryMaterialInventory(warehouse.getId(), materialCategory); } }