| | |
| | | package com.zy.asrs.wms.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wms.asrs.entity.LocDetl; |
| | | import com.zy.asrs.wms.asrs.entity.dto.OrderOutBatchPreviewDto; |
| | | import com.zy.asrs.wms.asrs.entity.dto.OrderOutMergeDto; |
| | | import com.zy.asrs.wms.asrs.entity.dto.OutDetlDto; |
| | | import com.zy.asrs.wms.asrs.entity.dto.OutLocDto; |
| | | import com.zy.asrs.wms.asrs.entity.param.OrderOutMergeParam; |
| | | import com.zy.asrs.wms.asrs.entity.param.OutParam; |
| | | import com.zy.asrs.wms.asrs.service.LocDetlService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class OutUtils { |
| | | |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | public List<OutLocDto> merge(OutParam outParam) { |
| | | HashMap<Long, OutLocDto> map = new HashMap<>(); |
| | | |
| | | for (OutDetlDto detl : outParam.getDetls()) { |
| | | LocDetl locDetl = locDetlService.getById(detl.getDetlId()); |
| | | if (locDetl == null) { |
| | | continue; |
| | | } |
| | | detl.setStock(locDetl.getAnfme()); |
| | | |
| | | if (map.containsKey(locDetl.getLocId())) { |
| | | OutLocDto locDto = map.get(locDetl.getLocId()); |
| | | List<OutDetlDto> detlDtos = locDto.getDetls(); |
| | | detlDtos.add(detl); |
| | | |
| | | locDto.setDetls(detlDtos); |
| | | }else { |
| | | OutLocDto locDto = new OutLocDto(); |
| | | map.put(locDetl.getLocId(), locDto); |
| | | |
| | | List<OutDetlDto> detlDtos = new ArrayList<>(); |
| | | detlDtos.add(detl); |
| | | |
| | | locDto.setLocId(locDetl.getLocId()); |
| | | locDto.setDetls(detlDtos); |
| | | } |
| | | } |
| | | |
| | | List<OutLocDto> locDtos = new ArrayList<>(); |
| | | for (Map.Entry<Long, OutLocDto> entry : map.entrySet()) { |
| | | OutLocDto locDto = entry.getValue(); |
| | | locDtos.add(locDto); |
| | | |
| | | Boolean all = this.isAllForOut(locDto.getLocId(), locDto.getDetls()); |
| | | locDto.setAll(all); |
| | | locDto.setOperationPort(outParam.getOperationPort()); |
| | | } |
| | | |
| | | //add zero stock |
| | | for (OutLocDto locDto : locDtos) { |
| | | List<OutDetlDto> detls = locDto.getDetls(); |
| | | List<Long> detlIds = new ArrayList<>(); |
| | | for (OutDetlDto detl : detls) { |
| | | detlIds.add(detl.getDetlId()); |
| | | } |
| | | |
| | | List<LocDetl> list = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, locDto.getLocId()).notIn(LocDetl::getId, detlIds)); |
| | | if (!list.isEmpty()) { |
| | | List<OutDetlDto> detlDtos = locDto.getDetls(); |
| | | for (LocDetl locDetl : list) { |
| | | OutDetlDto outDetlDto = new OutDetlDto(); |
| | | outDetlDto.setDetlId(locDetl.getId()); |
| | | outDetlDto.setAnfme(0D); |
| | | outDetlDto.setStock(locDetl.getAnfme()); |
| | | detlDtos.add(outDetlDto); |
| | | } |
| | | locDto.setDetls(detlDtos); |
| | | } |
| | | } |
| | | |
| | | return locDtos; |
| | | } |
| | | |
| | | public Boolean isAllForMerge(Long locId, List<OrderOutMergeDto> list) { |
| | | List<Double> anfmeList = new ArrayList<>(); |
| | | for (OrderOutMergeDto dto : list) { |
| | | anfmeList.add(dto.getAnfme()); |
| | | } |
| | | return isAll(locId, anfmeList); |
| | | } |
| | | |
| | | public Boolean isAllForPreview(Long locId, List<OrderOutBatchPreviewDto> list) { |
| | | List<Double> anfmeList = new ArrayList<>(); |
| | | for (OrderOutBatchPreviewDto outPreviewDto : list) { |
| | | anfmeList.add(outPreviewDto.getAnfme()); |
| | | } |
| | | return isAll(locId, anfmeList); |
| | | } |
| | | |
| | | public Boolean isAllForOut(Long locId, List<OutDetlDto> list) { |
| | | List<Double> anfmeList = new ArrayList<>(); |
| | | for (OutDetlDto dto : list) { |
| | | anfmeList.add(dto.getAnfme()); |
| | | } |
| | | return isAll(locId, anfmeList); |
| | | } |
| | | |
| | | private Boolean isAll(Long locId, List<Double> anfmeList) { |
| | | if (anfmeList.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, locId)); |
| | | Double sum = 0D; |
| | | for (LocDetl locDetl : locDetls) { |
| | | sum += locDetl.getAnfme(); |
| | | } |
| | | |
| | | for (Double anfme : anfmeList) { |
| | | sum -= anfme; |
| | | } |
| | | |
| | | return sum <= 0; |
| | | } |
| | | |
| | | } |
| | | package com.zy.asrs.wms.utils;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.zy.asrs.wms.asrs.entity.LocDetl;
|
| | | import com.zy.asrs.wms.asrs.entity.dto.OrderOutBatchPreviewDto;
|
| | | import com.zy.asrs.wms.asrs.entity.dto.OrderOutMergeDto;
|
| | | import com.zy.asrs.wms.asrs.entity.dto.OutDetlDto;
|
| | | import com.zy.asrs.wms.asrs.entity.dto.OutLocDto;
|
| | | import com.zy.asrs.wms.asrs.entity.param.OrderOutMergeParam;
|
| | | import com.zy.asrs.wms.asrs.entity.param.OutParam;
|
| | | import com.zy.asrs.wms.asrs.service.LocDetlService;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | @Component
|
| | | public class OutUtils {
|
| | |
|
| | | @Autowired
|
| | | private LocDetlService locDetlService;
|
| | |
|
| | | public List<OutLocDto> merge(OutParam outParam) {
|
| | | HashMap<Long, OutLocDto> map = new HashMap<>();
|
| | |
|
| | | for (OutDetlDto detl : outParam.getDetls()) {
|
| | | LocDetl locDetl = locDetlService.getById(detl.getDetlId());
|
| | | if (locDetl == null) {
|
| | | continue;
|
| | | }
|
| | | detl.setStock(locDetl.getAnfme());
|
| | |
|
| | | if (map.containsKey(locDetl.getLocId())) {
|
| | | OutLocDto locDto = map.get(locDetl.getLocId());
|
| | | List<OutDetlDto> detlDtos = locDto.getDetls();
|
| | | detlDtos.add(detl);
|
| | |
|
| | | locDto.setDetls(detlDtos);
|
| | | }else {
|
| | | OutLocDto locDto = new OutLocDto();
|
| | | map.put(locDetl.getLocId(), locDto);
|
| | |
|
| | | List<OutDetlDto> detlDtos = new ArrayList<>();
|
| | | detlDtos.add(detl);
|
| | |
|
| | | locDto.setLocId(locDetl.getLocId());
|
| | | locDto.setDetls(detlDtos);
|
| | | }
|
| | | }
|
| | |
|
| | | List<OutLocDto> locDtos = new ArrayList<>();
|
| | | for (Map.Entry<Long, OutLocDto> entry : map.entrySet()) {
|
| | | OutLocDto locDto = entry.getValue();
|
| | | locDtos.add(locDto);
|
| | |
|
| | | Boolean all = this.isAllForOut(locDto.getLocId(), locDto.getDetls());
|
| | | locDto.setAll(all);
|
| | | locDto.setOperationPort(outParam.getOperationPort());
|
| | | }
|
| | |
|
| | | //add zero stock
|
| | | for (OutLocDto locDto : locDtos) {
|
| | | List<OutDetlDto> detls = locDto.getDetls();
|
| | | List<Long> detlIds = new ArrayList<>();
|
| | | for (OutDetlDto detl : detls) {
|
| | | detlIds.add(detl.getDetlId());
|
| | | }
|
| | |
|
| | | List<LocDetl> list = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, locDto.getLocId()).notIn(LocDetl::getId, detlIds));
|
| | | if (!list.isEmpty()) {
|
| | | List<OutDetlDto> detlDtos = locDto.getDetls();
|
| | | for (LocDetl locDetl : list) {
|
| | | OutDetlDto outDetlDto = new OutDetlDto();
|
| | | outDetlDto.setDetlId(locDetl.getId());
|
| | | outDetlDto.setAnfme(0D);
|
| | | outDetlDto.setStock(locDetl.getAnfme());
|
| | | detlDtos.add(outDetlDto);
|
| | | }
|
| | | locDto.setDetls(detlDtos);
|
| | | }
|
| | | }
|
| | |
|
| | | return locDtos;
|
| | | }
|
| | |
|
| | | public Boolean isAllForMerge(Long locId, List<OrderOutMergeDto> list) {
|
| | | List<Double> anfmeList = new ArrayList<>();
|
| | | for (OrderOutMergeDto dto : list) {
|
| | | anfmeList.add(dto.getAnfme());
|
| | | }
|
| | | return isAll(locId, anfmeList);
|
| | | }
|
| | |
|
| | | public Boolean isAllForPreview(Long locId, List<OrderOutBatchPreviewDto> list) {
|
| | | List<Double> anfmeList = new ArrayList<>();
|
| | | for (OrderOutBatchPreviewDto outPreviewDto : list) {
|
| | | anfmeList.add(outPreviewDto.getAnfme());
|
| | | }
|
| | | return isAll(locId, anfmeList);
|
| | | }
|
| | |
|
| | | public Boolean isAllForOut(Long locId, List<OutDetlDto> list) {
|
| | | List<Double> anfmeList = new ArrayList<>();
|
| | | for (OutDetlDto dto : list) {
|
| | | anfmeList.add(dto.getAnfme());
|
| | | }
|
| | | return isAll(locId, anfmeList);
|
| | | }
|
| | |
|
| | | private Boolean isAll(Long locId, List<Double> anfmeList) {
|
| | | if (anfmeList.isEmpty()) {
|
| | | return false;
|
| | | }
|
| | |
|
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, locId));
|
| | | Double sum = 0D;
|
| | | for (LocDetl locDetl : locDetls) {
|
| | | sum += locDetl.getAnfme();
|
| | | }
|
| | |
|
| | | for (Double anfme : anfmeList) {
|
| | | sum -= anfme;
|
| | | }
|
| | |
|
| | | return sum <= 0;
|
| | | }
|
| | |
|
| | | }
|