海波 张
1 天以前 89943f29476e3de04c638cc7aefbdf2dd24d00c7
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
using HH.WCS.ZhongCeJinTan.util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Services.Configuration;
using Top.Api;
 
namespace HH.WCS.ZhongCeJinTan.wms
{
    /// <summary>
    /// 容器帮助类
    /// </summary>
    internal class ContainerHelper
    {
        internal static string GenerateCntrNo()
        {
            var date = DateTime.Now.ToString("yyMMdd");
            var id = SYSHelper.GetSerialNumber("托盘号", "KJZ" + date);
            return $"KJZ{date}{id.ToString().PadLeft(4, '0')}";
        }
 
        internal static bool CreateCntrItem(CntrItemRel work)
        {
            try
            {
                var db = new SqlHelper<object>().GetInstance();
                return db.Insertable<CntrItemRel>(work).ExecuteCommand() > 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
 
        internal static bool CreateCntr(Container cntr)
        {
            try
            {
                var db = new SqlHelper<object>().GetInstance();
 
                return db.Insertable<Container>(cntr).ExecuteCommand() > 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                LogHelper.Info($"添加容器异常"+ ex.Message, "Mes任务下发");
                throw;
            }
        }
 
       
 
 
      
        internal static bool delCntrItem(string cntrCode)
        {
            LogHelper.Info($"删除容器{cntrCode}");
            var db = new SqlHelper<object>().GetInstance();
 
            var tp = db.Queryable<CntrItemRel>().Where(it => it.S_CNTR_CODE == cntrCode).First();
            if (tp == null)
            {
                return true;
            }
            else
            {
                return db.Deleteable<CntrItemRel>().Where(it => it.S_CNTR_CODE == cntrCode).ExecuteCommand() > 0;
            }
        }
 
        internal static bool delCntrLoc(string cntrCode)
        {
            LogHelper.Info($"删除货位容器{cntrCode}");
            var db = new SqlHelper<object>().GetInstance();
 
            var tp = db.Queryable<LocCntrRel>().Where(it => it.S_CNTR_CODE == cntrCode).First();
            if (tp == null)
            {
                return true;
            }
            else
            {
                return db.Deleteable<CntrItemRel>().Where(it => it.S_CNTR_CODE == cntrCode).ExecuteCommand() > 0;
            }
        }
      
 
        internal static bool delCntr(string cntrCode)
        {
            var db = new SqlHelper<object>().GetInstance();
 
            var tp = db.Queryable<Container>().Where(it => it.S_CODE == cntrCode).First();
            if (tp == null)
            {
                return true;
            }
            else
            {
                return db.Deleteable<Container>().Where(it => it.S_CODE == cntrCode).ExecuteCommand() > 0;
            }
        }
 
 
 
        internal static Container GetCntr(string cntr)
        {
            //1.0 查货位容器表
            var db = new SqlHelper<object>().GetInstance();
            return db.Queryable<Container>().Where(a => a.S_CODE == cntr).First();
 
        }
        internal static CntrItemRel GetCntrItem(string cntr)
        {
            //1.0 查货位容器表
            var db = new SqlHelper<object>().GetInstance();
            return db.Queryable<CntrItemRel>().Where(s => s.S_CNTR_CODE == cntr).First();
 
        }
       
 
 
    }
}