You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4331 lines
261 KiB
4331 lines
261 KiB
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<ICSVendor>
|
|
{
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击生成条码
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
string dtPre = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生产退料生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "MDN" + ApplyNegCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除条码
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击委外退料生成条码
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 委外退料生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "OI" + OApplyNegCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<a.Quantity Or a.Quantity<=0) ";
|
|
}
|
|
}
|
|
}
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击成品生成条码(成品)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 成品生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "CP" + MOCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 销售退货单
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
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<a.Quantity Or a.Quantity<=0) ";
|
|
}
|
|
}
|
|
|
|
}
|
|
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);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击销售退货生成条码(销售退货)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 销售退货生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "SR" + SDNCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<a.Quantity Or a.Quantity<=0) ";
|
|
}
|
|
}
|
|
|
|
}
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击销售退货生成条码(其他入库)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 其他入库生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "QT" + InCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 其他入库批量生成条码
|
|
/// </summary>
|
|
/// <param name="ids">主键</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public int SubmitFormQiTaPL(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 ICSOtherIn a WHERE ID in({ids}) AND InCode 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();
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
for (int i = 0; i < table.Rows.Count; i++)
|
|
{
|
|
string dnCode = table.Rows[i]["InCode"].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 = "QT" + invCode + sequence;
|
|
string code = "QT" + invCode + dateString;
|
|
//条码
|
|
//string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 5);
|
|
string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 2);
|
|
//获取推荐库位
|
|
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($@"IF EXISTS (SELECT LotNo FROM ICSInventoryLotDetail WHERE TransCode='{dnCode}' AND WorkPoint='{workPoint}')
|
|
BEGIN
|
|
RAISERROR('单据:{dnCode}已批量生成条码,请刷新页面查看!',16,1);
|
|
RETURN
|
|
END");
|
|
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}','5','{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 DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<a.Quantity Or a.Quantity<=0) ";
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["DNID"].ToString()))
|
|
{
|
|
sql += " and a.DNID like '%" + queryParam["DNID"].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 GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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["WHCode"].ToString()))
|
|
{
|
|
sql += " and a.WHCode like '%" + queryParam["WHCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()))
|
|
{
|
|
if (queryParam["Container"].ToString() == "1")
|
|
{
|
|
sql += " and a.RCVQuantity=a.Quantity ";
|
|
}
|
|
else
|
|
{
|
|
sql += " and (a.RCVQuantity<a.Quantity Or a.Quantity<=0) ";
|
|
}
|
|
}
|
|
}
|
|
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["ProjectCode"].ToString()))
|
|
{
|
|
sql += " and f.ProjectCode like '%" + queryParam["ProjectCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Brand"].ToString()))
|
|
{
|
|
sql += " and f.Brand like '%" + queryParam["Brand"].ToString() + "%' ";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击审核委外到货单生成条码(审核委外到货单)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击开立成品入库生成条码(开立成品入库单)
|
|
/// </summary>
|
|
/// //--
|
|
public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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 ICSManufactureReceive 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.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());
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 点击审核到货单生成条码(审核到货单)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击归还生成条码(归还)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 归还单生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "GH" + ReturnCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审核到货单生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
var dateString = DateTime.Now.ToString("yyMMdd").Substring(1);
|
|
string Pre = "DN" + DNCode + dateString;
|
|
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, 2);
|
|
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<ICSHGResult>(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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审核到货单生成条码(批量生成)
|
|
/// </summary>
|
|
/// <param name="ids">主键</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
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();
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
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() + dateString;
|
|
//条码
|
|
string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 2);
|
|
//获取推荐库位
|
|
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($@"IF EXISTS (SELECT LotNo FROM ICSInventoryLotDetail WHERE TransCode='{dnCode}' AND WorkPoint='{workPoint}')
|
|
BEGIN
|
|
RAISERROR('单据:{dnCode}已批量生成条码,请刷新页面查看!',16,1);
|
|
RETURN
|
|
END");
|
|
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);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 检验合格单生成条码批量入库
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
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();
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
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 code = "DN" + table.Rows[i]["DNCode"].ToString() + dateString;
|
|
//条码
|
|
//string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 5);
|
|
string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 2);
|
|
#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);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取批量入库区域
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "MA" + ApplyNegCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// 领料退料单(批量)
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
public int SubmitTLPL(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 ICSMOApplyNegDetail a WHERE ID in({ids}) AND ApplyNegCode 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 dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
for (int i = 0; i < table.Rows.Count; i++)
|
|
{
|
|
string dnCode = table.Rows[i]["ApplyNegCode"].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 = "MA" + dnCode + sequence;
|
|
string code = "MA" + dnCode + dateString;
|
|
//条码
|
|
//string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 5);
|
|
string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 2);
|
|
//获取推荐库位
|
|
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}','12','{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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开立成品入库单
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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 dateString = DateTime.Now.ToString("yyMMdd").Substring(1);
|
|
string Pre = "KCP" + RCVCode + dateString;
|
|
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, 2);
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开立成品入库单(批量)
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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();
|
|
string dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
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 + dateString;
|
|
//条码
|
|
string LotNo = GetSerialCode(workPoint, "ICSInventoryLot", "LotNO", code, 2);
|
|
//获取推荐库位
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 审核委外到货单生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "ODN" + ODNCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 开立成品入库单
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "KCP" + RCVCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
|
|
|
|
//获取推荐库位
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<a.Quantity Or a.Quantity<=0) ";
|
|
}
|
|
}
|
|
}
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 拒收生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "JS" + DNCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// 委外拒收生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "OJS" + ODNCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击审核到货单生成条码(审核到货单)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击审核委外到货单生成条码(审核委外到货单)
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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
|
|
,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 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
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "MD" + ApplyNegCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击委外领料退料生成条码
|
|
/// </summary>
|
|
public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "OMA" + OApplyNegCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "OMD" + OApplyNegCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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<DbParameter> parameter = new List<DbParameter>();
|
|
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;
|
|
DateTime MTime = DateTime.Now;
|
|
var dateString = MTime.ToString("yyMMdd").Substring(1);
|
|
string Pre = "FG" + FGGDMOCode + dateString;
|
|
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);
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 2);
|
|
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),Quantity)
|
|
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<string> DocListSave = new List<string>();
|
|
#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<ICSHGResult>(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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool GetGeneratedNum(string Code, string Sequence, string Type, string thisCreateQty)
|
|
{
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
bool flag = true;
|
|
if (Type == "1")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
|
|
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 a.ApplyNegCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSMOApplyNegDetail a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.ApplyNegCode=a.ApplyNegCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
}
|
|
if (Type == "2")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
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 a.OApplyNegCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSOApplyNegDetail a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.OApplyNegCode=a.OApplyNegCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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' and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
}
|
|
if (Type == "3")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSMO a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.MODetailID,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSMO a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.MODetailID=a.MODetailID and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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
|
|
WHERE 1=1 and a.MOStatus<>'3' and a.MOCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
}
|
|
if (Type == "4")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSSDN a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.SDNCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSSDN a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.SDNCode=a.SDNCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.SDNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "5")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSOtherIn a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.InCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSOtherIn a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.InCode=a.InCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.InCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "6")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSReturn a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.ReturnCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSReturn a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.ReturnCode=a.ReturnCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.ReturnCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "7")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSDeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.DNCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSDeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.DNCode=a.DNCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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 a.DNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "8")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSODeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.ODNCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSODeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.ODNCode=a.ODNCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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
|
|
and a.ODNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "9")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSManufactureReceive a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.RCVCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSManufactureReceive a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.RCVCode=a.RCVCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.RCVCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "10")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
|
|
from ICSDeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.DNCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSDeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.DNCode=a.DNCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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
|
|
and a.DNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "11")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSODeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.ODNCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSODeliveryNotice a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.ODNCode=a.ODNCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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
|
|
and a.ODNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "12")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
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 a.ApplyNegCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSMOApplyNegDetail a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.ApplyNegCode=a.ApplyNegCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "13")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
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 a.ApplyNegCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSMOApplyNegDetail a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.ApplyNegCode=a.ApplyNegCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "14")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
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 a.OApplyNegCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSOApplyNegDetail a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.OApplyNegCode=a.OApplyNegCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "15")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
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 a.OApplyNegCode,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSOApplyNegDetail a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.OApplyNegCode=a.OApplyNegCode and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "16")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSMOPick a
|
|
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.MODetailID,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSMOPick a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.MODetailID=a.MODetailID and xx.Sequence=a.Sequence and xx.WorkPoint=a.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'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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'
|
|
and d.MOCode='" + Code + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
if (Type == "18")
|
|
{
|
|
sql = @" select distinct CAST(isnull(xx.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
|
|
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
|
|
from ICSMOPick a
|
|
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join(select a.MODetailID,a.Sequence,a.WorkPoint,
|
|
case when b.OverInType='1' then a.Quantity*(1+b.OverInValue) when b.OverInType='2' then a.Quantity+b.OverInValue when b.OverInType='3' then 999999 else a.Quantity end as Quantity
|
|
from ICSMOPick a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint) xx on xx.MODetailID=a.MODetailID and xx.Sequence=a.Sequence and xx.WorkPoint=a.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='18'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
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.MOCode='" + Code + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
|
|
|
|
}
|
|
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
decimal Quantity = Convert.ToDecimal(dt.Rows[0]["Quantity"].ToString());
|
|
decimal LOTQTY = Convert.ToDecimal(dt.Rows[0]["LOTQTY"].ToString());
|
|
decimal thisQty = Convert.ToDecimal(thisCreateQty);
|
|
if (LOTQTY + thisQty > Quantity)
|
|
{
|
|
flag = false;
|
|
}
|
|
|
|
return flag;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|