|
@@ -139,13 +139,13 @@ public class InventoryService extends GenericProvider {
|
|
|
long currentQuantity = StrUtil.parseLongSafe(inventory.get("quantity"));
|
|
long currentQuantity = StrUtil.parseLongSafe(inventory.get("quantity"));
|
|
|
long currentWithhold = StrUtil.parseLongSafe(inventory.get("withhold"));
|
|
long currentWithhold = StrUtil.parseLongSafe(inventory.get("withhold"));
|
|
|
long available = currentQuantity - currentWithhold;
|
|
long available = currentQuantity - currentWithhold;
|
|
|
|
|
+ String status = StrUtil.str(record.get("status"));
|
|
|
|
|
|
|
|
- if (available < quantity) {
|
|
|
|
|
|
|
+ if (available < quantity && "start".equals(status)) {
|
|
|
throw new Exception(record.get("ming_cheng_") + " 可用量不足!可用量:" + available + ",需要:" + quantity);
|
|
throw new Exception(record.get("ming_cheng_") + " 可用量不足!可用量:" + available + ",需要:" + quantity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String inventoryId = StrUtil.str(inventory.get("id_"));
|
|
String inventoryId = StrUtil.str(inventory.get("id_"));
|
|
|
- String status = StrUtil.str(record.get("status"));
|
|
|
|
|
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)) {
|
|
@@ -157,11 +157,12 @@ public class InventoryService extends GenericProvider {
|
|
|
record.put("quantity", quantity);
|
|
record.put("quantity", quantity);
|
|
|
record.put("flow", status.isEmpty()?"not":status);
|
|
record.put("flow", status.isEmpty()?"not":status);
|
|
|
record.put("position", StrUtil.str(inventory.get("position")));
|
|
record.put("position", StrUtil.str(inventory.get("position")));
|
|
|
- addTrans(record);
|
|
|
|
|
|
|
+ updateTrans(record);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void handleMultipleInventories(List<Map<String, Object>> inventoryList, Map<String, Object> record) throws Exception {
|
|
private void handleMultipleInventories(List<Map<String, Object>> inventoryList, Map<String, Object> record) throws Exception {
|
|
|
long quantity = Long.parseLong(record.get("shu_liang_").toString());
|
|
long quantity = Long.parseLong(record.get("shu_liang_").toString());
|
|
|
|
|
+ String status = StrUtil.str(record.get("status"));
|
|
|
long totalAvailable = inventoryList.stream()
|
|
long totalAvailable = inventoryList.stream()
|
|
|
.mapToLong(inv -> {
|
|
.mapToLong(inv -> {
|
|
|
long qty = StrUtil.parseLongSafe(inv.get("quantity"));
|
|
long qty = StrUtil.parseLongSafe(inv.get("quantity"));
|
|
@@ -170,12 +171,11 @@ public class InventoryService extends GenericProvider {
|
|
|
})
|
|
})
|
|
|
.sum();
|
|
.sum();
|
|
|
|
|
|
|
|
- if (totalAvailable < quantity) {
|
|
|
|
|
|
|
+ if (totalAvailable < quantity && "start".equals(status)) {
|
|
|
throw new Exception(record.get("ming_cheng_") + " 总可用量不足!总可用量:" + totalAvailable + ",需要:" + quantity);
|
|
throw new Exception(record.get("ming_cheng_") + " 总可用量不足!总可用量:" + totalAvailable + ",需要:" + quantity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
long remainingQuantity = quantity;
|
|
long remainingQuantity = quantity;
|
|
|
- String status = StrUtil.str(record.get("status"));
|
|
|
|
|
for (Map<String, Object> inventory : inventoryList) {
|
|
for (Map<String, Object> inventory : inventoryList) {
|
|
|
if (remainingQuantity <= 0) break;
|
|
if (remainingQuantity <= 0) break;
|
|
|
|
|
|
|
@@ -204,7 +204,7 @@ public class InventoryService extends GenericProvider {
|
|
|
record.put("quantity", actualDeduction);
|
|
record.put("quantity", actualDeduction);
|
|
|
record.put("flow", status.isEmpty()?"not":status);
|
|
record.put("flow", status.isEmpty()?"not":status);
|
|
|
record.put("position", StrUtil.str(inventory.get("position")));
|
|
record.put("position", StrUtil.str(inventory.get("position")));
|
|
|
- addTrans(record);
|
|
|
|
|
|
|
+ updateTrans(record);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -216,26 +216,33 @@ public class InventoryService extends GenericProvider {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void addTrans(Map<String, Object> map) {
|
|
|
|
|
- ReagentConsumablesTransactionPo tran = new ReagentConsumablesTransactionPo();
|
|
|
|
|
- tran.setReagentCode(StrUtil.str(map.get("bian_ma_")));
|
|
|
|
|
- tran.setQuantity(Long.parseLong(StrUtil.str(map.get("quantity"))));
|
|
|
|
|
- String value1 = StrUtil.str(map.get("you_xiao_qi_"));
|
|
|
|
|
- String value2 = StrUtil.str(map.get("you_xiao_qi_zhi_"));
|
|
|
|
|
- String date = !value1.isEmpty() ? value1 : !value2.isEmpty() ? value2 : "";
|
|
|
|
|
- tran.setExpDate(date);
|
|
|
|
|
- tran.setPosition(StrUtil.str(map.get("position")));
|
|
|
|
|
- tran.setStatus(StrUtil.str(map.get("type")));
|
|
|
|
|
- tran.setType(Long.valueOf("-1"));
|
|
|
|
|
- tran.setBoId(StrUtil.str(map.get("id_")));
|
|
|
|
|
- tran.setDiDian(StrUtil.str(map.get("di_dian_")));
|
|
|
|
|
- tran.setBatchNum(StrUtil.str(map.get("pi_hao_")));
|
|
|
|
|
- tran.setInventoryId(StrUtil.str(map.get("inventory_id")));
|
|
|
|
|
- tran.setFlow(StrUtil.str(map.get("flow")));
|
|
|
|
|
-
|
|
|
|
|
- ReagentConsumablesTransaction transaction = reagentConsumablesTransactionRepository.newInstance();
|
|
|
|
|
- transaction.setData(tran);
|
|
|
|
|
- transaction.save();
|
|
|
|
|
|
|
+ public void updateTrans(Map<String, Object> map) {
|
|
|
|
|
+ String status = StrUtil.str(map.get("flow"));
|
|
|
|
|
+ String boId = StrUtil.str(map.get("id_"));
|
|
|
|
|
+ String kcId = StrUtil.str(map.get("inventory_id"));
|
|
|
|
|
+ if("end".equals(status)){
|
|
|
|
|
+ linYongService.updateTaiZhang(boId,kcId);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ ReagentConsumablesTransactionPo tran = new ReagentConsumablesTransactionPo();
|
|
|
|
|
+ tran.setReagentCode(StrUtil.str(map.get("bian_ma_")));
|
|
|
|
|
+ tran.setQuantity(Long.parseLong(StrUtil.str(map.get("quantity"))));
|
|
|
|
|
+ String value1 = StrUtil.str(map.get("you_xiao_qi_"));
|
|
|
|
|
+ String value2 = StrUtil.str(map.get("you_xiao_qi_zhi_"));
|
|
|
|
|
+ String date = !value1.isEmpty() ? value1 : !value2.isEmpty() ? value2 : "";
|
|
|
|
|
+ tran.setExpDate(date);
|
|
|
|
|
+ tran.setPosition(StrUtil.str(map.get("position")));
|
|
|
|
|
+ tran.setStatus(StrUtil.str(map.get("type")));
|
|
|
|
|
+ tran.setType(Long.valueOf("-1"));
|
|
|
|
|
+ tran.setBoId(boId);
|
|
|
|
|
+ tran.setDiDian(StrUtil.str(map.get("di_dian_")));
|
|
|
|
|
+ tran.setBatchNum(StrUtil.str(map.get("pi_hao_")));
|
|
|
|
|
+ tran.setInventoryId(kcId);
|
|
|
|
|
+ tran.setFlow(status);
|
|
|
|
|
+
|
|
|
|
|
+ ReagentConsumablesTransaction transaction = reagentConsumablesTransactionRepository.newInstance();
|
|
|
|
|
+ transaction.setData(tran);
|
|
|
|
|
+ transaction.save();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void updateStock(StockDto stockDto) throws Exception {
|
|
public void updateStock(StockDto stockDto) throws Exception {
|