|  |  |  | 
|---|
|  |  |  | private String locNo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Integer staNo; | 
|---|
|  |  |  | private List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<LocDto> locDtos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public boolean isAll(){ | 
|---|
|  |  |  | // 汇总不考虑序列码 | 
|---|
|  |  |  | List<DetlDto> detlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (LocDto locDto : this.getLocDtos()) { | 
|---|
|  |  |  | DetlDto dto = new DetlDto(locDto); | 
|---|
|  |  |  | if (DetlDto.has(detlDtos, dto)) { | 
|---|
|  |  |  | DetlDto detlDto = DetlDto.find(detlDtos, locDto); | 
|---|
|  |  |  | assert detlDto != null; | 
|---|
|  |  |  | detlDto.setAnfme(detlDto.getAnfme() + locDto.getAnfme()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | detlDtos.add(new DetlDto(locDto)); | 
|---|
|  |  |  | //    public boolean isAll(){ | 
|---|
|  |  |  | //        // 汇总不考虑序列码 | 
|---|
|  |  |  | //        List<DetlDto> detlDtos = new ArrayList<>(); | 
|---|
|  |  |  | //        for (LocDto locDto : this.getLocDtos()) { | 
|---|
|  |  |  | //            DetlDto dto = new DetlDto(locDto); | 
|---|
|  |  |  | //            if (DetlDto.has(detlDtos, dto)) { | 
|---|
|  |  |  | //                DetlDto detlDto = DetlDto.find(detlDtos, locDto); | 
|---|
|  |  |  | //                assert detlDto != null; | 
|---|
|  |  |  | //                detlDto.setAnfme(detlDto.getAnfme() + locDto.getAnfme()); | 
|---|
|  |  |  | //            } else { | 
|---|
|  |  |  | //                detlDtos.add(new DetlDto(locDto)); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        // 查询当前库位号所有的库存明细 | 
|---|
|  |  |  | //        LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); | 
|---|
|  |  |  | //        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", this.locNo)); | 
|---|
|  |  |  | //        if (locDetls == null || locDetls.isEmpty()){ | 
|---|
|  |  |  | //            throw new CoolException("检索库存明细失败,库位号=" + this.locNo); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        int sameNumber = 0; | 
|---|
|  |  |  | //        for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | //            Iterator<DetlDto> iterator = detlDtos.iterator(); | 
|---|
|  |  |  | //            while (iterator.hasNext()) { | 
|---|
|  |  |  | //                DetlDto dto = iterator.next(); | 
|---|
|  |  |  | //                if (!dto.getMatnr().equals(locDetl.getMatnr())) { | 
|---|
|  |  |  | //                    continue; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) { | 
|---|
|  |  |  | //                    continue; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!Cools.isEmpty(dto.getBatch()) && Cools.isEmpty(locDetl.getBatch())) { | 
|---|
|  |  |  | //                    continue; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) { | 
|---|
|  |  |  | //                    if (!dto.getBatch().equals(locDetl.getBatch())) { | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (dto.getAnfme() > locDetl.getAnfme()) { | 
|---|
|  |  |  | //                    throw new CoolException("服务器内部错误"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (dto.getAnfme().equals(locDetl.getAnfme())) { | 
|---|
|  |  |  | //                    sameNumber++; | 
|---|
|  |  |  | //                    iterator.remove(); | 
|---|
|  |  |  | //                    break; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        return sameNumber == locDetls.size(); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | public boolean isAll() { | 
|---|
|  |  |  | // 深拷贝,防止原集合被修改 | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtosCp = new ArrayList<>(this.locDetlDtos); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 查询当前库位号所有库存明细 | 
|---|
|  |  |  | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.selectList( | 
|---|
|  |  |  | new EntityWrapper<LocDetl>().eq("loc_no", this.locNo) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (locDetls == null || locDetls.isEmpty()) { | 
|---|
|  |  |  | throw new CoolException("检索库存明细失败,库位号=" + this.locNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int sameNumber = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | boolean matched = false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | System.out.println("当前库存明细: matnr=" + locDetl.getMatnr() + ", batch=" + locDetl.getBatch() + ", anfme=" + locDetl.getAnfme()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Iterator<LocDetlDto> iterator = locDetlDtosCp.iterator(); | 
|---|
|  |  |  | while (iterator.hasNext()) { | 
|---|
|  |  |  | LocDetlDto dto = iterator.next(); | 
|---|
|  |  |  | String dtoMatnr = dto.getLocDetl().getMatnr(); | 
|---|
|  |  |  | String dtoBatch = dto.getLocDetl().getBatch(); | 
|---|
|  |  |  | Double dtoCount = dto.getCount(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | System.out.println("比较对象: matnr=" + dtoMatnr + ", batch=" + dtoBatch + ", count=" + dtoCount); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!dtoMatnr.equals(locDetl.getMatnr())) continue; | 
|---|
|  |  |  | if (!Cools.eq(dtoBatch, locDetl.getBatch())) continue; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (dtoCount > locDetl.getAnfme()) { | 
|---|
|  |  |  | throw new CoolException("服务器内部错误,数量大于库存"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (dtoCount.equals(locDetl.getAnfme())) { | 
|---|
|  |  |  | sameNumber++; | 
|---|
|  |  |  | matched = true; | 
|---|
|  |  |  | iterator.remove(); | 
|---|
|  |  |  | System.out.println("匹配成功并移除该项,当前 sameNumber = " + sameNumber + ",剩余匹配数: " + locDetlDtosCp.size()); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 查询当前库位号所有的库存明细 | 
|---|
|  |  |  | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", this.locNo)); | 
|---|
|  |  |  | if (locDetls == null || locDetls.isEmpty()){ | 
|---|
|  |  |  | throw new CoolException("检索库存明细失败,库位号=" + this.locNo); | 
|---|
|  |  |  | if (!matched) { | 
|---|
|  |  |  | System.out.println("未匹配成功: matnr=" + locDetl.getMatnr() + ", batch=" + locDetl.getBatch()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int sameNumber = 0; | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | Iterator<DetlDto> iterator = detlDtos.iterator(); | 
|---|
|  |  |  | while (iterator.hasNext()) { | 
|---|
|  |  |  | DetlDto dto = iterator.next(); | 
|---|
|  |  |  | if (!dto.getMatnr().equals(locDetl.getMatnr())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(dto.getBatch()) && Cools.isEmpty(locDetl.getBatch())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) { | 
|---|
|  |  |  | if (!dto.getBatch().equals(locDetl.getBatch())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (dto.getAnfme() > locDetl.getAnfme()) { | 
|---|
|  |  |  | throw new CoolException("服务器内部错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (dto.getAnfme().equals(locDetl.getAnfme())) { | 
|---|
|  |  |  | sameNumber++; | 
|---|
|  |  |  | iterator.remove(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return sameNumber == locDetls.size(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return sameNumber == locDetls.size(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|