| | |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.system.entity.User; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | @RestController |
| | | public class OutController extends BaseController { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(OutController.class); |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3(), cstateid); |
| | | |
| | | HashMap<String, Double> locAnfmeMap = new HashMap<>(); |
| | | HashMap<String, List<LocDetl>> map = new HashMap<>(); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (map.containsKey(locDetl.getLocNo())) { |
| | | List<LocDetl> list = map.get(locDetl.getLocNo()); |
| | | list.add(locDetl); |
| | | map.put(locDetl.getLocNo(), list); |
| | | |
| | | Double originAnfme = locAnfmeMap.get(locDetl.getLocNo()); |
| | | originAnfme += locDetl.getAnfme(); |
| | | locAnfmeMap.put(locDetl.getLocNo(), originAnfme); |
| | | }else { |
| | | List<LocDetl> list = new ArrayList<>(); |
| | | list.add(locDetl); |
| | | map.put(locDetl.getLocNo(), list); |
| | | locAnfmeMap.put(locDetl.getLocNo(), locDetl.getAnfme()); |
| | | } |
| | | } |
| | | |
| | | // 使用Stream API进行排序并创建新的Map,同时保持插入顺序。 |
| | | Map<String, Double> sortedMap = locAnfmeMap.entrySet().stream() |
| | | .sorted(Map.Entry.<String, Double>comparingByValue(Comparator.reverseOrder())) // 根据值排序条目。 |
| | | .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); |
| | | |
| | | //未匹配上整托库存 |
| | | HashMap<String, Double> lessMap = new HashMap<>(); |
| | | |
| | | List<LocDetl> allLoc = new ArrayList<>(); |
| | | List<LocDetl> lessLoc = new ArrayList<>(); |
| | | //优先找整托 |
| | | for (Map.Entry<String, Double> entry : sortedMap.entrySet()) { |
| | | if (issued <= 0) { |
| | | break; |
| | | } |
| | | |
| | | String locNo = entry.getKey(); |
| | | Double anfme = entry.getValue(); |
| | | if(anfme > orderDetl.getAnfme()) { |
| | | lessMap.put(locNo, anfme); |
| | | continue; |
| | | } |
| | | List<LocDetl> list = map.get(locNo); |
| | | allLoc.addAll(list); |
| | | |
| | | // 剩余待出数量递减 |
| | | issuedBigDecimal = issuedBigDecimal.subtract(BigDecimal.valueOf(anfme)); |
| | | issued = issuedBigDecimal.doubleValue(); |
| | | } |
| | | |
| | | if(issued > 0) { |
| | | //零散搜索 |
| | | for (Map.Entry<String, Double> entry : lessMap.entrySet()) { |
| | | if (issued <= 0) { |
| | | break; |
| | | } |
| | | |
| | | String locNo = entry.getKey(); |
| | | Double anfme = entry.getValue(); |
| | | if (anfme >= issued) { |
| | | List<LocDetl> list = map.get(locNo); |
| | | lessLoc.addAll(list); |
| | | // 剩余待出数量递减 |
| | | issuedBigDecimal = issuedBigDecimal.subtract(BigDecimal.valueOf(anfme)); |
| | | issued = issuedBigDecimal.doubleValue(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | allLoc.addAll(lessLoc); |
| | | issuedBigDecimal = Optional.of(BigDecimal.valueOf(orderDetl.getAnfme()).subtract(BigDecimal.valueOf(orderDetl.getWorkQty()))).orElse(new BigDecimal(0)); |
| | | issued = issuedBigDecimal.doubleValue(); |
| | | for (LocDetl locDetl : allLoc) { |
| | | if (disableCstateidList.contains(locDetl.getCstateid())) { |
| | | continue; |
| | | } |