|
|
@ -7364,86 +7364,6 @@ ISNULL(c.MTIME,'') AS MTIME,'' AS VenCode,'' AS cVenName,d.InvUnit,'' AS POCode, |
|
|
|
";
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//派纳调拨,不用站点条件
|
|
|
|
if (DBHelper.IsPNU9() && TransType == TransTypeEnum.OneStepTransferDocIn.GetDescription()) |
|
|
|
{ |
|
|
|
if (ScanType == "LOTNO") |
|
|
|
{ |
|
|
|
sql = @"SELECT a.ID,
|
|
|
|
con.ContainerCode, |
|
|
|
con.ContainerName, |
|
|
|
a.LotNo, |
|
|
|
a.InvCode, |
|
|
|
inv.InvName, |
|
|
|
inv.InvStd, |
|
|
|
inv.InvUnit, |
|
|
|
inv.LotEnable, |
|
|
|
{0} |
|
|
|
inv.AmountUnit, |
|
|
|
ext.ID AS ExtensionID, |
|
|
|
ext.ProjectCode, |
|
|
|
ext.Version, |
|
|
|
--ext.BatchCode, |
|
|
|
ext.Brand, |
|
|
|
ext.cFree1, |
|
|
|
ext.cFree2, |
|
|
|
ext.cFree3, |
|
|
|
ext.cFree4, |
|
|
|
ext.cFree5, |
|
|
|
ext.cFree6, |
|
|
|
ext.cFree7, |
|
|
|
ext.cFree8, |
|
|
|
ext.cFree9, |
|
|
|
ext.cFree10, |
|
|
|
a.MUSER AS [User], |
|
|
|
a.MTIME AS [MTime], |
|
|
|
'" + ScanType + @"' AS ScanType |
|
|
|
FROM {1} |
|
|
|
LEFT JOIN ICSContainerLot conlot ON a.LotNo=conlot.LotNo AND a.WorkPoint=conlot.WorkPoint |
|
|
|
LEFT JOIN ICSContainer con ON conlot.ContainerID=con.ID AND conlot.WorkPoint=con.WorkPoint |
|
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint |
|
|
|
WHERE a.LotNo='{2}' ";
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
sql = @"SELECT a.ID,
|
|
|
|
con.ContainerCode, |
|
|
|
con.ContainerName, |
|
|
|
a.LotNo, |
|
|
|
a.InvCode, |
|
|
|
inv.InvName, |
|
|
|
inv.InvStd, |
|
|
|
inv.InvUnit, |
|
|
|
{0} |
|
|
|
inv.AmountUnit, |
|
|
|
ext.ID AS ExtensionID, |
|
|
|
ext.ProjectCode, |
|
|
|
ext.Version, |
|
|
|
--ext.BatchCode, |
|
|
|
ext.Brand, |
|
|
|
ext.cFree1, |
|
|
|
ext.cFree2, |
|
|
|
ext.cFree3, |
|
|
|
ext.cFree4, |
|
|
|
ext.cFree5, |
|
|
|
ext.cFree6, |
|
|
|
ext.cFree7, |
|
|
|
ext.cFree8, |
|
|
|
ext.cFree9, |
|
|
|
ext.cFree10, |
|
|
|
a.MUSER AS [User], |
|
|
|
a.MTIME AS [MTime], |
|
|
|
'" + ScanType + @"' AS ScanType |
|
|
|
FROM {1} |
|
|
|
LEFT JOIN ICSContainerLot conlot ON a.LotNo=conlot.LotNo AND a.WorkPoint=conlot.WorkPoint |
|
|
|
LEFT JOIN ICSBomALL bom ON bom.ID=conlot.ContainerID |
|
|
|
LEFT JOIN ICSContainer con ON conlot.ContainerID=con.ID AND conlot.WorkPoint=con.WorkPoint |
|
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint |
|
|
|
WHERE bom.TContainerCode='{2}' ";
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (ScanType == "LOTNO") |
|
|
|
{ |
|
|
@ -7742,7 +7662,7 @@ ISNULL(c.MTIME,'') AS MTIME,'' AS VenCode,'' AS cVenName,d.InvUnit,'' AS POCode, |
|
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint |
|
|
|
WHERE bom.TContainerCode='{2}' AND a.WorkPoint='{3}' AND a.Quantity>0";
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -9290,12 +9210,9 @@ BEGIN |
|
|
|
|| TransType == TransTypeEnum.ManufactureReceive.GetDescription() || TransType == TransTypeEnum.OOStockINByProduct.GetDescription() |
|
|
|
|| TransType == TransTypeEnum.MOStockINByProduct.GetDescription() || TransType == TransTypeEnum.OtherInDoc.GetDescription() || TransType == TransTypeEnum.OutsourcingReceiveRevDoc.GetDescription() |
|
|
|
|| TransType == TransTypeEnum.PurchaseReceiveRevDoc.GetDescription() || TransType == TransTypeEnum.ManufactureMESReceive.GetDescription()) && needIns) |
|
|
|
{ |
|
|
|
if (DBHelper.IsPNU9() && TransType == TransTypeEnum.PurchaseReceiveRevDoc.GetDescription()) |
|
|
|
{ |
|
|
|
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
|
|
|
|
a.Quantity*(a.Amount/a.Quantity) AS Amount, |
|
|
|
isnull(pev.EATTRIBUTE3,'') AS VenName, |
|
|
|
{0},{2}, |
|
|
|
lotdd.TransCode,lotdd.TransSequence, |
|
|
|
{3} |
|
|
@ -9305,41 +9222,7 @@ BEGIN |
|
|
|
tableName = @"ICSInventoryLot a
|
|
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint |
|
|
|
LEFT JOIN ICSInventoryLotDetail lotdd ON lotdd.LotNo=a.LotNo AND a.WorkPoint=lotdd.WorkPoint |
|
|
|
LEFT JOIN ICSPurchaseReceive pev ON lotdd.TransCode=pev.RCVCode AND lotdd.TransSequence=pev.Sequence AND lotdd.WorkPoint=pev.WorkPoint |
|
|
|
LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint and ins.enable = 1";
|
|
|
|
} |
|
|
|
else if (DBHelper.IsPNU9() && TransType == TransTypeEnum.OutsourcingReceiveRevDoc.GetDescription()) |
|
|
|
{ |
|
|
|
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
|
|
|
|
a.Quantity*(a.Amount/a.Quantity) AS Amount, |
|
|
|
isnull(pev.EATTRIBUTE3,'') AS VenName, |
|
|
|
{0},{2}, |
|
|
|
lotdd.TransCode,lotdd.TransSequence, |
|
|
|
{3} |
|
|
|
{1} |
|
|
|
ext.BatchCode AS BatchCode,";
|
|
|
|
|
|
|
|
tableName = @"ICSInventoryLot a
|
|
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint |
|
|
|
LEFT JOIN ICSInventoryLotDetail lotdd ON lotdd.LotNo=a.LotNo AND a.WorkPoint=lotdd.WorkPoint |
|
|
|
LEFT JOIN ICSOutsourcingReceive pev ON lotdd.TransCode=pev.RCVCode AND lotdd.TransSequence=pev.Sequence AND lotdd.WorkPoint=pev.WorkPoint |
|
|
|
LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint and ins.enable = 1";
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
|
|
|
|
a.Quantity*(a.Amount/a.Quantity) AS Amount, |
|
|
|
{0},{2}, |
|
|
|
lotdd.TransCode,lotdd.TransSequence, |
|
|
|
{3} |
|
|
|
{1} |
|
|
|
ext.BatchCode AS BatchCode,";
|
|
|
|
|
|
|
|
tableName = @"ICSInventoryLot a
|
|
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint |
|
|
|
LEFT JOIN ICSInventoryLotDetail lotdd ON lotdd.LotNo=a.LotNo AND a.WorkPoint=lotdd.WorkPoint |
|
|
|
LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint and ins.enable = 1";
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (TransType == TransTypeEnum.SalesShipmentDocNegative.GetDescription()) |
|
|
@ -33018,7 +32901,304 @@ END as NEWLotNo |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static DataTable YSDeliveryNoticeCreate(List<ICSDeliveryNotice> JsonData) |
|
|
|
{ |
|
|
|
var language = LanguageHelper.GetName("WMSAPIInfo"); |
|
|
|
if (JsonData.Count <= 0) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo007"));//"传送数据为空!"
|
|
|
|
} |
|
|
|
using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString)) |
|
|
|
{ |
|
|
|
conn.Open(); |
|
|
|
SqlTransaction sqlTran = conn.BeginTransaction(); |
|
|
|
SqlCommand cmd = new SqlCommand(); |
|
|
|
cmd.Transaction = sqlTran; |
|
|
|
cmd.Connection = conn; |
|
|
|
cmd.CommandTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TimeOut"]); |
|
|
|
try |
|
|
|
{ |
|
|
|
string asncodes = string.Empty; |
|
|
|
string DNCodes = string.Empty; |
|
|
|
string DNLotNo = string.Empty; |
|
|
|
string sql = string.Empty; |
|
|
|
string picname = string.Empty; |
|
|
|
string Colspan = ""; |
|
|
|
string IDD = ""; |
|
|
|
string whcode = ""; |
|
|
|
foreach (var item in JsonData) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(item.ASNCode)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo009"));//"送货单号不能为空!"
|
|
|
|
} |
|
|
|
|
|
|
|
sql = @"SELECT a.DNCode FROM ICSDeliveryNotice a WHERE a.ASNCode='{0}' AND DNType = '1' AND a.WorkPoint='{1}'"; |
|
|
|
sql = string.Format(sql, item.ASNCode, item.WorkPoint); |
|
|
|
DataTable dt = DBHelper.SQlReturnData(sql, cmd); |
|
|
|
if (dt.Rows.Count > 0) |
|
|
|
{ |
|
|
|
DNCodes = dt.Rows[0]["DNCode"].ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取单号
|
|
|
|
sql = @"IF EXISTS(SELECT a.ID FROM ICSDeliveryNotice a WHERE a.ASNCode='{0}' AND DNType = '1' AND a.WorkPoint='{1}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo057") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
DECLARE @Status VARCHAR(10) |
|
|
|
SELECT @Status=Status FROM ICSASN WHERE ASNCode='{0}' and WorkPoint='{1}' |
|
|
|
|
|
|
|
IF (@Status IS NULL) |
|
|
|
BEGIN |
|
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo058") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
ELSE IF (@Status!='2') |
|
|
|
BEGIN |
|
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo059") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
|
|
|
|
DECLARE @MaxNO INT,@date varchar(20)='DN'+SUBSTRING(CONVERT(varchar(8), GETDATE(), 112), 1, 8) |
|
|
|
SELECT @MaxNO=SUBSTRING(MAX(DNCode),LEN(@date)+1,LEN(MAX(DNCode))-LEN(@date))+1 FROM ICSDeliveryNotice |
|
|
|
WHERE SUBSTRING(DNCode, 1, LEN(@date))=@date |
|
|
|
IF @MaxNO IS NULL |
|
|
|
BEGIN |
|
|
|
SELECT @date+'00001' AS Code |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
SELECT @date+REPLICATE('0',5-LEN(@MaxNO))+CAST(@MaxNO AS nvarchar(10)) AS Code |
|
|
|
END ";
|
|
|
|
sql = string.Format(sql, item.ASNCode, item.WorkPoint, DNCodes); |
|
|
|
string Code = DBHelper.ExecuteScalar(sql, cmd).ToString(); |
|
|
|
//修改送货单到货数量
|
|
|
|
foreach (var itemInfo in item.detail) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(itemInfo.TransSequence)) |
|
|
|
{ |
|
|
|
picname = ""; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
picname = itemInfo.TransSequence; |
|
|
|
} |
|
|
|
sql = @"
|
|
|
|
|
|
|
|
UPDATE ICSASNDetail SET DNQuantity=ISNULL(DNQuantity, 0)+'{2}' |
|
|
|
WHERE LotNo='{0}' AND WorkPoint='{1}' |
|
|
|
IF EXISTS(SELECT id FROM ICSASNDetail WHERE LotNo='{0}' AND WorkPoint='{1}' AND Quantity<DNQuantity) |
|
|
|
BEGIN |
|
|
|
RAISERROR('送货单子表信息更新失败,已到货数量不能大于计划到货数量!',16,1); |
|
|
|
RETURN |
|
|
|
END ";
|
|
|
|
|
|
|
|
sql = string.Format(sql, itemInfo.LotNo, item.WorkPoint, itemInfo.Quantity); |
|
|
|
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo010")); //"送货单子表信息更新失败!");
|
|
|
|
} |
|
|
|
|
|
|
|
sql = @"UPDATE ICSInventoryLot SET Quantity='{2}'
|
|
|
|
WHERE LotNo='{0}' AND WorkPoint='{1}'";
|
|
|
|
if (itemInfo.IsUrgency == "1") |
|
|
|
sql = @"UPDATE ICSInventoryLot SET Quantity='{2}' ,eattribute6 = '1' WHERE LotNo='{0}' AND WorkPoint='{1}'"; |
|
|
|
sql = string.Format(sql, itemInfo.LotNo, item.WorkPoint, itemInfo.Quantity); |
|
|
|
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo462")); //"条码表信息更新失败!");
|
|
|
|
} |
|
|
|
|
|
|
|
if (DNLotNo.Equals("")) |
|
|
|
{ |
|
|
|
DNLotNo = "'" + itemInfo.LotNo + "'"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DNLotNo = ",'" + itemInfo.LotNo + ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//到货指定仓库(批次汇总)
|
|
|
|
string Dsql = @"SELECT a.F_itemCode
|
|
|
|
FROM Sys_SRM_ItemsDetail a |
|
|
|
INNER JOIN Sys_SRM_Items b ON a.F_ItemId=b.F_Id |
|
|
|
WHERE b.F_EnCode='DaoWHCode' AND a.F_EnabledMark='1'";
|
|
|
|
Dsql = string.Format(Dsql); |
|
|
|
DataTable dtdao = DBHelper.SQlReturnData(Dsql, cmd); |
|
|
|
if (dtdao.Rows.Count > 0 && dtdao != null) |
|
|
|
{ |
|
|
|
whcode = dtdao.Rows[0]["F_itemCode"].ToString(); |
|
|
|
|
|
|
|
//创建到货单信息
|
|
|
|
sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{1}' AND F_Location='{2}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{1}") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
|
|
|
|
Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10) |
|
|
|
SELECT DISTINCT newid(),ISNULL(ext.ProjectCode, '')+'~'+CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END+'~'+ISNULL(ext.Version, '')+'~'+ISNULL(ext.Brand, '')+'~'+ |
|
|
|
ISNULL(ext.cFree1, '')+'~'+ISNULL(ext.cFree2, '')+'~'+ISNULL(ext.cFree3, '')+'~'+ISNULL(ext.cFree4, '')+'~'+ISNULL(ext.cFree5, '')+'~'+ISNULL(ext.cFree6, '')+'~'+ISNULL(ext.cFree7, '')+'~'+ISNULL(ext.cFree8, '')+'~'+ISNULL(ext.cFree9, '')+'~'+ISNULL(ext.cFree10, ''),ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand, |
|
|
|
ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 |
|
|
|
FROM ICSASNDetail a |
|
|
|
INNER JOIN ICSInventoryLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSExtension ext ON b.ExtensionID=ext.ID AND b.WorkPoint=ext.WorkPoint |
|
|
|
LEFT JOIN ICSInventory inv ON b.InvCode=inv.InvCode AND b.WorkPoint=inv.WorkPoint |
|
|
|
LEFT JOIN ICSInventoryBatchEnable invBat ON b.InvCode=invBat.InvCode AND '{5}'=invBat.WHCode AND b.WorkPoint=invBat.WorkPoint |
|
|
|
INNER JOIN ICSExtension extt ON ISNULL(ext.ProjectCode, '')+'~'+CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END+'~'+ISNULL(ext.Version, '')+'~'+ISNULL(ext.Brand, '')+'~'+ |
|
|
|
ISNULL(ext.cFree1, '')+'~'+ISNULL(ext.cFree2, '')+'~'+ISNULL(ext.cFree3, '')+'~'+ISNULL(ext.cFree4, '')+'~'+ISNULL(ext.cFree5, '')+'~'+ISNULL(ext.cFree6, '')+'~'+ISNULL(ext.cFree7, '')+'~'+ISNULL(ext.cFree8, '')+'~'+ISNULL(ext.cFree9, '')+'~'+ISNULL(ext.cFree10, '')=extt.Colspan |
|
|
|
|
|
|
|
WHERE a.ASNCode='{3}' AND a.WorkPoint='{2}' and a.DNQuantity>0 AND ext.id is NULL |
|
|
|
|
|
|
|
INSERT INTO ICSDeliveryNotice(ID,DNCode,Sequence,VenCode,DepCode, |
|
|
|
DNType,InvCode,Quantity,Amount,RCVQuantity, |
|
|
|
UnitPrice,Currency,Status,CreatePerson,CreateDateTime, |
|
|
|
POID,PODetailID,DNID,DNDetailID,ExtensionID, |
|
|
|
MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1,ASNCode,EATTRIBUTE8) |
|
|
|
SELECT NEWID(),'{0}',row_number() OVER (ORDER BY b.InvCode),d.VenCode,d.DepCode, |
|
|
|
'1',b.InvCode,SUM(a.DNQuantity),'0','0', |
|
|
|
d.UnitPrice,d.Currency,'2',e.F_Account,GETDATE(), |
|
|
|
d.POID,d.PODetailID,'{0}',newid(),extt.ID, |
|
|
|
e.F_Account,e.F_RealName,GETDATE(),a.WorkPoint,'',a.ASNCode,'{4}' |
|
|
|
FROM ICSASNDetail a |
|
|
|
INNER JOIN ICSInventoryLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSExtension ext ON b.ExtensionID=ext.ID AND b.WorkPoint=ext.WorkPoint |
|
|
|
LEFT JOIN ICSInventory inv ON b.InvCode=inv.InvCode AND b.WorkPoint=inv.WorkPoint |
|
|
|
LEFT JOIN ICSInventoryBatchEnable invBat ON b.InvCode=invBat.InvCode AND '{5}'=invBat.WHCode AND b.WorkPoint=invBat.WorkPoint |
|
|
|
INNER JOIN ICSExtension extt ON ISNULL(ext.ProjectCode, '')+'~'+CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END+'~'+ISNULL(ext.Version, '')+'~'+ISNULL(ext.Brand, '')+'~'+ |
|
|
|
ISNULL(ext.cFree1, '')+'~'+ISNULL(ext.cFree2, '')+'~'+ISNULL(ext.cFree3, '')+'~'+ISNULL(ext.cFree4, '')+'~'+ISNULL(ext.cFree5, '')+'~'+ISNULL(ext.cFree6, '')+'~'+ISNULL(ext.cFree7, '')+'~'+ISNULL(ext.cFree8, '')+'~'+ISNULL(ext.cFree9, '')+'~'+ISNULL(ext.cFree10, '')=extt.Colspan |
|
|
|
|
|
|
|
INNER JOIN ICSPurchaseOrder d ON c.TransCode=d.POCode AND c.TransSequence=d.Sequence AND c.WorkPoint=d.WorkPoint |
|
|
|
INNER JOIN Sys_SRM_User e ON e.F_Account='{1}' AND e.F_Location='{2}' |
|
|
|
WHERE a.ASNCode='{3}' AND a.WorkPoint='{2}' and a.DNQuantity>0 |
|
|
|
GROUP BY d.POID,d.PODetailID,d.VenCode,d.UnitPrice,d.Currency,d.DepCode,b.InvCode,a.ASNCode,e.F_Account,e.F_RealName,a.WorkPoint,extt.ID";
|
|
|
|
sql = string.Format(sql, Code, item.User, item.WorkPoint, item.ASNCode, picname, whcode); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//创建到货单信息
|
|
|
|
sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{1}' AND F_Location='{2}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{1}") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
|
|
|
|
INSERT INTO ICSDeliveryNotice(ID,DNCode,Sequence,VenCode,DepCode, |
|
|
|
DNType,InvCode,Quantity,Amount,RCVQuantity, |
|
|
|
UnitPrice,Currency,Status,CreatePerson,CreateDateTime, |
|
|
|
POID,PODetailID,DNID,DNDetailID,ExtensionID, |
|
|
|
MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1,ASNCode,EATTRIBUTE8) |
|
|
|
SELECT NEWID(),'{0}',row_number() OVER (ORDER BY b.InvCode),d.VenCode,d.DepCode, |
|
|
|
'1',b.InvCode,SUM(a.DNQuantity),'0','0', |
|
|
|
d.UnitPrice,d.Currency,'2',e.F_Account,GETDATE(), |
|
|
|
d.POID,d.PODetailID,'{0}',newid(),b.ExtensionID, |
|
|
|
e.F_Account,e.F_RealName,GETDATE(),a.WorkPoint,'',a.ASNCode,'{4}' |
|
|
|
FROM ICSASNDetail a |
|
|
|
INNER JOIN ICSInventoryLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSPurchaseOrder d ON c.TransCode=d.POCode AND c.TransSequence=d.Sequence AND c.WorkPoint=d.WorkPoint |
|
|
|
INNER JOIN Sys_SRM_User e ON e.F_Account='{1}' AND e.F_Location='{2}' |
|
|
|
WHERE a.ASNCode='{3}' AND a.WorkPoint='{2}' and a.DNQuantity>0 |
|
|
|
GROUP BY d.POID,d.PODetailID,d.VenCode,d.UnitPrice,d.Currency,d.DepCode,b.ExtensionID,b.InvCode,a.ASNCode,e.F_Account,e.F_RealName,a.WorkPoint";
|
|
|
|
sql = string.Format(sql, Code, item.User, item.WorkPoint, item.ASNCode, picname); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo011")); //"到货单信息创建失败!");
|
|
|
|
} |
|
|
|
|
|
|
|
string sqlCheckSign = @"select * from ICSConfiguration where code = 'UploadERP001' and enable = '1'"; |
|
|
|
DataTable flag = DBHelper.SQlReturnData(sqlCheckSign, cmd); |
|
|
|
if (flag != null && flag.Rows.Count > 0) |
|
|
|
{ |
|
|
|
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"])) |
|
|
|
{ |
|
|
|
ICSPurchaseService.YSDeliveryNoticeERP(Code, item.WorkPoint, cmd, language); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
asncodes += "'" + item.ASNCode + item.WorkPoint + "',"; |
|
|
|
} |
|
|
|
if (string.IsNullOrWhiteSpace(asncodes)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo009"));//"请传入送货单信息!");
|
|
|
|
} |
|
|
|
#region 查询返回数据
|
|
|
|
sql = @"SELECT
|
|
|
|
n.POCode, |
|
|
|
n.Sequence AS POSequence, |
|
|
|
a.ASNCode, |
|
|
|
a.DNCode, |
|
|
|
a.Sequence, |
|
|
|
a.VenCode, |
|
|
|
a.DepCode, |
|
|
|
a.InvCode, |
|
|
|
inv.InvName, |
|
|
|
inv.InvStd, |
|
|
|
a.Quantity, |
|
|
|
inv.InvUnit, |
|
|
|
a.Amount, |
|
|
|
inv.AmountUnit, |
|
|
|
a.RCVQuantity, |
|
|
|
a.UnitPrice, |
|
|
|
a.Currency, |
|
|
|
a.POID, |
|
|
|
a.PODetailID, |
|
|
|
a.DNID, |
|
|
|
a.DNDetailID, |
|
|
|
ext.ProjectCode, |
|
|
|
ext.BatchCode, |
|
|
|
ext.Version, |
|
|
|
ext.Brand, |
|
|
|
ext.cFree1, |
|
|
|
ext.cFree2, |
|
|
|
ext.cFree3, |
|
|
|
ext.cFree4, |
|
|
|
ext.cFree5, |
|
|
|
ext.cFree6, |
|
|
|
ext.cFree7, |
|
|
|
ext.cFree8, |
|
|
|
ext.cFree9, |
|
|
|
ext.cFree10, |
|
|
|
a.MUSER AS [User], |
|
|
|
a.MTIME AS [MTime] |
|
|
|
FROM ICSDeliveryNotice a |
|
|
|
INNER JOIN ICSPurchaseOrder n ON a.POID =n.POID AND a.PODetailID=n.PODetailID AND a.WorkPoint=n.WorkPoint |
|
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint |
|
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint |
|
|
|
WHERE a.ASNCode+a.WorkPoint IN ({0})";
|
|
|
|
sql = string.Format(sql, asncodes.Substring(0, asncodes.Length - 1)); |
|
|
|
DataTable data = DBHelper.SQlReturnData(sql, cmd); |
|
|
|
#endregion
|
|
|
|
cmd.Transaction.Commit(); |
|
|
|
return data; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
if (cmd.Transaction != null) |
|
|
|
cmd.Transaction.Rollback(); |
|
|
|
log.Error(ex.Message); |
|
|
|
throw new Exception(ex.Message); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
if (conn.State == ConnectionState.Open) |
|
|
|
{ |
|
|
|
conn.Close(); |
|
|
|
} |
|
|
|
conn.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |