IEmptyContainerOutApp.cs
3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using Infrastructure;
using WebRepository;
namespace WebApp
{
/// <summary>
/// 入库口补充空托请求接口App
/// </summary>
public partial class IEmptyContainerOutApp : ApiApp
{
public IEmptyContainerOutApp(IUnitWork unitWork, IAuth auth, BaseDBContext context) : base(unitWork, auth, context)
{
}
public string GetEmptyContainer(string station)
{
using (var tran = _context.Database.BeginTransaction())
{
Response<Location> Response = new Response<Location>();
try
{
StationRoadway st = _unitWork.FindSingle<StationRoadway>(u => u.StationCode.Equals(station));
Location loc = _unitWork.FindSingle<Location>(u => u.Roadway.Equals(st.RoadWay) && u.Status == LocationStatus.空容器 && u.IsStop == false);
if (loc == null)
{
Response.Code = 500;
Response.Status = false;
Response.Message = "库位中没有足够的空容器!";
}
else
{
Task task = new Task();
TaskDetail taskDetail = new TaskDetail();
var tno = _unitWork.GetTaskNo(TaskNo.空板补充);
task.TaskNo = tno;
task.OrderCode = tno;
task.BusinessType = BusinessType.出库_其他出库单;
task.FirstStatus = TaskStatus.下达任务;
task.LastStatus = TaskStatus.下达任务;
task.CreateTime = DateTime.Now;
if (task.UpdateBy == null)
{
task.UpdateBy = "wms";
task.UpdateTime = DateTime.Now;
}
_unitWork.Add(task);
taskDetail.TaskNo = tno;
taskDetail.OrderCode = tno;
taskDetail.TaskType = TaskType.空容器出库;
taskDetail.ContainerCode = loc.ContainerCode;
taskDetail.SourceLocation = loc.Code;
taskDetail.DestinationLocation = station;
taskDetail.OderQty = 0;
taskDetail.ContainerQty = 0;
taskDetail.HadQty = 0;
taskDetail.Roadway = loc.Roadway;
taskDetail.Station = station;
taskDetail.Status = TaskStatus.下达任务;
taskDetail.CreateTime = DateTime.Now;
if (taskDetail.UpdateBy == null)
{
taskDetail.UpdateBy = "wms";
taskDetail.UpdateTime = DateTime.Now;
}
_unitWork.Add(taskDetail);
loc.Status = LocationStatus.任务锁定中;
loc.UpdateTime = DateTime.Now;
if (loc.UpdateBy == null)
{
loc.UpdateBy = "wms";
loc.UpdateTime = DateTime.Now;
}
_unitWork.Update(loc);
tran.Commit();
Response.Result = loc;
}
}
catch (Exception ex)
{
tran.Rollback();
Response.Code = 500;
Response.Status = false;
Response.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Response);
}
}
}
}