From d4c326deaa51e7d4897a84afc339684012b8cfbe Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期五, 31 五月 2024 23:13:28 +0800 Subject: [PATCH] 把WMS移出Business --- Tiger.Business.WMS/Minsun/CustomerSupplyIn.cs | 12 Tiger.Business.WMS/iWMS/RePrintBarcode.cs | 8 Tiger.Business.WMS/Tiger.Business.WMS.csproj | 18 Tiger.Business.WMS/Transaction/OutWorkOrder.cs | 6 Tiger.Business.WMS/Transaction/InProductionReturn.cs | 8 Tiger.Business.WMS/T100ToWMS/SaleOutInfoBusiness.cs | 0 Tiger.Business.WMS/Extensions/JsonExtention.cs | 0 Tiger.Business.WMS/Task/ERP/Jobs.ProdMaterialReqToErpJob.cs | 2 Tiger.Business/BizContext.cs | 1 Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs | 2 Tiger.Business.WMS/T100ToWMS/SplitBoxBusiness.cs | 2 Tiger.Business.WMS/DigitalTwin/Sharetronic/Shelf.cs | 0 Tiger.Business.WMS/Transaction/InMatStorage.cs | 8 Tiger.Business.WMS/iSRM/SrmDataToSiHua.cs | 2 Tiger.Business.WMS/iWMS/iWMS.cs | 982 ++++++++ Tiger.Business.WMS/T100ToWMS/ReworkBusiness.cs | 2 Tiger.Business.WMS/Transaction/OutOther.cs | 6 Tiger.Business.WMS/iWMS/ReceiptInfo.cs | 6 Tiger.Business.WMS/iSRM/SrmParam.cs | 2 Tiger.Business.WMS/Transaction/ShelfRemote.cs | 0 Tiger.Business.WMS/Transaction/ItemQuery.cs | 0 Tiger.Business.WMS/Transaction/LocationTransfer.cs | 4 Tiger.Business.WMS/BS/BS.WareHouse.cs | 371 +++ Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs | 8 Tiger.Business.WMS/Task/ERP/Jobs.ReceiptHToErpJob.cs | 8 Tiger.Business.WMS/BS/BS.MaterialrReq.cs | 46 Tiger.Business.WMS/T100ToWMS/OtherOutInfoBusiness.cs | 2 Tiger.Business.WMS/Transaction/CustomerSupplyInNew.cs | 10 Tiger.Business/Tiger.Business.csproj | 42 Tiger.Business.WMS/ERP/ErpT100.Vender.cs | 127 + Tiger.Business.WMS/Transaction/OutTransfer.cs | 8 Tiger.Business.WMS/BS/BS.Transfer.cs | 38 Tiger.Business.WMS/DigitalTwin/Seastone/RackApi.cs | 0 Tiger.Business/DbCache/Biz.CodeRule.cs | 1 Tiger.Business.WMS/AGV/Agv.UpdateMReqStatus.cs | 58 Tiger.Business.WMS/Minsun/CustSupplyChecking.cs | 10 Tiger.Business.WMS/Minsun/Shelf.cs | 557 ++++ Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs | 4 Tiger.Business.WMS/BS/BS.MaterialResale.cs | 93 Tiger.Business.WMS/T100ToWMS/ProductInputBusiness.cs | 2 Tiger.Business.WMS/KanBan/WareHousing.cs | 210 + Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs | 8 Tiger.Business.WMS/iSRM/SrmToWms.cs | 14 Tiger.Business.WMS/DigitalTwin/Seastone/Rack.cs | 20 Tiger.Business.WMS/WMS_ITEM_Biz.cs | 36 Tiger.Business.WMS/Minsun/iWMS.cs | 1854 ++++++++++++++++ Tiger.Api.sln | 15 Tiger.Business.WMS/Minsun/InStorage.cs | 274 ++ Tiger.Business.WMS/Transaction/OutSale.cs | 8 Tiger.Business/Monitors/TransactionMonitor.cs | 1 Tiger.Business.WMS/Transaction/OutSplit.cs | 4 Tiger.Business/Monitors/MonitorsBus.cs | 1 Tiger.Business.WMS/SqlSugarHepler/BizSqlsugar.cs | 0 Tiger.Business.WMS/T100ToWMS/TrasferInfoBusiness.cs | 2 Tiger.Business.WMS/iSRM/iSRM.cs | 6 Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs | 3 Tiger.Business.WMS/Transaction/InReceipt.cs | 6 Tiger.Business/Model/TigerActive.cs | 1 Tiger.Business.WMS/Task/DBBackup/Jobs.DbBackupJob.cs | 2 Tiger.Business.WMS/Transaction/OutNoBillcode.cs | 4 Tiger.Business.WMS/WMSContext.cs | 0 Tiger.Business.WMS/AGV/Agv.cs | 72 /dev/null | 984 -------- Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs | 12 Tiger.Business.WMS/ERP/T100.cs | 453 ++++ Tiger.Business.WMS/T100ToWMS/ProductOutputtBusiness.cs | 2 Tiger.Business.WMS/Transaction/WmsCount.cs | 2 Tiger.Business.WMS/Transaction/OtherInLocation.cs | 14 Tiger.Business.WMS/Transaction/Resell.cs | 0 Tiger.Business.WMS/iWMS/ProdMaterialReq.cs | 6 Tiger.Business.WMS/iWMS/InventroyInfo.cs | 2 Tiger.Business.WMS/Transaction/InFinished.cs | 8 Tiger.Business.WMS/Transaction/WMSTransactionBase.cs | 0 Tiger.Business.WMS/BS/BS.ItemCount.cs | 195 + Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs | 0 Tiger.Business.WMS/T100ToWMS/StockInfoBusiness.cs | 2 76 files changed, 5,540 insertions(+), 1,137 deletions(-) diff --git a/Tiger.Api.sln b/Tiger.Api.sln index 621e9fb..b4ff214 100644 --- a/Tiger.Api.sln +++ b/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} diff --git a/Tiger.Business.WMS/AGV/Agv.UpdateMReqStatus.cs b/Tiger.Business.WMS/AGV/Agv.UpdateMReqStatus.cs new file mode 100644 index 0000000..d872c05 --- /dev/null +++ b/Tiger.Business.WMS/AGV/Agv.UpdateMReqStatus.cs @@ -0,0 +1,58 @@ +锘縰sing 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; + } + } +} diff --git a/Tiger.Business.WMS/AGV/Agv.cs b/Tiger.Business.WMS/AGV/Agv.cs new file mode 100644 index 0000000..dfd62b9 --- /dev/null +++ b/Tiger.Business.WMS/AGV/Agv.cs @@ -0,0 +1,72 @@ +锘縰sing 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; + } + } +} diff --git a/Tiger.Business.WMS/BS/BS.ItemCount.cs b/Tiger.Business.WMS/BS/BS.ItemCount.cs new file mode 100644 index 0000000..6f700b8 --- /dev/null +++ b/Tiger.Business.WMS/BS/BS.ItemCount.cs @@ -0,0 +1,195 @@ +锘縰sing 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; + } + } +} diff --git a/Tiger.Business.WMS/BS/BS.MaterialResale.cs b/Tiger.Business.WMS/BS/BS.MaterialResale.cs new file mode 100644 index 0000000..59ef41e --- /dev/null +++ b/Tiger.Business.WMS/BS/BS.MaterialResale.cs @@ -0,0 +1,93 @@ +锘縰sing 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; + } + } + } +} diff --git a/Tiger.Business.WMS/BS/BS.MaterialrReq.cs b/Tiger.Business.WMS/BS/BS.MaterialrReq.cs new file mode 100644 index 0000000..6f43d81 --- /dev/null +++ b/Tiger.Business.WMS/BS/BS.MaterialrReq.cs @@ -0,0 +1,46 @@ +锘縰sing 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; + } + } +} diff --git a/Tiger.Business.WMS/BS/BS.Transfer.cs b/Tiger.Business.WMS/BS/BS.Transfer.cs new file mode 100644 index 0000000..c9fe692 --- /dev/null +++ b/Tiger.Business.WMS/BS/BS.Transfer.cs @@ -0,0 +1,38 @@ +锘縰sing 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; + } + } +} diff --git a/Tiger.Business.WMS/BS/BS.WareHouse.cs b/Tiger.Business.WMS/BS/BS.WareHouse.cs new file mode 100644 index 0000000..1762647 --- /dev/null +++ b/Tiger.Business.WMS/BS/BS.WareHouse.cs @@ -0,0 +1,371 @@ +锘縰sing 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> + /// 鏍规嵁浠撳簱浠g爜鍜岀被鍨嬪垹闄や粨搴撴満鏋勫垪琛� + /// </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; + } + + } +} diff --git a/Tiger.Business.WMS/DigitalTwin/Seastone/Rack.cs b/Tiger.Business.WMS/DigitalTwin/Seastone/Rack.cs new file mode 100644 index 0000000..c7bea73 --- /dev/null +++ b/Tiger.Business.WMS/DigitalTwin/Seastone/Rack.cs @@ -0,0 +1,20 @@ +锘縰sing 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(); + //} +} diff --git a/Tiger.Business/WMS/DigitalTwin/Seastone/RackApi.cs b/Tiger.Business.WMS/DigitalTwin/Seastone/RackApi.cs similarity index 100% rename from Tiger.Business/WMS/DigitalTwin/Seastone/RackApi.cs rename to Tiger.Business.WMS/DigitalTwin/Seastone/RackApi.cs diff --git a/Tiger.Business/WMS/DigitalTwin/Sharetronic/Biz.Shelf.cs b/Tiger.Business.WMS/DigitalTwin/Sharetronic/Shelf.cs similarity index 100% rename from Tiger.Business/WMS/DigitalTwin/Sharetronic/Biz.Shelf.cs rename to Tiger.Business.WMS/DigitalTwin/Sharetronic/Shelf.cs diff --git a/Tiger.Business/WMS/DigitalTwin/Sharetronic/ShelfApi.cs b/Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs similarity index 100% rename from Tiger.Business/WMS/DigitalTwin/Sharetronic/ShelfApi.cs rename to Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs diff --git a/Tiger.Business.WMS/ERP/ErpT100.Vender.cs b/Tiger.Business.WMS/ERP/ErpT100.Vender.cs new file mode 100644 index 0000000..c2302f6 --- /dev/null +++ b/Tiger.Business.WMS/ERP/ErpT100.Vender.cs @@ -0,0 +1,127 @@ +锘縰sing 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> + /// 浠嶵100鑾峰彇渚涘簲鍟嗘帴鍙� + /// </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; + } + } +} diff --git a/Tiger.Business.WMS/ERP/T100.cs b/Tiger.Business.WMS/ERP/T100.cs new file mode 100644 index 0000000..7d53ce6 --- /dev/null +++ b/Tiger.Business.WMS/ERP/T100.cs @@ -0,0 +1,453 @@ +锘縰sing 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> + /// 浠嶵100鑾峰彇浜岀骇渚涘簲鍟嗘帴鍙� + /// </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鑾峰彇浜岀骇渚涘簲鍟嗘彁浜son: {requestJson}锛岃繑鍥濲son: {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", //姝e紡 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($"鐢熸垚鍒拌揣鍗曟彁浜son: {requestJson}锛岃繑鍥濲son: {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}]姝e湪鎺ㄩ�佸埌T100锛屼笉鑳介噸澶嶆帹閫侊紒"; + Logger.Interface.Warn($"鐢熸垚鍒拌揣鍗曞紓甯革紝杩斿洖: {ret.payload.std_data.execution.description}"); + return ret; + } + + #region 娴嬭瘯浠g爜 + + //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}锛岃繑鍥濲son: {{JsonConvert.SerializeObject(result)}}"); + + #endregion 娴嬭瘯浠g爜 + } + catch (System.Exception ex) + { + curDeliveryNoList.Remove(input.parameter.pmds010); + Logger.Interface.Error($"鐢熸垚鍒拌揣鍗曞紓甯革紝杩斿洖: {ex.Message}"); + } + + return new(); + } + + /// <summary> + /// 浠嶵100鑾峰彇浜岀骇渚涘簲鍟嗘帴鍙h繑鍥瀒Dropdownlist鍒楄〃 + /// </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", //姝e紡 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($"鐢熸垚閫佹鍗曟彁浜son: {requestJson}锛岃繑鍥濲son: {response.Message}"); + + #region 娴嬭瘯浠g爜 + + //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($"鐢熸垚閫佹鍗曟彁浜son: {requestJson}锛岃繑鍥濲son: {JsonConvert.SerializeObject(result)}"); + + #endregion 娴嬭瘯浠g爜 + + 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($"鐢熸垚鍏ュ簱鍗曡姹俆100锛屼紶鍏ュ弬鏁癑son:{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($"鏍规嵁棰嗘枡鍗曞彿鎷夊崟韬彁浜son: {requestJson}锛岃繑鍥濲son: {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($"棰嗘枡鍗曡繃璐︽彁浜son: {requestJson}锛岃繑鍥濲son: {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; + } + } +} \ No newline at end of file diff --git a/Tiger.Business/WMS/Extensions/JsonExtention.cs b/Tiger.Business.WMS/Extensions/JsonExtention.cs similarity index 100% rename from Tiger.Business/WMS/Extensions/JsonExtention.cs rename to Tiger.Business.WMS/Extensions/JsonExtention.cs diff --git a/Tiger.Business.WMS/KanBan/WareHousing.cs b/Tiger.Business.WMS/KanBan/WareHousing.cs new file mode 100644 index 0000000..e884379 --- /dev/null +++ b/Tiger.Business.WMS/KanBan/WareHousing.cs @@ -0,0 +1,210 @@ +锘縰sing 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; + } + } +} diff --git a/Tiger.Business/WMS/Minsun/CustSupplyChecking.cs b/Tiger.Business.WMS/Minsun/CustSupplyChecking.cs similarity index 98% rename from Tiger.Business/WMS/Minsun/CustSupplyChecking.cs rename to Tiger.Business.WMS/Minsun/CustSupplyChecking.cs index 98b45cf..358122d 100644 --- a/Tiger.Business/WMS/Minsun/CustSupplyChecking.cs +++ b/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, diff --git a/Tiger.Business/WMS/Minsun/CustomerSupplyIn.cs b/Tiger.Business.WMS/Minsun/CustomerSupplyIn.cs similarity index 98% rename from Tiger.Business/WMS/Minsun/CustomerSupplyIn.cs rename to Tiger.Business.WMS/Minsun/CustomerSupplyIn.cs index 9b6eb22..1d49648 100644 --- a/Tiger.Business/WMS/Minsun/CustomerSupplyIn.cs +++ b/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> { diff --git a/Tiger.Business.WMS/Minsun/InStorage.cs b/Tiger.Business.WMS/Minsun/InStorage.cs new file mode 100644 index 0000000..5feec00 --- /dev/null +++ b/Tiger.Business.WMS/Minsun/InStorage.cs @@ -0,0 +1,274 @@ +锘縰sing 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) }; + } + } +} diff --git a/Tiger.Business.WMS/Minsun/Shelf.cs b/Tiger.Business.WMS/Minsun/Shelf.cs new file mode 100644 index 0000000..2cdfed6 --- /dev/null +++ b/Tiger.Business.WMS/Minsun/Shelf.cs @@ -0,0 +1,557 @@ +锘縰sing 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; + } + } + + // 鏇存柊搴撲綅浠g爜锛孡ocationCode + 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; + + } + + // 璇诲彇鏁版嵁瀛楀吀锛屾牴鎹瓹odeType,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 + + + } +} diff --git a/Tiger.Business.WMS/Minsun/iWMS.cs b/Tiger.Business.WMS/Minsun/iWMS.cs new file mode 100644 index 0000000..c243ca1 --- /dev/null +++ b/Tiger.Business.WMS/Minsun/iWMS.cs @@ -0,0 +1,1854 @@ +锘縰sing 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; + } + //寰呮彁浜ゆ暟鎹寜鏉ユ簮鍗曞彿鍒嗙粍锛圓SN/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, $"瑙f瀽鏉$爜[{nFullBarcode}]鎴愬姛"); + //璇嗗埆鏂扮殑璇嗗埆浜岀淮鐮佽鍒欙紝浠寮�澶达紝鍚﹀垯鎸夋棫璇嗗埆妯″紡 + 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 瑙f瀽鍑烘潵鐨勬暟鎹墠缂�鈥淪鈥濅笉鐢ㄥ幓鎺� + //if (itemValue.StartsWith("C") || itemValue.StartsWith("P")) //涓锛圕锛夊拰鏍堟澘锛圥锛夛紝闇�瑕佸啀娆″幓鎺変竴浣� + // nBarcodeLotNo = itemValue.Substring(1); + } + else if (itemKey == "Q") + { //鏉$爜鏁伴噺 + nLotQty = itemValue; + } + else if (itemKey == "D") + { //鐢熶骇鏃ユ湡(鍘绘帀-锛屽吋瀹瑰甫-鐨勬椂闂存牸寮忥紝鍚庨潰缁熶竴鏃堕棿瑙f瀽) + 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 = $"鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"; + return result; + } + + // 瑙f瀽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("鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"); + //} + + /// 鍘熷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 = $"鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; + return result; + } + + } + + // 鍒ゆ柇鐗╂枡浠g爜鏄惁鍚堟硶 + 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锛歅O锛圡O锛� + ///P锛欳 P/N锛氭枡鍙� + ///N锛歂ame锛堢墿鏂欏悕绉帮級 + ///Q锛歈TY锛堟暟閲忥級 + ///U锛歎nit锛堝崟浣嶏級 + ///M锛歁fr P/N锛堜緵搴斿晢鍐呴儴绠℃帶鐨勭墿鏂欑殑鏂欏彿锛� + ///D锛欴ate Code锛堢敓浜ф棩鏈燂紝鐗╂枡鐨勭敓浜ф棩鏈燂級 + ///L锛歀ot Code锛堢敓浜х殑鎵规锛� + ///S锛歅AG 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, $"瑙f瀽鏉$爜[{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") + { + //鐢熶骇鏃ユ湡(鍘绘帀-锛屽吋瀹瑰甫-鐨勬椂闂存牸寮忥紝鍚庨潰缁熶竴鏃堕棿瑙f瀽) + 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锛寃eikaiyong + { + // 鍒ゆ柇鍗曟嵁缂栧彿鏄惁涓篈SN, 濡傛灉鏄疉SN锛岃皟鐢ˋSN鏍囩瑙f瀽 + 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("鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"); + 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}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; + 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鏍囩鏉$爜瑙f瀽 + /// 鎷嗚В鏉$爜锛屼緷娆℃槸锛� + /// V锛歅O锛圡O锛� + /// P锛欳 P/N锛氭枡鍙� + /// N锛歂ame锛堢墿鏂欏悕绉帮級 + /// Q锛歈TY锛堟暟閲忥級 + /// U锛歎nit锛堝崟浣嶏級 + /// M锛歁fr P/N锛堜緵搴斿晢鍐呴儴绠℃帶鐨勭墿鏂欑殑鏂欏彿锛� + /// D锛欴ate Code锛堢敓浜ф棩鏈燂紝鐗╂枡鐨勭敓浜ф棩鏈燂級 + /// L锛歀ot Code锛堢敓浜х殑鎵规锛� + /// S锛歅AG 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, $"瑙f瀽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 瑙f瀽鍑烘潵鐨勬暟鎹墠缂�鈥淪鈥濅笉鐢ㄥ幓鎺� + //if(itemValue.StartsWith("C")|| itemValue.StartsWith("P")) //涓锛圕锛夊拰鏍堟澘锛圥锛夛紝闇�瑕佸啀娆″幓鎺変竴浣� + // nBarcodeLotNo = itemValue.Substring(1); + } + else if (itemKey == "Q") + { //鏉$爜鏁伴噺 + nLotQty = itemValue; + } + else if (itemKey == "D") + { //鐢熶骇鏃ユ湡(鍘绘帀-锛屽吋瀹瑰甫-鐨勬椂闂存牸寮忥紝鍚庨潰缁熶竴鏃堕棿瑙f瀽) + //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; + } + } + + // 楠岃瘉鏉$爜鏍囩鏁伴噺鏍煎紡鏄惁姝g‘ + if (!decimal.TryParse(nLotQty, out decimal nBarcodeQty)) + { + //throw new UserFriendlyException("鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"); + result.Flag = Result.Flags.Failed; + result.Message = $"鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"; + return result; + } + + // 楠岃瘉鏉$爜鏍囩鏁伴噺涓嶴RM 鏈�灏忓寘瑁呮暟閲忓悎璁℃槸鍚︿竴鑷� + decimal snQtyTotal = snBarcodeList.Sum(t => t.IncludeQty); + if (nBarcodeQty != snQtyTotal) + { + //throw new UserFriendlyException("鏍囩鏁伴噺涓嶴RM鏈�灏忓寘瑁呮�绘暟閲忎笉涓�鑷�"); + result.Flag = Result.Flags.Failed; + result.Message = $"鏍囩鏁伴噺涓嶴RM鏈�灏忓寘瑁呮�绘暟閲忎笉涓�鑷�"; + 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}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; + return result; + } + } + + if (!DateTime.TryParse(dateTimeStr, out nDateCode)) + //if (!DateTime.TryParse(nLotDate, out DateTime nDateCode)) + { + result.Flag = Result.Flags.Failed; + result.Message = $"鏉$爜[{nBarcodeLotNo}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; + return result; + } + } + catch (System.Exception ex) + { + //Logger.Info($"ASN鏍囩鏉$爜瑙f瀽 =>鏉$爜[{nBarcodeLotNo}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈燂紝{ex.Message}"); + result.Flag = Result.Flags.Failed; + result.Message = $"鏉℃潯鐮乕{nBarcodeLotNo}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈燂紝{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; + + // 浠嶹MS_SRM_ASN琛ㄦ煡鎵惧崟鎹紪鍙凤紝鍒ゆ柇鏄惁涓篈SN + 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) + { + // 浠嶹MS_SRM_ASN琛ㄦ煡鎵惧崟鎹紪鍙凤紝鍒ゆ柇鏄惁涓篈SN + 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锛屾娊妫�鐗╂枡锛孉QL鍜屾楠岄」鐩兘缁存姢浜� + 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锛屾娊妫�鐗╂枡锛屾病鏈夌淮鎶QL銆佷絾鏄淮鎶や簡妫�楠岄」鐩� + nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.NormalII; + } + else + { + //鏅I锛屾娊妫�鐗╂枡锛屼絾鏄病鏈夌淮鎶QL鍜屾楠岄」鐩� + 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鍜孉qlCode閰嶇疆涓嬶紝绗﹀悎鐨勬壒娆℃暟閲忚寖鍥� + 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 +} diff --git a/Tiger.Business/SqlSugarHepler/BizSqlsugar.cs b/Tiger.Business.WMS/SqlSugarHepler/BizSqlsugar.cs similarity index 100% rename from Tiger.Business/SqlSugarHepler/BizSqlsugar.cs rename to Tiger.Business.WMS/SqlSugarHepler/BizSqlsugar.cs diff --git a/Tiger.Business/WMS/T100ToWMS/MaterialInfoBusiness.cs b/Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs similarity index 99% rename from Tiger.Business/WMS/T100ToWMS/MaterialInfoBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs index 729ef3d..55b2af9 100644 --- a/Tiger.Business/WMS/T100ToWMS/MaterialInfoBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/WMS/T100ToWMS/OtherOutInfoBusiness.cs b/Tiger.Business.WMS/T100ToWMS/OtherOutInfoBusiness.cs similarity index 99% rename from Tiger.Business/WMS/T100ToWMS/OtherOutInfoBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/OtherOutInfoBusiness.cs index 016d447..ef66b37 100644 --- a/Tiger.Business/WMS/T100ToWMS/OtherOutInfoBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/WMS/T100ToWMS/ProductInputBusiness.cs b/Tiger.Business.WMS/T100ToWMS/ProductInputBusiness.cs similarity index 99% rename from Tiger.Business/WMS/T100ToWMS/ProductInputBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/ProductInputBusiness.cs index d3c0685..a7ec6b8 100644 --- a/Tiger.Business/WMS/T100ToWMS/ProductInputBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/WMS/T100ToWMS/ProductOutputtBusiness.cs b/Tiger.Business.WMS/T100ToWMS/ProductOutputtBusiness.cs similarity index 99% rename from Tiger.Business/WMS/T100ToWMS/ProductOutputtBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/ProductOutputtBusiness.cs index ba7fff9..ef05438 100644 --- a/Tiger.Business/WMS/T100ToWMS/ProductOutputtBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/WMS/T100ToWMS/ReworkBusiness.cs b/Tiger.Business.WMS/T100ToWMS/ReworkBusiness.cs similarity index 98% rename from Tiger.Business/WMS/T100ToWMS/ReworkBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/ReworkBusiness.cs index f0e3b4e..7e71be2 100644 --- a/Tiger.Business/WMS/T100ToWMS/ReworkBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/WMS/T100ToWMS/SaleOutInfoBusiness.cs b/Tiger.Business.WMS/T100ToWMS/SaleOutInfoBusiness.cs similarity index 100% rename from Tiger.Business/WMS/T100ToWMS/SaleOutInfoBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/SaleOutInfoBusiness.cs diff --git a/Tiger.Business/WMS/T100ToWMS/SplitBoxBusiness.cs b/Tiger.Business.WMS/T100ToWMS/SplitBoxBusiness.cs similarity index 99% rename from Tiger.Business/WMS/T100ToWMS/SplitBoxBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/SplitBoxBusiness.cs index f3872f2..ce2dd46 100644 --- a/Tiger.Business/WMS/T100ToWMS/SplitBoxBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/WMS/T100ToWMS/StockInfoBusiness.cs b/Tiger.Business.WMS/T100ToWMS/StockInfoBusiness.cs similarity index 98% rename from Tiger.Business/WMS/T100ToWMS/StockInfoBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/StockInfoBusiness.cs index 3daa9b0..5b1dbcc 100644 --- a/Tiger.Business/WMS/T100ToWMS/StockInfoBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/WMS/T100ToWMS/TrasferInfoBusiness.cs b/Tiger.Business.WMS/T100ToWMS/TrasferInfoBusiness.cs similarity index 99% rename from Tiger.Business/WMS/T100ToWMS/TrasferInfoBusiness.cs rename to Tiger.Business.WMS/T100ToWMS/TrasferInfoBusiness.cs index c5f5cec..68979a0 100644 --- a/Tiger.Business/WMS/T100ToWMS/TrasferInfoBusiness.cs +++ b/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> /// diff --git a/Tiger.Business/TSK/DBBackup/Jobs.DbBackupJob.cs b/Tiger.Business.WMS/Task/DBBackup/Jobs.DbBackupJob.cs similarity index 98% rename from Tiger.Business/TSK/DBBackup/Jobs.DbBackupJob.cs rename to Tiger.Business.WMS/Task/DBBackup/Jobs.DbBackupJob.cs index d77acc6..8394a4f 100644 --- a/Tiger.Business/TSK/DBBackup/Jobs.DbBackupJob.cs +++ b/Tiger.Business.WMS/Task/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> /// 澶囦唤瀹氭椂浠诲姟 diff --git a/Tiger.Business/TSK/ERP/Jobs.ProdMaterialReqToErpJob.cs b/Tiger.Business.WMS/Task/ERP/Jobs.ProdMaterialReqToErpJob.cs similarity index 98% rename from Tiger.Business/TSK/ERP/Jobs.ProdMaterialReqToErpJob.cs rename to Tiger.Business.WMS/Task/ERP/Jobs.ProdMaterialReqToErpJob.cs index 787b534..7b09b2d 100644 --- a/Tiger.Business/TSK/ERP/Jobs.ProdMaterialReqToErpJob.cs +++ b/Tiger.Business.WMS/Task/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> /// 棰嗘枡鍗曞畾鏃惰繃璐� diff --git a/Tiger.Business/TSK/ERP/Jobs.ReceiptHToErpJob.cs b/Tiger.Business.WMS/Task/ERP/Jobs.ReceiptHToErpJob.cs similarity index 98% rename from Tiger.Business/TSK/ERP/Jobs.ReceiptHToErpJob.cs rename to Tiger.Business.WMS/Task/ERP/Jobs.ReceiptHToErpJob.cs index 5962346..22c1a0e 100644 --- a/Tiger.Business/TSK/ERP/Jobs.ReceiptHToErpJob.cs +++ b/Tiger.Business.WMS/Task/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}"); diff --git a/Tiger.Business/TSK/ERP/Jobs.VenderFromErpJob.cs b/Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs similarity index 98% rename from Tiger.Business/TSK/ERP/Jobs.VenderFromErpJob.cs rename to Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs index d3d9c21..b6c4d1a 100644 --- a/Tiger.Business/TSK/ERP/Jobs.VenderFromErpJob.cs +++ b/Tiger.Business.WMS/Task/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 diff --git a/Tiger.Business/TSK/iSRM/Jobs.QqtSrmJob.cs b/Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs similarity index 97% rename from Tiger.Business/TSK/iSRM/Jobs.QqtSrmJob.cs rename to Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs index 4f30757..ac1ac0b 100644 --- a/Tiger.Business/TSK/iSRM/Jobs.QqtSrmJob.cs +++ b/Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs @@ -10,7 +10,7 @@ using Tiger.Model; using Tiger.Model.Minsun; -namespace Tiger.Business +namespace Tiger.Business.WMS { /// <summary> /// 浼佷紒閫歋RM浣滀笟 @@ -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"); } diff --git a/Tiger.Business.WMS/Tiger.Business.WMS.csproj b/Tiger.Business.WMS/Tiger.Business.WMS.csproj new file mode 100644 index 0000000..7bb0538 --- /dev/null +++ b/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)
xcopy /r/y/i $(ProjectDir)$(OutDir)$(AssemblyName).pdb $(SolutionDir)Tiger.Api\$(OutDir)
xcopy /r/y/i $(ProjectDir)$(OutDir)BizSettings.json $(SolutionDir)Tiger.Api\$(OutDir)" /> + </Target> + +</Project> diff --git a/Tiger.Business/WMS/Transaction/CustSupplyCheckingNew.cs b/Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/CustSupplyCheckingNew.cs rename to Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs index 3c9c75a..81b204b 100644 --- a/Tiger.Business/WMS/Transaction/CustSupplyCheckingNew.cs +++ b/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 { diff --git a/Tiger.Business/WMS/Transaction/CustomerSupplyInNew.cs b/Tiger.Business.WMS/Transaction/CustomerSupplyInNew.cs similarity index 97% rename from Tiger.Business/WMS/Transaction/CustomerSupplyInNew.cs rename to Tiger.Business.WMS/Transaction/CustomerSupplyInNew.cs index 069b5fb..049f577 100644 --- a/Tiger.Business/WMS/Transaction/CustomerSupplyInNew.cs +++ b/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 }; } diff --git a/Tiger.Business/WMS/Transaction/InFinished.cs b/Tiger.Business.WMS/Transaction/InFinished.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/InFinished.cs rename to Tiger.Business.WMS/Transaction/InFinished.cs index fdcc407..2c0706f 100644 --- a/Tiger.Business/WMS/Transaction/InFinished.cs +++ b/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 }; } diff --git a/Tiger.Business/WMS/Transaction/InMatStorage.cs b/Tiger.Business.WMS/Transaction/InMatStorage.cs similarity index 97% rename from Tiger.Business/WMS/Transaction/InMatStorage.cs rename to Tiger.Business.WMS/Transaction/InMatStorage.cs index 2a5f40e..5e42c67 100644 --- a/Tiger.Business/WMS/Transaction/InMatStorage.cs +++ b/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 }; } diff --git a/Tiger.Business/WMS/Transaction/InProductionReturn.cs b/Tiger.Business.WMS/Transaction/InProductionReturn.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/InProductionReturn.cs rename to Tiger.Business.WMS/Transaction/InProductionReturn.cs index f8247be..ccce5e4 100644 --- a/Tiger.Business/WMS/Transaction/InProductionReturn.cs +++ b/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 }; } diff --git a/Tiger.Business/WMS/Transaction/InReceipt.cs b/Tiger.Business.WMS/Transaction/InReceipt.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/InReceipt.cs rename to Tiger.Business.WMS/Transaction/InReceipt.cs index f93f332..e7f00bf 100644 --- a/Tiger.Business/WMS/Transaction/InReceipt.cs +++ b/Tiger.Business.WMS/Transaction/InReceipt.cs @@ -92,7 +92,7 @@ #endregion 鎶ュ叧鍗曞彿鍒ゆ柇 //瑙f瀽鏉$爜 - 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 { diff --git a/Tiger.Business/WMS/Transaction/ItemQuery.cs b/Tiger.Business.WMS/Transaction/ItemQuery.cs similarity index 100% rename from Tiger.Business/WMS/Transaction/ItemQuery.cs rename to Tiger.Business.WMS/Transaction/ItemQuery.cs diff --git a/Tiger.Business/WMS/Transaction/LocationTransfer.cs b/Tiger.Business.WMS/Transaction/LocationTransfer.cs similarity index 97% rename from Tiger.Business/WMS/Transaction/LocationTransfer.cs rename to Tiger.Business.WMS/Transaction/LocationTransfer.cs index 7d0748a..f8b0322 100644 --- a/Tiger.Business/WMS/Transaction/LocationTransfer.cs +++ b/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; diff --git a/Tiger.Business/WMS/Transaction/OtherInLocation.cs b/Tiger.Business.WMS/Transaction/OtherInLocation.cs similarity index 97% rename from Tiger.Business/WMS/Transaction/OtherInLocation.cs rename to Tiger.Business.WMS/Transaction/OtherInLocation.cs index a8a7ee9..36a28c3 100644 --- a/Tiger.Business/WMS/Transaction/OtherInLocation.cs +++ b/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}],涓婃灦鎴愬姛"; diff --git a/Tiger.Business/WMS/Transaction/OtherInLocationChecking.cs b/Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs similarity index 99% rename from Tiger.Business/WMS/Transaction/OtherInLocationChecking.cs rename to Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs index 26283d5..5a1d400 100644 --- a/Tiger.Business/WMS/Transaction/OtherInLocationChecking.cs +++ b/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); diff --git a/Tiger.Business/WMS/Transaction/OutNoBillcode.cs b/Tiger.Business.WMS/Transaction/OutNoBillcode.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/OutNoBillcode.cs rename to Tiger.Business.WMS/Transaction/OutNoBillcode.cs index 030b9ca..7de8deb 100644 --- a/Tiger.Business/WMS/Transaction/OutNoBillcode.cs +++ b/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 @@ } //瑙f瀽鏉$爜 - 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; diff --git a/Tiger.Business/WMS/Transaction/OutOther.cs b/Tiger.Business.WMS/Transaction/OutOther.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/OutOther.cs rename to Tiger.Business.WMS/Transaction/OutOther.cs index c888a07..86c33bc 100644 --- a/Tiger.Business/WMS/Transaction/OutOther.cs +++ b/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 @@ } //瑙f瀽鏉$爜 - 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; diff --git a/Tiger.Business/WMS/Transaction/OutSale.cs b/Tiger.Business.WMS/Transaction/OutSale.cs similarity index 97% rename from Tiger.Business/WMS/Transaction/OutSale.cs rename to Tiger.Business.WMS/Transaction/OutSale.cs index 18c5c4b..15af4f5 100644 --- a/Tiger.Business/WMS/Transaction/OutSale.cs +++ b/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 @@ } //瑙f瀽鏉$爜 - 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>()}"); diff --git a/Tiger.Business/WMS/Transaction/OutSplit.cs b/Tiger.Business.WMS/Transaction/OutSplit.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/OutSplit.cs rename to Tiger.Business.WMS/Transaction/OutSplit.cs index c5ba632..3c6afb0 100644 --- a/Tiger.Business/WMS/Transaction/OutSplit.cs +++ b/Tiger.Business.WMS/Transaction/OutSplit.cs @@ -63,7 +63,7 @@ return action; } //瑙f瀽鏉$爜 - 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, diff --git a/Tiger.Business/WMS/Transaction/OutTransfer.cs b/Tiger.Business.WMS/Transaction/OutTransfer.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/OutTransfer.cs rename to Tiger.Business.WMS/Transaction/OutTransfer.cs index 8b192ac..2684fab 100644 --- a/Tiger.Business/WMS/Transaction/OutTransfer.cs +++ b/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 @@ } //瑙f瀽鏉$爜 - 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; diff --git a/Tiger.Business/WMS/Transaction/OutWorkOrder.cs b/Tiger.Business.WMS/Transaction/OutWorkOrder.cs similarity index 98% rename from Tiger.Business/WMS/Transaction/OutWorkOrder.cs rename to Tiger.Business.WMS/Transaction/OutWorkOrder.cs index 78e46ea..ac6ab1b 100644 --- a/Tiger.Business/WMS/Transaction/OutWorkOrder.cs +++ b/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 @@ } //瑙f瀽鏉$爜 - 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; diff --git a/Tiger.Business/WMS/Transaction/ProductionMaterialReq.cs b/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs similarity index 97% rename from Tiger.Business/WMS/Transaction/ProductionMaterialReq.cs rename to Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs index 243f9bd..84e7d6e 100644 --- a/Tiger.Business/WMS/Transaction/ProductionMaterialReq.cs +++ b/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 @@ } //瑙f瀽鏉$爜 - 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 = ""; diff --git a/Tiger.Business/WMS/Transaction/Resell.cs b/Tiger.Business.WMS/Transaction/Resell.cs similarity index 100% rename from Tiger.Business/WMS/Transaction/Resell.cs rename to Tiger.Business.WMS/Transaction/Resell.cs diff --git a/Tiger.Business/WMS/Transaction/ShelfRemote.cs b/Tiger.Business.WMS/Transaction/ShelfRemote.cs similarity index 100% rename from Tiger.Business/WMS/Transaction/ShelfRemote.cs rename to Tiger.Business.WMS/Transaction/ShelfRemote.cs diff --git a/Tiger.Business/WMS/Transaction/WMSTransactionBase.cs b/Tiger.Business.WMS/Transaction/WMSTransactionBase.cs similarity index 100% rename from Tiger.Business/WMS/Transaction/WMSTransactionBase.cs rename to Tiger.Business.WMS/Transaction/WMSTransactionBase.cs diff --git a/Tiger.Business/WMS/Transaction/WmsCount.cs b/Tiger.Business.WMS/Transaction/WmsCount.cs similarity index 99% rename from Tiger.Business/WMS/Transaction/WmsCount.cs rename to Tiger.Business.WMS/Transaction/WmsCount.cs index 37c3266..1b590f2 100644 --- a/Tiger.Business/WMS/Transaction/WmsCount.cs +++ b/Tiger.Business.WMS/Transaction/WmsCount.cs @@ -205,7 +205,7 @@ } //瑙f瀽鏉$爜 - 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; diff --git a/Tiger.Business/WMS/WMSContext.cs b/Tiger.Business.WMS/WMSContext.cs similarity index 100% rename from Tiger.Business/WMS/WMSContext.cs rename to Tiger.Business.WMS/WMSContext.cs diff --git a/Tiger.Business/WMS/Biz.WMS_ITEM.cs b/Tiger.Business.WMS/WMS_ITEM_Biz.cs similarity index 94% rename from Tiger.Business/WMS/Biz.WMS_ITEM.cs rename to Tiger.Business.WMS/WMS_ITEM_Biz.cs index 5bf7979..4892a66 100644 --- a/Tiger.Business/WMS/Biz.WMS_ITEM.cs +++ b/Tiger.Business.WMS/WMS_ITEM_Biz.cs @@ -1,5 +1,4 @@ 锘縰sing 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; } diff --git a/Tiger.Business/WMS/iSRM/SrmDataToSiHua.cs b/Tiger.Business.WMS/iSRM/SrmDataToSiHua.cs similarity index 99% rename from Tiger.Business/WMS/iSRM/SrmDataToSiHua.cs rename to Tiger.Business.WMS/iSRM/SrmDataToSiHua.cs index 7395f50..8f022fc 100644 --- a/Tiger.Business/WMS/iSRM/SrmDataToSiHua.cs +++ b/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 { diff --git a/Tiger.Business/WMS/iSRM/SrmParam.cs b/Tiger.Business.WMS/iSRM/SrmParam.cs similarity index 98% rename from Tiger.Business/WMS/iSRM/SrmParam.cs rename to Tiger.Business.WMS/iSRM/SrmParam.cs index d79e2de..6afade1 100644 --- a/Tiger.Business/WMS/iSRM/SrmParam.cs +++ b/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 { diff --git a/Tiger.Business/WMS/iSRM/SrmToWms.cs b/Tiger.Business.WMS/iSRM/SrmToWms.cs similarity index 98% rename from Tiger.Business/WMS/iSRM/SrmToWms.cs rename to Tiger.Business.WMS/iSRM/SrmToWms.cs index ff04818..c9dbeff 100644 --- a/Tiger.Business/WMS/iSRM/SrmToWms.cs +++ b/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) diff --git a/Tiger.Business/WMS/iSRM/Biz.iSRM.cs b/Tiger.Business.WMS/iSRM/iSRM.cs similarity index 99% rename from Tiger.Business/WMS/iSRM/Biz.iSRM.cs rename to Tiger.Business.WMS/iSRM/iSRM.cs index 183fab3..1f38284 100644 --- a/Tiger.Business/WMS/iSRM/Biz.iSRM.cs +++ b/Tiger.Business.WMS/iSRM/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; } } - } } diff --git a/Tiger.Business/WMS/iWMS/Biz.InventroyInfo.cs b/Tiger.Business.WMS/iWMS/InventroyInfo.cs similarity index 99% rename from Tiger.Business/WMS/iWMS/Biz.InventroyInfo.cs rename to Tiger.Business.WMS/iWMS/InventroyInfo.cs index 334cf29..8115079 100644 --- a/Tiger.Business/WMS/iWMS/Biz.InventroyInfo.cs +++ b/Tiger.Business.WMS/iWMS/InventroyInfo.cs @@ -11,7 +11,7 @@ using Tiger.Model; using Tiger.Model.Minsun; -namespace Tiger.Business +namespace Tiger.Business.WMS { /// <summary> /// 搴撳瓨淇℃伅鎺ュ彛 diff --git a/Tiger.Business/WMS/iWMS/Biz.ProdMaterialReq.cs b/Tiger.Business.WMS/iWMS/ProdMaterialReq.cs similarity index 98% rename from Tiger.Business/WMS/iWMS/Biz.ProdMaterialReq.cs rename to Tiger.Business.WMS/iWMS/ProdMaterialReq.cs index 05adbdd..728904a 100644 --- a/Tiger.Business/WMS/iWMS/Biz.ProdMaterialReq.cs +++ b/Tiger.Business.WMS/iWMS/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 { diff --git a/Tiger.Business/WMS/iWMS/Biz.RePrintBarcode.cs b/Tiger.Business.WMS/iWMS/RePrintBarcode.cs similarity index 97% rename from Tiger.Business/WMS/iWMS/Biz.RePrintBarcode.cs rename to Tiger.Business.WMS/iWMS/RePrintBarcode.cs index 480c0f6..06c159a 100644 --- a/Tiger.Business/WMS/iWMS/Biz.RePrintBarcode.cs +++ b/Tiger.Business.WMS/iWMS/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; //瑙f瀽鏉$爜 - 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; } //瑙f瀽鏉$爜 - 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; diff --git a/Tiger.Business/WMS/iWMS/Biz.ReceiptInfo.cs b/Tiger.Business.WMS/iWMS/ReceiptInfo.cs similarity index 98% rename from Tiger.Business/WMS/iWMS/Biz.ReceiptInfo.cs rename to Tiger.Business.WMS/iWMS/ReceiptInfo.cs index 4fe3587..750a282 100644 --- a/Tiger.Business/WMS/iWMS/Biz.ReceiptInfo.cs +++ b/Tiger.Business.WMS/iWMS/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 { diff --git a/Tiger.Business.WMS/iWMS/iWMS.cs b/Tiger.Business.WMS/iWMS/iWMS.cs new file mode 100644 index 0000000..fae6690 --- /dev/null +++ b/Tiger.Business.WMS/iWMS/iWMS.cs @@ -0,0 +1,982 @@ +锘縰sing 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/> 棰嗘枡鍗昜{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/> 棰嗘枡鍗昜{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(); //鏂癝RM + 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(); } //鏃RM + 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 = $"锛屽埌璐у崟鎺═100瀹屾垚"; + 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> + /// 鏍规嵁浠撳簱浠g爜鍜岀被鍨嬪垹闄や粨搴撴満鏋勫垪琛� + /// </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> + /// 鏍规嵁浠撳簱浠g爜鍜岀被鍨嬪垹闄や粨搴撴満鏋勫垪琛� + /// </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锛宐y 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; + } + } +} diff --git a/Tiger.Business/Automate/AutoContext.cs b/Tiger.Business/Automate/AutoContext.cs deleted file mode 100644 index c7ac164..0000000 --- a/Tiger.Business/Automate/AutoContext.cs +++ /dev/null @@ -1,22 +0,0 @@ -锘縰sing Apache.NMS; -using Apache.NMS.ActiveMQ; -using Rhea.Common; -using Tiger.Model.SeaStone.Shelf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; - -namespace Tiger.Business.Auto -{ - /// <summary> - /// 鑷姩鍖栦笂涓嬫枃 - /// </summary> - public static class AutoContext - { - - } -} diff --git a/Tiger.Business/BizContext.cs b/Tiger.Business/BizContext.cs index de6d323..f864228 100644 --- a/Tiger.Business/BizContext.cs +++ b/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 diff --git a/Tiger.Business/DbCache/Biz.CodeRule.cs b/Tiger.Business/DbCache/Biz.CodeRule.cs index a73f15b..f7206cd 100644 --- a/Tiger.Business/DbCache/Biz.CodeRule.cs +++ b/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; diff --git a/Tiger.Business/ERP/Biz.T100.cs b/Tiger.Business/ERP/Biz.T100.cs deleted file mode 100644 index 0c85e47..0000000 --- a/Tiger.Business/ERP/Biz.T100.cs +++ /dev/null @@ -1,456 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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> - /// 浠嶵100鑾峰彇浜岀骇渚涘簲鍟嗘帴鍙� - /// </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鑾峰彇浜岀骇渚涘簲鍟嗘彁浜son: {requestJson}锛岃繑鍥濲son: {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", //姝e紡 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($"鐢熸垚鍒拌揣鍗曟彁浜son: {requestJson}锛岃繑鍥濲son: {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}]姝e湪鎺ㄩ�佸埌T100锛屼笉鑳介噸澶嶆帹閫侊紒"; - Logger.Interface.Warn($"鐢熸垚鍒拌揣鍗曞紓甯革紝杩斿洖: {ret.payload.std_data.execution.description}"); - return ret; - } - - #region 娴嬭瘯浠g爜 - - //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}锛岃繑鍥濲son: {{JsonConvert.SerializeObject(result)}}"); - - #endregion 娴嬭瘯浠g爜 - } - catch (System.Exception ex) - { - curDeliveryNoList.Remove(input.parameter.pmds010); - Logger.Interface.Error($"鐢熸垚鍒拌揣鍗曞紓甯革紝杩斿洖: {ex.Message}"); - } - - return new(); - } - - /// <summary> - /// 浠嶵100鑾峰彇浜岀骇渚涘簲鍟嗘帴鍙h繑鍥瀒Dropdownlist鍒楄〃 - /// </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", //姝e紡 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($"鐢熸垚閫佹鍗曟彁浜son: {requestJson}锛岃繑鍥濲son: {response.Message}"); - - #region 娴嬭瘯浠g爜 - - //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($"鐢熸垚閫佹鍗曟彁浜son: {requestJson}锛岃繑鍥濲son: {JsonConvert.SerializeObject(result)}"); - - #endregion 娴嬭瘯浠g爜 - - 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($"鐢熸垚鍏ュ簱鍗曡姹俆100锛屼紶鍏ュ弬鏁癑son:{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($"鏍规嵁棰嗘枡鍗曞彿鎷夊崟韬彁浜son: {requestJson}锛岃繑鍥濲son: {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($"棰嗘枡鍗曡繃璐︽彁浜son: {requestJson}锛岃繑鍥濲son: {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; - } - } - } -} \ No newline at end of file diff --git a/Tiger.Business/ERP/Biz.Vender.cs b/Tiger.Business/ERP/Biz.Vender.cs deleted file mode 100644 index 86ea41b..0000000 --- a/Tiger.Business/ERP/Biz.Vender.cs +++ /dev/null @@ -1,129 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - public partial class ErpT100 - { - - /// <summary> - /// 浠嶵100鑾峰彇渚涘簲鍟嗘帴鍙� - /// </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 = 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; - } - } - } -} diff --git a/Tiger.Business/Model/TigerActive.cs b/Tiger.Business/Model/TigerActive.cs index 1a92e16..2386bdb 100644 --- a/Tiger.Business/Model/TigerActive.cs +++ b/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 diff --git a/Tiger.Business/Monitors/MonitorsBus.cs b/Tiger.Business/Monitors/MonitorsBus.cs index cc1409b..c82b4cc 100644 --- a/Tiger.Business/Monitors/MonitorsBus.cs +++ b/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 diff --git a/Tiger.Business/Monitors/TransactionMonitor.cs b/Tiger.Business/Monitors/TransactionMonitor.cs index 2f67401..b5f28b8 100644 --- a/Tiger.Business/Monitors/TransactionMonitor.cs +++ b/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 diff --git a/Tiger.Business/Tiger.Business.csproj b/Tiger.Business/Tiger.Business.csproj index dc91069..9e9ef44 100644 --- a/Tiger.Business/Tiger.Business.csproj +++ b/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> diff --git a/Tiger.Business/WMS/AGV/Biz.Agv.UpdateMReqStatus.cs b/Tiger.Business/WMS/AGV/Biz.Agv.UpdateMReqStatus.cs deleted file mode 100644 index 91b056a..0000000 --- a/Tiger.Business/WMS/AGV/Biz.Agv.UpdateMReqStatus.cs +++ /dev/null @@ -1,61 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - /// <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; - } - } - } -} diff --git a/Tiger.Business/WMS/AGV/Biz.Agv.cs b/Tiger.Business/WMS/AGV/Biz.Agv.cs deleted file mode 100644 index 34caecb..0000000 --- a/Tiger.Business/WMS/AGV/Biz.Agv.cs +++ /dev/null @@ -1,75 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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; - } - } - } -} diff --git a/Tiger.Business/WMS/BS/Biz.ItemCount.cs b/Tiger.Business/WMS/BS/Biz.ItemCount.cs deleted file mode 100644 index 8c94250..0000000 --- a/Tiger.Business/WMS/BS/Biz.ItemCount.cs +++ /dev/null @@ -1,199 +0,0 @@ -锘縰sing 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 -{ - - public partial class Biz : ControllerBase - { - public partial class BS - { - /// <summary> - /// 鍒涘缓鐩樼偣鍗曞彿 - /// </summary> - /// <returns></returns> - public ApiAction CreateBillCode() - { - var action = new ApiAction(); - - Result ruleResult = Biz.CodeRule["PD001"].Generate("PD"); //Biz.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; - } - } - } -} diff --git a/Tiger.Business/WMS/BS/Biz.MaterialResale.cs b/Tiger.Business/WMS/BS/Biz.MaterialResale.cs deleted file mode 100644 index cef3c2e..0000000 --- a/Tiger.Business/WMS/BS/Biz.MaterialResale.cs +++ /dev/null @@ -1,97 +0,0 @@ -锘縰sing Apache.NMS; -using Newtonsoft.Json; -using Rhea.Common; -using SqlSugar; -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Tiger.IBusiness; -using Tiger.Model; -using System.Xml.Linq; -using System.Collections; - -namespace Tiger.Business -{ - - public partial class Biz : ControllerBase - { - public partial class BS - { - /// <summary> - /// 瀹屽伐鍏ュ簱锛岀墿鏂欒浆鍗� - /// </summary> - /// <returns></returns> - public ApiAction MaterialResale(string billcode, string whcode, string org_code) - { - try - { - var action = new ApiAction(); - var wh_id = GetWmsCode(whcode);//搴撲綅id - var items = Biz.Db.Queryable<WMS_ITEM>().Where(q => q.TRANS_NO == billcode).ToList(); - var items_pkg = Biz.Db.Queryable<WMS_ITEM_PKG>().Where(q => q.TRANS_NO == billcode).ToList(); - var ProdIn = Biz.Db.Queryable<BIZ_ERP_PROD_IN>().Where(q => q.BILLCODE == billcode).First(); - if (items.Count() == 0) - { - action.Message = "搴撳瓨琛ㄦ煡鏃犳暟鎹�"; - action.IsSuccessed = false; - return action; - } - if (items_pkg.Count() == 0) - { - action.Message = "鍖呰琛ㄦ煡鏃犳暟鎹�"; - action.IsSuccessed = false; - return action; - } - if (ProdIn.IsNullOrEmpty()) - { - action.Message = "鏌ユ棤姝ゅ崟鎹�"; - action.IsSuccessed = false; - return action; - } - foreach (var item in items) - { - item.AUTH_ORG = org_code; - item.WH_ID = wh_id.Result; - item.ERP_WH = whcode; - } - foreach (var item in items_pkg) - { - item.AUTH_ORG = org_code; - item.WH_ID = wh_id.Result; - item.ERP_WH = whcode; - } - ProdIn.STATUS = BIZ_ERP_PROD_IN.STATUSs.COMPLETE.GetValue(); - - var db = Business.Biz.Db; - //鍏ュ簱 - - var dbTran = db.UseTran(() => - { - db.Updateable(items).ExecuteCommand(); - db.Updateable(items_pkg).ExecuteCommand(); - db.Updateable(ProdIn).ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - action.Message = "杞崠澶辫触"; - } - else - { - action.Message = "杞崠鎴愬姛"; - } - - return action; - } - catch (Exception ex) - { - - throw; - } - } - } - } -} diff --git a/Tiger.Business/WMS/BS/Biz.MaterialrReq.cs b/Tiger.Business/WMS/BS/Biz.MaterialrReq.cs deleted file mode 100644 index a082057..0000000 --- a/Tiger.Business/WMS/BS/Biz.MaterialrReq.cs +++ /dev/null @@ -1,49 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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; - } - } - } -} diff --git a/Tiger.Business/WMS/BS/Biz.Transfer.cs b/Tiger.Business/WMS/BS/Biz.Transfer.cs deleted file mode 100644 index 2a7e8bc..0000000 --- a/Tiger.Business/WMS/BS/Biz.Transfer.cs +++ /dev/null @@ -1,42 +0,0 @@ -锘縰sing 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 -{ - - public partial class Biz : ControllerBase - { - public partial class BS - { - /// <summary> - /// 鍒涘缓璋冩嫧鍗曞彿 - /// </summary> - /// <returns></returns> - public ApiAction CreateTFBillCode() - { - var action = new ApiAction(); - - Result ruleResult = Biz.CodeRule["TF001"].Generate("TF"); //Biz.iWMS.GetBillNoByType("CI"); - if (!ruleResult.IsSuccessed) - { - throw new Exception(ruleResult.ExceptionMsg.Message); - } - - - action.Data = ruleResult.Data; - return action; - } - } - } -} diff --git a/Tiger.Business/WMS/BS/Biz.WareHouse.cs b/Tiger.Business/WMS/BS/Biz.WareHouse.cs deleted file mode 100644 index 18cd6d1..0000000 --- a/Tiger.Business/WMS/BS/Biz.WareHouse.cs +++ /dev/null @@ -1,374 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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> - /// 鏍规嵁浠撳簱浠g爜鍜岀被鍨嬪垹闄や粨搴撴満鏋勫垪琛� - /// </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 = 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 = 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; - } - - } - } -} diff --git a/Tiger.Business/WMS/DigitalTwin/Seastone/Biz.Rack.cs b/Tiger.Business/WMS/DigitalTwin/Seastone/Biz.Rack.cs deleted file mode 100644 index c58660d..0000000 --- a/Tiger.Business/WMS/DigitalTwin/Seastone/Biz.Rack.cs +++ /dev/null @@ -1,24 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - //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(); - //} - - } -} diff --git a/Tiger.Business/WMS/KanBan/Biz.WareHousing.cs b/Tiger.Business/WMS/KanBan/Biz.WareHousing.cs deleted file mode 100644 index 8be17fc..0000000 --- a/Tiger.Business/WMS/KanBan/Biz.WareHousing.cs +++ /dev/null @@ -1,213 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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 = 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 = 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 = 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 = 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 = 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 = 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; - } - } - } -} diff --git a/Tiger.Business/WMS/Minsun/Biz.InStorage.cs b/Tiger.Business/WMS/Minsun/Biz.InStorage.cs deleted file mode 100644 index d8d0476..0000000 --- a/Tiger.Business/WMS/Minsun/Biz.InStorage.cs +++ /dev/null @@ -1,277 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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) }; - } - } - } -} diff --git a/Tiger.Business/WMS/Minsun/Biz.Shelf.cs b/Tiger.Business/WMS/Minsun/Biz.Shelf.cs deleted file mode 100644 index 890235e..0000000 --- a/Tiger.Business/WMS/Minsun/Biz.Shelf.cs +++ /dev/null @@ -1,560 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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; - } - } - - // 鏇存柊搴撲綅浠g爜锛孡ocationCode - 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; - - } - - // 璇诲彇鏁版嵁瀛楀吀锛屾牴鎹瓹odeType,CodeValue鑾峰彇鍙傛暟Text - private static string GetSysCodeText(string codeType, string codeValue) - { - var code = 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 - - - } - } -} diff --git a/Tiger.Business/WMS/Minsun/Biz.iWMS.cs b/Tiger.Business/WMS/Minsun/Biz.iWMS.cs deleted file mode 100644 index 2be31f9..0000000 --- a/Tiger.Business/WMS/Minsun/Biz.iWMS.cs +++ /dev/null @@ -1,1856 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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 = 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 = 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 = 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 = 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 = 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; - } - //寰呮彁浜ゆ暟鎹寜鏉ユ簮鍗曞彿鍒嗙粍锛圓SN/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 = Biz.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 = Biz.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 = db.Queryable<WMS_PRDPICK_H>().Where(s => s.BILLCODE == item_h.BILLCODE).Single(); - if (prd_h?.STATUS != "COMPLETE") - { - var list_d = 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 = 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, $"瑙f瀽鏉$爜[{nFullBarcode}]鎴愬姛"); - //璇嗗埆鏂扮殑璇嗗埆浜岀淮鐮佽鍒欙紝浠寮�澶达紝鍚﹀垯鎸夋棫璇嗗埆妯″紡 - 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 瑙f瀽鍑烘潵鐨勬暟鎹墠缂�鈥淪鈥濅笉鐢ㄥ幓鎺� - //if (itemValue.StartsWith("C") || itemValue.StartsWith("P")) //涓锛圕锛夊拰鏍堟澘锛圥锛夛紝闇�瑕佸啀娆″幓鎺変竴浣� - // nBarcodeLotNo = itemValue.Substring(1); - } - else if (itemKey == "Q") - { //鏉$爜鏁伴噺 - nLotQty = itemValue; - } - else if (itemKey == "D") - { //鐢熶骇鏃ユ湡(鍘绘帀-锛屽吋瀹瑰甫-鐨勬椂闂存牸寮忥紝鍚庨潰缁熶竴鏃堕棿瑙f瀽) - 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 = $"鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"; - return result; - } - - // 瑙f瀽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("鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"); - //} - - /// 鍘熷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 = $"鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; - return result; - } - - } - - // 鍒ゆ柇鐗╂枡浠g爜鏄惁鍚堟硶 - 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锛歅O锛圡O锛� - ///P锛欳 P/N锛氭枡鍙� - ///N锛歂ame锛堢墿鏂欏悕绉帮級 - ///Q锛歈TY锛堟暟閲忥級 - ///U锛歎nit锛堝崟浣嶏級 - ///M锛歁fr P/N锛堜緵搴斿晢鍐呴儴绠℃帶鐨勭墿鏂欑殑鏂欏彿锛� - ///D锛欴ate Code锛堢敓浜ф棩鏈燂紝鐗╂枡鐨勭敓浜ф棩鏈燂級 - ///L锛歀ot Code锛堢敓浜х殑鎵规锛� - ///S锛歅AG 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,$"瑙f瀽鏉$爜[{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") - { - //鐢熶骇鏃ユ湡(鍘绘帀-锛屽吋瀹瑰甫-鐨勬椂闂存牸寮忥紝鍚庨潰缁熶竴鏃堕棿瑙f瀽) - 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锛寃eikaiyong - { - // 鍒ゆ柇鍗曟嵁缂栧彿鏄惁涓篈SN, 濡傛灉鏄疉SN锛岃皟鐢ˋSN鏍囩瑙f瀽 - 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("鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"); - 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}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; - 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鏍囩鏉$爜瑙f瀽 - /// 鎷嗚В鏉$爜锛屼緷娆℃槸锛� - /// V锛歅O锛圡O锛� - /// P锛欳 P/N锛氭枡鍙� - /// N锛歂ame锛堢墿鏂欏悕绉帮級 - /// Q锛歈TY锛堟暟閲忥級 - /// U锛歎nit锛堝崟浣嶏級 - /// M锛歁fr P/N锛堜緵搴斿晢鍐呴儴绠℃帶鐨勭墿鏂欑殑鏂欏彿锛� - /// D锛欴ate Code锛堢敓浜ф棩鏈燂紝鐗╂枡鐨勭敓浜ф棩鏈燂級 - /// L锛歀ot Code锛堢敓浜х殑鎵规锛� - /// S锛歅AG 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, $"瑙f瀽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 瑙f瀽鍑烘潵鐨勬暟鎹墠缂�鈥淪鈥濅笉鐢ㄥ幓鎺� - //if(itemValue.StartsWith("C")|| itemValue.StartsWith("P")) //涓锛圕锛夊拰鏍堟澘锛圥锛夛紝闇�瑕佸啀娆″幓鎺変竴浣� - // nBarcodeLotNo = itemValue.Substring(1); - } - else if (itemKey == "Q") - { //鏉$爜鏁伴噺 - nLotQty = itemValue; - } - else if (itemKey == "D") - { //鐢熶骇鏃ユ湡(鍘绘帀-锛屽吋瀹瑰甫-鐨勬椂闂存牸寮忥紝鍚庨潰缁熶竴鏃堕棿瑙f瀽) - //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; - } - } - - // 楠岃瘉鏉$爜鏍囩鏁伴噺鏍煎紡鏄惁姝g‘ - if (!decimal.TryParse(nLotQty, out decimal nBarcodeQty)) - { - //throw new UserFriendlyException("鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"); - result.Flag = Result.Flags.Failed; - result.Message = $"鏉$爜鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬潯鐮佹暟閲�"; - return result; - } - - // 楠岃瘉鏉$爜鏍囩鏁伴噺涓嶴RM 鏈�灏忓寘瑁呮暟閲忓悎璁℃槸鍚︿竴鑷� - decimal snQtyTotal = snBarcodeList.Sum(t => t.IncludeQty); - if (nBarcodeQty != snQtyTotal) - { - //throw new UserFriendlyException("鏍囩鏁伴噺涓嶴RM鏈�灏忓寘瑁呮�绘暟閲忎笉涓�鑷�"); - result.Flag = Result.Flags.Failed; - result.Message = $"鏍囩鏁伴噺涓嶴RM鏈�灏忓寘瑁呮�绘暟閲忎笉涓�鑷�"; - 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}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; - return result; - } - } - - if (!DateTime.TryParse(dateTimeStr, out nDateCode)) - //if (!DateTime.TryParse(nLotDate, out DateTime nDateCode)) - { - result.Flag = Result.Flags.Failed; - result.Message = $"鏉$爜[{nBarcodeLotNo}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈�"; - return result; - } - } - catch (System.Exception ex) - { - //Logger.Info($"ASN鏍囩鏉$爜瑙f瀽 =>鏉$爜[{nBarcodeLotNo}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈燂紝{ex.Message}"); - result.Flag = Result.Flags.Failed; - result.Message = $"鏉℃潯鐮乕{nBarcodeLotNo}]鏍煎紡閿欒锛氭湭鍙栧埌姝g‘鐨勬壒娆℃棩鏈燂紝{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; - - // 浠嶹MS_SRM_ASN琛ㄦ煡鎵惧崟鎹紪鍙凤紝鍒ゆ柇鏄惁涓篈SN - 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 = 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 = 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 = 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) - { - // 浠嶹MS_SRM_ASN琛ㄦ煡鎵惧崟鎹紪鍙凤紝鍒ゆ柇鏄惁涓篈SN - 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 = 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; - 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 = db.Queryable<WMS_MesMaterial>().Where(t => t.MCode.ToUpper() == detail.MATERIALCODE.ToUpper()).First(); - var nAql = db.Queryable<WMS_IQCMATERIAL_AQL>().Where(t => t.MATERIALID.Equals(nMaterial.Id)).First(); - - var nIqcHeader = new WMS_IQC_H - { - BILLCODE = Biz.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 = 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 = db.Queryable<WMS_IQCMATERIAL_AQL>().Where(t => t.IQCMATERIALID.Equals(nIQCMaterial.Id)).ToList(); - if (nIQCMaterial2AQL.Any()) - { - var nIQCMaterial2CheckItem = db.Queryable<WMS_IQCMATERIAL_CHECKITEM>().Where(t => t.IQCMATERIALID.Equals(nIQCMaterial.Id)).ToList(); - if (nIQCMaterial2CheckItem.Any()) - { - //楂樻II锛屾娊妫�鐗╂枡锛孉QL鍜屾楠岄」鐩兘缁存姢浜� - 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 = db.Queryable<WMS_IQCMATERIAL_CHECKITEM>().Where(t => t.IQCMATERIALID.Equals(nIQCMaterial.Id)).ToList(); - if (nIQCMaterial2CheckItem.Any()) - { - //鏅II锛屾娊妫�鐗╂枡锛屾病鏈夌淮鎶QL銆佷絾鏄淮鎶や簡妫�楠岄」鐩� - nIqcHeader.QCLEVEL = (int)IqcManagementSides.QCLevel.NormalII; - } - else - { - //鏅I锛屾娊妫�鐗╂枡锛屼絾鏄病鏈夌淮鎶QL鍜屾楠岄」鐩� - 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鍜孉qlCode閰嶇疆涓嬶紝绗﹀悎鐨勬壒娆℃暟閲忚寖鍥� - var nAqlDetail = 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 - } -} diff --git a/Tiger.Business/WMS/iWMS/Biz.iWMS.cs b/Tiger.Business/WMS/iWMS/Biz.iWMS.cs deleted file mode 100644 index c3379e8..0000000 --- a/Tiger.Business/WMS/iWMS/Biz.iWMS.cs +++ /dev/null @@ -1,984 +0,0 @@ -锘縰sing 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 -{ - public partial class Biz - { - 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 = Biz.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 = Biz.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/> 棰嗘枡鍗昜{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 = Biz.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/> 棰嗘枡鍗昜{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(); //鏂癝RM - 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(); } //鏃RM - 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 = Biz.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 = $"锛屽埌璐у崟鎺═100瀹屾垚"; - 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> - /// 鏍规嵁浠撳簱浠g爜鍜岀被鍨嬪垹闄や粨搴撴満鏋勫垪琛� - /// </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> - /// 鏍规嵁浠撳簱浠g爜鍜岀被鍨嬪垹闄や粨搴撴満鏋勫垪琛� - /// </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 = 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 = L("WMS.WareHouse.妫�鏌ュ偍浣嶅垵濮嬪寲", shelf.ID); - } - } - return action; - } - - /// <summary> - /// 鑾峰彇T100妫�楠屽崟鏁版嵁2023.07.23锛宐y 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; - } - } - } -} -- Gitblit v1.9.3