111
lss
2 天以前 23c28e3c0437081a78a48e54dc066c87500fa8bc
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using HH.WCS.JiaTong_DCJ.dispatch;
using HH.WCS.JiaTong_DCJ.process;
using HH.WCS.JiaTong_DCJ.util;
using HH.WCS.JiaTong_DCJ.wms;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Web.Http;
using static HH.WCS.JiaTong_DCJ.api.ApiModel;
using static HH.WCS.JiaTong_DCJ.api.OtherModel;
 
namespace HH.WCS.JiaTong_DCJ.api
{
    /// <summary>
    /// mobox3调用,脚本中调用
    /// </summary>
    public class MoboxController : System.Web.Http.ApiController
    {
        /// <summary>
        /// 任务取消(目前支持ndc)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public Result CancelTask(MoboxTaskBase model)
        {
            var result = new Result();
            var db = new SqlHelper<object>().GetInstance();
            try
            {
                var taskWCS = db.Queryable<WCSTask>().First(a => a.S_CODE.Trim() == model.TaskNo);
                if (taskWCS == null)
                {
                    result.code = "1";
                    result.msg = $"未找到该任务号,{model.TaskNo}";
                    LogHelper.Info(result.msg);
                    return result;
                }
                if (taskWCS.N_B_STATE == 0)
                {
                    taskWCS.N_B_STATE = 4;
                    taskWCS.S_B_STATE = "取消";
                    taskWCS.T_MODIFY = System.DateTime.Now;
                    db.Updateable<WCSTask>(taskWCS).ExecuteCommand();
 
                    result.code = "0";
                    result.msg = $"成功";
                    LogHelper.Info(result.msg);
                    return result;
                }
                if (taskWCS.N_B_STATE == 3)
                {
                    result.code = "2";
                    result.msg = $"该任务号:{model.TaskNo},已完成无需取消";
            
                    LogHelper.Info(result.msg);
                    return result;
                }
                var res = NDCApi.CancelOrder(model.TaskNo);//取消命令,默认强制取消
                if (res.err_code == 0)
                {
                    taskWCS.N_B_STATE = 4;
                    taskWCS.S_B_STATE = "取消";
                    taskWCS.T_MODIFY = System.DateTime.Now;
                    db.Updateable<WCSTask>(taskWCS).ExecuteCommand();
 
                    result.code = "0";
                    result.msg = $"成功";
                    LogHelper.Info(result.msg);
                    return result;
                }
                else
                {
                    LogHelper.Info($"该任务号:{model.TaskNo},取消命令已发送,结果:{JsonConvert.SerializeObject(res)}");
                    //任务小车已经取消,单方面处理取消
                    //taskWCS.N_B_STATE = 4;
                    //taskWCS.S_B_STATE = "取消";
                    //taskWCS.T_MODIFY = System.DateTime.Now;
                    TaskProcess.OperateStatus(taskWCS, 7);
                   // db.Updateable<WCSTask>(taskWCS).ExecuteCommand();
                    result.code = res.err_code.ToString();
                    result.msg = res.err_msg;
                    return result;
                }
            }
            catch (Exception ex)
            {
                result.code = "-1";
                result.msg = $"发生了异常{ex.Message}";
                LogHelper.Info(result.msg);
                return result;
            }
        }
        /// <summary>
        /// 任务强制完成(目前支持ndc)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public SimpleResult CompleteTask(MoboxTaskBase model)
        {
            var result = new SimpleResult();
            return result;
        }
 
        /// <summary>
        /// 货位信息上传
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public Result UploadLoc(List<LocList> model)
        {
            Result result = new Result();
            LogHelper.Info("UploadLoc 接收:" + JsonConvert.SerializeObject(model));
            result = ApiHelper.UploadLoc(model);
            LogHelper.Info("UploadLoc 返回:" + JsonConvert.SerializeObject(model));
            return result;
        }
 
        /// <summary>
        /// 设备状态上报
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpGet]
        public DeviceInfoModel DeviceInfo()
        {
            DeviceInfoModel result = new DeviceInfoModel();
            //LogHelper.Info("UploadLoc 接收:" + JsonConvert.SerializeObject(model));
           
            result = ApiHelper.Device();
            LogHelper.Info("DeviceInfo 返回:" + JsonConvert.SerializeObject(result));
            return result;
        }
    }
}