dengjunjie
2024-11-27 5be0f5bc3b9a83a3b30c9915bd5309279d140244
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.Enums;
using WIDESEA_Core;
using WIDESEA_DTO.WCSInfo;
using WIDESEA_Model.Models;
using WIDESEAWCS_DTO.WCSInfo;
using WIDESEA_Core.Helper;
 
namespace WIDESEA_TaskInfoService
{
    public partial class TaskService
    {
 
        /// <summary>
        /// 产线申请
        /// </summary>
        /// <param name="productionlineDTO"></param>
        /// <returns></returns>
        public WebResponseContent ProductionlineRequest(ProductionlineDTO productionlineDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                (bool, string) result = CheckRequestInbound(productionlineDTO.Station, productionlineDTO.TrayBarcode, false);
                if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
                var task = BaseDal.QueryFirst(x => x.PalletCode == productionlineDTO.TrayBarcode);
                if (task != null && task.TaskType == TaskTypeEnum.Inbound.ObjToInt())
                    return content.OK(data: task);
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// 产线申请
        /// </summary>
        /// <param name="lineDTO"></param>
        /// <returns></returns>
        public WebResponseContent ProductionlineRequest(ConveyorLineDTO lineDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode);
                if (task != null && task.TaskType == TaskTypeEnum.Inbound.ObjToInt())
                    return content.OK(data: task);
                if (task != null) throw new Exception($"托盘号[{lineDTO.Barcode}]已存在任务");
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(lineDTO.Barcode);
                (bool, string) result = CheckRequestInbound(lineDTO.stationCode, lineDTO.Barcode, true, stockInfo);
                if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
                var StockInfoDetails = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).ToList();
                #region 生成入库任务
                Dt_Task dt_Task = new Dt_Task()
                {
                    CurrentAddress = lineDTO.stationCode,
                    NextAddress = "SC01",
                    SourceAddress = lineDTO.stationCode,
                    TargetAddress = "SC01",
                    CreateDate = DateTime.Now,
                    Creater = "System",
                    PalletCode = lineDTO.Barcode,
                    OrderNo = StockInfoDetails.Count() == 1 ? StockInfoDetails.First().OrderNo : null,
                    Roadway = "SC01",
                    TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
                    TaskState = InTaskStatusEnum.InNew.ObjToInt(),
                    TaskType = TaskTypeEnum.Inbound.ObjToInt(),
                };
                dt_Task.Dispatchertime = dt_Task.CreateDate;
                Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt());
                //content.Data = dt_Task;
                Db.Ado.CommitTran();
                if (task != null) return content.OK(data: task);
                #endregion
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
    }
}