From 7973a66867883f4b3f73d55fcfa51d9cf4e45d1b Mon Sep 17 00:00:00 2001 From: lilili Date: Mon, 5 Jun 2023 14:46:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8B=A3=E6=96=99=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=93=8D=E4=BD=9C=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NFine.Application/WMS/PickMaterialApp.cs | 206 ++++++++++++++++-- .../WMS/Controllers/PickMaterialController.cs | 11 +- 2 files changed, 194 insertions(+), 23 deletions(-) diff --git a/WMS-BS/NFine.Application/WMS/PickMaterialApp.cs b/WMS-BS/NFine.Application/WMS/PickMaterialApp.cs index a8e1d65..3903476 100644 --- a/WMS-BS/NFine.Application/WMS/PickMaterialApp.cs +++ b/WMS-BS/NFine.Application/WMS/PickMaterialApp.cs @@ -97,7 +97,7 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'"; //工单领料(发料申请) - public DataTable GetGridJson2(string queryJson,string type, ref Pagination jqgridparam) + public DataTable GetGridJson2(string queryJson, ref Pagination jqgridparam) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; DataTable dt = new DataTable(); @@ -117,11 +117,11 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'"; sqlString.Append($@" SELECT * from (select row_number() over(partition by a.ApplyCode ORDER BY a.ApplyCode) as row, - a.ApplyCode as Code,a.CreateDateTime as MTIME,a.createperson as MUSER,a.WHCode,detail.LocationCode AS Area, + a.ApplyCode as Code,CONVERT(varchar(100),a.CreateDateTime,23) as MTIME,a.createperson as MUSER,a.WHCode,detail.LocationCode AS Area, a.EATTRIBUTE,a.Sets,a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Desks,a.DispatchNumber,a.DispatcherName, a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator, case when max(e.SourceID) is null then '未合并' else '已合并' end as IsNew,f.Colspan , - case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName != 'JOB' then '已过帐' + case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName != 'JOB' then '已过账' else (case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName = 'JOB' then '已配料' else '未配料' end) end as Status, f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 , f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.ID @@ -130,15 +130,184 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'"; LEFT JOIN ICSInventoryDetail detail ON b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint - where a.WorkPoint='{WorkPoint}' "); - if (type == "12") + where a.WorkPoint='{WorkPoint}' and a.EATTRIBUTE!='17'"); + + if (!string.IsNullOrWhiteSpace(queryJson)) { - sqlString.Append($@" and a.EATTRIBUTE='17' "); + if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) + { + sqlString.Append($@" and a.ApplyCode like '%{queryParam["POCode"]}%' "); + } + if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) + { + sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' "); + } + if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString())) + { + sqlString.Append($@" and a.WHCode like '%{queryParam["WHCode"]}%' "); + } + if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) + { + sqlString.Append($@" and detail.LocationCode like '%{queryParam["Area"]}%' "); + } + if (!string.IsNullOrWhiteSpace(queryParam["Order"].ToString())) + { + sqlString.Append($@" and a.OrderNumber like '%{queryParam["Order"]}%' "); + } + if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()) && queryParam["Container"].ToString() == "2") + { + sqlString.Append($@" and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail + WHERE + F_Define3='HGAreaConfig' AND F_Define1=a.WHCode AND F_Define4=a.WorkPoint) OR detail.LocationCode is null OR detail.LocationCode='') "); + } + if (!string.IsNullOrWhiteSpace(queryParam["CreateDate"].ToString())) + { + sqlString.Append($@" and a.CreateDateTime >='{queryParam["CreateDate"].ToDate()}' and a.CreateDateTime <'{queryParam["CreateDate"].ToDate().AddDays(+1)}' "); + } + if (!string.IsNullOrWhiteSpace(queryParam["NeedDate"].ToString())) + { + sqlString.Append($@" and a.NeedDate like '%{queryParam["NeedDate"]}%' "); + } + if (!string.IsNullOrWhiteSpace(queryParam["Status"].ToString())) + { + if (queryParam["NeedDate"].ToString() == "3") + { + sqlString.Append($@" and sum(a.Quantity) = sum(IssueQuantity) and a.MUSERName != 'JOB "); + } + else if (queryParam["NeedDate"].ToString() == "2") + { + sqlString.Append($@" and sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName = 'JOB' "); + } + else if (queryParam["NeedDate"].ToString() == "1") + { + sqlString.Append($@" and sum(a.Quantity) >= sum(IssueQuantity) "); + } + } + + + } + sqlString.Append(@" group by a.ApplyCode, a.WorkPoint,a.IssueQuantity,a.CreateDateTime,a.createperson, + f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2, + f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.WHCode,detail.LocationCode,a.ID,a.EATTRIBUTE,a.Sets,a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Desks,a.DispatchNumber,a.DispatcherName, + a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator,a.MUSERName) as t where t.row=1"); + + if (!string.IsNullOrWhiteSpace(queryParam["Status"].ToString())) + { + if (queryParam["Status"].ToString() == "3") + { + sqlString.Append($@" AND t.Status='已过帐' "); + } + else if (queryParam["Status"].ToString() == "2") + { + sqlString.Append($@" AND t.Status='已配料' "); + } + else if (queryParam["Status"].ToString() == "1") + { + sqlString.Append($@" AND t.Status='未配料' "); + } } - else + #endregion + + + return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam); + } + + //工单领料(发料申请)子表查询 + public DataTable GetSubGridJson2(string queryJson, string Code) + { + string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; + DataTable dt = new DataTable(); + var queryParam = queryJson.ToJObject(); + List parameter = new List(); + string sql = @"SELECT * FROM (select row_number() over(partition by a.ApplyCode,a.InvCode,a.Sequence ORDER BY a.ApplyCode) as row, + a.ID,a.ApplyCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName ,a.InvCode,a.OrderNumber, + a.EATTRIBUTE,a.Sets,a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Desks,a.DispatchNumber,a.DispatcherName, + a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator, + d.InvName,d.InvDesc,d.InvStd,d.InvUnit,detail.LocationCode AS Area, + case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity + ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 + ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.IssueQuantity as IssueQuantity + from ICSMOApply a + left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint + left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint + LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint + left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint + left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint + where a.ApplyCode='{0}' and a.WorkPoint='{1}' and a.EATTRIBUTE!='17'"; + + if (!string.IsNullOrWhiteSpace(queryJson)) { - sqlString.Append($@" and a.EATTRIBUTE!='17' "); + if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString())) + { + sql += " and a.WHCode like '%" + queryParam["WHCode"].ToString() + "%' "; + } + if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) + { + sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; + } + if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) + { + sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; + } + if (!string.IsNullOrWhiteSpace(queryParam["Order"].ToString())) + { + sql += $@" and a.OrderNumber like '%{queryParam["Order"]}%' "; + } + if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()) && queryParam["Container"].ToString() == "2") + { + sql += $@" and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail + WHERE + F_Define3='HGAreaConfig' AND F_Define1=a.WHCode AND F_Define4=a.WorkPoint) OR detail.LocationCode is null OR detail.LocationCode='') "; + } + if (!string.IsNullOrWhiteSpace(queryParam["CreateDate"].ToString())) + { + sql += $@" and a.CreateDateTime like '%{queryParam["CreateDate"]}%' "; + } + if (!string.IsNullOrWhiteSpace(queryParam["NeedDate"].ToString())) + { + sql += $@" and a.NeedDate like '%{queryParam["NeedDate"]}%' "; + } } + sql += " ) c WHERE c.row=1 "; + sql = string.Format(sql, Code, WorkPoint); + return Repository().FindTableBySql(sql.ToString()); + } + + //售后领料 + public DataTable GetGridJson12(string queryJson, ref Pagination jqgridparam) + { + string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; + DataTable dt = new DataTable(); + var queryParam = queryJson.ToJObject(); + List parameter = new List(); + StringBuilder sqlString = new StringBuilder(); + #region [SQL] + // select a.ID,a.ApplyCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName ,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit, + //case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity + // from ICSMOApply a + + // left join ICSWarehouse b on a.WHCode = b.WarehouseCode and a.WorkPoint = b.WorkPoint + + // left join ICSInventory d on a.InvCode = d.InvCode and a.WorkPoint = d.WorkPoint + + // left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint + + sqlString.Append($@" + SELECT * from (select row_number() over(partition by a.ApplyCode ORDER BY a.ApplyCode) as row, + a.ApplyCode as Code,CONVERT(varchar(100),a.CreateDateTime,23) as MTIME ,a.createperson MUSER,a.WHCode,detail.LocationCode AS Area, + a.EATTRIBUTE,a.Sets,a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Desks,a.DispatchNumber,a.DispatcherName, + a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator, + case when max(e.SourceID) is null then '未合并' else '已合并' end as IsNew,f.Colspan , + case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName != 'JOB' then '已过账' + else (case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName = 'JOB' then '已配料' else '未配料' end) end as Status, + f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 , + f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.ID + from ICSMOApply a + left JOIN ICSInventory b ON b.InvCode=a.InvCode + LEFT JOIN ICSInventoryDetail detail ON b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint + left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint + left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint + where a.WorkPoint='{WorkPoint}' and a.EATTRIBUTE='17' "); if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) @@ -219,8 +388,8 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'"; return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam); } - //工单领料(发料申请)子表查询 - public DataTable GetSubGridJson2(string queryJson, string type,string Code) + //售后领料(子表查询) + public DataTable GetSubGridJson12(string queryJson, string Code) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; DataTable dt = new DataTable(); @@ -240,11 +409,8 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'"; LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint - where a.ApplyCode='{0}' and a.WorkPoint='{1}'"; - if (type == "12") - { - sql += $@" and a.EATTRIBUTE='17' "; - } + where a.ApplyCode='{0}' and a.WorkPoint='{1}' and a.EATTRIBUTE='17'"; + if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString())) @@ -438,7 +604,7 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'"; //left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint //left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint"; // sql += " WHERE 1=1 and e.ID is null"; - sqlString.Append($@"select * from (select row_number() over (partition by a.ApplyCode order by a.ApplyCode ) row, a.ApplyCode as Code,a.CreateDateTime as MTIME,a.CreatePerson as MUSER, + sqlString.Append($@"select * from (select row_number() over (partition by a.ApplyCode order by a.ApplyCode ) row, a.ApplyCode as Code,CONVERT(varchar(100),a.CreateDateTime,23) as MTIME,a.CreatePerson as MUSER, case when max(e.SourceID) is null then '未合并' else '已合并' end as IsNew,f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1, @@ -628,7 +794,7 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'"; //left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint"; // sql += " WHERE 1=1 and a.Type='1' and e.ID is null"; sqlString.Append($@"SELECT * from (SELECT Row_Number() over(partition by a.SDNCode Order by a.SDNCode) as r, a.SDNCode AS Code, - a.CreateDateTime AS MTIME, + CONVERT(varchar(100),a.CreateDateTime,23) AS MTIME, a.CreatePerson AS MUSER, a.CusCode,a.CusName, (CASE WHEN max(e.SourceID) IS NULL THEN '未合并' ELSE '已合并' END) AS IsNew, @@ -755,7 +921,7 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'"; //left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint"; // sql += " WHERE 1=1 and e.ID is null "; sqlString.Append($@"select * from(select row_number() over(partition by a.OutCode order by a.OutCode) row, a.OutCode as Code, - a.CreateDateTime as MTIME, + CONVERT(varchar(100),a.CreateDateTime,23) as MTIME, a.CreatePerson as MUSER, case when max(e.SourceID) is null then '未合并' @@ -790,7 +956,7 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'"; } if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()) && queryParam["Container"].ToString() == "2") { - sqlString.Append($@" (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail + sqlString.Append($@" and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail WHERE F_Define3='HGAreaConfig' AND F_Define1=a.WHCode AND F_Define4=a.WorkPoint) OR detail.LocationCode is null OR detail.LocationCode='') "); } @@ -943,7 +1109,7 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'"; // left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint"; // sql += " WHERE 1=1 and e.ID is null "; sqlString.Append($@"select * from (select row_number() over(partition by a.TransferNO order by a.TransferNO) row, - a.TransferNO as Code,a.ID,a.CreateDateTime as MTIME,a.CreatePerson as MUSER, + a.TransferNO as Code,a.ID,CONVERT(varchar(100),a.CreateDateTime,23) as MTIME,a.CreatePerson as MUSER, case when max(e.SourceID) is null then '未合并' else '已合并' diff --git a/WMS-BS/NFine.Web/Areas/WMS/Controllers/PickMaterialController.cs b/WMS-BS/NFine.Web/Areas/WMS/Controllers/PickMaterialController.cs index 4558b02..c3566e3 100644 --- a/WMS-BS/NFine.Web/Areas/WMS/Controllers/PickMaterialController.cs +++ b/WMS-BS/NFine.Web/Areas/WMS/Controllers/PickMaterialController.cs @@ -33,9 +33,13 @@ namespace NFine.Web.Areas.WMS.Controllers { ListData = App.GetGridJson(queryJson, ref pagination); } - if (Type=="2"|| Type=="12" )//工单发料 + if (Type=="2")//工单发料 { - ListData = App.GetGridJson2(queryJson,Type, ref pagination); + ListData = App.GetGridJson2(queryJson, ref pagination); + } + if ( Type == "12")//售后领料 + { + ListData = App.GetGridJson12(queryJson, ref pagination); } if (Type=="3")//工单材料出库 { @@ -91,7 +95,8 @@ namespace NFine.Web.Areas.WMS.Controllers { DataTable ListData = new DataTable(); if (Type=="1"){ListData = App.GetSubGridJson1(Code); }//工单 - if (Type=="2"||Type=="12"){ListData = App.GetSubGridJson2(queryJson,Type,Code); }//工单发料 + if (Type=="2"){ListData = App.GetSubGridJson2(queryJson,Code); }//工单发料 + if (Type == "12") { ListData = App.GetSubGridJson12(queryJson, Code); }//工单发料 if (Type == "3") { ListData = App.GetSubGridJson3(Code); }//材料出库 if (Type == "4") { ListData = App.GetSubGridJson4(Code); }//委外备料 if (Type == "5") { ListData = App.GetSubGridJson5(Code, queryJson); }//委外领料