package org.jeecg.modules.base.service.impl; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.jeecg.modules.base.entity.ProductionLineWarehouseClient; import org.jeecg.modules.base.mapper.FactoryModelMapper; import org.jeecg.modules.base.mapper.ProductionLineWarehouseClientMapper; import org.jeecg.modules.base.service.IProductionLineWarehouseClientService; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; /** * @Description: 线边库服务对象 * @Author: jeecg-boot * @Date: 2023-01-28 * @Version: V1.0 */ @Service public class ProductionLineWarehouseClientServiceImpl extends ServiceImpl implements IProductionLineWarehouseClientService { @Autowired private ProductionLineWarehouseClientMapper productionLineWarehouseClientMapper; @Autowired private FactoryModelMapper factoryModelMapper; @Override public List selectByMainId(String mainId) { return productionLineWarehouseClientMapper.selectByMainId(mainId); } @Override public Page> getFactoryList(Page> page, Integer version, String parentId, List ids) { return page.setRecords(baseMapper.getFactoryList(page,version,getAllChild(parentId),ids)); } public List getAllChild(String parentId){ List list = factoryModelMapper.getAllChildrenIdByParentId(parentId); CopyOnWriteArrayList cowList = new CopyOnWriteArrayList<>(); cowList.addAll(list); if(CollectionUtils.isNotEmpty(cowList)){ cowList.forEach(str->{ cowList.addAll(getAllChild(str)); }); } cowList.add(parentId); return cowList; } }