IWcsTaskTestApp.cs
2.06 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
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using WebRepository;
namespace WebApp
{
    /// <summary>
    /// 模拟创建WCS任务测试接口App
    /// </summary>
    public partial class IWcsTaskTestApp : ApiApp
    {
        public IWcsTaskTestApp(IUnitWork unitWork, IAuth auth, BaseDBContext context) : base(unitWork, auth, context)
        {
        }
        public WCSResponse<WcsTask> CreateWcsTaskApp(TaskDetail td)
        {
            using (var tran = _context.Database.BeginTransaction())
            {
                WCSResponse<WcsTask> Response = new WCSResponse<WcsTask>();
                try
                {
                    if (td == null)
                    {
                        Response.Code = 500;
                        Response.Status = false;
                        Response.Message = "未传入任何有效数据!";
                    }
                    else
                    {
                        WcsTask wcsTask = new WcsTask();
                        wcsTask.TNo = td.TaskNo;
                        wcsTask.TNoWMS = td.TaskNo;
                        wcsTask.Type = td.TaskType;
                        wcsTask.PalletOrBoxNo = td.ContainerCode;
                        wcsTask.Priority = td.Priority;
                        wcsTask.Roadway = td.Roadway;
                        wcsTask.FromPlace = td.SourceLocation;
                        wcsTask.ToPlace = td.DestinationLocation;
                        wcsTask.EntrancePlace = td.Station;
                        wcsTask.ExitPlace = td.Station;
                        _unitWork.Add(wcsTask);
                        tran.Commit();
                        Response.Result = wcsTask;
                    }
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    Response.Code = 500;
                    Response.Status = false;
                    Response.Message = ex.Message;
                }
                return Response;
            }
        }
    }
}