| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.OutlocDetlParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.third.entity.ExdOutstockSource; |
| | | import com.zy.third.service.ExdOutstockSourceService; |
| | | import lombok.Synchronized; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | private WorkService workService; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private ExdOutstockSourceService exdOutstockSourceService; |
| | | |
| | | |
| | | @PostMapping("/out/pakout/orderDetlIds/auth") |
| | |
| | | for (TaskDto taskDto : taskDtos) { |
| | | workService.stockOut(null, taskDto, getUser(), taskDto.getStaNo()); |
| | | } |
| | | //对出库订单流水号进行更新 |
| | | Order order = orderService.selectByNo(locDtos.get(0).getOrderNo()); |
| | | if(order.getDocType()==81){ |
| | | order.setAccountDay(Cools.isEmpty(order.getAccountDay()) ? 1 : order.getAccountDay()+1); |
| | | order.setUpdateTime(new Date()); |
| | | orderService.updateById(order); |
| | | } |
| | | |
| | | //对出库单进行锁定 |
| | | List<ExdOutstockSource> fBillNo = exdOutstockSourceService.selectList(new EntityWrapper<ExdOutstockSource>().eq("FBillNo", order.getOrderNo())); |
| | | if(fBillNo != null){ |
| | | for(ExdOutstockSource exdOutstockSource : fBillNo){ |
| | | exdOutstockSource.setStatus(10); |
| | | exdOutstockSourceService.updateById(exdOutstockSource); |
| | | } |
| | | |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/out/pakout2/preview/auth") |
| | | @ManagerAuth |
| | | public R pakoutPreview2(@RequestBody List<Long> ids) { |
| | | if (Cools.isEmpty(ids)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | List<OrderDetl> orderDetls = orderDetlService.selectBatchIds(ids); |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | |
| | | Set<String> exist = new HashSet<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | for (LocDetl locDetl : locDetls) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | List<String> staNos = new ArrayList<>(); |
| | | staNos.add("C1"); |
| | | staNos.add("C2"); |
| | | staNos.add("C3"); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | } |
| | | } |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | @PostMapping("/out/pakoutV2/auth") |
| | | @Synchronized |
| | | @PostMapping("/out/pakout2/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | public synchronized R pakout2(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | public R pakout2(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | if (Cools.isEmpty(locDtos)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | |
| | | |
| | | Thread.sleep(1000L); |
| | | |
| | | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | |
| | | } else { |
| | | taskDtos.add(taskDto); |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDto.getLocNo())); |
| | | if(!locMast.getLocSts().equals("F")) { |
| | | return R.error("库位="+locMast.getLocNo()+"不是在库状态,请刷新页面重新提取物料"); |
| | | } |
| | | } |
| | | // ----------------------------------------------------------------------------------------------- |
| | | for (TaskDto taskDto : taskDtos) { |
| | | workService.stockOut(null, taskDto, getUser(), taskDto.getStaNo()); |
| | | workService.stockOutCheckAnfme(null, taskDto, getUser(), taskDto.getStaNo()); |
| | | } |
| | | //对出库订单流水号进行更新 |
| | | Order order = orderService.selectByNo(locDtos.get(0).getOrderNo()); |
| | | if(order.getDocType()==81){ |
| | | order.setAccountDay(Cools.isEmpty(order.getAccountDay()) ? 1 : order.getAccountDay()+1); |
| | | order.setUpdateTime(new Date()); |
| | | orderService.updateById(order); |
| | | } |
| | | |
| | | //对出库单进行锁定 |
| | | List<ExdOutstockSource> fBillNo = exdOutstockSourceService.selectList(new EntityWrapper<ExdOutstockSource>().eq("FBillNo", order.getOrderNo())); |
| | | if(fBillNo != null){ |
| | | for(ExdOutstockSource exdOutstockSource : fBillNo){ |
| | | exdOutstockSource.setStatus(10); |
| | | exdOutstockSourceService.updateById(exdOutstockSource); |
| | | } |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout2/preview/auth") |
| | | @ManagerAuth |
| | | public R pakoutPreview2(@RequestBody List<Long> ids) { |
| | | if (Cools.isEmpty(ids)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | List<OrderDetl> orderDetls = orderDetlService.selectBatchIds(ids); |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | |
| | | Set<String> exist = new HashSet<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | for (LocDetl locDetl : locDetls) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), locDetl.getAnfme()); |
| | | List<String> staNos = new ArrayList<>(); |
| | | staNos.add("C1"); |
| | | staNos.add("C2"); |
| | | staNos.add("C3"); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | } |
| | | orderDetl.setUpdateBy(getUserId()); |
| | | } |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/preview/auth1") |
| | | @ManagerAuth |
| | | public R pakoutPreview1(@RequestBody OutlocDetlParam map) { |
| | | if (Cools.isEmpty(map)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectById(map.getId()); |
| | | if (Cools.isEmpty(orderDetl)) { |
| | | return R.error("没有找到该订单"); |
| | | } |
| | | |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | Set<String> exist = new HashSet<>(); |
| | | |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | for (LocDetl locDetl : map.getList()) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | locDetl.getAnfme()); |
| | | List<String> staNos = new ArrayList<>(); |
| | | staNos.add("C1"); |
| | | staNos.add("C2"); |
| | | staNos.add("C3"); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto("库存不足", orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setLack(Boolean.TRUE); |
| | | locDtos.add(locDto); |
| | | } |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | } |