服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2025-02-28 3258283603cca12b2373529f1333dfe97dca7c61
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
using Rhea.Common;
using Microsoft.AspNetCore.Http;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.Model;
using Apache.NMS;
using System.Drawing.Drawing2D;
using Tiger.Model.Sharetronic.Shelf;
using Tiger.IBusiness;
using Tiger.Model.MES.Yada;
using Apache.NMS.ActiveMQ.Commands;
using System.Diagnostics;
using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser;
using Tiger.Model.Entitys.MES.U9C;
 
namespace Tiger.Business.WMS.Transaction
{
    /// <summary>
    /// 半成品打印标签事务
    /// </summary>
    public class PrintSemiProdLabel : WMSTransactionBase, IPrintSemiProdLabel
    {
        private readonly IMES_U9C _IMES_U9C = DI.Resolve<IMES_U9C>();
        public IPrintSemiProdLabel Init(string id, string userCode, string apiHost, string orgCode)
        {
            TransID = id;
            UserCode = userCode;
            ApiHost = apiHost;
            OrgCode = orgCode;
            Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]");
            return this;
        }
 
        #region Propertys & Variables
        public string UserCode { get; set; }
        public long UserId { get; set; }
        public string OrgCode { get; set; }
        public List<V_WMS_ITEM> Vitem { get; set; } = new();
 
        #endregion
 
        #region Functions
        /// <summary>
        /// 扫描入口
        /// </summary>
        public async Task<ApiAction<ScanOutput>> Scan(BaseInput input)
        {
            var action = new ApiAction<ScanOutput>(new ScanOutput());
            try
            {
                if (input.SN.IsNullOrEmpty())
                {
                    action.IsSuccessed = false;
                    action.LocaleMsg = Biz.L("WMS.PrintSemiProdLabel.ScanItem.SnEmptyFailure");
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                var DocLines = Biz.DataSource["YadaU9C"].Client.Ado.SqlQuery<mes_RcvRptDocLine>($"select * from mes_RcvRptDocLine where DocNo = '{input.SN}'");
 
                var temps = new List<SemiTemplateInput>();
                foreach (var item in DocLines)
                {
                    var temp = new SemiTemplateInput
                    {
                        RcvRptDocId = item.ID.ToString(),
                        ItemCode= item.ItemCode,
                        ItemDesc= item.ItemDescription,
                        SapItemCode= "",
                        PackQty= item.PackQty.ToDecimal(),
                        Qty=0,
                        DocNo= item.DocNo,
                        WorkOrder= item.Mo
                    };
                    temps.Add(temp);
                }
 
                action.Data.Data = temps;
                action.LocaleMsg = Biz.L("WMS.PrintSemiProdLabel.Scan.ScanSuccessed", input.SN);
            }
            catch (Exception ex)
            {
                //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.PrintSemiProdLabel.Scan.ScanException", input.SN));
            }
            return SetOutPutMqttMsg(action, input.Locale);
        }
 
        /// <summary>
        /// 扫码提交
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ApiAction<ScanOutput>> ScanItem(BaseInput input)
        {
            var action = new ApiAction<ScanOutput>(new ScanOutput());
            try
            {
                if (input.SN.IsNullOrEmpty())
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("条码不能为空");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure");
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                var semiTemplate = (input.Data ?? "").JsonToObject<SemiTemplateInput>() ?? new SemiTemplateInput();
 
                //生成条码
                BarcodeCreateByAssignQtyInput barcodeCreateInput = new()
                {
                    RevDocId = semiTemplate.RcvRptDocId,
                    userId = input.AuthOption.UserId,
                    token = "",
                    IsLogin = true,
                    CreateBarCodeItemQty = semiTemplate.PackQty,
                    LabelQty = semiTemplate.Qty,
                };
               
                var snList = await _IMES_U9C.U9CCreateBarCodeByAssignQty(barcodeCreateInput);
                action.Data.Data = snList;
            }
            catch (Exception ex)
            {
                //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]提交异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.PrintSemiProdLabel.ScanItem.ScanItemException", input.SN));
 
            }
            return SetOutPutMqttMsg(action, input.Locale);
        }
 
        #endregion
 
        public override bool Close(bool needSaveHistoryLog = false)
        {
            needSaveHistoryLog = true;
            //保存操作日志
 
            this.IsFinished = true;
            return IsFinished ? base.Close(needSaveHistoryLog) : IsFinished;
        }
 
    }//endClass
}