| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.service.impl.WorkServiceImpl; |
| | | import com.zy.asrs.utils.OutboundAllocationUtil; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.web.BaseController; |
| | |
| | | } |
| | | List<OrderDetl> orderDetls = orderDetlService.selectBatchIds(ids); |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | if (orderDetl.getAnfme()-orderDetl.getWorkQty()-orderDetl.getQty()==0.0){ |
| | | continue; |
| | | } |
| | | LocDto locDto = new LocDto(orderDetl.getManu(), orderDetl.getMatnr(), orderDetl.getMaktx(),orderDetl.getModel(),orderDetl.getSpecs(), |
| | | orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getBarcode(), orderDetl.getOrderNo(),orderDetl.getAnfme()); |
| | | locDto.setOrderDetlId(orderDetl.getId()); |
| | | locDto.setTkType(orderDetl.getTkType()); |
| | | locDtos.add(locDto); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // Set<String> exist = new HashSet<>(); |
| | | |
| | | // for (OrderDetl orderDetl : orderDetls) { |
| | | // double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | // if (issued <= 0.0D) { continue; } |
| | | // if (orderDetl.getAnfme()-orderDetl.getWorkQty()-orderDetl.getQty()==0.0){ |
| | | // continue; |
| | | // } |
| | | // LocDto locDto = new LocDto(orderDetl.getManu(), orderDetl.getMatnr(), orderDetl.getMaktx(),orderDetl.getModel(),orderDetl.getSpecs(), |
| | | // orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getBarcode(), orderDetl.getOrderNo(),orderDetl.getAnfme()); |
| | | // locDto.setOrderDetlId(orderDetl.getId()); |
| | | // locDto.setTkType(orderDetl.getTkType()); |
| | | // locDtos.add(locDto); |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | Set<String> exist = new HashSet<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { continue; } |
| | | // List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | // for (LocDetl locDetl : locDetls) { |
| | | // if (issued > 0) { |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("batch",orderDetl.getBatch()).eq("model",orderDetl.getModel())); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(orderDetl.getManu(), orderDetl.getMatnr(), orderDetl.getMaktx(),orderDetl.getModel(),orderDetl.getSpecs(), |
| | | orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getBarcode(), orderDetl.getOrderNo(),orderDetl.getAnfme()); |
| | | // LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | // issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | // List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | // locDto.setStaNos(staNos); |
| | | // locDtos.add(locDto); |
| | | // exist.add(locDetl.getLocNo()); |
| | | // // 剩余待出数量递减 |
| | | // issued = issued - locDetl.getAnfme(); |
| | | // } else { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if (issued > 0) { |
| | | // LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | // locDto.setLack(Boolean.TRUE); |
| | | // locDtos.add(locDto); |
| | | // } |
| | | // } |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | |
| | | locDto.setLocNo(locDetl.getLocNo()); |
| | | // wrkDetl.setMatnr(roll.getSpecs()); // 规格 |
| | | // wrkDetl.setMaktx(roll.getSpecs()); //规格 |
| | | locDto.setBatch(locDetl.getBatch()); // 箱号 |
| | | locDto.setModel(locDetl.getModel()); // 卷号 |
| | | locDto.setBrand(""); // 木箱类型 |
| | | locDto.setOrigin(locDetl.getOrigin()); // 木箱在托盘位置 |
| | | locDto.setWeight(locDetl.getWeight()); // 净重 |
| | | locDto.setVolume(locDetl.getVolume()); // 毛重 |
| | | locDto.setPrice(locDetl.getPrice()); |
| | | locDto.setSpecs(locDetl.getSpecs()); |
| | | locDto.setZpallet(locDetl.getZpallet()); |
| | | locDto.setStaNos(staNos); |
| | | locDto.setOrderDetlId(orderDetl.getId()); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setLack(Boolean.TRUE); |
| | | locDtos.add(locDto); |
| | | } |
| | | } |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | |
| | | @PostMapping("/out/pakout/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | public synchronized R pakout(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | StockOutParam param = new StockOutParam(); |
| | | ArrayList<StockOutParam.LocDetl> locDetls = new ArrayList<>(); |
| | | for (LocDto locDto:locDtos){ |
| | | StockOutParam.LocDetl locDetl = new StockOutParam.LocDetl(); |
| | | locDetl.setBrand(locDto.getBrand()); |
| | | locDetl.setLocNo(locDto.getLocNo()); |
| | | locDetl.setAnfme(locDto.getAnfme()); |
| | | locDetl.setMatnr(locDto.getMatnr()); |
| | | locDetl.setBatch(locDto.getBatch()); |
| | | locDetl.setModel(locDto.getModel()); |
| | | locDetl.setSpecs(locDto.getSpecs()); |
| | | locDetl.setZpallet(locDto.getZpallet()); |
| | | |
| | | param.setOrderNo(locDto.getOrderNo()); |
| | | |
| | | locDetls.add(locDetl); |
| | | } |
| | | param.setLocDetls(locDetls); |
| | | |
| | | List<StockOutParam> stockOutParams = OutboundAllocationUtil.OutboundClassification(param); |
| | | for (StockOutParam stockOutParam : stockOutParams){ |
| | | workService.startupFullTakeStore(stockOutParam, getUserId()); |
| | | } |
| | | |
| | | for (LocDto locDto:locDtos){ |
| | | OrderDetl orderDetl = orderDetlService.selectById(locDto.getOrderDetlId()); |
| | | orderDetl.setWorkQty(locDto.getAnfme()); |
| | | orderDetlService.updateById(orderDetl); |
| | | } |
| | | |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | order.setSettle(2L); |
| | | orderService.updateById(order); |
| | | |
| | | |
| | | // if (Cools.isEmpty(locDtos)) { |
| | | // return R.parse(BaseRes.PARAM); |
| | | // StockOutParam param = new StockOutParam(); |
| | | // ArrayList<StockOutParam.LocDetl> locDetls = new ArrayList<>(); |
| | | // for (LocDto locDto:locDtos){ |
| | | // StockOutParam.LocDetl locDetl = new StockOutParam.LocDetl(); |
| | | // locDetl.setBrand(locDto.getBrand()); |
| | | // locDetl.setLocNo(locDto.getLocNo()); |
| | | // locDetl.setAnfme(locDto.getAnfme()); |
| | | // locDetl.setMatnr(locDto.getMatnr()); |
| | | // locDetl.setBatch(locDto.getBatch()); |
| | | // locDetl.setModel(locDto.getModel()); |
| | | // locDetl.setSpecs(locDto.getSpecs()); |
| | | // locDetl.setZpallet(locDto.getZpallet()); |
| | | // |
| | | // param.setOrderNo(locDto.getOrderNo()); |
| | | // |
| | | // locDetls.add(locDetl); |
| | | // } |
| | | // boolean lack = true; |
| | | // for (LocDto locDto : locDtos) { |
| | | // if (!locDto.isLack()) { |
| | | // lack = false; |
| | | // break; |
| | | // } |
| | | // } |
| | | // if (lack) { |
| | | // return R.error("库存不足"); |
| | | // param.setLocDetls(locDetls); |
| | | // |
| | | // List<StockOutParam> stockOutParams = OutboundAllocationUtil.OutboundClassification(param); |
| | | // for (StockOutParam stockOutParam : stockOutParams){ |
| | | // workService.startupFullTakeStore(stockOutParam, getUserId()); |
| | | // } |
| | | // |
| | | // Thread.sleep(1000L); |
| | | // for (LocDto locDto:locDtos){ |
| | | // OrderDetl orderDetl = orderDetlService.selectById(locDto.getOrderDetlId()); |
| | | // orderDetl.setWorkQty(locDto.getAnfme()); |
| | | // orderDetlService.updateById(orderDetl); |
| | | // } |
| | | // |
| | | // List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | // for (LocDto locDto : locDtos) { |
| | | // if (locDto.isLack()) { continue; } |
| | | // TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto); |
| | | // if (TaskDto.has(taskDtos, taskDto)) { |
| | | // TaskDto dto = TaskDto.find(taskDtos, taskDto); |
| | | // assert dto != null; |
| | | // dto.getLocDtos().addAll(taskDto.getLocDtos()); |
| | | // } else { |
| | | // taskDtos.add(taskDto); |
| | | // } |
| | | // } |
| | | // // ----------------------------------------------------------------------------------------------- |
| | | // for (TaskDto taskDto : taskDtos) { |
| | | // BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | // workService.stockOut(staNo, taskDto, getUserId()); |
| | | // } |
| | | // Order order = orderService.selectByNo(param.getOrderNo()); |
| | | // order.setSettle(2L); |
| | | // orderService.updateById(order); |
| | | |
| | | |
| | | if (Cools.isEmpty(locDtos)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | boolean lack = true; |
| | | for (LocDto locDto : locDtos) { |
| | | if (!locDto.isLack()) { |
| | | lack = false; |
| | | break; |
| | | } |
| | | } |
| | | if (lack) { |
| | | return R.error("库存不足"); |
| | | } |
| | | |
| | | Thread.sleep(1000L); |
| | | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto); |
| | | if (TaskDto.has(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.find(taskDtos, taskDto); |
| | | assert dto != null; |
| | | dto.getLocDtos().addAll(taskDto.getLocDtos()); |
| | | } else { |
| | | taskDtos.add(taskDto); |
| | | } |
| | | } |
| | | // ----------------------------------------------------------------------------------------------- |
| | | for (TaskDto taskDto : taskDtos) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | workService.stockOut(staNo, taskDto, getUserId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | } |
| | | // 单据明细档 |
| | | int i=0; |
| | | List<LocDto> locDtosList = new ArrayList<>(); |
| | | List<String> batchList = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (!batchList.contains(locDto.getBatch())){ |
| | | batchList.add(locDto.getBatch()); |
| | | locDtosList.add(locDto); |
| | | } |
| | | } |
| | | for (LocDto locDto : locDtosList) { |
| | | i++; |
| | | Mat mat = matService.selectByMatnr(locDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |