|  |  |  | 
|---|
|  |  |  | return R.error("缺少容器参数"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | pda.setContainerType(Short.valueOf(pda.getContainerCode().substring(0, 2))); | 
|---|
|  |  |  | workService.emptyPlateIn(pda.getDevNo(), pda.getContainerCode(), pda.getContainerType(), getUserId(), false); | 
|---|
|  |  |  | workService.emptyPlateInV3(pda.getDevNo(), pda.getContainerCode(), pda.getContainerType(), getUserId(), false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/orderDetl/pakout/workNum") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R listWorkDetl(@RequestParam OrderDetl param) { | 
|---|
|  |  |  | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlMapper.listAnfmeByMatnr(param.getMatnr(), param.getThreeCode(), param.getOrderNo()); | 
|---|
|  |  |  | if (agvWrkDetls != null) { | 
|---|
|  |  |  | for (AgvWrkDetl agvWrkDetl : agvWrkDetls) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public R listWorkDetl() { | 
|---|
|  |  |  | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlMapper.listAnfmeByMatnr(); | 
|---|
|  |  |  | return R.ok(agvWrkDetls); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | Double sumAnfmeByMatnr(@Param("matnr") String matnr, @Param("threeCode") String threeCode, @Param("orderNo") String orderNo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Select("SELECT d.* from agv_wrk_detl d ,agv_wrk_mast m where d.wrk_no=m.wrk_no and m.io_type in (101,103,53) and d.matnr = #{matnr}   AND d.three_code = #{threeCode}  AND d.order_no = #{orderNo} AND d.process_sts != 1") | 
|---|
|  |  |  | List<AgvWrkDetl> listAnfmeByMatnr(@Param("matnr") String matnr, @Param("threeCode") String threeCode, @Param("orderNo") String orderNo); | 
|---|
|  |  |  | @Select("SELECT d.matnr,d.three_code,d.order_no,SUM(d.anfme) anfme from agv_wrk_detl d ,agv_wrk_mast m where d.wrk_no=m.wrk_no and m.io_type in (101,103,53)  AND d.process_sts != 1 GROUP BY d.matnr,d.three_code,d.order_no") | 
|---|
|  |  |  | List<AgvWrkDetl> listAnfmeByMatnr(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String emptyPlateInV2(String station, String containerCode, Short containerType, Long userId, boolean emptyAutoIn,String factory); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String emptyPlateInV3(String station, String containerCode, Short containerType, Long userId, boolean emptyAutoIn); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void emptyPlateOut(String station, int containerType, Long userId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //            return R.error("当前库位不为在库,或者空货架,不支持移库"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 校验楼层 | 
|---|
|  |  |  | if (agvLocMast.getLocType1() != 3) { // 不为箱壳区域 | 
|---|
|  |  |  | if (agvLocMast.getLocType1() != 3 && agvLocMast.getLocType1() != 6) { // 不为箱壳区域 | 
|---|
|  |  |  | if (agvLocMast.getFloor() != floor) { | 
|---|
|  |  |  | throw new CoolException("当前库位不支持跨楼层转移"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("当前库位请选择调拨单调拨!"); | 
|---|
|  |  |  | } else if ((agvLocMast.getFloor() == 2 || agvLocMast.getFloor() == 3) && (floor == 1 || floor == 4)) { | 
|---|
|  |  |  | throw new CoolException("当前库位请选择调拨回流单回退!"); | 
|---|
|  |  |  | } else if (agvLocMast.getFloor() == 1 && agvLocMast.getLev1() == 2 && floor == 4) { | 
|---|
|  |  |  | ioType = 11; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | ioType = 12; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (agvLocMast.getFloor() == 1) { | 
|---|
|  |  |  | if (agvLocMast.getLev1() == 1 && floor == 1) { | 
|---|
|  |  |  | ioType = 11; | 
|---|
|  |  |  | } else if (agvLocMast.getLev1() == 2 && floor == 4) { | 
|---|
|  |  |  | ioType = 11; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | ioType = 12; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //生成工作档 | 
|---|
|  |  |  | AgvWrkMast wrkMast = createWrkMastV2(1, 201L, devNo, locNo, containerCode, now, userId, containerType, agvLocMast.getPltType(), ctnNo); | 
|---|
|  |  |  | //生成工作档明细 | 
|---|
|  |  |  | long flowId = snowflakeIdWorker.nextId(); | 
|---|
|  |  |  | agvWaitPakinList.forEach(wp -> { | 
|---|
|  |  |  | createWrkDetlReWrite(wp.getMatnr(), wrkMast.getWrkNo(), wp.getOrderNo(), wp.getBatch(), wp.getAnfme(), wp.getSuppCode(), now, userId, wp.getThreeCode(), wp.getDeadTime(), wp.getProcessSts()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //修改入库通知档状态 | 
|---|
|  |  |  | agvWaitPakinService.updateIoStatus(containerCode, "Y"); | 
|---|
|  |  |  | //更新源站点状态 | 
|---|
|  |  |  | updateAgvBasDevp(agvBasDevp, "R", containerType); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //查询工作档 | 
|---|
|  |  |  | AgvWrkMast agvWrkMast1 = agvWrkMastService.selectByContainerCode(containerCode); | 
|---|
|  |  |  | if (!Cools.isEmpty(agvWrkMast1)) { | 
|---|
|  |  |  | throw new CoolException("当前货架已有入库任务,无法进行入库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), true, true); | 
|---|
|  |  |  | // 生成工作档 10.空板入库 | 
|---|
|  |  |  | createWrkMast(10, 201L, agvBasDevp.getDevNo(), agvLocMast.getLocNo(), containerCode, now, userId, containerType, agvLocMast.getPltType()); | 
|---|
|  |  |  | //更新源站点状态 | 
|---|
|  |  |  | updateAgvBasDevp(agvBasDevp, "R", containerType, containerCode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新目标库位状态和信息 | 
|---|
|  |  |  | updateAgvLocMast(agvLocMast, "S"); | 
|---|
|  |  |  | return agvLocMast.getLocNo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 入库 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public String emptyPlateInV3(String station, String containerCode, Short containerType, Long userId, boolean emptyAutoIn) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Short locType = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | AgvBasDevp agvBasDevp = agvBasDevpService.selectById(station); | 
|---|
|  |  |  | if (Cools.isEmpty(agvBasDevp)) { | 
|---|
|  |  |  | throw new CoolException("暂无" + station + "站点"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int br = 0; | 
|---|
|  |  |  | if (containerType == 21 && agvBasDevp.getFloor() == 2) { | 
|---|
|  |  |  | containerType = 20; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | switch (containerType) { | 
|---|
|  |  |  | case 10: | 
|---|
|  |  |  | br = 1; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 20: | 
|---|
|  |  |  | br = 2; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 21: | 
|---|
|  |  |  | br = 4; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 30: | 
|---|
|  |  |  | br = 3; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 31: | 
|---|
|  |  |  | br = 6; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 40: | 
|---|
|  |  |  | br = 5; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (br == 4 && agvBasDevp.getLocType1() == 2) { | 
|---|
|  |  |  | br = 2; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (agvBasDevp.getLocType1() != br) { | 
|---|
|  |  |  | throw new CoolException("站点类型和货架类型不符!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | AtomicReference<String> factory = new AtomicReference<>(); | 
|---|
|  |  |  | if (containerType == 40) { | 
|---|
|  |  |  | locType = 5; | 
|---|
|  |  |  | } else if (containerType == 21 && agvBasDevp.getFloor() == 3) { | 
|---|
|  |  |  | locType = 4; | 
|---|
|  |  |  | } else if (containerType == 20 && agvBasDevp.getFloor() == 3) { | 
|---|
|  |  |  | locType = 2; | 
|---|
|  |  |  | } else if (containerType == 30) { | 
|---|
|  |  |  | locType = 3; | 
|---|
|  |  |  | } else if (containerType == 31) { | 
|---|
|  |  |  | locType = 6; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | locType = agvBasDevp.getLocType1(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!Cools.eq(agvBasDevp.getBarcode(), containerCode) && !agvBasDevp.getLocSts().equals("O") && !emptyAutoIn) { | 
|---|
|  |  |  | throw new CoolException("当前工作位状态为" + agvBasDevp.getLocSts() + ",无法进行入库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询工作档 | 
|---|
|  |  |  | AgvWrkMast agvWrkMast = agvWrkMastService.selectByContainerCode(containerCode); | 
|---|
|  |  |  | if (!Cools.isEmpty(agvWrkMast) && !emptyAutoIn) { | 
|---|
|  |  |  | throw new CoolException("当前货架已有入库任务,无法进行入库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //检索库位,选择合适的库位 | 
|---|
|  |  |  | AgvLocMast agvLocMast = new AgvLocMast(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询库存 | 
|---|
|  |  |  | AgvLocMast locMast = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("barcode", containerCode)); | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | throw new CoolException("当前货架已在库存中,无法进行入库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询入库通知档 | 
|---|
|  |  |  | List<AgvWaitPakin> agvWaitPakinList = agvWaitPakinService.selectByContainerCode(containerCode); | 
|---|
|  |  |  | if (!Cools.isEmpty(agvWaitPakinList)) { | 
|---|
|  |  |  | AtomicBoolean isCurrLev = new AtomicBoolean(false); | 
|---|
|  |  |  | agvWaitPakinList.forEach(agvWaitPakin -> { | 
|---|
|  |  |  | factory.set(OrderUtils.getFactory(agvWaitPakin.getThreeCode())); | 
|---|
|  |  |  | if (!Cools.isEmpty(agvWaitPakin.getProcessSts())) { | 
|---|
|  |  |  | if (agvWaitPakin.getProcessSts() == 1) { | 
|---|
|  |  |  | isCurrLev.set(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "elevatorTasks")); | 
|---|
|  |  |  | if (Cools.isEmpty(config)) { | 
|---|
|  |  |  | if (isCurrLev.get()) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (station.endsWith("F4") && locType == 3) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNoOnXiSuer(locType, 1); | 
|---|
|  |  |  | } else if (locType == 6) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNoOnXiSuer20(locType, 1); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | List<AgvWrkMast> agvWrkMasts = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>().like("loc_no", "02F1").like("source_loc_no", "F1")); | 
|---|
|  |  |  | if (Integer.parseInt(config.getValue()) <= agvWrkMasts.size()) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (isCurrLev.get()) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //agvLocMast = agvCommonService.getLocNo(locType,agvBasDevp.getFloor(),false,false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (agvLocMast==null){ | 
|---|
|  |  |  | throw new CoolException("没有该类型的空库位了"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String devNo = agvBasDevp.getDevNo(); | 
|---|
|  |  |  | String locNo = agvLocMast.getLocNo(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //生成工作档 | 
|---|
|  |  |  | AgvWrkMast wrkMast = createWrkMast(1, 201L, devNo, locNo, containerCode, now, userId, containerType, agvLocMast.getPltType()); | 
|---|
|  |  |  | //生成工作档明细 | 
|---|
|  |  |  | long flowId = snowflakeIdWorker.nextId(); | 
|---|
|  |  |  | agvWaitPakinList.forEach(wp -> { | 
|---|
|  |  |  | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 11: | 
|---|
|  |  |  | case 12: | 
|---|
|  |  |  | AgvLocDetl agvLocDetl1 = agvLocDetlService.selectByLocNo(agvWrkMast.getLocNo()); | 
|---|
|  |  |  | if (agvLocDetl1 == null) { | 
|---|
|  |  |  | agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(), "D", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(), "F", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //更新库存明细 | 
|---|
|  |  |  | agvLocDetlService.updateStock(agvWrkMast.getSourceLocNo(), agvWrkMast.getLocNo()); | 
|---|
|  |  |  | //修改源库位状态为O | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public AgvLocMast getLocNoOnXiSuer20(int type, int floor) { | 
|---|
|  |  |  | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("loc_sts", "O").eq("loc_type1", type); | 
|---|
|  |  |  | wrapper.eq("floor", floor).eq("lev1", 2); | 
|---|
|  |  |  | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(agvLocMasts)) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | int num = 15; | 
|---|
|  |  |  | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "LOC_6_NUM")); | 
|---|
|  |  |  | if (config != null && !Cools.isEmpty(config.getValue())) { | 
|---|
|  |  |  | num = Integer.parseInt(config.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (agvLocMasts.size()>num){ | 
|---|
|  |  |  | for (AgvLocMast agvLocMast : agvLocMasts) { | 
|---|
|  |  |  | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); | 
|---|
|  |  |  | if (agvLocMast1.getLocSts().equals("O")) { | 
|---|
|  |  |  | return agvLocMast1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //随机取一个货位 | 
|---|
|  |  |  | private AgvLocMast getLocNoRule(int type, int floor, boolean isEmpty, boolean isCurrLev) { | 
|---|