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
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="PalletCode"></param>
        /// <returns></returns>
        public WebResponseContent ManualInterface(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>();
                List<Dt_LocationInfo> locations = new List<Dt_LocationInfo>();
                List<Dt_Task> taskdt = new List<Dt_Task>();
                List<Dt_StockInfoDetail> dtstocktdetail = new List<Dt_StockInfoDetail>();
                for (int i = 0; i < saveModel.DelKeys.Count; i++)
                {
                    int stockid = int.Parse(saveModel.DelKeys[i].ToString());
                    Dt_StockInfo stockt = _stockInfoService.Repository.QueryFirst(x => x.Id == stockid);
 
                    if (stockt.StockStatus != (int)StockStatusEmun.已入库) return content.Error($"出库失败,原因:当前库存状态不在库,不可进行出库");
 
                    //Dt_StockInfoDetail stocktdetail = _stockDetailService.Repository.QueryFirst(x => x.StockId == stockt.Id);
                    stockt.StockStatus = (int)StockStatusEmun.出库锁定;
 
 
 
                    Dt_LocationInfo locationinfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockt.LocationCode);
                    if (locationinfo == null) return content.Error($"未找到托盘条码:{stockt.PalletCode},的货位编号,库存货位编号:{stockt.LocationCode}");
 
                    locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
 
                    Dt_Task dt_Task = new()
                    {
                        PalletCode = stockt.PalletCode,
                        TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                        Roadway = locationinfo.RoadwayNo,
                        TaskType = TaskTypeEnum.Outbound.ObjToInt(),
                        TaskStatus = TaskOutStatusEnum.OutNew.ObjToInt(),
                        SourceAddress = locationinfo.LocationCode,
                        TargetAddress = "1001",
                        CurrentAddress = locationinfo.LocationCode,
                        NextAddress = "1001",
                        Grade = 1,
                        Creater = "WMS",
                        Depth = locationinfo.Depth,
                        CreateDate = DateTime.Now,
                        WarehouseId = locationinfo.WarehouseId,
                    };
                    dtstockt.Add(stockt);
                    locations.Add(locationinfo);
                    taskdt.Add(dt_Task);
 
                }
 
 
                WebResponseContent responses = HttpHelper.Post<WebResponseContent>(ReceiveWCSTask, taskdt, "下发任务入库");
                if (responses.Status)
                {
                    _unitOfWorkManage.BeginTran();
                    if (dtstockt.Count > 0)
                    {
                        _stockInfoService.Repository.UpdateData(dtstockt);
                        _locationInfoService.Repository.UpdateData(locations);
                        BaseDal.AddData(taskdt);
                    }
                    _unitOfWorkManage.CommitTran();
                    content.OK("下发成功!!!");
                    return content;
                }
                else
                {
                    return content.Error($"下发失败,原因:{responses.Message}");
                }
                
                
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content.Error($"出库失败,报错信息:{ex.Message}");
            }
        }
 
    }
}