加事务
This commit is contained in:
1 parent
9f6f95828c
commit
2453e8405b
4 files changed
+80
-3
No files matched your search
@@ -99,7 +99,10 @@ namespace HHWMS.Web
|
||||
var task = _unitwork.Find<TaskHeader>(x => x.TaskNo.Equals(taskno)
|
||||
&& x.Status != TaskStatusEnum.完成)
|
||||
.Include(x => x.TaskDetails).FirstOrDefault();
|
||||
|
||||
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (task != null)
|
||||
{
|
||||
if (task.Status != TaskStatusEnum.完成 && response.Result == (int)TaskStatusEnum.完成)
|
||||
@@ -400,6 +403,14 @@ namespace HHWMS.Web
|
||||
{
|
||||
return ApiResult();
|
||||
}
|
||||
tran.Commit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
return JsonMore(null, 500, ex.Message);
|
||||
}
|
||||
}
|
||||
return ApiResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -153,7 +154,10 @@ public class ReceiptSLInController : BaseController
|
||||
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
|
||||
data.Select(x => x.ReceiptCode).ToList().Contains(x.ID.ToString()))
|
||||
.Include(x => x.ReceiptDetails).ToList();
|
||||
|
||||
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
||||
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
||||
{
|
||||
@@ -197,6 +201,15 @@ public class ReceiptSLInController : BaseController
|
||||
_unitWork.Add(inventory);
|
||||
}
|
||||
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
||||
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
return JsonMore(null, 500, ex.Message);
|
||||
}
|
||||
}
|
||||
return JsonMore(null);
|
||||
}
|
||||
/// <summary>
|
||||
@@ -224,6 +237,10 @@ public class ReceiptSLInController : BaseController
|
||||
{
|
||||
return JsonMore(null, 500, $"{boxCode}站台没有料箱,无法入库!");
|
||||
}
|
||||
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
// 判断箱号是否合理
|
||||
var box = _unitWork.FindSingle<Location>(x => x.ContainerCode.Equals(station.ContainerCode)
|
||||
&& x.Type != LocationTypeEnum.散料库站台);
|
||||
@@ -259,6 +276,35 @@ public class ReceiptSLInController : BaseController
|
||||
toLocation.Status = LocationStatus.任务锁;
|
||||
toLocation.Length = isFull ? 1 : 0; // 是否满盘
|
||||
_unitWork.Update(toLocation);
|
||||
|
||||
var listInvtran = new List<InventoryTransaction>();
|
||||
var invList = _unitWork.Find<Inventory>(x =>
|
||||
x.ContainerCode.Equals(task.ContainerCode)
|
||||
&& x.TaskStatus == InventoryTaskStatus.任务中
|
||||
).ToList();
|
||||
foreach (var inv in invList)
|
||||
{
|
||||
listInvtran.Add(new InventoryTransaction
|
||||
{
|
||||
BillType = "in",
|
||||
ZoneCode = inv.ZoneCode,
|
||||
Type = inv.UniqueCode,
|
||||
MaterialCode = inv.MaterialCode,
|
||||
MaterialName = inv.MaterialName,
|
||||
MaterialSpec = inv.MaterialSpec,
|
||||
MaterialUnit = inv.MaterialUnit,
|
||||
MaterialType = inv.MaterialType,
|
||||
Batch = inv.Batch,
|
||||
Lot = inv.Lot,
|
||||
CompanyCode = inv.CompanyCode,
|
||||
LocationCode = inv.LocationCode,
|
||||
SupplierCode = inv.SupplierCode,
|
||||
Qty = inv.Qty,
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
_unitWork.BatchAdd(listInvtran.ToArray());
|
||||
tran.Commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -272,4 +318,11 @@ public class ReceiptSLInController : BaseController
|
||||
return JsonMore(null, 500, $"{boxCode}不正确!");
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
return JsonMore(null, 500, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,10 @@ public class ReceiptShelfInController : BaseController
|
||||
var invList = new List<Inventory>();
|
||||
var listInvtran = new List<InventoryTransaction>();
|
||||
|
||||
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
||||
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
||||
{
|
||||
@@ -127,6 +131,15 @@ public class ReceiptShelfInController : BaseController
|
||||
_unitWork.BatchAdd(invList.ToArray());
|
||||
_unitWork.BatchAdd(listInvtran.ToArray());
|
||||
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
||||
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
return JsonMore(null, 500, ex.Message);
|
||||
}
|
||||
}
|
||||
return JsonMore(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
_this.disabledbackbutton = false;
|
||||
} else {
|
||||
_this.$message({
|
||||
message: "绑定失败!",
|
||||
message: "绑定失败!"+ json.Msg,
|
||||
type: "warning",
|
||||
duration: "10000",
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user