kazelee
2025-05-15 1af49bdb3cdaa44a7e44ebdc843fb8180596365f
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
using System;
using System.Collections.Generic;
using System.Web.Http;
 
using HH.WCS.Mobox3.DSZSH.Helpers;
using HH.WCS.Mobox3.DSZSH.Models;
using HH.WCS.Mobox3.DSZSH.Services;
 
using static HH.WCS.Mobox3.DSZSH.Dtos.Request.AgvRequest;
using static HH.WCS.Mobox3.DSZSH.Dtos.Request.DebugRequest;
using static HH.WCS.Mobox3.DSZSH.Dtos.Response.AgvResponse;
using static HH.WCS.Mobox3.DSZSH.Dtos.Response.DebugResponse;
 
namespace HH.WCS.Mobox3.DSZSH.Controllers {
    /// <summary>
    /// 测试用:如果项目中要和设备对接,前期设备无法测试,用接口模拟
    /// </summary>
    [RoutePrefix("api")]
    public class DebugController : ApiController
    {
        /// <summary>
        /// 模拟 AGV 多次回报任务状态
        /// </summary>
        /// <param name="model">容器号</param>
        /// <returns></returns>
        [HttpPost]
        [Route("AgvSeriesReports")]
        public ReturnResults AgvSeriesReports(UpdateTaskState model)
        {
            return DebugService.AgvSeriesReports(model);
        }
            
        /// <summary>
        /// 初始化数据库
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Route("CreateDatabase")]
        public string CreateDatabase() {
            return DebugService.CreateDatabase();
        }
 
        [HttpPost]
        [Route("InsertLocation")]
        public string InsertLocation(InsertLocationInfo model) {
            try {
                var db = DbHelper.GetDbClient();
                
                var locList = new List<TN_Location>();
                locList.Add(new TN_Location { S_AREA_CODE = model.AreaCode, S_CODE = model.Code});
 
                if (db.Insertable<TN_Location>(locList).ExecuteCommand() <= 0) {
                    return "失败";
                }
 
            }
            catch (Exception ex) {
                LogHelper.Info($"发生了异常");
                return "添加货位错误" + ex.Message;
            }
            //return res ? "成功" : "失败";
            return "成功";
        }
 
        /// <summary>
        /// DEBUG:插入货位、容器、货品信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Route("InsertLocCntrCg")]
        public string InsertLocCntrCg() {
            return DebugService.InsertLocCntrCg();
        }
 
    }
 
    public class CgInfo {
        public string ItemCode { get; set; }
        public string CntId { get; set; }
        public string LocId { get; set; }
    }
 
    public class InsertLocationInfo {
        public string Code { set; get; } 
        public string AreaCode { set; get; }
    }
 
    public class UpdateTaskWeightInfo {
        public string TaskID { set; get; }
        public float Weight { set; get; }
    }
}