| #region << 版 本 注 释 >> | 
| /*---------------------------------------------------------------- | 
|  * 命名空间:WIDESEAWCS_TaskInfoRepository | 
|  * 创建者:胡童庆 | 
|  * 创建时间:2024/8/2 16:13:36 | 
|  * 版本:V1.0.0 | 
|  * 描述: | 
|  * | 
|  * ---------------------------------------------------------------- | 
|  * 修改人: | 
|  * 修改时间: | 
|  * 版本:V1.0.1 | 
|  * 修改说明: | 
|  *  | 
|  *----------------------------------------------------------------*/ | 
| #endregion << 版 本 注 释 >> | 
|   | 
| using System; | 
| using System.Collections.Generic; | 
| using System.Linq; | 
| using System.Text; | 
| using System.Threading.Tasks; | 
| using WIDESEA_Core.Attributes; | 
| using WIDESEA_Core.BaseRepository; | 
| using WIDESEA_Core.Helper; | 
| using WIDESEA_ITaskInfoRepository; | 
| using WIDESEA_Model.Models; | 
|   | 
| namespace WIDESEA_TaskInfoRepository | 
| { | 
|     public class TaskRepository : RepositoryBase<Dt_Task>, ITaskRepository | 
|     { | 
|         public TaskRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) | 
|         { | 
|         } | 
|   | 
|         static object lock_taskNum = new object(); | 
|         public int GetTaskNum(string sequenceName) | 
|         { | 
|             lock (lock_taskNum) | 
|             { | 
|                 return Db.Ado.GetScalar($"SELECT NEXT VALUE FOR {sequenceName}").ObjToInt(); | 
|             } | 
|         } | 
|   | 
|         public override int AddData(Dt_Task entity) | 
|         { | 
|             return base.AddData(entity); | 
|         } | 
|   | 
|         public override int AddData(List<Dt_Task> listEntity) | 
|         { | 
|             if (listEntity.GroupBy(x => x.PalletCode).Select(x => x.Count()).Any(x => x > 1)) | 
|             { | 
|                 throw new Exception("任务数组数据托盘号重复"); | 
|             } | 
|   | 
|             if (QueryFirst(x => listEntity.Select(v => v.PalletCode).Contains(x.PalletCode)) != null) | 
|             { | 
|                 throw new Exception("有重复任务"); | 
|             } | 
|   | 
|             return base.AddData(listEntity); | 
|         } | 
|     } | 
| } |