Admin
3 天以前 6184f79fcb92452dee17f5441aff77911336aa95
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using MailKit.Search;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OtherEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Task;
using WIDESEA_Model.Models;
using static WIDESEA_ITaskInfoService.ITaskService;
 
namespace WIDESEA_TaskInfoService
{
    public partial class TaskService
    {
 
        //任务完成接口
        /// <summary>
        /// 任务完成
        /// </summary>
        /// <param name="taskNum">任务号</param>
        /// <returns>返回处理结果</returns>
        public WebResponseContent TaskCompleted(int taskNum)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task == null)
                {
                    return WebResponseContent.Instance.Error("未找到任务信息");
                }
 
                MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted");
                if (methodInfo != null)
                {
                    WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task });
                    if (responseContent != null)
                    {
                        return responseContent;
                    }
                }
                return content.Error("未找到任务类型对应业务处理逻辑");
            }
            catch (Exception ex)
            {
                return content.Error("任务完成失败,系统接口原因:" + ex.Message);
            }
        }
 
 
        /// <summary>
        /// 入库完成
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public WebResponseContent InboundTaskCompleted(Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //查库存
                Dt_StockInfo stockInfo = _stockInfoService.GetStockInfo(task.PalletCode);
                //查货位
                Dt_LocationInfo locationInfo = _locationInfoService.GetLocationInfo(task.WarehouseId, task.TargetAddress);
 
                Dt_StockInfoDetail dt_StockInfodetail = _stockDetailService.Repository.QueryData(x => x.Status == (int)StockStatusEmun.组盘暂存).Where(x => x.StockId == stockInfo.Id).FirstOrDefault();
 
 
                stockInfo.LocationCode = task.TargetAddress;
                stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt();
                dt_StockInfodetail.Status = StockStatusEmun.已入库.ObjToInt();
                locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
 
 
                _unitOfWorkManage.BeginTran();
                _stockInfoService.Repository.UpdateData(stockInfo);
                _stockDetailService.Repository.UpdateData(dt_StockInfodetail);
                _locationInfoService.Repository.UpdateData(locationInfo);
                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                _unitOfWorkManage.CommitTran();
                return content.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content.Error("入库任务完成失败,系统接口原因:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 出库完成
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public WebResponseContent OutboundTaskCompleted(Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
 
                task.TaskStatus = TaskOutStatusEnum.OutFinish.ObjToInt();
 
 
                _unitOfWorkManage.BeginTran();
                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                _unitOfWorkManage.CommitTran();
                return content.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content.Error("出库任务完成失败,系统接口原因:" + ex.Message);
            }
        }
 
        //移库完成
        public WebResponseContent RelocationTaskCompleted(Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_StockInfo stockInfo = _stockInfoService.GetStockInfo(task.PalletCode);
 
                Dt_LocationInfo locationpoint = _locationInfoService.GetLocationInfo(task.WarehouseId, task.SourceAddress);
                Dt_LocationInfo locationEnd = _locationInfoService.GetLocationInfo(task.WarehouseId, task.TargetAddress);
                List<Dt_LocationInfo> loca = new List<Dt_LocationInfo>();
 
                stockInfo.LocationCode = locationEnd.LocationCode;
                stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt();
 
                locationpoint.LocationStatus = LocationStatusEnum.Free.ObjToInt();
                locationEnd.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                loca.Add(locationpoint);
                loca.Add(locationEnd);
 
                _unitOfWorkManage.BeginTran();
                _stockInfoService.Repository.UpdateData(stockInfo);
                _locationInfoService.Repository.UpdateData(loca);
 
                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                _unitOfWorkManage.CommitTran();
                return content.OK();
 
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content.Error("移库任务完成失败,系统接口原因:" + ex.Message);
            }
 
        }
 
 
    }
}