#
Junjie
2026-01-12 9dc731ba8d1a20da3556879f0b41630bfd73dec3
src/main/java/com/zy/common/service/CommonService.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
@Slf4j
@Service
@@ -43,6 +44,8 @@
    private NavigateUtils navigateUtils;
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private BasOutStationAreaService basOutStationAreaService;
    /**
     * 生成工作号
@@ -302,7 +305,23 @@
        }
        Integer crnNo = findCrnResult.getCrnNo();
        Integer sourceStationId = this.findOutStationId(findCrnResult, param.getStaNo());
        Integer staNo = param.getStaNo();
        String outArea = param.getOutArea();
        if(Cools.isEmpty(staNo) && Cools.isEmpty(outArea)) {
            throw new CoolException("请传入出库站点或出库区域");
        }
        if(Cools.isEmpty(staNo)) {
            List<BasOutStationArea> areaList = basOutStationAreaService.selectList(new EntityWrapper<BasOutStationArea>().eq("area_code", outArea));
            if (areaList.isEmpty()) {
                throw new CoolException("出库区域不存在");
            }
            int nextInt = new Random().nextInt(areaList.size());
            BasOutStationArea basOutStationArea = areaList.get(nextInt);
            staNo = basOutStationArea.getStationId();
        }
        Integer sourceStationId = this.findOutStationId(findCrnResult, staNo);
        if (sourceStationId == null) {
            throw new CoolException("未找到输送目标站点可走行路径");
        }
@@ -318,7 +337,7 @@
        wrkMast.setIoPri(ioPri);
        wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位
        wrkMast.setSourceStaNo(sourceStationId);//源站
        wrkMast.setStaNo(param.getStaNo());//目标站
        wrkMast.setStaNo(staNo);//目标站
        wrkMast.setWmsWrkNo(param.getTaskNo());
        wrkMast.setBarcode(locMast.getBarcode());
        wrkMast.setAppeTime(now);
@@ -427,7 +446,7 @@
                    break;
                }
            } catch (Exception e) {
                e.printStackTrace();
//                e.printStackTrace();
            }
        }
        return targetStationId;
@@ -459,7 +478,7 @@
                    break;
                }
            } catch (Exception e) {
                e.printStackTrace();
//                e.printStackTrace();
            }
        }
        return finalSourceStationId;