lss
2025-05-19 27aa7a13c64b829eef39fbd67255f1be9155cc12
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
using HH.WCS.JiaTong.api;
using HH.WCS.JiaTong.models.other;
using HH.WCS.JiaTong.util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;
using static HH.WCS.JiaTong.api.ApiModel;
 
namespace HH.WCS.JiaTong.wms
{
    /// <summary>
    /// wms管到作业
    /// </summary>
    internal class WMSHelper
    {
        internal static string GenerateTaskNo()
        {
            var id = SYSHelper.GetSerialNumber("作业号", "OP");
            var date = DateTime.Now.ToString("yyMMdd");
            return $"OP{date}{id.ToString().PadLeft(4, '0')}";
        }
        internal static string GenerateSortingNo()
        {
            var id = SYSHelper.GetSerialNumber("分拣单", "SO");
            var date = DateTime.Now.ToString("yyMMdd");
            return $"SO{date}{id.ToString().PadLeft(4, '0')}";
        }
        internal static List<WMSTask> GetOperationListByState(string state)
        {
            var db = new SqlHelper<object>().GetInstance();
            return db.Queryable<WMSTask>().Where(a => a.S_B_STATE == state).ToList();
        }
        internal static List<WMSTask> GetOperationListByState(int state)
        {
            var db = new SqlHelper<object>().GetInstance();
            return db.Queryable<WMSTask>().Where(a => a.N_B_STATE == state).ToList();
        }
        internal static List<WMSTask> GetWaitingOperationList()
        {
            var db = new SqlHelper<object>().GetInstance();
            return db.Queryable<WMSTask>().Where(a => a.N_B_STATE == 0 || a.N_B_STATE == 3).ToList();
        }
 
        internal static bool CreateWmsTask(WMSTask wmsTask)
        {
            try
            {
                var db = new SqlHelper<object>().GetInstance();
                return db.Insertable<WMSTask>(wmsTask).ExecuteCommand() > 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
      
        internal static Location GetEnd(WMSTask a)
        {
 
            throw new NotImplementedException();
        }
 
        internal static Location GetStart(WMSTask a)
        {
            throw new NotImplementedException();
        }
 
        internal static void UpdateTaskState(WMSTask task)
        {
            var db = new SqlHelper<object>().GetInstance();
            task.T_MODIFY = DateTime.Now;
            task.S_B_STATE = WMSTask.GetStateStr(task.N_B_STATE);
            db.Updateable<WMSTask>(task).UpdateColumns(a => new { a.N_B_STATE, a.S_B_STATE, a.T_MODIFY }).ExecuteCommand();
        }
 
        internal static bool UpdateTaskEnd(WMSTask a)
        {
            var db = new SqlHelper<object>().GetInstance();
            a.T_MODIFY = DateTime.Now;
            return db.Updateable<WMSTask>(a).UpdateColumns(it => new { it.S_END_LOC, it.T_MODIFY }).ExecuteCommand() > 0;
        }
 
        internal static WMSTask GetWmsTask(string code)
        {
            var db = new SqlHelper<object>().GetInstance();
            return db.Queryable<WMSTask>().Where(a => a.S_CODE == code).First();
        }
 
      
    }
}