1
hutongqing
2024-09-13 ea9bdf217e8202a5fa475262dba1792decb05bcb
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#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)
        {
        }
 
        public int GetTaskNum(string sequenceName)
        {
            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);
        }
    }
}