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.
1146 lines
68 KiB
1146 lines
68 KiB
using ICSSoft.Common;
|
|
using ICSSoft.Entity;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ICSSoft.DataProject
|
|
{
|
|
/// <summary>
|
|
/// 使用中
|
|
/// 采购模块
|
|
/// </summary>
|
|
public class ICSPurchaseService
|
|
{
|
|
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
#region 采购到货
|
|
/// <summary>
|
|
/// 采购到货接口
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void DeliveryNoticeERP(string DNCode, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
#region ERP
|
|
string sql = @"SELECT a.VenCode+a.DepCode+y.POCode+a.MUSER AS Costre,a.VenCode,a.DepCode,y.POCode,a.MUSER,a.MTIME,
|
|
a.Sequence,a.InvCode,a.Quantity,a.Amount,ISNULL(a.UnitPrice,0) AS UnitPrice,a.Currency,a.PODetailID
|
|
,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN 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
|
|
INTO #TempERP
|
|
FROM ICSDeliveryNotice a
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
|
|
LEFT JOIN ICSInventory invBat ON a.InvCode=invBat.InvCode AND a.WorkPoint=invBat.WorkPoint
|
|
INNER JOIN ICSPurchaseOrder y ON a.PODetailID=y.PODetailID AND a.WorkPoint=y.WorkPoint
|
|
WHERE a.DNCode='{0}' AND a.WorkPoint='{1}'
|
|
|
|
SELECT DISTINCT Costre,WorkPoint,VenCode,DepCode,POCode,MUSER AS [User],SYSDATETIME() AS MTime FROM #TempERP
|
|
SELECT Costre,Sequence,InvCode,Quantity,Amount,UnitPrice,Currency,PODetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
|
|
FROM #TempERP
|
|
|
|
DROP TABLE #TempERP";
|
|
sql = string.Format(sql, DNCode, WorkPoint);
|
|
DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
|
|
|
|
string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
|
|
string resultStr = HTTPHelper.HttpPost("采购到货", ERPUrl.CreatePOArrivURL, Inputstr);
|
|
Result result = new Result();
|
|
result = JsonConvert.DeserializeObject<Result>(resultStr);
|
|
if (result.Success)
|
|
{
|
|
try
|
|
{
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
|
|
foreach (var detail in resdetail)
|
|
{
|
|
JObject det = (JObject)detail;
|
|
|
|
string ERPupdate = @"update ICSDeliveryNotice set DNCode='{0}',Sequence='{1}',DNID='{2}',DNDetailID='{3}'
|
|
where PODetailID='{4}' AND DNType='1' AND DNCode='{5}' ";
|
|
ERPupdate = string.Format(ERPupdate, jo["DNCode"], det["Sequence"], jo["ID"], det["DetailID"], det["PODetailID"], DNCode);
|
|
|
|
if (!DBHelper.ExecuteNonQuery(ERPupdate, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Debug(ex.ToString());
|
|
log.Debug(resultStr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 采购入库
|
|
/// <summary>
|
|
/// 采购入库
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseReceiveDoc(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"DECLARE @Status VARCHAR(10)
|
|
SELECT @Status=c.Status FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
|
|
|
|
IF (@Status IS NULL)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
|
|
RETURN
|
|
END
|
|
ELSE IF (@Status='3')
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
|
|
RETURN
|
|
END
|
|
UPDATE c SET InQuantity=ISNULL(InQuantity,0)+'{2}'
|
|
FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
|
|
IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Quantity<c.InQuantity)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
|
|
END";
|
|
sql = string.Format(sql, LotNo, WorkPoint, Quantity);
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo104"));//"采购入库单更新失败!");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 采购入库接口
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseReceiveDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
|
|
{
|
|
try
|
|
{
|
|
#region ERP
|
|
string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.POCode+a.MUSER+CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.POCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END AS DNCode,CASE WHEN(LEN(f.DNID)>=20) THEN '1' ELSE '0' END AS HasDN,a.MUSER,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.Sequence END AS DNSequence,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.POCode,c.PODetailID,a.InvCode) AS Sequence,
|
|
a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,c.PODetailID,con.Enable AS UpdateTodoQuantity,conn.Enable
|
|
,a.WorkPoint,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
|
|
INTO #TempERP
|
|
FROM ICSWareHouseLotInfoLog a
|
|
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
|
|
INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
|
|
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSASNDetail g ON a.LotNo=g.LotNo AND a.WorkPoint=g.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice f ON g.ASNCode=f.ASNCode AND g.WorkPoint=f.WorkPoint
|
|
INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND f.PODetailID=c.PODetailID AND b.WorkPoint=c.WorkPoint
|
|
INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
|
|
INNER JOIN ICSConfiguration conn ON con.WorkPoint=conn.WorkPoint AND conn.Code='Escrow001'
|
|
WHERE a.Identification='{0}' AND ERPUpload='0' AND BusinessCode='{1}'
|
|
GROUP BY c.VenCode,a.ToWarehouseCode,c.POCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END,f.DNID,a.MUSER,a.InvCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.Sequence END,c.PODetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conn.Enable
|
|
,a.WorkPoint,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, '')
|
|
|
|
SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,POCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,Enable,UpdateTodoQuantity FROM #TempERP
|
|
SELECT Costre,Sequence,DNSequence,InvCode,Quantity,Amount,PODetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
|
|
FROM #TempERP
|
|
SELECT HasDN FROM #TempERP
|
|
|
|
DROP TABLE #TempERP";
|
|
sql = string.Format(sql, Identification, BusinessCode);
|
|
DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
|
|
|
|
|
|
string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
|
|
|
|
var IsDNCode = ds.Tables[2];
|
|
if (IsDNCode == null || IsDNCode.Rows.Count != 1)
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo463"));//ERP到货单只能选择启用或不启用中的一种!
|
|
}
|
|
string dncode = Convert.ToString(IsDNCode.Rows[0]["HasDN"]);
|
|
if (dncode.Equals(""))
|
|
{
|
|
string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.DeliveryNoticeURL, Inputstr);
|
|
Result result = new Result();
|
|
result = JsonConvert.DeserializeObject<Result>(resultStr);
|
|
if (result.Success)
|
|
{
|
|
try
|
|
{
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
|
|
foreach (var detail in resdetail)
|
|
{
|
|
JObject det = (JObject)detail;
|
|
string allcol = jo["cWhCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
|
|
+ det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
|
|
ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(),
|
|
det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Debug(ex.ToString());
|
|
log.Debug(resultStr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseOrderURL, Inputstr);
|
|
Result result = new Result();
|
|
result = JsonConvert.DeserializeObject<Result>(resultStr);
|
|
if (result.Success)
|
|
{
|
|
try
|
|
{
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
|
|
foreach (var detail in resdetail)
|
|
{
|
|
JObject det = (JObject)detail;
|
|
string allcol = jo["cWhCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
|
|
+ det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
|
|
ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["PODetailID"].ToString(), Identification, jo["ID"].ToString(),
|
|
det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Debug(ex.ToString());
|
|
log.Debug(resultStr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 审核的到货单(货柜)
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void DeliveryNoticeInForHG(string DocNO, string TransLine, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language,string quantity)
|
|
{
|
|
try
|
|
{
|
|
decimal iquantity = Convert.ToDecimal(quantity);
|
|
string sql = @" IF EXISTS (SELECT ID FROM ICSDeliveryNotice WHERE RCVQuantity=Quantity AND DNCode='{0}' AND Sequence='{1}' and WorkPoint='{2}' )
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo471") + @"',16,1);
|
|
RETURN
|
|
END;
|
|
UPDATE ICSDeliveryNotice set RCVQuantity=RCVQuantity+{3}
|
|
Where DNCode='{0}' AND Sequence='{1}' and WorkPoint='{2}'";
|
|
sql = string.Format(sql, DocNO, TransLine, WorkPoint, iquantity);
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#region 审核的到货单
|
|
/// <summary>
|
|
/// 审核的到货单
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void DeliveryNoticeIn(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"DECLARE @Status VARCHAR(10)
|
|
SELECT @Status=c.Status FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
|
|
|
|
IF (@Status IS NULL)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
|
|
RETURN
|
|
END
|
|
ELSE IF (@Status='3')
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
|
|
RETURN
|
|
END
|
|
UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
|
|
FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
|
|
IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1' AND c.Quantity<c.RCVQuantity)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
|
|
END";
|
|
sql = string.Format(sql, LotNo, WorkPoint, Quantity);
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审核的到货单接口(平库,传给SAP单据行总数)
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void DeliveryNoticeInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
|
|
{
|
|
try
|
|
{
|
|
#region SAP(检验合格单为两层结构 一行对应一个序列号)
|
|
string IsSuccess = "";
|
|
string ErrorMessage = "";
|
|
string sql = @" select A.DNCode,A.WorkPoint,SUM(B.Quantity) AS Quantity from ICSDeliveryNotice A
|
|
LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.DNCode AND B.WorkPoint=A.WorkPoint
|
|
where B.Identification='{0}' AND BusinessCode='2'
|
|
GROUP BY A.DNCode,A.WorkPoint";
|
|
sql = string.Format(sql, Identification);
|
|
DataTable dt = DBHelper.SQlReturnData(sql, cmd);
|
|
if (dt.Rows.Count > 1)
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据)
|
|
}
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
string chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSDeliveryNotice
|
|
where DNCode='{0}' and WorkPoint='{1}'
|
|
GROUP BY DNCode,WorkPoint";
|
|
chksql = string.Format(chksql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
|
|
DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
|
|
if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"]))
|
|
{
|
|
return;
|
|
}
|
|
sql = @"select A.DNCode,
|
|
CASE WHEN SUM(Convert(decimal(18,6),A.SAPSequence)) IS NULL THEN SUM(A.RCVQuantity)
|
|
ELSE SUM(Convert(decimal(18,6),A.SAPSequence)) END AS RCVQuantity,B.BatchCode from ICSDeliveryNotice A
|
|
LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
|
|
WHERE DNCode='{0}' AND A.WorkPoint='{1}'
|
|
GROUP BY A.DNCode,B.BatchCode";
|
|
sql = string.Format(sql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
|
|
DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
|
|
if (Sapdt.Rows.Count == 0)
|
|
{
|
|
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo205"), dt.Rows[i]["DNCode"].ToString()));//单据查询失败
|
|
}
|
|
SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU Client = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU();
|
|
SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1 Info = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1();
|
|
Info.NEWID = Identification;
|
|
Info.PRUEFLOS = Sapdt.Rows[0]["DNCode"].ToString();
|
|
Info.L_LME = System.Decimal.Round(Convert.ToDecimal(Sapdt.Rows[0]["RCVQuantity"].ToString()), 3);
|
|
Info.SERNP = Sapdt.Rows[0]["BatchCode"].ToString();
|
|
Info.Z_GERNR = new SAPCallBackJYHGDCS.ZWEBS_GERNR[0];
|
|
|
|
SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse result = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse();
|
|
result = Client.CallZWMS_SK_WS_RUKU(Info);
|
|
if (result.Z_NULL == "N")
|
|
{
|
|
IsSuccess = "N";
|
|
ErrorMessage += result.L_MESSAGE;
|
|
}
|
|
}
|
|
if (IsSuccess == "N")
|
|
{
|
|
throw new Exception(ErrorMessage);
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 审核的到货单接口(货柜,传给SAP本次入库数量)
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void DeliveryNoticeInERPHG(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
|
|
{
|
|
try
|
|
{
|
|
#region SAP(检验合格单为两层结构 一行对应一个序列号)
|
|
string IsSuccess = "";
|
|
string ErrorMessage = "";
|
|
string sql = @" select A.DNCode,A.WorkPoint,SUM(B.Quantity) AS Quantity from ICSDeliveryNotice A
|
|
LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.DNCode AND B.WorkPoint=A.WorkPoint
|
|
where B.Identification='{0}' AND BusinessCode='2'
|
|
GROUP BY A.DNCode,A.WorkPoint";
|
|
sql = string.Format(sql, Identification);
|
|
DataTable dt = DBHelper.SQlReturnData(sql, cmd);
|
|
if (dt.Rows.Count > 1)
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据)
|
|
}
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
string chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSDeliveryNotice
|
|
where DNCode='{0}' and WorkPoint='{1}'
|
|
GROUP BY DNCode,WorkPoint";
|
|
chksql = string.Format(chksql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
|
|
DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
|
|
if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"]))
|
|
{
|
|
return;
|
|
}
|
|
sql = @"select A.DNCode,SUM(A.RCVQuantity) AS RCVQuantity,B.BatchCode from ICSDeliveryNotice A
|
|
LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
|
|
WHERE DNCode='{0}' AND A.WorkPoint='{1}'
|
|
GROUP BY A.DNCode,B.BatchCode";
|
|
sql = string.Format(sql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
|
|
DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
|
|
if (Sapdt.Rows.Count == 0)
|
|
{
|
|
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo205"), dt.Rows[i]["DNCode"].ToString()));//单据查询失败
|
|
}
|
|
SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU Client = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU();
|
|
SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1 Info = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1();
|
|
Info.NEWID = Identification;
|
|
Info.PRUEFLOS = Sapdt.Rows[0]["DNCode"].ToString();
|
|
Info.L_LME = System.Decimal.Round(Convert.ToDecimal(dt.Rows[0]["Quantity"].ToString()), 3);
|
|
Info.SERNP = Sapdt.Rows[0]["BatchCode"].ToString();
|
|
Info.Z_GERNR = new SAPCallBackJYHGDCS.ZWEBS_GERNR[0];
|
|
|
|
SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse result = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse();
|
|
result = Client.CallZWMS_SK_WS_RUKU(Info);
|
|
if (result.Z_NULL == "N")
|
|
{
|
|
IsSuccess = "N";
|
|
ErrorMessage += result.L_MESSAGE;
|
|
}
|
|
}
|
|
if (IsSuccess == "N")
|
|
{
|
|
throw new Exception(ErrorMessage);
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 叉车采购入库
|
|
/// <summary>
|
|
/// 叉车采购入库
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void DeliveryNoticeForkLift(string ContainerCode, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
string lotsql = @" select A.LotNo,C.Quantity,B.WorkPoint from ICSContainerLot A
|
|
LEFT JOIN ICSContainer B ON B.ID=A.ContainerID AND B.WorkPoint=A.WorkPoint
|
|
LEFT JOIN ICSInventoryLot C ON C.LotNo=A.LotNo AND C.WorkPoint=A.WorkPoint
|
|
where B.ContainerCode='{0}'";
|
|
lotsql = string.Format(lotsql, ContainerCode);
|
|
DataTable lotdt = DBHelper.SQlReturnData(lotsql, cmd);
|
|
if (lotdt.Rows.Count == 0)
|
|
{
|
|
throw new Exception("托盘号不存在或者尚未绑定条码!");
|
|
}
|
|
foreach (DataRow dr in lotdt.Rows)
|
|
{
|
|
string sql = @" UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
|
|
FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
|
|
IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1' AND c.Quantity<c.RCVQuantity)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
|
|
END";
|
|
sql = string.Format(sql, dr["LotNo"].ToString(), dr["WorkPoint"].ToString(), dr["Quantity"].ToString());
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 采购拒收
|
|
/// <summary>
|
|
/// 采购拒收
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseRejectDocIn(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"DECLARE @Status VARCHAR(10)
|
|
SELECT @Status=c.Status FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3'
|
|
|
|
IF (@Status IS NULL)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
|
|
RETURN
|
|
END
|
|
ELSE IF (@Status='3')
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
|
|
RETURN
|
|
END
|
|
UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
|
|
FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3'
|
|
IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3' AND c.Quantity<c.RCVQuantity)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
|
|
END";
|
|
sql = string.Format(sql, LotNo, WorkPoint, Quantity);
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo084"));//"拒收单更新失败!");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 采购拒收接口
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseRejectDocInNewERP(string DNCode, string JDNCode, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
//try
|
|
//{
|
|
// #region ERP
|
|
// string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,d.DNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DNCode,c.DNDetailID,a.InvCode) AS Sequence,
|
|
// a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,d.DNDetailID,con.Enable AS UpdateTodoQuantity
|
|
// ,a.WorkPoint,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,conv.Enable AS VerificationEnable
|
|
// INTO #TempERP
|
|
// FROM ICSWareHouseLotInfoLog a
|
|
// INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
// INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
|
|
// INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
|
|
// INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
|
|
// LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
|
|
// INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
// INNER JOIN ICSDeliveryNotice d ON c.PODetailID=d.DNDetailID AND d.WorkPoint=c.WorkPoint
|
|
// INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
|
|
// INNER JOIN ICSConfiguration conv ON con.Code='CompleteVerification' AND a.WorkPoint=conv.WorkPoint
|
|
// WHERE a.Identification='{0}' AND ERPUpload='0'
|
|
// GROUP BY c.VenCode,a.ToWarehouseCode,c.DNCode,d.DNCode,a.MUSER,lot.Amount,lot.Quantity,a.InvCode,d.DNDetailID,c.DNDetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conv.Enable
|
|
// ,a.WorkPoint,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, '')
|
|
|
|
|
|
// SELECT DISTINCT Costre,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,VerificationEnable,WorkPoint FROM #TempERP
|
|
// SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
|
|
// FROM #TempERP
|
|
|
|
// DROP TABLE #TempERP";
|
|
// sql = string.Format(sql, Identification);
|
|
// DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
|
|
|
|
// string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
|
|
// string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.CreatePuArrivalVouchURL, Inputstr);
|
|
// Result result = new Result();
|
|
// result = JsonConvert.DeserializeObject<Result>(resultStr);
|
|
// if (result.Success)
|
|
// {
|
|
// try
|
|
// {
|
|
// JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
|
|
// foreach (var item in res)
|
|
// {
|
|
// JObject jo = (JObject)item;
|
|
// JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
|
|
// foreach (var detail in resdetail)
|
|
// {
|
|
// JObject det = (JObject)detail;
|
|
// ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
|
|
// }
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// log.Debug(ex.ToString());
|
|
// log.Debug(resultStr);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
|
|
// }
|
|
// #endregion
|
|
//}
|
|
//catch (Exception)
|
|
//{
|
|
// throw;
|
|
//}
|
|
try
|
|
{
|
|
#region ERP
|
|
string sql = @"SELECT a.VenCode+a.DepCode+a.DNCode+a.MUSER AS Costre,a.VenCode,a.DepCode,a.DNCode,a.MUSER,a.MTIME,
|
|
a.Sequence,a.InvCode,Sum(x.Quantity) AS Quantity,a.Amount,ISNULL(a.UnitPrice,0) AS UnitPrice,a.Currency,a.DNDetailID
|
|
,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN 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
|
|
INTO #TempERP
|
|
FROM ICSDeliveryNotice a
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
|
|
INNER JOIN ICSInventory invBat ON a.InvCode=invBat.InvCode AND a.WorkPoint=invBat.WorkPoint
|
|
INNER JOIN ICSDeliveryNotice x ON a.DNDetailID=x.PODetailID AND a.WorkPoint=x.WorkPoint
|
|
WHERE a.DNCode='{0}' AND a.WorkPoint='{1}'
|
|
GROUP BY a.VenCode,a.DepCode,a.DNCode,a.MUSER,a.MTIME,a.Sequence,a.InvCode,a.Amount,a.Quantity,a.UnitPrice,a.Currency,a.DNDetailID,
|
|
a.WorkPoint,ISNULL(ext.ProjectCode, ''),ISNULL(invBat.BatchEnable, ''),ISNULL(ext.BatchCode, ''),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, '')
|
|
|
|
SELECT DISTINCT Costre,WorkPoint,VenCode,DepCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime FROM #TempERP
|
|
SELECT Costre,Sequence,InvCode,Quantity,Amount,UnitPrice,Currency,DNDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
|
|
FROM #TempERP
|
|
|
|
DROP TABLE #TempERP";
|
|
sql = string.Format(sql, DNCode, WorkPoint);
|
|
DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
|
|
|
|
string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
|
|
string resultStr = HTTPHelper.HttpPost("采购拒收", ERPUrl.CreatePuArrivalVouchURL, Inputstr);
|
|
Result result = new Result();
|
|
result = JsonConvert.DeserializeObject<Result>(resultStr);
|
|
if (result.Success)
|
|
{
|
|
try
|
|
{
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
|
|
foreach (var detail in resdetail)
|
|
{
|
|
JObject det = (JObject)detail;
|
|
//ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RJTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
|
|
string ERPupdate = @"update ICSDeliveryNotice set DNCode='{0}',Sequence='{1}',DNID='{2}',DNDetailID='{3}'
|
|
where PODetailID='{4}' AND DNType='3' AND DNCode='{5}' ";
|
|
ERPupdate = string.Format(ERPupdate, jo["RJTCode"], det["Sequence"], jo["ID"], det["DetailID"], det["DNDetailID"], JDNCode);
|
|
|
|
if (!DBHelper.ExecuteNonQuery(ERPupdate, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Debug(ex.ToString());
|
|
log.Debug(resultStr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 采购拒收接口
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseRejectDocInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
|
|
{
|
|
//try
|
|
//{
|
|
// #region ERP
|
|
// string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,d.DNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DNCode,c.DNDetailID,a.InvCode) AS Sequence,
|
|
// a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,d.DNDetailID,con.Enable AS UpdateTodoQuantity
|
|
// ,a.WorkPoint,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,conv.Enable AS VerificationEnable
|
|
// INTO #TempERP
|
|
// FROM ICSWareHouseLotInfoLog a
|
|
// INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
// INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
|
|
// INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
|
|
// INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
|
|
// LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
|
|
// INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
|
|
// INNER JOIN ICSDeliveryNotice d ON c.PODetailID=d.DNDetailID AND d.WorkPoint=c.WorkPoint
|
|
// INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
|
|
// INNER JOIN ICSConfiguration conv ON con.Code='CompleteVerification' AND a.WorkPoint=conv.WorkPoint
|
|
// WHERE a.Identification='{0}' AND ERPUpload='0'
|
|
// GROUP BY c.VenCode,a.ToWarehouseCode,c.DNCode,d.DNCode,a.MUSER,a.InvCode,d.DNDetailID,c.DNDetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conv.Enable
|
|
// ,a.WorkPoint,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, '')
|
|
|
|
|
|
// SELECT DISTINCT Costre,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,VerificationEnable,WorkPoint FROM #TempERP
|
|
// SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
|
|
// FROM #TempERP
|
|
|
|
// DROP TABLE #TempERP";
|
|
// sql = string.Format(sql, Identification);
|
|
// DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
|
|
|
|
// string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
|
|
// string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.CreatePuArrivalVouchURL, Inputstr);
|
|
// Result result = new Result();
|
|
// result = JsonConvert.DeserializeObject<Result>(resultStr);
|
|
// if (result.Success)
|
|
// {
|
|
// try
|
|
// {
|
|
// JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
|
|
// foreach (var item in res)
|
|
// {
|
|
// JObject jo = (JObject)item;
|
|
// JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
|
|
// foreach (var detail in resdetail)
|
|
// {
|
|
// JObject det = (JObject)detail;
|
|
// ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
|
|
// }
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// log.Debug(ex.ToString());
|
|
// log.Debug(resultStr);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
|
|
// }
|
|
// #endregion
|
|
//}
|
|
//catch (Exception)
|
|
//{
|
|
// throw;
|
|
//}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 采购退货
|
|
/// <summary>
|
|
/// 采购退货
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseReceiveDoctNegative(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"DECLARE @Status VARCHAR(10)
|
|
SELECT @Status=Status FROM ICSDeliveryNotice WHERE DNCode='{0}' AND DNType='2' AND WorkPoint='{1}'
|
|
|
|
IF (@Status IS NULL)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo085") + @"',16,1);
|
|
RETURN
|
|
END
|
|
ELSE IF (@Status!='2')
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo086") + @"',16,1);
|
|
RETURN
|
|
END
|
|
|
|
UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
|
|
FROM ICSDeliveryNotice a
|
|
WHERE a.DNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND DNType='2'
|
|
|
|
IF EXISTS(SELECT a.ID FROM ICSDeliveryNotice a
|
|
WHERE a.DNCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.RCVQuantity AND DNType='2')
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo087") + @"',16,1);
|
|
RETURN
|
|
END";
|
|
|
|
sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo088"));//"采购退货单更新失败!");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 采购退货(货柜)
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseReceiveDoctNegativeHG(string TransCode, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
string sql = @" IF EXISTS (SELECT ID FROM ICSDeliveryNotice WHERE RCVQuantity=Quantity AND DNCode='{0}' AND WorkPoint='{1}' )
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo471") + @"',16,1);
|
|
RETURN
|
|
END;
|
|
UPDATE ICSDeliveryNotice SET RCVQuantity=Quantity
|
|
WHERE DNCode='{0}' AND WorkPoint='{1}'";
|
|
|
|
sql = string.Format(sql, TransCode, WorkPoint);
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo088"));//"采购退货单更新失败!");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 采购退货接口
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseReceiveDoctNegativeERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
|
|
{
|
|
try
|
|
{
|
|
#region SAP(三层结构)
|
|
string IsSuccess = "";
|
|
string ErrorMessage = "";
|
|
string sql = @" select A.DNCode,A.WorkPoint,SUM(B.Quantity) AS Quantity from ICSDeliveryNotice A
|
|
LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.DNCode AND B.WorkPoint=A.WorkPoint
|
|
where B.Identification='{0}' AND BusinessCode='3'
|
|
GROUP BY A.DNCode,A.WorkPoint";
|
|
sql = string.Format(sql, Identification);
|
|
DataTable dt = DBHelper.SQlReturnData(sql, cmd);
|
|
if (dt.Rows.Count > 1)
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据)
|
|
}
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
string chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSDeliveryNotice
|
|
where DNCode='{0}' and WorkPoint='{1}'
|
|
GROUP BY DNCode,WorkPoint";
|
|
chksql = string.Format(chksql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
|
|
DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
|
|
if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) == Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"]))
|
|
{
|
|
SAPCallBackDocVPN.ZWMS_SK_WS_PZ Client = new SAPCallBackDocVPN.ZWMS_SK_WS_PZ();
|
|
SAPCallBackDocVPN.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDocVPN.ZWMS_SK_WS_PZ1();
|
|
Info.NEWID = Identification;
|
|
Info.DANJU = dt.Rows[i]["DNCode"].ToString();
|
|
Info.STATE = "0";
|
|
List<SAPCallBackDocVPN.ZWMS_PZ> ItemList = new List<SAPCallBackDocVPN.ZWMS_PZ>();
|
|
List<SAPCallBackDocVPN.ZWEBS_GERNR> ItemLineList = new List<SAPCallBackDocVPN.ZWEBS_GERNR>();
|
|
Info.Z_FLAG = new SAPCallBackDocVPN.ZWEB_RETURN[1];
|
|
sql = @"select A.DNCode,A.SAPSequence,A.InvCode,A.Sequence,A.Quantity,A.RCVQuantity
|
|
,ISNULL(B.BatchCode,'') AS BatchCode from ICSDeliveryNotice A
|
|
LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
|
|
WHERE DNCode='{0}' AND A.WorkPoint='{1}'";
|
|
sql = string.Format(sql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
|
|
DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
|
|
foreach (DataRow dr in Sapdt.Rows)
|
|
{
|
|
if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["RCVQuantity"].ToString()))
|
|
{
|
|
SAPCallBackDocVPN.ZWMS_PZ Item = new SAPCallBackDocVPN.ZWMS_PZ();
|
|
SAPCallBackDocVPN.ZWEBS_GERNR ItemLine = new SAPCallBackDocVPN.ZWEBS_GERNR();
|
|
Item.DANJU = dr["DNCode"].ToString();
|
|
Item.POSNR = dr["SAPSequence"].ToString();
|
|
Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(dt.Rows[0]["Quantity"].ToString()), 3);
|
|
ItemList.Add(Item);
|
|
if (dr["BatchCode"].ToString() != "")
|
|
{
|
|
ItemLine.DANJU = dr["DNCode"].ToString();
|
|
ItemLine.POSNR = dr["SAPSequence"].ToString();
|
|
ItemLine.MATNR = dr["InvCode"].ToString();
|
|
ItemLine.GERNR = dr["BatchCode"].ToString();
|
|
ItemLineList.Add(ItemLine);
|
|
}
|
|
}
|
|
}
|
|
if (ItemList.Count > 0)
|
|
{
|
|
Info.Z_ITEM = ItemList.ToArray();
|
|
if (ItemLineList.Count > 0)
|
|
{
|
|
Info.Z_GERNR = ItemLineList.ToArray();
|
|
}
|
|
else
|
|
{
|
|
Info.Z_GERNR = new SAPCallBackDocVPN.ZWEBS_GERNR[1];
|
|
}
|
|
SAPCallBackDocVPN.ZWMS_SK_WS_PZResponse result = new SAPCallBackDocVPN.ZWMS_SK_WS_PZResponse();
|
|
result = Client.CallZWMS_SK_WS_PZ(Info);
|
|
if (result.Z_NULL == "N")
|
|
{
|
|
foreach (SAPCallBackDocVPN.ZWEB_RETURN resultItem in result.Z_FLAG)
|
|
{
|
|
IsSuccess = "N";
|
|
ErrorMessage += resultItem.L_MESSAGE + "/r/n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (IsSuccess == "N")
|
|
{
|
|
throw new Exception(ErrorMessage);
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 开立红字入库
|
|
/// <summary>
|
|
/// 开立红字入库
|
|
/// </summary>
|
|
/// <param name="TransCode"></param>
|
|
/// <param name="TransSequence"></param>
|
|
/// <param name="Quantity"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseReceive(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"DECLARE @Status VARCHAR(10)
|
|
SELECT @Status=a.Status FROM ICSPurchaseReceive a
|
|
WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
|
|
|
|
IF (@Status IS NULL)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo089") + @"',16,1);
|
|
RETURN
|
|
END
|
|
ELSE IF (@Status!='1')
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo090") + @"',16,1);
|
|
RETURN
|
|
END
|
|
UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
|
|
FROM ICSPurchaseReceive a
|
|
WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
|
|
|
|
IF EXISTS(SELECT a.ID FROM ICSPurchaseReceive a
|
|
WHERE a.RCVCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='2' AND a.Quantity<a.RCVQuantity)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
|
|
RETURN
|
|
END";
|
|
|
|
sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd))
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo092"));//"红字入库单更新失败!");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开立红字入库接口
|
|
/// </summary>
|
|
/// <param name="TransType"></param>
|
|
/// <param name="Identification"></param>
|
|
/// <param name="cmd"></param>
|
|
public static void PurchaseReceiveERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
|
|
{
|
|
try
|
|
{
|
|
#region ERP开立状态单据审核
|
|
string sql = @"IF EXISTS(SELECT b.ID FROM ICSWareHouseLotInfoLog a
|
|
INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.Identification='{0}' AND b.Quantity!=b.RCVQuantity)
|
|
BEGIN
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo093") + @"',16,1);
|
|
RETURN
|
|
END
|
|
SELECT b.RCVID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
|
|
FROM ICSWareHouseLotInfoLog a
|
|
INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
|
|
INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock001' AND a.WorkPoint=conStock.WorkPoint
|
|
WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '4'
|
|
GROUP BY b.RCVID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
|
|
sql = string.Format(sql, Identification);
|
|
DataTable dt = DBHelper.SQlReturnData(sql, cmd);
|
|
|
|
string Inputstr = JsonConvert.SerializeObject(dt);
|
|
string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseReceiveDoctNegativeURL, Inputstr);
|
|
Result result = new Result();
|
|
result = JsonConvert.DeserializeObject<Result>(resultStr);
|
|
if (result.Success)
|
|
{
|
|
try
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "", "", cmd, language, BusinessCode);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Debug(ex.ToString());
|
|
log.Debug(resultStr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|