using NFine.Data.Extensions; using System; using System.Collections.Generic; using System.Data; using NFine.Code; using NFine.Repository; using System.Data.Common; using NFine.Domain._03_Entity.SRM; using System.Configuration; using System.Text; using System.Net; using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System.IO; using NFine.Domain._03_Entity.WMS; namespace NFine.Application.WMS { public class WMSCreateItemLotApp : RepositoryFactory { private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME , CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSMOApplyNegDetail a left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='1' group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where d.Type='1'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, string Type, ref Pagination jqgridparam) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME ,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,c.EATTRIBUTE1 AS LocationCode from ICSInventoryLot a left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint left join ICSInventoryLotDetail c on a.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint WHERE a.LotNo not like '%-%' and a.Type='" + Type + "' and c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')"; sql = string.Format(sql, Figure); return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } /// /// 点击生成条码 /// public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity, CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty , CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSMOApplyNegDetail a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } public DataTable GetVendorLotNo(string VenCode, string WorkPoint) { DataTable dt = new DataTable(); //var queryParam = queryJson.ToJObject(); List parameter = new List(); string dtPre = DateTime.Now.ToString("yyyyMMdd"); string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2"; return Repository().FindTableBySql(sql.ToString()); } /// /// 生产退料生成条码 /// /// /// /// /// 已改 /// public int CreateItemLotNo(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint); string Pre = "MDN" + ApplyNegCode + Sequence; string sql = string.Empty; //string VendorLot = queryParam["VendorLot"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string Colspan = ""; string sqls = string.Empty; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}' from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen) { string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}"; sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen }); return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString(); } /// /// 删除条码 /// /// /// public string DeleteItemLot(string keyValue) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string msg = string.Empty; string sql = string.Format(@"SELECT * FROM dbo.ICSInspection WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint); DataTable dtASN = SqlHelper.GetDataTableBySql(sql); if (dtASN != null && dtASN.Rows.Count > 0) { msg = "所选条码已生成检验单,无法删除!"; } sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint); DataTable dtCarton = SqlHelper.GetDataTableBySql(sql); if (dtCarton != null && dtCarton.Rows.Count > 0) { msg += "所选条码已入库,无法删除!"; } if (string.IsNullOrEmpty(msg)) { string sqls = string.Format("DELETE FROM ICSInventoryLotDetail WHERE LotNO IN (select LotNO from ICSInventoryLot where ID in ({0}) ) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint); sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint); SqlHelper.CmdExecuteNonQueryLi(sqls); } return msg; } public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME , CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSOApplyNegDetail a left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='2' group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint WHERE d.Type='1' "; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } public DataTable GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); //var queryParam = queryJson.ToJObject(); List parameter = new List(); string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity from ICSInventoryLot a left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint left join ICSInventoryLotDetail c on a.LotNo=c.LotNo WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")"; sql = string.Format(sql, Figure); return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } /// /// 点击委外退料生成条码 /// public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSOApplyNegDetail a left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence WHERE d.Type='1' and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 委外退料生成条码 /// /// /// /// /// 已改 /// public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "OI" + OApplyNegCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','2','{3}','{4}', getdate(),'{5}','{9}' from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @" select a.ID, a.MODetailID,a.MOCode,a.Sequence, CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,a.StartDate ,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSMO a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='3' group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint "; sql += " WHERE 1=1"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString())) { if (queryParam["Container"].ToString() == "1") { sql += " and a.RCVQuantity=a.Quantity "; } else { sql += " and (a.RCVQuantity /// 点击成品生成条码(成品) /// public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select d.Enable, a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSMO a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence left join ICSConfiguration d on d.Code='CompleteVerification' WHERE 1 =1 and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 成品生成条码 /// /// /// /// /// 已改 /// public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint); string Pre = "CP" + MOCode + Sequence; string sql = string.Empty; //string VendorLot = queryParam["VendorLot"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}' from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } /// /// 销售退货单 /// /// /// /// public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @" select a.ID,a.SDNCode,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,a.Type,a.ArriveDate,a.InvCode,a.WHCode,detail.LocationCode AS Area,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,cast(a.Amount as decimal(18,{0})) as Amount, CAST(a.SDNQuantity AS DECIMAL(18,{0})) as SDNQuantity ,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,a.WorkPoint,a.Points,a.DeliveryType,a.DeliveryDescribe,a.InvDescribe,a.OtherDescribe,a.SalesUnit,a.StockIndicator,a.IsSerialNumber ,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 from ICSSDN a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='4' AND ee.EATTRIBUTE1 is NULL group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.Type='2'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString())) { sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString())) { if (queryParam["Container"].ToString() == "1") { sql += " and a.SDNQuantity=a.Quantity "; } else { sql += " and (a.SDNQuantity /// 点击销售退货生成条码(销售退货) /// public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSSDN a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo where a.LotNo NOT LIKE'%-%' group by b.TransCode,b.TransSequence ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 销售退货生成条码 /// /// /// /// /// 已改 /// public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint); string Pre = "SR" + SDNCode + Sequence; string sql = string.Empty; //string VendorLot = queryParam["VendorLot"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')", LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}' from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode,a.WorkPoint,a.OrderType, a.TypeDescribe,a.CostCenter,a.Remarks,a.PersonNumber,a.InvDescribe, a.Unit,a.StockIndicator,detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.InQuantity AS DECIMAL(18,{0})) as InQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSOtherIn a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='5' AND ee.EATTRIBUTE1 is NULL group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.Status='1'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString())) { sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString())) { if (queryParam["Container"].ToString() == "1") { sql += " and a.InQuantity=a.Quantity "; } else { sql += " and (a.InQuantity /// 点击销售退货生成条码(其他入库) /// public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSOtherIn a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo WHERE a.LotNo NOT LIKE'%-%' group by b.TransCode,b.TransSequence ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 其他入库生成条码 /// /// /// /// /// 已改 /// public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint); string Pre = "QT" + InCode + Sequence; string sql = string.Empty; //string VendorLot = queryParam["VendorLot"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}' from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } //归还 public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as ReturnQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSReturn a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='6' group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.Status='2'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } //获取工序外协检验合格单 public DataTable GetGridJsonGXWX(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @" select a.ID, '' as 'POCode', '' as POSequence,a.ModificationDate,a.TrackingNumber,a.NonconformingForm,a.POID, a.DNCode,a.Sequence,a.VenCode,a.DepCode AS VenName,a.WHCode,a.InvCode,a.DNID,a.DNDetailID,a.WorkPoint,a.InspectionType,a.InvoDescribe,a.Unity,a.StockIndicator, b.InvName,b.InvStd,b.InvDesc,b.InvUnit, b.DrawingNo, b.Version AS Version1, detail.LocationCode AS Area, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount ,CASE When ISNULL(a.RCVQuantity,0)!=ISNULL(a.Quantity,0) Then '否' ELSE '是' END AS SAPMark,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 ,Case When a.WHCode+';'+detail.LocationCode in (select F_Define1+';'+F_Define2 from Sys_SRM_ItemsDetail where F_Define3='HGAreaConfig') THEN '货柜' ELSE '平库' END AS AreaType from ICSDeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7' and ee.EATTRIBUTE1 is null group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint -- inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.DNType='1' and a.Status='2' and a.ASNCode is null AND ISNULL(a.EATTRIBUTE2,'')='F' "; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString())) { sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString())) { sql += " and a.DepCode like '%" + queryParam["VenName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString())) { sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } if (!string.IsNullOrWhiteSpace(queryParam["SAPMark"].ToString())) { sql = $@"select * from ({sql}) c where c.SAPMark='{queryParam["SAPMark"]}' "; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } //审核到货单(采购订单需与审核到货单一起同步) public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID, '' as 'POCode',-- d.POCode,d.Sequence as POSequence, '' as POSequence,a.ModificationDate,a.TrackingNumber,a.NonconformingForm,a.POID, a.DNCode,a.Sequence,a.VenCode,a.DepCode AS VenName,a.WHCode,a.InvCode,a.DNID,a.DNDetailID,a.WorkPoint,a.InspectionType,a.InvoDescribe,a.Unity,a.StockIndicator, b.InvName,b.InvStd,b.InvDesc,b.InvUnit, b.DrawingNo, b.Version AS Version1, detail.LocationCode AS Area,a.EATTRIBUTE3, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 ,Case When a.WHCode+';'+detail.LocationCode in (select F_Define1+';'+F_Define2 from Sys_SRM_ItemsDetail where F_Define3='HGAreaConfig') THEN '货柜' ELSE '平库' END AS AreaType from ICSDeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7' and ee.EATTRIBUTE1 is null group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint -- inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.DNType='1' and a.Status='2' and a.ASNCode is null AND ISNULL(a.EATTRIBUTE2,'')!='F' "; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString())) { sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString())) { sql += " and a.DepCode like '%" + queryParam["VenName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString())) { sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString())) { if (queryParam["Container"].ToString() == "1") { sql += " and a.RCVQuantity=a.Quantity and a.Quantity!=0 "; } else { sql += " and (a.RCVQuantity parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID, d.OOCode,d.Sequence as OOSequence,a.ODNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,detail.LocationCode AS Area,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime, CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSODeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8' group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.ODNType='1' and a.Status='2' and a.OASNCode is null"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString())) { sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString())) { sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } //开立得成品入库单 public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @" select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode,a.EATTRIBUTE,a.WorkPoint,a.InvDescribe,a.OrderNumber,a.Desks,a.DispatcherName, a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Unit, a.StockIndicator,a.RemarksTerm,detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity , CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 ,Case When a.WHCode+';'+detail.LocationCode in (select F_Define1+';'+F_Define2 from Sys_SRM_ItemsDetail where F_Define3='HGAreaConfig') THEN '货柜' ELSE '平库' END AS AreaType from ICSManufactureReceive a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9' AND ee.EATTRIBUTE1 is NULL group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.Status='1' and a.Type='1'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["OrderNumber"].ToString())) { sql += " and a.OrderNumber like '%" + queryParam["OrderNumber"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString())) { if (queryParam["Container"].ToString() == "1") { sql += " and a.RCVQuantity=a.Quantity "; } else { sql += " and (a.RCVQuantity /// 点击审核委外到货单生成条码(审核委外到货单) /// public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSODeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 点击开立成品入库生成条码(开立成品入库单) /// /// //-- public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSManufactureReceive a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo WHERE a.LotNo NOT LIKE'%-%' group by b.TransCode,b.TransSequence ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 点击审核到货单生成条码(审核到货单) /// public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays ,e.BatchCode,e.Brand,e.ProjectCode from ICSDeliveryNotice a left join ICSExtension e ON e.ID=a.ExtensionID left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo where a.LotNo NOT LIKE'%-%' group by b.TransCode,b.TransSequence ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 点击归还生成条码(归还) /// public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSReturn a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 归还单生成条码 /// /// /// /// /// 已改 /// public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "GH" + ReturnCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}' from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } /// /// 审核到货单生成条码 /// /// /// /// /// 已改 /// public int SubmitFormSHDH(string DNCode, string Sequence, string INVCode, string keyValue, string WorkPoint) { try { //string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString(); var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "DN" + DNCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; //string InspectJosn = ""; //InspectJosn += "{"; //InspectJosn += "\"IMP_ORDINI\":["; //InspectJosn += "{"; //InspectJosn += "\"ORD_ORDINE\":\"" + DNCode + "\","; //InspectJosn += "货柜区域预留"; //InspectJosn += "\"ORD_DES\":\"采购入库-采购到货单\","; //InspectJosn += "\"ORD_TIPOOP\":\"V\","; //InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\""; //InspectJosn += "}"; //InspectJosn += "],"; //InspectJosn += "\"IMP_ORDINI_RIGHE\":["; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } //Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); //sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); //object ExtensionID = SqlHelper.ExecuteScalar(sqls); sqls = $@"SELECT TOP 1 ExtensionID FROM ICSDeliveryNotice WHERE DNCode='{DNCode}'"; object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } //获取推荐库位 var locstionsql = $@"DECLARE @locationCodeCurrent VARCHAR(50) SET @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{WorkPoints}' AND a.WarehouseCode= (SELECT TOP 1 WHCode FROM ICSDeliveryNotice WHERE DNCode='{DNCode}' And Sequence='{Sequence}' ) AND a.InvCode= '{INVCode}' AND a.Quantity>0 ORDER BY InDate DESC) PRINT(@locationCodeCurrent) IF @locationCodeCurrent is NULL BEGIN set @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{WorkPoints}' AND a.WarehouseCode= (SELECT TOP 1 WHCode FROM ICSDeliveryNotice WHERE DNCode='{DNCode}' And Sequence='{Sequence}' ) AND a.InvCode= '{INVCode}' AND a.Quantity=0 ORDER BY InDate DESC) END SELECT @locationCodeCurrent"; object locationCode = SqlHelper.ExecuteScalar(locstionsql); string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','{6}')", LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints, locationCode); sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}' from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //if (i == createPageCount - 1) //{ // InspectJosn += "{"; // InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\","; // InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\","; // InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\","; // InspectJosn += "\"RIG_SUB2\": \"\","; // //InspectJosn += "\"RIG_OPERATORE_ASSEGNATO\": \"" + 20220968 + "\","; // InspectJosn += "\"RIG_QTAR\": " + LOTQTY + ","; // InspectJosn += "\"RIG_HOSTINF\": " + Sequence + ""; // InspectJosn += "}"; //} //else //{ // InspectJosn += "{"; // InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\","; // InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\","; // InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\","; // InspectJosn += "\"RIG_SUB2\": \"\","; // //InspectJosn += "\"RIG_OPERATORE_ASSEGNATO\": \"" + 20220968 + "\","; // InspectJosn += "\"RIG_QTAR\": " + LOTQTY + ","; // InspectJosn += "\"RIG_HOSTINF\": " + Sequence + ""; // InspectJosn += "},"; //} } //InspectJosn += "]"; //InspectJosn += "}"; //string result = ""; //#region 验证物料对应仓储区域,非货柜区域不调用接口向货柜传输数据 //string LocationCode = ""; //string InvWHCode = ""; //string chksql = @"select LocationCode,WHCode from ICSInventoryDetail // where INVCode='{0}' and WHCode=( // select WHCode from ICSDeliveryNotice // where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}')"; //chksql = string.Format(chksql, INVCode, DNCode, Sequence, WorkPoint); //DataTable chkdt = SqlHelper.GetDataTableBySql(chksql); //if (chkdt.Rows.Count == 0) //{ // throw new Exception("当前选中行物料在对应库存地点没有维护有效的区域,无法生成条码,请确认!"); //} //else //{ // LocationCode = chkdt.Rows[0]["LocationCode"].ToString(); // InvWHCode = chkdt.Rows[0]["WHCode"].ToString(); // chksql = @"select F_Id from Sys_SRM_ItemsDetail // where F_Define3='HGAreaConfig' AND F_Define1='{0}' AND F_Define2='{1}' and F_Define4='{2}'"; // chksql = string.Format(chksql, InvWHCode, LocationCode, WorkPoint); // chkdt = SqlHelper.GetDataTableBySql(chksql); //} //#endregion //if (chkdt.Rows.Count > 0 && Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"])) //{ // #region 货柜接口调用前日志 // object logID = Guid.NewGuid(); // string logsql = @"insert into ICSWMS_HGLog // values // ('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}')"; // logsql = string.Format(logsql, logID, InspectJosn, "", WorkPoint, MUSER, MUSERNAME); // SqlHelper.CmdExecuteNonQueryLi(logsql); // #endregion // InspectJosn = InspectJosn.Replace("货柜区域预留", "\"ORD_ELEAREE\":\"" + LocationCode + "\","); // result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr); // #region 货柜接口调用后日志 // logsql = @"update ICSWMS_HGLog set ReturnResult='{0}' // where ID='{1}'"; // logsql = string.Format(logsql, result, logID); // SqlHelper.CmdExecuteNonQueryLi(logsql); // #endregion // if (!result.Contains("successo")) // { // ICSHGResult hgresult = JsonConvert.DeserializeObject(result.TrimStart('[').TrimEnd(']')); // throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + ""); // } //} int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 审核到货单生成条码(批量生成) /// /// /// /// /// 已改(2023-6-13) /// public int SubmitSHDH(string ids) { try { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; DateTime MTime = DateTime.Now; string sql = $@"SELECT * FROM ICSDeliveryNotice a WHERE ID in({ids}) AND DNCode NOT IN(SELECT TransCode From ICSInventoryLotDetail b where a.Sequence=b.TransSequence) "; var dataset = Repository().FindDataSetBySql(sql); if (dataset.Tables.Count <= 0) return 0; DataTable table = dataset.Tables[0]; StringBuilder sqlString = new StringBuilder(); for (int i = 0; i < table.Rows.Count; i++) { string dnCode = table.Rows[i]["DNCode"].ToString(); string invCode = table.Rows[i]["INVCode"].ToString(); string workPoint = table.Rows[i]["WorkPoint"].ToString(); string whCode = table.Rows[i]["WHCode"].ToString(); string quantity = table.Rows[i]["Quantity"].ToString(); string sequence = table.Rows[i]["Sequence"].ToString(); string extensionID = table.Rows[i]["ExtensionID"].ToString(); string amount = table.Rows[i]["Amount"].ToString(); string code = "DN" + table.Rows[i]["DNCode"].ToString() + table.Rows[i]["Sequence"].ToString(); //条码 string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 5); //获取推荐库位 var locstionsql = $@"DECLARE @locationCodeCurrent VARCHAR(50) SET @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{workPoint}' AND a.WarehouseCode= '{whCode}' AND a.InvCode= '{invCode}' AND a.Quantity>0 ORDER BY InDate DESC) PRINT(@locationCodeCurrent) IF @locationCodeCurrent is NULL BEGIN set @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{workPoint}' AND a.WarehouseCode= '{whCode}' AND a.InvCode= '{invCode}' AND a.Quantity=0 ORDER BY InDate DESC) END SELECT @locationCodeCurrent"; object locationCode = SqlHelper.ExecuteScalar(locstionsql); sqlString.Append($@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) Values('{LotNo}','{dnCode}','{sequence}','{MUSER}','{MUSERNAME}',getdate(),'{workPoint}','{locationCode}');"); sqlString.Append($@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) Values( newid(),'{LotNo}','{invCode}','{MTime}','2999-12-31','{quantity}','{extensionID}','7','{MUSER}','{MUSERNAME}', getdate(),'{workPoint}','{amount}');"); } if (sqlString.IsEmpty()) { return 0; } int count = SqlHelper.CmdExecuteNonQueryLi(sqlString.ToString()); return count; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 检验合格单生成条码批量入库 /// /// /// /// /// public int BatchStockIN(string ids, string BinCode) { try { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; DateTime MTime = DateTime.Now; string sql = $@"SELECT * FROM ICSDeliveryNotice a WHERE ID in({ids}) AND DNCode NOT IN(SELECT TransCode From ICSInventoryLotDetail b where a.Sequence=b.TransSequence) "; var dataset = Repository().FindDataSetBySql(sql); if (dataset.Tables.Count <= 0) return 0; DataTable table = dataset.Tables[0]; StringBuilder sqlString = new StringBuilder(); string Identification = Guid.NewGuid().ToString(); for (int i = 0; i < table.Rows.Count; i++) { string dnCode = table.Rows[i]["DNCode"].ToString(); string invCode = table.Rows[i]["INVCode"].ToString(); string workPoint = table.Rows[i]["WorkPoint"].ToString(); string whCode = table.Rows[i]["WHCode"].ToString(); string quantity = table.Rows[i]["Quantity"].ToString(); string sequence = table.Rows[i]["Sequence"].ToString(); string extensionID = table.Rows[i]["ExtensionID"].ToString(); string amount = table.Rows[i]["Amount"].ToString(); string code = "DN" + table.Rows[i]["DNCode"].ToString() + table.Rows[i]["Sequence"].ToString(); //条码 string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 5); #region 验证输入库位是否满足单据要求 string binsql = $@"select LocationCode from ICSLocation where LocationCode='{BinCode}' and WorkPoint='{workPoint}'"; var bindataset = Repository().FindDataSetBySql(binsql); DataTable bintable = bindataset.Tables[0]; if (bintable.Rows.Count == 0) { throw new Exception("输入的库位不存在,无法入库!"); } binsql = $@"select LocationCode from ICSInventoryDetail where INVCode='{invCode}' and WHCode='{whCode}' and WorkPoint='{workPoint}'"; bindataset = Repository().FindDataSetBySql(binsql); bintable = bindataset.Tables[0]; if (bintable.Rows.Count != 0) { if (BinCode.Split('-')[0].ToString() != whCode || BinCode.Split('-')[1].ToString() != bintable.Rows[0]["LocationCode"].ToString()) { throw new Exception("单据:" + dnCode + "的入库区域与输入的库位不符,无法入库!"); } } #endregion #region 生成条码 sqlString.Append($@" Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) Values('{LotNo}','{dnCode}','{sequence}','{MUSER}','{MUSERNAME}',getdate(),'{workPoint}','')"); sqlString.Append($@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) Values( newid(),'{LotNo}','{invCode}','{MTime}','2999-12-31','{quantity}','{extensionID}','7','{MUSER}','{MUSERNAME}', getdate(),'{workPoint}','{amount}')"); #endregion #region 入库 sqlString.Append($@" Update ICSDeliveryNotice set RCVQuantity=Quantity where DNCode='{dnCode}' AND WorkPoint='{workPoint}'"); sqlString.Append($@" INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) SELECT NEWID(),a.LotNo ,e.WarehouseCode,d.LocationCode,a.InvCode ,a.Quantity,getdate(),'0',f.F_Account ,f.F_RealName ,getdate(),a.WorkPoint ,'' FROM ICSInventoryLot a INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint INNER JOIN ICSLocation d ON d.LocationCode='{BinCode}' AND a.WorkPoint=d.WorkPoint INNER JOIN ICSWarehouse e ON d.WHID=e.ID AND d.WorkPoint=e.WorkPoint INNER JOIN Sys_SRM_User f ON f.F_Account='{MUSER}' AND a.WorkPoint=f.F_Location WHERE a.LotNo='{LotNo}' AND a.WorkPoint='{workPoint}'"); sqlString.Append($@" INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode, FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity, Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID, ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName, MTIME,WorkPoint,EATTRIBUTE1,LogID) SELECT NEWID(),'{Identification}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode , '','',c.WarehouseCode,c.LocationCode,'{quantity}', '','0','2','2','0','', '','','',f.F_Account ,f.F_RealName , SYSDATETIME() ,a.WorkPoint ,'','' FROM ICSInventoryLot a INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint INNER JOIN Sys_SRM_User f ON f.F_Account='{MUSER}' AND a.WorkPoint=f.F_Location WHERE a.LotNo='{LotNo}' AND a.WorkPoint='{workPoint}'"); #endregion } if (sqlString.IsEmpty()) { return 0; } #region 调用SAP接口(检验合格单为两层结构 一行对应一个序列号) string IsSuccess = ""; string ErrorMessage = ""; foreach (DataRow dr in table.Rows) { SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU Client = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU(); SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU1 Info = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU1(); Info.NEWID = Identification; Info.PRUEFLOS = dr["DNCode"].ToString(); Info.L_LME = System.Decimal.Round(Convert.ToDecimal(dr["Quantity"].ToString()), 3); Info.SERNP = ""; Info.Z_GERNR = new SAPCallBackJYHGDVPN.ZWEBS_GERNR[0]; SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKUResponse result = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKUResponse(); result = Client.CallZWMS_SK_WS_RUKU(Info); if (result.Z_NULL == "N") { IsSuccess = "N"; ErrorMessage += result.L_MESSAGE; } else { log.Debug("批量过账返回值:" + result.Z_NULL + "批量过账返回信息:" + result.L_MESSAGE); } } if (IsSuccess == "N") { log.Debug("批量过账返回值:" + IsSuccess + "批量过账返回信息:" + ErrorMessage); throw new Exception(ErrorMessage); } #endregion int count = SqlHelper.CmdExecuteNonQueryLi(sqlString.ToString()); return count; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 获取批量入库区域 /// /// /// /// /// public string GetBatchStockINLocation() { try { string Location = ""; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); string sql = @" select F_Define1 from Sys_SRM_ItemsDetail where F_ItemName='INLocation' AND F_Define4='1701'"; var dataset = Repository().FindDataSetBySql(sql); if (dataset.Tables.Count <= 0) return ""; DataTable table = dataset.Tables[0]; foreach (DataRow dr in table.Rows) { if (Location == "") { Location = dr["F_Define1"].ToString(); } else { Location += "," + dr["F_Define1"].ToString(); } } return Location; } catch (Exception ex) { throw new Exception(ex.Message); } } //领料申请退料生成条码 public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string INVCode, string keyValue, string WorkPoint) { string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString(); var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint); string Pre = "MA" + ApplyNegCode + Sequence; string sql = string.Empty; //string VendorLot = queryParam["VendorLot"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}' from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } /// /// 开立成品入库单 /// /// /// /// /// 已改 /// public int SubmitFormKLCPRK(string RCVCode, string Sequence, string INVCode, string keyValue, string WorkPoint) { string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString(); var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "KCP" + RCVCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints); sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}' from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } /// /// 开立成品入库单(批量) /// /// /// /// /// 已改 /// public int SubmitKLCPRK(string ids) { try { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; DateTime MTime = DateTime.Now; string sql = $@"SELECT * FROM ICSManufactureReceive a WHERE ID in({ids}) AND RCVCode NOT IN(SELECT TransCode From ICSInventoryLotDetail b where a.Sequence=b.TransSequence) "; var dataset = Repository().FindDataSetBySql(sql); if (dataset.Tables.Count == 0) return 0; DataTable table = dataset.Tables[0]; StringBuilder sqlString = new StringBuilder(); for (int i = 0; i < table.Rows.Count; i++) { string dnCode = table.Rows[i]["RCVCode"].ToString(); string invCode = table.Rows[i]["INVCode"].ToString(); string workPoint = table.Rows[i]["WorkPoint"].ToString(); string whCode = table.Rows[i]["WHCode"].ToString(); string quantity = table.Rows[i]["Quantity"].ToString(); string sequence = table.Rows[i]["Sequence"].ToString(); string extensionID = table.Rows[i]["ExtensionID"].ToString(); string amount = table.Rows[i]["Amount"].ToString(); string code = "KCP" + dnCode + sequence; ; //条码 string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 5); //获取推荐库位 var locstionsql = $@"DECLARE @locationCodeCurrent VARCHAR(50) SET @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{workPoint}' AND a.WarehouseCode= '{whCode}' AND a.InvCode= '{invCode}' AND a.Quantity>0 ORDER BY InDate DESC) PRINT(@locationCodeCurrent) IF @locationCodeCurrent is NULL BEGIN set @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{workPoint}' AND a.WarehouseCode= '{whCode}' AND a.InvCode= '{invCode}' AND a.Quantity=0 ORDER BY InDate DESC) END SELECT @locationCodeCurrent"; object locationCode = SqlHelper.ExecuteScalar(locstionsql); sqlString.Append($@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) Values('{LotNo}','{dnCode}','{sequence}','{MUSER}','{MUSERNAME}',getdate(),'{workPoint}','{locationCode}');"); sqlString.Append($@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) Values( newid(),'{LotNo}','{invCode}','{MTime}','2999-12-31','{quantity}','{extensionID}','9','{MUSER}','{MUSERNAME}', getdate(),'{workPoint}','{amount}');"); } if (sqlString.IsEmpty()) { return 0; } int count = SqlHelper.CmdExecuteNonQueryLi(sqlString.ToString()); return count; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 审核委外到货单生成条码 /// /// /// /// /// 已改 /// public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "ODN" + ODNCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints); sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}' from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } /// /// 开立成品入库单 /// /// /// /// /// 已改 /// public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "KCP" + RCVCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); //获取推荐库位 var locstionsql = $@"DECLARE @locationCodeCurrent VARCHAR(50) SET @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{WorkPoints}' AND a.WarehouseCode= (SELECT TOP 1 WHCode FROM ICSManufactureReceive WHERE RCVCode='{RCVCode}' And Sequence='{Sequence}' ) AND a.InvCode= (SELECT TOP 1 INVCode FROM ICSManufactureReceive WHERE RCVCode='{RCVCode}' And Sequence='{Sequence}') AND a.Quantity>0 ORDER BY InDate DESC) PRINT(@locationCodeCurrent) IF @locationCodeCurrent is NULL BEGIN set @locationCodeCurrent=(SELECT top 1 a.LocationCode FROM ICSWareHouseLotInfo a WHERE a.WorkPoint= '{WorkPoints}' AND a.WarehouseCode= (SELECT TOP 1 WHCode FROM ICSManufactureReceive WHERE RCVCode='{RCVCode}' And Sequence='{Sequence}' ) AND a.InvCode= (SELECT TOP 1 INVCode FROM ICSManufactureReceive WHERE RCVCode='{RCVCode}' And Sequence='{Sequence}') AND a.Quantity=0 ORDER BY InDate DESC) END SELECT @locationCodeCurrent"; object locationCode = SqlHelper.ExecuteScalar(locstionsql); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','{6}' )", LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints, locationCode); sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}' from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } //委外拒收单 public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID, a.ODNCode OOCode,a.Sequence OOSequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSODeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11' group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null "; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString())) { sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString())) { sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } //拒收单 public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST( a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime, CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSDeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10' group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null "; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString())) { sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString())) { sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } //领料申请退料 public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,d.CreateDateTime, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY,a.EATTRIBUTE ,a.WHCode,detail.LocationCode AS Area,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 ,Case When a.WHCode+';'+detail.LocationCode in (select F_Define1+';'+F_Define2 from Sys_SRM_ItemsDetail where F_Define3='HGAreaConfig') THEN '货柜' ELSE '平库' END AS AreaType from ICSMOApplyNegDetail a left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInventoryDetail detail ON b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12' AND ee.EATTRIBUTE1 is NULL group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint WHERE d.Type='2'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString())) { sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString())) { sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString())) { if (queryParam["Container"].ToString() == "1") { sql += " and a.IssueNegQuantity=a.Quantity "; } else { sql += " and (a.IssueNegQuantity /// 拒收生成条码 /// /// /// /// /// public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "JS" + DNCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}' from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } /// /// 委外拒收生成条码 /// /// /// /// /// public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "OJS" + ODNCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@" insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}' from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } /// /// 点击审核到货单生成条码(审核到货单) /// public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSDeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence WHERE a.DNType='3' and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } /// /// 点击审核委外到货单生成条码(审核委外到货单) /// public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSODeliveryNotice a left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence WHERE a.ODNType='3' and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSMOApplyNegDetail a left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo WHERE a.LotNo NOT LIKE'%-%' group by b.TransCode,b.TransSequence ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence WHERE d.Type='2' and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } //材料出库退料 public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @" select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity, CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSMOApplyNegDetail a left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13' group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint WHERE d.Type='3'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } //材料出库退料 public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSMOApplyNegDetail a left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence WHERE d.Type='3' and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } //材料出库退料生成条码 public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "MD" + ApplyNegCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}' from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSOApplyNegDetail a left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14' group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint WHERE d.Type='2'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } /// /// 点击委外领料退料生成条码 /// public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSOApplyNegDetail a left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence WHERE d.Type='2' and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } //委外领料申请退料 public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "OMA" + OApplyNegCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}' from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } //委外材料出库 public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSOApplyNegDetail a left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15' group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint WHERE d.Type='3'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } //委外材料出库 public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSOApplyNegDetail a left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence WHERE d.Type='3' and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } //委外材料出库 public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint); string Pre = "OMD" + OApplyNegCode + Sequence; string sql = string.Empty; //string VendorLot = queryParam["VendorLot"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0) //{ sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}' from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //} } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime) { string sql = @"select ColCode from ICSExtensionEnable where Enable=0 order by cast(EATTRIBUTE1 as int)"; DataTable dt = SqlHelper.GetDataTableBySql(sql); return dt; } //返工工单 public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam) { DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List parameter = new List(); object Figure = GetDecimalDigits(); #region [SQL] string sql = @"select a.ID,d.MOCode,d.Sequence+'-'+ a.Sequence as Sequence,a.PickID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,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 from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16' group by mm.TransCode,mm.TransSequence,ee.WorkPoint )c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'"; sql = string.Format(sql, Figure); sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName()); #endregion if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List parameter = new List(); string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty, CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint left join ( select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a left join ICSInventoryLotDetail b on a.LotNo=b.LotNo group by b.TransCode,b.TransSequence ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence WHERE 1=1 and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'"; sql += " and a.WorkPoint='" + WorkPoint + "'"; sql = string.Format(sql, Figure); return Repository().FindTableBySql(sql.ToString()); } //返工工单 public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "FG" + FGGDMOCode + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString(); sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )", ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(), MUSER, MUSERNAME, WorkPoints); } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint) Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )", LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints); sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}' from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint where d.MOCode='{6}' and d.Sequence+'-'+a.Sequence='{7}' and a.WorkPoint='{5}' ", LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; } //工序外协检验合格单过账SAP public string GXWXCallSAPInterFace(string DocNoList) { try { string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); #region 检验合格单 string sql = @" select ID,DNCode,SAPSequence from ICSDeliveryNotice where DNCode in ({0}) and WorkPoint='{1}'"; sql = string.Format(sql, DocNoList.TrimEnd(','), WorkPoint); DataTable dt = Repository().FindTableBySql(sql.ToString()); for (int i = 0; i < dt.Rows.Count; i++) { #region 调用SAP接口(检验合格单为两层结构 一行对应一个序列号) string IsSuccess = ""; string ErrorMessage = ""; SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU Client = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU(); SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU1 Info = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU1(); Info.NEWID = dt.Rows[i]["ID"].ToString(); Info.PRUEFLOS = dt.Rows[i]["DNCode"].ToString(); Info.L_LME = System.Decimal.Round(Convert.ToDecimal(dt.Rows[i]["SAPSequence"].ToString()), 3); Info.SERNP = ""; Info.Z_GERNR = new SAPCallBackJYHGDVPN.ZWEBS_GERNR[0]; SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKUResponse result = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKUResponse(); result = Client.CallZWMS_SK_WS_RUKU(Info); if (result.Z_NULL == "N") { IsSuccess = "N"; ErrorMessage += result.L_MESSAGE; } else { log.Debug("过账返回值:" + result.Z_NULL + "过账返回信息:" + result.L_MESSAGE); string updatesql = @"update ICSDeliveryNotice set RCVQuantity+=Convert(decimal(18,6),SAPSequence) where DNCode='{0}' and WorkPoint='{1}'"; updatesql = string.Format(updatesql, dt.Rows[i]["DNCode"].ToString(), WorkPoint); SqlHelper.CmdExecuteNonQueryLi(updatesql.ToString()); } if (IsSuccess == "N") { log.Error("过账返回值:" + IsSuccess + "过账返回信息:" + ErrorMessage); throw new Exception(ErrorMessage); } #endregion } #endregion return ""; } catch (Exception ex) { return ex.Message; } } //单据上传货柜 public string DocUpLoadToHG(string DocNoList, string Type) { try { string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); string DocNoInfo = DocNoList.TrimEnd(','); StringBuilder stringBuilder = new StringBuilder(); string InspectJosn = ""; List DocListSave = new List(); #region 检验合格单 if (Type == "7") { InspectJosn += "{"; InspectJosn += "\"IMP_ORDINI\":["; foreach (string DocNO in DocNoInfo.Split(',')) { if (!DocListSave.Contains(DocNO)) { DocListSave.Add(DocNO); InspectJosn += "{"; InspectJosn += "\"ORD_ORDINE\":\"" + DocNO + "\","; InspectJosn += "\"ORD_DES\":\"采购入库-采购到货单\","; InspectJosn += "\"ORD_TIPOOP\":\"V\","; InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\""; InspectJosn += "},"; } } InspectJosn = InspectJosn.TrimEnd(','); InspectJosn += "],"; InspectJosn += "\"IMP_ORDINI_RIGHE\":["; foreach (string DocNO in DocListSave) { string sql = @" select A.DNCode,A.Sequence,A.InvCode,ISNULL(A.SAPSequence,A.Quantity) AS Quantity,B.LocationCode AS Area from ICSDeliveryNotice A INNER JOIN ICSInventoryDetail B ON B.WHCode=A.WHCode AND B.INVCode=A.InvCode AND B.WorkPoint=A.WorkPoint where A.DNCode='{0}' and A.WorkPoint='{1}'"; sql = string.Format(sql, DocNO, WorkPoint); DataTable dt = Repository().FindTableBySql(sql.ToString()); for (int i = 0; i < dt.Rows.Count; i++) { //RIG_ELERUOLI_GEST-区域-出入库都要 //RIG_ELEBAIE-机器出口-出库-出库才要 InspectJosn += "{"; InspectJosn += "\"RIG_ORDINE\":\"" + DocNO + "\","; InspectJosn += "\"RIG_ARTICOLO\": \"" + dt.Rows[i]["InvCode"].ToString() + "\","; InspectJosn += "\"RIG_SUB1\": \"\","; InspectJosn += "\"RIG_SUB2\": \"\","; InspectJosn += "\"RIG_ELEBAIE\": \"\","; InspectJosn += "\"RIG_ELERUOLI_GEST\": \"" + dt.Rows[i]["Area"].ToString() + "\","; InspectJosn += "\"RIG_QTAR\": " + dt.Rows[i]["Quantity"].ToString() + ","; InspectJosn += "\"RIG_HOSTINF\": " + dt.Rows[i]["Sequence"].ToString() + ""; InspectJosn += "},"; } stringBuilder.Append($@"'{DocNO}',"); } InspectJosn = InspectJosn.TrimEnd(','); InspectJosn += "]"; InspectJosn += "}"; } #endregion #region 机加工成品入库单 if (Type == "9") { InspectJosn += "{"; InspectJosn += "\"IMP_ORDINI\":["; foreach (string DocNO in DocNoInfo.Split(',')) { if (!DocListSave.Contains(DocNO)) { DocListSave.Add(DocNO); InspectJosn += "{"; InspectJosn += "\"ORD_ORDINE\":\"" + DocNO + "\","; InspectJosn += "\"ORD_DES\":\"产成品入库-产成品入库单\","; InspectJosn += "\"ORD_TIPOOP\":\"V\","; InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\""; InspectJosn += "},"; } } InspectJosn = InspectJosn.TrimEnd(','); InspectJosn += "],"; InspectJosn += "\"IMP_ORDINI_RIGHE\":["; foreach (string DocNO in DocListSave) { string sql = @" select A.RCVCode,A.Sequence,A.InvCode,A.Quantity,B.LocationCode AS Area from ICSManufactureReceive A INNER JOIN ICSInventoryDetail B ON B.WHCode=A.WHCode AND B.INVCode=A.InvCode AND B.WorkPoint=A.WorkPoint where A.RCVCode='{0}' and A.WorkPoint='{1}'"; sql = string.Format(sql, DocNO, WorkPoint); DataTable dt = Repository().FindTableBySql(sql.ToString()); for (int i = 0; i < dt.Rows.Count; i++) { //RIG_ELERUOLI_GEST-区域-出入库都要 //RIG_ELEBAIE-机器出口-出库-出库才要 InspectJosn += "{"; InspectJosn += "\"RIG_ORDINE\":\"" + DocNO + "\","; InspectJosn += "\"RIG_ARTICOLO\": \"" + dt.Rows[i]["InvCode"].ToString() + "\","; InspectJosn += "\"RIG_SUB1\": \"\","; InspectJosn += "\"RIG_SUB2\": \"\","; InspectJosn += "\"RIG_ELEBAIE\": \"\","; InspectJosn += "\"RIG_ELERUOLI_GEST\": \"" + dt.Rows[i]["Area"].ToString() + "\","; InspectJosn += "\"RIG_QTAR\": " + dt.Rows[i]["Quantity"].ToString() + ","; InspectJosn += "\"RIG_HOSTINF\": " + dt.Rows[i]["Sequence"].ToString() + ""; InspectJosn += "},"; } } InspectJosn = InspectJosn.TrimEnd(','); InspectJosn += "]"; InspectJosn += "}"; } #endregion #region 生产退料单 if (Type == "12") { InspectJosn += "{"; InspectJosn += "\"IMP_ORDINI\":["; foreach (string DocNO in DocNoInfo.Split(',')) { if (!DocListSave.Contains(DocNO)) { DocListSave.Add(DocNO); InspectJosn += "{"; InspectJosn += "\"ORD_ORDINE\":\"" + DocNO + "\","; InspectJosn += "\"ORD_DES\":\"生产退料-生产退料单-领料申请单\","; InspectJosn += "\"ORD_TIPOOP\":\"V\","; InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\""; InspectJosn += "},"; } } InspectJosn = InspectJosn.TrimEnd(','); InspectJosn += "],"; InspectJosn += "\"IMP_ORDINI_RIGHE\":["; foreach (string DocNO in DocListSave) { string sql = @" select A.ApplyNegCode,B.Sequence,B.InvCode,B.Quantity,C.LocationCode AS Area from ICSMOApplyNeg A INNER JOIN ICSMOApplyNegDetail B ON B.ApplyNegCode=A.ApplyNegCode AND B.WorkPoint=A.WorkPoint INNER JOIN ICSInventoryDetail C ON C.WHCode=B.WHCode AND C.INVCode=B.InvCode AND C.WorkPoint=B.WorkPoint where A.ApplyNegCode='{0}' and A.WorkPoint='{1}'"; sql = string.Format(sql, DocNO, WorkPoint); DataTable dt = Repository().FindTableBySql(sql.ToString()); for (int i = 0; i < dt.Rows.Count; i++) { //RIG_ELERUOLI_GEST-区域-出入库都要 //RIG_ELEBAIE-机器出口-出库-出库才要 InspectJosn += "{"; InspectJosn += "\"RIG_ORDINE\":\"" + DocNO + "\","; InspectJosn += "\"RIG_ARTICOLO\": \"" + dt.Rows[i]["InvCode"].ToString() + "\","; InspectJosn += "\"RIG_SUB1\": \"\","; InspectJosn += "\"RIG_SUB2\": \"\","; InspectJosn += "\"RIG_ELEBAIE\": \"\","; InspectJosn += "\"RIG_ELERUOLI_GEST\": \"" + dt.Rows[i]["Area"].ToString() + "\","; InspectJosn += "\"RIG_QTAR\": " + dt.Rows[i]["Quantity"].ToString() + ","; InspectJosn += "\"RIG_HOSTINF\": " + dt.Rows[i]["Sequence"].ToString() + ""; InspectJosn += "},"; } stringBuilder.Append($@"'{DocNO}',"); } InspectJosn = InspectJosn.TrimEnd(','); InspectJosn += "]"; InspectJosn += "}"; } #endregion string result = ""; if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"])) { #region 货柜接口调用前日志 object logID = Guid.NewGuid(); string logsql = @"insert into ICSWMS_HGLog values ('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}')"; logsql = string.Format(logsql, logID, InspectJosn, "", WorkPoint, MUSER, MUSERNAME); SqlHelper.CmdExecuteNonQueryLi(logsql); #endregion result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr); #region 货柜接口调用后日志 logsql = @"update ICSWMS_HGLog set ReturnResult='{0}' where ID='{1}'"; logsql = string.Format(logsql, result, logID); SqlHelper.CmdExecuteNonQueryLi(logsql); #endregion if (!result.Contains("successo")) { ICSHGResult hgresult = JsonConvert.DeserializeObject(result.TrimStart('[').TrimEnd(']')); throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + ""); } string sb = stringBuilder.ToString().TrimEnd(','); string sqlString=string.Empty; if (Type == "7") { sqlString = $@"UPDATE ICSDeliveryNotice SET EATTRIBUTE3='1' WHERE DNCode IN ({sb})"; } if (Type == "12") { sqlString = $@" UPDATE ICSMOApplyNegDetail SET EATTRIBUTE='1' WHERE ApplyNegCode in ({sb});"; } if (!sqlString.IsEmpty()) { SqlHelper.CmdExecuteNonQueryLi(sqlString.ToString()); } } return ""; } catch (Exception ex) { return ex.Message; } } public object GetDecimalDigits() { try { string sql = string.Empty; sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'"; object Figure = SqlHelper.ExecuteScalar(sql); return Figure; } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } public object GetQiSetNum(string keyValue) { int Num = 0; string msg = ""; string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve"; string result = HttpPost(APIURL, keyValue); JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText); string MessAge = Obj["Message"].ToString(); string Success = Obj["Success"].ToString(); if (Success.ToUpper() == "FALSE") { msg = MessAge; } if (msg == "") { JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString()); foreach (var item in res) { JObject jo = (JObject)item; Num = Convert.ToInt32(jo["min_lotqty"].ToString()); } } var Header = new { msg = msg, Num = Num, }; return Header; } //接口api解析 public static string HttpPost(string url, string body) { try { Encoding encoding = Encoding.UTF8; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*"; request.ContentType = "application/json; charset=utf-8"; byte[] buffer = encoding.GetBytes(body); request.ContentLength = buffer.Length; request.GetRequestStream().Write(buffer, 0, buffer.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding)) { return reader.ReadToEnd(); } } catch (WebException ex) { throw new Exception(ex.Message); } } } }