服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-05-31 d4c326deaa51e7d4897a84afc339684012b8cfbe
把WMS移出Business
已删除16个文件
已修改7个文件
已重命名52个文件
已添加16个文件
11111 ■■■■ 文件已修改
Tiger.Api.sln 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/AGV/Agv.UpdateMReqStatus.cs 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/AGV/Agv.cs 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/BS/BS.ItemCount.cs 195 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/BS/BS.MaterialResale.cs 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/BS/BS.MaterialrReq.cs 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/BS/BS.Transfer.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/BS/BS.WareHouse.cs 371 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/DigitalTwin/Seastone/Rack.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/DigitalTwin/Seastone/RackApi.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/DigitalTwin/Sharetronic/Shelf.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/ERP/ErpT100.Vender.cs 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/ERP/T100.cs 453 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Extensions/JsonExtention.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/KanBan/WareHousing.cs 210 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Minsun/CustSupplyChecking.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Minsun/CustomerSupplyIn.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Minsun/InStorage.cs 274 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Minsun/Shelf.cs 557 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Minsun/iWMS.cs 1854 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/SqlSugarHepler/BizSqlsugar.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/OtherOutInfoBusiness.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/ProductInputBusiness.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/ProductOutputtBusiness.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/ReworkBusiness.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/SaleOutInfoBusiness.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/SplitBoxBusiness.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/StockInfoBusiness.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/T100ToWMS/TrasferInfoBusiness.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Task/DBBackup/Jobs.DbBackupJob.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Task/ERP/Jobs.ProdMaterialReqToErpJob.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Task/ERP/Jobs.ReceiptHToErpJob.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Tiger.Business.WMS.csproj 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/CustomerSupplyInNew.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/InFinished.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/InMatStorage.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/InProductionReturn.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/InReceipt.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/ItemQuery.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/LocationTransfer.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OtherInLocation.cs 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OutNoBillcode.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OutOther.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OutSale.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OutSplit.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OutTransfer.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/OutWorkOrder.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/Resell.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/ShelfRemote.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/WMSTransactionBase.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/WmsCount.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/WMSContext.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/WMS_ITEM_Biz.cs 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iSRM/SrmDataToSiHua.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iSRM/SrmParam.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iSRM/SrmToWms.cs 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iSRM/iSRM.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iWMS/InventroyInfo.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iWMS/ProdMaterialReq.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iWMS/RePrintBarcode.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iWMS/ReceiptInfo.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/iWMS/iWMS.cs 982 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/Automate/AutoContext.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/BizContext.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/DbCache/Biz.CodeRule.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/ERP/Biz.T100.cs 456 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/ERP/Biz.Vender.cs 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/Model/TigerActive.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/Monitors/MonitorsBus.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/Monitors/TransactionMonitor.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/Tiger.Business.csproj 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/AGV/Biz.Agv.UpdateMReqStatus.cs 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/AGV/Biz.Agv.cs 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/BS/Biz.ItemCount.cs 199 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/BS/Biz.MaterialResale.cs 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/BS/Biz.MaterialrReq.cs 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/BS/Biz.Transfer.cs 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/BS/Biz.WareHouse.cs 374 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/DigitalTwin/Seastone/Biz.Rack.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/KanBan/Biz.WareHousing.cs 213 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/Minsun/Biz.InStorage.cs 277 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/Minsun/Biz.Shelf.cs 560 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/Minsun/Biz.iWMS.cs 1856 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/iWMS/Biz.iWMS.cs 984 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Api.sln
@@ -24,9 +24,11 @@
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "05-单元测试", "05-单元测试", "{CF29B377-FE5A-488A-AF99-DF9D9C6FCA95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tiger.Business.MES", "Tiger.Business.MES\Tiger.Business.MES.csproj", "{3848BCAB-4E77-4D5E-8BF0-2A747981C1B4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tiger.Business.MES", "Tiger.Business.MES\Tiger.Business.MES.csproj", "{3848BCAB-4E77-4D5E-8BF0-2A747981C1B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tiger.Business.MengQi", "Tiger.Business.MengQi\Tiger.Business.MengQi.csproj", "{DD5B5282-B673-45CB-8608-3AAEB4A469B9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tiger.Business.MengQi", "Tiger.Business.MengQi\Tiger.Business.MengQi.csproj", "{DD5B5282-B673-45CB-8608-3AAEB4A469B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tiger.Business.WMS", "Tiger.Business.WMS\Tiger.Business.WMS.csproj", "{83F123C4-3E7A-485E-A99C-3FE66CA5867E}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -84,6 +86,14 @@
        {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Release|Any CPU.Build.0 = Release|Any CPU
        {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Release|x86.ActiveCfg = Release|Any CPU
        {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Release|x86.Build.0 = Release|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Debug|x86.ActiveCfg = Debug|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Debug|x86.Build.0 = Debug|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Release|Any CPU.Build.0 = Release|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Release|x86.ActiveCfg = Release|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Release|x86.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
@@ -95,6 +105,7 @@
        {60FA322B-9B03-4380-803C-63B1F240E453} = {70881CAB-17ED-4C46-895A-62F2CE39A607}
        {3848BCAB-4E77-4D5E-8BF0-2A747981C1B4} = {70881CAB-17ED-4C46-895A-62F2CE39A607}
        {DD5B5282-B673-45CB-8608-3AAEB4A469B9} = {70881CAB-17ED-4C46-895A-62F2CE39A607}
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E} = {70881CAB-17ED-4C46-895A-62F2CE39A607}
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {797A1D83-9F3C-4AEC-8A83-E3468102DBD1}
Tiger.Business.WMS/AGV/Agv.UpdateMReqStatus.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,58 @@
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business.WMS
{
    /// <summary>
    /// æ›´æ–°é¢†æ–™å•状态
    /// </summary>
    public partial class AGV
    {
        public ApiAction UpdateStatus(AgvMRUpdateInput input)
        {
            ApiAction response = new();
            try
            {
                DbClient db = Biz.DataSource["WMS57"].Client;
                BIZ_ERP_PROD_OUT entity = new BIZ_ERP_PROD_OUT();
                BIZ_ERP_PROD_OUT entity_x = db.Queryable<BIZ_ERP_PROD_OUT>().Where(x => x.SOURCECODE.Contains(input.taskId)).First();
                if (entity_x != null)
                {
                    entity = entity_x;
                }
                else
                {
                    response.IsSuccessed = false;
                    response.Message = $"任务ID[{input.taskId}]在领料单中查不到记录";
                    return response;
                }
                entity.STATUS = BIZ_ERP_PROD_OUT.STATUSs.COMPLETE.GetValue();
                entity.ERP_BILL_CODE = "手工过账";
                //保存数据库
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable(entity).UpdateColumns(x => new { x.STATUS, x.ERP_BILL_CODE }).ExecuteCommand();
                });
                if (!dbTran.IsSuccess)
                {
                    response.GetResponse().CatchExceptionWithLog(dbTran.ErrorException);
                }
                response.Message = $"领料单[{entity.BILLCODE}]更新状态成功,agv可清除";
            }
            catch (Exception ex)
            {
                response.GetResponse().CatchExceptionWithLog(ex);
            }
            return response;
        }
    }
}
Tiger.Business.WMS/AGV/Agv.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,72 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Business.WMS
{
    public partial class AGV : IAGV
    {
        /// <summary>
        /// AGV接口URL
        /// </summary>
        public static string agvurl { get; set; } = @$"{Biz.SysParamOld["agvUrl", "AgvApiAddress"].PARAM_VALUE}"; //@"http://10.12.16.249:10007/rcs/order/";
        /// <summary>
        /// å¤‡æ–™å®Œæˆé€šçŸ¥
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public AgvActionResult materialPreparation(AgvMPInput input)
        {
            AgvActionResult result = new AgvActionResult();
            Work.DoAsync
            (() =>
            {
                var requestJson = JsonConvert.SerializeObject(input);
                var response = HttpHelper.PostAsync(agvurl + "materialPreparation", requestJson).Result;
                var result1 = JsonConvert.DeserializeObject<AgvActionResult>(response.Message);
                Logger.Interface.Info("AGV返回:" + response.Message);
            });
            return result;
        }
        public AgvActionResult materialPreparation(AgvMPInput input, string agvApi)
        {
            AgvActionResult result = new AgvActionResult();
            Work.DoAsync
            (() =>
            {
                var requestJson = JsonConvert.SerializeObject(input);
                var response = HttpHelper.PostAsync(agvApi + "materialPreparation", requestJson).Result;
                var result1 = JsonConvert.DeserializeObject<AgvActionResult>(response.Message);
                Logger.Interface.Info("AGV返回:" + response.Message);
            });
            return result;
        }
        /// <summary>
        /// æ”¾è¡Œ
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public AgvActionResultBase carPass(AgvMPInput input)
        {
            var requestJson = JsonConvert.SerializeObject(input);
            var response = HttpHelper.PostAsync(agvurl + "carPass", requestJson).Result;
            var result = JsonConvert.DeserializeObject<AgvActionResultBase>(response.Message);
            return result;
        }
    }
}
Tiger.Business.WMS/BS/BS.ItemCount.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,195 @@
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 Tiger.Model.Entitys.WMS.DTOS;
using Tiger.IBusiness.WMS.T100ToWMS;
namespace Tiger.Business.WMS
{
    public partial class BS
    {
        /// <summary>
        /// åˆ›å»ºç›˜ç‚¹å•号
        /// </summary>
        /// <returns></returns>
        public ApiAction CreateBillCode()
        {
            var action = new ApiAction();
            Result ruleResult = Biz.CodeRule["PD001"].Generate("PD");  //iWMS.GetBillNoByType("CI");
            if (!ruleResult.IsSuccessed)
            {
                throw new Exception(ruleResult.ExceptionMsg.Message);
            }
            action.Data = ruleResult.Data;
            return action;
        }
        /// <summary>
        /// ç›˜ç‚¹å•明细
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public ApiAction SummaryCount(WMS_COUNT count)
        {
            var action = new ApiAction();
            var items = Biz.Db.Queryable<V_ITEM_COUNT>().Where(q => q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue() && q.AUTH_ORG == count.AUTH_ORG)
               .WhereIF(count.ItemCodeList.Any(), q => count.ItemCodeList.Contains(q.ITEM_CODE))
               .Where(q => (count.WhIdList.Contains(q.WH_ID) || count.RegionIdList.Contains(q.REGION_ID) || count.ShelfIdList.Contains(q.SHELF_ID))).GroupBy(q => q.ITEM_CODE).Select(q => new
               {
                   ITEM_CODE = q.ITEM_CODE,
                   ITEM_NAME = SqlFunc.AggregateMax(q.ITEM_NAME),
                   ITEM_DESC = SqlFunc.AggregateMax(q.ITEM_DESC),
                   QTY = SqlFunc.AggregateSum(q.QTY),
                   SN_COUNT = SqlFunc.AggregateCount(q.SN),
               }).OrderBy(q => q.ITEM_CODE).ToList();
            action.Data = items;
            return action;
        }
        /// <summary>
        /// ç›˜ç‚¹å•明细
        /// </summary>
        /// <param name="count"></param>
        /// <param name="_data"></param>
        /// <returns></returns>
        public ApiAction GenerateCount(WMS_COUNT count, List<SaleOutInfoDetailDTO> _data)
        {
            var action = new ApiAction();
            List<WMS_COUNT_MDTL> Count_mdtls = new();
            List<WMS_COUNT_LDTL> Count_ldtls = new();
            List<WMS_COUNT_SUM> Count_sums = new();
            var startTime = DateTime.Now;
            //物品明细
            var mdtls = Biz.Db.Queryable<WMS_ITEM>().Where(q => q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue())
                                    .WhereIF(count.ItemCodeList.Any(), q => count.ItemCodeList.Contains(q.ITEM_CODE))
                                    .Where(q => (count.WhIdList.Contains(q.WH_ID) || count.RegionIdList.Contains(q.REGION_ID) || count.ShelfIdList.Contains(q.SHELF_ID)))
                                    .Select(q => new WMS_COUNT_MDTL()
                                    {
                                        CREATE_USER = count.CREATE_USER,
                                        CREATE_TIME = DateTime.Now,
                                        UPDATE_USER = count.UPDATE_USER,
                                        UPDATE_TIME = DateTime.Now,
                                        AUTH_ORG = count.AUTH_ORG,
                                        COUNT_NO = count.COUNT_NO,
                                        ITEM_CODE = q.ITEM_CODE,
                                        SN = q.SN,
                                        UNIT = q.UNIT,
                                        QTY = q.QTY,
                                        PROD_DATE = q.PROD_DATE,
                                        FIRST_IN_DATE = q.FIRST_IN_DATE,
                                        SUPP_CODE = q.SUPP_CODE,
                                        SUPP_LOTNO = q.SUPP_LOTNO,
                                        WH_ID = q.WH_ID,
                                        REGION_ID = q.REGION_ID,
                                        SHELF_ID = q.SHELF_ID,
                                        LOCATION_ID = q.LOCATION_ID,
                                        ERP_WH = q.ERP_WH,
                                    })
                                    .OrderBy(q => q.ITEM_CODE).ToList();
            if (mdtls.Count > 0)
            {
                Count_mdtls = mdtls;
            }
            //储位明细
            var ldtls = Biz.Db.Queryable<WMS_ITEM>().Where(q => q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue())
                                   .WhereIF(count.ItemCodeList.Any(), q => count.ItemCodeList.Contains(q.ITEM_CODE))
                                    .Where(q => (count.WhIdList.Contains(q.WH_ID) || count.RegionIdList.Contains(q.REGION_ID) || count.ShelfIdList.Contains(q.SHELF_ID)))
                                   .GroupBy(q => new { q.ITEM_CODE, q.WH_ID, q.REGION_ID, q.SHELF_ID, q.LOCATION_ID, q.ERP_WH })
                                   .Select(q => new WMS_COUNT_LDTL()
                                   {
                                       CREATE_USER = count.CREATE_USER,
                                       CREATE_TIME = DateTime.Now,
                                       UPDATE_USER = count.UPDATE_USER,
                                       UPDATE_TIME = DateTime.Now,
                                       COUNT_NO = count.COUNT_NO,
                                       AUTH_ORG = count.AUTH_ORG,
                                       WH_ID = q.WH_ID,
                                       SHELF_ID = q.SHELF_ID,
                                       REGION_ID = q.REGION_ID,
                                       LOCATION_ID = q.LOCATION_ID,
                                       ERP_WH = q.ERP_WH,
                                       ITEM_CODE = q.ITEM_CODE,
                                       UNIT = SqlFunc.AggregateMax(q.UNIT),
                                       SN_QTY = SqlFunc.AggregateCount(q.SN),
                                       QTY = SqlFunc.AggregateSum(q.QTY),
                                   }).OrderBy(q => q.ITEM_CODE).ToList();
            if (ldtls.Count() > 0)
            {
                Count_ldtls = ldtls;
            }
            //结果明细
            var sums = Biz.Db.Queryable<WMS_ITEM>().Where(q => q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue())
                                    .WhereIF(count.ItemCodeList.Any(), q => count.ItemCodeList.Contains(q.ITEM_CODE))
                                    .Where(q => (count.WhIdList.Contains(q.WH_ID) || count.RegionIdList.Contains(q.REGION_ID) || count.ShelfIdList.Contains(q.SHELF_ID)))
                                    .GroupBy(q => new { q.ITEM_CODE, q.ERP_WH })
                                    .Select(q => new WMS_COUNT_SUM()
                                    {
                                        CREATE_USER = count.CREATE_USER,
                                        CREATE_TIME = DateTime.Now,
                                        UPDATE_USER = count.UPDATE_USER,
                                        UPDATE_TIME = DateTime.Now,
                                        AUTH_ORG = count.AUTH_ORG,
                                        COUNT_NO = count.COUNT_NO,
                                        ERP_WH = q.ERP_WH,
                                        ITEM_CODE = q.ITEM_CODE,
                                        UNIT = SqlFunc.AggregateMax(q.UNIT),
                                        QTY = SqlFunc.AggregateSum(q.QTY),
                                        SN_QTY = SqlFunc.AggregateCount(q.SN),
                                    }).OrderBy(q => q.ITEM_CODE).ToList();
            //t100库存数量
            //var t100_sums = _stockBus.GetStockInfo(_data);
            if (sums.Count > 0)
            {
                foreach (var sum in sums)
                {
                    foreach (var item in _data)
                    {
                        if (sum.ITEM_CODE == item.inag001 && sum.ERP_WH == item.inag004)
                        {
                            sum.ERP_QTY = item.inag009;
                        }
                    }
                }
                Count_sums = sums;
            }
            //保存数据库
            var startSaveTime = DateTime.Now;
            var db = Biz.Db;
            var dbTran = db.UseTran(() =>
            {
                db.Deleteable<WMS_COUNT_LDTL>(false).Where(q => q.COUNT_NO == count.COUNT_NO).ExecuteCommand();
                db.Deleteable<WMS_COUNT_MDTL>(false).Where(q => q.COUNT_NO == count.COUNT_NO).ExecuteCommand();
                db.Deleteable<WMS_COUNT_SUM>(false).Where(q => q.COUNT_NO == count.COUNT_NO).ExecuteCommand();
                db.Fastest<WMS_COUNT_LDTL>().BulkCopy(Count_ldtls);
                db.Fastest<WMS_COUNT_MDTL>().BulkCopy(Count_mdtls);
                db.Fastest<WMS_COUNT_SUM>().BulkCopy(Count_sums);
            });
            if (!dbTran.IsSuccess)
            {
                action.GetResponse().CatchExceptionWithLog(dbTran.ErrorException, $"生成盘点单[{count.COUNT_NO}]明细异常");
            }
            action.Message = $"生成盘点单[{count.COUNT_NO}]明细成功,总耗时{(DateTime.Now - startTime).TotalSeconds}毫秒,保存耗时{(DateTime.Now - startSaveTime).TotalSeconds}毫秒";
            return action;
        }
    }
}
Tiger.Business.WMS/BS/BS.MaterialResale.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,93 @@
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.WMS
{
    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;
            }
        }
    }
}
Tiger.Business.WMS/BS/BS.MaterialrReq.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,46 @@
using Apache.NMS;
using Newtonsoft.Json;
using Org.BouncyCastle.Ocsp;
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Business.WMS
{
    public partial class BS
    {
        /// <summary>
        /// é‡æ–°è¿‡è´¦
        /// </summary>
        /// <param name="User"></param>
        /// <param name="BillCode"></param>
        /// <param name="Auth_Org"></param>
        /// <returns></returns>
        public async Task<string> UpdateReq(string User, string BillCode, string Auth_Org)
        {
            MReqPostParam mRegPostParam = new()
            {
                BillCode = BillCode,
                CompanyId = Auth_Org
            };
            DI.Resolve<IiWMS>().MaterialReqToErpNew(mRegPostParam);
            Thread.Sleep(10 * 1000);
            var data = Biz.Db.Queryable<BIZ_ERP_PROD_OUT>().Where(q => q.BILLCODE == BillCode && q.AUTH_ORG == Auth_Org).First();
            data.COMMIT_MSG = "用户:" + User + "确认T100已经过账," + data.COMMIT_MSG;
            data.COMMIT_JSON = "用户:" + User + "确认T100已经过账," + data.COMMIT_JSON;
            Biz.Db.Updateable(data).ExecuteCommand();
            return null;
        }
    }
}
Tiger.Business.WMS/BS/BS.Transfer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
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;
namespace Tiger.Business.WMS
{
    public partial class BS
    {
        /// <summary>
        /// åˆ›å»ºè°ƒæ‹¨å•号
        /// </summary>
        /// <returns></returns>
        public ApiAction CreateTFBillCode()
        {
            var action = new ApiAction();
            Result ruleResult = Biz.CodeRule["TF001"].Generate("TF");  //iWMS.GetBillNoByType("CI");
            if (!ruleResult.IsSuccessed)
            {
                throw new Exception(ruleResult.ExceptionMsg.Message);
            }
            action.Data = ruleResult.Data;
            return action;
        }
    }
}
Tiger.Business.WMS/BS/BS.WareHouse.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,371 @@
using Newtonsoft.Json;
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using Tiger.IBusiness;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.Model;
namespace Tiger.Business.WMS
{
    public partial class BS : IBS
    {
        /// <summary>
        /// èŽ·å–æ‰€æœ‰ä»“åº“æœºæž„åˆ—è¡¨
        /// </summary>
        /// <param name="name"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public async Task<string> GetHouseModel(string name, string status)
        {
            var data = new List<OrgItemH>();
            V_WH_TREE func = null;
            if (!string.IsNullOrEmpty(name))
            {
                func = Biz.Db.Queryable<V_WH_TREE>().Where(x => x.NAME == name).First();
            }
            var items = await Biz.Db.Queryable<V_WH_TREE>()
                .Where(q => q.TYPE != "Location")
                .OrderBy(x => x.CODE)
                .Distinct().ToListAsync();
            //没有查询的时候
            if (func == null)
            {
                List<V_WH_TREE> entities = items.OrderBy(x => x.CODE).ToList().FindAll(t => t.PARENT_ID.IsNullOrEmpty());
                foreach (var item in entities)
                {
                    OrgItemH houseItem = new();
                    houseItem.id = item.TYPE.ToString().FirstOrDefault() + item.ID;
                    houseItem.houseCode = item.CODE;
                    houseItem.houseName = item.AUTH_ORG + ":" + item.CODE + "(" + item.NAME + ")";
                    houseItem.PARENT_HOUSE = item.PARENT_ID;
                    houseItem.createTime = DateTime.Now.ToString("yyyy-MM-dd mm:dd:ss");
                    houseItem.houseType = item.TYPE;
                    //hosueItem.remark = item.REMARK;
                    //hosueItem.orderNo = item.SEQ_NO;
                    houseItem.children = new();
                    if (item.TYPE != "Shelf") GetOrgItem(items, item.ID, ref houseItem);
                    data.Add(houseItem);
                }
            }
            //有查询条件的时候
            else
            {
            }
            //转换Json时,去除值为null的属性
            var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
            var json = JsonConvert.SerializeObject(data, Formatting.Indented, jsonSetting);
            return json;
        }
        /// <summary>
        /// é€’归返回组织机构
        /// </summary>
        /// <param name="data"></param>
        /// <param name="parent"></param>
        /// <param name="pOrgItem"></param>
        private static void GetOrgItem(List<V_WH_TREE> data, string parent, ref OrgItemH pOrgItem)
        {
            List<V_WH_TREE> entities = data.OrderBy(x => x.CODE).ToList().FindAll(t => t.PARENT_ID == parent).Distinct().ToList();
            if (entities.Count > 0)
            {
                foreach (var item in entities)
                {
                    OrgItemH houseItem = new();
                    houseItem.id = item.TYPE.ToString().FirstOrDefault() + item.ID;
                    houseItem.houseCode = item.CODE;
                    houseItem.houseName = item.AUTH_ORG + ":" + item.CODE + "(" + item.NAME + ")";
                    houseItem.PARENT_HOUSE = item.PARENT_ID;
                    houseItem.createTime = DateTime.Now.ToString("yyyy-MM-dd mm:dd:ss");
                    houseItem.houseType = item.TYPE;
                    //houseItem.remark = item.REMARK;
                    //houseItem.orderNo = item.SEQ_NO;
                    houseItem.children = new();
                    if (item.TYPE != "Shelf") GetOrgItem(data, item.ID, ref houseItem);
                    pOrgItem.children.Add(houseItem);
                }
            }
        }
        /// <summary>
        /// èŽ·å–æ‰€æœ‰ä»“åº“æœºæž„åˆ—è¡¨
        /// </summary>
        /// <param name="listItem"></param>
        /// <returns></returns>
        public async Task<string> GetHouseModelOrg(HouseListItem listItem)
        {
            var data = new List<OrgItemH>();
            V_WH_TREE func = null;
            var items = await Biz.Db.Queryable<V_WH_TREE>()
                .Where(q => q.TYPE != "Location" && q.AUTH_ORG == listItem.AUTH_ORG)
                .OrderBy(x => x.CODE)
                .Distinct().ToListAsync();
            //没有查询的时候
            if (func == null)
            {
                List<V_WH_TREE> entities = items.OrderBy(x => x.CODE).ToList().FindAll(t => t.PARENT_ID.IsNullOrEmpty());
                foreach (var item in entities)
                {
                    OrgItemH houseItem = new();
                    houseItem.id = item.ID;
                    houseItem.houseCode = item.CODE;
                    houseItem.houseName = item.AUTH_ORG + ":" + item.CODE + "(" + item.NAME + ")";
                    houseItem.PARENT_HOUSE = item.PARENT_ID;
                    houseItem.createTime = DateTime.Now.ToString("yyyy-MM-dd mm:dd:ss");
                    houseItem.houseType = item.TYPE;
                    //hosueItem.remark = item.REMARK;
                    //hosueItem.orderNo = item.SEQ_NO;
                    houseItem.children = new();
                    if (item.TYPE != "Shelf") GetOrgItemOrg(items, item.ID, ref houseItem);
                    data.Add(houseItem);
                }
            }
            //有查询条件的时候
            else
            {
            }
            //转换Json时,去除值为null的属性
            var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
            var json = JsonConvert.SerializeObject(data, Formatting.Indented, jsonSetting);
            return json;
        }
        /// <summary>
        /// é€’归返回组织机构
        /// </summary>
        /// <param name="data"></param>
        /// <param name="parent"></param>
        /// <param name="pOrgItem"></param>
        private static void GetOrgItemOrg(List<V_WH_TREE> data, string parent, ref OrgItemH pOrgItem)
        {
            List<V_WH_TREE> entities = data.OrderBy(x => x.CODE).ToList().FindAll(t => t.PARENT_ID == parent).Distinct().ToList();
            if (entities.Count > 0)
            {
                foreach (var item in entities)
                {
                    OrgItemH houseItem = new();
                    houseItem.id = item.ID;
                    houseItem.houseCode = item.CODE;
                    houseItem.houseName = item.AUTH_ORG + ":" + item.CODE + "(" + item.NAME + ")";
                    houseItem.PARENT_HOUSE = item.PARENT_ID;
                    houseItem.createTime = DateTime.Now.ToString("yyyy-MM-dd mm:dd:ss");
                    houseItem.houseType = item.TYPE;
                    //houseItem.remark = item.REMARK;
                    //houseItem.orderNo = item.SEQ_NO;
                    houseItem.children = new();
                    if (item.TYPE != "Shelf") GetOrgItemOrg(data, item.ID, ref houseItem);
                    pOrgItem.children.Add(houseItem);
                }
            }
        }
        /// <summary>
        /// æ ¹æ®ä»“库代码和类型删除仓库机构列表
        /// </summary>
        /// <param name="wareHouse"></param>
        /// <returns></returns>
        public ApiAction DelWareHouseModel(DelWareHouseModelEntity wareHouse)
        {
            var action = new ApiAction();
            List<string> locaIds = new();
            List<string> shelfIds = new();
            List<string> regIds = new();
            List<string> wareIds = new();
            var db = Biz.Db;
            List<V_WH_UNIT> uNITs = new List<V_WH_UNIT>();
            if (wareHouse.Type == "Warehouse")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.WH_ID == wareHouse.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    var unit = db.Queryable<V_WH_UNIT>().Where(q => q.WH_ID == wareHouse.ID).ToList();
                    locaIds.AddRange(unit.Where(q => !q.LOCATION_ID.IsNullOrEmpty()).Select(s => s.LOCATION_ID).Distinct());
                    shelfIds.AddRange(unit.Where(q => !q.SHELF_ID.IsNullOrEmpty()).Select(s => s.SHELF_ID).Distinct());
                    regIds.AddRange(unit.Where(q => !q.REGION_ID.IsNullOrEmpty()).Select(s => s.REGION_ID).Distinct());
                    wareIds.AddRange(unit.Where(q => !q.WH_ID.IsNullOrEmpty()).Select(s => s.WH_ID).Distinct());
                }
                else
                {
                    action.IsSuccessed = false;
                    action.Message = "仓库里面有东西,不能删除!";
                }
            }
            else if (wareHouse.Type == "Region")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.REGION_ID == wareHouse.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    var unit = db.Queryable<V_WH_UNIT>().Where(q => q.REGION_ID == wareHouse.ID).ToList();
                    locaIds.AddRange(unit.Where(q => !q.LOCATION_ID.IsNullOrEmpty()).Select(s => s.LOCATION_ID).Distinct());
                    shelfIds.AddRange(unit.Where(q => !q.SHELF_ID.IsNullOrEmpty()).Select(s => s.SHELF_ID).Distinct());
                    regIds.AddRange(unit.Where(q => !q.REGION_ID.IsNullOrEmpty()).Select(s => s.REGION_ID).Distinct());
                }
                else
                {
                    action.IsSuccessed = false;
                    action.Message = "储区里面有东西,不能删除!";
                }
            }
            else if (wareHouse.Type == "Shelf")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.SHELF_ID == wareHouse.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    var unit = db.Queryable<V_WH_UNIT>().Where(q => q.SHELF_ID == wareHouse.ID).ToList();
                    locaIds.AddRange(unit.Where(q => !q.LOCATION_ID.IsNullOrEmpty()).Select(s => s.LOCATION_ID).Distinct());
                    shelfIds.AddRange(unit.Where(q => !q.SHELF_ID.IsNullOrEmpty()).Select(s => s.SHELF_ID).Distinct());
                }
                else
                {
                    action.IsSuccessed = false;
                    action.Message = "货架里面有东西,不能删除!";
                }
            }
            else
            {
            }
            //删储位
            if (locaIds.Any())
            {
                db.Deleteable<Model.WMS_LOCATION>().Where(it => locaIds.Contains(it.ID)).ExecuteCommand();
            }
            //删货架
            if (shelfIds.Any())
            {
                db.Deleteable<Model.WMS_SHELF>().Where(it => shelfIds.Contains(it.ID)).ExecuteCommand();
            }
            //删储区
            if (regIds.Any())
            {
                db.Deleteable<Model.WMS_REGION>().Where(it => regIds.Contains(it.ID)).ExecuteCommand();
            }
            //删仓库
            if (wareIds.Any())
            {
                db.Deleteable<Model.WMS_WAREHOUSE>().Where(it => wareIds.Contains(it.ID)).ExecuteCommand();
            }
            return action;
        }
        /// <summary>
        /// ç”Ÿæˆå‚¨ä½åˆ—表
        /// </summary>
        /// <param name="locations"></param>
        /// <returns></returns>
        public ApiAction AddLocationModel(List<AddLocationModelEntity> locations)
        {
            var action = new ApiAction();
            List<WMS_LOCATION> Locations = new List<WMS_LOCATION>();
            foreach (var item in locations)
            {
                WMS_LOCATION location = new WMS_LOCATION()
                {
                    LOCATION_CODE = item.LOCATION_CODE,
                    LOCATION_NAME = item.LOCATION_CODE,
                    IS_ACTIVE = "Y",
                    AUTH_ORG = item.AUTH_ORG,
                    ORG_CODE = item.ORG_CODE,
                    SHELF_ID = item.SHELF_ID,
                    IS_MIX = item.ISMIX,
                    IS_SINGLE = item.ISMIX == "N" ? "Y" : "N",
                    FLOOR_NO = item.FLOOR_NO,
                    SEQ_NO = item.SEQ_NO,
                    LEDID = item.LEDID
                };
                Locations.Add(location);
            }
            var db = Biz.Db;
            var dbTran = db.UseTran(() =>
            {
                db.Deleteable<WMS_LOCATION>().Where(q => q.SHELF_ID == locations[0].SHELF_ID).ExecuteCommand();
                db.Insertable<WMS_LOCATION>(Locations).ExecuteCommand();
            });
            if (!dbTran.IsSuccess)
            {
                action.GetResponse().CatchExceptionWithLog(dbTran.ErrorException, $"新增储位异常");
            }
            action.LocaleMsg = Biz.L("WMS.WareHouse.VerifyException", Locations[0].ORG_CODE);
            return action;
        }
        /// <summary>
        /// æŸ¥è¯¢è´§æž¶æ˜¯å¦æœ‰ä¸œè¥¿
        /// </summary>
        /// <param name="shelf"></param>
        /// <returns></returns>
        public ApiAction CheckLocation(DelWareHouseModelEntity shelf)
        {
            var action = new ApiAction();
            var db = Biz.Db;
            if (shelf.Type == "shelf")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.SHELF_ID == shelf.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    action.IsSuccessed = true;
                }
                else
                {
                    action.IsSuccessed = false;
                    action.LocaleMsg = Biz.L("WMS.WareHouse.检查储位初始化", shelf.ID);
                }
            }
            return action;
        }
        /// <summary>
        /// ä¿®æ”¹ä»“库据点,同下级全部修改
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<string> GetUpdateOrg(string id)
        {
            var db = Biz.Db;
            List<WMS_SHELF> shelfs = new();
            List<WMS_LOCATION> locations = new();
            var warehouse = db.Queryable<WMS_WAREHOUSE>().Where(q => q.ID == id).First();
            if (warehouse != null)
            {
                var unit = db.Queryable<V_WH_UNIT>().Where(q => q.WH_ID == id).ToList();
                var regionids = unit.Select(q => q.REGION_ID).Distinct().ToList();
                var shelfids = unit.Select(q => q.SHELF_ID).Distinct().ToList();
                //var locationids=unit.Select(q=>q.LOCATION_ID).Distinct().ToList();
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable<WMS_REGION>().SetColumns(q => q.AUTH_ORG == warehouse.AUTH_ORG).Where(q => q.WH_ID == warehouse.ID).ExecuteCommand();
                    db.Updateable<WMS_SHELF>().SetColumns(q => q.AUTH_ORG == warehouse.AUTH_ORG)
                    .Where(q => regionids.Any(o => o == q.REGION_ID)).ExecuteCommand();
                    db.Updateable<WMS_LOCATION>().SetColumns(q => q.AUTH_ORG == warehouse.AUTH_ORG)
                    .Where(q => SqlFunc.Subqueryable<WMS_SHELF>().Where(s => regionids.Any(o => o == s.REGION_ID) && q.SHELF_ID == s.ID).Any()).ExecuteCommand();
                });
            }
            return "";
        }
        /// <summary>
        /// æ ¹æ®id获取Code
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<string> GetWmsCode(string id)
        {
            var db = Biz.Db;
            var ID = "";
            var warehouse = db.Queryable<WMS_WAREHOUSE>().Where(q => q.WH_CODE == id).First();
            if (warehouse != null)
            {
                ID = warehouse.ID;
            }
            return ID;
        }
    }
}
Tiger.Business.WMS/DigitalTwin/Seastone/Rack.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
using Tiger.Model;
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Tiger.Business.WMS
{
    //public static async Task<List<K3_VWHEADER>> GetInCommingList(string FBILLNO)
    //{
    //    var query = Biz.Db.Queryable<K3_VWHEADER>().Where(q => q.STATUS < (int)K3_VWHEADER.STATUSs.Completed)
    //        .WhereIF(!string.IsNullOrEmpty(FBILLNO), q => q.FBILLNO == FBILLNO || q.FSOURCEBILLNO == FBILLNO)
    //        .OrderBy(q => q.STATUS, OrderByType.Desc).OrderBy(q => q.FBILLNO, OrderByType.Asc);
    //    return await query.ToListAsync();
    //}
}
Tiger.Business.WMS/DigitalTwin/Seastone/RackApi.cs
Tiger.Business.WMS/DigitalTwin/Sharetronic/Shelf.cs
Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs
Tiger.Business.WMS/ERP/ErpT100.Vender.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,127 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Tiger.Model;
using Tiger.Model.Minsun;
using Tiger.IBusiness;
namespace Tiger.Business.WMS
{
    public partial class ErpT100
    {
        /// <summary>
        /// ä»ŽT100获取供应商接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public T100ActionResult<resultStd_data<VenderParameterR>> GetVenderInfo(VenderInputParameter input)
        {
            var t100Action = new T100Action<actionStd_data<VenderParameter>>
            {
                key = Guid.NewGuid().ToString("N"),
                type = "sync",
                host = new host
                {
                    prod = "MES",
                    ip = "",
                    lang = "zh_CN",
                    acct = "tiptop",
                    timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
                },
                datakey = input.datakey,
                service = new Service
                {
                    ip = "",
                    prod = "T100",
                    id = "topprd",
                    name = "wms_erp_wms_getven"
                },
                payload = new PayloadData<actionStd_data<VenderParameter>>
                {
                    std_data = new actionStd_data<VenderParameter>
                    {
                        parameter = input.parameter
                    }
                }
            };
            var requestJson = JsonConvert.SerializeObject(t100Action);
            var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
            var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<VenderParameterR>>>(response.Message);
            return result;
        }
        public ApiAction GetVenderInfoToDDL(iVenderParams input)
        {
            var action = new ApiAction();
            try
            {
                var t100Res = GetVenderInfo(new VenderInputParameter
                {
                    parameter = new VenderParameter
                    {
                        site = input.company,
                        startdt = input.startDate,
                        enddt = input.endDate
                    },
                    datakey = new Datakey
                    {
                        EntId = ApiConfig.IsTestServer ? "108" : "88",
                        CompanyId = input.company
                    }
                });
                if (t100Res.payload.std_data.execution.code == "0")
                {
                    var list = t100Res.payload.std_data.parameter.@return;
                    action.Data = list;
                    List<BAS_SUPPLIER> suppliers = new List<BAS_SUPPLIER>();
                    var allList = Biz.Db.Queryable<BAS_SUPPLIER>().Where(x => x.AUTH_ORG == input.company).ToList();
                    foreach (var item in list)
                    {
                        var query = allList.Where(x => x.SUPP_CODE == item.pmab001).FirstOrDefault();
                        BAS_SUPPLIER entity = query ?? new BAS_SUPPLIER()
                        {
                            SUPP_CODE = item.pmab001,
                            SUPP_NAME_CN = item.pmaal003,
                            AUTH_ORG = input.company
                        };
                        suppliers.Add(entity);
                    }
                    var db = Business.Biz.Db;
                    //数据库处理操作
                    if (action.IsSuccessed)
                    {
                        action.Message = $"供应商信息同步成功";
                        var dbTran = db.UseTran(() =>
                        {
                            db.Storageable(suppliers, "Interface").ExecuteCommand();
                        });
                        if (!dbTran.IsSuccess)
                        {
                            action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                        }
                    }
                }
                else
                {
                    action.IsSuccessed = false;
                    action.Message = $"T100返回信息错误:{t100Res.payload.std_data.execution.description}";
                }
            }
            catch (Exception ex)
            {
                action.CatchExceptionWithLog(ex, $"数据处理失败");
            }
            return action;
        }
    }
}
Tiger.Business.WMS/ERP/T100.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,453 @@
using Apache.NMS.ActiveMQ.Commands;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Ocsp;
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business.WMS
{
    public partial class ErpT100 : IErpT100
    {
        /// <summary>
        /// T100接口URL
        /// </summary>
        public static string t100Url { get; set; } = @"http://172.18.8.11/wstopprd/ws/r/awsp920";
        public static List<string> curDeliveryNoList { get; set; } = new List<string>();
        /// <summary>
        /// ä»ŽT100获取二级供应商接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static T100ActionResult<resultStd_data<Parameter3>> GetSecondarySupplyInfo(SupplierInputParameter input)
        {
            var t100Action = new T100Action<actionStd_data<SupplierParameter>>
            {
                key = Guid.NewGuid().ToString("N"),
                type = "sync",
                host = new host
                {
                    prod = "WMS",
                    ip = "",
                    lang = "zh_CN",
                    acct = "tiptop",
                    timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
                },
                datakey = input.datakey,
                //datakey = new Datakey
                //{
                //    EntId = "88",
                //    CompanyId = "XCSJ" //据点 DGXC
                //},
                service = new Service
                {
                    ip = "",
                    prod = "T100",
                    id = "topprd",
                    name = "wms_ge_pmaauc"
                },
                payload = new PayloadData<actionStd_data<SupplierParameter>>
                {
                    std_data = new actionStd_data<SupplierParameter>
                    {
                        parameter = input.parameter
                    }
                }
            };
            var requestJson = JsonConvert.SerializeObject(t100Action);
            var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
            var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter3>>>(response.Message);
            Logger.Interface.Info($"T100获取二级供应商提交Json: {requestJson},返回Json: {response.Message}");
            return result;
        }
        /// <summary>
        /// ç”Ÿæˆå®¢ä¾›æ–™åˆ°è´§å•
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static T100ActionResult<resultStd_data<Parameter>> GenerateCustReceipt(CustReceiptInputParameter input)
        {
            try
            {
                var t100Action = new T100Action<actionStd_data<Parameter<Detail>>>
                {
                    key = Guid.NewGuid().ToString("N"),
                    type = "sync",
                    host = new host
                    {
                        prod = "WMS",
                        ip = "",
                        lang = "zh_CN",
                        acct = "tiptop",
                        timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
                    },
                    datakey = input.datakey,
                    //datakey = new Datakey
                    //{
                    //    EntId = "108",  //正式 88
                    //    CompanyId = "XCSJ" //据点 DGXC
                    //},
                    service = new Service
                    {
                        ip = "",
                        prod = "T100",
                        id = "topprd",
                        name = "wms_gen_apmt520"
                    },
                    payload = new PayloadData<actionStd_data<Parameter<Detail>>>
                    {
                        std_data = new actionStd_data<Parameter<Detail>>
                        {
                            parameter = input.parameter
                            //parameter = new Parameter<Detail>
                            //{
                            //    pmds000 = "2",
                            //    pmdsdocno = "3453",
                            //    pmdsdocdt = "2023-04-26", //当天时间
                            //    pmds002 = "L36783", //用户ID
                            //    pmds003 = "",
                            //    pmds007 = "C0006", //供应商代码
                            //    pmds010 = "测试客供料无采购收货", //送货单号
                            //    pmdsud001 = "CM017", //二级供应编号
                            //    detail = new List<Detail>
                            //{
                            //    new Detail
                            //    {
                            //        pmdtseq= "1",
                            //        pmdt001= "",
                            //        pmdt002= "",
                            //        pmdt003= "",
                            //        pmdt004= "",
                            //        pmdt006= itemcode, //"K7015AA016141",
                            //        pmdt020= qty,  //"100.00000",
                            //        pmdtud011= "0"
                            //    }
                            //}
                            //}
                        }
                    }
                };
                //如果送货单已经在处理,刚不能再重复抛送
                if (!curDeliveryNoList.Contains(input.parameter.pmds010) || input.parameter.pmds010.IsNullOrEmpty())
                {
                    if (!input.parameter.pmds010.IsNullOrEmpty())
                    {
                        curDeliveryNoList.Add(input.parameter.pmds010);
                    }
                    var requestJson = JsonConvert.SerializeObject(t100Action);
                    var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
                    var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
                    Logger.Interface.Info($"生成到货单提交Json: {requestJson},返回Json: {response.Message}");
                    curDeliveryNoList.Remove(input.parameter.pmds010);
                    Logger.Interface.Info($"操作单号列表移除当前操作单号[{input.parameter.pmds010}]");
                    return result;
                }
                else
                {
                    T100ActionResult<resultStd_data<Parameter>> ret = new();
                    ret.payload.std_data.execution.code = "-1";
                    ret.payload.std_data.execution.description = $"此单[{input.parameter.pmds010}]正在推送到T100,不能重复推送!";
                    Logger.Interface.Warn($"生成到货单异常,返回: {ret.payload.std_data.execution.description}");
                    return ret;
                }
                #region æµ‹è¯•代码
                //var result = new T100ActionResult<resultStd_data<Parameter>>()
                //{
                //    payload = new()
                //    {
                //        std_data = new()
                //        {
                //            execution = new()
                //            {
                //                code = "0",
                //                sql_code = "0",
                //                description = "执行成功!",
                //            },
                //            parameter = new()
                //            {
                //                docno = $"DGrec-{DateTime.Now:yyMMddHHmm}",
                //            }
                //        }
                //    }
                //};
                //Logger.Interface.Info($"生成客供料到货单提交Json: {requestJson},返回Json: {{JsonConvert.SerializeObject(result)}}");
                #endregion æµ‹è¯•代码
            }
            catch (System.Exception ex)
            {
                curDeliveryNoList.Remove(input.parameter.pmds010);
                Logger.Interface.Error($"生成到货单异常,返回: {ex.Message}");
            }
            return new();
        }
        /// <summary>
        /// ä»ŽT100获取二级供应商接口返回iDropdownlist列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public List<iDropdownlist> GetSecondarySupplyInfoToDDL(SupplierInputParameter input)
        {
            List<iDropdownlist> iDropdownlists = new List<iDropdownlist>();
            var list = GetSecondarySupplyInfo(input).payload.std_data.parameter.@return;
            foreach (var item in list)
            {
                iDropdownlist _iDropdownlist = new()
                {
                    label = item.pmaauc003,
                    value = $"{item.pmaauc002},{item.pmaauc001}",
                };
                iDropdownlists.Add(_iDropdownlist);
            }
            return iDropdownlists;
        }
        /// <summary>
        /// ç”Ÿæˆé€æ£€å•
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static T100ActionResult<resultStd_data<Parameter>> GenerateInspection(InsInputParameter input)
        {
            var t100Action = new T100Action<actionStd_data<InsParameter>>
            {
                key = Guid.NewGuid().ToString("N"),
                type = "sync",
                host = new host
                {
                    prod = "WMS",
                    ip = "",
                    lang = "zh_CN",
                    acct = "tiptop",
                    timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
                },
                datakey = input.datakey,
                //datakey = new Datakey
                //{
                //    EntId = "108",  //正式 88
                //    CompanyId = "XCSJ" //据点 DGXC
                //},
                service = new Service
                {
                    ip = "",
                    prod = "T100",
                    id = "topprd",
                    name = "wms_gen_aqct300"
                },
                payload = new PayloadData<actionStd_data<InsParameter>>
                {
                    std_data = new actionStd_data<InsParameter>
                    {
                        parameter = input.parameter
                    }
                }
            };
            var requestJson = JsonConvert.SerializeObject(t100Action);
            var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
            var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
            Logger.Interface.Info($"生成送检单提交Json: {requestJson},返回Json: {response.Message}");
            #region æµ‹è¯•代码
            //var result = new T100ActionResult<resultStd_data<Parameter>>()
            //{
            //    payload = new()
            //    {
            //        std_data = new()
            //        {
            //            execution = new()
            //            {
            //                code = "0",
            //                sql_code = "0",
            //                description = "执行成功!",
            //            },
            //            parameter = new()
            //            {
            //                docno = $"DGtest-{DateTime.Now:yyMMddHHmm}",
            //            }
            //        }
            //    }
            //};
            //Logger.Interface.Info($"生成送检单提交Json: {requestJson},返回Json: {JsonConvert.SerializeObject(result)}");
            #endregion æµ‹è¯•代码
            return result;
        }
        /// <summary>
        /// ç”Ÿæˆå…¶ä»–入库单
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static T100ActionResult<resultStd_data<Parameter>> GenerateOtherIn(OtherInputParameter<Detail4> input)
        {
            var t100Action = new T100Action<actionStd_data<InParameter<Detail4>>>
            {
                key = Guid.NewGuid().ToString("N"),
                type = "sync",
                host = new host
                {
                    prod = "WMS",
                    ip = "",
                    lang = "zh_CN",
                    acct = "tiptop",
                    timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
                },
                datakey = input.datakey,
                service = new Service
                {
                    ip = "",
                    prod = "T100",
                    id = "topprd",
                    name = "wms_gen_apmt570"
                },
                payload = new PayloadData<actionStd_data<InParameter<Detail4>>>
                {
                    std_data = new actionStd_data<InParameter<Detail4>>
                    {
                        parameter = input.parameter
                    }
                }
            };
            var requestJson = JsonConvert.SerializeObject(t100Action);
            var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
            var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
            if (result.payload.std_data.execution.code != "0")
            {
                throw new Exception($"T100生成入库单失败,失败原因:{result.payload.std_data.execution.description}");
            }
            Logger.Interface.Info($"生成入库单请求T100,传入参数Json:{requestJson},返回:{response.Message}");
            return result;
        }
        /// <summary>
        /// æ ¹æ®é¢†æ–™å•号拉单身
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public T100ActionResult<resultStd_data<reqParameter1>> GetMaterialReqDetail(ReqInputParameter input)
        {
            var t100Action = new T100Action<actionStd_data<reqParameter>>
            {
                key = Guid.NewGuid().ToString("N"),
                type = "sync",
                host = new host
                {
                    prod = "WMS",
                    ip = "",
                    lang = "zh_CN",
                    acct = "tiptop",
                    timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
                },
                datakey = input.datakey,
                service = new Service
                {
                    ip = "",
                    prod = "T100",
                    id = "topprd",
                    name = "wms_erp_wms_getwoissd"
                },
                payload = new PayloadData<actionStd_data<reqParameter>>
                {
                    std_data = new actionStd_data<reqParameter>
                    {
                        parameter = input.parameter
                    }
                }
            };
            var requestJson = JsonConvert.SerializeObject(t100Action);
            var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
            var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<reqParameter1>>>(response.Message);
            Logger.Interface.Info($"根据领料单号拉单身提交Json: {requestJson},返回Json: {response.Message}");
            return result;
        }
        /// <summary>
        /// é¢†æ–™å•过账
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static T100ActionResult<resultStd_data<Parameter>> MaterialReqToErp(ReqErpInputParameter input)
        {
            var t100Action = new T100Action<actionStd_data<Parameter4>>
            {
                key = Guid.NewGuid().ToString("N"),
                type = "sync",
                host = new host
                {
                    prod = "WMS",
                    ip = "",
                    lang = "zh_CN",
                    acct = "tiptop",
                    timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
                },
                datakey = input.datakey,
                service = new Service
                {
                    ip = "",
                    prod = "T100",
                    id = "topprd",
                    name = "wms_gen_asft310"
                },
                payload = new PayloadData<actionStd_data<Parameter4>>
                {
                    std_data = new actionStd_data<Parameter4>
                    {
                        parameter = input.parameter
                    }
                }
            };
            var requestJson = JsonConvert.SerializeObject(t100Action);
            var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
            var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
            Logger.Interface.Info($"领料单过账提交Json: {requestJson},返回Json: {response.Message}");
            if (input.datakey.CompanyId == "DGXC")
            {
                Logger.Interface.Info($"领料单[{input.parameter.sfdadocno}]过账Json保存到数据库开始");
                DbClient db = ApiConfig.IsOldVersion ? Biz.DataSource["WMS57"].Client : Business.Biz.Db;
                BIZ_ERP_PROD_OUT entity_h = db.Queryable<BIZ_ERP_PROD_OUT>().Where(x => x.BILLCODE == input.parameter.sfdadocno && x.ERP_BILL_CODE == null).First();
                if (entity_h != null)
                {
                    entity_h.COMMIT_JSON = requestJson;
                    entity_h.COMMIT_MSG = response.Message;
                }
                //数据库处理操作
                var dbTran = db.UseTran(() =>
                {
                    if (entity_h != null)
                    {
                        db.Updateable(entity_h).UpdateColumns(q => new { q.COMMIT_JSON, q.COMMIT_MSG }).ExecuteCommand();
                    }
                });
                if (!dbTran.IsSuccess)
                {
                    Logger.Interface.Error(dbTran.ErrorException);
                    throw dbTran.ErrorException;
                }
                Logger.Interface.Info($"领料单[{input.parameter.sfdadocno}]过账Json保存到数据库结束");
            }
            return result;
        }
    }
}
Tiger.Business.WMS/Extensions/JsonExtention.cs
Tiger.Business.WMS/KanBan/WareHousing.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,210 @@
using Rhea.Common;
using Tiger.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Newtonsoft.Json;
using Rhea.Common.Authorization;
using Newtonsoft.Json.Linq;
using Tiger.Model.Minsun;
using Tiger.IBusiness;
using System.Data.Entity;
namespace Tiger.Business.WMS
{
    public partial class KanBan : IKanBan
    {
        /// <summary>
        /// warehousing看板全部数据对接
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<MaterialKBOutput> GetReceiptDetail(MaterialKBInput input)
        {
            try
            {
                DateTime dateTime = DateTime.Now.AddDays(-2);
                int nYear = DateTime.Now.Year;
                //var sql = $"SELECT SUM(INSTOCKQTY) as Total, convert(varchar(100),datepart(mm, LastModificationTime))+'月' as Month FROM WMS_RECEIPT_D WHERE LINESTATUS=8 and datepart(yy,LastModificationTime)=@nYear GROUP BY datepart(mm, LastModificationTime)";
                //var sList = Db.Queryable<BIZ_ERP_RECEIPT_DTL, V_USER_ORG>((d, r) =>
                //                        new JoinQueryInfos(
                //                            JoinType.Left, d.CREATE_USER == r.USER_ID
                //                        ))
                //             .Where((d, r) => d.LINESTATUS == 2 && d.UPDATE_TIME.Year == nYear && r.USERGROUP_CODE == "清溪结构仓")
                //             //.GroupBy((d, r) => d.UPDATE_TIME)
                //            .Select((d, r) => new TotalByMonth
                //             {
                //                 Total = SqlFunc.AggregateSum(d.INSTOCKQTY),
                //                 Month = $"{d.UPDATE_TIME.Month}月"
                //             })
                //.ToList();
                var sList = Biz.Db.Queryable<V_MONTH_IN_SUM>().ToList();
                //var sList = Db.Queryable<BIZ_ERP_RECEIPT_DTL>()
                //    .LeftJoin<V_USER_ORG>((d, r) => d.CREATE_USER==r.USER_ID)
                //    .GroupBy((d, r) => d.UPDATE_TIME.Month)
                //    .Where((d, r) => d.LINESTATUS == 1 && d.UPDATE_TIME.Year == nYear && r.USERGROUP_CODE == "清溪结构仓")
                //           //.GroupBy((d, r) => new { Month = d.UPDATE_TIME.Month })
                //            .Select((d, r) => new TotalByMonth
                //            {
                //                Total = SqlFunc.AggregateSum(d.INSTOCKQTY),
                //                Month = $"{d.UPDATE_TIME.Month}月"
                //            })
                //           .ToList();
                //SqlParameter[] nParams = new SqlParameter[]
                //{
                //    new SqlParameter("@nYear",System.Data.SqlDbType.Int),
                //};
                //nParams[0].Value = nYear;
                //var sList = SqlQuery<TotalByMonth>(sql, nParams).ToList();
                //var taskTotalSql = $"SELECT SUM(QTY-INSTOCKQTY) as Total,'' as Month FROM WMS_RECEIPT_D WHERE LINESTATUS = 4 and datepart(yy,LastModificationTime)=@nYear ";
                var sTaskTotal = Biz.Db.Queryable<BIZ_ERP_RECEIPT_DTL, V_USER_ORG>((d, r) =>
                                               new JoinQueryInfos(
                                                   JoinType.Left, d.CREATE_USER == r.USER_ID
                                        ))
                    .Where((d, r) => (d.LINESTATUS == 1) && d.UPDATE_TIME.Year == nYear && r.USERGROUP_CODE == "清溪结构仓")
                    .Select((d, r) => new TotalByMonth
                    {
                        Total = SqlFunc.RowCount(),
                        Month = ""
                    }).First();
                //SqlParameter[] nParams2 = new SqlParameter[]
                //{
                //new SqlParameter("@nYear",System.Data.SqlDbType.Int),
                //};
                //nParams2[0].Value = nYear;
                //var sTaskTotal = this._receiptDetailRepository.SqlQuery<TotalByMonth>(taskTotalSql, nParams2).FirstOrDefault();
                //var unChecklSql = $"SELECT SUM(QTY) as Total,'' as Month FROM WMS_RECEIPT_D WHERE LINESTATUS = 2 and datepart(yy,LastModificationTime)=@nYear ";
                var sUnCheckNumber = Biz.Db.Queryable<BIZ_ERP_RECEIPT_DTL, V_USER_ORG>((d, r) =>
                                               new JoinQueryInfos(
                                                   JoinType.Left, d.CREATE_USER == r.USER_ID
                                        ))
                   .Where((d, r) => d.LINESTATUS == 1 && d.UPDATE_TIME.Year == nYear && r.USERGROUP_CODE == "清溪结构仓")
                   .Select((d, r) => new TotalByMonth
                   {
                       Total = SqlFunc.AggregateSum(d.QTY),
                       Month = ""
                   }).First();
                //SqlParameter[] nParams3 = new SqlParameter[]
                //{
                //new SqlParameter("@nYear",System.Data.SqlDbType.Int),
                //};
                //nParams3[0].Value = nYear;
                //var sUnCheckNumber = this._receiptDetailRepository.SqlQuery<TotalByMonth>(unChecklSql, nParams3).FirstOrDefault();
                //var sTotalSql = $"SELECT SUM(INSTOCKQTY) as Total,'' as Month FROM WMS_RECEIPT_D WHERE LINESTATUS in (4, 8) and datepart(yy,LastModificationTime)=@nYear ";
                //结构仓数量
                var Structure = Biz.Db.Queryable<BIZ_ERP_RECEIPT_DTL, V_USER_ORG>((d, r) =>
                                               new JoinQueryInfos(
                                                   JoinType.Left, d.CREATE_USER == r.USER_ID
                                        ))
                   .Where((d, r) => (d.LINESTATUS == 2) && d.UPDATE_TIME.Year == nYear && r.USERGROUP_CODE == "清溪结构仓")
                   .Select((d, r) => new TotalByMonth
                   {
                       Total = SqlFunc.AggregateSum(d.INSTOCKQTY),
                       Month = ""
                   }).First();
                //电子仓数量
                var Electron = Biz.Db.Queryable<BIZ_ERP_RECEIPT_DTL, V_USER_ORG>((d, r) =>
                                               new JoinQueryInfos(
                                                   JoinType.Left, d.CREATE_USER == r.USER_ID
                                        ))
                   .Where((d, r) => (d.LINESTATUS == 2) && d.UPDATE_TIME.Year == nYear && r.USERGROUP_CODE == "清溪电子仓")
                   .Select((d, r) => new TotalByMonth
                   {
                       Total = SqlFunc.AggregateSum(d.INSTOCKQTY),
                       Month = ""
                   }).First();
                //SqlParameter[] nParams4 = new SqlParameter[]
                //{
                //new SqlParameter("@nYear",System.Data.SqlDbType.Int),
                //};
                //nParams4[0].Value = nYear;
                //var sTotal = this._receiptDetailRepository.SqlQuery<TotalByMonth>(sTotalSql, nParams4).FirstOrDefault();
                var nOutput = new MaterialKBOutput()
                {
                    Structure = Structure.Total,
                    Electron = Electron.Total,
                    UnCheckNumber = sUnCheckNumber.Total,
                    TaskTotal = sTaskTotal.Total,
                    TotalByMonthList = sList,
                    // IncomingRptList = nResult
                };
                return nOutput;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// warehousing入库明细信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<MaterialKBOutput> GetIncomingDetail(MaterialKBInput input)
        {
            int pagenumber = Convert.ToInt16(input.Barcode); // pagenumber是从1开始的不是从零开始的
            int pageSize = 10;
            int totalCount = 0;
            DateTime dateTime = DateTime.Now.AddDays(-2);
            //入库信息
            var nResult = Biz.Db.Queryable<BIZ_ERP_RECEIPT_DTL, BAS_ITEM, V_USER_ORG>((r, m, s) =>
                                new JoinQueryInfos(
                                    JoinType.Left, r.ITEM_CODE == m.ITEM_CODE,
                                    JoinType.Left, r.CREATE_USER == s.USER_ID
                                    ))
            .Where((r, m, s) => r.CREATE_TIME > dateTime && s.USERGROUP_CODE == "清溪结构仓")
            .OrderByDescending((r, m, s) => r.CREATE_TIME)
            .Select((r, m, s) => new IncomingRptOutput
            {
                CreationTime = r.CREATE_TIME,
                BillCode = r.SOURCECODE,
                WarehouseCode = r.WAREHOUSECODE,
                MaterialCode = r.ITEM_CODE,
                MaterialName = m.ITEM_NAME,
                Status = r.LINESTATUS,
                Qty = r.QTY,
                InstockQty = r.INSTOCKQTY,
                LeftQty = r.QTY - r.INSTOCKQTY
            })
            .ToPageList(pagenumber, pageSize, ref totalCount);
            //nResult = nResult.OrderByDescending(q=>q.CreationTime).ToList();
            //totalCount = 21;
            if (totalCount > pageSize * pagenumber)
            {
                pagenumber += 1;
            }
            else
            {
                pagenumber = 1;
            }
            var nOutput = new MaterialKBOutput()
            {
                Structure = pagenumber,
                IncomingRptList = nResult
            };
            return nOutput;
        }
    }
}
Tiger.Business.WMS/Minsun/CustSupplyChecking.cs
ÎļþÃû´Ó Tiger.Business/WMS/Minsun/CustSupplyChecking.cs ÐÞ¸Ä
@@ -65,7 +65,7 @@
                    action.Message = $"条码不能为空!";
                    return action;
                }
                Result<InputBarcodeDto> result = Biz.iWMS.SplitFullBarcode(input.SN);
                Result<InputBarcodeDto> result = iWMS.SplitFullBarcode(input.SN);
                if (result.Flag != Result.Flags.Success)
                {
                    action.IsSuccessed = false;
@@ -291,7 +291,7 @@
                //var nWarehouseCodes = nScannedBarcodes.Select(x => x.WarehouseCode).Distinct().ToList();
                //新建其他入库单据头 OtherInstockHeader 
                string billCode = Biz.iWMS.GetBillNoByType("CI");
                string billCode = iWMS.GetBillNoByType("CI");
                var nBillHeader = new WMS_OTHERINSTOCK_H
                {
                    CreationTime = DateTime.Now,
@@ -389,7 +389,7 @@
                }
                //调用T100接口生成到货单
                var ret = Biz.ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                var ret = ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                {
                    parameter = new Parameter<Detail>
                    {
@@ -417,7 +417,7 @@
                    #region ç”Ÿæˆé€æ£€å•
                    foreach (var item in iqcHeaders)
                    {
                        var retIns = Biz.ErpT100.GenerateInspection(new InsInputParameter
                        var retIns = ErpT100.GenerateInspection(new InsInputParameter
                        {
                            parameter = new InsParameter
                            {
@@ -593,7 +593,7 @@
            var nIqcHeader = new WMS_IQC_H
            {
                BILLCODE = Biz.iWMS.GetBillNoByType("IQC"),
                BILLCODE = iWMS.GetBillNoByType("IQC"),
                SOURCETYPE = (int)InventoryTransferSides.BillType.CustSupplyInStock,
                SOURCECODE = detail.BILLCODE,
                SOURCELINE = detail.BILLLINE,
Tiger.Business.WMS/Minsun/CustomerSupplyIn.cs
ÎļþÃû´Ó Tiger.Business/WMS/Minsun/CustomerSupplyIn.cs ÐÞ¸Ä
@@ -60,7 +60,7 @@
                    return action;
                }
                var nLocation = new Model.Minsun.WMS_LOCATION();
                var nDisassembleBarcode = Biz.iWMS.SplitFullBarcode(sn).Data;
                var nDisassembleBarcode = iWMS.SplitFullBarcode(sn).Data;
                //验证条码是否已经存在
                var nBarcode = Biz.Db.Queryable<WMS_BARCODE>().Where(t => t.BARCODE.ToUpper() == nDisassembleBarcode.Barcode.ToUpper()).First();
                if (nBarcode != null)
@@ -105,7 +105,7 @@
                // åˆ¤æ–­æ˜¯å¦æ™ºèƒ½è´§æž¶
                if (CustomerSupplyPuton.IsSmartRack)
                {
                    Result<ShelfOperateOutput> result = await Biz.Shelf.UpShelf(new ShelfOperateInput
                    Result<ShelfOperateOutput> result = await Shelf.UpShelf(new ShelfOperateInput
                    {
                        ShelfNo = CustomerSupplyPuton.RackCode,
                        OperateType = "1"
@@ -246,7 +246,7 @@
                }
                //执行入库
                action = Biz.iWMS.MultiInStorageAsync(new MultiInvInStorageInput
                action = iWMS.MultiInStorageAsync(new MultiInvInStorageInput
                {
                    InvBarcodes = new List<WMS_BARCODE>() { nBarcode },
                    InvBarcodeLogs = new List<WMS_BARCODE_LOG>
@@ -392,7 +392,7 @@
                            pmdt018 = billHeader.REMARK
                        });
                    }
                    var ret = Biz.ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                    var ret = ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                    {
                        parameter = new InParameter<Detail4>
                        {
@@ -441,7 +441,7 @@
                    StateFlag = nDisassembleBarcode.StateFlag,
                    LocationCode = nLocation.LOCATIONCODE,
                    ReceiptCode = barcodeScanned?.BUSINESSCODE,
                    IncompleteTips = isCompleted? "数量:0 (0盘)" : Biz.iWMS.GetIncompleteTips(barcodeScanned?.BUSINESSCODE, barcodeScanned?.MATERIALCODE),
                    IncompleteTips = isCompleted? "数量:0 (0盘)" : iWMS.GetIncompleteTips(barcodeScanned?.BUSINESSCODE, barcodeScanned?.MATERIALCODE),
                };
            }
            catch (Exception ex)
@@ -564,7 +564,7 @@
                        pmdt018 ="创米科技"
                    });
                }
                var ret = Biz.ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                var ret = ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                {
                    parameter = new InParameter<Detail4>
                    {
Tiger.Business.WMS/Minsun/InStorage.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,274 @@
using Rhea.Common;
using Tiger.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Newtonsoft.Json;
using Rhea.Common.Authorization;
using Newtonsoft.Json.Linq;
using Tiger.Model.Minsun;
using System.Globalization;
using System.Data;
using Tiger.IBusiness;
namespace Tiger.Business.WMS
{
    public partial class iWMS
    {
        /// <summary>
        /// é€šç”¨æ‰¹é‡å…¥åº“
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static ApiAction MultiInStorageAsync(MultiInvInStorageInput input)
        {
            var action = new ApiAction();
            try
            {
                string flag = "";
                //保存到数据库
                var db = Business.Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    //插入或更新  InvBarcode
                    var x = db.Storageable(input.InvBarcodes)
                       .WhereColumns(t => new { t.BARCODE })
                       .ToStorage();
                    x.AsInsertable.ExecuteCommand();
                    x.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
                    flag = "InvBarcode更新成功";
                    #region æ’å…¥ InvStorageLotInfo
                    var y = db.Storageable(input.InvStorageLotInfos)
                       .WhereColumns(t => new { t.BARCODE })
                       .ToStorage();
                    y.AsInsertable.ExecuteCommand();
                    y.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
                    flag += "; InvStorageLotInfo更新成功";
                    #endregion
                    #region æ’å…¥ InvStorageInfo
                    var z = db.Storageable(input.InvStorageInfos)
                       .WhereColumns(t => new { t.WAREHOUSECODE, t.MATERIALCODE })
                       .ToStorage();
                    z.AsInsertable.ExecuteCommand();
                    z.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
                    #endregion
                    flag += "; InvStorageInfo更新成功";
                    #region æ’å…¥ InvScanMain å’Œ InvScanDetail
                    var m = db.Storageable(input.InvScanMains)
                        .ToStorage();
                    m.AsInsertable.IgnoreColumns(t => t.LastModificationTime).ExecuteCommand();
                    var o = db.Storageable(input.InvScanDetails)
                        .WhereColumns(t => new { t.SCANMAINID, t.SOURCEDETAILLINE, t.WAREHOUSECODE, t.MATERIALCODE })
                        .ToStorage();
                    o.AsInsertable.ExecuteCommand();
                    o.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
                    #endregion
                    flag += "; InvScanMain更新成功";
                    #region æ’å…¥ InvBarcodeLog
                    db.Insertable(input.InvBarcodeLogs).ExecuteCommand();
                    #endregion
                    flag += "; å…¥åº“成功";
                });
                if (!dbTran.IsSuccess)
                {
                    action.IsSuccessed = false;
                    action.Message = $"{flag} Error:{dbTran.ErrorException.Message}";
                    action.Data = new MultiInvInStorageOutput
                    {
                        Message = $"{flag} Error:{dbTran.ErrorException.Message}",
                        InvBarcodes = input.InvBarcodes
                    };
                    //throw dbTran.ErrorException;
                }
            }
            catch (System.Exception ex)
            {
                action.CatchExceptionWithLog(ex, $"入库异常");
            }
            action.Message = "OK";
            action.Data = new MultiInvInStorageOutput
            {
                Message = "OK",
                InvBarcodes = input.InvBarcodes
            };
            return action;
        }
        /// <summary>
        /// èŽ·å¾—åˆ°è´§å•å®Œæˆä¿¡æ¯
        /// </summary>
        /// <param name="billcode"></param>
        /// <param name="materialCode"></param>
        /// <returns></returns>
        public static string GetERP_RECEIPTTips(string billcode, string materialCode)
        {
            var tips = "";
            var otherInDetails = Biz.Db.Queryable<BIZ_ERP_RECEIPT_SN>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
                                && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
                                && t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
            //if (otherInDetails.Any())
            {
                tips += $"数量:{otherInDetails.Sum(q => q.SCANQTY):N0}";
            }
            var otherInScanList = Biz.Db.Queryable<BIZ_ERP_RECEIPT_SN>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
                                && t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
                                && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()).ToList();
            //if (otherInScanList.Any())
            {
                tips += $" ({otherInScanList.Count()} ç›˜)";
            }
            return tips;
        }
        /// <summary>
        /// èŽ·å¾—åˆ°è´§å•å®Œæˆä¿¡æ¯
        /// </summary>
        /// <param name="billcode"></param>
        /// <param name="materialCode"></param>
        /// <returns></returns>
        public static string GetERP_ReturnTips(string billcode, string materialCode)
        {
            var tips = "";
            var otherInDetails = Biz.Db.Queryable<BIZ_ERP_PROD_RETURN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
                                //&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
                                && t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
            //if (otherInDetails.Any())
            {
                tips += $"数量:{otherInDetails.Sum(q => q.QTY):N0}";
            }
            var otherInScanList = Biz.Db.Queryable<BIZ_ERP_PROD_RETURN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
                                && t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
                                //&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
                                ).ToList();
            //if (otherInScanList.Any())
            {
                tips += $" ({otherInScanList.Count()} ç›˜)";
            }
            return tips;
        }
        /// <summary>
        /// èŽ·å¾—å…¶ä»–å…¥åº“å•å®Œæˆä¿¡æ¯
        /// </summary>
        /// <param name="billcode"></param>
        /// <param name="materialCode"></param>
        /// <returns></returns>
        public static string GetERP_OTH_INTips(string billcode, string materialCode)
        {
            var tips = "";
            var otherInDetails = Biz.Db.Queryable<BIZ_ERP_OTH_IN_DTL>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
                                && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
                                && t.LINESTATUS == BIZ_ERP_OTH_IN.STATUSs.WORKING.GetValue()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
            //if (otherInDetails.Any())
            {
                tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.QTY):N0}";
            }
            var otherInScanList = Biz.Db.Queryable<BIZ_ERP_OTH_IN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
                                && t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
                                && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()).ToList();
            //if (otherInScanList.Any())
            {
                tips += $" ({otherInScanList.Count()} ç›˜)";
            }
            return tips;
        }
        /// <summary>
        /// èŽ·å¾—å…¶ä»–å…¥åº“å•å®Œæˆä¿¡æ¯
        /// </summary>
        /// <param name="billcode"></param>
        /// <param name="materialCode"></param>
        /// <returns></returns>
        public static string GetFinishedTips(string billcode, string materialCode)
        {
            var tips = "";
            var otherInDetails = Biz.Db.Queryable<BIZ_ERP_PROD_IN_DTL>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
                                && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
                                && t.LINESTATUS == BIZ_ERP_OTH_IN.STATUSs.WORKING.GetValue()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
            //if (otherInDetails.Any())
            {
                tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.INVENTORYQTY):N0}";
            }
            var otherInScanList = Biz.Db.Queryable<BIZ_ERP_PROD_IN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
                                && t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
                                && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()).ToList();
            //if (otherInScanList.Any())
            {
                tips += $" ({otherInScanList.Count()} ç›˜)";
            }
            return tips;
        }
        /// <summary>
        /// èŽ·å¾—å…¶ä»–å…¥åº“å•å®Œæˆä¿¡æ¯
        /// </summary>
        /// <param name="billcode"></param>
        /// <param name="materialCode"></param>
        /// <returns></returns>
        public static string GetBIZ_ERP_PROD_INips(string billcode)
        {
            var tips = "";
            //var otherInDetails = Biz.Db.Queryable<BIZ_ERP_OTH_IN_DTL>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
            //                    && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
            //                    && t.LINESTATUS == BIZ_ERP_OTH_IN.STATUSs.WORKING.GetValue()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
            ////if (otherInDetails.Any())
            //{
            //    tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.QTY):N0}";
            //}
            var otherInScanList = Biz.Db.Queryable<BIZ_ERP_PROD_IN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
                                && t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
            //if (otherInScanList.Any())
            {
                tips += $" æ€»æ•°ï¼š({otherInScanList.Count()})";
            }
            return tips;
        }
        /// <summary>
        /// èŽ·å¾—å®Œæˆä¿¡æ¯
        /// </summary>
        /// <param name="billcode"></param>
        /// <param name="materialCode"></param>
        /// <returns></returns>
        public static string GetIncompleteTips(string billcode, string materialCode)
        {
            var tips = "";
            var otherInDetails = Biz.Db.Queryable<WMS_OTHERINSTOCK_D>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
                                && t.MATERIALCODE.ToUpper() == materialCode.ToUpper()
                                && t.LINESTATUS == OtherInstockSides.Status.WORKING.ToString()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
            if (otherInDetails.Any())
            {
                tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.QTY):N0}";
            }
            var otherInScanList = Biz.Db.Queryable<WMS_OTHERINSTOCK_SCAN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
                                && t.MATERIALCODE.ToUpper() == materialCode.ToUpper()).OrderBy(t => new { t.BUSINESSCODE, t.BUSINESSLINE }).ToList();
            if (otherInScanList.Any())
            {
                tips += $" ({otherInScanList.Count()} ç›˜)";
            }
            return tips;
        }
        /// <summary>
        /// å®¢ä¾›æ–™å…¥åº“完成信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<CustSupplyInOutput> CustSupplyInIncompleteList(CustSupplyIncompleteInput input)
        {
            var otherInScanList = await Biz.Db.Queryable<WMS_OTHERINSTOCK_SCAN>()
                        .Where(t => t.BUSINESSCODE.ToUpper() == input.receiptNo.ToUpper()
                                && t.MATERIALCODE.ToUpper() == input.materialCode.ToUpper())
                        .ToListAsync();
            var incompleteList = otherInScanList.OrderBy(q => q.STATUS == "Billed" ? 1 : (q.STATUS == "Complete" ? 3 : 2))
                .Select(q => new
                {
                    Barcode = q.BARCODE,
                    Qty = (int)q.QTY,
                    Status = q.STATUS == "Billed" ? "待入库" : (q.STATUS == "Complete" ? "已入库" : $"其他({q.STATUS})")
                });
            return new CustSupplyInOutput() { result = JsonConvert.SerializeObject(incompleteList) };
        }
    }
}
Tiger.Business.WMS/Minsun/Shelf.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,557 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Newtonsoft.Json;
using Rhea.Common.Authorization;
using Newtonsoft.Json.Linq;
using Tiger.Model.Minsun;
using System.Globalization;
using System.Data;
using System.Text.RegularExpressions;
using System.Text;
using System.DirectoryServices.ActiveDirectory;
using Dm;
using Tiger.Model.DigitalTwin;
using System.IO;
using System.Net;
using Rhea.Common;
using static Tiger.Model.Minsun.IqcManagementSides;
namespace Tiger.Business.WMS
{
    public static partial class Shelf
    {
        public static long UserId { get; set; }
        public static string _shelfApiUrl { get; set; } = GetSysCodeText("ShelfSetting", "ShelfApiUrl");
        private static string _shelfLightColor { get; set; } = GetSysCodeText("ShelfSetting", "ShelfLightColor");
        /// <summary>
        /// ä¸Šæž¶
        /// </summary>
        /// <param name="operateInput"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfOperateOutput>> UpShelf(ShelfOperateInput operateInput)
        {
            Result<ShelfOperateOutput> result = new(Result.Flags.Success, $"成功上架");
            string uniqueID = Guid.NewGuid().ToString();
            // 1. å‘送上架指令
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data1 = new
            {
                shelfNo = operateInput.ShelfNo,
                operateType = 1,
                pdaid = string.IsNullOrEmpty(operateInput.PdaId) ? UserId.ToString() : operateInput.PdaId,
                keepSeconds = 30,
                uniqueNumber = uniqueID
            };
            string apiUrl1 = _shelfApiUrl + "/OperateConfig";
            var jsonString1 = JsonConvert.SerializeObject(data1);
            Result<JObject> result1 = await PostShelfApi(apiUrl1, jsonString1);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            JObject resp1 = result1.Data;
            ShelfApiResult apiResult = new ShelfApiResult();
            apiResult.IsSuccess = resp1["OperateConfigResult"]["IsSuccess"].ToString();
            apiResult.ItemCode = resp1["OperateConfigResult"]["ItemCode"].ToString();
            apiResult.ResultValue = resp1["OperateConfigResult"]["ResultValue"].ToString();
            apiResult.Type = resp1["OperateConfigResult"]["Type"].ToString();
            //定义返回参数
            ShelfOperateOutput shelfOperateOutput = new ShelfOperateOutput();
            // å¦‚果上架操作指令成功
            if (apiResult.IsSuccess.ToUpper() == "TRUE")
            {
                // 2. å‘送 GetOperateChuteChangeInfo æŒ‡ä»¤ï¼ŒèŽ·å–ä¸Šæž¶ä½ç½®ï¼ˆledAddr)及 uniqueNumber
                // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
                var data2 = new
                {
                    shelfNo = operateInput.ShelfNo,
                    operateType = operateInput.OperateType
                };
                string apiUrl2 = _shelfApiUrl + "/GetOperateChuteChangeInfo";
                var jsonString2 = JsonConvert.SerializeObject(data2);
                shelfOperateOutput.IsSuccess = "FALSE";
                DateTime timeStart = DateTime.Now;
                TimeSpan timeSpan = DateTime.Now - timeStart;
                while (shelfOperateOutput.IsSuccess.ToUpper() != "TRUE" && timeSpan.TotalSeconds < 30)
                {
                    DateTime timeEnd = DateTime.Now;
                    timeSpan = DateTime.Now - timeStart;
                    Result<JObject> result2 = await PostShelfApi(apiUrl2, jsonString2);
                    if (result2.Flag == Result.Flags.Success)
                    {
                        JObject resp2 = result2.Data;
                        shelfOperateOutput.IsSuccess = resp2["GetOperateChuteChangeInfoResult"]["IsSuccess"].ToString();
                        string resultValue = resp2["GetOperateChuteChangeInfoResult"]["ResultValue"].ToString();
                        if (shelfOperateOutput.IsSuccess.ToUpper() == "TRUE" && !String.IsNullOrEmpty(resultValue))
                        {
                            JObject jo = JObject.Parse(resultValue);
                            shelfOperateOutput.ShelfNo = jo["shelfNo"].ToString();
                            shelfOperateOutput.OperateType = jo["operateType"].ToString();
                            shelfOperateOutput.LedAddr = jo["ledAddr"].ToString();
                            shelfOperateOutput.PdaId = jo["pdaid"].ToString();
                            shelfOperateOutput.UniqueNumber = jo["uniqueNumber"].ToString();
                            if (uniqueID != shelfOperateOutput.UniqueNumber)
                            {
                                shelfOperateOutput.IsSuccess = "False";
                                shelfOperateOutput.Message = "UniqueNumber ä¸åŒ";
                            };
                            if (operateInput.ShelfNo != shelfOperateOutput.ShelfNo)
                            {
                                shelfOperateOutput.IsSuccess = "False";
                                shelfOperateOutput.Message = "ShelfNo ä¸åŒ";
                            };
                        }
                    }
                }
                // 3. ç»“束上架
                var data3 = new
                {
                    shelfNo = data1.shelfNo,
                    operateType = 7,
                    pdaid = data1.pdaid,
                    keepSeconds = 30,
                    uniqueNumber = data1.uniqueNumber,
                };
                string apiUrl3 = _shelfApiUrl + "/OperateConfig";
                var jsonString3 = JsonConvert.SerializeObject(data3);
                Result<JObject> result3 = await PostShelfApi(apiUrl3, jsonString3);
                if (result3.Flag != Result.Flags.Success)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = result3.Message;
                    return result;
                }
                JObject resp3 = result3.Data;
                if (timeSpan.TotalSeconds >= 30)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"上架操作超时";
                    return result;
                }
            }
            // æ›´æ–°åº“位代码,LocationCode
            WMS_LOCATION locOut = await Biz.Db.Queryable<WMS_LOCATION>().Where(t => t.RACKCODE == shelfOperateOutput.ShelfNo
                                     && t.LedAddr.ToString() == shelfOperateOutput.LedAddr).FirstAsync();
            if (locOut != null)
                shelfOperateOutput.LocationCode = locOut.LOCATIONCODE;
            result.Data = shelfOperateOutput;
            return result;
        }
        // è¯»å–数据字典,根据CodeType,CodeValue获取参数Text
        private static string GetSysCodeText(string codeType, string codeValue)
        {
            var code = Biz.Db.Queryable<Sys_Code>().Where(x => x.CodeType.ToUpper() == codeType && x.Value.ToUpper() == codeValue).First();
            return code?.Text;
        }
        // Http Post ShelfApi
        private static async Task<Result<JObject>> PostShelfApi(string apiUrl, string strJson)
        {
            Result<JObject> result = new(Result.Flags.Success, $"货架API返回成功");
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(apiUrl);
            httpWebRequest.ContentType = "application/json;charset=utf-8";
            httpWebRequest.Method = "POST";
            httpWebRequest.Timeout = 10000;
            byte[] btBodys = Encoding.UTF8.GetBytes(strJson);
            httpWebRequest.ContentLength = btBodys.Length;
            //Logger.Default.Info(string.Format("智能货架:开始请求{0},参数{1}", apiUrl, strJson));
            try
            {
                httpWebRequest.GetRequestStream().Write(btBodys, 0, btBodys.Length);
            }
            catch (Exception ex)
            {
                Logger.Default.Info(string.Format("智能货架:请求异常;返回信息:{0}", JsonConvert.SerializeObject(ex)));
                result.Flag = Result.Flags.Failed;
                result.Message = $"智能货架:请求异常;返回信息:{JsonConvert.SerializeObject(ex)}";
                return result;
            }
            HttpWebResponse httpResponse;
            string respnsetContent;
            try
            {
                httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                if (httpResponse.StatusCode != HttpStatusCode.OK)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"智能货架API通讯异常,请检查货架是否正常";
                    return result;
                }
                StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream());
                respnsetContent = streamReader.ReadToEnd();
                httpResponse.Close();
                streamReader.Close();
                httpWebRequest.Abort();
                //Logger.Default.Info(string.Format("智能货架:请求成功;返回信息:{0}", respnsetContent));
            }
            catch (Exception ex)
            {
                Logger.Default.Info(string.Format("智能货架:请求异常;返回信息:{0}", JsonConvert.SerializeObject(ex)));
                //不捕获指令发出后的异常
                result.Flag = Result.Flags.Failed;
                result.Message = $"智能货架:请求异常;返回信息:{JsonConvert.SerializeObject(ex)}";
                return result;
            }
            JObject jo = JObject.Parse(respnsetContent);
            result.Data = jo;
            return result;
        }
        #region è´§æž¶äº®ç¯
        /// <summary>
        /// å…¨éƒ¨äº®ç¯
        /// </summary>
        /// <param name="lightParam"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfApiResult>> LightAll(ShelfLightParam lightParam)
        {
            Result<ShelfApiResult> result = new(Result.Flags.Success, $"全部亮灯成功");
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data = new
            {
                shelfNo = lightParam.ShelfNo,
                color = lightParam.LightColor,
                isCover = lightParam.IsCover,
                shelfType = "sensor_shelf"
            };
            string apiUrl = _shelfApiUrl + "/LightAll";
            var jsonString = JsonConvert.SerializeObject(data);
            Result<JObject> result1 = await PostShelfApi(apiUrl, jsonString);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            result.Data = new ShelfApiResult
            {
                LightType = "Light All",
                IsSuccess = result1.Data["LightAllResult"]["IsSuccess"].ToString(),
                ItemCode = result1.Data["LightAllResult"]["ItemCode"].ToString(),
                ResultValue = result1.Data["LightAllResult"]["ResultValue"].ToString(),
                Type = result1.Data["LightAllResult"]["Type"].ToString(),
            };
            return result;
        }
        /// <summary>
        /// å…¨éƒ¨ç­ç¯
        /// </summary>
        /// <param name="lightParam"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfApiResult>> DownAll(ShelfLightParam lightParam)
        {
            Result<ShelfApiResult> result = new(Result.Flags.Success, $"全部灭灯成功");
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data = new
            {
                shelfNo = lightParam.ShelfNo,
                shelfType = "sensor_shelf"
            };
            string apiUrl = _shelfApiUrl + "/DownAll";
            var jsonString = JsonConvert.SerializeObject(data);
            Result<JObject> result1 = await PostShelfApi(apiUrl, jsonString);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            result.Data = new ShelfApiResult
            {
                LightType = "Down All",
                IsSuccess = result1.Data["DownAllResult"]["IsSuccess"].ToString(),
                ItemCode = result1.Data["DownAllResult"]["ItemCode"].ToString(),
                ResultValue = result1.Data["DownAllResult"]["ResultValue"].ToString(),
                Type = result1.Data["DownAllResult"]["Type"].ToString(),
            };
            return result;
        }
        /// <summary>
        /// å•灯亮
        /// </summary>
        /// <param name="lightParam"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfApiResult>> LightSingle(ShelfLightParam lightParam)
        {
            Result<ShelfApiResult> result = new(Result.Flags.Success, $"单灯亮成功");
            //如果参数传入LocationCode
            var nLocation = await Biz.Db.Queryable<WMS_LOCATION>().Where(t => t.LOCATIONCODE == lightParam.LocationCode).FirstAsync();
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data = new
            {
                shelfNo = lightParam.ShelfNo,
                ledAddr = (nLocation == null) ? lightParam.LedAddr : nLocation.LedAddr.ToString(),
                color = lightParam.LightColor.IsNullOrEmpty() ? _shelfLightColor : lightParam.LightColor,
                isCover = lightParam.IsCover.IsNullOrEmpty() ? "1" : lightParam.IsCover,
                shelfType = "sensor_shelf"
            };
            string apiUrl = _shelfApiUrl + "/LightSingle";
            var jsonString = JsonConvert.SerializeObject(data);
            Result<JObject> result1 = await PostShelfApi(apiUrl, jsonString);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            result.Data = new ShelfApiResult
            {
                LightType = "Light Single",
                IsSuccess = result1.Data["LightSingleResult"]["IsSuccess"].ToString(),
                ItemCode = result1.Data["LightSingleResult"]["ItemCode"].ToString(),
                ResultValue = result1.Data["LightSingleResult"]["ResultValue"].ToString(),
                Type = result1.Data["LightSingleResult"]["Type"].ToString(),
            };
            return result;
        }
        /// <summary>
        /// å•灯灭
        /// </summary>
        /// <param name="lightParam"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfApiResult>> DownSingle(ShelfLightParam lightParam)
        {
            Result<ShelfApiResult> result = new(Result.Flags.Success, $"单灯灭成功");
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data = new
            {
                shelfNo = lightParam.ShelfNo,
                ledAddr = lightParam.LedAddr,
                shelfType = "sensor_shelf"
            };
            string apiUrl = _shelfApiUrl + "/DownSingle";
            var jsonString = JsonConvert.SerializeObject(data);
            Result<JObject> result1 = await PostShelfApi(apiUrl, jsonString);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            result.Data = new ShelfApiResult()
            {
                LightType = "Down Single",
                IsSuccess = result1.Data["DownSingleResult"]["IsSuccess"].ToString(),
                ItemCode = result1.Data["DownSingleResult"]["ItemCode"].ToString(),
                ResultValue = result1.Data["DownSingleResult"]["ResultValue"].ToString(),
                Type = result1.Data["DownSingleResult"]["Type"].ToString(),
            };
            return result;
        }
        /// <summary>
        /// å¤šç¯äº®
        /// </summary>
        /// <param name="lightParam"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfApiResult>> LightMulti(ShelfLightParam lightParam)
        {
            Result<ShelfApiResult> result = new(Result.Flags.Success, $"多灯亮成功");
            // åº“位列表 LedAddrList
            List<Object> ledList = new List<object>();
            foreach (string led_addr in lightParam.LedAddrList)
            {
                //ledList.Add(new { ledAddr = led_addr, uniqueNumber = "" });
                ledList.Add(new { ledAddress = led_addr, uniqueNumber = "" });
            }
            // è´§æž¶åº“位列表
            List<Object> shelfLedAddr = new List<Object>();
            shelfLedAddr.Add(
                new
                {
                    shelfNo = lightParam.ShelfNo,
                    shelfType = "sensor_shelf",
                    ledAddressList = ledList
                }
            );
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data = new
            {
                shelfLedAddressList = shelfLedAddr,
                parameters = new
                {
                    pdaId = "WMS_PDA",
                    orderCode = "WMS_PDA",
                    userItem1 = "",
                    userItem2 = "",
                    userItem3 = "",
                    userItem4 = "",
                    userItem5 = "",
                },
                operateType = 0,
                color = lightParam.LightColor.IsNullOrEmpty() ? _shelfLightColor : lightParam.LightColor,
                isCover = lightParam.IsCover.IsNullOrEmpty() ? "1" : lightParam.IsCover,
            };
            string apiUrl = _shelfApiUrl + "/LightMulti";
            var jsonString = JsonConvert.SerializeObject(data);
            Result<JObject> result1 = await PostShelfApi(apiUrl, jsonString);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            result.Data = new ShelfApiResult
            {
                LightType = "Light Multi",
                IsSuccess = result1.Data["LightMultiResult"]["IsSuccess"].ToString(),
                ItemCode = result1.Data["LightMultiResult"]["ItemCode"].ToString(),
                ResultValue = result1.Data["LightMultiResult"]["ResultValue"].ToString(),
                Type = result1.Data["LightMultiResult"]["Type"].ToString(),
            };
            return result;
        }
        /// <summary>
        /// å¤šç¯ç­
        /// </summary>
        /// <param name="lightParam"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfApiResult>> DownMulti(ShelfLightParam lightParam)
        {
            Result<ShelfApiResult> result = new(Result.Flags.Success, $"多灯灭成功");
            // åº“位列表 LedAddrList
            List<Object> ledList = new List<object>();
            foreach (string led_addr in lightParam.LedAddrList)
            {
                //ledList.Add(new { ledAddr = led_addr, uniqueNumber = "" });
                ledList.Add(new { ledAddress = led_addr, uniqueNumber = "" });
            }
            // è´§æž¶åº“位列表
            List<Object> shelfLedAddr = new List<Object>();
            shelfLedAddr.Add(
                new
                {
                    shelfNo = lightParam.ShelfNo,
                    shelfType = "sensor_shelf",
                    ledAddressList = ledList
                }
            );
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data = new
            {
                shelfLedAddressList = shelfLedAddr,
                parameters = new
                {
                    pdaId = "",
                    orderCode = "",
                    userItem1 = "",
                    userItem2 = ""
                },
                operateType = lightParam.OperateType,
                color = lightParam.LightColor,
                isCover = lightParam.IsCover,
            };
            string apiUrl = _shelfApiUrl + "/DownMulti";
            var jsonString = JsonConvert.SerializeObject(data);
            Result<JObject> result1 = await PostShelfApi(apiUrl, jsonString);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            result.Data = new ShelfApiResult
            {
                LightType = "Down Multi",
                IsSuccess = result1.Data["DownMultiResult"]["IsSuccess"].ToString(),
                ItemCode = result1.Data["DownMultiResult"]["ItemCode"].ToString(),
                ResultValue = result1.Data["DownMultiResult"]["ResultValue"].ToString(),
                Type = result1.Data["DownMultiResult"]["Type"].ToString(),
            };
            return result;
        }
        /// <summary>
        /// æ“ä½œè´§æž¶ç¯å¡”
        /// </summary>
        /// <param name="lightParam"></param>
        /// <returns></returns>
        public static async Task<Result<ShelfApiResult>> OperateTowerLight(ShelfLightParam lightParam)
        {
            Result<ShelfApiResult> result = new(Result.Flags.Success, $"多灯灭成功");
            // å‡†å¤‡ POST è¯·æ±‚ body å‚æ•°
            var data = new
            {
                shelfNo = lightParam.ShelfNo,
                color = 3,
                operEnum = lightParam.OperEnum,
                shelfType = "sensor_shelf"
            };
            string apiUrl = _shelfApiUrl + "/OperateTowerLight";
            var jsonString = JsonConvert.SerializeObject(data);
            Result<JObject> result1 = await PostShelfApi(apiUrl, jsonString);
            if (result1.Flag != Result.Flags.Success)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = result1.Message;
                return result;
            }
            result.Data = new ShelfApiResult
            {
                LightType = "Operate TowerLight",
                IsSuccess = result1.Data["OperateTowerLightResult"]["IsSuccess"].ToString(),
                ItemCode = result1.Data["OperateTowerLightResult"]["ItemCode"].ToString(),
                ResultValue = result1.Data["OperateTowerLightResult"]["ResultValue"].ToString(),
                Type = result1.Data["OperateTowerLightResult"]["Type"].ToString()
            };
            return result;
        }
        #endregion
    }
}
Tiger.Business.WMS/Minsun/iWMS.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,1854 @@
using Rhea.Common;
using Tiger.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Newtonsoft.Json;
using Rhea.Common.Authorization;
using Newtonsoft.Json.Linq;
using Tiger.Model.Minsun;
using System.Globalization;
using System.Data;
using System.Text.RegularExpressions;
using System.Text;
using System.DirectoryServices.ActiveDirectory;
using Dm;
using System.Reflection;
using Apache.NMS.ActiveMQ.Commands;
using Apache.NMS;
using System.Configuration;
using System.Reflection.PortableExecutable;
using Tiger.Business.WMS.Transaction;
using System.Threading;
using System.Drawing.Drawing2D;
using System.Collections;
using Tiger.IBusiness;
using Autofac;
namespace Tiger.Business.WMS
{
    public partial class iWMS
    {
        /// <summary>
        ///
        /// </summary>
        /// <summary>
        /// ç‰©æ–™åŒ…装管理    ç‰©æ–™åŒ…装层级:小包归属于哪个中包、中包归属于哪个外包  wms_barcode æœ‰
        /// </summary>
        /// <param name="sn"></param>
        /// <returns></returns>
        public List<iPackageInfo> GetPackageInfo(string sn)
        {
            var query = new List<iPackageInfo>();
            return query;
        }
        /// <summary>
        /// ç‰©æ–™å…¥åº“信息    ç‰©æ–™åç§°ã€ç‰©æ–™ä»£ç ã€ç‰©æ–™ä¾›åº”商、数量、库位、储位、批次、入库时间
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<iInStoreInfo> GetInStoreInfo(iParams param)
        {
            var query = Biz.Db.Queryable<WMS_STORAGELOTINFO, WMS_BARCODE, WMS_BARCODE_LOG, WMS_MesMaterial>((t, b, l, m) =>
                                new JoinQueryInfos(
                                    JoinType.Left, t.BARCODE == b.BARCODE,
                                    JoinType.Left, t.BARCODE == l.BARCODE,
                                    JoinType.Left, t.MATERIALCODE == m.MCode
                                    ))
            .Where((t, b, l, m) => l.INOUTTYPE == 10)
            .WhereIF(!string.IsNullOrEmpty(param.sn), (t, b, l, m) => t.BARCODE == param.sn)
            .WhereIF(!string.IsNullOrEmpty(param.startDate), (t, b, l, m) => l.CreationTime >= Convert.ToDateTime(param.startDate))
            .WhereIF(!string.IsNullOrEmpty(param.endDate), (t, b, l, m) => l.CreationTime < Convert.ToDateTime(param.endDate))
            .Select((t, b, l, m) => new iInStoreInfo
            {
                sn = t.BARCODE,
                MaterialCode = t.MATERIALCODE,
                MaterialName = m.MDesc,
                VendorCode = b.SUPPLIERCODE,
                WarehouseCode = t.WAREHOUSECODE,
                LocationCode = t.LOCATIONCODE,
                LotNo = b.LOTNO,
                SourceCode = b.SOURCEBARCODE,
                QTY = t.QTY,
                CreateDate = l.CreationTime,
                UpdateDate = l.LastModificationTime
            })
            .ToList();
            return query;
        }
        /// <summary>
        /// ç‰©æ–™å‡ºåº“信息    é¢†æ–™å•号、领料料号、数量、库位、储位、出库时间
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<iOutStoreInfo> GetOutStoreInfo(iParams param)
        {
            var query = Biz.Db.Queryable<WMS_BARCODE_LOG, WMS_MesMaterial>((t, m) =>
                                new JoinQueryInfos(
                                    JoinType.Left, t.MATERIALCODE == m.MCode
                                    ))
            .Where((t, m) => t.INOUTTYPE == 20 && !SqlFunc.IsNullOrEmpty(t.BILLCODE))
            .WhereIF(!string.IsNullOrEmpty(param.sn), (t, m) => t.BARCODE == param.sn)
            .WhereIF(!string.IsNullOrEmpty(param.startDate), (t, m) => t.CreationTime >= Convert.ToDateTime(param.startDate))
            .WhereIF(!string.IsNullOrEmpty(param.endDate), (t, m) => t.CreationTime < Convert.ToDateTime(param.endDate))
            .Select((t, m) => new iOutStoreInfo
            {
                sn = t.BARCODE,
                MaterialCode = t.MATERIALCODE,
                MaterialName = m.MDesc,
                WarehouseCode = t.WAREHOUSECODE,
                LocationCode = t.LOCATIONCODE,
                BillCode = t.BILLCODE,
                QTY = t.QTY,
                CreateDate = t.CreationTime,
                UpdateDate = t.LastModificationTime
            })
            .ToList();
            return query;
        }
        /// <summary>
        /// ç‰©æ–™é€€æ–™ä¿¡æ¯    é€€æ–™æ–™å·ã€é€€æ–™æ—¶é—´ã€é€€æ–™æ¡ç ã€é€€æ–™åº“位、称重清点结果
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<iReturnInfo> GetReturnInfo(iParamsBase param)
        {
            var query = Biz.Db.Queryable<WMS_BARCODE_LOG, WMS_MesMaterial>((t, m) =>
                                new JoinQueryInfos(
                                    JoinType.Left, t.MATERIALCODE == m.MCode
                                    ))
                .Where(t => t.SOURCEBILLTYPE == 25)
                .WhereIF(!string.IsNullOrEmpty(param.startDate), (t, m) => t.CreationTime >= Convert.ToDateTime(param.startDate))
                .WhereIF(!string.IsNullOrEmpty(param.endDate), (t, m) => t.CreationTime < Convert.ToDateTime(param.endDate))
                .Select((t, m) => new iReturnInfo
                {
                    sn = t.BARCODE,
                    MaterialCode = t.MATERIALCODE,
                    MaterialName = m.MDesc,
                    WarehouseCode = t.WAREHOUSECODE,
                    CreateDate = t.CreationTime
                })
                .ToList();
            return query;
        }
        /// <summary>
        /// ç‰©æ–™åº“存信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<iStorageInfo> GetStorageInfo(iParamsBase param)
        {
            var query = Biz.Db.Queryable<WMS_STORAGELOTINFO, WMS_BARCODE, WMS_MesMaterial, MesVender>((t, b, m, v) =>
                                new JoinQueryInfos(
                                    JoinType.Left, t.BARCODE == b.BARCODE,
                                    JoinType.Left, t.MATERIALCODE == m.MCode,
                                    JoinType.Left, b.SUPPLIERCODE == v.VenderCode
                                    ))
            .WhereIF(!string.IsNullOrEmpty(param.startDate), (t, b, m, v) => t.CreationTime >= Convert.ToDateTime(param.startDate))
            .WhereIF(!string.IsNullOrEmpty(param.endDate), (t, b, m, v) => t.CreationTime < Convert.ToDateTime(param.endDate))
            .Select((t, b, m, v) => new iStorageInfo
            {
                MaterialCode = t.MATERIALCODE,
                MaterialName = m.MDesc,
                VenderCode = b.SUPPLIERCODE,
                VenderName = v.VenderName,
                Unit = m.MUom,
                QTY = t.QTY,
                UpdateDate = t.LastModificationTime ?? t.CreationTime
            })
            .ToList();
            return query;
        }
        /// <summary>
        /// å¤‡æ–™åˆ†åŒ…装信息    æ‹†åŒ…备料,重新组包的包装号关系:拆包编号、组包后编号、组包后数量、备领料单号、料号
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<iSplitInfo> GetSplitInfo(iParams param)
        {
            var query = Biz.Db.Queryable<WMS_BARCODE, WMS_MesMaterial>((t, m) =>
                                new JoinQueryInfos(
                                    JoinType.Left, t.MATERIALCODE == m.MCode
                                    ))
            .WhereIF(!string.IsNullOrEmpty(param.sn), (t, m) => t.BARCODE.Contains(param.sn))
            .WhereIF(!string.IsNullOrEmpty(param.startDate), (t, m) => t.CreationTime >= Convert.ToDateTime(param.startDate))
            .WhereIF(!string.IsNullOrEmpty(param.endDate), (t, m) => t.CreationTime < Convert.ToDateTime(param.endDate))
            .Select((t, m) => new iSplitInfo
            {
                sn = t.BARCODE,
                MaterialCode = t.MATERIALCODE,
                MaterialName = m.MDesc,
                ParentBoxBarcode = t.PARENTBOXBARCODE,
                SourceCode = t.SOURCECODE,
                QTY = t.PACKQTY,
                UpdateDate = t.LastModificationTime
            })
            .ToList();
            return query;
        }
        private static readonly IReceiptInfo _IReceiptInfo = BizContext.Container.Resolve<IReceiptInfo>();
        /// <summary>
        /// åˆ°è´§å•生成接口    æ¸…点系统 --> wms,  æŽ¥å£éœ€wms定义
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public ApiAction GenerateReceipt(iReceiptInput input)
        {
            var action = new ApiAction();
            bool isIQCOk = true;
            try
            {
                string msg = "";
                if (!input.iReceipts.Any())
                {
                    action.IsSuccessed = false;
                    msg += $"{msg.IsNullOrEmpty("", ";")}没有可以提交的清点数据";
                    action.Message = msg;
                    return action;
                }
                var judian = BizConfig.Configuration["JuDian"];
                var requestJson = JsonConvert.SerializeObject(input);
                var response = HttpHelper.PostAsync("http://172.18.8.56:9631/api/WMS/GenerateReceiptNew/", requestJson).Result;
                action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                return action;
                //if (input.StrongHold != judian)
                //{
                //    var requestJson = JsonConvert.SerializeObject(input);
                //    //if (input.StrongHold == "AHXC")
                //    //{
                //    //    var response = HttpHelper.PostAsync("http://172.18.8.56:9529/api/WMS/GenerateReceipt", requestJson).Result;
                //    //    action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                //    //    return action;
                //    //}
                //    if (input.StrongHold == "DGXC" || input.StrongHold == "AHXC")
                //    {
                //        //return _IReceiptInfo.GenerateReceipt(input);
                //        var response = HttpHelper.PostAsync("http://172.18.8.56:9631/api/WMS/GenerateReceiptNew/", requestJson).Result;
                //        action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                //        return action;
                //    }
                //    if (input.StrongHold == "XCSJ")
                //    {
                //        var response = HttpHelper.PostAsync("http://172.18.8.56:9527/api/WMS/GenerateReceipt/", requestJson).Result;
                //        action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                //        return action;
                //    }
                //}
                var usercode = "00000";
                switch (input.CompanyCode)
                {
                    case "XCQX":
                        usercode = "LX0001";
                        break;
                    case "XCHF":
                        usercode = "AA0001";
                        break;
                    case "XCTH":
                        //usercode = "AA0001";
                        break;
                    case "XCTX":
                        usercode = "TA0001";
                        break;
                }
                //待提交数据按来源单号分组(ASN/PO)
                var srcBills = input.iReceipts
                        .Select(p => new { BillCode = p.DeliveryNo })
                        .GroupBy(p => p.BillCode)
                        .ToList();
                List<WMS_RECEIPT_H> receiptHeaders = new List<WMS_RECEIPT_H>();
                List<WMS_RECEIPT_D> receiptDetails = new List<WMS_RECEIPT_D>();
                List<WMS_RECEIPT_SCAN> receiptScans = new List<WMS_RECEIPT_SCAN>();
                List<Detail> details = new List<Detail>();
                List<WMS_IQC_H> iqcHeaders = new List<WMS_IQC_H>();
                List<WMS_PO_D> poDetails = new List<WMS_PO_D>();
                int billid = 1;
                foreach (var srcBill in srcBills)
                {
                    var asnHeader = Biz.Db.Queryable<WMS_SRM_ASN>().Where(x => x.DeliveryNo == srcBill.Key).First();
                    if (asnHeader == null)
                    {
                        action.IsSuccessed = false;
                        msg += $"{msg.IsNullOrEmpty("", ";")}SRM中查不到数据";
                        action.Message = msg;
                        return action;
                    }
                    //获取ASN行明细
                    var asnLines = Biz.Db.Queryable<WMS_SRM_ASN_LINES>().Where(x => x.DeliveryNo == srcBill.Key).ToList();
                    if (asnLines == null)
                    {
                        action.IsSuccessed = false;
                        msg += $"{msg.IsNullOrEmpty("", ";")}SRM中查不到ASN行明细";
                        action.Message = msg;
                        return action;
                    }
                    var asnBarcodeList = Biz.Db.Queryable<WMS_SRMSNList>().Where(x => x.DeliveryNo == srcBill.Key).ToList();
                    if (asnBarcodeList == null)
                    {
                        action.IsSuccessed = false;
                        msg += $"{msg.IsNullOrEmpty("", ";")}SRM中查不到ASN行明细";
                        action.Message = msg;
                        return action;
                    }
                    if (asnBarcodeList.Count > input.iReceipts.Where(x => x.DeliveryNo == srcBill.Key).ToList().Count)
                    {
                        action.IsSuccessed = false;
                        msg += $"{msg.IsNullOrEmpty("", ";")}送货单[{srcBill.Key}]还有条码未扫描清点,不能生成到货单";
                        action.Message = msg;
                        return action;
                    }
                    if (Biz.Db.Queryable<WMS_RECEIPT_SCAN>().Where(x => x.BILLCODE == srcBill.Key).Any())
                    {
                        action.IsSuccessed = false;
                        msg += $"{msg.IsNullOrEmpty("", ";")}送货单[{srcBill.Key}]已经扫描过不能再扫描";
                        action.Message = msg;
                        return action;
                    }
                    List<string> asnLinesNum = new List<string>();
                    asnLinesNum = asnLines.Select(x => x.productCode).Distinct().ToList();
                    List<string> tempBarcodesNum = new List<string>();
                    tempBarcodesNum = input.iReceipts.Where(x => x.DeliveryNo == srcBill.Key).ToList().Select(x => x.MaterialCode).Distinct().ToList();
                    if (asnLinesNum.Count > tempBarcodesNum.Count)
                    {
                        action.IsSuccessed = false;
                        msg += $"{msg.IsNullOrEmpty("", ";")}送货单[{srcBill.Key}]还有料号未扫描清点,不能生成到货单";
                        return action;
                    }
                    msg += $"{msg.IsNullOrEmpty("", ";")}送货单[{srcBill.Key}]总数[{asnBarcodeList.Count}],扫描总数[{input.iReceipts.Where(x => x.DeliveryNo == srcBill.Key).ToList().Count}]";
                    // ç”Ÿæˆæ”¶æ–™å•
                    // æ–°å»ºä¸€ä¸ª Header
                    var nReceiptHeader = new WMS_RECEIPT_H
                    {
                        BILLCODE = GetBillNoByType("RECEIPT"),
                        BILLDATE = DateTime.Now,
                        STATUS = (int)WMS_RECEIPT_H.ReceiptStatus.Add,
                        BIZTYPE = (int)WMS_RECEIPT_H.ReceiptBizType.PO,
                        SUPPLIERCODE = asnHeader.innerVendorCode,
                        CreationTime = DateTime.Now,
                        CreatorUserId = 1
                    };
                    var nHeaderId = Biz.Db.Insertable(nReceiptHeader).ExecuteReturnBigIdentity();
                    nReceiptHeader.Id = nHeaderId;
                    // ç”Ÿæˆæ”¶æ–™å•行明细
                    var nLineSeq = 1;
                    foreach (var asnLine in asnLines)
                    {
                        //订单物料行(唯一)
                        int poline = Convert.ToInt32(asnLine.poLineNo.Split('-')[0]);
                        var nOrderDetail = Biz.Db.Queryable<WMS_PO_D>().Where(x => x.BILLCODE.ToUpper() == asnLine.poErpNo.ToUpper() && x.BILLLINE == poline).First();
                        if (asnBarcodeList == null)
                        {
                            action.IsSuccessed = false;
                            msg += $"{msg.IsNullOrEmpty("", ";")}订单中查不到数据";
                            return action;
                        }
                        nOrderDetail.ARRIVALQTY = (nOrderDetail.ARRIVALQTY ?? 0) + asnLine.deliveryQty;
                        poDetails.Add(nOrderDetail);
                        //插入收料单行
                        var nReceiptDetail = new WMS_RECEIPT_D
                        {
                            BILLCODE = nReceiptHeader.BILLCODE,
                            BILLLINE = nLineSeq++,
                            BILLID = nHeaderId,
                            LINESTATUS = (int)WMS_RECEIPT_H.ReceiptLineStatus.Add,
                            MATERIALCODE = asnLine.productCode,
                            UNITCODE = "",
                            QTY = asnLine.deliveryQty,
                            QTYPASS = 0,
                            INSTOCKQTY = 0,
                            RETURNQTY = 0,
                            PRINTQTY = 0,
                            ISGIVEAWAY = false,
                            SOURCETYPE = (int)WMS_RECEIPT_H.SourceType.Asn,
                            SOURCECODE = asnLine.DeliveryNo,
                            SOURCELINE = string.IsNullOrEmpty(asnLine.extendN01) ? asnLine.lineNo : Convert.ToInt32(asnLine.extendN01 ?? "0"), //asnLine.lineNo,
                            PONO = asnLine.poErpNo,
                            POLINE = poline,
                            LastModificationTime = DateTime.Now,
                            CreationTime = DateTime.Now,
                            CreatorUserId = 1
                        };
                        receiptDetails.Add(nReceiptDetail);
                        details.Add(new Detail
                        {
                            pmdtseq = nLineSeq.ToString(),
                            pmdt001 = string.IsNullOrEmpty(nReceiptDetail.PONO) ? asnLine.DeliveryNo : asnLine.poErpNo,
                            pmdt002 = asnLine.lineNo.ToString(), //string.IsNullOrEmpty(nReceiptDetail.PONO) ? asnLine.lineNo.ToString() : poline.ToString(), é‡‡è´­é¡¹æ¬¡
                            pmdt003 = "1",
                            pmdt004 = asnLine.poLineNo.Split('-').Length > 2 ? asnLine.poLineNo.Split('-')[2] : (asnLine.poLineNo ?? "1"), //采购分批序
                            pmdt006 = asnLine.productCode, //"K7015AA016141",
                                                           //pmdt018 = "创米科技",
                            pmdt020 = asnLine.deliveryQty.ToString(),  //"100.00000",
                            pmdtud011 = "0"
                        });
                        //创建送检单
                        Result<WMS_IQC_H> result = CreateIqcHeader(nReceiptDetail, "Y", Biz.Db);
                        if (result.Flag != Result.Flags.Success)
                        {
                            action.IsSuccessed = false;
                            action.Message = result.Message;
                            return action;
                        }
                        iqcHeaders.Add(result.Data);
                        billid++;
                    }
                    //var asnScanTemp = await _tempRepository.GetAll().Where(x => x.CreatorUserId == (AbpSession.UserId ?? 0) && x.BillCode.ToUpper() == srcBill.Key.ToUpper()).ToListAsync();
                    foreach (var scanTemp in input.iReceipts.Where(x => x.DeliveryNo == srcBill.Key).ToList())
                    {
                        WMS_RECEIPT_SCAN scanObj = new WMS_RECEIPT_SCAN
                        {
                            Id = Guid.NewGuid().ToString(),
                            BILLCODE = scanTemp.DeliveryNo,
                            BILLLINE = 0,
                            SOURCETYPE = (int)WMS_RECEIPT_H.SourceType.Asn,
                            MATERIALCODE = scanTemp.MaterialCode,
                            BARCODE = scanTemp.SmallBarcode,
                            SCAN_BARCODE = scanTemp.SCAN_BARCODE,
                            CARTON = scanTemp.BigBarcode,
                            PALLET = scanTemp.OuterBarcode,
                            SUPPLIERCODE = scanTemp.innerVendorCode,
                            DATECODE = DateTime.Now,
                            //LOTNO = scanTemp.LotNo,
                            SCANQTY = scanTemp.SCANQTY,
                            //UNIT = scanTemp.Unit,
                            //ISGIVEAWAY = scanTemp.IsGiveAway,
                            RECEIPTNO = nReceiptHeader.BILLCODE,
                            RECEIPTLINE = 0,
                            STATEFLAG = WMS_RECEIPT_H.ReceiptLineStatus.PreInstock.ToString(),
                            LastModificationTime = DateTime.Now,
                            CreationTime = DateTime.Now,
                            CreatorUserId = 1
                        };
                        receiptScans.Add(scanObj);
                    }
                    //调用T100接口生成到货单
                    var ret = ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                    {
                        parameter = new Parameter<Detail>
                        {
                            pmds000 = "1",
                            pmdsdocno = "3438",
                            pmdsdocdt = DateTime.Now.ToString("yyyy-MM-dd"), //"2023-04-26", //当天时间
                            pmds002 = usercode, // "00000", //UserCode == "admin" ? "00000" : UserCode, //"L36783", //用户ID
                            pmds003 = "",
                            pmds007 = nReceiptHeader.SUPPLIERCODE, //"C0006", //供应商代码
                            pmds010 = srcBill.Key, //"测试客供料无采购收货", //送货单号
                                                   //pmdsud001 = SecondVenderCode, //"CM017", //二级供应编号
                            detail = details
                        },
                        datakey = new Datakey
                        {
                            EntId = ApiConfig.IsTestServer ? "108" : "88",
                            CompanyId = input.StrongHold
                        }
                    });
                    if (ret.payload.std_data.execution.code == "0") //成功
                    {
                        nReceiptHeader.ERP_BILL_CODE = ret.payload.std_data.parameter.docno;
                        nReceiptHeader.STATUS = 3;
                        receiptHeaders.Add(nReceiptHeader);
                        action.Message += $"{action.Message.IsNullOrEmpty("", ";")}{ret.payload.std_data.execution.description},返回的收货单号:[{ret.payload.std_data.parameter.docno}]";
                        #region ç”Ÿæˆé€æ£€å•
                        foreach (var item in iqcHeaders)
                        {
                            var retIns = ErpT100.GenerateInspection(new InsInputParameter
                            {
                                parameter = new InsParameter
                                {
                                    pmdsdocno = ret.payload.std_data.parameter.docno,
                                    pmdsdocdt = DateTime.Now.ToString("yyyy-MM-dd"),
                                    pmdtseq = item.SOURCELINE.ToString(),
                                    pmdt020 = item.QCQTY.ToString(),
                                    qcbadocno = "3701",
                                },
                                datakey = new Datakey
                                {
                                    EntId = ApiConfig.IsTestServer ? "108" : "88",
                                    CompanyId = input.StrongHold
                                }
                            });
                            if (retIns.payload.std_data.execution.code != "0")
                            {
                                isIQCOk = false;
                                action.IsSuccessed = false;
                                action.Message = $"到货单[{ret.payload.std_data.parameter.docno}],当前用户[{usercode}],供应商编号[{nReceiptHeader.SUPPLIERCODE}],返回的信息:{retIns.payload.std_data.execution.description}"; ;
                                //return action;
                            }
                            else
                            {
                                action.Message += $"到货单[{ret.payload.std_data.parameter.docno}],当前用户[{usercode}],供应商编号[{nReceiptHeader.SUPPLIERCODE}],返回的信息:{retIns.payload.std_data.execution.description}";
                                item.ERP_BILL_CODE = retIns.payload.std_data.parameter.docno;
                            }
                        }
                        #endregion
                    }
                    else //失败
                    {
                        action.IsSuccessed = false;
                        action.Message = $"当前用户[{usercode}],供应商编号[{nReceiptHeader.SUPPLIERCODE}],返回的信息:{ret.payload.std_data.execution.description}";
                        return action;
                    }
                }
                var db = Business.Biz.Db;
                //保存到数据库
                var dbTran = db.UseTran(() =>
                {
                    if (receiptHeaders.Any())
                    {
                        db.Updateable(receiptHeaders, "system").ExecuteCommand();
                    }
                    if (poDetails.Any())
                    {
                        db.Updateable(poDetails, "system").ExecuteCommand();
                    }
                    if (receiptDetails.Any())
                    {
                        db.Insertable(receiptDetails, "system").ExecuteCommand();
                    }
                    if (receiptScans.Any())
                    {
                        db.Insertable(receiptScans, "system").ExecuteCommand();
                    }
                    if (action.IsSuccessed && isIQCOk)
                    {
                        db.Insertable(iqcHeaders).ExecuteCommand();
                    }
                });
                if (!dbTran.IsSuccess)
                {
                    if (receiptHeaders.Any())
                    {
                        db.Deleteable(receiptHeaders).ExecuteCommand();
                    }
                    action.GetResponse().CatchExceptionWithLog(dbTran.ErrorException, $"到货单生成异常");
                }
                action.Message += $"{msg.IsNullOrEmpty("", ";")}到货单和送检单生成成功!";
                return action;
            }
            catch (Exception ex)
            {
                return action.GetResponse().CatchExceptionWithLog(ex, $"到货单生成异常");
            }
        }
        private static readonly IProdMaterialReq _IProdMaterialReq = BizContext.Container.Resolve<IProdMaterialReq>();
        /// <summary>
        /// èŽ·å–T100领料单数据
        /// </summary>
        /// <param name="prd_hs"></param>
        /// <returns></returns>
        public ApiAction GetMaterialReq(List<WMS_PRDPICK_H> prd_hs)
        {
            var action = new ApiAction();
            try
            {
                if (prd_hs.Count > 0)
                {
                    Work.DoAsync(() =>
                    {
                        Logger.Interface.Info($"开始异步推送到新数据库");
                        _IProdMaterialReq.GetMaterialReq(prd_hs);
                    });
                    return action;
                    //var judian = BizConfig.Configuration["JuDian"];
                    //foreach (var group in prd_hs.Select(q => q.ENTERPRISECODE).Distinct())
                    //{
                    //    List<WMS_PRDPICK_H> entity_h = new();
                    //    List<WMS_PRDPICK_D> entity_d = new();
                    //    //查询出来的列表
                    //    List<WMS_PRDPICK_D> list_d = new();
                    //    DbClient db;
                    //    List<WMS_PRDPICK_H> dtls=new();
                    //    if (group == 88)
                    //    {
                    //        dtls = prd_hs.Where(q=>q.STRONGHOID== judian && q.ENTERPRISECODE==group).ToList();
                    //        db = Business.Biz.Db;
                    //        foreach (var ju in prd_hs.Where(q=>q.STRONGHOID!=judian).Select(q => q.STRONGHOID).Distinct())
                    //        {
                    //            if (ju == "AHXC")
                    //            {
                    //                var requestJson = JsonConvert.SerializeObject(prd_hs.Where(q => q.STRONGHOID == ju && q.ENTERPRISECODE == group).ToList());
                    //                var response = HttpHelper.PostAsync("http://172.18.8.56:9529/api/WMS/GetMaterialReq", requestJson).Result;
                    //                action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                    //            }
                    //            if (ju == "DGXC")
                    //            {
                    //                //var requestJson = JsonConvert.SerializeObject(prd_hs.Where(q => q.STRONGHOID == ju && q.ENTERPRISECODE == group).ToList());
                    //                //var response = HttpHelper.PostAsync("http://172.18.8.56:9528/api/WMS/GetMaterialReq/", requestJson).Result;
                    //                //action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                    //            }
                    //            if (ju == "XCSJ")
                    //            {
                    //                var requestJson = JsonConvert.SerializeObject(prd_hs.Where(q => q.STRONGHOID == ju && q.ENTERPRISECODE == group).ToList());
                    //                var response = HttpHelper.PostAsync("http://172.18.8.56:9527/api/WMS/GetMaterialReq/", requestJson).Result;
                    //                action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                    //            }
                    //        }
                    //    }
                    //    else
                    //    {
                    //        //dtls = prd_hs.Where(q =>  q.ENTERPRISECODE !=88 ).ToList();
                    //        db = Biz.DataSource["Test"].Client;
                    //    }
                    //    foreach (var item_h in dtls)
                    //    {
                    //        var prd_h = Biz.Db.Queryable<WMS_PRDPICK_H>().Where(s => s.BILLCODE == item_h.BILLCODE).Single();
                    //        if (prd_h?.STATUS != "COMPLETE")
                    //        {
                    //            prd_h = prd_h ?? new WMS_PRDPICK_H()
                    //            {
                    //                STATUS = "INIT",
                    //                BIZTYPE = "1",
                    //                CreationTime = DateTime.Now,
                    //                CreatorUserId = 1,
                    //            };
                    //            prd_h.BILLCODE = item_h.BILLCODE;
                    //            prd_h.BILLDATE = item_h.BILLDATE;
                    //            prd_h.SOURCETYPE = item_h.SOURCETYPE;
                    //            prd_h.STATUS = prd_h.STATUS == "DELETE"? "INIT": prd_h.STATUS;
                    //            prd_h.REMARK = item_h.REMARK;
                    //            prd_h.SOURCECODE = item_h.SOURCECODE;
                    //            prd_h.LastModificationTime = DateTime.Now;
                    //            //prd_h.ENTERPRISECODE = item_h.ENTERPRISECODE;
                    //            //prd_h.STRONGHOID = item_h.STRONGHOID;
                    //            entity_h.Add(prd_h);
                    //        }
                    //    }
                    //    //保存到数据库
                    //    var dbTran = db.UseTran(() =>
                    //    {
                    //        db.Storageable(entity_h, "system").ExecuteCommand();
                    //    });
                    //    if (!dbTran.IsSuccess)
                    //    {
                    //        action.CatchExceptionWithLog(dbTran.ErrorException, $"数据保存失败");
                    //    }
                    //    //异步拉取单身列表
                    //    Work.DoAsync(() =>
                    //    {
                    //        GenerateReqDetail(dtls,db);
                    //    });
                    //    action.Message += $"拉取领料单单头完成,调用异步拉单身。";
                    //}
                }
                return action;
            }
            catch (Exception ex)
            {
                return action.GetResponse().CatchExceptionWithLog(ex, $"领料单生成异常");
            }
        }
        /// <summary>
        /// æ ¹æ®é¢†æ–™å•头拉单身
        /// </summary>
        /// <param name="dtls"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        private static ApiAction GenerateReqDetail(List<WMS_PRDPICK_H> dtls, DbClient db)
        {
            Thread.Sleep(5000);
            var action = new ApiAction();
            try
            {
                var judian = BizConfig.Configuration["JuDian"];
                List<WMS_PRDPICK_H> entity_h = new();
                List<WMS_PRDPICK_D> entity_d = new();
                List<WMS_TRANSFER_H> transferH = new();
                List<WMS_SCTRWO_TRANSFER> sctrwos = new();
                //查询出来的列表
                List<WMS_PRDPICK_D> list_dOld = new();
                foreach (var item_h in dtls)
                {
                    var prd_h = Biz.Db.Queryable<WMS_PRDPICK_H>().Where(s => s.BILLCODE == item_h.BILLCODE).Single();
                    if (prd_h?.STATUS != "COMPLETE")
                    {
                        var list_d = Biz.Db.Queryable<WMS_PRDPICK_D>().Where(s => s.BILLCODE == item_h.BILLCODE).ToList();
                        var item_h_list = new List<WMS_PRDPICK_D>();
                        var ret = DI.Resolve<IErpT100>().GetMaterialReqDetail(new ReqInputParameter
                        {
                            parameter = new reqParameter { sfdcdocno = item_h.BILLCODE },
                            datakey = new Datakey
                            {
                                EntId = item_h.ENTERPRISECODE.ToString(),
                                CompanyId = judian
                            }
                        });
                        List<reqParameterReturn> ret_list = new List<reqParameterReturn>();
                        if (ret.payload.std_data.execution.code != "0")
                        {
                            action.IsSuccessed = false;
                            action.Message = $"错误信息:[{ret.payload.std_data.execution.description}]";
                            Logger.Default.Info(action.Message);
                            var dt = DateTime.Now;
                            while ((dt - DateTime.Now).TotalSeconds < 10)
                            {
                            }
                            var ret1 = DI.Resolve<IErpT100>().GetMaterialReqDetail(new ReqInputParameter
                            {
                                parameter = new reqParameter { sfdcdocno = item_h.BILLCODE },
                                datakey = new Datakey
                                {
                                    EntId = item_h.ENTERPRISECODE.ToString(),
                                    CompanyId = judian
                                }
                            });
                            if (ret1.payload.std_data.execution.code != "0")
                            {
                                action.IsSuccessed = false;
                                action.Message = $"错误信息:[{ret1.payload.std_data.execution.description}]";
                                Logger.Default.Info(action.Message);
                                return action;
                            }
                            else
                            {
                                ret_list = ret1.payload.std_data.parameter.@return;
                            }
                        }
                        else
                        {
                            ret_list = ret.payload.std_data.parameter.@return;
                        }
                        foreach (var item in ret_list)
                        {
                            WMS_PRDPICK_D d = new WMS_PRDPICK_D
                            {
                                BILLCODE = item.sfdcdocno,
                                BILLLINE = Convert.ToInt32(item.sfdcseq),
                                UNITCODE = item.sfdc006,
                                MATERIALCODE = item.sfdc004,
                                PRQTY = Convert.ToDecimal(item.sfdc007),
                                DELIVERYDATE = Convert.ToDateTime(item.sfdareqdt),
                                WAREHOUSECODE = item.sfdc012,
                                SOURCETYPE = Convert.ToInt32(item.sfdc003),
                                SOURCECODE = item.sfdc001,
                                SOURCELINE = Convert.ToInt32(item.sfdc002),
                            };
                            item_h_list.Add(d);
                        }
                        //保存委外工单号对应关系
                        WMS_SCTRWO_TRANSFER sctr = new WMS_SCTRWO_TRANSFER
                        {
                            ID = Guid.NewGuid().ToString("N"),
                            ORIGINAL_WORKORDER = ret_list[0]?.sfdc001,
                            TARGET_WORKORDER = ret_list[0]?.sfdc001_1
                        };
                        sctrwos.Add(sctr);
                        action.Message += $",领料单明细获取成功,[{string.Join(",", item_h_list.Select(x => x.BILLCODE + ";" + x.MATERIALCODE).ToList())},获取总数[{item_h_list.Count}],数据库中总数[{list_d.Count}]";
                        action.Message += $",委外工单,[{string.Join(",", sctrwos.Select(x => x.ORIGINAL_WORKORDER + ";" + x.TARGET_WORKORDER).ToList())}";
                        if (list_d.Count != item_h_list.Count)
                        {
                            foreach (var d in list_d) { d.PRQTY = 0; } //需求数量都弄成0
                        }
                        int n = 0;
                        List<WMS_PRDPICK_D> prdDList = new List<WMS_PRDPICK_D>();
                        foreach (var item_d in item_h_list)
                        {
                            //根据单据重新到数据查找相应的单据明细
                            var prd_d = list_d.Where(s => s.BILLCODE == item_d.BILLCODE && s.BILLLINE == item_d.BILLLINE).FirstOrDefault();
                            prd_d = prd_d ?? new WMS_PRDPICK_D()
                            {
                                LINESTATUS = "INIT",
                                QTY = Convert.ToDecimal(0),
                                CreationTime = DateTime.Now,
                                CreatorUserId = 1,
                            };
                            prd_d.BILLCODE = item_d.BILLCODE;
                            prd_d.BILLLINE = item_d.BILLLINE;
                            prd_d.UNITCODE = item_d.UNITCODE;
                            prd_d.MATERIALCODE = item_d.MATERIALCODE;
                            prd_d.PRQTY = Convert.ToDecimal(item_d.PRQTY);
                            prd_d.DELIVERYDATE = Convert.ToDateTime(item_d.DELIVERYDATE);
                            prd_d.WAREHOUSECODE = item_d.WAREHOUSECODE;
                            prd_d.LINESTATUS = prd_d.PRQTY == prd_d.QTY ? "COMPLETE" : Convert.ToDecimal(item_d.PRQTY) == 0 ? "COMPLETE" : prd_d.LINESTATUS == "DELETE" ? "INIT" : prd_d.LINESTATUS;
                            prd_d.SOURCETYPE = item_d.SOURCETYPE;
                            prd_d.SOURCECODE = item_d.SOURCECODE;
                            prd_d.SOURCELINE = item_d.SOURCELINE;
                            prd_d.LastModificationTime = item_d.LastModificationTime;
                            list_d.RemoveAll(q => q.BILLCODE == item_d.BILLCODE && q.BILLLINE == item_d.BILLLINE);
                            if (prd_d.LINESTATUS == "COMPLETE") { n++; }
                            prdDList.Add(prd_d);
                            entity_d.Add(prd_d);
                        }
                        if (prdDList.Count == n) { prd_h.STATUS = "COMPLETE"; }
                        entity_h.Add(prd_h);
                        list_dOld.AddRange(list_d);
                        //检查有没有调拨单,有就更新状态为完成
                        var transferList = Biz.Db.Queryable<WMS_TRANSFER_H>().Where(s => s.SOURCECODE == prd_h.BILLCODE).ToList();
                        if (transferList.Any())
                        {
                            foreach (var item in transferList)
                            {
                                item.STATUS = "COMPLETE2";
                                item.LastModificationTime = DateTime.Now;
                                item.SOURCECODE = prd_h.BILLCODE;
                                transferH.Add(item);
                                action.Message += $",领料单[{prd_h.BILLCODE}]对应调拨单[{item.BILLCODE}]完成";
                            }
                        }
                    }
                }
                //保存到数据库
                var dbTran = db.UseTran(() =>
                {
                    db.Storageable(entity_h, "system").ExecuteCommand();
                    db.Storageable(entity_d, "system").ExecuteCommand();
                    if (transferH.Any())
                    {
                        db.Updateable(transferH).ExecuteCommand();
                    }
                    if (sctrwos.Any())
                    {
                        //db.Insertable(sctrwos).ExecuteCommand();
                        var y = db.Storageable(sctrwos)
                        .WhereColumns(t => new { t.ORIGINAL_WORKORDER, t.TARGET_WORKORDER })
                        .ToStorage();
                        y.AsInsertable.ExecuteCommand();
                        y.AsUpdateable.IgnoreColumns(t => t.ID).ExecuteCommand();
                    }
                    if (list_dOld.Any())
                    {
                        db.Deleteable(list_dOld).ExecuteCommand();
                    }
                });
                if (!dbTran.IsSuccess)
                {
                    action.CatchExceptionWithLog(dbTran.ErrorException, $"数据保存失败");
                }
                Logger.Default.Info(action.Message);
                return action;
            }
            catch (System.Exception ex)
            {
                return action.GetResponse().CatchExceptionWithLog(ex, $"领料单生成异常");
            }
        }
        /// <summary>
        /// æ‹†è§£æ¡ç 
        /// </summary>
        /// <param name="nFullBarcode"></param>
        /// <param name="nPackageBarcode"></param>
        /// <returns></returns>
        public static Result<InputBarcodeDto> SplitFullBarcode(string nFullBarcode, bool nPackageBarcode = false)
        {
            Result<InputBarcodeDto> result = new(Result.Flags.Success, $"解析条码[{nFullBarcode}]成功");
            //识别新的识别二维码规则,以V开头,否则按旧识别模式
            if (nFullBarcode.Substring(0, 1).ToUpper() == "V")
            {
                return SplitFullBarcodeNew(nFullBarcode, nPackageBarcode);
            }
            // æ—§æ ¼å¼æ¡ç ï¼Œéƒ½æ˜¯æœ€å°æ‰¹æ¬¡æ ‡ç­¾ï¼ŒéžåŒ…装标签
            nPackageBarcode = false;
            //新条码解析
            var nSplitArray = nFullBarcode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (nSplitArray.Length == 1) //一维码
            {
                result.Data = new InputBarcodeDto
                {
                    Barcode = nFullBarcode
                };
                return result;
            }
            var nOrderNo = "";
            var nMaterialCode = "";
            var nBarcodeLotNo = "";
            var nLotQty = "";
            var nLotDate = "";
            var nStateFlag = "";
            bool isBox = false;
            var nLotNo = "";
            foreach (string item in nSplitArray)
            {
                string itemKey = item.Substring(0, 1).ToUpper();
                string itemValue = item.Substring(1);
                if (itemKey == "V")
                { //采购订单号
                    nOrderNo = itemValue;
                }
                else if (itemKey == "P")
                { //条码料号
                    nMaterialCode = itemValue;
                }
                else if (itemKey == "S")
                { //来料外包条码
                    nBarcodeLotNo = itemValue;
                    //nBarcodeLotNo = item;//PAG ID è§£æžå‡ºæ¥çš„æ•°æ®å‰ç¼€â€œS”不用去掉
                    //if (itemValue.StartsWith("C") || itemValue.StartsWith("P")) //中箱(C)和栈板(P),需要再次去掉一位
                    //    nBarcodeLotNo = itemValue.Substring(1);
                }
                else if (itemKey == "Q")
                { //条码数量
                    nLotQty = itemValue;
                }
                else if (itemKey == "D")
                { //生产日期(去掉-,兼容带-的时间格式,后面统一时间解析)
                    nLotDate = itemValue;
                    //nLotDate = itemValue.Replace("-", "");
                }
                else if (itemKey == "L")
                { //批号
                    nLotNo = itemValue;
                }
            }
            if (nMaterialCode == "" || nLotQty == "" || nBarcodeLotNo == "")
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码数据有误";
                return result;
            }
            // åˆ¤æ–­æ ‡ç­¾æ•°é‡æ˜¯å¦åˆæ³•
            if (!decimal.TryParse(nLotQty, out decimal nBarcodeQty))
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码格式错误:未取到正确的条码数量";
                return result;
            }
            // è§£æžDateCode
            DateTime nDateCode = DateTime.MinValue;
            if (nLotDate != "")
            {
                //string dateTimeStr = nLotDate.Substring(0, 4) + "-" + nLotDate.Substring(4, 2) + "-" + nLotDate.Substring(6, 2);
                //if (!DateTime.TryParse(dateTimeStr, out nDateCode))
                ////if (!DateTime.TryParse(nLotDate, out DateTime nDateCode))
                //{
                //    throw new UserFriendlyException("条码格式错误:未取到正确的批次日期");
                //}
                /// åŽŸå§‹DateCode ä¸ºæ—¥æœŸ
                if (nLotDate.Length > 6)
                {
                    var sDate = nLotDate;
                    if (nLotDate.Length == 7) { sDate = $"{nLotDate.Substring(0, 4)}0{nLotDate.Substring(4)}"; }
                    IFormatProvider ifp = new CultureInfo("zh-CN", true);
                    DateTime.TryParseExact(sDate, "yyyyMMdd", ifp, DateTimeStyles.None, out nDateCode);
                }
                /// åŽŸå§‹DateCode ä¸ºå¹´ã€å‘¨æ¬¡ï¼ˆYYYYWW / YYWW)
                int yw = 0;
                if (nLotDate.Length <= 6 && int.TryParse(nLotDate, out yw))
                {
                    nDateCode = GetWeekStartTime(nLotDate);
                }
                if (nDateCode == DateTime.MinValue)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"条码格式错误:未取到正确的批次日期";
                    return result;
                }
            }
            // åˆ¤æ–­ç‰©æ–™ä»£ç æ˜¯å¦åˆæ³•
            var nMaterial = Biz.Db.Queryable<WMS_MesMaterial>().Where(q => q.MCode.ToUpper() == nMaterialCode.ToUpper() || q.MCode.ToUpper() == "K" + nMaterialCode.ToUpper()).First();
            if (nMaterial == null)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码对应的物料不存在";
                return result;
            }
            // åˆ¤æ–­åŒ…装条码格式是否合法
            if (nPackageBarcode && nBarcodeLotNo.Length != 12)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"来料外包条码格式错误,应包含12位字符的批次号";
                return result;
            }
            if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_semimanufacture" && nBarcodeLotNo.Length < 16) //5位供应商+8位日期+3位流水码
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"半成品条码的批次格式错误,应至少包含16位字符";
                return result;
            }
            if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_finishedproduct" && nBarcodeLotNo.Length < 17) //5位供应商+8位日期+4位流水码
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"成品箱号批次格式错误,应至少包含17位字符";
                return result;
            }
            if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_rawmaterial" && nBarcodeLotNo.Length < 15)//4位供应商+8位日期+4位流水码
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"物料条码批次格式错误,应至少包含15位字符";
                return result;
            }
            result.Data = new InputBarcodeDto
            {
                OrderNo = nOrderNo,
                Barcode = nBarcodeLotNo,
                MaterialCode = nMaterial?.MCode,
                MaterialName = nMaterial?.MName,
                MaterialStandard = nMaterial?.MDesc,
                MGroupCode = nMaterial?.MGroupCode,
                Unit = nMaterial?.MUom,
                LotQty = nBarcodeQty,
                LotDate = nDateCode,
                LotDateString = nLotDate,
                PeriodDays = nMaterial.PERIODDAYS,
                FIFO = nMaterial.FIFO,
                SafeStorageQty = nMaterial.SAFEQTY,
                StateFlag = nStateFlag,
                IsBox = isBox,
                //SnList = snList,
                LotNo = nBarcodeLotNo,
            };
            return result;
        }
        /// <summary>
        /// æœ€æ–°è§£ç è§„则,SRM æ ‡ç­¾
        /// æ‹†è§£æ¡ç 
        ///        ä¾æ¬¡æ˜¯ï¼š
        ///V:PO(MO)
        ///P:C P/N:料号
        ///N:Name(物料名称)
        ///Q:QTY(数量)
        ///U:Unit(单位)
        ///M:Mfr P/N(供应商内部管控的物料的料号)
        ///D:Date Code(生产日期,物料的生产日期)
        ///L:Lot Code(生产的批次)
        ///S:PAG ID(小包批次代码,也就是来料外包条码)
        /// </summary>
        /// <param name="nFullBarcode"></param>
        /// <param name="nPackageBarcode"></param>
        /// <returns></returns>
        public static Result<InputBarcodeDto> SplitFullBarcodeNew(string nFullBarcode, bool nPackageBarcode = false)
        {
            Result<InputBarcodeDto> result = new(Result.Flags.Success, $"解析条码[{nFullBarcode}]成功");
            var nSplitArray = nFullBarcode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var nOrderNo = "";
            var nMaterialCode = "";
            var nBarcodeLotNo = "";
            var nLotQty = "";
            var nLotDate = "";
            var nStateFlag = "";
            bool isBox = false;
            var nLotNo = "";
            List<Tuple<string, decimal>> snList = new List<Tuple<string, decimal>>();
            foreach (string item in nSplitArray)
            {
                string itemKey = item.Substring(0, 1).ToUpper();
                string itemValue = item.Substring(1);
                if (itemKey == "V")
                { //采购订单号
                    nOrderNo = itemValue;
                }
                else if (itemKey == "P")
                { //条码料号
                    nMaterialCode = itemValue;
                }
                else if (itemKey == "S")
                { //来料外包条码
                    nBarcodeLotNo = itemValue;
                }
                else if (itemKey == "Q")
                { //条码数量
                    nLotQty = itemValue;
                }
                else if (itemKey == "D")
                {
                    //生产日期(去掉-,兼容带-的时间格式,后面统一时间解析)
                    nLotDate = Regex.Replace(itemValue, @"[^0-9]+", "");
                }
                else if (itemKey == "L")
                { //批号
                    nLotNo = itemValue;
                }
            }
            //判断条码是否拆分过,拆分过的不判断是否为ASN 2022/12/17 Ben Lin
            //if (!nBarcodeLotNo.Contains("-1") && !nBarcodeLotNo.Contains("-2"))
            if (nBarcodeLotNo.Substring(nBarcodeLotNo.Length - 3, 2) != "-1" && nBarcodeLotNo.Substring(nBarcodeLotNo.Length - 3, 2) != "-2") //调整判断拆包标签的标准2023-1-2,weikaiyong
            {
                // åˆ¤æ–­å•据编号是否为ASN, å¦‚果是ASN,调用ASN标签解析
                if (BillIsAsn(nOrderNo))
                {
                    return SplitFullBarcodeAsn(nSplitArray, nPackageBarcode);
                }
            }
            if (nMaterialCode == "" || nLotQty == "" || nBarcodeLotNo == "")
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码数据有误";
                return result;
            }
            var nInputSnDto = Biz.Db.Queryable<WMS_SRMSNList>().Where(q => q.OuterBarcode == nBarcodeLotNo || q.BigBarcode == nBarcodeLotNo).ToList();
            if (nInputSnDto.Any())
            {
                isBox = true;
                snList = nInputSnDto.Select(t => new Tuple<string, decimal>(t.SmallBarcode, t.IncludeQty)).ToList();
            }
            if (!decimal.TryParse(nLotQty, out decimal nBarcodeQty))
            {
                //throw new UserFriendlyException("条码格式错误:未取到正确的条码数量");
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码数据有误";
                return result;
            }
            DateTime nDateCode = DateTime.Now;
            if (nLotDate != "")
            {
                // åŽŸå§‹DateCode ä¸ºæ—¥æœŸ
                if (nLotDate.Length > 6)
                {
                    IFormatProvider ifp = new CultureInfo("zh-CN", true);
                    DateTime.TryParseExact(nLotDate, "yyyyMMdd", ifp, DateTimeStyles.None, out nDateCode);
                }
                // åŽŸå§‹DateCode ä¸ºå¹´ã€å‘¨æ¬¡ï¼ˆYYYYWW / YYWW)
                int yw = 0;
                if (nLotDate.Length <= 6 && int.TryParse(nLotDate, out yw))
                {
                    nDateCode = GetWeekStartTime(nLotDate);
                }
                if (nDateCode == DateTime.MinValue)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"条码[{nFullBarcode}]格式错误:未取到正确的批次日期";
                    return result;
                }
            }
            var nMaterial = Biz.Db.Queryable<WMS_MesMaterial>().Where(q => q.MCode.ToUpper() == nMaterialCode.ToUpper()).First();
            if (nMaterial == null)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码对应的物料不存在";
                return result;
            }
            if (!nPackageBarcode)
            {
                if (nPackageBarcode && nBarcodeLotNo.Length != 12)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"来料外包条码格式错误,应包含12位字符的批次号";
                    return result;
                }
                else if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_semimanufacture" && nBarcodeLotNo.Length < 16) //5位供应商+8位日期+3位流水码
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"半成品条码的批次格式错误,应至少包含16位字符";
                    return result;
                }
                else if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_finishedproduct" && nBarcodeLotNo.Length < 17) //5位供应商+8位日期+4位流水码
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"成品箱号批次格式错误,应至少包含17位字符";
                    return result;
                }
                else if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_rawmaterial" && nBarcodeLotNo.Length < 15)//4位供应商+8位日期+4位流水码
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"物料条码批次格式错误,应至少包含15位字符";
                    return result;
                }
            }
            result.Data = new InputBarcodeDto
            {
                OrderNo = nOrderNo,
                Barcode = nBarcodeLotNo,
                MaterialCode = nMaterialCode,
                MaterialName = nMaterial?.MName,
                MaterialStandard = nMaterial?.MDesc,
                MGroupCode = nMaterial?.MGroupCode,
                Unit = nMaterial?.MUom,
                LotQty = nBarcodeQty,
                LotDateString = nLotDate,
                LotDate = nDateCode,
                PeriodDays = nMaterial.PERIODDAYS,
                FIFO = nMaterial.FIFO,
                SafeStorageQty = nMaterial.SAFEQTY,
                StateFlag = nStateFlag,
                IsBox = isBox,
                SnList = snList,
                LotNo = nBarcodeLotNo,
            };
            return result;
        }
        /// <summary>
        /// ASN标签条码解析
        /// æ‹†è§£æ¡ç ï¼Œä¾æ¬¡æ˜¯ï¼š
        /// V:PO(MO)
        /// P:C P/N:料号
        /// N:Name(物料名称)
        /// Q:QTY(数量)
        /// U:Unit(单位)
        /// M:Mfr P/N(供应商内部管控的物料的料号)
        /// D:Date Code(生产日期,物料的生产日期)
        /// L:Lot Code(生产的批次)
        /// S:PAG ID(小包批次代码,也就是来料外包条码)
        /// </summary>
        /// <param name="nFullBarcode"></param>
        /// <param name="nBarcodeType"></param>
        /// <returns></returns>
        public static Result<InputBarcodeDto> SplitFullBarcodeAsn(string[] nSplitArray, bool nPackageBarcode = false)
        {
            Result<InputBarcodeDto> result = new(Result.Flags.Success, $"解析Asn条码成功");
            #region æ–¹æ³•变量
            // æ¡ç å˜é‡
            var nAsnNo = "";
            var nVendorCode = "";
            var nMaterialCode = "";
            var nBarcodeLotNo = "";
            var nLotQty = "";
            var nLotDate = "";
            var nStateFlag = "";
            bool isBox = false;
            var nLotNo = "";
            // æœ€å°åŒ…装条码列表
            List<Tuple<string, decimal>> snList = new List<Tuple<string, decimal>>();
            // é€è´§å•行明细
            List<InputAsnLineDto> asnLineList = new List<InputAsnLineDto>();
            // æœ€å°åŒ…装条码明细
            List<WMS_SRMSNList> snBarcodeList = new List<WMS_SRMSNList>();
            var nCartonNo = "";
            var nPalletNo = "";
            // å˜é‡èµ‹å€¼
            foreach (string item in nSplitArray)
            {
                string itemKey = item.Substring(0, 1).ToUpper();
                string itemValue = item.Substring(1);
                if (itemKey == "V")
                { //送货单号
                    nAsnNo = itemValue;
                }
                else if (itemKey == "P")
                { //条码料号
                    nMaterialCode = itemValue;
                }
                else if (itemKey == "S")
                { //来料外包条码
                    nBarcodeLotNo = itemValue;
                    //nBarcodeLotNo = item;//PAG ID è§£æžå‡ºæ¥çš„æ•°æ®å‰ç¼€â€œS”不用去掉
                    //if(itemValue.StartsWith("C")|| itemValue.StartsWith("P")) //中箱(C)和栈板(P),需要再次去掉一位
                    //    nBarcodeLotNo = itemValue.Substring(1);
                }
                else if (itemKey == "Q")
                { //条码数量
                    nLotQty = itemValue;
                }
                else if (itemKey == "D")
                { //生产日期(去掉-,兼容带-的时间格式,后面统一时间解析)
                  //nLotDate = itemValue.Replace("-", "");
                    nLotDate = Regex.Replace(itemValue, @"[^0-9]+", "");
                }
                else if (itemKey == "L")
                { //批号
                    nLotNo = itemValue;
                }
            }
            #endregion
            #region æ¡ç æ•°æ®æ ¡éªŒ
            if (nMaterialCode == "" || nLotQty == "" || nBarcodeLotNo == "")
            {
                //throw new UserFriendlyException("条码数据有误");
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码数据有误";
                return result;
            }
            // èŽ·å–æ¡ç åˆ—è¡¨ snBarcodeList
            snBarcodeList = GetSrmBarcodeList(nBarcodeLotNo);
            // å¦‚果最小包装标签记录数大于1,则为包装标签,否则为最小包装标签
            if (BarcodeIsBox(nBarcodeLotNo))
            {
                isBox = true;
            }
            if (snBarcodeList.Any())
            {
                snList = snBarcodeList.Select(t => new Tuple<string, decimal>(t.SmallBarcode, t.IncludeQty)).ToList();
                snBarcodeList = snBarcodeList.Select(t => new WMS_SRMSNList
                {
                    BILLCODE = t.BILLCODE,
                    MATERIALCODE = t.MATERIALCODE,
                    SmallBarcode = t.SmallBarcode,
                    BigBarcode = t.BigBarcode,
                    OuterBarcode = t.OuterBarcode,
                    IncludeQty = t.IncludeQty
                }).ToList();
                // åˆ¤æ–­æ ‡ç­¾æ¡ç ç±»åž‹
                // æ˜¯æœ€å°åŒ…装条码
                var smallBarcode = snBarcodeList.Where(t => t.SmallBarcode == nBarcodeLotNo).FirstOrDefault();
                if (smallBarcode != null && !smallBarcode.SmallBarcode.IsNullOrEmpty())
                {
                    isBox = false;
                    nCartonNo = smallBarcode.BigBarcode;
                    nPalletNo = smallBarcode.OuterBarcode;
                }
                // æ˜¯å¤–箱条码
                var bigBarcode = snBarcodeList.Where(t => t.BigBarcode == nBarcodeLotNo).FirstOrDefault();
                if (bigBarcode != null && !bigBarcode.BigBarcode.IsNullOrEmpty())
                {
                    isBox = true;
                    nCartonNo = bigBarcode.BigBarcode;
                    nPalletNo = bigBarcode.OuterBarcode;
                }
                // æ˜¯æ ˆæ¿æ¡ç 
                var outerBarcode = snBarcodeList.Where(t => t.OuterBarcode == nBarcodeLotNo).FirstOrDefault();
                if (outerBarcode != null && !outerBarcode.OuterBarcode.IsNullOrEmpty())
                {
                    isBox = true;
                    nCartonNo = outerBarcode.BigBarcode;
                    nPalletNo = outerBarcode.OuterBarcode;
                }
            }
            // éªŒè¯æ¡ç æ ‡ç­¾æ•°é‡æ ¼å¼æ˜¯å¦æ­£ç¡®
            if (!decimal.TryParse(nLotQty, out decimal nBarcodeQty))
            {
                //throw new UserFriendlyException("条码格式错误:未取到正确的条码数量");
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码格式错误:未取到正确的条码数量";
                return result;
            }
            // éªŒè¯æ¡ç æ ‡ç­¾æ•°é‡ä¸ŽSRM æœ€å°åŒ…装数量合计是否一致
            decimal snQtyTotal = snBarcodeList.Sum(t => t.IncludeQty);
            if (nBarcodeQty != snQtyTotal)
            {
                //throw new UserFriendlyException("标签数量与SRM最小包装总数量不一致");
                result.Flag = Result.Flags.Failed;
                result.Message = $"标签数量与SRM最小包装总数量不一致";
                return result;
            }
            DateTime nDateCode = DateTime.Now;
            if (nLotDate != "")
            {
                //增加判断日期的抛错提示 2022/07/27 Ben Lin, 2022/07/29 Ben Lin å†æ¬¡æ›´æ–°
                try
                {
                    string dateTimeStr = nLotDate.Substring(0, 4) + "-" + nLotDate.Substring(4, 2) + "-" + nLotDate.Substring(6, 2);
                    if (nLotDate.Length < 7)
                    {
                        if (nLotDate.StartsWith("2") && nLotDate.Length == 6)
                        {
                            dateTimeStr = $"20{nLotDate.Substring(0, 2)}-{nLotDate.Substring(2, 2)}-{nLotDate.Substring(4, 2)}";
                        }
                        else
                        {
                            result.Flag = Result.Flags.Failed;
                            result.Message = $"条码[{nBarcodeLotNo}]格式错误:未取到正确的批次日期";
                            return result;
                        }
                    }
                    if (!DateTime.TryParse(dateTimeStr, out nDateCode))
                    //if (!DateTime.TryParse(nLotDate, out DateTime nDateCode))
                    {
                        result.Flag = Result.Flags.Failed;
                        result.Message = $"条码[{nBarcodeLotNo}]格式错误:未取到正确的批次日期";
                        return result;
                    }
                }
                catch (System.Exception ex)
                {
                    //Logger.Info($"ASN标签条码解析 =>条码[{nBarcodeLotNo}]格式错误:未取到正确的批次日期,{ex.Message}");
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"条条码[{nBarcodeLotNo}]格式错误:未取到正确的批次日期,{ex.Message}";
                    return result;
                }
            }
            var nMaterial = Biz.Db.Queryable<WMS_MesMaterial>().Where(t => t.MCode.ToUpper() == nMaterialCode.ToUpper()).First();
            if (nMaterial == null)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"条码对应的物料[{nMaterialCode}]不存在";
                return result;
            }
            if (!nPackageBarcode)
            {
                if (nPackageBarcode && nBarcodeLotNo.Length != 12)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"来料外包条码格式错误,应包含12位字符的批次号";
                    return result;
                }
                else if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_semimanufacture" && nBarcodeLotNo.Length < 16) //5位供应商+8位日期+3位流水码
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"半成品条码的批次格式错误,应至少包含16位字符";
                    return result;
                }
                else if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_finishedproduct" && nBarcodeLotNo.Length < 17) //5位供应商+8位日期+4位流水码
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"成品箱号批次格式错误,应至少包含17位字符";
                    return result;
                }
                else if (!nPackageBarcode && nMaterial.MtypeCode == "itemtype_rawmaterial" && nBarcodeLotNo.Length < 15)//4位供应商+8位日期+4位流水码
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"物料条码批次格式错误,应至少包含15位字符";
                    return result;
                }
            }
            #endregion
            #region èŽ·å–é€è´§å•æ•°æ®
            // å¦‚果标签没有送货单号,根据标签条码获取送货单号
            if (nAsnNo.IsNullOrEmpty())
            {
                var asnList = GetSrmAsn(nBarcodeLotNo);
                var asn = asnList.FirstOrDefault();
                if (asn != null)
                {
                    nAsnNo = asn.DeliveryNo;
                    nVendorCode = asn.VendorCode;
                }
            }
            // èŽ·å–é€è´§å•è¡Œæ˜Žç»† poLineList
            List<InputAsnLineDto> asnLines = GetSrmAsnLines(nAsnNo, nMaterialCode);
            if (asnLines != null && asnLines.Count > 0)
            {
                foreach (var line in asnLines)
                {
                    // åˆ†å‰²poLineNo(1-1-1),用-分割,取第一段,获取 PoErpLine
                    string[] splitLineNo = line.PoLineNo.Split('-');
                    if (splitLineNo != null && splitLineNo.Count() > 0)
                    {
                        int erpPoLine = 0;
                        int.TryParse(splitLineNo[0], out erpPoLine);
                        line.PoErpLine = erpPoLine;
                    }
                }
            }
            #endregion
            result.Data = new InputBarcodeDto
            {
                AsnNo = nAsnNo,
                Barcode = nBarcodeLotNo,
                VendorCode = nVendorCode,
                MaterialCode = nMaterialCode,
                MaterialName = nMaterial?.MName,
                MaterialStandard = nMaterial?.MDesc,
                MGroupCode = nMaterial?.MGroupCode,
                Unit = nMaterial?.MUom,
                LotQty = nBarcodeQty,
                LotDateString = nLotDate,
                LotDate = nDateCode,
                PeriodDays = nMaterial.PERIODDAYS,
                FIFO = nMaterial.FIFO,
                SafeStorageQty = nMaterial.SAFEQTY,
                StateFlag = nStateFlag,
                IsBox = isBox,
                SnList = snList,
                LotNo = nBarcodeLotNo,
                AsnLineList = asnLines,
                SnBarcodeList = snBarcodeList,
                CartonNo = nCartonNo,
                PalletNo = nPalletNo
            };
            return result;
        }
        private static bool BarcodeIsBox(string barcode)
        {
            bool isBox = false;
            // ä»ŽWMS_SRM_ASN表查找单据编号,判断是否为ASN
            if (Biz.Db.Queryable<WMS_SRMSNList>().Where(t => t.OuterBarcode == barcode || t.BigBarcode == barcode).Any())
                isBox = true;
            return isBox;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputBarcode"></param>
        /// <returns></returns>
        public static List<SRMSNStatus> GetSrmAsn(string inputBarcode)
        {
            var query = Biz.Db.Queryable<WMS_SRMSNList, WMS_SRM_ASN>((t, m) =>
                                new JoinQueryInfos(
                                    JoinType.Left, t.DeliveryNo == m.DeliveryNo
                                    ))
            .Where((t, m) => t.SmallBarcode == inputBarcode || t.BigBarcode == inputBarcode || t.OuterBarcode == inputBarcode)
            .Select((t, m) => new SRMSNStatus
            {
                DeliveryNo = t.DeliveryNo,
                VendorCode = m.innerVendorCode,
                Status = m.status
            })
            .ToList();
            return query;
        }
        /// <summary>
        /// èŽ·å– SRM ASN è¡Œ
        /// </summary>
        /// <param name="inputAsnNo"></param>
        /// <returns></returns>
        public static List<InputAsnLineDto> GetSrmAsnLines(string inputAsnNo)
        {
            var query = Biz.Db.Queryable<WMS_SRM_ASN_LINES>()
            .Where(t => t.DeliveryNo == inputAsnNo)
            .Select(t => new InputAsnLineDto
            {
                DeliveryNo = t.DeliveryNo,
                LineNo = t.lineNo,
                ProductCode = t.productCode,
                PurchaseType = t.purchaseType,
                PoErpNo = t.poErpNo,
                PoLineNo = t.poLineNo,
                DeliveryQty = t.deliveryQty
            })
            .ToList();
            return query;
        }
        /// <summary>
        /// èŽ·å– SRM ASN è¡Œ
        /// </summary>
        /// <param name="inputAsnNo"></param>
        /// <param name="inputMaterialCode"></param>
        /// <returns></returns>
        public static List<InputAsnLineDto> GetSrmAsnLines(string inputAsnNo, string inputMaterialCode)
        {
            var query = Biz.Db.Queryable<WMS_SRM_ASN_LINES>()
            .Where(t => t.DeliveryNo == inputAsnNo && t.productCode == inputMaterialCode)
            .Select(t => new InputAsnLineDto
            {
                DeliveryNo = t.DeliveryNo,
                LineNo = t.lineNo,
                ProductCode = t.productCode,
                PurchaseType = t.purchaseType,
                PoErpNo = t.poErpNo,
                PoLineNo = t.poLineNo,
                DeliveryQty = t.deliveryQty
            })
            .ToList();
            return query;
        }
        /// <summary>
        /// èŽ·å– SRM æ¡ç åˆ—表
        /// </summary>
        /// <param name="inputBarcode"></param>
        /// <returns></returns>
        public static List<WMS_SRMSNList> GetSrmBarcodeList(string inputBarcode)
        {
            return Biz.Db.Queryable<WMS_SRMSNList>().Where(t => t.OuterBarcode == inputBarcode || t.BigBarcode == inputBarcode || t.SmallBarcode == inputBarcode).ToList();
        }
        /// <summary>
        /// å½“前周的第一天(星期一)
        /// </summary>
        /// <param name="yearWeek">周数,格式:yyyywww</param>
        /// <returns></returns>
        private static DateTime GetWeekStartTime(string yearWeek)
        {
            //年份
            int year = 0;
            //周数
            int weekNum = 0;
            if (yearWeek.Length == 4)
            {
                year = 2000 + int.Parse(yearWeek.Substring(0, 2));
                weekNum = int.Parse(yearWeek.Substring(2));
            }
            if (yearWeek.Length == 6)
            {
                year = int.Parse(yearWeek.Substring(0, 4));
                weekNum = int.Parse(yearWeek.Substring(4));
            }
            //本年1月1日
            DateTime firstOfYear = new DateTime(year, 1, 1);
            //本年1月1日与本周星期一相差的天数
            int dayDiff = (firstOfYear.DayOfWeek == DayOfWeek.Sunday ? 7 : Convert.ToInt32(firstOfYear.DayOfWeek)) - 1;
            //第一周的星期一
            DateTime firstDayOfFirstWeek = firstOfYear.AddDays(-dayDiff);
            //当前周的星期一
            DateTime firstDayOfThisWeek = firstDayOfFirstWeek.AddDays((weekNum - 1) * 7);
            return firstDayOfThisWeek;
        }
        // æ ¹æ®å•据编号判断是都为 ASN
        private static bool BillIsAsn(string billCode)
        {
            // ä»ŽWMS_SRM_ASN表查找单据编号,判断是否为ASN
            return Biz.Db.Queryable<WMS_SRMSNList>().Where(q => q.DeliveryNo == billCode).Any();
        }
        /// <summary>
        /// èŽ·å–å•å·æ ¹æ®å•æ®ç±»åž‹
        /// </summary>
        /// <param name="billType"></param>
        /// <returns></returns>
        public static string GetBillNoByType(string billType)
        {
            //根据BillType去表中找到相关前缀、日期码、流水号、长度
            var billNoRule = Biz.Db.Queryable<MesBillNoHelper>().Where(t => t.BillType.Equals(billType)).ToList();
            if (billNoRule.Count == 1)
            {
                var nowRule = billNoRule[0];
                string prefix = nowRule.BillPrefix.Trim();
                string datecode = nowRule.DateCode.Trim();
                string today = DateTime.Now.ToString("yyyyMMdd");
                int serial = nowRule.SerialNo;
                int maxSerial = GetMaxNumByLength(nowRule.SerialNoLength);
                if (serial >= maxSerial)
                {
                    return "over";
                }
                else
                {
                    if (datecode != string.Empty && datecode != today)
                    {
                        serial = 0;
                        datecode = today;
                    }
                    string serialNo = (serial + 1).ToString().PadLeft(nowRule.SerialNoLength, '0');
                    //update serialNo
                    nowRule.DateCode = datecode;
                    nowRule.SerialNo = serial + 1;
                    Biz.Db.Updateable(nowRule).ExecuteCommand();
                    //返回编号
                    return prefix + datecode + serialNo;
                }
            }
            else
            {
                return "";
            }
        }
        private static int GetMaxNumByLength(int length)
        {
            if (length == 0)
            {
                return 0;
            }
            else
            {
                string strNum = string.Empty;
                for (int i = 1; i <= length; i++)
                {
                    strNum += "9";
                }
                return Convert.ToInt32(strNum);
            }
        }
        /// <summary>
        /// ç”Ÿæˆé€æ£€å•
        /// </summary>
        /// <param name="detail"></param>
        /// <param name="nUrgent"></param>
        /// <returns></returns>
        private static Result<WMS_IQC_H> CreateIqcHeader(WMS_RECEIPT_D detail, string nUrgent, DbClient db)
        {
            Result<WMS_IQC_H> result = new(Result.Flags.Success, $"生成送检单成功");
            var nMaterial = Biz.Db.Queryable<WMS_MesMaterial>().Where(t => t.MCode.ToUpper() == detail.MATERIALCODE.ToUpper()).First();
            var nAql = Biz.Db.Queryable<WMS_IQCMATERIAL_AQL>().Where(t => t.MATERIALID.Equals(nMaterial.Id)).First();
            var nIqcHeader = new WMS_IQC_H
            {
                BILLCODE = iWMS.GetBillNoByType("IQC"),
                SOURCETYPE = (int)InventoryTransferSides.BillType.CustSupplyInStock,
                SOURCECODE = detail.BILLCODE,
                SOURCELINE = detail.BILLLINE,
                PONO = detail.SOURCECODE,
                POLINE = detail.POLINE ?? 0,
                MEASURE = nUrgent,
                QCTIMES = 0,
                QCSTATUS = (int)IqcManagementSides.QCStatus.UnFinish, /*(int)IqcManagementSides.QCStatus.UnFinish,*/
                QCRESULT = (int)IqcManagementSides.QCResult.Wait,
                QCREVIEW = (int)IqcManagementSides.QCReview.UnReview,
                CreationTime = DateTime.Now,
                CreatorUserId = 1,
                MATERIALCODE = detail.MATERIALCODE
                //ReceiveQty = detail.Qty, //生成送检单加上接收数量 2022/07/27 Ben Lin 2022/09/03 Ben Lin æ³¨é‡Š
            };
            var nIQCMaterial = Biz.Db.Queryable<WMS_IQCMATERIAL>().Where(t => t.MATERIALID.Equals(nMaterial.Id)).First();
            if (nIQCMaterial == null)
            {
                nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.NormalI;
            }
            //免检
            else if (nIQCMaterial.CHECKTYPE == "Exemption")
            {
                nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.Exemption;
            }
            //抽检
            else if (nIQCMaterial.CHECKTYPE == "Sampling")
            {
                var nIQCMaterial2AQL = Biz.Db.Queryable<WMS_IQCMATERIAL_AQL>().Where(t => t.IQCMATERIALID.Equals(nIQCMaterial.Id)).ToList();
                if (nIQCMaterial2AQL.Any())
                {
                    var nIQCMaterial2CheckItem = Biz.Db.Queryable<WMS_IQCMATERIAL_CHECKITEM>().Where(t => t.IQCMATERIALID.Equals(nIQCMaterial.Id)).ToList();
                    if (nIQCMaterial2CheckItem.Any())
                    {
                        //高检II,抽检物料,AQL和检验项目都维护了
                        nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.HighII;
                        Result<WMS_IQC_H> result1 = GetAqlSettingAsync(nAql, nIqcHeader, detail, db);
                        if (result1.Flag != Result.Flags.Success)
                        {
                            result.Flag = result1.Flag;
                            result.Message = result1.Message;
                        }
                        else
                        {
                            nIqcHeader = result1.Data;
                        }
                    }
                    else
                    {
                        //高检I,抽检物料,维护了AQL、但是没有维护检验项目
                        nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.HighI;
                        Result<WMS_IQC_H> result2 = GetAqlSettingAsync(nAql, nIqcHeader, detail, db);
                        if (result2.Flag != Result.Flags.Success)
                        {
                            result.Flag = result2.Flag;
                            result.Message = result2.Message;
                        }
                        else
                        {
                            nIqcHeader = result2.Data;
                        }
                    }
                }
                else
                {
                    var nIQCMaterial2CheckItem = Biz.Db.Queryable<WMS_IQCMATERIAL_CHECKITEM>().Where(t => t.IQCMATERIALID.Equals(nIQCMaterial.Id)).ToList();
                    if (nIQCMaterial2CheckItem.Any())
                    {
                        //普检II,抽检物料,没有维护AQL、但是维护了检验项目
                        nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.NormalII;
                    }
                    else
                    {
                        //普检I,抽检物料,但是没有维护AQL和检验项目
                        nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.NormalI;
                    }
                }
            }
            //全检
            else if (nIQCMaterial.CHECKTYPE == "FullInspection")
            {
                nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.FullInspection;
                nIqcHeader.SAMPLENGQTY = detail.QTY;
            }
            result.Data = nIqcHeader;
            return result;
        }
        private static Result<WMS_IQC_H> GetAqlSettingAsync(WMS_IQCMATERIAL_AQL nAql, WMS_IQC_H nIqcHeader, WMS_RECEIPT_D nDetail, DbClient db)
        {
            Result<WMS_IQC_H> result = new(Result.Flags.Success, $"获取Aql成功");
            if (nAql.AUTOSTRICT == true)
            {
                nIqcHeader.STRICTLEVEL = nAql.CURRENTSTRICT.IsNullOrEmpty() ? nAql.DEFAULTSTRICT : nAql.CURRENTSTRICT;
                nIqcHeader.LEVELCODE = nIqcHeader.STRICTLEVEL.ToUpper() == "NORMAL" ? nAql.NORMALLEVEL : (nIqcHeader.STRICTLEVEL.ToUpper() == "STRICT" ? nAql.STRICTLEVEL : nAql.RELAXLEVEL);
                nIqcHeader.AQL = nIqcHeader.STRICTLEVEL.ToUpper() == "NORMAL" ? nAql.NORMALAQLLEVEL : (nIqcHeader.STRICTLEVEL.ToUpper() == "STRICT" ? nAql.STRICTAQLLEVEL : nAql.RELAXAQLLEVEL);
            }
            else
            {
                nIqcHeader.STRICTLEVEL = nAql.DEFAULTSTRICT;
                nIqcHeader.LEVELCODE = nAql.DEFAULTLEVEL;
                nIqcHeader.AQL = nAql.DEFAULTAQL;
            }
            //找到该 LevelCode和AqlCode配置下,符合的批次数量范围
            var nAqlDetail = Biz.Db.Queryable<WMS_AQL_D>()
                .Where(t => t.LEVELCODE.ToUpper() == nIqcHeader.LEVELCODE.ToUpper() && t.AQLCODE.ToUpper() == nIqcHeader.AQL.ToUpper())
                .Where(t => t.LOTMAXQTY >= nDetail.QTY && t.LOTMAXQTY <= nDetail.QTY)
                .First();
            if (nAqlDetail == null)
            {
                result.Flag = Result.Flags.Failed;
                result.Message = $"未能在水准[{nIqcHeader.LEVELCODE}]下的AQL[{nIqcHeader.AQL}]下找到符合[{nDetail.QTY}]的批次范围";
            }
            nIqcHeader.BEGINQTY = nAqlDetail.LOTMINQTY;
            nIqcHeader.ENDQTY = nAqlDetail.LOTMAXQTY;
            nIqcHeader.SAMPLEQTY = nAqlDetail.SAMPLEQTY > nDetail.QTY ? nDetail.QTY : nAqlDetail.SAMPLEQTY;
            result.Data = nIqcHeader;
            return result;
        }
    }//endClass
}
Tiger.Business.WMS/SqlSugarHepler/BizSqlsugar.cs
Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/MaterialInfoBusiness.cs ÐÞ¸Ä
@@ -9,14 +9,13 @@
using System.Linq;
using System.Threading.Tasks;
using Tiger.Business.SqlSugarHepler;
using Tiger.Business.WMS.iSRM;
using Tiger.IBusiness;
using Tiger.Model;
using Tiger.Model.DTO;
using Tiger.Model.Entitys.MES;
using Tiger.Model.Entitys.WMS.DTOS;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/T100ToWMS/OtherOutInfoBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/OtherOutInfoBusiness.cs ÐÞ¸Ä
@@ -9,7 +9,7 @@
using Tiger.Model.Entitys.WMS.DTOS;
using Tiger.Model.Extensions;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/T100ToWMS/ProductInputBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/ProductInputBusiness.cs ÐÞ¸Ä
@@ -13,7 +13,7 @@
using Tiger.Model.Entitys.MES;
using Tiger.Model.Entitys.WMS.DTOS;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/T100ToWMS/ProductOutputtBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/ProductOutputtBusiness.cs ÐÞ¸Ä
@@ -10,7 +10,7 @@
using Tiger.Model;
using Tiger.Model.Entitys.WMS.DTOS;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/T100ToWMS/ReworkBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/ReworkBusiness.cs ÐÞ¸Ä
@@ -9,7 +9,7 @@
using Tiger.Model.Entitys.WMS.DTOS;
using Tiger.Model.Extensions;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/T100ToWMS/SaleOutInfoBusiness.cs
Tiger.Business.WMS/T100ToWMS/SplitBoxBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/SplitBoxBusiness.cs ÐÞ¸Ä
@@ -9,7 +9,7 @@
using Tiger.Model;
using Tiger.Model.Entitys.WMS.DTOS;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/T100ToWMS/StockInfoBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/StockInfoBusiness.cs ÐÞ¸Ä
@@ -8,7 +8,7 @@
using Tiger.Model;
using Tiger.Model.Entitys.WMS.DTOS;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/T100ToWMS/TrasferInfoBusiness.cs
ÎļþÃû´Ó Tiger.Business/WMS/T100ToWMS/TrasferInfoBusiness.cs ÐÞ¸Ä
@@ -8,7 +8,7 @@
using Tiger.Model.Entitys.WMS.DTOS;
using Tiger.Model.Extensions;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    ///
Tiger.Business.WMS/Task/DBBackup/Jobs.DbBackupJob.cs
ÎļþÃû´Ó Tiger.Business/TSK/DBBackup/Jobs.DbBackupJob.cs ÐÞ¸Ä
@@ -15,7 +15,7 @@
using Tiger.Model.Entitys.WMS.DTOS;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    /// å¤‡ä»½å®šæ—¶ä»»åŠ¡
Tiger.Business.WMS/Task/ERP/Jobs.ProdMaterialReqToErpJob.cs
ÎļþÃû´Ó Tiger.Business/TSK/ERP/Jobs.ProdMaterialReqToErpJob.cs ÐÞ¸Ä
@@ -14,7 +14,7 @@
using Tiger.Model.Entitys.WMS.DTOS;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    /// é¢†æ–™å•定时过账
Tiger.Business.WMS/Task/ERP/Jobs.ReceiptHToErpJob.cs
ÎļþÃû´Ó Tiger.Business/TSK/ERP/Jobs.ReceiptHToErpJob.cs ÐÞ¸Ä
@@ -12,7 +12,7 @@
using Tiger.Model.Entitys.WMS.DTOS;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    /// XCXJ据点到货单推T100
@@ -27,7 +27,7 @@
        {
            try
            {
                var result = Biz.iWMS.ReceiptHToErp("XCSJ", context.Trigger.ConvertToMonitor());
                var result = iWMS.ReceiptHToErp("XCSJ", context.Trigger.ConvertToMonitor());
                if (!result.IsSuccessed)
                {
                    Logger.Scheduler.Error($"生成到货异常:{result.Message}");
@@ -55,7 +55,7 @@
        {
            try
            {
                var result = Biz.iWMS.ReceiptHToErp("DGXC", context.Trigger.ConvertToMonitor());
                var result = iWMS.ReceiptHToErp("DGXC", context.Trigger.ConvertToMonitor());
                //Thread.Sleep(10*60*1000);
                if (!result.IsSuccessed)
                {
@@ -84,7 +84,7 @@
        {
            try
            {
                var result = Biz.iWMS.ReceiptHToErp("AHXC", context.Trigger.ConvertToMonitor());
                var result = iWMS.ReceiptHToErp("AHXC", context.Trigger.ConvertToMonitor());
                if (!result.IsSuccessed)
                {
                    Logger.Scheduler.Error($"生成到货异常:{result.Message}");
Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs
ÎļþÃû´Ó Tiger.Business/TSK/ERP/Jobs.VenderFromErpJob.cs ÐÞ¸Ä
@@ -9,7 +9,7 @@
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    /// XCXJ据点到货单推T100
Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs
ÎļþÃû´Ó Tiger.Business/TSK/iSRM/Jobs.QqtSrmJob.cs ÐÞ¸Ä
@@ -10,7 +10,7 @@
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    /// ä¼ä¼é€šSRM作业
@@ -37,7 +37,7 @@
                        startDate = LastRunTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        endDate = LastRunTime.AddMinutes(30).ToString("yyyy-MM-dd HH:mm:ss")
                    };
                    var result = Biz.iSRM.GetSuppDlvy(iSrmParams);
                    var result = iSRM.GetSuppDlvy(iSrmParams);
                    if (!result.IsSuccessed)
                    {
                        Logger.Scheduler.Error($"获取送货单异常:{result.Message}");
@@ -182,7 +182,7 @@
                var LastRunTime = LastRun.IsNullOrEmpty() ? DateTime.Now.AddMinutes(-30) : LastRun.Text.ToDateTime();
                if ((DateTime.Now - LastRunTime).TotalMinutes > 30)
                {
                    Biz.iSRM.GetNoList(LastRunTime, LastRunTime.AddMinutes(30));
                    iSRM.GetNoList(LastRunTime, LastRunTime.AddMinutes(30));
                }
                //SaveLog(context, "SRM接口任务");
            }
@@ -197,7 +197,7 @@
                    var dlvyList = Biz.Db.Queryable<WMS_SRMRcece>().Where(q => q.FLAW == "N").ToList();
                    foreach (var dlvy in dlvyList)
                    {
                        Biz.iSRM.GetDetail(dlvy);
                        iSRM.GetDetail(dlvy);
                    }
                    Logger.Scheduler.Info($"SRM Get Delivery List[{dlvyList.Count}] done");
                }
Tiger.Business.WMS/Tiger.Business.WMS.csproj
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\Tiger.Business\Tiger.Business.csproj" />
    <ProjectReference Include="..\Tiger.IBusiness\Tiger.IBusiness.csproj" />
  </ItemGroup>
  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="xcopy /r/y/i $(ProjectDir)$(OutDir)$(AssemblyName).dll $(SolutionDir)Tiger.Api\$(OutDir)&#xD;&#xA;xcopy /r/y/i $(ProjectDir)$(OutDir)$(AssemblyName).pdb $(SolutionDir)Tiger.Api\$(OutDir)&#xD;&#xA;xcopy /r/y/i $(ProjectDir)$(OutDir)BizSettings.json $(SolutionDir)Tiger.Api\$(OutDir)" />
  </Target>
</Project>
Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/CustSupplyCheckingNew.cs ÐÞ¸Ä
@@ -135,7 +135,7 @@
                    return action;
                }
                input.AuthOption.OrgCode = input.AuthOption.OrgCode.IsNullOrEmpty() ? input.AuthOption.CurOrg : input.AuthOption.OrgCode;
                Result<Inventory> result = Biz.WmsItem.GetK(input.SN, input.AuthOption, false);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.GetK(input.SN, input.AuthOption, false);
                if (result.Flag != Result.Flags.Success)
                {
                    action.IsSuccessed = false;
@@ -336,7 +336,7 @@
                //var nWarehouseCodes = nScannedBarcodes.Select(x => x.WarehouseCode).Distinct().ToList();
                //新建其他入库单据头 OtherInstockHeader
                Result ruleResult = Biz.CodeRule["CI001"].Generate("CI");  //Biz.iWMS.GetBillNoByType("CI");
                Result ruleResult = Biz.CodeRule["CI001"].Generate("CI");  //iWMS.GetBillNoByType("CI");
                if (!ruleResult.IsSuccessed)
                {
                    throw new Exception(ruleResult.ExceptionMsg.Message);
@@ -499,7 +499,7 @@
                var customsData = Biz.Db.Queryable<BIZ_ERP_CUSTOMS>().Where(i => sns.Contains(i.Barcodes)).First();
                //调用T100接口生成到货单
                var ret = Biz.ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                var ret = ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                {
                    parameter = new Parameter<Detail>
                    {
@@ -531,7 +531,7 @@
                    foreach (var item in iqcHeaders)
                    {
                        var retIns = Biz.ErpT100.GenerateInspection(new InsInputParameter
                        var retIns = ErpT100.GenerateInspection(new InsInputParameter
                        {
                            parameter = new InsParameter
                            {
Tiger.Business.WMS/Transaction/CustomerSupplyInNew.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/CustomerSupplyInNew.cs ÐÞ¸Ä
@@ -79,7 +79,7 @@
                        pmdt018 = billHeader.REMARK
                    });
                }
                var ret = Biz.ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                var ret = ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                {
                    parameter = new InParameter<Detail4>
                    {
@@ -144,7 +144,7 @@
                }
                var nLocation = new WMS_LOCATION();
                input.AuthOption.OrgCode.IsNullOrEmpty(input.AuthOption.CurOrg);
                Result<Inventory> result = Biz.WmsItem.GetK(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.GetK(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -278,7 +278,7 @@
                }
                //执行入库
                Result<PutOnInfo> onResult = Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                Result<PutOnInfo> onResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                if (!onResult.IsSuccessed) {
                    action.IsSuccessed = false;
                    action.LocaleMsg = onResult.LocaleMsg;
@@ -362,7 +362,7 @@
                            pmdt018 = billHeader.REMARK
                        });
                    }
                    var ret = Biz.ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                    var ret = ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                    {
                        parameter = new InParameter<Detail4>
                        {
@@ -411,7 +411,7 @@
                    //StateFlag = inv.StateFlag,
                    LocationCode = nLocation.LOCATION_CODE,
                    ReceiptCode = barcodeScanned?.BUSINESSCODE,
                    IncompleteTips = Biz.iWMS.GetERP_OTH_INTips(barcodeScanned?.BUSINESSCODE, barcodeScanned?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    IncompleteTips = iWMS.GetERP_OTH_INTips(barcodeScanned?.BUSINESSCODE, barcodeScanned?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    IsScanShelf = false
                };
            }
Tiger.Business.WMS/Transaction/InFinished.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/InFinished.cs ÐÞ¸Ä
@@ -99,7 +99,7 @@
                BillCode = input.FinishedNo;
                action.Data = new FinishedInput
                {
                    IncompleteTips = Biz.iWMS.GetBIZ_ERP_PROD_INips(BillCode),//isCompleted ? "数量:0 (0盘)" :
                    IncompleteTips = iWMS.GetBIZ_ERP_PROD_INips(BillCode),//isCompleted ? "数量:0 (0盘)" :
                };
                action.LocaleMsg = Biz.L("选择完工入库单成功");
            }
@@ -137,7 +137,7 @@
                    return action;
                }
                var nLocation = new WMS_LOCATION();
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -270,7 +270,7 @@
                }
                //执行入库
                Result<PutOnInfo> onResult = Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                Result<PutOnInfo> onResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                if (!onResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -356,7 +356,7 @@
                    //StateFlag = inv.StateFlag,
                    LocationCode = nLocation.LOCATION_CODE,
                    ReceiptCode = barcodeScanned?.BUSINESSCODE,
                    IncompleteTips = Biz.iWMS.GetFinishedTips(barcodeScanned?.BUSINESSCODE, barcodeScanned?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    IncompleteTips = iWMS.GetFinishedTips(barcodeScanned?.BUSINESSCODE, barcodeScanned?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    IsScanShelf = false
                };
            }
Tiger.Business.WMS/Transaction/InMatStorage.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/InMatStorage.cs ÐÞ¸Ä
@@ -70,7 +70,7 @@
                    return action;
                }
                var nLocation = new WMS_LOCATION();
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -209,7 +209,7 @@
                }
                //执行入库
                Result<PutOnInfo> onResult = Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                Result<PutOnInfo> onResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                if (!onResult.IsSuccessed) {
                    action.IsSuccessed = false;
                    action.LocaleMsg = onResult.LocaleMsg;
@@ -310,7 +310,7 @@
                            pmdt018 = billHeader.REMARK
                        });
                    }
                    var ret = Biz.ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                    var ret = ErpT100.GenerateOtherIn(new OtherInputParameter<Detail4>
                    {
                        parameter = new InParameter<Detail4>
                        {
@@ -356,7 +356,7 @@
                    itemDesc = inv.ItemInfo.SPEC,
                    qty = inv.CurPkg.QTY,
                    dateCode = inv.Barcode.ProdDate.ToString()??DateTime.MinValue.ToString(),
                    Tips = Biz.iWMS.GetERP_RECEIPTTips(barcodeScanneds[0]?.BILLCODE, barcodeScanneds[0]?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    Tips = iWMS.GetERP_RECEIPTTips(barcodeScanneds[0]?.BILLCODE, barcodeScanneds[0]?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    IsScanShelf = false
                };
            }
Tiger.Business.WMS/Transaction/InProductionReturn.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/InProductionReturn.cs ÐÞ¸Ä
@@ -87,11 +87,11 @@
                Result<Inventory> result = new();
                if (WarehouseName.Contains("客供"))
                {
                    result = Biz.WmsItem.GetK(input.SN, input.AuthOption, true);
                    result = WMS_ITEM_Biz.WmsItem.GetK(input.SN, input.AuthOption, true);
                }
                else
                {
                    result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                    result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                }
                if (!result.IsSuccessed)
                {
@@ -258,7 +258,7 @@
                }
                //执行入库
                Result<PutOnInfo> onResult = Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                Result<PutOnInfo> onResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                if (!onResult.IsSuccessed) {
                    action.IsSuccessed = false;
                    action.LocaleMsg = onResult.LocaleMsg;
@@ -415,7 +415,7 @@
                    qty = inv.CurPkg.QTY,
  
                    dateCode = inv.Barcode.ProdDate.ToString()??DateTime.MinValue.ToString(),
                    Tips = Biz.iWMS.GetERP_ReturnTips(barcodeScanneds?.BUSINESSCODE, barcodeScanneds?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    Tips = iWMS.GetERP_ReturnTips(barcodeScanneds?.BUSINESSCODE, barcodeScanneds?.ITEM_CODE),//isCompleted ? "数量:0 (0盘)" :
                    IsScanShelf = false
                };
            }
Tiger.Business.WMS/Transaction/InReceipt.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/InReceipt.cs ÐÞ¸Ä
@@ -92,7 +92,7 @@
                #endregion æŠ¥å…³å•号判断
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, false);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, false);
                if (result.Flag != Result.Flags.Success)
                {
                    action.IsSuccessed = false;
@@ -494,7 +494,7 @@
                    }
                    //调用T100接口生成到货单
                    var ret = Biz.ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                    var ret = ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                    {
                        parameter = new Parameter<Detail>
                        {
@@ -525,7 +525,7 @@
                        foreach (var item in iqcHeaders_n)
                        {
                            var retIns = Biz.ErpT100.GenerateInspection(new InsInputParameter
                            var retIns = ErpT100.GenerateInspection(new InsInputParameter
                            {
                                parameter = new InsParameter
                                {
Tiger.Business.WMS/Transaction/ItemQuery.cs
Tiger.Business.WMS/Transaction/LocationTransfer.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/LocationTransfer.cs ÐÞ¸Ä
@@ -100,7 +100,7 @@
                    return action;
                }
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -170,7 +170,7 @@
                }
                //执行入库
                Result<PutOnInfo> onResult = Biz.WmsItem.PutOn(inv, input.AuthOption, target?.LOCATION_CODE, true);
                Result<PutOnInfo> onResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, target?.LOCATION_CODE, true);
                if (!onResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
Tiger.Business.WMS/Transaction/OtherInLocation.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OtherInLocation.cs ÐÞ¸Ä
@@ -74,11 +74,11 @@
                    Result<Inventory> res = new();
                    if (WarehouseName.Contains("客供"))
                    {
                        res = Biz.WmsItem.GetK(input.SN, new() { UserId = "admin" }, true);
                        res = WMS_ITEM_Biz.WmsItem.GetK(input.SN, new() { UserId = "admin" }, true);
                    }
                    else
                    {
                        res = Biz.WmsItem.Get(input.SN, new() { UserId = "admin" }, true);
                        res = WMS_ITEM_Biz.WmsItem.Get(input.SN, new() { UserId = "admin" }, true);
                    }
                    //判断是否一维码
                    if (!res.Data.IsQRCode)
@@ -244,7 +244,7 @@
                    }
                    //执行入库
                    Result<PutOnInfo> putonResult = Biz.WmsItem.PutOn(res.Data, input.AuthOption, nLocation.LOCATION_CODE);
                    Result<PutOnInfo> putonResult = WMS_ITEM_Biz.WmsItem.PutOn(res.Data, input.AuthOption, nLocation.LOCATION_CODE);
                    if (!putonResult.IsSuccessed)
                    {
                        action.IsSuccessed = false;
@@ -294,7 +294,7 @@
                                              //SourceBillCode = billCode,
                        LocationCode = nLocation.LOCATION_CODE,
                        //ReceiptCode = barcodeScanned?.BUSINESSCODE,
                        //IncompleteTips = isCompleted ? "数量:0 (0盘)" : Biz.iWMS.GetIncompleteTipsNew(barcodeScanned?.BUSINESSCODE, barcodeScanned?.ITEM_CODE),
                        //IncompleteTips = isCompleted ? "数量:0 (0盘)" : iWMS.GetIncompleteTipsNew(barcodeScanned?.BUSINESSCODE, barcodeScanned?.ITEM_CODE),
                        IsScanShelf = false
                    };
                    action.LocaleMsg = Biz.L("入库成功{0}", res.Data.SN);
@@ -303,7 +303,7 @@
                //其他入库
                if (input.ReqType == 1)
                {
                    Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                    Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                    if (!result.IsSuccessed)
                    {
                        action.IsSuccessed = false;
@@ -407,7 +407,7 @@
                    }
                    //执行入库
                    Result<PutOnInfo> onResult = Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                    Result<PutOnInfo> onResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                    if (!onResult.IsSuccessed)
                    {
                        action.IsSuccessed = false;
@@ -501,7 +501,7 @@
                        //SourceBillLine = Convert.ToInt32(billLine),
                        LocationCode = nLocation.LOCATION_CODE,
                        //ReceiptCode = barcodeScanned?.BUSINESSCODE,
                        IncompleteTips = isCompleted ? "数量:0 (0盘)" : Biz.iWMS.GetERP_OTH_INTips(billCode, inv.ItemInfo?.ITEM_CODE),
                        IncompleteTips = isCompleted ? "数量:0 (0盘)" : iWMS.GetERP_OTH_INTips(billCode, inv.ItemInfo?.ITEM_CODE),
                        IsScanShelf = false
                    };
                    action.Message = $"其他入库单[{billCode}],条码[{inv.SN}],上架成功";
Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OtherInLocationChecking.cs ÐÞ¸Ä
@@ -110,7 +110,7 @@
                    return action;
                }
                input.AuthOption.OrgCode = input.AuthOption.OrgCode.IsNullOrEmpty() ? input.AuthOption.CurOrg : input.AuthOption.OrgCode;
                Result<Inventory> result = WarehouseName.Contains("客供") ? Biz.WmsItem.GetK(input.SN, input.AuthOption, false) : Biz.WmsItem.Get(input.SN, input.AuthOption, false);
                Result<Inventory> result = WarehouseName.Contains("客供") ? WMS_ITEM_Biz.WmsItem.GetK(input.SN, input.AuthOption, false) : WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, false);
                if (result.Flag != Result.Flags.Success)
                {
                    action.IsSuccessed = false;
@@ -303,7 +303,7 @@
                //var nWarehouseCodes = nScannedBarcodes.Select(x => x.WarehouseCode).Distinct().ToList();
                //新建其他入库单据头 OtherInstockHeader
                Result ruleResult = Biz.CodeRule["OI001"].Generate("OI");  //Biz.iWMS.GetBillNoByType("CI");
                Result ruleResult = Biz.CodeRule["OI001"].Generate("OI");  //iWMS.GetBillNoByType("CI");
                if (!ruleResult.IsSuccessed)
                {
                    throw new Exception(ruleResult.ExceptionMsg.Message);
Tiger.Business.WMS/Transaction/OutNoBillcode.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OutNoBillcode.cs ÐÞ¸Ä
@@ -24,7 +24,7 @@
            UserCode = userCode;
            ApiHost = apiHost;
            OrgCode = orgCode;
            Result ruleResult = Biz.CodeRule["NB001"].Generate("NB");  //Biz.iWMS.GetBillNoByType("CI");
            Result ruleResult = Biz.CodeRule["NB001"].Generate("NB");  //iWMS.GetBillNoByType("CI");
            if (!ruleResult.IsSuccessed)
            {
                throw new Exception(ruleResult.ExceptionMsg.Message);
@@ -80,7 +80,7 @@
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
Tiger.Business.WMS/Transaction/OutOther.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OutOther.cs ÐÞ¸Ä
@@ -238,7 +238,7 @@
                        {
                            lock (item.Key.lockObj)
                            {
                                dic[item.Key] = Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, req.Dtls.Where(q=>q.ITEM_CODE==item.Key.ItemCode).Select(s=>s.WAREHOUSECODE).FirstOrDefault(), null, null, null, input.AuthOption, item.Key.actQty);
                                dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, req.Dtls.Where(q=>q.ITEM_CODE==item.Key.ItemCode).Select(s=>s.WAREHOUSECODE).FirstOrDefault(), null, null, null, input.AuthOption, item.Key.actQty);
                            }
                        });
                    }
@@ -360,7 +360,7 @@
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -607,7 +607,7 @@
                    item.TRANS_NO = req.BILLCODE;
                    item.TRANS_LINE = string.Join(",", dtls.Select(x => x.BILLLINE));
                }
                Result<TakeDownInfo> downResult = Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                Result<TakeDownInfo> downResult = WMS_ITEM_Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                if (!downResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
Tiger.Business.WMS/Transaction/OutSale.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OutSale.cs ÐÞ¸Ä
@@ -83,7 +83,7 @@
                    {
                        lock (item.Key.lockObj)
                        {
                            dic[item.Key] = Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                            dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                        }
                    });
                }
@@ -285,7 +285,7 @@
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -496,7 +496,7 @@
                    item.TRANS_NO = req.BILLCODE;
                    item.TRANS_LINE = string.Join(",", dtls.Select(x => x.BILLLINE));
                }
                Result<TakeDownInfo> downResult = Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                Result<TakeDownInfo> downResult = WMS_ITEM_Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                if (!downResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -540,7 +540,7 @@
                        CompanyId = OrgCode
                    };
                    //异步调用T100过账
                    //Biz.iWMS.MaterialReqToErpNew(mReqPostParam);
                    //iWMS.MaterialReqToErpNew(mReqPostParam);
                }
                action.LocaleMsg = Biz.L($"销售出库 =>销售出库完成,单号:[{req.BILLCODE}],状态:{req.STATUS.GetEnumDesc<BIZ_ERP_SALE_OUT.STATUSs>()}");
Tiger.Business.WMS/Transaction/OutSplit.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OutSplit.cs ÐÞ¸Ä
@@ -63,7 +63,7 @@
                    return action;
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -379,7 +379,7 @@
                        var sctrwo = query != null ? (query.TARGET_WORKORDER.IsNullOrEmpty() ? sourcecode : query.TARGET_WORKORDER) : sourcecode;
                        toMes = new ProductionPickToMes()
                        {
                            qrcode = Biz.WmsItem.GetQRCode(nSplitBarcode1.SN),
                            qrcode = WMS_ITEM_Biz.WmsItem.GetQRCode(nSplitBarcode1.SN),
                            wo = sctrwo, // nCurrentLines.First().SourceCode,
                            pkgid = nSplitBarcode1.SN,
                            mfrkp = CurInv.Barcode.OEMItemCode,
Tiger.Business.WMS/Transaction/OutTransfer.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OutTransfer.cs ÐÞ¸Ä
@@ -91,7 +91,7 @@
                    {
                        lock (item.Key.lockObj)
                        {
                            dic[item.Key] = Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                            dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                        }
                    });
                }
@@ -293,7 +293,7 @@
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -497,7 +497,7 @@
                //    item.SOURCE_CODE = "WORK_ORDER";
                //    item.SOURCE_ORDER = dtls.First().SOURCECODE;
                //}
                //Result<TakeDownInfo> downResult = Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended);
                //Result<TakeDownInfo> downResult = WMS_ITEM_Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended);
                //if (!downResult.IsSuccessed)
                //{
                //    action.IsSuccessed = false;
@@ -620,7 +620,7 @@
                    item.SOURCE_CODE = "WORK_ORDER";
                    item.SOURCE_ORDER = dtls.First().SOURCECODE;
                }
                Result<TakeDownInfo> downResult = Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                Result<TakeDownInfo> downResult = WMS_ITEM_Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                if (!downResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
Tiger.Business.WMS/Transaction/OutWorkOrder.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/OutWorkOrder.cs ÐÞ¸Ä
@@ -259,7 +259,7 @@
                        {
                            lock (item.Key.lockObj)
                            {
                                dic[item.Key] = Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                                dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                            }
                        });
                    }
@@ -380,7 +380,7 @@
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -701,7 +701,7 @@
                    item.SOURCE_CODE = "WORK_ORDER";
                    item.SOURCE_ORDER = dtls.First().SOURCECODE;
                }
                Result<TakeDownInfo> downResult = Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                Result<TakeDownInfo> downResult = WMS_ITEM_Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                if (!downResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/ProductionMaterialReq.cs ÐÞ¸Ä
@@ -131,7 +131,7 @@
                if (CurReqType == ReqType.IsAgv)
                {
                    //推荐物料
                    Result<List<SuggestItem>> result = Biz.WmsItem.Suggest(req.BILLCODE, req.Dtls[0].ITEM_CODE, req.Dtls[0].WAREHOUSECODE, null, null, null, input.AuthOption, 1);
                    Result<List<SuggestItem>> result = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, req.Dtls[0].ITEM_CODE, req.Dtls[0].WAREHOUSECODE, null, null, null, input.AuthOption, 1);
                    action.LocaleMsg = result.LocaleMsg;
                    if (result.IsException)
                    {
@@ -173,7 +173,7 @@
                        {
                            lock (item.Key.lockObj)
                            {
                                dic[item.Key] = Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, 1);
                                dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, 1);
                            }
                        });
                    }
@@ -226,7 +226,7 @@
                        {
                            lock (item.Key.lockObj)
                            {
                                dic[item.Key] = Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                                dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty);
                            }
                        });
                    }
