|  |  | 
 |  |  |         return mergePreviewDtos;
 | 
 |  |  |     }
 | 
 |  |  | 
 | 
 |  |  |     /**
 | 
 |  |  |      * 波次出库预览
 | 
 |  |  |      *
 | 
 |  |  |      * @param param
 | 
 |  |  |      * @return
 | 
 |  |  |      */
 | 
 |  |  |     @Transactional(rollbackFor = Exception.class)
 | 
 |  |  |     public List<MergePreviewResultDto> orderOutMergeLocPreview(List<MergePreviewDto> param) {
 | 
 |  |  |         if (param == null) {
 | 
 |  |  | 
 |  |  |             //查询平库中符合条件的库存
 | 
 |  |  |             List<LocDetl> locs = locDetlService.queryFlatStock(pars.getMatnr(), pars.getBatch(), pars.getFieldParams());
 | 
 |  |  |             if (!locs.isEmpty()) {
 | 
 |  |  |                 double anfme = pars.getAnfme() - pars.getWorkQty();
 | 
 |  |  |                 Double anfme = pars.getAnfme() - pars.getWorkQty();
 | 
 |  |  |                 for (LocDetl detl : locs) {
 | 
 |  |  |                     Loc loc = locService.getById(detl.getLocId());
 | 
 |  |  |                     if (loc == null) {
 | 
 |  |  | 
 |  |  |                     locDto.setLocNo(detl.getLocNo());
 | 
 |  |  |                     locDto.setTypeId(LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id);
 | 
 |  |  |                     locDto.setLocDetlId(detl.getId());
 | 
 |  |  |                     locDto.setAnfme(detl.getAnfme());
 | 
 |  |  |                     locDto.setAnfme(detl.getAnfme() - detl.getWorkQty());
 | 
 |  |  |                     locDto.setWorkQty(detl.getWorkQty());
 | 
 |  |  |                     locDtos.add(locDto);
 | 
 |  |  |                     //库位实际可用数量
 | 
 |  |  | 
 |  |  |                         continue;
 | 
 |  |  |                     }
 | 
 |  |  |                     //波次数量减去库位可用数量后,盈余数量
 | 
 |  |  |                     anfme = anfme - surplusQty;
 | 
 |  |  |                     if (anfme > 0) {
 | 
 |  |  |                     anfme = Math.round((anfme - surplusQty) * 10000) / 10000.0;
 | 
 |  |  |                     if (anfme.compareTo(0.0) > 0) {
 | 
 |  |  |                         //当前可使用数量
 | 
 |  |  |                         resultDto.setFetchQty(surplusQty);
 | 
 |  |  |                         //余下需求数量
 | 
 |  |  | 
 |  |  |      * 根据不同库位类型生成出库拣货单或CTU任务档
 | 
 |  |  |      *
 | 
 |  |  |      * @param dto
 | 
 |  |  |      * @param wave
 | 
 |  |  |      * @param
 | 
 |  |  |      */
 | 
 |  |  |     private void outStockByArea(OrderOutMergeParamDto dto, Wave wave) {
 | 
 |  |  |     @Transactional(rollbackFor = Exception.class)
 | 
 |  |  |     public void outStockByArea(OrderOutMergeParamDto dto, Wave wave) {
 | 
 |  |  |         List<OrderOutMergeParam> params = dto.getList();
 | 
 |  |  |         if (params.isEmpty()) {
 | 
 |  |  |             throw new CoolException("参数不能为空");
 | 
 |  |  | 
 |  |  |                 throw new CoolException("保存工作档失败");
 | 
 |  |  |             }
 | 
 |  |  | 
 | 
 |  |  |             wave.setSite(operationPort.getFlag());
 | 
 |  |  |             if (!waveService.updateById(wave)) {
 | 
 |  |  |                 throw new CoolException("波次站口状态更新失败!!");
 | 
 |  |  |             }
 | 
 |  |  | 
 | 
 |  |  |             for (OrderOutMergeDto merge : list) {
 | 
 |  |  |                 LocDetl locDetl = locDetlService.getById(merge.getLocDetlId());
 | 
 |  |  |                 if (locDetl == null) {
 | 
 |  |  | 
 |  |  |                 }
 | 
 |  |  | 
 | 
 |  |  |                 String matUniqueKey = Utils.getMatUniqueKey(taskDetl.getMatnr(), taskDetl.getBatch(), taskDetl.getUniqueField());
 | 
 |  |  |                 WaveDetl waveDetl = waveDetlService.getOne(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getStockIndex, matUniqueKey).eq(WaveDetl::getWaveId, wave.getId()));
 | 
 |  |  |                 logger.error("Matnr------>{}", taskDetl.getMatnr());
 | 
 |  |  |                 WaveDetl waveDetl = waveDetlService.getOne(new LambdaQueryWrapper<WaveDetl>()
 | 
 |  |  |                         .eq(WaveDetl::getStockIndex, matUniqueKey)
 | 
 |  |  |                         .eq(WaveDetl::getWaveId, wave.getId()));
 | 
 |  |  |                 if (waveDetl == null) {
 | 
 |  |  |                     throw new CoolException("波次数据不存在");
 | 
 |  |  |                     throw new CoolException("waveId:" + wave.getId() + "物料:" + taskDetl.getMatnr() + "波次数据不存在");
 | 
 |  |  |                 }
 | 
 |  |  |                 waveDetl.setWorkQty(waveDetl.getWorkQty() + taskDetl.getAnfme());
 | 
 |  |  |                 waveDetl.setUpdateTime(new Date());
 | 
 |  |  | 
 |  |  |             if (orders.isEmpty()) {
 | 
 |  |  |                 throw new CoolException("当前波次订单不存在!!");
 | 
 |  |  |             }
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | //            List<CacheSite> cacheSites = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>()
 | 
 |  |  | //                    .eq(CacheSite::getSiteStatus, CacheSiteStatusType.O.id).eq(CacheSite::getChannel, task.getTargetSite()));
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  |         for (LocDetl locDetl : param.getLocDetls()) {
 | 
 |  |  |             List<OrderOutMergeParam> orders = new ArrayList<>();
 | 
 |  |  |             LocDetl detl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, locDetl.getLocNo()));
 | 
 |  |  |             LocDetl detl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>()
 | 
 |  |  |                     .eq(LocDetl::getMatId, locDetl.getMatId())
 | 
 |  |  |                     .eq(LocDetl::getBatch, locDetl.getBatch())
 | 
 |  |  |                     .eq(LocDetl::getLocNo, locDetl.getLocNo()));
 | 
 |  |  |             if (Objects.isNull(detl)) {
 | 
 |  |  |                 continue;
 | 
 |  |  |             }
 |