海波 张
2025-05-15 65ddd36c0036014ff656417767b4a9438efb76b1
wms/TaskHelper.cs
@@ -49,6 +49,14 @@
            return task;
        }
        //查找WCS立库任务 参数作业编码,调度类型 agv/wcs
        internal static WMSTask GetTaskByWorkNo(string no,string type)
        {
            var db = new SqlHelper<WMSTask>().GetInstance();
            var task = db.Queryable<WMSTask>().Where(a => a.S_OP_CODE == no && a.S_SCHEDULE_TYPE== type).First();
            return task;
        }
        internal static WMSTask GetTaskByCntrCode(string cntrCode)
        {
@@ -235,13 +243,15 @@
        {
            var tasks = new List<Task>();
            // 任务1
            var task1 = new WMSTask()
            {
                // 作业编码
                S_OP_CODE = operation.S_CODE,
                // 任务号
                S_CODE = GenerateTaskNo(),
                S_CODE = operation.S_CODE + "_1",
                // 任务类型
                N_TYPE = operation.N_TYPE,
                // 任务类型
@@ -250,6 +260,10 @@
                S_START_LOC = operation.S_START_LOC,
                // 起点库区
                S_START_AREA = operation.S_START_AREA,
                //起点库区名称
                S_START_AREA_NAME = operation.S_START_AREA_NAME,
                //终点库区名称
                S_END_AREA_NAME = operation.S_END_AREA_NAME,
                // 终点货位
                S_END_LOC = operation.S_END_LOC,
                // 终点库区
@@ -266,6 +280,10 @@
                N_PRIORITY = operation.N_PRIORITY,
                //工装类型
                TOOLSTYPE = operation.TOOLSTYPE,
            };
            try
@@ -335,6 +353,10 @@
                N_PRIORITY = operation.N_PRIORITY,
                //工装类型
                TOOLSTYPE = operation.TOOLSTYPE,
                //起点库区名称
                S_START_AREA_NAME = operation.S_START_AREA_NAME,
                //终点库区名称
                S_END_AREA_NAME = operation.CONNECTION_AREA,
            };
@@ -369,6 +391,10 @@
                N_PRIORITY = operation.N_PRIORITY,
                //工装类型
                TOOLSTYPE = operation.TOOLSTYPE,
                //起点库区名称
                S_START_AREA_NAME = operation.CONNECTION_AREA,
                //终点库区名称
                S_END_AREA_NAME = operation.S_END_AREA_NAME,
            };
            try
@@ -411,7 +437,7 @@
                // 作业编码
                S_OP_CODE = operation.S_CODE,
                // 任务号
                S_CODE = operation.S_CODE + "_2",
                S_CODE = operation.S_CODE + "_1",
                // 任务类型
                N_TYPE = operation.N_TYPE,
                // 任务类型
@@ -436,6 +462,10 @@
                N_PRIORITY = operation.N_PRIORITY,
                //工装类型
                TOOLSTYPE = operation.TOOLSTYPE,
                //起点库区名称
                S_START_AREA_NAME = operation.S_START_AREA_NAME,
                //终点库区名称
                S_END_AREA_NAME = operation.CONNECTION_AREA,
            };
            // 任务2
@@ -444,7 +474,7 @@
                // 作业编码
                S_OP_CODE = operation.S_CODE,
                // 任务号
                S_CODE = operation.S_CODE + "_1",
                S_CODE = operation.S_CODE + "_2",
                // 任务类型
                N_TYPE = operation.N_TYPE,
                // 任务类型
@@ -469,6 +499,10 @@
                N_PRIORITY = operation.N_PRIORITY,
                //工装类型
                TOOLSTYPE = operation.TOOLSTYPE,
                //起点库区名称
                S_START_AREA_NAME = operation.CONNECTION_AREA,
                //终点库区名称
                S_END_AREA_NAME = operation.S_END_AREA_NAME,
            };
            try
@@ -534,7 +568,26 @@
            return ac;
        }
        /// <summary>
        /// 任务拦截
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        internal static bool Intercept()
        {
                var db = new SqlHelper<object>().GetInstance();
                var model = db.Queryable<ManualTaskSwitch>().First();
                if (model != null && model.State == "Y")
                {
                    return false;
                }
                else
                {
                    return true;
                }
        }
        internal static bool WcsAddActionRecord(string no, string state, string forkliftNo, string extData = "0")
@@ -558,18 +611,18 @@
            var db = new SqlHelper<WmsTaskAction>().GetInstance();
            return db.Queryable<WmsTaskAction>().Count(a => a.S_TASK_CODE.Trim() == no.Trim() && a.S_ACTION == code) > 0;
        }
        internal static void Begin(WMSTask task,string avgNo) {
            var db = new SqlHelper<WMSTask>().GetInstance();
            if (task != null) {
                if (task.S_B_STATE.Trim() == "已推送") {
                    task.S_B_STATE = "执行中";
                    task.T_START_TIME = DateTime.Now;
                    task.S_EQ_NO = avgNo;
                    db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE, it.T_START_TIME,it.S_EQ_NO }).ExecuteCommand();
                }
        //internal static void Begin(WMSTask task,string avgNo) {
        //    var db = new SqlHelper<WMSTask>().GetInstance();
        //    if (task != null) {
        //        if (task.S_B_STATE.Trim() == "已推送") {
        //            task.S_B_STATE = "执行中";
        //            task.T_START_TIME = DateTime.Now;
        //            task.S_EQ_NO = avgNo;
        //            db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE, it.T_START_TIME,it.S_EQ_NO }).ExecuteCommand();
        //        }
            }
        }
        //    }
        //}
        internal static WcsRfidCheckoutEntitys GetRfid(string TaskCode) {
@@ -581,7 +634,7 @@
        internal static void Begin(WMSTask task)
        internal static void Begin(WMSTask task, string avgNo="")
        {
            var db = new SqlHelper<WMSTask>().GetInstance();
            if (task != null)
@@ -590,8 +643,9 @@
                {
                    task.N_B_STATE = 2;
                    task.S_B_STATE = WMSTask.GetStateStr(task.N_B_STATE);
                    task.S_EQ_NO = avgNo;
                    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();
                    db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_START_TIME,it.S_EQ_NO }).ExecuteCommand();
                }
            }
        }
@@ -680,7 +734,8 @@
            {
                task.N_B_STATE = 5;
                task.S_B_STATE = WMSTask.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();
            }
        }