| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.BasDevp; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.ExistDto; |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.utils.OutStockInterceptUtil; |
| | | import com.zy.common.utils.RoleUtils; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/3/26 |
| | |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | |
| | | @PostMapping("/out/pakout/preview/auth") |
| | | |
| | | @PostMapping("/out/pakout/orderDetlIds/auth") |
| | | @ManagerAuth |
| | | public R pakoutPreview(@RequestBody List<Long> ids) { |
| | | public R pakoutOrderDetlIds(@RequestParam Long orderId) throws InterruptedException { |
| | | Thread.sleep(200); |
| | | return R.ok().add(orderDetlService.selectByOrderId(orderId).stream().map(OrderDetl::getId).distinct().collect(Collectors.toList())); |
| | | } |
| | | |
| | | |
| | | /** 四向库订单出库 **/ |
| | | @PostMapping("/out/pakout/previewCustomQuantity/auth/sxk") |
| | | @ManagerAuth |
| | | public R pakoutPreviewCustomQuantitySXK(@RequestBody JSONObject jsonObject) { |
| | | List<Long> ids = JSON.parseObject(jsonObject.get("ids").toString(), ArrayList.class); |
| | | Double amount = JSON.parseObject(jsonObject.get("amount").toString(), Double.class); |
| | | if (Cools.isEmpty(ids)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | |
| | | Set<String> exist = new HashSet<>(); |
| | | Set<ExistDto> existDtos = new HashSet<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (!Cools.isEmpty(amount)) { |
| | | if (amount > issued) { |
| | | return R.error("数量高于可出库数量"); |
| | | } |
| | | issued = amount; |
| | | } |
| | | if (issued <= 0.0D) { continue; } |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | List<LocDetl> locDetls = new ArrayList<>(); |
| | | locDetls = locDetlService.queryStockFour(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist,orderDetl.getSupp(),orderDetl.getTemp1(),orderDetl.getTemp2()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | LocDetl locDetl1 = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("loc_No", locMast.getLocNo()) |
| | | .eq("matnr", locDetl.getMatnr()).eq("batch", locDetl.getBatch())); |
| | | if (!Cools.isEmpty(locDetl1)) { |
| | | ExistDto existDto = new ExistDto(); |
| | | existDto.setLocNo(locDetl1.getLocNo()); |
| | | existDto.setMatnr(locDetl1.getMatnr()); |
| | | existDto.setBatch(locDetl1.getBatch()); |
| | | if (existDtos.add(existDto)){ |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl1.getLocNo(), locDetl1.getMatnr(), locDetl1.getMaktx(), locDetl1.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl1.getAnfme() ? locDetl1.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl1.getLocNo(), issued >= locDetl1.getAnfme() ? 101 : 103); |
| | | List<LocDto.staListDto> maps = new ArrayList<>(); |
| | | for (Integer staNo : staNos) { |
| | | LocDto.staListDto staListDto = new LocDto.staListDto(); |
| | | staListDto.setStaNo(staNo); |
| | | staListDto.setStaName(Utils.getStaName(staNo)); |
| | | maps.add(staListDto); |
| | | } |
| | | locDto.setStaNos(maps); |
| | | locDtos.add(locDto); |
| | | // 剩余待出数量递减 |
| | | 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/preview/auth/sxk") |
| | | @ManagerAuth |
| | | public R pakoutPreviewSXK(@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<>(); |
| | | Set<ExistDto> existDtos = 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 = new ArrayList<>(); |
| | | locDetls = locDetlService.queryStockFour(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist,orderDetl.getSupp(),orderDetl.getTemp1(),orderDetl.getTemp2()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | LocDetl locDetl1 = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("loc_No", locMast.getLocNo()) |
| | | .eq("matnr", locDetl.getMatnr()).eq("batch", locDetl.getBatch())); |
| | | if (!Cools.isEmpty(locDetl1)) { |
| | | ExistDto existDto = new ExistDto(); |
| | | existDto.setLocNo(locDetl1.getLocNo()); |
| | | existDto.setMatnr(locDetl1.getMatnr()); |
| | | existDto.setBatch(locDetl1.getBatch()); |
| | | if (existDtos.add(existDto)){ |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl1.getLocNo(), locDetl1.getMatnr(), locDetl1.getMaktx(), locDetl1.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl1.getAnfme() ? locDetl1.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl1.getLocNo(), issued >= locDetl1.getAnfme() ? 101 : 103); |
| | | List<LocDto.staListDto> maps = new ArrayList<>(); |
| | | for (Integer staNo : staNos) { |
| | | LocDto.staListDto staListDto = new LocDto.staListDto(); |
| | | staListDto.setStaNo(staNo); |
| | | staListDto.setStaName(Utils.getStaName(staNo)); |
| | | maps.add(staListDto); |
| | | } |
| | | locDto.setStaNos(maps); |
| | | locDtos.add(locDto); |
| | | // 剩余待出数量递减 |
| | | 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); |
| | | } |
| | | |
| | | /** ctu订单出库 **/ |
| | | @PostMapping("/out/pakout/previewCustomQuantity/auth/ctu") |
| | | @ManagerAuth |
| | | public R pakoutPreviewCustomQuantityCTU(@RequestBody JSONObject jsonObject) { |
| | | List<Long> ids = JSON.parseObject(jsonObject.get("ids").toString(), ArrayList.class); |
| | | Double amount = JSON.parseObject(jsonObject.get("amount").toString(), Double.class); |
| | | 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<>(); |
| | | Set<ExistDto> existDtos = new HashSet<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (!Cools.isEmpty(amount)) { |
| | | if (amount > issued) { |
| | | return R.error("数量高于可出库数量"); |
| | | } |
| | | issued = amount; |
| | | } |
| | | if (issued <= 0.0D) { continue; } |
| | | List<LocDetl> locDetls = new ArrayList<>(); |
| | | locDetls = locDetlService.queryStockMinAnfme(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist,orderDetl.getSupp(),orderDetl.getTemp1(),orderDetl.getTemp2()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_No", locDetl.getLocNo())); |
| | | if (issued > 0) { |
| | | 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 { |
| | | ExistDto existDto = new ExistDto(); |
| | | existDto.setLocNo(locDetl.getLocNo()); |
| | | existDto.setMatnr(locDetl.getMatnr()); |
| | | existDto.setBatch(locDetl.getBatch()); |
| | | if (existDtos.add(existDto)) { |
| | | 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() && locDetlList.size() ==1? 101 : 103); |
| | | List<LocDto.staListDto> maps = new ArrayList<>(); |
| | | for (Integer staNo : staNos) { |
| | | LocDto.staListDto staListDto = new LocDto.staListDto(); |
| | | staListDto.setStaNo(staNo); |
| | | staListDto.setStaName(Utils.getStaName(staNo)); |
| | | maps.add(staListDto); |
| | | } |
| | | locDto.setStaNos(maps); |
| | | locDtos.add(locDto); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/preview/auth/ctu") |
| | | @ManagerAuth |
| | | public R pakoutPreviewCtu(@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<>(); |
| | | Set<ExistDto> existDtos = 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 = new ArrayList<>(); |
| | | locDetls = locDetlService.queryStockMinAnfme(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist,orderDetl.getSupp(),orderDetl.getTemp1(),orderDetl.getTemp2()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_No", locDetl.getLocNo())); |
| | | if (issued > 0) { |
| | | ExistDto existDto = new ExistDto(); |
| | | existDto.setLocNo(locDetl.getLocNo()); |
| | | existDto.setMatnr(locDetl.getMatnr()); |
| | | existDto.setBatch(locDetl.getBatch()); |
| | | if (existDtos.add(existDto)) { |
| | | 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() && locDetlList.size() ==1? 101 : 103); |
| | | List<LocDto.staListDto> maps = new ArrayList<>(); |
| | | for (Integer staNo : staNos) { |
| | | LocDto.staListDto staListDto = new LocDto.staListDto(); |
| | | staListDto.setStaNo(staNo); |
| | | staListDto.setStaName(Utils.getStaName(staNo)); |
| | | maps.add(staListDto); |
| | | } |
| | | locDto.setStaNos(maps); |
| | | locDtos.add(locDto); |
| | | // 剩余待出数量递减 |
| | | 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); |
| | | } |
| | | |
| | | /** crn订单出库 **/ |
| | | @PostMapping("/out/pakout/previewCustomQuantity/auth/crn") |
| | | @ManagerAuth |
| | | public R pakoutPreviewCustomQuantityCRN(@RequestBody JSONObject jsonObject) { |
| | | List<Long> ids = JSON.parseObject(jsonObject.get("ids").toString(), ArrayList.class); |
| | | Double amount = JSON.parseObject(jsonObject.get("amount").toString(), Double.class); |
| | | 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<>(); |
| | | Set<ExistDto> existDtos = new HashSet<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (!Cools.isEmpty(amount)) { |
| | | if (amount > issued) { |
| | | return R.error("数量高于可出库数量"); |
| | | } |
| | | issued = amount; |
| | | } |
| | | if (issued <= 0.0D) { continue; } |
| | | List<LocDetl> locDetls = new ArrayList<>(); |
| | | locDetls = locDetlService.queryStockCrn(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist,orderDetl.getSupp(),orderDetl.getTemp1(),orderDetl.getTemp2()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_No", locDetl.getLocNo())); |
| | | if (issued > 0) { |
| | | ExistDto existDto = new ExistDto(); |
| | | existDto.setLocNo(locDetl.getLocNo()); |
| | | existDto.setMatnr(locDetl.getMatnr()); |
| | | existDto.setBatch(locDetl.getBatch()); |
| | | if (existDtos.add(existDto)) { |
| | | 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() && locDetlList.size() ==1? 101 : 103); |
| | | List<LocDto.staListDto> maps = new ArrayList<>(); |
| | | for (Integer staNo : staNos) { |
| | | LocDto.staListDto staListDto = new LocDto.staListDto(); |
| | | staListDto.setStaNo(staNo); |
| | | staListDto.setStaName(Utils.getStaName(staNo)); |
| | | maps.add(staListDto); |
| | | } |
| | | locDto.setStaNos(maps); |
| | | locDtos.add(locDto); |
| | | // 剩余待出数量递减 |
| | | 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/preview/auth/crn") |
| | | @ManagerAuth |
| | | public R pakoutPreviewCRN(@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<>(); |
| | | Set<ExistDto> existDtos = 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 = new ArrayList<>(); |
| | | locDetls = locDetlService.queryStockCrn(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist,orderDetl.getSupp(),orderDetl.getTemp1(),orderDetl.getTemp2()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_No", locDetl.getLocNo())); |
| | | if (issued > 0) { |
| | | ExistDto existDto = new ExistDto(); |
| | | existDto.setLocNo(locDetl.getLocNo()); |
| | | existDto.setMatnr(locDetl.getMatnr()); |
| | | existDto.setBatch(locDetl.getBatch()); |
| | | if (existDtos.add(existDto)) { |
| | | 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() && locDetlList.size() ==1? 101 : 103); |
| | | List<LocDto.staListDto> maps = new ArrayList<>(); |
| | | for (Integer staNo : staNos) { |
| | | LocDto.staListDto staListDto = new LocDto.staListDto(); |
| | | staListDto.setStaNo(staNo); |
| | | staListDto.setStaName(Utils.getStaName(staNo)); |
| | | maps.add(staListDto); |
| | | } |
| | | locDto.setStaNos(maps); |
| | | locDtos.add(locDto); |
| | | // 剩余待出数量递减 |
| | | 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 { |
| | |
| | | } |
| | | boolean lack = true; |
| | | for (LocDto locDto : locDtos) { |
| | | // 判断入库模式 |
| | | OutStockInterceptUtil.outStockIntercept(locDto.getStaNo()); |
| | | if (!locDto.isLack()) { |
| | | lack = false; |
| | | break; |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/auth/sxk") |
| | | @ManagerAuth(memo = "订单出库") |
| | | public synchronized R pakoutSxk(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | if (Cools.isEmpty(locDtos)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | boolean lack = true; |
| | | for (LocDto locDto : locDtos) { |
| | | // 判断入库模式 |
| | | OutStockInterceptUtil.outStockIntercept(locDto.getStaNo()); |
| | | 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.stockOutSxk(staNo, taskDto, getUserId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |