服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-03-23 5ec2816b25ccc33855c48da7f7f9305e21e6dc38
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
using Apache.NMS;
using Newtonsoft.Json;
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
using System.Xml.Linq;
using System.Collections;
 
namespace Tiger.Business
{
 
    public partial class Biz : ControllerBase
    {
        public partial class BS
        {
            /// <summary>
            /// 完工入库,物料转卖
            /// </summary>
            /// <returns></returns>
            public ApiAction MaterialResale(string billcode, string whcode, string org_code)
            {
                try
                {
                    var action = new ApiAction();
                    var wh_id = GetWmsCode(whcode);//库位id
                    var items = Biz.Db.Queryable<WMS_ITEM>().Where(q => q.TRANS_NO == billcode).ToList();
                    var items_pkg = Biz.Db.Queryable<WMS_ITEM_PKG>().Where(q => q.TRANS_NO == billcode).ToList();
                    var ProdIn = Biz.Db.Queryable<BIZ_ERP_PROD_IN>().Where(q => q.BILLCODE == billcode).First();
                    if (items.Count() == 0)
                    {
                        action.Message = "库存表查无数据";
                        action.IsSuccessed = false;
                        return action;
                    }
                    if (items_pkg.Count() == 0)
                    {
                        action.Message = "包装表查无数据";
                        action.IsSuccessed = false;
                        return action;
                    }
                    if (ProdIn.IsNullOrEmpty())
                    {
                        action.Message = "查无此单据";
                        action.IsSuccessed = false;
                        return action;
                    }
                    foreach (var item in items)
                    {
                        item.AUTH_ORG = org_code;
                        item.WH_ID = wh_id.Result;
                        item.ERP_WH = whcode;
                    }
                    foreach (var item in items_pkg)
                    {
                        item.AUTH_ORG = org_code;
                        item.WH_ID = wh_id.Result;
                        item.ERP_WH = whcode;
                    }
                    ProdIn.STATUS = BIZ_ERP_PROD_IN.STATUSs.COMPLETE.GetValue();
 
                    var db = Business.Biz.Db;
                    //入库
 
                    var dbTran = db.UseTran(() =>
                    {
                        db.Updateable(items).ExecuteCommand();
                        db.Updateable(items_pkg).ExecuteCommand();
                        db.Updateable(ProdIn).ExecuteCommand();
                    });
                    if (!dbTran.IsSuccess)
                    {
                        action.Message = "转卖失败";
                    }
                    else
                    {
                        action.Message = "转卖成功";
                    }
                    
                    return action;
                }
                catch (Exception ex)
                {
 
                    throw;
                }
            }
        }
    }
}