wanshenmean
2026-03-31 9b77acb859f0866f3a854d2a2842072b2fe9cca8
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
using WIDESEA_Common.LocationEnum;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_IRecordService;
using WIDESEA_Model.Models;
 
namespace WIDESEA_RecordService
{
    /// <summary>
    /// 货位状态变更记录服务实现类
    /// </summary>
    public partial class LocationStatusChangeRecordService : ServiceBase<Dt_LocationStatusChangeRecord, IRepository<Dt_LocationStatusChangeRecord>>, ILocationStatusChangeRecordService
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public LocationStatusChangeRecordService(IRepository<Dt_LocationStatusChangeRecord> baseDal) : base(baseDal)
        {
        }
 
        /// <summary>
        /// 获取货位状态变更记录仓储接口
        /// </summary>
        public IRepository<Dt_LocationStatusChangeRecord> Repository => BaseDal;
 
        /// <summary>
        /// 记录货位状态变更。
        /// </summary>
        public async Task<bool> AddChangeRecordAsync(
            Dt_LocationInfo beforeLocation,
            Dt_LocationInfo afterLocation,
            LocationChangeType changeType,
            int? taskNum = null,
            string? orderNo = null,
            int? orderId = null,
            string? remark = null)
        {
            if (beforeLocation == null || afterLocation == null)
                return false;
 
            if (beforeLocation.LocationStatus == afterLocation.LocationStatus)
                return true;
 
            Dt_LocationStatusChangeRecord record = new Dt_LocationStatusChangeRecord
            {
                LocationId = afterLocation.Id,
                LocationCode = afterLocation.LocationCode,
                BeforeStatus = beforeLocation.LocationStatus,
                AfterStatus = afterLocation.LocationStatus,
                ChangeType = (int)changeType,
                OrderId = orderId,
                OrderNo = orderNo,
                TaskNum = taskNum,
                Remark = remark
            };
 
            return await BaseDal.AddDataAsync(record) > 0;
        }
    }
}