| | |
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.fasterxml.jackson.datatype.jsr310.DecimalUtils;
|
| | | import com.mysql.cj.util.StringUtils;
|
| | | import com.zy.asrs.framework.exception.CoolException;
|
| | | import com.zy.asrs.wms.asrs.entity.dto.*;
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.DecimalFormat;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
| | | List<MergePreviewResultDto> resultDtos = new ArrayList<>();
|
| | | //优先查询平库数据
|
| | | param.forEach(pars -> {
|
| | | if (pars.getStatus() == 1) {
|
| | | return;
|
| | | }
|
| | | List<MergePreviewResultLocDto> locDtos = new ArrayList<>();
|
| | | MergePreviewResultDto resultDto = new MergePreviewResultDto();
|
| | | resultDto.sync(pars);
|
| | | resultDto.setOrderIds(pars.getOrderIds());
|
| | | //总需求数量
|
| | | resultDto.setAnfme(pars.getAnfme());
|
| | | resultDto.setLocs(locDtos);
|
| | |
|
| | | //查询平库中符合条件的库存
|
| | | List<LocDetl> locs = locDetlService.queryFlatStock(pars.getMatnr(), pars.getBatch(), pars.getFieldParams());
|
| | | if (!locs.isEmpty()) {
|
| | | double anfme = pars.getAnfme() - pars.getWorkQty();
|
| | |
| | | locDto.setLocNo(detl.getLocNo());
|
| | | locDto.setTypeId(LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id);
|
| | | locDto.setLocDetlId(detl.getId());
|
| | |
|
| | | locDto.setAnfme(detl.getAnfme());
|
| | | locDto.setWorkQty(detl.getWorkQty());
|
| | | locDtos.add(locDto);
|
| | | //库位实际可用数量
|
| | | double surplusQty = detl.getAnfme() - detl.getWorkQty();
|
| | | if (surplusQty <= 0) {
|
| | | continue;
|
| | | }
|
| | | //波次数量减去库位可用数量后,盈余数量
|
| | | anfme = anfme - surplusQty;
|
| | | if (anfme > 0) {
|
| | | locDto.setAnfme(detl.getAnfme());
|
| | | locDto.setWorkQty(surplusQty);
|
| | | //当前可使用数量
|
| | | resultDto.setFetchQty(surplusQty);
|
| | | //余下需求数量
|
| | | pars.setStatus(2);
|
| | | pars.setWorkQty(pars.getWorkQty() + surplusQty);
|
| | | pars.setAnfme(anfme);
|
| | | } else {
|
| | | locDto.setAnfme(pars.getAnfme() - pars.getWorkQty());
|
| | | locDto.setWorkQty(pars.getAnfme() - pars.getWorkQty());
|
| | | //当前使用数量
|
| | | resultDto.setFetchQty(pars.getAnfme());
|
| | | //余下需求
|
| | | pars.setWorkQty(pars.getWorkQty() + pars.getAnfme());
|
| | | pars.setStatus(1);
|
| | | pars.setAnfme(0.0);
|
| | | break;
|
| | | }
|
| | | }
|
| | | //保存出库数量(平库)
|
| | | pars.setWorkQty(pars.getAnfme() - pars.getWorkQty() - anfme);
|
| | |
|
| | | resultDto.setOtherLocs(new ArrayList<>());
|
| | | if (!Objects.isNull(resultDto.getFetchQty()) && !(new BigDecimal(resultDto.getFetchQty()).compareTo(new BigDecimal("0.00")) == 0)) {
|
| | | resultDto.setOtherLocs(new ArrayList<>());
|
| | |
|
| | | resultDto.setAnfme(pars.getAnfme());
|
| | | resultDto.setType(LocAreaTypeSts.LOC_AREA_TYPE_FLAT.desc);
|
| | |
|
| | | resultDtos.add(resultDto);
|
| | |
|
| | | resultDtos.add(resultDto);
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | //平库查询完成后,再查询TCU
|
| | | for (MergePreviewDto dto : param) {
|
| | | Double anfme = dto.getAnfme() - dto.getWorkQty();
|
| | | //减去平库数量后,小于等于0,跳出处理
|
| | | if (anfme <= 0) {
|
| | | //单据已完成,跳出
|
| | | if (dto.getStatus() == 1) {
|
| | | continue;
|
| | | }
|
| | | // Double anfme = dto.getAnfme() - dto.getWorkQty();
|
| | | // //减去平库数量后,小于等于0,跳出处理
|
| | | // if (anfme <= 0) {
|
| | | // continue;
|
| | | // }
|
| | | List<LocDetl> locDetls = locDetlService.queryStock(dto.getMatnr(), dto.getBatch(), dto.getFieldParams(), sortParams);
|
| | | if (locDetls.isEmpty()) {
|
| | | MergePreviewResultDto resultDto = new MergePreviewResultDto();
|
| | | resultDto.sync(dto);
|
| | | resultDto.setLocs(new ArrayList<>());
|
| | | resultDto.setType(LocAreaTypeSts.LOC_AREA_TYPE_UTC.desc);
|
| | | resultDto.setOrderIds(dto.getOrderIds());
|
| | | resultDto.setAnfme(dto.getAnfme());
|
| | | resultDtos.add(resultDto);
|
| | |
| | | MergePreviewResultDto resultDto = new MergePreviewResultDto();
|
| | | resultDto.sync(dto);
|
| | | resultDto.setOrderIds(dto.getOrderIds());
|
| | | // Double anfme = dto.getAnfme();
|
| | | Double anfme = dto.getAnfme();
|
| | | resultDto.setLocs(locDtos);
|
| | | for (LocDetl locDetl : locDetls) {
|
| | | Loc loc = locService.getById(locDetl.getLocId());
|
| | |
| | |
|
| | | resultDto.setAnfme(dto.getAnfme());
|
| | |
|
| | | resultDto.setType(LocAreaTypeSts.LOC_AREA_TYPE_UTC.desc);
|
| | |
|
| | | resultDtos.add(resultDto);
|
| | | }
|
| | |
|