| | |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.web.WcsController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Autowired |
| | | private CheckOrderDetlService checkOrderDetlService; |
| | | @Autowired |
| | | private LocCacheServiceImpl locCacheService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private TaskDetlService taskDetlService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void agvStockOut(BasStation staNo, TaskDto taskDto, Long userId) { |
| | | Date now = new Date(); |
| | | List<LocDto> locDtos = taskDto.getLocDtos(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (!taskDto.getLocNo().equals(locDto.getLocNo()) && !taskDto.getStaNo().equals(locDto.getStaNo())) { |
| | | throw new CoolException("订单出库异常,请联系管理员"); |
| | | } |
| | | } |
| | | // 获取库位 |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", taskDto.getLocNo())); |
| | | int ioType = (taskDto.isAll() ? 101 : 103); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(11L) // 工作状态:11.生成出库ID |
| | | .setIoType(ioType) // 入出库状态 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setFullPlt("Y") // 满板:Y |
| | | .setPicking("N") // 拣料 |
| | | .setExitMk("N")// 退出 |
| | | .setStaNo(staNo.getDevNo()) |
| | | .setSourceLocNo(locCache.getLocNo()) |
| | | .setEmptyMk("N")// 空板 |
| | | .setBarcode(locCache.getBarcode())// 托盘码 |
| | | .setLinkMis("N") |
| | | .setAppeUser(userId) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId) |
| | | .setModiTime(new Date()); |
| | | if (!taskService.insert(task)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { |
| | | continue; |
| | | } |
| | | // OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); |
| | | OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(), locDto.getBrand() |
| | | , locDto.getStandby1(), locDto.getStandby2(), locDto.getStandby3(), locDto.getBoxType1(), locDto.getBoxType2(), locDto.getBoxType3()); |
| | | // if (orderDetl == null) { |
| | | //// orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); |
| | | // orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), null); |
| | | // |
| | | // } |
| | | |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(orderDetl, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo) |
| | | .setId(null) |
| | | .setIoTime(new Date()) |
| | | .setOrderNo(locDto.getOrderNo()) |
| | | .setAnfme(locDto.getAnfme()) |
| | | .setZpallet(locCache.getBarcode()) |
| | | .setBatch(locDto.getBatch()) |
| | | .setAppeUser(userId) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId); |
| | | if (!taskDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | // // 修改订单明细 |
| | | // if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { |
| | | // throw new CoolException("修改订单明细数量失败"); |
| | | // } |
| | | // orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | OrderInAndOutUtil.increaseWorkQty(Boolean.FALSE, orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3() |
| | | , locDto.getAnfme()); |
| | | OrderInAndOutUtil.updateOrder(Boolean.FALSE, orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | |
| | | if (locCache.getLocSts().equals("F")) { |
| | | locCache.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locCache.setModiUser(userId); |
| | | locCache.setModiTime(now); |
| | | if (!locCacheService.updateById(locCache)) { |
| | | throw new CoolException("预约库位状态失败,库位号:" + taskDto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(taskDto.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public String emptyPlateIn(Integer devpNo, Long userId) { |
| | | // 源站点状态检测 |