New file |
| | |
| | | using HH.WCS.Mobox3.FJJT.util; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace HH.WCS.Mobox3.FJJT.wms |
| | | { |
| | | internal class SYSHelper |
| | | { |
| | | private static object locker = new object(); |
| | | internal static int GetSerialNumber(string snType, string prefix) { |
| | | int result = 0; |
| | | lock (locker) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var sId = db.Queryable<OI_SYS_MAXID>().Where(a => a.CN_S_TYPE.Trim() == snType && a.CN_S_PRE.Trim() == prefix).First(); |
| | | if (sId != null) { |
| | | sId.CN_N_MAX++; |
| | | if (db.Ado.ExecuteCommand($"update OI_SYS_MAXID set CN_N_MAX={sId.CN_N_MAX} where CN_S_TYPE='{snType}' and CN_S_PRE='{prefix}' ") > 0) { |
| | | result = sId.CN_N_MAX; |
| | | } |
| | | } |
| | | else { |
| | | //插入表 |
| | | sId = new OI_SYS_MAXID { CN_S_TYPE = snType, CN_S_PRE = prefix, CN_N_MAX = 1 }; |
| | | result = db.Insertable<OI_SYS_MAXID>(sId).ExecuteCommand() > 0 ? 1 : 0; |
| | | |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | [SugarTable("OI_SYS_MAXID")] |
| | | public class OI_SYS_MAXID |
| | | { |
| | | public string CN_S_APP_TYPE { get; set; } = "MOBOX"; |
| | | public string CN_S_TYPE { get; set; } |
| | | public string CN_S_PRE { get; set; } |
| | | public int CN_N_MAX { get; set; } |
| | | } |
| | | } |
| | | } |