抛光仓库功能
This commit is contained in:
@@ -252,7 +252,7 @@ namespace ZR.Service.mes.wms
|
||||
.Insertable(newWmPolishInventory)
|
||||
.ExecuteReturnEntity();
|
||||
string code = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
string remark = "初次创建仓库,新增手动入库数据";
|
||||
string remark = "初次创建仓库,新增入库数据 " + parm.Remark;
|
||||
int successNum = AddPolishRecord(
|
||||
addWmPolishInventory.Id,
|
||||
code,
|
||||
@@ -280,7 +280,6 @@ namespace ZR.Service.mes.wms
|
||||
}
|
||||
// 已有则新增记录
|
||||
string code = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
string remark = "手动入库";
|
||||
int successNum = AddPolishRecord(
|
||||
polishInventory.Id,
|
||||
code,
|
||||
@@ -288,13 +287,117 @@ namespace ZR.Service.mes.wms
|
||||
1,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
parm.Remark,
|
||||
parm.CreatedBy
|
||||
);
|
||||
if (successNum == 0)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("入库日志添加失败");
|
||||
}
|
||||
}
|
||||
Context.Ado.CommitTran();
|
||||
return 1;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public int DoWmPolishRetrieval(WmPolishInventory parm)
|
||||
{
|
||||
try
|
||||
{
|
||||
Context.Ado.BeginTran();
|
||||
// 零件号检查
|
||||
string partnumber = parm.Partnumber;
|
||||
WmMaterial material = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.Where(it => it.Type == 1)
|
||||
.Where(it => it.Status == 1)
|
||||
.First();
|
||||
if (material == null)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("零件号在物料清单未查到,请到物料清单新增零件号记录");
|
||||
}
|
||||
// 检查是否存在库中
|
||||
WmPolishInventory polishInventory = Context
|
||||
.Queryable<WmPolishInventory>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.Where(it => it.Type == parm.Type)
|
||||
.Where(it => it.Status == 1)
|
||||
.First();
|
||||
if (polishInventory == null)
|
||||
{
|
||||
// 为空则新增库
|
||||
WmPolishInventory newWmPolishInventory =
|
||||
new()
|
||||
{
|
||||
Id = SnowFlakeSingle.Instance.NextId().ToString(),
|
||||
BlankNum = "",
|
||||
Partnumber = partnumber,
|
||||
Type = parm.Type,
|
||||
Quantity = parm.Quantity * -1,
|
||||
MaxNum = 0,
|
||||
MinNum = 0,
|
||||
WarnNum = 0,
|
||||
Status = 1,
|
||||
Remark = "系统自动创建库",
|
||||
CreatedBy = parm.CreatedBy,
|
||||
CreatedTime = DateTime.Now.ToLocalTime(),
|
||||
UpdatedBy = parm.CreatedBy,
|
||||
UpdatedTime = DateTime.Now.ToLocalTime(),
|
||||
};
|
||||
WmPolishInventory addWmPolishInventory = Context
|
||||
.Insertable(newWmPolishInventory)
|
||||
.ExecuteReturnEntity();
|
||||
string code = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
string remark = "初次创建仓库,新增手动出库数据" + parm.Remark;
|
||||
int successNum = AddPolishRecord(
|
||||
addWmPolishInventory.Id,
|
||||
code,
|
||||
partnumber,
|
||||
2,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
remark,
|
||||
parm.CreatedBy
|
||||
);
|
||||
if (successNum == 0)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("入库日志添加失败");
|
||||
throw new Exception("出库日志添加失败");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
polishInventory.Quantity -= parm.Quantity;
|
||||
int updateNum = Context.Updateable(polishInventory).ExecuteCommand();
|
||||
if (updateNum == 0)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("修改抛光仓库零件数失败");
|
||||
}
|
||||
// 已有则新增记录
|
||||
string code = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
int successNum = AddPolishRecord(
|
||||
polishInventory.Id,
|
||||
code,
|
||||
partnumber,
|
||||
2,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
parm.Remark,
|
||||
parm.CreatedBy
|
||||
);
|
||||
if (successNum == 0)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("出库日志添加失败");
|
||||
}
|
||||
}
|
||||
Context.Ado.CommitTran();
|
||||
@@ -326,7 +429,6 @@ namespace ZR.Service.mes.wms
|
||||
Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
// 已有则新增记录
|
||||
string code = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
string remark = "手动盘点";
|
||||
int successNum = AddPolishRecord(
|
||||
parm.Id,
|
||||
code,
|
||||
@@ -334,7 +436,7 @@ namespace ZR.Service.mes.wms
|
||||
3,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
remark,
|
||||
parm.Remark,
|
||||
parm.CreatedBy
|
||||
);
|
||||
if (successNum == 0)
|
||||
@@ -351,5 +453,7 @@ namespace ZR.Service.mes.wms
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user