|
@@ -106,7 +106,8 @@ public class InventoryService extends GenericProvider {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void handleOperation(String status, String operationType, List<Map<String, Object>> records) throws Exception {
|
|
|
|
|
|
|
+ public String handleOperation(String status, String operationType, List<Map<String, Object>> records) throws Exception {
|
|
|
|
|
+ String retVal = "";
|
|
|
if (records == null || records.isEmpty()) {
|
|
if (records == null || records.isEmpty()) {
|
|
|
throw new Exception("未查询到对应的 "+operationType+" 记录,操作失败!");
|
|
throw new Exception("未查询到对应的 "+operationType+" 记录,操作失败!");
|
|
|
}
|
|
}
|
|
@@ -136,6 +137,35 @@ public class InventoryService extends GenericProvider {
|
|
|
handleMultipleInventories(inventoryList, record);
|
|
handleMultipleInventories(inventoryList, record);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ return retVal;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void handleBackOrEndOperation(String status, List<Map<String, Object>> records) throws Exception {
|
|
|
|
|
+
|
|
|
|
|
+ for(Map<String, Object> record : records){
|
|
|
|
|
+ record.put("status", status);
|
|
|
|
|
+ String name1 = StrUtil.str(record.get("ming_cheng_"));
|
|
|
|
|
+ String name2 = StrUtil.str(record.get("shi_ji_ming_cheng"));
|
|
|
|
|
+ String reagentName = !name1.isEmpty() ? name1 : !name2.isEmpty() ? name2 : "";
|
|
|
|
|
+ record.put("ming_cheng_", reagentName);
|
|
|
|
|
+ String kcId = StrUtil.str(record.get("inventory_id"));
|
|
|
|
|
+ String batchNum = StrUtil.str(record.get("pi_hao_"));
|
|
|
|
|
+ String reagentCode = StrUtil.str(record.get("bian_ma_"));
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> inventoryList;
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(kcId)) {
|
|
|
|
|
+ inventoryList = storeService.queryInventoryById(kcId);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ inventoryList = storeService.queryInventoryByPhAndCode(batchNum, reagentCode);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (inventoryList.size() == 1) {
|
|
|
|
|
+ handleSingleInventory(inventoryList.get(0), record);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ handleMultipleInventories(inventoryList, record);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void handleSingleInventory(Map<String, Object> inventory, Map<String, Object> record) throws Exception {
|
|
private void handleSingleInventory(Map<String, Object> inventory, Map<String, Object> record) throws Exception {
|
|
@@ -153,8 +183,19 @@ public class InventoryService extends GenericProvider {
|
|
|
if ("start".equals(status)) {
|
|
if ("start".equals(status)) {
|
|
|
linYongService.updateWithhold(inventoryId, currentWithhold + quantity);
|
|
linYongService.updateWithhold(inventoryId, currentWithhold + quantity);
|
|
|
} else if ("end".equals(status)) {
|
|
} else if ("end".equals(status)) {
|
|
|
|
|
+ if(currentQuantity < quantity){
|
|
|
|
|
+ throw new Exception(record.get("ming_cheng_") + " 可用量不足!可用量:" + currentWithhold + ",需要:" + quantity);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(currentWithhold < quantity){
|
|
|
|
|
+ throw new Exception(record.get("ming_cheng_") + " 预扣量不足!预扣量:" + currentWithhold + ",需要:" + quantity);
|
|
|
|
|
+ }
|
|
|
linYongService.updateWithholdAndInventory(inventoryId, currentQuantity - quantity, currentWithhold - quantity);
|
|
linYongService.updateWithholdAndInventory(inventoryId, currentQuantity - quantity, currentWithhold - quantity);
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if ("back".equals(status)) {
|
|
|
|
|
+ if(currentWithhold < quantity){
|
|
|
|
|
+ throw new Exception(record.get("ming_cheng_") + " 预扣量不足!预扣量:" + currentWithhold + ",需要:" + quantity);
|
|
|
|
|
+ }
|
|
|
|
|
+ linYongService.updateWithhold(inventoryId, currentWithhold - quantity);
|
|
|
|
|
+ }else {
|
|
|
linYongService.updateInventory(inventoryId, currentQuantity - quantity);
|
|
linYongService.updateInventory(inventoryId, currentQuantity - quantity);
|
|
|
}
|
|
}
|
|
|
record.put("inventory_id", inventoryId);
|
|
record.put("inventory_id", inventoryId);
|
|
@@ -195,8 +236,20 @@ public class InventoryService extends GenericProvider {
|
|
|
actualDeduction = Math.min(available, remainingQuantity);
|
|
actualDeduction = Math.min(available, remainingQuantity);
|
|
|
linYongService.updateWithhold(inventoryId, currentWithhold + actualDeduction);
|
|
linYongService.updateWithhold(inventoryId, currentWithhold + actualDeduction);
|
|
|
} else if ("end".equals(status)) {
|
|
} else if ("end".equals(status)) {
|
|
|
|
|
+ if(currentQuantity < quantity){
|
|
|
|
|
+ throw new Exception(record.get("ming_cheng_") + " 可用量不足!可用量:" + currentWithhold + ",需要:" + quantity);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(currentWithhold < quantity){
|
|
|
|
|
+ throw new Exception(record.get("ming_cheng_") + " 预扣量不足!预扣量:" + currentWithhold + ",需要:" + quantity);
|
|
|
|
|
+ }
|
|
|
actualDeduction = Math.min(available, remainingQuantity);
|
|
actualDeduction = Math.min(available, remainingQuantity);
|
|
|
linYongService.updateWithholdAndInventory(inventoryId, currentQuantity - actualDeduction, currentWithhold - actualDeduction);
|
|
linYongService.updateWithholdAndInventory(inventoryId, currentQuantity - actualDeduction, currentWithhold - actualDeduction);
|
|
|
|
|
+ } else if ("back".equals(status)) {
|
|
|
|
|
+ if (currentWithhold < quantity) {
|
|
|
|
|
+ throw new Exception(record.get("ming_cheng_") + " 预扣量不足!预扣量:" + currentWithhold + ",需要:" + quantity);
|
|
|
|
|
+ }
|
|
|
|
|
+ actualDeduction = Math.min(available, remainingQuantity);
|
|
|
|
|
+ linYongService.updateWithhold(inventoryId, currentWithhold - quantity);
|
|
|
} else {
|
|
} else {
|
|
|
actualDeduction = Math.min(available, remainingQuantity);
|
|
actualDeduction = Math.min(available, remainingQuantity);
|
|
|
linYongService.updateInventory(inventoryId, currentQuantity - actualDeduction);
|
|
linYongService.updateInventory(inventoryId, currentQuantity - actualDeduction);
|