| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.BaseRes; |
| | |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); |
| | | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") ){ |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | } |
| | | } else { |
| | | throw new CoolException("库存不存在"); |
| | | } |
| | |
| | | ioType = dto.isAll() ? 101 : 103; |
| | | } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) { |
| | | ioType = 107; |
| | | if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { |
| | | throw new CoolException("只能存在一笔盘点任务"); |
| | | } |
| | | // if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { |
| | | // throw new CoolException("只能存在一笔盘点任务"); |
| | | // } |
| | | } |
| | | assert ioType != null; |
| | | // 获取库位 |
| | |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | Double ioPri = wrkMastService.getIoPri(ioType, dto.getLocNo()); |
| | | wrkMast.setIoPri(ioPri); // 优先级:13 |
| | | wrkMast.setIoPri(15D); // 优先级:13 |
| | | wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), false) ? 1 : 0); |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setSpecs(detlDto.getLocDetl().getSpecs()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | locMastService.breakUp(dto.getLocNo(), excludeLocNos); |
| | | // locMastService.breakUp(dto.getLocNo(), excludeLocNos); |
| | | } |
| | | } |
| | | |
| | |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | // 修改订单明细 |
| | | if (BaseController.isJSON(locDto.getOrderNo())) { |
| | | if (!BaseController.isJSON(locDto.getOrderNo())) { |
| | | String[] orderNos = GetOrderNo(locDto.getOrderNo()); |
| | | Double anfme = locDto.getAnfme(); |
| | | for (String orderNo : orderNos) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), null); |
| | | if (!Cools.isEmpty(orderNos)){ |
| | | Double anfme = locDto.getAnfme(); |
| | | for (String orderNo : orderNos) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), null); |
| | | } |
| | | if (orderDetl.getAnfme() <= anfme) { |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getAnfme())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | anfme = anfme - orderDetl.getAnfme(); |
| | | } else { |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), anfme)) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | if (orderDetl.getAnfme() <= anfme) { |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getAnfme())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | anfme = anfme - orderDetl.getAnfme(); |
| | | } else { |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), anfme)) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | }else { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); |
| | | } |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | } else { |
| | | // 订单合并出库 |
| | | List<OrderDto> orderDtoList = JSON.parseArray(locDto.getOrderNo(), OrderDto.class); |
| | | |
| | | for (OrderDto orderDto : orderDtoList) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | |
| | | private String[] GetOrderNo(String orderNo) { |
| | | String[] s3 = orderNo.split("\""); |
| | | String[] s = new String[(s3.length - 1) / 6]; |
| | | int i = 0; |
| | | int j = 0; |
| | | for (String ss : s3) { |
| | | if (ss.equals("orderNo")) { |
| | | s[i] = s3[j + 2]; |
| | | i++; |
| | | if (!Cools.isEmpty(s3)){ |
| | | int i = 0; |
| | | int j = 0; |
| | | for (String ss : s3) { |
| | | if (ss.equals("orderNo")) { |
| | | s[i] = s3[j + 2]; |
| | | i++; |
| | | } |
| | | j++; |
| | | } |
| | | j++; |
| | | }else { |
| | | s=null; |
| | | } |
| | | return s; |
| | | } |
| | |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException(locNo + "库位不存在"); |
| | | } |
| | | if (!locMast.getLocSts().equals("D")){ |
| | | throw new CoolException("所选库位存在状态不为D的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | } |
| | | // 获取源站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", 110) |
| | |
| | | @Override |
| | | @Transactional |
| | | public void locCheckOut(StockOutParam param, Long userId) { |
| | | if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { |
| | | throw new CoolException("只能存在一笔盘点任务"); |
| | | } |
| | | // if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { |
| | | // throw new CoolException("只能存在一笔盘点任务"); |
| | | // } |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | // 获取库位明细 |
| | |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 107.盘点出库 |
| | | stockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | // 启动出库开始 107.盘点出库 |
| | | stockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | } |
| | | |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | } |
| | |
| | | LocMast loc = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(loc)) { |
| | | throw new CoolException("未找到库位"); |
| | | } |
| | | if (!loc.getLocSts().equals("O")||(!sourceLoc.getLocSts().equals("F") && !sourceLoc.getLocSts().equals("D"))){ |
| | | throw new CoolException("库位状态已改变"); |
| | | } |
| | | if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { |
| | | // throw new CoolException("移转库位属于不同堆垛机"); todo:luxiaotao |
| | |
| | | wrkMast.setWrkSts(9L); |
| | | // 出库 |
| | | } else if (wrkMast.getWrkSts() > 10) { |
| | | wrkMast.setSteNo(0); |
| | | wrkMast.setWrkSts(17L); |
| | | } |
| | | Date now = new Date(); |
| | |
| | | locSts = "D"; |
| | | // 库位转移 ===>> D.空桶/空栈板 |
| | | } else if (wrkMast.getIoType() == 11) { |
| | | if (wrkMast.getWrkSts() > 11){ |
| | | throw new CoolException("移库任务已在执行中,不能取消"); |
| | | } |
| | | locSts = wrkMast.getFullPlt().equalsIgnoreCase("N") ? "D" : "F"; |
| | | // 库位转移:目标库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | if (!Cools.isEmpty(wrkDetl.getOrderNo())){ |
| | | String[] orderNos = GetOrderNo(wrkDetl.getOrderNo()); |
| | | String[] anfmes = GetAnfme(wrkDetl.getOrderNo()); |
| | | int i = 0; |
| | | for (String orderNo : orderNos) { |
| | | if (!Cools.isEmpty(orderNo)) { |
| | | Double anfme = Integer.parseInt(anfmes[i]) + 0.0; |
| | | i++; |
| | | if (BaseController.isJSON(wrkDetl.getOrderNo())) { |
| | | if (!orderDetlService.decrease(orderNo, wrkDetl.getMatnr(), wrkDetl.getBatch(), anfme)) { |
| | | throw new CoolException("订单数据回滚失败"); |
| | | } |
| | | } else { |
| | | // 订单合并出库 |
| | | List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class); |
| | | for (OrderDto orderDto : orderDtoList) { |
| | | if (!orderDetlService.decrease(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) { |
| | | if (!Cools.isEmpty(orderNos)){ |
| | | String[] anfmes = GetAnfme(wrkDetl.getOrderNo()); |
| | | int i = 0; |
| | | for (String orderNo : orderNos) { |
| | | if (!Cools.isEmpty(orderNo)) { |
| | | Double anfme = Integer.parseInt(anfmes[i]) + 0.0; |
| | | i++; |
| | | if (!BaseController.isJSON(wrkDetl.getOrderNo())) { |
| | | if (!orderDetlService.decrease(orderNo, wrkDetl.getMatnr(), wrkDetl.getBatch(), anfme)) { |
| | | throw new CoolException("订单数据回滚失败"); |
| | | } |
| | | } else { |
| | | // 订单合并出库 |
| | | List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class); |
| | | for (OrderDto orderDto : orderDtoList) { |
| | | if (!orderDetlService.decrease(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) { |
| | | throw new CoolException("订单数据回滚失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | if (!BaseController.isJSON(wrkDetl.getOrderNo())) { |
| | | if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { |
| | | throw new CoolException("订单数据回滚失败"); |
| | | } |
| | | } else { |
| | | // 订单合并出库 |
| | | List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class); |
| | | for (OrderDto orderDto : orderDtoList) { |
| | | if (!orderDetlService.decrease(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) { |
| | | throw new CoolException("订单数据回滚失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (Cools.isEmpty(locNos)) { |
| | | return; |
| | | } |
| | | if (true && !Cools.isEmpty(locNos)) { |
| | | throw new CoolException("暂不支持移库任务"); // todo:luxiaotao 移库开关 |
| | | } |
| | | // if (true && !Cools.isEmpty(locNos)) { |
| | | // throw new CoolException("暂不支持移库任务"); // todo:luxiaotao 移库开关 |
| | | // } |
| | | LocMast one = locMastService.selectById(locNos.get(0)); |
| | | List<Integer> rows = Utils.getGroupLoc(Integer.parseInt(locNos.get(0).substring(0, 2))); |
| | | List<LocMast> locMasts = locMastService.queryFreeLocMast(rows, rows.size(), one.getLocType1()); |