@@ -369,7 +369,7 @@
                        {
                            lock (item.Key.lockObj)
                            {
                                dic[item.Key] = Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, req.Dtls[0].WAREHOUSECODE, null, null, null, SelectOrderOption, item.Key.actQty);
                                dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, req.Dtls[0].WAREHOUSECODE, null, null, null, SelectOrderOption, item.Key.actQty);
                            }
                        });
                    }
@@ -506,7 +506,7 @@
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -835,7 +835,7 @@
                    item.SOURCE_CODE = "WORK_ORDER";
                    item.SOURCE_ORDER = dtls.First().SOURCECODE;
                }
                Result<TakeDownInfo> downResult = Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                Result<TakeDownInfo> downResult = WMS_ITEM_Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting);
                if (!downResult.IsSuccessed)
                {
                    ProcessingSn = "";
Tiger.Business.WMS/Transaction/Resell.cs
Tiger.Business.WMS/Transaction/ShelfRemote.cs
Tiger.Business.WMS/Transaction/WMSTransactionBase.cs
Tiger.Business.WMS/Transaction/WmsCount.cs
ÎļþÃû´Ó Tiger.Business/WMS/Transaction/WmsCount.cs ÐÞ¸Ä
@@ -205,7 +205,7 @@
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
Tiger.Business.WMS/WMSContext.cs
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;
        }
