服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-05-31 d4c326deaa51e7d4897a84afc339684012b8cfbe
Tiger.Business.WMS/WMS_ITEM_Biz.cs
ÎļþÃû´Ó Tiger.Business/WMS/Biz.WMS_ITEM.cs ÐÞ¸Ä
@@ -1,5 +1,4 @@
using Microsoft.CodeAnalysis;
using Org.BouncyCastle.Ocsp;
using Rhea.Common;
using SqlSugar;
using System;
@@ -7,13 +6,12 @@
using System.DirectoryServices.ActiveDirectory;
using System.Linq;
using System.Threading.Tasks;
using Tiger.Business.WMS;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    public partial class Biz
    public class WMS_ITEM_Biz
    {
        private static _Biz_WmsItem _WmsItem = new();
@@ -101,7 +99,7 @@
                                    var unPackQty = result.Data.Items.Sum(q => q.QTY);
                                    db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.PARENT_SN == null).Where(q => q.ID == query.ID).ExecuteCommand();
                                    db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.QTY == q.QTY - unPackQty).Where(q => q.ID == query.Parent.ID).ExecuteCommand();
                                    if (!db.Queryable<WMS_ITEM_PKG>().Any(q => q.PARENT_SN == query.PARENT_SN && q.SN != query.SN))
                                    if (!Biz.Db.Queryable<WMS_ITEM_PKG>().Any(q => q.PARENT_SN == query.PARENT_SN && q.SN != query.SN))
                                    {
                                        db.Deleteable(query.Parent);
                                    }
@@ -127,7 +125,7 @@
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, L("WMS.WmsItem.Barcode.GetException", sn));
                    result.CatchExceptionWithLog(ex, Biz.L("WMS.WmsItem.Barcode.GetException", sn));
                }
                return result;
            }
@@ -209,7 +207,7 @@
                                    var unPackQty = result.Data.Items.Sum(q => q.QTY);
                                    db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.PARENT_SN == null).Where(q => q.ID == query.ID).ExecuteCommand();
                                    db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.QTY == q.QTY - unPackQty).Where(q => q.ID == query.Parent.ID).ExecuteCommand();
                                    if (!db.Queryable<WMS_ITEM_PKG>().Any(q => q.PARENT_SN == query.PARENT_SN && q.SN != query.SN))
                                    if (!Biz.Db.Queryable<WMS_ITEM_PKG>().Any(q => q.PARENT_SN == query.PARENT_SN && q.SN != query.SN))
                                    {
                                        db.Deleteable(query.Parent);
                                    }
@@ -235,7 +233,7 @@
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, L("WMS.WmsItem.Barcode.GetException", sn));
                    result.CatchExceptionWithLog(ex, Biz.L("WMS.WmsItem.Barcode.GetException", sn));
                }
                return result;
            }
@@ -299,7 +297,7 @@
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, L("WMS.WmsItem.PutOn.Exception", inventory.SN, targetLocation));
                    result.CatchExceptionWithLog(ex, Biz.L("WMS.WmsItem.PutOn.Exception", inventory.SN, targetLocation));
                }
                return result;
            }
@@ -344,7 +342,7 @@
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, L("WMS.WmsItem.TakeDown.Exception", inventory.SN, inventory?.Location?.LOCATION_CODE));
                    result.CatchExceptionWithLog(ex, Biz.L("WMS.WmsItem.TakeDown.Exception", inventory.SN, inventory?.Location?.LOCATION_CODE));
                }
                return result;
            }
@@ -431,7 +429,7 @@
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, L("WMS.WmsItem.Suggest.Exception"));
                    result.CatchExceptionWithLog(ex, Biz.L("WMS.WmsItem.Suggest.Exception"));
                }
                return result;
            }
@@ -581,7 +579,7 @@
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, L("WMS.WmsItem.Suggest.Exception"));
                    result.CatchExceptionWithLog(ex, Biz.L("WMS.WmsItem.Suggest.Exception"));
                }
                return result;
            }
