添加根据工单自动生成批处理记录功能
This commit is contained in:
parent
3568a502e4
commit
9af5f78dd3
@ -73,6 +73,28 @@ namespace ZR.Admin.WebApi.Controllers.mes.ql
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据工单自动生成批处理记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="actionDate">执行时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("AddBatchListByWorkOrder2")]
|
||||||
|
public IActionResult AddBatchListByWorkOrder2(int year,int week,int day)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int ret = plBatchService.CreatePLBatchRecordsByWorkOrder(year,week,day);
|
||||||
|
|
||||||
|
return ToResponse(new ApiResult(200, "success", ret));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return ToResponse(new ApiResult(500, "error", e.Message));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除测试数据记录
|
/// 删除测试数据记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -18,6 +18,7 @@ namespace ZR.Service.mes.ql.IService
|
|||||||
|
|
||||||
public int CreatePLBatchRecordsByWorkOrder(DateTime actionDate);
|
public int CreatePLBatchRecordsByWorkOrder(DateTime actionDate);
|
||||||
|
|
||||||
|
// 根据年月日生成数据
|
||||||
|
public int CreatePLBatchRecordsByWorkOrder(int year,int week,int day);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,6 +95,52 @@ namespace ZR.Service.mes.ql
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据年月日生成实验室批量工单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="year"></param>
|
||||||
|
/// <param name="week"></param>
|
||||||
|
/// <param name="day"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
|
public int CreatePLBatchRecordsByWorkOrder(int year, int week, int day)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Context.Ado.BeginTran();
|
||||||
|
// 查询工单
|
||||||
|
var predicate = Expressionable
|
||||||
|
.Create<ProWorkorder_v2>()
|
||||||
|
.And(it => it.Year == year)
|
||||||
|
.And(it => it.Week == week)
|
||||||
|
.And(it => it.Date == day)
|
||||||
|
//.And(it => it.Remark2.Contains("调试"))
|
||||||
|
.And(it => it.Remark3 == "是")
|
||||||
|
.ToExpression();
|
||||||
|
List<ProWorkorder_v2> workOrderList = Context.Queryable<ProWorkorder_v2>()
|
||||||
|
.Where(predicate)
|
||||||
|
.OrderByDescending(it => it.Sort)
|
||||||
|
.ToList();
|
||||||
|
foreach (ProWorkorder_v2 workorder in workOrderList)
|
||||||
|
{
|
||||||
|
List<PLBatch> pLBatches = CreatePLBatchRecordsByWorkOrder(workorder);
|
||||||
|
int res = Context.Insertable<PLBatch>(pLBatches).ExecuteCommand();
|
||||||
|
if (res == 0)
|
||||||
|
{
|
||||||
|
Context.Ado.RollbackTran();
|
||||||
|
throw new Exception("插入批量检测记录异常,异常工单:" + workorder.ClientWorkorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context.Ado.CommitTran();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Context.Ado.RollbackTran();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据工单创建批量检测数据
|
/// 根据工单创建批量检测数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -200,6 +246,7 @@ namespace ZR.Service.mes.ql
|
|||||||
.AndIF(!string.IsNullOrEmpty(workOrder), it => it.Workorder.Contains(workOrder))
|
.AndIF(!string.IsNullOrEmpty(workOrder), it => it.Workorder.Contains(workOrder))
|
||||||
.AndIF(!string.IsNullOrEmpty(code), it => it.Code.Contains(code))
|
.AndIF(!string.IsNullOrEmpty(code), it => it.Code.Contains(code))
|
||||||
.AndIF(!string.IsNullOrEmpty(description), it => it.Description.Contains(description))
|
.AndIF(!string.IsNullOrEmpty(description), it => it.Description.Contains(description))
|
||||||
|
|
||||||
.ToExpression();
|
.ToExpression();
|
||||||
|
|
||||||
//int totalNum = 0;
|
//int totalNum = 0;
|
||||||
@ -291,5 +338,6 @@ namespace ZR.Service.mes.ql
|
|||||||
return (int)dayOfWeek;
|
return (int)dayOfWeek;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user