Tiger.Business.WMS/iSRM/SrmDataToSiHua.cs
ÎļþÃû´Ó Tiger.Business/WMS/iSRM/SrmDataToSiHua.cs ÐÞ¸Ä
@@ -9,7 +9,7 @@
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    public class SrmDataToSiHua : ISrmDataToSiHua
    {
Tiger.Business.WMS/iSRM/SrmParam.cs
ÎļþÃû´Ó Tiger.Business/WMS/iSRM/SrmParam.cs ÐÞ¸Ä
@@ -5,7 +5,7 @@
using System.Text;
using System.Threading.Tasks;
namespace Tiger.Business.WMS.iSRM
namespace Tiger.Business.WMS
{
    public class SrmParam
    {
Tiger.Business.WMS/iSRM/SrmToWms.cs
ÎļþÃû´Ó Tiger.Business/WMS/iSRM/SrmToWms.cs ÐÞ¸Ä
@@ -13,7 +13,7 @@
using SqlSugar;
using Org.BouncyCastle.Ocsp;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    public class SrmToWms : ISrmToWms
    {
@@ -99,8 +99,8 @@
                                asn.innerVendorName = dlvy.supplierName;
                                //asn.deliveryType = dlvy["deliveryType"]?.ToInt32() ?? 0;
                                //asn.logisticsStatus = dlvy["logisticsStatus"]?.ToInt32() ?? 0;
                                asn.deliveryDate = Biz.iSRM.FromUnixTime(Convert.ToInt64(dlvy.deliveryDate));
                                asn.planArrivedDate = Biz.iSRM.FromUnixTime(Convert.ToInt64(dlvy.bookDeliveryDate));
                                asn.deliveryDate = iSRM.FromUnixTime(Convert.ToInt64(dlvy.deliveryDate));
                                asn.planArrivedDate = iSRM.FromUnixTime(Convert.ToInt64(dlvy.bookDeliveryDate));
                                asn.CreationTime = DateTime.Now;
                                asn.LastModificationTime = DateTime.Now;
                                //asn.updateTime = FromUnixTime(dlvy["updateTime"]?.ToInt64());
@@ -281,8 +281,8 @@
                            SUPP_CODE = dlvy.supplierCode,
                            HANDLED = 0,
                            SUPP_NAME = dlvy.supplierName,
                            DELIVERY_DATE = Biz.iSRM.FromUnixTime(Convert.ToInt64(dlvy.deliveryDate)),
                            PLANARRIVED_DATE = Biz.iSRM.FromUnixTime(Convert.ToInt64(dlvy.bookDeliveryDate)),
                            DELIVERY_DATE = iSRM.FromUnixTime(Convert.ToInt64(dlvy.deliveryDate)),
                            PLANARRIVED_DATE = iSRM.FromUnixTime(Convert.ToInt64(dlvy.bookDeliveryDate)),
                            AUTH_ORG = dlvy.company,
                        };
                        dlvyList.Add(_dlvy);
@@ -597,8 +597,8 @@
                                SUPP_CODE = dlvy.supplierCode,
                                HANDLED = 0,
                                SUPP_NAME = dlvy.supplierName,
                                DELIVERY_DATE = Biz.iSRM.FromUnixTime(Convert.ToInt64(dlvy.deliveryDate)),
                                PLANARRIVED_DATE = Biz.iSRM.FromUnixTime(Convert.ToInt64(dlvy.bookDeliveryDate)),
                                DELIVERY_DATE = iSRM.FromUnixTime(Convert.ToInt64(dlvy.deliveryDate)),
                                PLANARRIVED_DATE = iSRM.FromUnixTime(Convert.ToInt64(dlvy.bookDeliveryDate)),
                                AUTH_ORG = dlvy.company,
                            };
                            if (statusitem == 0)
Tiger.Business.WMS/iSRM/iSRM.cs
ÎļþÃû´Ó Tiger.Business/WMS/iSRM/Biz.iSRM.cs ÐÞ¸Ä
@@ -10,12 +10,9 @@
using Rhea.Common.Authorization;
using Tiger.Model.Minsun;
using Tiger.IBusiness;
using Tiger.Business.WMS.iSRM;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    public partial class Biz
    {
        /// <summary>
        /// SRM数据接口
        /// </summary>
@@ -810,5 +807,4 @@
                return result;
            }
        }
    }
}
Tiger.Business.WMS/iWMS/InventroyInfo.cs
ÎļþÃû´Ó Tiger.Business/WMS/iWMS/Biz.InventroyInfo.cs ÐÞ¸Ä
@@ -11,7 +11,7 @@
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    /// åº“存信息接口
Tiger.Business.WMS/iWMS/ProdMaterialReq.cs
ÎļþÃû´Ó Tiger.Business/WMS/iWMS/Biz.ProdMaterialReq.cs ÐÞ¸Ä
@@ -11,7 +11,7 @@
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    public class ProdMaterialReq : IProdMaterialReq
    {
@@ -266,7 +266,7 @@
                    if (req != null && dtlList.Where(x => x.LINESTATUS == BIZ_ERP_PROD_OUT.STATUSs.COMPLETE.GetValue()).Count() == dtlList.Count)
                    {
                        Logger.Interface.Info($"领料单[{reqNo}]重新过账准备进入过账进程");
                        Biz.iWMS.MaterialReqOldToErpNew(new MReqPostParam() {BillCode = req.BILLCODE, CompanyId=req.AUTH_ORG});
                        iWMS.MaterialReqOldToErpNew(new MReqPostParam() {BillCode = req.BILLCODE, CompanyId=req.AUTH_ORG});
                    }
                }
                    Logger.Interface.Info(action.Message);
