|
@@ -2,10 +2,7 @@ package com.tld.service.impl;
|
|
|
|
|
|
import com.tld.mapper.AskGoodsMapper;
|
|
|
import com.tld.mapper.DeliveryMapper;
|
|
|
-import com.tld.model.AskGoods;
|
|
|
-import com.tld.model.Delivery;
|
|
|
-import com.tld.model.Inventory;
|
|
|
-import com.tld.model.ReturRemoval;
|
|
|
+import com.tld.model.*;
|
|
|
import com.tld.service.DeliveryService;
|
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
@@ -46,20 +43,44 @@ public class DeliveryServiceImpl implements DeliveryService {
|
|
|
public Map<String, Object> getRecommend(Delivery delivery) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
try{
|
|
|
- //查询所有产成品库位
|
|
|
- String storageLocationCode = deliveryMapper.getStorageLocationCodeList();
|
|
|
- List<Inventory> list = new LinkedList<>();
|
|
|
- Map<String, Object> occupyMap = new HashMap<>();
|
|
|
- for(Inventory inventory : deliveryMapper.getInventory(storageLocationCode, delivery)){
|
|
|
- int occupy = deliveryMapper.getVitrual(inventory);
|
|
|
- if(Integer.parseInt(inventory.getAmount()) == occupy){
|
|
|
- list.add(inventory);
|
|
|
- int num = Integer.parseInt(inventory.getAmount()) - occupy;
|
|
|
- occupyMap.put(inventory.getStorageLocationCode(), num);
|
|
|
+ MaterialClass materialClass = deliveryMapper.getMaterialClass(delivery.getMaterialId());
|
|
|
+ if(materialClass == null){
|
|
|
+ map.put("msg", "500");
|
|
|
+ map.put("errMsg", "物料信息未录入,请联系管理员");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ if(materialClass.getPartType().equals("产成品")){
|
|
|
+ //查询所有产成品库位
|
|
|
+ String storageLocationCode = deliveryMapper.getStorageLocationCodeList();
|
|
|
+ List<Inventory> list = new LinkedList<>();
|
|
|
+ Map<String, Object> occupyMap = new HashMap<>();
|
|
|
+ for(Inventory inventory : deliveryMapper.getInventory(storageLocationCode, delivery)){
|
|
|
+ int occupy = deliveryMapper.getVitrual(inventory);
|
|
|
+ if(Integer.parseInt(inventory.getAmount()) == occupy){
|
|
|
+ list.add(inventory);
|
|
|
+ int num = Integer.parseInt(inventory.getAmount()) - occupy;
|
|
|
+ occupyMap.put(inventory.getStorageLocationCode(), num);
|
|
|
+ }
|
|
|
}
|
|
|
+ map.put("data", list);
|
|
|
+ map.put("occupyMap", occupyMap);
|
|
|
+ } else if(materialClass.getPartType().equals("半成品")){
|
|
|
+ String storageLocationCode = "000000,";
|
|
|
+ List<Inventory> list = new LinkedList<>();
|
|
|
+ Map<String, Object> occupyMap = new HashMap<>();
|
|
|
+ for(Inventory inventory : deliveryMapper.getInventory(storageLocationCode, delivery)){
|
|
|
+ int occupy = deliveryMapper.getVitrual(inventory);
|
|
|
+ if(Integer.parseInt(inventory.getAmount()) > occupy){
|
|
|
+ list.add(inventory);
|
|
|
+ int num = Integer.parseInt(inventory.getAmount()) - occupy;
|
|
|
+ occupyMap.put(inventory.getStorageLocationCode(), num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("data", list);
|
|
|
+ map.put("occupyMap", occupyMap);
|
|
|
+ } else {
|
|
|
+
|
|
|
}
|
|
|
- map.put("data", list);
|
|
|
- map.put("occupyMap", occupyMap);
|
|
|
map.put("msg", "200");
|
|
|
}catch (Exception e){
|
|
|
map.put("msg", "500");
|