| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.result.KeyValueVo; |
| | | import com.zy.asrs.mapper.LocMastMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.Shelves; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * 货架核心功能 |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | |
| | | @Resource |
| | | private LocMastMapper locMastMapper; |
| | | |
| | | /** |
| | | * 生成工作号 |
| | |
| | | }catch (Exception e){ |
| | | log.error("站点={} 未查询到对应的规则",sourceStaNo); |
| | | } |
| | | return null; |
| | | throw new CoolException("获取库位异常"); |
| | | } |
| | | |
| | | /** |
| | | * 获取库位,杰上杰用 |
| | | * @param ioType 1全板入库,10空托盘组入库 |
| | | * @param sourceSite 源站点 |
| | | * @param locType 库位检测信息 0空托1列,1一层,2.2-4层,3.5-9层 |
| | | * @return 目标库位信息 |
| | | */ |
| | | @Transactional |
| | | public StartupDto getLocNoRunNew(Integer ioType, Integer sourceSite, Integer locType) { |
| | | |
| | | // 根据入库类型和源站点获取工作路径 |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("type_no", ioType).eq("crn_stn", sourceSite)); |
| | | if (staDesc == null) { |
| | | throw new CoolException("获取工作路径异常:" + ioType + " , " + sourceSite); |
| | | } |
| | | |
| | | // 寻找到的库位 |
| | | LocMast locMast = null; |
| | | |
| | | // 按库位类型获取库位 |
| | | List<LocMast> locMasts = locMastMapper.selectLocByTypeToList(locType, staDesc.getCrnNo()); |
| | | |
| | | // todo 如果当前类型库位剩余不多,是一直放满,还是兼容到下一种库位类型 |
| | | // 考虑移库需要同类型库位,这里限制不能放满,兼容下一种库位类型 |
| | | if (locMasts.size() <= 4) { |
| | | switch (locType) { |
| | | case 0: |
| | | case 2: |
| | | return getLocNoRunNew(ioType, sourceSite, 3); |
| | | case 1: |
| | | case 3: |
| | | throw new CoolException("当前库位剩余四个用于移库,无法占用:" + locType); |
| | | default: |
| | | } |
| | | } |
| | | |
| | | // 先取深库位 |
| | | Optional<LocMast> first = locMasts.stream().filter(o -> o.getRow1() == 1 || o.getRow1() == 4 || o.getRow1() == 5 || o.getRow1() == 8).findFirst(); |
| | | if (first.isPresent()) { |
| | | locMast = first.get(); |
| | | } else { |
| | | // 深库位里面没有从浅库位里面取 |
| | | Optional<LocMast> first2 = locMasts.stream().filter(o -> o.getRow1() == 2 || o.getRow1() == 3 || o.getRow1() == 5 || o.getRow1() == 7).findFirst(); |
| | | if(first2.isPresent()) { |
| | | locMast = first2.get(); |
| | | } |
| | | } |
| | | |
| | | if (locMast == null) { |
| | | throw new CoolException("没有找到合适空库位"); |
| | | } |
| | | |
| | | // 生成工作号 |
| | | int workNo = getWorkNo(0); |
| | | // 返回dto |
| | | StartupDto startupDto = new StartupDto(); |
| | | startupDto.setWorkNo(workNo); |
| | | startupDto.setCrnNo(staDesc.getCrnNo()); |
| | | startupDto.setSourceStaNo(staDesc.getStnNo()); |
| | | startupDto.setStaNo(sourceSite); |
| | | startupDto.setLocNo(locMast.getLocNo()); |
| | | |
| | | return startupDto; |
| | | } |
| | | |
| | | /** |
| | |
| | | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc).eq("loc_sts", "F").eq("whs_type",rowLastnoType.getType().longValue())); |
| | | if (!Cools.isEmpty(locMast2)) { |
| | | locMast = locMast2; |
| | | locMast = locMast1; |
| | | break; |
| | | } else { |
| | | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc).eq("loc_sts", "D").eq("whs_type",rowLastnoType.getType().longValue())); |
| | | if (!Cools.isEmpty(locMast2)) { |
| | | locMast = locMast2; |
| | | locMast = locMast1; |
| | | break; |
| | | } |
| | | } |