| | |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.mapper.ConfigMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | @Resource |
| | | private ConfigMapper configMapper; |
| | | |
| | | /** |
| | | * 生成工作号 |
| | |
| | | // 可用堆垛机列表 |
| | | List<Integer> crnNoList = basCrnps.stream().map(BasCrnp::getCrnNo).collect(Collectors.toList()); |
| | | |
| | | // 获取备货区配置 |
| | | Config config = configMapper.selectConfigByCode("auto_stock_up"); |
| | | if (config == null) { |
| | | throw new CoolException("理货获取备货区配置错误!!!"); |
| | | } |
| | | |
| | | // 前几列是备货区 |
| | | int columnNum = Integer.parseInt(config.getValue()); |
| | | |
| | | // 搜索深库位 |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","O").in("crn_no",crnNoList).in("row1","1,4,5,8,9,12,13,16,17,20,21,24").orderBy("lev1,bay1,row1")); |
| | | .eq("loc_sts","O").in("crn_no",crnNoList).in("row1","1,4,5,8,9,12,13,16,17,20,21,24").orderBy("lev1,bay1,row1") |
| | | .gt("bay1",columnNum)); |
| | | |
| | | // 深库位没有则搜索浅库位 |
| | | if (locMasts.isEmpty()) { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","O").in("crn_no",crnNoList).in("row1","2,3,6,7,10,11,14,15,18,19,22,23").orderBy("lev1,bay1,row1")); |
| | | .eq("loc_sts","O").in("crn_no",crnNoList).in("row1","2,3,6,7,10,11,14,15,18,19,22,23").orderBy("lev1,bay1,row1") |
| | | .gt("bay1",columnNum)); |
| | | } |
| | | if (locMasts.isEmpty()) { |
| | | throw new CoolException("没有可用库位"); |
| | | } |
| | | |
| | | // 浅库位 |
| | | String[] split = "02,03,06,07,10,11,14,15,18,19,22,23".split(","); |
| | | // 记录堆垛机是否查询过,避免重复查询 |
| | | Map<Integer,Boolean> crnMap = new HashMap<>(); |
| | | for (LocMast mast : locMasts) { |
| | | if (crnMap.get(mast.getCrnNo()) == null) { |
| | | //预留空库位 |
| | | if (locMastService.checkEmptyCount(mast, 10)) { |
| | | Integer row1 = mast.getRow1(); |
| | | if(slaveProperties.getDoubleLocs().contains(row1)){ |
| | | // 取浅库位 |
| | | String s = split[slaveProperties.getDoubleLocs().indexOf(row1)]; |
| | | LocMast locMast1 = locMastService.selectById(s + mast.getLocNo().substring(2)); |
| | | if(locMast1 != null && !locMast1.getLocSts().equals("O")) { |
| | | log.warn("入库分配库位:{},对应浅库位{}不为空:{}",mast.getLocNo(),locMast1.getLocNo(),locMast1.getLocSts()); |
| | | continue; |
| | | } |
| | | } |
| | | locMast = mast; |
| | | break; |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | if (locMast == null) { |
| | | log.error("入库请求库位不足,剩余库位不足/不满足入库条件"); |
| | | throw new CoolException("入库请求库位不足,剩余数量不足/不满足入库条件"); |
| | | } |
| | | |
| | | return locMast; |
| | | } |
| | | |