@@ -379,7 +379,7 @@
                            sfdc007 = qty,
                        });
                    }
                    var ret = Biz.ErpT100.MaterialReqToErp(new ReqErpInputParameter
                    var ret = ErpT100.MaterialReqToErp(new ReqErpInputParameter
                    {
                        parameter = new Parameter4
                        {
Tiger.Business.WMS/iWMS/RePrintBarcode.cs
ÎļþÃû´Ó Tiger.Business/WMS/iWMS/Biz.RePrintBarcode.cs ÐÞ¸Ä
@@ -13,7 +13,7 @@
using Tiger.Model.Entitys.WMS.Api;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    /// <summary>
    /// è¡¥å°æ¡ç 
@@ -48,7 +48,7 @@
                OrgCode = input.AuthOption.OrgCode;
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
@@ -218,7 +218,7 @@
                    return action;
                }
                var nDisassembleBarcode = Biz.iWMS.SplitFullBarcode(input.Barcode).Data; //await _commonService.SplitFullBarcode(input.Barcode, true);
                var nDisassembleBarcode = iWMS.SplitFullBarcode(input.Barcode).Data; //await _commonService.SplitFullBarcode(input.Barcode, true);
                WMS_PO_H nOrderHeader = null;
                List<WMS_PO_D> nOrderDetails = new List<WMS_PO_D>();
                if (nDisassembleBarcode.OrderNo != null)
@@ -290,7 +290,7 @@
                    return action;
                }
                //解析条码
                Result<Inventory> result = Biz.WmsItem.Get(input.Barcode, new AuthOption { ByOrg = true, CurOrg = "DGXC", UserId = "admin" }, false);
                Result<Inventory> result = WMS_ITEM_Biz.WmsItem.Get(input.Barcode, new AuthOption { ByOrg = true, CurOrg = "DGXC", UserId = "admin" }, false);
                if (!result.IsSuccessed)
                {
                    action.IsSuccessed = false;
Tiger.Business.WMS/iWMS/ReceiptInfo.cs
ÎļþÃû´Ó Tiger.Business/WMS/iWMS/Biz.ReceiptInfo.cs ÐÞ¸Ä
@@ -10,7 +10,7 @@
using Tiger.Model;
using Tiger.Model.Minsun;
namespace Tiger.Business
namespace Tiger.Business.WMS
{
    public class ReceiptInfo : IReceiptInfo
    {
@@ -273,7 +273,7 @@
                    }
                    //调用T100接口生成到货单
                    var ret = Biz.ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                    var ret = ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                    {
                        parameter = new Parameter<Detail>
                        {
@@ -302,7 +302,7 @@
                        foreach (var item in iqcHeaders)
                        {
                            var retIns = Biz.ErpT100.GenerateInspection(new InsInputParameter
                            var retIns = ErpT100.GenerateInspection(new InsInputParameter
                            {
                                parameter = new InsParameter
                                {
Tiger.Business.WMS/iWMS/iWMS.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,982 @@
using Autofac;
using Newtonsoft.Json;
using Rhea.Common;
using SqlSugar;
using Swifter.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Business.WMS
{
    public partial class iWMS : IiWMS
    {
        /// <summary>
        /// å‘料单取消审核
        /// </summary>
        /// <param name="sn"></param>
        /// <returns></returns>
        public ApiAction MaterialRem(Model.Minsun.MaterialRem parameter)
        {
            var action = new ApiAction();
            try
            {
                if (!parameter.IsNullOrEmpty())
                {
                    var judian = BizConfig.Configuration["JuDian"];
                    Model.Minsun.WMS_PRDPICK_H entity_h = new();
                    List<Model.Minsun.WMS_PRDPICK_D> entity_d = new();
                    DbClient db = Business.Biz.Db;
                    if (parameter.ENTERPRISECODE == 88)
                    {
                        //判断是不是本据点s
                        if (parameter.STRONGHOID != judian)
                        {
                            if (parameter.STRONGHOID == "AHXC")
                            {
                                var requestJson = JsonConvert.SerializeObject(parameter);
                                var response = HttpHelper.PostAsync("http://172.18.8.56:9529/api/WMS/parameterRem", requestJson).Result;
                                action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                            }
                            if (parameter.STRONGHOID == "DGXC")
                            {
                                var requestJson = JsonConvert.SerializeObject(parameter);
                                var response = HttpHelper.PostAsync("http://172.18.8.56:9528/api/WMS/parameterRem", requestJson).Result;
                                action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                            }
                            if (parameter.STRONGHOID == "XCSJ")
                            {
                                var requestJson = JsonConvert.SerializeObject(parameter);
                                var response = HttpHelper.PostAsync("http://172.18.8.56:9527/api/WMS/parameterRem/", requestJson).Result;
                                action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                            }
                        }
                    }
                    else
                    {
                        //测试
                        db = Biz.DataSource["Test"].Client;
                    }
                    entity_h = db.Queryable<Model.Minsun.WMS_PRDPICK_H>().Where(q => q.BILLCODE == parameter.BILLCODE).First();
                    entity_d = db.Queryable<Model.Minsun.WMS_PRDPICK_D>().Where(q => q.BILLCODE == parameter.BILLCODE).ToList();
                    if (!entity_h.IsNullOrEmpty())
                    {
                        if (entity_h.STATUS == "COMPLETE")
                        {
                            action.Message = $"领料单{entity_h.BILLCODE}已经发料,不能取消";
                            action.IsSuccessed = false;
                            Logger.Interface.Info("单头:" + action.Message);
                        }
                        else
                        {
                            entity_h.STATUS = "DELETE";
                        }
                        if (entity_d.Count > 0)
                        {
                            foreach (var item in entity_d)
                            {
                                if (item.LINESTATUS == "COMPLETE" || item.QTY > 0)
                                {
                                    action.Message = $"领料单{item.BILLCODE}已经发料,不能取消";
                                    action.IsSuccessed = false;
                                    Logger.Interface.Info("单身:" + action.Message);
                                }
                                else
                                {
                                    item.LINESTATUS = "DELETE";
                                }
                            }
                        }
                    }
                    //数据库处理操作
                    if (action.IsSuccessed)
                    {
                        action.Message = $"领料单{entity_h.BILLCODE}取消审核成功";
                        var dbTran = db.UseTran(() =>
                        {
                            db.Updateable(entity_h).ExecuteCommand();
                            db.Updateable(entity_d).ExecuteCommand();
                            //db.Storageable(entity_h, "system").ExecuteCommand();
                            //db.Storageable(entity_d, "system").ExecuteCommand();
                        });
                        if (!dbTran.IsSuccess)
                        {
                            action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                        }
                    }
                    Logger.Interface.Info(action.Message);
                }
                return action;
            }
            catch (Exception ex)
            {
                return action.GetResponse().CatchExceptionWithLog(ex, $"发料单取消审核异常");
            }
        }
        /// <summary>
        /// é¢†æ–™å•过账到T100
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ApiAction MaterialReqToErp(MReqPostParam param)
        {
            var action = new ApiAction();
            Work.DoAsync(() =>
            {
                Thread.Sleep(3000);
                try
                {
                    Model.Minsun.WMS_PRDPICK_H entity_h = Biz.Db.Queryable<Model.Minsun.WMS_PRDPICK_H>().Where(x => x.BILLCODE == param.BillCode && x.ERP_BILL_CODE == null).First();
                    List<Model.Minsun.WMS_PRDPICK_D> entity_d = Biz.Db.Queryable<Model.Minsun.WMS_PRDPICK_D>().Where(x => x.BILLCODE == param.BillCode && Convert.ToInt32(x.PRQTY) != 0).ToList();
                    List<Detail5> details = new List<Detail5>();
                    foreach (var item in entity_d)
                    {
                        //计算数量
                        var qty = item.QTY > item.PRQTY ? item.PRQTY.ToString() : item.QTY.ToString();
                        details.Add(new Detail5
                        {
                            sfdcseq = item.BILLLINE.ToString(),
                            sfdc001 = item.SOURCECODE,
                            sfdc002 = item.SOURCELINE.ToString(),
                            sfdc003 = item.SOURCETYPE.ToString(),
                            sfdc007 = qty,
                        });
                    }
                    var ret = ErpT100.MaterialReqToErp(new ReqErpInputParameter
                    {
                        parameter = new Parameter4
                        {
                            sfdatype = entity_h.SOURCETYPE.ToString(),
                            sfdadocno = entity_h.BILLCODE,
                            detail = details
                        },
                        datakey = new Datakey
                        {
                            EntId = ApiConfig.IsTestServer ? "108" : "88",
                            CompanyId = param.CompanyId
                        }
                    });
                    if (ret.payload.std_data.execution.code == "0") //成功
                    {
                        entity_h.ERP_BILL_CODE = ret.payload.std_data.parameter.docno;
                        entity_h.LastModificationTime = DateTime.Now;
                        action.Message += $"{action.Message.IsNullOrEmpty("", ";")}{ret.payload.std_data.execution.description},返回的ERP_BILL_CODE:[{ret.payload.std_data.parameter.docno}]";
                        Logger.Interface.Info(action.Message);
                    }
                    else //失败
                    {
                        action.IsSuccessed = false;
                        action.Message += $",领料单{entity_h.BILLCODE}过账失败,返回的信息:{ret.payload.std_data.execution.description}";
                        Logger.Interface.Error(action.Message);
                        //return action;
                    }
                    //数据库处理操作
                    DbClient db = Business.Biz.Db;
                    if (action.IsSuccessed)
                    {
                        action.Message += $",领料单{entity_h.BILLCODE}过账成功";
                        var dbTran = db.UseTran(() =>
                        {
                            db.Updateable(entity_h).ExecuteCommand();
                            db.Updateable(entity_d).ExecuteCommand();
                        });
                        if (!dbTran.IsSuccess)
                        {
                            action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                            Logger.Interface.Error(action.Message);
                        }
                    }
                    Logger.Interface.Info(action.Message);
                    //return action;
                }
                catch (Exception ex)
                {
                    action.GetResponse().CatchExceptionWithLog(ex, $"发料单过账异常");
                    Logger.Interface.Error(action.Message);
                }
            });
            return action;
        }
        /// <summary>
        /// æ–°æ¡†æž¶-领料单过账到T100
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ApiAction MaterialReqToErpNew(MReqPostParam param)
        {
            var action = new ApiAction();
            Work.DoAsync(() =>
            {
                Thread.Sleep(3000);
                Logger.Interface.Info($"领料单过账到T100 =>开始过账,单号:[{param.BillCode},{param.CompanyId}]");
                try
                {
                    BIZ_ERP_PROD_OUT entity_h = Biz.Db.Queryable<BIZ_ERP_PROD_OUT>().Where(x => x.BILLCODE == param.BillCode && SqlFunc.IsNullOrEmpty(x.ERP_BILL_CODE)).First();
                    List<BIZ_ERP_PROD_OUT_DTL> entity_d = Biz.Db.Queryable<BIZ_ERP_PROD_OUT_DTL>().Where(x => x.BILLCODE == param.BillCode && Convert.ToInt32(x.PRQTY) > 0).ToList();
                    List<Detail5> details = new List<Detail5>();
                    if (entity_h != null)
                    {
                        foreach (var item in entity_d)
                        {
                            //计算数量
                            var qty = item.QTY > item.PRQTY ? item.PRQTY.ToString() : item.QTY.ToString();
                            details.Add(new Detail5
                            {
                                sfdcseq = item.BILLLINE,
                                sfdc001 = item.SOURCECODE,
                                sfdc002 = item.SOURCELINE.ToString(),
                                sfdc003 = item.SOURCETYPE.ToString(),
                                sfdc007 = qty,
                            });
                        }
                        var ret = ErpT100.MaterialReqToErp(new ReqErpInputParameter
                        {
                            parameter = new Parameter4
                            {
                                sfdatype = entity_h.SOURCETYPE.ToString(),
                                sfdadocno = entity_h.BILLCODE,
                                detail = details
                            },
                            datakey = new Datakey
                            {
                                EntId = "88", // ApiConfig.IsTestServer ? "108" : "88",
                                CompanyId = param.CompanyId
                            }
                        });
                        if (ret.payload.std_data.execution.code == "0") //成功
                        {
                            entity_h.ERP_BILL_CODE = ret.payload.std_data.parameter.docno;
                            entity_h.UPDATE_TIME = DateTime.Now;
                            entity_h.HANDLED = 0;
                            entity_h.HANDLED_DATE = DateTime.Now;
                            action.Message += $"{action.Message.IsNullOrEmpty("", ";")}{ret.payload.std_data.execution.description},返回的ERP_BILL_CODE:[{ret.payload.std_data.parameter.docno}]";
                        }
                        else if (ret.payload.std_data.execution.code == "S" || ret.payload.std_data.execution.code == "ain-00222")
                        {
                            entity_h.ERP_BILL_CODE = "此笔资料已过账-system";
                            entity_h.UPDATE_TIME = DateTime.Now;
                            entity_h.HANDLED = 0;
                            entity_h.HANDLED_DATE = DateTime.Now;
                            action.IsSuccessed = false;
                            action.Message = $"{action.Message.IsNullOrEmpty("", ";")}{ret.payload.std_data.execution.description},返回的ERP_BILL_CODE:[{ret.payload.std_data.parameter?.docno}]";
                        }
                        else //失败
                        {
                            action.IsSuccessed = false;
                            action.Message = $"领料单{entity_h.BILLCODE}过账失败,返回的信息:{ret.payload.std_data.execution.description}";
                            //大于5次就不发邮件
                            if (entity_h.HANDLED < 6)
                            {
                                Work.DoAsync(() =>
                                {
                                    MailServiceApi _IMailServiceApi = new MailServiceApi();
                                    _IMailServiceApi.SendMail(new MailBodyEntity
                                    {
                                        MailTextBody = $"Hi All,<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;领料单[{entity_h.BILLCODE}]过账失败,<br/> T100返回消息:{ret.payload.std_data.execution.description}",
                                        MailBodyType = "Html",
                                        MailFilePath = null,
                                        Recipients = Biz.SysParam.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> { "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
                                        Cc = new List<string>(),
                                        Sender = "WMS Email Admin",
                                        SenderAddress = "xcerp@sharetronic.com",
                                        Subject = $"领料单[{entity_h.BILLCODE}]过账失败",
                                        Body = ""
                                    },
                                    new SendServerConfigurationEntity
                                    {
                                        SmtpHost = "mail.sharetronic.com",
                                        SmtpPort = 25,
                                        SenderAccount = "xcerp@sharetronic.com",
                                        SenderPassword = "sha66666",
                                        MailEncoding = "utf-8",
                                        IsSsl = false
                                    });
                                });
                            }
                            entity_h.HANDLED++;
                            entity_h.HANDLED_DATE = DateTime.Now;
                        }
                        //数据库处理操作
                        DbClient db = Business.Biz.Db;
                        action.Message += action.IsSuccessed ? $",领料单{entity_h.BILLCODE}过账成功" : "";
                        var dbTran = db.UseTran(() =>
                        {
                            db.Updateable(entity_h).UpdateColumns(q => new { q.ERP_BILL_CODE, q.UPDATE_TIME, q.HANDLED, q.HANDLED_DATE }).ExecuteCommand();
                            //db.Updateable(entity_d).ExecuteCommand();
                        });
                        if (!dbTran.IsSuccess)
                        {
                            action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                            Logger.Interface.Error(action.Message);
                            Logger.Scheduler.Error(action.Message);
                        }
                        Logger.Interface.Info(action.Message);
                        Logger.Scheduler.Info(action.Message);
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.Message = $"查不到符合条件的领料需要过账";
                        Logger.Interface.Error(action.Message);
                        Logger.Scheduler.Error(action.Message);
                    }
                }
                catch (Exception ex)
                {
                    action.GetResponse().CatchExceptionWithLog(ex, $"发料单过账异常");
                    Logger.Interface.Error(action.Message);
                    Logger.Scheduler.Error(action.Message);
                }
            });
            return action;
        }
        /// <summary>
        /// é¢†æ–™å•过账到T100
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static ApiAction MaterialReqOldToErpNew(MReqPostParam param)
        {
            var action = new ApiAction();
            Work.DoAsync(() =>
            {
                Thread.Sleep(3000);
                Logger.Interface.Info($"领料单过账到T100 =>开始过账,单号:[{param.BillCode},{param.CompanyId}]");
                DbClient db = Biz.DataSource["WMS57"].Client;
                try
                {
                    BIZ_ERP_PROD_OUT entity_h = db.Queryable<BIZ_ERP_PROD_OUT>().Where(x => x.BILLCODE == param.BillCode && SqlFunc.IsNullOrEmpty(x.ERP_BILL_CODE)).First();
                    List<BIZ_ERP_PROD_OUT_DTL> entity_d = db.Queryable<BIZ_ERP_PROD_OUT_DTL>().Where(x => x.BILLCODE == param.BillCode && Convert.ToInt32(x.PRQTY) > 0).ToList();
                    List<Detail5> details = new List<Detail5>();
                    if (entity_h != null)
                    {
                        foreach (var item in entity_d)
                        {
                            //计算数量
                            var qty = item.QTY > item.PRQTY ? item.PRQTY.ToString() : item.QTY.ToString();
                            details.Add(new Detail5
                            {
                                sfdcseq = item.BILLLINE,
                                sfdc001 = item.SOURCECODE,
                                sfdc002 = item.SOURCELINE.ToString(),
                                sfdc003 = item.SOURCETYPE.ToString(),
                                sfdc007 = qty,
                            });
                        }
                        var ret = ErpT100.MaterialReqToErp(new ReqErpInputParameter
                        {
                            parameter = new Parameter4
                            {
                                sfdatype = entity_h.SOURCETYPE.ToString(),
                                sfdadocno = entity_h.BILLCODE,
                                detail = details
                            },
                            datakey = new Datakey
                            {
                                EntId = "88", // ApiConfig.IsTestServer ? "108" : "88",
                                CompanyId = param.CompanyId
                            }
                        });
                        if (ret.payload.std_data.execution.code == "0") //成功
                        {
                            entity_h.ERP_BILL_CODE = ret.payload.std_data.parameter.docno;
                            entity_h.UPDATE_TIME = DateTime.Now;
                            entity_h.HANDLED = 0;
                            entity_h.HANDLED_DATE = DateTime.Now;
                            action.Message += $"{action.Message.IsNullOrEmpty("", ";")}{ret.payload.std_data.execution.description},返回的ERP_BILL_CODE:[{ret.payload.std_data.parameter.docno}]";
                            Logger.Interface.Info(action.Message);
                        }
                        else if (ret.payload.std_data.execution.code == "S" || ret.payload.std_data.execution.code == "ain-00222")
                        {
                            entity_h.ERP_BILL_CODE = "此笔资料已过账-system";
                            entity_h.UPDATE_TIME = DateTime.Now;
                            entity_h.HANDLED = 0;
                            entity_h.HANDLED_DATE = DateTime.Now;
                            action.IsSuccessed = false;
                            action.Message = $"{action.Message.IsNullOrEmpty("", ";")}{ret.payload.std_data.execution.description},返回的ERP_BILL_CODE:[{ret.payload.std_data.parameter.docno}]";
                            Logger.Interface.Info(action.Message);
                        }
                        else //失败
                        {
                            action.IsSuccessed = false;
                            action.Message = $"领料单{entity_h.BILLCODE}过账失败,返回的信息:{ret.payload.std_data.execution.description}";
                            Logger.Interface.Error(action.Message);
                            //大于5次就不发邮件
                            if (entity_h.HANDLED < 6)
                            {
                                Work.DoAsync(() =>
                                {
                                    MailServiceApi _IMailServiceApi = new MailServiceApi();
                                    _IMailServiceApi.SendMail(new MailBodyEntity
                                    {
                                        MailTextBody = $"Hi All,<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;领料单[{entity_h.BILLCODE}]过账失败,<br/> T100返回消息:{ret.payload.std_data.execution.description}",
                                        MailBodyType = "Html",
                                        MailFilePath = null,
                                        Recipients = Biz.SysParamOld.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> { "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
                                        Cc = new List<string>(),
                                        Sender = "WMS Email Admin",
                                        SenderAddress = "xcerp@sharetronic.com",
                                        Subject = $"领料单[{entity_h.BILLCODE}]过账失败",
                                        Body = ""
                                    },
                                    new SendServerConfigurationEntity
                                    {
                                        SmtpHost = "mail.sharetronic.com",
                                        SmtpPort = 25,
                                        SenderAccount = "xcerp@sharetronic.com",
                                        SenderPassword = "sha66666",
                                        MailEncoding = "utf-8",
                                        IsSsl = false
                                    });
                                });
                            }
                            entity_h.HANDLED++;
                            entity_h.HANDLED_DATE = DateTime.Now;
                            //return action;
                        }
                        //数据库处理操作
                        db = Biz.DataSource["WMS57"].Client;
                        action.Message += action.IsSuccessed ? $",领料单{entity_h.BILLCODE}过账成功" : "";
                        var dbTran = db.UseTran(() =>
                        {
                            db.Updateable(entity_h).UpdateColumns(q => new { q.ERP_BILL_CODE, q.UPDATE_TIME, q.HANDLED, q.HANDLED_DATE }).ExecuteCommand();
                            //db.Updateable(entity_d).ExecuteCommand();
                        });
                        if (!dbTran.IsSuccess)
                        {
                            action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                            Logger.Interface.Error(action.Message);
                        }
                        Logger.Interface.Info(action.Message);
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.Message = $"查不到符合条件的领料需要过账";
                        Logger.Interface.Error(action.Message);
                    }
                }
                catch (Exception ex)
                {
                    action.GetResponse().CatchExceptionWithLog(ex, $"发料单过账异常");
                    Logger.Interface.Error(action.Message);
                }
            });
            return action;
        }
        /// <summary>
        /// èŽ·å–æ‰€æœ‰ä»“åº“æœºæž„åˆ—è¡¨
        /// </summary>
        /// <param name="billcode"></param>
        /// <returns></returns>
        public static async Task<string> GetHouseModel(string name, string status)
        {
            var data = new List<OrgItemH>();
            V_WH_TREE func = null;
            if (!string.IsNullOrEmpty(name))
            {
                func = Biz.Db.Queryable<V_WH_TREE>().Where(x => x.NAME == name).First();
            }
            var items = await Biz.Db.Queryable<V_WH_TREE>()
                .Where(q => q.TYPE != "Location")
                .OrderBy(x => x.NAME)
                .Distinct().ToListAsync();
            //没有查询的时候
            if (func == null)
            {
                List<V_WH_TREE> entities = items.OrderBy(x => x.NAME).ToList().FindAll(t => t.PARENT_ID.IsNullOrEmpty());
                foreach (var item in entities)
                {
                    OrgItemH houseItem = new();
                    houseItem.id = item.ID;
                    houseItem.houseCode = item.CODE;
                    houseItem.houseName = item.NAME;
                    houseItem.PARENT_HOUSE = item.PARENT_ID;
                    houseItem.createTime = DateTime.Now.ToString("yyyy-MM-dd mm:dd:ss");
                    houseItem.houseType = item.TYPE;
                    //hosueItem.remark = item.REMARK;
                    //hosueItem.orderNo = item.SEQ_NO;
                    houseItem.children = new();
                    if (item.TYPE != "Shelf") GetOrgItem(items, item.CODE, ref houseItem);
                    data.Add(houseItem);
                }
            }
            //有查询条件的时候
            else
            {
            }
            //转换Json时,去除值为null的属性
            var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
            var json = JsonConvert.SerializeObject(data, Formatting.Indented, jsonSetting);
            return json;
        }
        /// <summary>
        /// é€’归返回组织机构
        /// </summary>
        /// <param name="data"></param>
        /// <param name="parent"></param>
        /// <param name="pOrgItem"></param>
        private static void GetOrgItem(List<V_WH_TREE> data, string parent, ref OrgItemH pOrgItem)
        {
            List<V_WH_TREE> entities = data.OrderBy(x => x.NAME).ToList().FindAll(t => t.PARENT_ID == parent).Distinct().ToList();
            if (entities.Count > 0)
            {
                foreach (var item in entities)
                {
                    OrgItemH houseItem = new();
                    houseItem.id = item.ID;
                    houseItem.houseCode = item.CODE;
                    houseItem.houseName = item.NAME;
                    houseItem.PARENT_HOUSE = item.PARENT_ID;
                    houseItem.createTime = DateTime.Now.ToString("yyyy-MM-dd mm:dd:ss");
                    houseItem.houseType = item.TYPE;
                    //houseItem.remark = item.REMARK;
                    //houseItem.orderNo = item.SEQ_NO;
                    houseItem.children = new();
                    if (item.TYPE != "Shelf") GetOrgItem(data, item.CODE, ref houseItem);
                    pOrgItem.children.Add(houseItem);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="serverId"></param>
        /// <returns></returns>
        public static ApiAction ReceiptHToErp(string serverId, string triggerDetail)
        {
            var action = new ApiAction();
            try
            {
                Logger.Scheduler.Info(triggerDetail);
                DbClient db = Business.Biz.Db;
                var CompanyId = "";
                switch (serverId)
                {
                    case "55":
                        db = Biz.DataSource["Test"].Client;
                        CompanyId = "XCSJ";
                        break;
                    case "XCSJ":
                        db = Biz.DataSource["XCSJ"].Client;
                        CompanyId = "XCSJ";
                        break;
                    case "DGXC":
                        db = Biz.DataSource["DGXC"].Client;
                        CompanyId = "DGXC";
                        break;
                    case "AHXC":
                        db = Biz.DataSource["AHXC"].Client;
                        CompanyId = "AHXC";
                        break;
                }
                var entity_h = db.Queryable<Model.Minsun.WMS_RECEIPT_H>().Where(x => x.STATUS == 2 && x.ERP_BILL_CODE == null).ToList();
                List<Model.Minsun.WMS_RECEIPT_H> receiptList = new List<Model.Minsun.WMS_RECEIPT_H>();
                foreach (var h in entity_h)
                {
                    List<Detail> details = new List<Detail>();
                    var userid = db.Queryable<Model.Minsun.Sys_Users>().Where(c => c.Id.Equals(h.CreatorUserId)).ToList();
                    var CreatorUserId = userid[0].UserName == "admin" ? "00000" : userid[0].UserName;
                    List<Model.Minsun.WMS_RECEIPT_D> entity_d = db.Queryable<Model.Minsun.WMS_RECEIPT_D>().Where(x => x.BILLCODE == h.BILLCODE).ToList();
                    foreach (var item in entity_d)
                    {
                        var line = db.Queryable<Model.Minsun.WMS_SRM_ASN_LINES>().Where(c => c.DeliveryNo.Equals(item.SOURCECODE.ToString()) && c.extendN01 == item.SOURCELINE.ToString() && c.productCode == item.MATERIALCODE).First(); //新SRM
                        if (line == null) { line = db.Queryable<Model.Minsun.WMS_SRM_ASN_LINES>().Where(c => c.DeliveryNo.Equals(item.SOURCECODE.ToString()) && c.lineNo == item.SOURCELINE && c.productCode == item.MATERIALCODE).First(); } //旧SRM
                        var pmdt004 = line != null ? ((line.poLineNo ?? "1").Split('-').Length > 2 ? (line.poLineNo ?? "1").Split('-')[2] : (line.poLineNo ?? "1")) : "1";
                        details.Add(new Detail
                        {
                            pmdtseq = item.BILLLINE.ToString(),
                            pmdt001 = string.IsNullOrEmpty(item.PONO) ? item.SOURCECODE : item.PONO,
                            pmdt002 = string.IsNullOrEmpty(item.PONO) ? $"{item.SOURCELINE}" : $"{item.POLINE}",
                            pmdt003 = "1",
                            pmdt004 = pmdt004,
                            pmdt006 = item.MATERIALCODE,
                            //pmdt018 = "创米科技",
                            pmdt020 = $"{item.QTY}",
                            pmdtud011 = "0"
                        });
                    }
                    var XSOURCECODE = entity_d[0].SOURCECODE.ToString();
                    //调用T100接口生成到货单
                    var ret = ErpT100.GenerateCustReceipt(new CustReceiptInputParameter
                    {
                        parameter = new Parameter<Detail>
                        {
                            pmds000 = "1",
                            pmdsdocno = "3438",
                            pmdsdocdt = DateTime.Now.ToString("yyyy-MM-dd"), //"2023-04-26", //当天时间
                            pmds002 = CreatorUserId, //用户ID
                            pmds003 = "",
                            pmds007 = h.SUPPLIERCODE, //"C0006", //供应商代码
                            pmds010 = XSOURCECODE, //送货单号
                                                   //pmdsud001 = SecondVenderCode, //"CM017", //二级供应编号
                            detail = details
                        },
                        datakey = new Datakey
                        {
                            EntId = ApiConfig.IsTestServer ? "108" : "88",
                            CompanyId = CompanyId
                        }
                    });
                    if (ret.payload.std_data.execution.code == "0") //成功
                    {
                        Logger.Scheduler.Info($"{action.Message.IsNullOrEmpty("", ";")}{ret.payload.std_data.execution.description},据点[{CompanyId}],收货单号[{h.BILLCODE}],当前用户[{CreatorUserId}],供应商编号[{h.SUPPLIERCODE}],返回的收货单号:[{ret.payload.std_data.parameter.docno}]");
                        h.ERP_BILL_CODE = ret.payload.std_data.parameter.docno;
                        h.STATUS = 3;
                        h.LastModificationTime = DateTime.Now;
                        receiptList.Add(h);
                    }
                    else //失败
                    {
                        Logger.Scheduler.Info($"失败信息:据点[{CompanyId}],收货单号[{h.BILLCODE}],当前用户[{CreatorUserId}],供应商编号[{h.SUPPLIERCODE}],返回的信息:{ret.payload.std_data.execution.description}");
                        //return action;
                    }
                }
                //数据库处理操作
                action.Message = $",到货单推T100完成";
                var dbTran = db.UseTran(() =>
                {
                    if (receiptList.Any())
                    {
                        db.Updateable(receiptList).ExecuteCommand();
                    }
                });
                if (!dbTran.IsSuccess)
                {
                    action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                    Logger.Scheduler.Error(action.Message);
                }
                Logger.Scheduler.Info(action.Message);
                //return action;
            }
            catch (Exception ex)
            {
                action.GetResponse().CatchExceptionWithLog(ex, $"生成到货单异常");
                Logger.Scheduler.Error(action.Message);
            }
            return action;
        }
        /// <summary>
        /// æ ¹æ®ä»“库代码和类型删除仓库机构列表
        /// </summary>
        /// <param name="billcode"></param>
        /// <returns></returns>
        public static ApiAction DelWareHouseModel(DelWareHouseModelEntity wareHouse)
        {
            var action = new ApiAction();
            List<string> locaIds = new();
            List<string> shelfIds = new();
            List<string> regIds = new();
            List<string> wareIds = new();
            var db = Biz.Db;
            List<V_WH_UNIT> uNITs = new List<V_WH_UNIT>();
            if (wareHouse.Type == "Warehouse")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.WH_ID == wareHouse.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    var unit = db.Queryable<V_WH_UNIT>().Where(q => q.WH_CODE == wareHouse.ID).ToList();
                    locaIds.AddRange(unit.Where(q => !q.LOCATION_ID.IsNullOrEmpty()).Select(s => s.LOCATION_ID).Distinct());
                    shelfIds.AddRange(unit.Where(q => !q.SHELF_ID.IsNullOrEmpty()).Select(s => s.SHELF_ID).Distinct());
                    regIds.AddRange(unit.Where(q => !q.REGION_ID.IsNullOrEmpty()).Select(s => s.REGION_ID).Distinct());
                    wareIds.AddRange(unit.Where(q => !q.WH_ID.IsNullOrEmpty()).Select(s => s.WH_ID).Distinct());
                }
                else
                {
                    action.IsSuccessed = false;
                    action.Message = "仓库里面有东西,不能删除!";
                }
            }
            else if (wareHouse.Type == "Region")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.REGION_ID == wareHouse.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    var unit = db.Queryable<V_WH_UNIT>().Where(q => q.REGION_CODE == wareHouse.ID).ToList();
                    locaIds.AddRange(unit.Where(q => !q.LOCATION_ID.IsNullOrEmpty()).Select(s => s.LOCATION_ID).Distinct());
                    shelfIds.AddRange(unit.Where(q => !q.SHELF_ID.IsNullOrEmpty()).Select(s => s.SHELF_ID).Distinct());
                    regIds.AddRange(unit.Where(q => !q.REGION_ID.IsNullOrEmpty()).Select(s => s.REGION_ID).Distinct());
                }
                else
                {
                    action.IsSuccessed = false;
                    action.Message = "储区里面有东西,不能删除!";
                }
            }
            else if (wareHouse.Type == "Shelf")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.SHELF_ID == wareHouse.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    var unit = db.Queryable<V_WH_UNIT>().Where(q => q.SHELF_CODE == wareHouse.ID).ToList();
                    locaIds.AddRange(unit.Where(q => !q.LOCATION_ID.IsNullOrEmpty()).Select(s => s.LOCATION_ID).Distinct());
                    shelfIds.AddRange(unit.Where(q => !q.SHELF_ID.IsNullOrEmpty()).Select(s => s.SHELF_ID).Distinct());
                }
                else
                {
                    action.IsSuccessed = false;
                    action.Message = "货架里面有东西,不能删除!";
                }
            }
            else
            {
            }
            //删储位
            if (locaIds.Any())
            {
                db.Deleteable<Model.WMS_LOCATION>().Where(it => locaIds.Contains(it.ID)).ExecuteCommand();
            }
            //删货架
            if (shelfIds.Any())
            {
                db.Deleteable<Model.WMS_SHELF>().Where(it => shelfIds.Contains(it.ID)).ExecuteCommand();
            }
            //删储区
            if (regIds.Any())
            {
                db.Deleteable<Model.WMS_REGION>().Where(it => regIds.Contains(it.ID)).ExecuteCommand();
            }
            //删仓库
            if (wareIds.Any())
            {
                db.Deleteable<Model.WMS_WAREHOUSE>().Where(it => wareIds.Contains(it.ID)).ExecuteCommand();
            }
            return action;
        }
        /// <summary>
        /// æ ¹æ®ä»“库代码和类型删除仓库机构列表
        /// </summary>
        /// <param name="billcode"></param>
        /// <returns></returns>
        public static ApiAction AddLocationModel(List<AddLocationModelEntity> locations)
        {
            var action = new ApiAction();
            List<Model.WMS_LOCATION> Locations = new List<Model.WMS_LOCATION>();
            foreach (var item in locations)
            {
                Model.WMS_LOCATION location = new Model.WMS_LOCATION()
                {
                    LOCATION_CODE = item.LOCATION_CODE,
                    LOCATION_NAME = item.LOCATION_CODE,
                    IS_ACTIVE = "Y",
                    ORG_CODE = item.ORG_CODE,
                    SHELF_ID = item.SHELF_ID,
                    IS_MIX = item.ISMIX,
                    FLOOR_NO = item.FLOOR_NO,
                    SEQ_NO = item.SEQ_NO,
                    LEDID = item.SEQ_NO
                };
                Locations.Add(location);
            }
            var db = Biz.Db;
            var dbTran = db.UseTran(() =>
            {
                db.Deleteable<Model.WMS_LOCATION>(Locations.Select(it => it.ID)).ExecuteCommand();
                db.Insertable(Locations).ExecuteCommand();
            });
            if (!dbTran.IsSuccess)
            {
                action.GetResponse().CatchExceptionWithLog(dbTran.ErrorException, $"新增储位异常");
            }
            action.LocaleMsg = Biz.L("WMS.WareHouse.VerifyException", Locations[0].ORG_CODE);
            return action;
        }
        /// <summary>
        /// æŸ¥è¯¢è´§æž¶æ˜¯å¦æœ‰ä¸œè¥¿
        /// </summary>
        /// <param name="billcode"></param>
        /// <returns></returns>
        public static ApiAction CheckLocation(DelWareHouseModelEntity shelf)
        {
            var action = new ApiAction();
            var db = Biz.Db;
            if (shelf.Type == "shelf")
            {
                var res = db.Queryable<WMS_ITEM>().Where(q => q.STATUS > 2 && q.SHELF_ID == shelf.ID).ToList();
                if (res.IsNullOrEmpty())
                {
                    action.IsSuccessed = true;
                }
                else
                {
                    action.IsSuccessed = false;
                    action.LocaleMsg = Biz.L("WMS.WareHouse.检查储位初始化", shelf.ID);
                }
            }
            return action;
        }
        /// <summary>
        /// èŽ·å–T100检验单数据2023.07.23,by weikaiyong
        /// </summary>
        /// <param name="iqcs"></param>
        /// <returns></returns>
        public ApiAction GetQcReq(List<BIZ_ERP_IQC> iqcs)
        {
            var action = new ApiAction();
            try
            {
                List<BIZ_ERP_IQC> iqcs_new = new List<BIZ_ERP_IQC>();
                List<WMS_ITEM> saveItems = new();
                List<BIZ_ERP_OTH_IN_SN> othSns = new();
                List<BIZ_ERP_RECEIPT_SN> reqSns = new();
                List<WMS_ITEM_HIS> saveHis = new();
                DbClient db = Biz.DataSource["WMS57"].Client;
                var iqcEntitys = db.Queryable<BIZ_ERP_IQC>().Where(x => iqcs.Select(q => q.ERP_BILL_CODE).Contains(x.ERP_BILL_CODE)).ToList();
                foreach (var iqc in iqcs)
                {
                    var entity = iqcEntitys.Where(x => x.ERP_BILL_CODE == iqc.ERP_BILL_CODE).FirstOrDefault();
                    if (!entity.IsNullOrEmpty())
                    {
                        entity.QCRESULT = iqc.QCRESULT;
                        entity.QCSTATUS = 3;
                        entity.RECEIVEQTY = iqc.RECEIVEQTY;
                        entity.REJECTQTY = iqc.REJECTQTY;
                        entity.UPDATE_TIME = DateTime.Now;
                        iqcs_new.Add(entity);
                        var items = db.Queryable<WMS_ITEM>().Where(q => (q.TRANS_CODE == nameof(BIZ_ERP_OTH_IN) || q.TRANS_CODE == nameof(BIZ_ERP_RECEIPT))
                                                                                        && q.TRANS_NO == entity.SOURCECODE && q.STATUS < WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
                        //if (items.Count>0)
                        {
                            foreach (var item in items)
                            {
                                item.UPDATE_TIME = DateTime.Now;
                                item.UPDATE_USER = "Interface";
                                item.STATUS = WMS_ITEM.STATUSs.WaitIn.GetValue();
                                saveItems.Add(item);
                                saveHis.Add(new WMS_ITEM_HIS(item, $"检验单T100审单通过,条码待入库[{WMS_ITEM.STATUSs.WaitIn.GetDesc()}]"));
                            }
                            othSns = db.Queryable<BIZ_ERP_OTH_IN_SN>().Where(q => q.BUSINESSCODE == entity.SOURCECODE && q.STATUS < WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
                            foreach (var item in othSns)
                            {
                                item.UPDATE_TIME = DateTime.Now;
                                item.UPDATE_USER = "Interface";
                                item.STATUS = WMS_ITEM.STATUSs.WaitIn.GetValue();
                            }
                            reqSns = db.Queryable<BIZ_ERP_RECEIPT_SN>().Where(q => q.BILLCODE == entity.SOURCECODE && q.STATUS < WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
                            foreach (var item in reqSns)
                            {
                                item.UPDATE_TIME = DateTime.Now;
                                item.UPDATE_USER = "Interface";
                                item.STATUS = WMS_ITEM.STATUSs.WaitIn.GetValue();
                            }
                        }
                    }
                    else
                    {
                        action.Message += $"找不到对应的WMS检验单{iqc.ERP_BILL_CODE}";
                        action.IsSuccessed = false;
                    }
                }
                //数据库处理操作
                if (action.IsSuccessed)
                {
                    action.Message = $"送检单[{string.Join(",", iqcEntitys.Select(q => $"{q.ERP_BILL_CODE}"))}]回写WMS成功";
                    var _db = Biz.DataSource["WMS57"].Client;
                    var dbTran = _db.UseTran(() =>
                    {
                        _db.Updateable(iqcs_new, "Interface").ExecuteCommand();
                        if (saveItems.Count > 100)
                        {
                            db.Fastest<WMS_ITEM>().BulkUpdate(saveItems, new string[] { "ID" }, new string[] { "STATUS", "UPDATE_TIME", "UPDATE_USER" });
                            Logger.Interface.Info($"库存[{string.Join(",", saveItems.Select(q => $"{q.TRANS_NO}"))}]Fastest回写WMS成功");
                        }
                        else
                        {
                            _db.Updateable(saveItems, "Interface").UpdateColumns(q => new { q.STATUS, q.UPDATE_TIME, q.UPDATE_USER }).ExecuteCommand();
                            Logger.Interface.Info($"库存[{string.Join(",", saveItems.Select(q => $"{q.TRANS_NO}"))}]Updateable回写WMS成功");
                        }
                        if (saveHis.Count > 100)
                        {
                            db.Fastest<WMS_ITEM_HIS>().BulkCopy(saveHis);
                        }
                        else
                        {
                            db.Insertable(saveHis, "Interface").ExecuteCommand();
                        }
                        if (othSns.Count > 100)
                        {
                            db.Fastest<BIZ_ERP_OTH_IN_SN>().BulkUpdate(othSns);
                        }
                        else
                        {
                            db.Updateable(othSns, "Interface").ExecuteCommand();
                        }
                        if (reqSns.Count > 100)
                        {
                            db.Fastest<BIZ_ERP_RECEIPT_SN>().BulkUpdate(reqSns);
                        }
                        else
                        {
                            db.Updateable(reqSns, "Interface").ExecuteCommand();
                        }
                    });
                    if (!dbTran.IsSuccess)
                    {
                        action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                    }
                    Logger.Interface.Info($"送检单[{string.Join(",", iqcEntitys.Select(q => $"{q.ERP_BILL_CODE}"))}]回写WMS成功");
                }
                action.IsSuccessed = true;
            }
            catch (Exception ex)
            {
                action.CatchExceptionWithLog(ex, $"数据处理失败");
            }
            return action;
        }
        /// <summary>
        /// èŽ·å–é”€å”®å‡ºåº“åˆ—è¡¨
        /// </summary>
        /// <returns></returns>
        public ApiAction<PageAble<BIZ_ERP_SALE_OUT>> GetOutSaleList(int pageIndex, int pageSize, string orgcode, string billcode)
        {
            var action = new ApiAction<PageAble<BIZ_ERP_SALE_OUT>>();
            var query = Biz.Db.Queryable<BIZ_ERP_SALE_OUT>().Where(x =>
            (x.STATUS == BIZ_ERP_SALE_OUT.STATUSs.INIT.GetValue()
            || x.STATUS == BIZ_ERP_SALE_OUT.STATUSs.WORKING.GetValue())
            && x.AUTH_ORG == orgcode)
                .WhereIF(!billcode.IsNullOrEmpty(), x => x.BILLCODE.Contains(billcode))
                .OrderByDescending(x => x.UPDATE_TIME.ToString("yyyy-MM-dd"))
                .OrderBy(x => x.REMARK == "L40774" ? 0 : 1)
                .OrderBy(x => x.SOURCECODE == null ? 1 : 0)
            .OrderBy(x => x.CREATE_TIME)
                .ToPage(pageIndex, pageSize);
            action.Data = query;
            return action;
        }
    }
}
Tiger.Business/Automate/AutoContext.cs
ÎļþÒÑɾ³ý
Tiger.Business/BizContext.cs
@@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Tiger.Business.WMS.Transaction;
using Tiger.IBusiness;
namespace Tiger.Business
Tiger.Business/DbCache/Biz.CodeRule.cs
@@ -10,7 +10,6 @@
using System.Linq;
using Newtonsoft.Json;
using Tiger.Business.DbCache;
using Tiger.Business.WMS.iSRM;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Threading;
Tiger.Business/ERP/Biz.T100.cs
ÎļþÒÑɾ³ý
Tiger.Business/ERP/Biz.Vender.cs
ÎļþÒÑɾ³ý
Tiger.Business/Model/TigerActive.cs
@@ -5,7 +5,6 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.Business.Auto;
using Tiger.IBusiness;
namespace Tiger.Business
Tiger.Business/Monitors/MonitorsBus.cs
@@ -5,7 +5,6 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.Business.WMS;
using Tiger.IBusiness;
namespace Tiger.Business
Tiger.Business/Monitors/TransactionMonitor.cs
@@ -6,7 +6,6 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.Business.WMS;
using Tiger.IBusiness;
namespace Tiger.Business
Tiger.Business/Tiger.Business.csproj
@@ -27,8 +27,38 @@
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="BAS\**" />
    <Compile Remove="EMS\**" />
    <Compile Remove="Language\Automate\**" />
    <Compile Remove="Language\Common\**" />
    <Compile Remove="Language\EMS\**" />
    <Compile Remove="Language\MES\**" />
    <Compile Remove="Language\Monitors\**" />
    <Compile Remove="Language\QMS\**" />
    <Compile Remove="Language\TSK\**" />
    <Compile Remove="QMS\**" />
    <Compile Remove="RTest\**" />
    <EmbeddedResource Remove="BAS\**" />
    <EmbeddedResource Remove="EMS\**" />
    <EmbeddedResource Remove="Language\Automate\**" />
    <EmbeddedResource Remove="Language\Common\**" />
    <EmbeddedResource Remove="Language\EMS\**" />
    <EmbeddedResource Remove="Language\MES\**" />
    <EmbeddedResource Remove="Language\Monitors\**" />
    <EmbeddedResource Remove="Language\QMS\**" />
    <EmbeddedResource Remove="Language\TSK\**" />
    <EmbeddedResource Remove="QMS\**" />
    <EmbeddedResource Remove="RTest\**" />
    <None Remove="BAS\**" />
    <None Remove="EMS\**" />
    <None Remove="Language\Automate\**" />
    <None Remove="Language\Common\**" />
    <None Remove="Language\EMS\**" />
    <None Remove="Language\MES\**" />
    <None Remove="Language\Monitors\**" />
    <None Remove="Language\QMS\**" />
    <None Remove="Language\TSK\**" />
    <None Remove="QMS\**" />
    <None Remove="RTest\**" />
  </ItemGroup>
@@ -105,18 +135,8 @@
  </ItemGroup>
  <ItemGroup>
    <Folder Include="BAS\" />
    <Folder Include="EMS\" />
    <Folder Include="Language\Automate\" />
    <Folder Include="Language\Common\" />
    <Folder Include="Language\EMS\" />
    <Folder Include="Language\MES\" />
    <Folder Include="Language\Monitors\" />
    <Folder Include="Language\QMS\" />
    <Folder Include="Language\TSK\" />
    <Folder Include="QMS\" />
    <Folder Include="RTest\" />
    <Folder Include="WMS\MengQi\" />
    <Folder Include="WMS\" />
  </ItemGroup>
  <ItemGroup>
Tiger.Business/WMS/AGV/Biz.Agv.UpdateMReqStatus.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/AGV/Biz.Agv.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/BS/Biz.ItemCount.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/BS/Biz.MaterialResale.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/BS/Biz.MaterialrReq.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/BS/Biz.Transfer.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/BS/Biz.WareHouse.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/DigitalTwin/Seastone/Biz.Rack.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/KanBan/Biz.WareHousing.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/Minsun/Biz.InStorage.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/Minsun/Biz.Shelf.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/Minsun/Biz.iWMS.cs
ÎļþÒÑɾ³ý
Tiger.Business/WMS/iWMS/Biz.iWMS.cs
ÎļþÒÑɾ³ý