服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-09-09 5ab5e848589059becbcddc8295dd17251477c1fd
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
using Tiger.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Rhea.Common;
using System.Net;
using System.Linq;
using Newtonsoft.Json;
using Tiger.IBusiness;
using Microsoft.AspNetCore.Http;
using Tiger.Model.Entitys.MES.BizMesWoBatch;
using Tiger.Model.Entitys.MES.BizMesWo;
using Tiger.Model.Entitys.MES.DoUnPack;
using Tiger.Model.Entitys.MES.Position;
 
namespace Tiger.Business.MES
{
    public partial class DoUnPack : IDoUnPack
    {
        /// <summary>
        /// 拆解包装
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
       public async Task<ApiAction<List<MES_WIP_PKG>>> Submit(DoUnPackInput input)
        {
            var result = new ApiAction<List<MES_WIP_PKG>>();
            try
            {
                var wipPkg = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == input.SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync();
                var wipPkgParent = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == wipPkg.PARENT_SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync();
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.PARENT_SN == null).Where(q => q.ID == wipPkg.ID).ExecuteCommand();
                    db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.QTY == q.QTY - 1).Where(q => q.ID == wipPkgParent.ID).ExecuteCommand();
                    if (!Biz.Db.Queryable<WMS_ITEM_PKG>().Any(q => q.PARENT_SN == wipPkg.PARENT_SN && q.SN != wipPkg.SN))
                    {
                        db.Deleteable(wipPkgParent);
                    }
                });
                if (!dbTran.IsSuccess)
                {
                    result.IsSuccessed = false;
                    result.Message = $"拆解包装异常";
                }
                result.Data = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.PARENT_SN == wipPkgParent.SN).ToList();
            }
            catch (Exception ex)
            {
                result.CatchExceptionWithLog(ex, "拆解包装异常");
            }
            return result;
        }
    }
}