wangxinhui
2025-11-12 f54b7815d8451f362554e3d2d09b4991ce13d4ff
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_IRecordRepository;
using WIDESEA_IRecordService;
using WIDESEA_Model.Models;
 
namespace WIDESEA_RecordService
{
    public partial class StockQuantityChangeRecordService : ServiceBase<Dt_StockQuantityChangeRecord, IStockQuantityChangeRecordRepository>, IStockQuantityChangeRecordService
    {
        /// <summary>
        /// 卷料变动库存记录
        /// </summary>
        /// <param name="stockInfo">库存</param>
        /// <param name="beforeQuantity">变动前库存</param>
        /// <param name="changeQuantity">变动库存</param>
        /// <param name="changeType">变动类型</param>
        /// <param name="taskNum">任务号</param>
        /// <param name="orderNo">单据编号</param>
        /// <exception cref="Exception"></exception>
        public void AddStockChangeRecord(Dt_StockInfo stockInfo, decimal beforeQuantity, decimal changeQuantity, StockChangeTypeEnum changeType, int? taskNum = 0,string orderNo="")
        {
            try
            {
                Dt_StockQuantityChangeRecord stockQuantityChangeRecord = new Dt_StockQuantityChangeRecord()
                {
                    StockId = stockInfo.Id,
                    PalleCode = stockInfo.PalletCode,
                    MaterielCode=stockInfo.MaterielCode,
                    MaterielName=stockInfo.MaterielName,
                    BatchNo = "",
                    SerilNumber=$"{stockInfo.Id}",
                    OrderNo = orderNo,
                    TaskNum= taskNum,
                    ChangeType=changeType.ObjToInt(),
                    ChangeQuantity=changeQuantity,
                    BeforeQuantity=beforeQuantity,
                    AfterQuantity=beforeQuantity+changeQuantity,
                    Creater="System"
                };
                BaseDal.AddData(stockQuantityChangeRecord);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 成品辅料库存记录
        /// </summary>
        /// <param name="proStockInfo">库存</param>
        /// <param name="beforeQuantity">变动前库存</param>
        /// <param name="changeQuantity">变动库存</param>
        /// <param name="changeType">变动类型</param>
        /// <param name="taskNum">任务号</param>
        /// <param name="orderNo"></param>
        /// <exception cref="Exception"></exception>
        public void AddStockChangeRecord(Dt_ProStockInfo proStockInfo, decimal beforeQuantity, decimal changeQuantity, StockChangeTypeEnum changeType, int? taskNum = null, string orderNo = "")
        {
            try
            {
                Dt_StockQuantityChangeRecord stockQuantityChangeRecord = new Dt_StockQuantityChangeRecord()
                {
                    StockId = proStockInfo.Id,
                    PalleCode = proStockInfo.PalletCode,
                    MaterielCode = proStockInfo.proStockInfoDetails?.FirstOrDefault()?.ProductCode ?? "",
                    MaterielName = proStockInfo.proStockInfoDetails?.FirstOrDefault()?.ProductName ?? "",
                    BatchNo = "",
                    SerilNumber = $"{proStockInfo.Id}",
                    OrderNo = orderNo,
                    TaskNum = taskNum,
                    ChangeType = changeType.ObjToInt(),
                    ChangeQuantity = changeQuantity,
                    BeforeQuantity = beforeQuantity,
                    AfterQuantity = beforeQuantity + changeQuantity,
                    Creater = "System"
                };
                BaseDal.AddData(stockQuantityChangeRecord);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}