@@ -593,7 +591,7 @@
            /// <returns></returns>
            public string GetQRCode(string sn)
            {
                return Db.Queryable<WMS_ITEM>().Where(q => q.SN == sn).First()?.GetQRCode();
                return Biz.Db.Queryable<WMS_ITEM>().Where(q => q.SN == sn).First()?.GetQRCode();
            }
            /// <summary>
@@ -606,7 +604,7 @@
                var action = new ApiAction<PageAble<V_WMS_ITEM>>();
                if (input.Code != "")
                {
                    var query = Db.Queryable<V_WMS_ITEM>().ByAuth(input.AuthOption).Where(q => q.LOCATION_CODE == input.Code).ToPage(input.pageIndex, input.pageSize);
                    var query = Biz.Db.Queryable<V_WMS_ITEM>().ByAuth(input.AuthOption).Where(q => q.LOCATION_CODE == input.Code).ToPage(input.pageIndex, input.pageSize);
                    if (query.data.Count > 0)
                    {
                        action.Data = query;
@@ -631,14 +629,14 @@
            /// <returns></returns>
            public PageAble<V_WMS_ITEM> QueryItemSum(QueryItemInputDtl input)
            {
                var ItemCode = Db.Queryable<WMS_ITEM_PKG>().ByAuth(input.AuthOption).Where(q => q.SN == input.Code).First()?.ITEM_CODE ??
                var ItemCode = Biz.Db.Queryable<WMS_ITEM_PKG>().ByAuth(input.AuthOption).Where(q => q.SN == input.Code).First()?.ITEM_CODE ??
                                         (input.IsK.IsNullOrEmpty() ? input.Code : (((bool)input.IsK ? "K" : "") + new Barcode(input.Code).ItemCode));
                var itemInfo = Db.Queryable<BAS_ITEM>().Where(q => q.ITEM_CODE == ItemCode).First();
                var itemInfo = Biz.Db.Queryable<BAS_ITEM>().Where(q => q.ITEM_CODE == ItemCode).First();
                if (!itemInfo.IsNullOrEmpty())
                {
                    var sumInfo = Db.Queryable<V_WMS_ITEM>().Where(q => q.ITEM_CODE == ItemCode && q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue())
                    var sumInfo = Biz.Db.Queryable<V_WMS_ITEM>().Where(q => q.ITEM_CODE == ItemCode && q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue())
                                      .ByAuth(input.AuthOption).GroupBy(q => new { q.WH_CODE, q.ITEM_CODE }).Select(q => new { WH_CODE = q.WH_CODE, SumQty = SqlFunc.AggregateSum(q.QTY) }).ToList();
                    var items = Db.Queryable<V_WMS_ITEM>().Where(q => q.ITEM_CODE == ItemCode && q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue())
                    var items = Biz.Db.Queryable<V_WMS_ITEM>().Where(q => q.ITEM_CODE == ItemCode && q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue())
                                      .ByAuth(input.AuthOption).ToPage(input.pageIndex, input.pageSize);
                    items.data2 = new { ItemCode = ItemCode, ItemName = itemInfo.ITEM_NAME, SumInfo = $"{string.Join("\r\n", sumInfo.Select(q => $"{q.WH_CODE}总库存: {(double)q.SumQty}"))}" };
                    return items;
@@ -725,7 +723,7 @@
        public static List<string> GetOrgList()
        {
            var DB = Biz.DataSource["WMS57"].Client;
            var dataList = DB.Queryable<SYS_ORGANIZATION>().Select(i => i.ORG_CODE).Distinct().ToList();// èŽ·å–ç»„ç»‡ç¼–ç 
            var dataList = Biz.Db.Queryable<SYS_ORGANIZATION>().Select(i => i.ORG_CODE).Distinct().ToList();// èŽ·å–ç»„ç»‡ç¼–ç 
            return dataList;
        }