schangxiang@126.com
2025-09-17 ff43ddf18764629ff875478e4e47a7281cbd230a
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
138
139
140
141
142
143
144
145
using iWareSql.MyDbContext;
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace iWareCC.Common.Helper
{
    public class BaseInfoHelper
    {
        /// <summary>
        /// 获取容器
        /// </summary>
        /// <param name="mycontext"></param>
        /// <param name="containerCode"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static wms_base_container GetContainer(MyDbContext mycontext, string containerCode, ref string errMsg)
        {
 
 
            var container = mycontext.wms_base_container.FirstOrDefault(f => f.ContainerCode == containerCode && f.IsDelete == false);
            if (container == null)
            {
                errMsg = $"容器号{containerCode}不存在";
                throw new Exception(errMsg);
            }
            if (container.IsDisabled == true)
            {
                errMsg = $"容器号{containerCode}已禁用";
                throw new Exception(errMsg);
 
            }
 
            return container;
        }
 
        /// <summary>
        /// 获取库位
        /// </summary>
        /// <param name="mycontext"></param>
        /// <param name="placeCode"></param>
        /// <param name="remark"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static wms_base_place GetPlace(MyDbContext mycontext, string placeCode, string remark, ref string errMsg)
        {
 
 
            var place = mycontext.wms_base_place.FirstOrDefault(f => f.PlaceCode == placeCode && f.IsDelete == false);
            if (place == null)
            {
                errMsg = $"{remark}{placeCode}不存在";
                throw new Exception(errMsg);
            }
            if (place.IsDisabled == true)
            {
                errMsg = $"{remark}{placeCode}已禁用";
                throw new Exception(errMsg);
            }
            //if (place.PlaceStatus != (int)PlaceStatusEnum.正常)
            //{
            //    errMsg = $"{remark}{placeCode}库位属性不是{PlaceStatusEnum.正常.ToString()}";
            //}
 
            return place;
 
        }
 
 
        /// <summary>
        /// 获取库区
        /// </summary>
        /// <param name="mycontext"></param>
        /// <param name="placeCode"></param>
        /// <param name="remark"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static wms_base_area GetArea(MyDbContext mycontext, string areaCode, string remark, ref string errMsg)
        {
 
 
            var area = mycontext.wms_base_area.FirstOrDefault(f => f.AreaCode == areaCode && f.IsDelete == false);
            if (area == null)
            {
                errMsg = $"{remark}{areaCode}不存在";
                throw new Exception(errMsg);
            }
            if (area.IsDisabled == true)
            {
                errMsg = $"{remark}{areaCode}已禁用";
                throw new Exception(errMsg);
            }
 
            return area;
 
        }
 
 
 
        /// <summary>
        /// 获取移动单
        /// </summary>
        /// <param name="mycontext"></param>
        /// <param name="singleTask"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static wms_order_movement GetOrderMovement(MyDbContext mycontext, wms_task singleTask, ref string errMsg)
        {
 
            var moveOrder = mycontext.wms_order_movement.FirstOrDefault(x => singleTask.OrderNo.Equals(x.OrderNo) || singleTask.RelationNo.Equals(x.OrderNo));
            if (moveOrder == null)
            {
                errMsg = $"单号{singleTask.RelationNo}\\{singleTask.OrderNo}未查询到移动单";
                throw new Exception(errMsg);
 
            }
 
            return moveOrder;
        }
 
        /// <summary>
        /// 获取移动单明细
        /// </summary>
        /// <param name="mycontext"></param>
        /// <param name="singleTask"></param>
        /// <param name="moveOrder"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static List<wms_order_movement_details> GetMoveOrderDetails(MyDbContext mycontext, wms_task singleTask, wms_order_movement moveOrder, ref string errMsg)
        {
 
            var moveOrderDetails = mycontext.wms_order_movement_details.Where(x => x.MovementId == moveOrder.Id).ToList();
            if (moveOrderDetails?.Count <= 0)
            {
                errMsg = $"单号{singleTask.OrderNo}移动单明细不存在";
                throw new Exception(errMsg);
            }
 
            return moveOrderDetails;
        }
 
 
 
    }
}