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.ProductionLineWarehouse; import org.jeecg.modules.base.entity.Warehouse; import org.jeecg.modules.base.mapper.ProductionLineWarehouseClientMapper; import org.jeecg.modules.base.mapper.ProductionLineWarehouseMapper; import org.jeecg.modules.base.service.IProductionLineWarehouseService; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import java.io.Serializable; import java.util.*; /** * @Description: 线边库管理 * @Author: jeecg-boot * @Date: 2023-01-28 * @Version: V1.0 */ @Service public class ProductionLineWarehouseServiceImpl extends ServiceImpl implements IProductionLineWarehouseService { @Autowired private ProductionLineWarehouseMapper productionLineWarehouseMapper; @Autowired private ProductionLineWarehouseClientMapper productionLineWarehouseClientMapper; @Override public Integer getInitVersion() { List usableVersionList = productionLineWarehouseMapper.getUsableList(); Set allVersionList = getVersionList(); if(CollectionUtils.isNotEmpty(usableVersionList)){ return usableVersionList.get(0).getVersion(); }else if(CollectionUtils.isNotEmpty(allVersionList)){ return allVersionList.stream().findFirst().get(); } return null; } @Override public Page> getWarehouseList(Page> page, Integer version, String workshopId) { return page.setRecords(productionLineWarehouseMapper.getWarehouseList(page,version,workshopId)); } @Override @Transactional(rollbackFor = Exception.class) public void delMain(String id) { productionLineWarehouseClientMapper.deleteByMainId(id); productionLineWarehouseMapper.deleteById(id); } @Override @Transactional(rollbackFor = Exception.class) public void delBatchMain(Collection idList) { for(Serializable id:idList) { productionLineWarehouseClientMapper.deleteByMainId(id.toString()); productionLineWarehouseMapper.deleteById(id); } } @Override public Set getVersionList() { Set set = new TreeSet(Comparator.reverseOrder()); set.addAll(productionLineWarehouseMapper.getAllVersion()); return set; } @Override public List getLastUsableList() { return productionLineWarehouseMapper.getLastUsableList(); } @Override public List getUsableList() { return productionLineWarehouseMapper.getUsableList(); } @Override public Map getNowAndLastUsableVersion() { List usableList = productionLineWarehouseMapper.getUsableList(); List lastUsableList = productionLineWarehouseMapper.getLastUsableList(); Map map = new HashMap<>(2); if(CollectionUtils.isNotEmpty(usableList)){ map.put("usableVersion",usableList.get(0).getVersion()); } if(CollectionUtils.isNotEmpty(lastUsableList)){ map.put("lastUsableVersion",lastUsableList.get(0).getVersion()); } return map; } @Override public List getVersionStatusByVersion(Integer version) { return productionLineWarehouseMapper.getVersionStatusByVersion(version); } }