hudong
2025-07-04 67c7f0449f57933c26d785c277ddcd539c899b25
wms/WCSHelper.cs
@@ -12,7 +12,20 @@
            var date = DateTime.Now.ToString("yyMMdd");
            return $"TN{date}{id.ToString().PadLeft(4, '0')}";
        }
        public static string Generate13DigitIds()
        {
            // 2. 年月日(6位,yMMdd格式,如231215)
            string datePart = DateTime.Now.ToString("yyMMdd");
            // 3. 6位高强度随机数(避免重复)
            Random random = new Random(Guid.NewGuid().GetHashCode());
            string randomPart = random.Next(10000, 99999).ToString();
            // 4. 组合成13位ID
            return datePart + randomPart;
        }
        public static string Generate13DigitId()
        {
            // 1. 业务标识(1位,如H=住建)
@@ -143,17 +156,30 @@
                    task.S_B_STATE = WCSTask.GetStateStr(task.N_B_STATE);
                    task.T_START_TIME = DateTime.Now;
                    db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_START_TIME }).ExecuteCommand();
                    var wmstask = db.Queryable<WMSTask>().Where(s => s.S_CODE == task.S_OP_CODE).First();
                    wmstask.N_B_STATE = 2;
                    wmstask.S_B_STATE = WCSTask.GetStateStr(wmstask.N_B_STATE);
                    wmstask.T_START_TIME = DateTime.Now;
                    db.Updateable(wmstask).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_START_TIME }).ExecuteCommand();
                }
            }
        }
        internal static void End(WCSTask task) {
            LogHelper.Info($"修改状态 ");
            var db = new SqlHelper<WCSTask>().GetInstance();
            if (task != null) {
                task.N_B_STATE = 3;
                task.S_B_STATE = WCSTask.GetStateStr(task.N_B_STATE);
                task.T_END_TIME = DateTime.Now;
                db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_END_TIME }).ExecuteCommand();
                LogHelper.Info($"修改状态为3 ");
                var wmstask = db.Queryable<WMSTask>().Where(s => s.S_CODE == task.S_OP_CODE).First();
                wmstask.N_B_STATE = 3;
                wmstask.S_B_STATE = WCSTask.GetStateStr(wmstask.N_B_STATE);
                wmstask.T_END_TIME = DateTime.Now;
                db.Updateable(wmstask).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_END_TIME }).ExecuteCommand();
            }
        }
        internal static void Fail(WCSTask task) {
@@ -162,7 +188,15 @@
                //判断有没有取货完成,没有就变成失败。有取货完成默认完成了(跟据项目而定,有些项目人工拉走了也没有放到终点)。
                task.N_B_STATE = 5;
                task.S_B_STATE = WCSTask.GetStateStr(task.N_B_STATE);
                db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE }).ExecuteCommand();
                task.T_END_TIME = DateTime.Now;
                db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_END_TIME }).ExecuteCommand();
                var wmstask = db.Queryable<WMSTask>().Where(s => s.S_CODE == task.S_OP_CODE).First();
                wmstask.N_B_STATE = 5;
                wmstask.S_B_STATE = WCSTask.GetStateStr(wmstask.N_B_STATE);
                wmstask.T_END_TIME = DateTime.Now;
                db.Updateable(wmstask).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_END_TIME }).ExecuteCommand();
            }
        }
        internal static bool CreateTask(WCSTask TN_Task) {
@@ -194,7 +228,7 @@
        }
        internal static List<WCSTask> GetWaitingTaskList() {
            var db = new SqlHelper<object>().GetInstance();
            return db.Queryable<WCSTask>().Where(a => a.N_B_STATE == 0).ToList();
            return db.Queryable<WCSTask>().Where(a => a.N_B_STATE == 0).OrderByDescending(s=>s.N_PRIORITY).ToList();
        }
        //前移车执行中任务 
        internal static List<WCSTask> GetWaitingTaskGoList()