分支自 SuZhouGuanHong/TaiYuanTaiZhong

PCS
dengjunjie
2023-12-13 113d1d4262d8f9e78a9d92123713c41669ad6c87
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
using FreeSql;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.FreeDB;
 
namespace WIDESEA_Comm.TaskNo
{
    public class IdenxManager
    {
        static FreeDB freeDB = new FreeDB();
        private static object lock_obj = new object();
 
        /// <summary>
        /// 获取任务编号
        /// </summary>
        /// <param name="first">标记头地址</param>
        /// <param name="numType">编号类型</param>
        /// <returns></returns>
        public static string GetTaskNo(string first = "", string numType = "stacker")
        {
            lock (lock_obj)
            {
                var taskno = freeDB.DataBase.Ado.QuerySingle<int>("select taskno from dt_task_num where numtype=@numtype", new { numType });
 
                //堆垛机任务号处理
                if (numType == "stacker")
                {
                    //限制最小和最大值
                    if (taskno < 1000 || taskno >= 10000)
                    {
                        taskno = 1000;
                    }
                    else
                    {
                        taskno++;
                    }
                }
 
                freeDB.DataBase.Ado.ExecuteNonQuery("update dt_task_num set taskno=@taskno where numtype=@numtype", new { numType, taskno });
                return first + taskno;
            }
        }
    }
}