|  |  |  | 
|---|
|  |  |  | 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.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasDevp; | 
|---|
|  |  |  | import com.zy.asrs.entity.LocDetl; | 
|---|
|  |  |  | import com.zy.asrs.entity.OrderDetl; | 
|---|
|  |  |  | import com.zy.asrs.entity.result.StoPreTab; | 
|---|
|  |  |  | import com.zy.asrs.entity.LocMast; | 
|---|
|  |  |  | import com.zy.asrs.entity.OrderDetlPakout; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.common.model.DetlDto; | 
|---|
|  |  |  | import com.zy.common.model.ExistDto; | 
|---|
|  |  |  | import com.zy.common.model.LocDto; | 
|---|
|  |  |  | import com.zy.common.model.TaskDto; | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | 
|---|
|  |  |  | public class OutController extends BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | private OrderPakoutService orderPakoutService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderDetlService orderDetlService; | 
|---|
|  |  |  | private OrderDetlPakoutService orderDetlPakoutService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDetlService locDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | private BasDevpService basDevpService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @PostMapping("/out/pakout/preview/auth") | 
|---|
|  |  |  | //    public R pakoutPreview(@RequestBody List<Long> ids) { | 
|---|
|  |  |  | //        if (Cools.isEmpty(ids)) { | 
|---|
|  |  |  | //            return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        List<OrderDetl> orderDetls = orderDetlService.selectBatchIds(ids); | 
|---|
|  |  |  | //        Set<DetlDto> detlDtos = new HashSet<>(); | 
|---|
|  |  |  | //        for (OrderDetl orderDetl : orderDetls) { | 
|---|
|  |  |  | //            if (DetlDto.hasList(detlDtos, orderDetl)) { | 
|---|
|  |  |  | //                DetlDto detlDto = DetlDto.find(detlDtos, orderDetl.getMatnr(), orderDetl.getBatch()); | 
|---|
|  |  |  | //                assert detlDto != null; | 
|---|
|  |  |  | //                detlDto.setAnfme(detlDto.getAnfme() + orderDetl.getAnfme()); | 
|---|
|  |  |  | //            } else { | 
|---|
|  |  |  | //                detlDtos.add(new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getAnfme())); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  | //        for (DetlDto detlDto : detlDtos) { | 
|---|
|  |  |  | //            double issued = Optional.ofNullable(detlDto.getAnfme()).orElse(0.0D) ; | 
|---|
|  |  |  | //            List<LocDetl> locDetls = locDetlService.queryStock(detlDto.getMatnr(), detlDto.getBatch(), null); | 
|---|
|  |  |  | //            for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | //                if (issued > 0) { | 
|---|
|  |  |  | //                    locDtos.add(new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), issued>=locDetl.getAnfme()?locDetl.getAnfme():issued)); | 
|---|
|  |  |  | //                    // 剩余待出数量递减 | 
|---|
|  |  |  | //                    issued = issued - locDetl.getAnfme(); | 
|---|
|  |  |  | //                } else { | 
|---|
|  |  |  | //                    break; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        return R.ok().add(locDtos); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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(orderDetlPakoutService.selectByOrderId(orderId).stream().map(OrderDetlPakout::getId).distinct().collect(Collectors.toList())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/out/pakout/OrderOutGetLoc/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R OrderOutGetLoc(@RequestBody List<Long> ids) { | 
|---|
|  |  |  | if (Cools.isEmpty(ids)) { | 
|---|
|  |  |  | return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.selectBatchIds(ids); | 
|---|
|  |  |  | // 获取订单明细并处理 | 
|---|
|  |  |  | List<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | Set<String> processedLocs = new HashSet<>(); // 已处理货位缓存 | 
|---|
|  |  |  | Set<ExistDto> processedStock = new HashSet<>(); // 已处理库存缓存 | 
|---|
|  |  |  | List<LocDto> result = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout detl : orderDetlPakouts) { | 
|---|
|  |  |  | result.addAll(processOrderDetl(detl, null, processedLocs, processedStock)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理订单出库货位分配 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param jsonObject 请求参数(包含订单明细ID列表和出库数量) | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/out/pakout/OrderOutGetLoc.number/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R OrderOutGetLocNumber(@RequestBody JSONObject jsonObject) { | 
|---|
|  |  |  | // 参数校验 | 
|---|
|  |  |  | if (!jsonObject.containsKey("ids") || !jsonObject.containsKey("amount")) { | 
|---|
|  |  |  | return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 提取并转换参数 | 
|---|
|  |  |  | List<Long> ids = jsonObject.getJSONArray("ids").toJavaList(Long.class); | 
|---|
|  |  |  | Double amount = jsonObject.getDouble("amount"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取订单明细并处理 | 
|---|
|  |  |  | List<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | Set<String> processedLocs = new HashSet<>(); // 已处理货位缓存 | 
|---|
|  |  |  | Set<ExistDto> processedStock = new HashSet<>(); // 已处理库存缓存 | 
|---|
|  |  |  | List<LocDto> result = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout detl : orderDetlPakouts) { | 
|---|
|  |  |  | result.addAll(processOrderDetl(detl, amount, processedLocs, processedStock)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理单个订单明细的货位分配 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param orderDetlPakout 订单明细 | 
|---|
|  |  |  | * @param requiredAmount  需求出库量 | 
|---|
|  |  |  | * @param processedLocs   已处理的货位集合(用于去重) | 
|---|
|  |  |  | * @param processedStock  已处理的库存记录集合(用于去重) | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private List<LocDto> processOrderDetl(OrderDetlPakout orderDetlPakout, Double requiredAmount, | 
|---|
|  |  |  | Set<String> processedLocs, Set<ExistDto> processedStock) { | 
|---|
|  |  |  | List<LocDto> result = new ArrayList<>(); | 
|---|
|  |  |  | double remaining = Optional.ofNullable(orderDetlPakout.getAnfme() - orderDetlPakout.getWorkQty()).orElse(0.0D); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 调整校验逻辑:当requiredAmount不为null时才校验 | 
|---|
|  |  |  | if (requiredAmount != null) { | 
|---|
|  |  |  | if (requiredAmount <= 0) { | 
|---|
|  |  |  | throw new CoolException("出库数量必须大于0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (requiredAmount > remaining) { | 
|---|
|  |  |  | throw new CoolException("订单" + orderDetlPakout.getOrderNo() + "请求数量超过可出库数量,剩余可出:" + remaining); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 当指定数量时,使用指定数量覆盖剩余量 | 
|---|
|  |  |  | remaining = Math.min(requiredAmount, remaining); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取可用库存记录 | 
|---|
|  |  |  | List<LocDetl> stocks = locDetlService.queryStock( | 
|---|
|  |  |  | orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), orderDetlPakout.getSuppCode(), | 
|---|
|  |  |  | processedLocs, orderDetlPakout.getSupp(), | 
|---|
|  |  |  | orderDetlPakout.getTemp1(), orderDetlPakout.getTemp2() | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 遍历处理每个库存记录 | 
|---|
|  |  |  | for (LocDetl stock : stocks) { | 
|---|
|  |  |  | if (remaining <= 0) break; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne( | 
|---|
|  |  |  | new EntityWrapper<LocMast>().eq("loc_no", stock.getLocNo())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 非7号堆垛机处理逻辑 | 
|---|
|  |  |  | if (locMast.getCrnNo() != 7) { | 
|---|
|  |  |  | processNormalLocation(stock, orderDetlPakout, remaining, processedStock, result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 7号堆垛机特殊处理 | 
|---|
|  |  |  | else { | 
|---|
|  |  |  | processCrn7Location(locMast, stock, orderDetlPakout, remaining, processedStock, result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | remaining -= stock.getAnfme(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 处理缺量情况 | 
|---|
|  |  |  | if (remaining > 0) { | 
|---|
|  |  |  | result.add(createShortageDto(orderDetlPakout, remaining)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建缺量DTO | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocDto createShortageDto(OrderDetlPakout orderDetlPakout, double qty) { | 
|---|
|  |  |  | LocDto dto = new LocDto(null, orderDetlPakout.getMatnr(), | 
|---|
|  |  |  | orderDetlPakout.getMaktx(), orderDetlPakout.getBatch(), | 
|---|
|  |  |  | orderDetlPakout.getOrderNo(), qty); | 
|---|
|  |  |  | dto.setLack(true); | 
|---|
|  |  |  | return dto; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理普通货位 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void processNormalLocation(LocDetl stock, OrderDetlPakout orderDetlPakout, double remaining, | 
|---|
|  |  |  | Set<ExistDto> processedStock, List<LocDto> result) { | 
|---|
|  |  |  | ExistDto exist = new ExistDto() | 
|---|
|  |  |  | .setLocNo(stock.getLocNo()) | 
|---|
|  |  |  | .setMatnr(stock.getMatnr()) | 
|---|
|  |  |  | .setBatch(stock.getBatch()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (processedStock.add(exist)) { | 
|---|
|  |  |  | double allocateQty = Math.min(remaining, stock.getAnfme()); | 
|---|
|  |  |  | result.add(buildLocDto(stock, orderDetlPakout, allocateQty)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理7号堆垛机货位 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void processCrn7Location(LocMast baseLoc, LocDetl stock, OrderDetlPakout orderDetlPakout, | 
|---|
|  |  |  | double remaining, Set<ExistDto> processedStock, | 
|---|
|  |  |  | List<LocDto> result) { | 
|---|
|  |  |  | // 构建查询条件 | 
|---|
|  |  |  | EntityWrapper<LocMast> wrapper = (EntityWrapper<LocMast>) new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("gro1", baseLoc.getGro1()) | 
|---|
|  |  |  | .eq("crn_no", 7) | 
|---|
|  |  |  | .eq("loc_type1", baseLoc.getLocType1()) | 
|---|
|  |  |  | .orderBy("bay1", (baseLoc.getBay1() == 6 || baseLoc.getBay1() == 5)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取同组货位并处理 | 
|---|
|  |  |  | locMastService.selectList(wrapper).stream() | 
|---|
|  |  |  | .filter(loc -> "F".equals(loc.getLocSts())) | 
|---|
|  |  |  | .forEach(loc -> processCrn7SubLocation(loc, stock, orderDetlPakout, remaining, processedStock, result)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理7号堆垛机子货位 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void processCrn7SubLocation(LocMast loc, LocDetl stock, OrderDetlPakout orderDetlPakout, | 
|---|
|  |  |  | double remaining, Set<ExistDto> processedStock, | 
|---|
|  |  |  | List<LocDto> result) { | 
|---|
|  |  |  | LocDetl subStock = locDetlService.selectOne( | 
|---|
|  |  |  | new EntityWrapper<LocDetl>() | 
|---|
|  |  |  | .eq("loc_No", loc.getLocNo()) | 
|---|
|  |  |  | .eq("matnr", stock.getMatnr()) | 
|---|
|  |  |  | .eq("batch", stock.getBatch())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!Cools.isEmpty(subStock)) { | 
|---|
|  |  |  | ExistDto exist = new ExistDto() | 
|---|
|  |  |  | .setLocNo(subStock.getLocNo()) | 
|---|
|  |  |  | .setMatnr(subStock.getMatnr()) | 
|---|
|  |  |  | .setBatch(subStock.getBatch()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (processedStock.add(exist) && remaining > 0) { | 
|---|
|  |  |  | double allocateQty = Math.min(remaining, subStock.getAnfme()); | 
|---|
|  |  |  | result.add(buildLocDto(subStock, orderDetlPakout, allocateQty)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 构建货位DTO通用方法 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocDto buildLocDto(LocDetl stock, OrderDetlPakout orderDetlPakout, double qty) { | 
|---|
|  |  |  | LocDto dto = new LocDto( | 
|---|
|  |  |  | stock.getLocNo(), stock.getMatnr(), stock.getMaktx(), | 
|---|
|  |  |  | stock.getBatch(), orderDetlPakout.getOrderNo(), qty | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取工作站并转换 | 
|---|
|  |  |  | List<Integer> staNos = staDescService.queryOutStaNosByLocNo( | 
|---|
|  |  |  | stock.getLocNo(), qty >= stock.getAnfme() ? 101 : 103); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocDto.staListDto> staList = staNos.stream() | 
|---|
|  |  |  | .map(staNo -> new LocDto.staListDto() | 
|---|
|  |  |  | .setStaNo(staNo) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .collect(Collectors.toList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | dto.setStaNos(staList); | 
|---|
|  |  |  | return dto; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 四向库订单出库 | 
|---|
|  |  |  | **/ | 
|---|
|  |  |  | @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<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (OrderDetl orderDetl : orderDetls) { | 
|---|
|  |  |  | double issued = Optional.ofNullable(orderDetl.getAnfme()).orElse(0.0D) ; | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null); | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | // 剩余待出数量递减 | 
|---|
|  |  |  | issued = issued - locDetl.getAnfme(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<String> exist = new HashSet<>(); | 
|---|
|  |  |  | Set<ExistDto> existDtos = new HashSet<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) { | 
|---|
|  |  |  | double issued = Optional.of(orderDetlPakout.getAnfme() - orderDetlPakout.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.queryStockFour(orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), null, exist, orderDetlPakout.getSupp(), orderDetlPakout.getTemp1(), orderDetlPakout.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(), orderDetlPakout.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); | 
|---|
|  |  |  | 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 locDto = new LocDto(null, orderDetlPakout.getMatnr(), orderDetlPakout.getMaktx(), orderDetlPakout.getBatch(), orderDetlPakout.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<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<String> exist = new HashSet<>(); | 
|---|
|  |  |  | Set<ExistDto> existDtos = new HashSet<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) { | 
|---|
|  |  |  | double issued = Optional.of(orderDetlPakout.getAnfme() - orderDetlPakout.getWorkQty()).orElse(0.0D); | 
|---|
|  |  |  | if (issued <= 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = new ArrayList<>(); | 
|---|
|  |  |  | locDetls = locDetlService.queryStockFour(orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), null, exist, orderDetlPakout.getSupp(), orderDetlPakout.getTemp1(), orderDetlPakout.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(), orderDetlPakout.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); | 
|---|
|  |  |  | maps.add(staListDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDto.setStaNos(maps); | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | // 剩余待出数量递减 | 
|---|
|  |  |  | issued = issued - locDetl.getAnfme(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (issued > 0) { | 
|---|
|  |  |  | LocDto locDto = new LocDto(null, orderDetlPakout.getMatnr(), orderDetlPakout.getMaktx(), orderDetlPakout.getBatch(), orderDetlPakout.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<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<String> exist = new HashSet<>(); | 
|---|
|  |  |  | Set<ExistDto> existDtos = new HashSet<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) { | 
|---|
|  |  |  | double issued = Optional.of(orderDetlPakout.getAnfme() - orderDetlPakout.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(orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), null, exist, orderDetlPakout.getSupp(), orderDetlPakout.getTemp1(), orderDetlPakout.getTemp2()); | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | 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(), orderDetlPakout.getOrderNo(), | 
|---|
|  |  |  | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); | 
|---|
|  |  |  | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); | 
|---|
|  |  |  | List<LocDto.staListDto> maps = new ArrayList<>(); | 
|---|
|  |  |  | for (Integer staNo : staNos) { | 
|---|
|  |  |  | LocDto.staListDto staListDto = new LocDto.staListDto(); | 
|---|
|  |  |  | staListDto.setStaNo(staNo); | 
|---|
|  |  |  | maps.add(staListDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDto.setStaNos(maps); | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | // 剩余待出数量递减 | 
|---|
|  |  |  | issued = issued - locDetl.getAnfme(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (issued > 0) { | 
|---|
|  |  |  | LocDto locDto = new LocDto(null, orderDetlPakout.getMatnr(), orderDetlPakout.getMaktx(), orderDetlPakout.getBatch(), orderDetlPakout.getOrderNo(), issued); | 
|---|
|  |  |  | locDto.setLack(Boolean.TRUE); | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<String> exist = new HashSet<>(); | 
|---|
|  |  |  | Set<ExistDto> existDtos = new HashSet<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) { | 
|---|
|  |  |  | double issued = Optional.of(orderDetlPakout.getAnfme() - orderDetlPakout.getWorkQty()).orElse(0.0D); | 
|---|
|  |  |  | if (issued <= 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = new ArrayList<>(); | 
|---|
|  |  |  | locDetls = locDetlService.queryStockMinAnfme(orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), null, exist, orderDetlPakout.getSupp(), orderDetlPakout.getTemp1(), orderDetlPakout.getTemp2()); | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | 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(), orderDetlPakout.getOrderNo(), | 
|---|
|  |  |  | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); | 
|---|
|  |  |  | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); | 
|---|
|  |  |  | List<LocDto.staListDto> maps = new ArrayList<>(); | 
|---|
|  |  |  | for (Integer staNo : staNos) { | 
|---|
|  |  |  | LocDto.staListDto staListDto = new LocDto.staListDto(); | 
|---|
|  |  |  | staListDto.setStaNo(staNo); | 
|---|
|  |  |  | maps.add(staListDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDto.setStaNos(maps); | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | // 剩余待出数量递减 | 
|---|
|  |  |  | issued = issued - locDetl.getAnfme(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (issued > 0) { | 
|---|
|  |  |  | LocDto locDto = new LocDto(null, orderDetlPakout.getMatnr(), orderDetlPakout.getMaktx(), orderDetlPakout.getBatch(), orderDetlPakout.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<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<String> exist = new HashSet<>(); | 
|---|
|  |  |  | Set<ExistDto> existDtos = new HashSet<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) { | 
|---|
|  |  |  | double issued = Optional.of(orderDetlPakout.getAnfme() - orderDetlPakout.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(orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), null, exist, orderDetlPakout.getSupp(), orderDetlPakout.getTemp1(), orderDetlPakout.getTemp2()); | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | 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(), orderDetlPakout.getOrderNo(), | 
|---|
|  |  |  | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); | 
|---|
|  |  |  | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); | 
|---|
|  |  |  | List<LocDto.staListDto> maps = new ArrayList<>(); | 
|---|
|  |  |  | for (Integer staNo : staNos) { | 
|---|
|  |  |  | LocDto.staListDto staListDto = new LocDto.staListDto(); | 
|---|
|  |  |  | staListDto.setStaNo(staNo); | 
|---|
|  |  |  | maps.add(staListDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDto.setStaNos(maps); | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | // 剩余待出数量递减 | 
|---|
|  |  |  | issued = issued - locDetl.getAnfme(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (issued > 0) { | 
|---|
|  |  |  | LocDto locDto = new LocDto(null, orderDetlPakout.getMatnr(), orderDetlPakout.getMaktx(), orderDetlPakout.getBatch(), orderDetlPakout.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<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectBatchIds(ids); | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<String> exist = new HashSet<>(); | 
|---|
|  |  |  | Set<ExistDto> existDtos = new HashSet<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) { | 
|---|
|  |  |  | double issued = Optional.of(orderDetlPakout.getAnfme() - orderDetlPakout.getWorkQty()).orElse(0.0D); | 
|---|
|  |  |  | if (issued <= 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = new ArrayList<>(); | 
|---|
|  |  |  | locDetls = locDetlService.queryStockCrn(orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), null, exist, orderDetlPakout.getSupp(), orderDetlPakout.getTemp1(), orderDetlPakout.getTemp2()); | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | 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(), orderDetlPakout.getOrderNo(), | 
|---|
|  |  |  | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); | 
|---|
|  |  |  | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); | 
|---|
|  |  |  | List<LocDto.staListDto> maps = new ArrayList<>(); | 
|---|
|  |  |  | for (Integer staNo : staNos) { | 
|---|
|  |  |  | LocDto.staListDto staListDto = new LocDto.staListDto(); | 
|---|
|  |  |  | staListDto.setStaNo(staNo); | 
|---|
|  |  |  | maps.add(staListDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDto.setStaNos(maps); | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | // 剩余待出数量递减 | 
|---|
|  |  |  | issued = issued - locDetl.getAnfme(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (issued > 0) { | 
|---|
|  |  |  | LocDto locDto = new LocDto(null, orderDetlPakout.getMatnr(), orderDetlPakout.getMaktx(), orderDetlPakout.getBatch(), orderDetlPakout.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) { | 
|---|
|  |  |  | public synchronized R pakout(@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; } | 
|---|
|  |  |  | if (locDto.isLack()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto); | 
|---|
|  |  |  | if (TaskDto.has(taskDtos, taskDto)) { | 
|---|
|  |  |  | TaskDto dto = TaskDto.find(taskDtos, taskDto); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|