加事务
This commit is contained in:
1 parent
9f6f95828c
commit
2453e8405b
4 files changed
+84
-7
No files matched your search
@@ -99,7 +99,10 @@ namespace HHWMS.Web
|
|||||||
var task = _unitwork.Find<TaskHeader>(x => x.TaskNo.Equals(taskno)
|
var task = _unitwork.Find<TaskHeader>(x => x.TaskNo.Equals(taskno)
|
||||||
&& x.Status != TaskStatusEnum.完成)
|
&& x.Status != TaskStatusEnum.完成)
|
||||||
.Include(x => x.TaskDetails).FirstOrDefault();
|
.Include(x => x.TaskDetails).FirstOrDefault();
|
||||||
|
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
if (task != null)
|
if (task != null)
|
||||||
{
|
{
|
||||||
if (task.Status != TaskStatusEnum.完成 && response.Result == (int)TaskStatusEnum.完成)
|
if (task.Status != TaskStatusEnum.完成 && response.Result == (int)TaskStatusEnum.完成)
|
||||||
@@ -246,9 +249,9 @@ namespace HHWMS.Web
|
|||||||
&& x.Type.Equals(LocationTypeEnum.机械臂工位))?.Code;
|
&& x.Type.Equals(LocationTypeEnum.机械臂工位))?.Code;
|
||||||
plrTask.ToLocation = to;
|
plrTask.ToLocation = to;
|
||||||
// 更新明细为待下发
|
// 更新明细为待下发
|
||||||
var details = plrTask.TaskDetails.Where(x =>!string.IsNullOrEmpty(x.ContainerCode) && x.ContainerCode.Contains(task.ContainerCode));
|
var details = plrTask.TaskDetails.Where(x => !string.IsNullOrEmpty(x.ContainerCode) && x.ContainerCode.Contains(task.ContainerCode));
|
||||||
|
|
||||||
foreach(var item in details)
|
foreach (var item in details)
|
||||||
{
|
{
|
||||||
item.Status = TaskStatusEnum.待下发;
|
item.Status = TaskStatusEnum.待下发;
|
||||||
item.UpdateTime = DateTime.Now;
|
item.UpdateTime = DateTime.Now;
|
||||||
@@ -359,7 +362,7 @@ namespace HHWMS.Web
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(task.TaskType == TaskTypeEnum.盘料盒入库
|
if (task.TaskType == TaskTypeEnum.盘料盒入库
|
||||||
|| task.TaskType == TaskTypeEnum.散料盒入库)
|
|| task.TaskType == TaskTypeEnum.散料盒入库)
|
||||||
{
|
{
|
||||||
var invList = _unitwork.Find<Inventory>(x => x.ContainerCode == task.ContainerCode
|
var invList = _unitwork.Find<Inventory>(x => x.ContainerCode == task.ContainerCode
|
||||||
@@ -400,6 +403,14 @@ namespace HHWMS.Web
|
|||||||
{
|
{
|
||||||
return ApiResult();
|
return ApiResult();
|
||||||
}
|
}
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
tran.Rollback();
|
||||||
|
return JsonMore(null, 500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
return ApiResult();
|
return ApiResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using HHWMS.Web.Models;
|
using HHWMS.Web.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -153,7 +154,10 @@ public class ReceiptSLInController : BaseController
|
|||||||
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
|
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
|
||||||
data.Select(x => x.ReceiptCode).ToList().Contains(x.ID.ToString()))
|
data.Select(x => x.ReceiptCode).ToList().Contains(x.ID.ToString()))
|
||||||
.Include(x => x.ReceiptDetails).ToList();
|
.Include(x => x.ReceiptDetails).ToList();
|
||||||
|
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
||||||
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
||||||
{
|
{
|
||||||
@@ -165,7 +169,7 @@ public class ReceiptSLInController : BaseController
|
|||||||
if (receipt.Status == ReceiptStatusEnum.收完) continue;
|
if (receipt.Status == ReceiptStatusEnum.收完) continue;
|
||||||
receipt.CompletedQty += item.BindQty;
|
receipt.CompletedQty += item.BindQty;
|
||||||
}
|
}
|
||||||
if(receipt.CompletedQty == receipt.Qty)
|
if (receipt.CompletedQty == receipt.Qty)
|
||||||
{
|
{
|
||||||
receipt.Status = ReceiptStatusEnum.收完;
|
receipt.Status = ReceiptStatusEnum.收完;
|
||||||
if (!header.ReceiptDetails.Any(x => x.Status < ReceiptStatusEnum.收完))
|
if (!header.ReceiptDetails.Any(x => x.Status < ReceiptStatusEnum.收完))
|
||||||
@@ -197,6 +201,15 @@ public class ReceiptSLInController : BaseController
|
|||||||
_unitWork.Add(inventory);
|
_unitWork.Add(inventory);
|
||||||
}
|
}
|
||||||
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
||||||
|
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tran.Rollback();
|
||||||
|
return JsonMore(null, 500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
return JsonMore(null);
|
return JsonMore(null);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -224,6 +237,10 @@ public class ReceiptSLInController : BaseController
|
|||||||
{
|
{
|
||||||
return JsonMore(null, 500, $"{boxCode}站台没有料箱,无法入库!");
|
return JsonMore(null, 500, $"{boxCode}站台没有料箱,无法入库!");
|
||||||
}
|
}
|
||||||
|
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
// 判断箱号是否合理
|
// 判断箱号是否合理
|
||||||
var box = _unitWork.FindSingle<Location>(x => x.ContainerCode.Equals(station.ContainerCode)
|
var box = _unitWork.FindSingle<Location>(x => x.ContainerCode.Equals(station.ContainerCode)
|
||||||
&& x.Type != LocationTypeEnum.散料库站台);
|
&& x.Type != LocationTypeEnum.散料库站台);
|
||||||
@@ -259,6 +276,35 @@ public class ReceiptSLInController : BaseController
|
|||||||
toLocation.Status = LocationStatus.任务锁;
|
toLocation.Status = LocationStatus.任务锁;
|
||||||
toLocation.Length = isFull ? 1 : 0; // 是否满盘
|
toLocation.Length = isFull ? 1 : 0; // 是否满盘
|
||||||
_unitWork.Update(toLocation);
|
_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
|
else
|
||||||
{
|
{
|
||||||
@@ -272,4 +318,11 @@ public class ReceiptSLInController : BaseController
|
|||||||
return JsonMore(null, 500, $"{boxCode}不正确!");
|
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 invList = new List<Inventory>();
|
||||||
var listInvtran = new List<InventoryTransaction>();
|
var listInvtran = new List<InventoryTransaction>();
|
||||||
|
|
||||||
|
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
||||||
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
||||||
{
|
{
|
||||||
@@ -127,6 +131,15 @@ public class ReceiptShelfInController : BaseController
|
|||||||
_unitWork.BatchAdd(invList.ToArray());
|
_unitWork.BatchAdd(invList.ToArray());
|
||||||
_unitWork.BatchAdd(listInvtran.ToArray());
|
_unitWork.BatchAdd(listInvtran.ToArray());
|
||||||
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
||||||
|
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tran.Rollback();
|
||||||
|
return JsonMore(null, 500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
return JsonMore(null);
|
return JsonMore(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@
|
|||||||
_this.disabledbackbutton = false;
|
_this.disabledbackbutton = false;
|
||||||
} else {
|
} else {
|
||||||
_this.$message({
|
_this.$message({
|
||||||
message: "绑定失败!",
|
message: "绑定失败!"+ json.Msg,
|
||||||
type: "warning",
|
type: "warning",
|
||||||
duration: "10000",
|
duration: "10000",
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user