Browse Source

新增拣料的数据接口

master
lilili 2 years ago
parent
commit
fd873d3d6b
  1. 201
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSalesService.cs
  2. 210
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
  3. 185
      ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs

201
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSalesService.cs

@ -408,6 +408,84 @@ namespace ICSSoft.DataProject
}
}
///// <summary>
///// 销售退货-原条码接口
///// </summary>
///// <param name="TransType"></param>
///// <param name="Identification"></param>
///// <param name="cmd"></param>
//public static void SalesReturnBackInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
//{
// try
// {
// #region ERP
// string sql = @"SELECT c.CusCode+a.ToWarehouseCode+c.SDNCode+a.MUSER AS Costre,c.CusCode,a.ToWarehouseCode AS WarehouseCode,c.SDNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.CusCode,a.ToWarehouseCode,c.SDNCode,c.SDNDetailID,a.InvCode) AS Sequence,
// a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,c.SDNDetailID,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
// 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 ICSSDN c ON a.TransCode=c.SDNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
// INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
// WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2' AND BusinessCode='{1}'
// GROUP BY c.CusCode,a.ToWarehouseCode,c.SDNCode,a.MUSER,a.InvCode,c.SDNDetailID,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,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
// SELECT Costre,Sequence,InvCode,Quantity,Amount,SDNDetailID AS SDNRTDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
// DROP TABLE #TempERP";
// sql = string.Format(sql, Identification, BusinessCode);
// DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
// string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
// string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, 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["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
// det["DetailID"].ToString(), jo["SDNNEGCode"].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;
// }
//}
/// <summary>
/// 销售退货-原条码接口
/// </summary>
@ -418,64 +496,89 @@ namespace ICSSoft.DataProject
{
try
{
#region ERP
string sql = @"SELECT c.CusCode+a.ToWarehouseCode+c.SDNCode+a.MUSER AS Costre,c.CusCode,a.ToWarehouseCode AS WarehouseCode,c.SDNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.CusCode,a.ToWarehouseCode,c.SDNCode,c.SDNDetailID,a.InvCode) AS Sequence,
a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,c.SDNDetailID,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
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 ICSSDN c ON a.TransCode=c.SDNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2' AND BusinessCode='{1}'
GROUP BY c.CusCode,a.ToWarehouseCode,c.SDNCode,a.MUSER,a.InvCode,c.SDNDetailID,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,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
SELECT Costre,Sequence,InvCode,Quantity,Amount,SDNDetailID AS SDNRTDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
DROP TABLE #TempERP";
sql = string.Format(sql, Identification, BusinessCode);
DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, Inputstr);
Result result = new Result();
result = JsonConvert.DeserializeObject<Result>(resultStr);
if (result.Success)
#region SAP(三层结构)
string IsSuccess = "";
string ErrorMessage = "";
string sql = @" select Distinct A.SDNCode,A.WorkPoint from ICSSDN A
LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.SDNCode AND B.WorkPoint=A.WorkPoint
where B.Identification='{0}' AND BusinessCode='20'";
sql = string.Format(sql, Identification);
DataTable dt = DBHelper.SQlReturnData(sql, cmd);
if (dt.Rows.Count > 1)
{
try
throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据)
}
for (int i = 0; i < dt.Rows.Count; i++)
{
string chksql = @"select SUM(Quantity) AS Quantity,SUM(SDNQuantity) AS SDNQuantity from ICSSDN
where SDNCode='{0}' and WorkPoint='{1}'
GROUP BY SDNCode,WorkPoint";
chksql = string.Format(chksql, dt.Rows[i]["SDNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) == Convert.ToDecimal(chkdt.Rows[0]["SDNQuantity"]))
{
JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
foreach (var item in res)
SAPCallBackDispatchVPN.ZWMS_SK_DO_GZ Client = new SAPCallBackDispatchVPN.ZWMS_SK_DO_GZ();
SAPCallBackDispatchVPN.ZWMS_SK_DO_GZ1 Info = new SAPCallBackDispatchVPN.ZWMS_SK_DO_GZ1();
List<SAPCallBackDispatchVPN.ZWMS_DO_HEAD> headlist = new List<SAPCallBackDispatchVPN.ZWMS_DO_HEAD>();
SAPCallBackDispatchVPN.ZWMS_DO_HEAD head = new SAPCallBackDispatchVPN.ZWMS_DO_HEAD();
head.VBELN = dt.Rows[i]["SDNCode"].ToString();
headlist.Add(head);
Info.T_HEAD = headlist.ToArray();
List<SAPCallBackDispatchVPN.ZWMS_DO_ITEM> ItemList = new List<SAPCallBackDispatchVPN.ZWMS_DO_ITEM>();
List<SAPCallBackDispatchVPN.ZWMS_DO_GERNR> ItemLineList = new List<SAPCallBackDispatchVPN.ZWMS_DO_GERNR>();
Info.T_RETURN = new SAPCallBackDispatchVPN.ZWMS_DO_RETURN[1];
sql = @" select A.SDNCode,A.SAPSequence,A.InvCode,A.Sequence,A.Quantity,A.SDNQuantity
,ISNULL(B.BatchCode,'') AS BatchCode from ICSSDN A
LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
WHERE SDNCode='{0}' AND A.WorkPoint='{1}'";
sql = string.Format(sql, dt.Rows[i]["SDNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
foreach (DataRow dr in Sapdt.Rows)
{
JObject jo = (JObject)item;
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
foreach (var detail in resdetail)
if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["SDNQuantity"].ToString()))
{
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["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
det["DetailID"].ToString(), jo["SDNNEGCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
SAPCallBackDispatchVPN.ZWMS_DO_ITEM Item = new SAPCallBackDispatchVPN.ZWMS_DO_ITEM();
SAPCallBackDispatchVPN.ZWMS_DO_GERNR ItemLine = new SAPCallBackDispatchVPN.ZWMS_DO_GERNR();
Item.VBELN = dr["SDNCode"].ToString();
Item.POSNR = dr["SAPSequence"].ToString();
Item.LFIMG = System.Decimal.Round(Convert.ToDecimal(dr["Quantity"].ToString()), 3);
ItemList.Add(Item);
if (dr["BatchCode"].ToString() != "")
{
ItemLine.VBELN = dr["SDNCode"].ToString();
ItemLine.POSNR = dr["SAPSequence"].ToString();
ItemLine.GERNR = dr["BatchCode"].ToString();
ItemLineList.Add(ItemLine);
}
}
}
if (ItemList.Count > 0)
{
Info.T_ITEM = ItemList.ToArray();
if (ItemLineList.Count > 0)
{
Info.T_GERNR = ItemLineList.ToArray();
}
else
{
Info.T_GERNR = new SAPCallBackDispatchVPN.ZWMS_DO_GERNR[1];
}
SAPCallBackDispatchVPN.ZWMS_SK_DO_GZResponse result = new SAPCallBackDispatchVPN.ZWMS_SK_DO_GZResponse();
result = Client.CallZWMS_SK_DO_GZ(Info);
foreach (SAPCallBackDispatchVPN.ZWMS_DO_RETURN resultItem in result.T_RETURN)
{
if (resultItem.ZFLG == "N")
{
IsSuccess = "N";
ErrorMessage += resultItem.ZMESS + "/r/n";
}
}
}
}
catch (Exception ex)
{
log.Debug(ex.ToString());
log.Debug(resultStr);
}
}
else
if (IsSuccess == "N")
{
throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
throw new Exception(ErrorMessage);
}
#endregion
}

210
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs

@ -7338,149 +7338,143 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
if (JsonData.TransType == TransTypeEnum.MOApply.GetDescription())
{
#region 工单领料SQL
sqls = @" select
x.MergeID,
a.ApplyCode as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.WhCode,
a.ExtensionID
FROM
ICSMOApply a
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,x.MergeID,a.ExtensionID";
sqls = @"select
a.ApplyCode as Code, a.InvCode, b.InvName, b.InvStd, b.InvUnit, SUM(ISNULL(a.Quantity, 0)) AS iQuantity, a.WhCode,a.ExtensionID,c.LocationCode
FROM
ICSMOApply a
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint = b.WorkPoint
LEFT JOIN ICSInventoryDetail c ON b.InvCode=c.INVCode AND a.WHCode=c.WHCode AND a.WorkPoint=c.WorkPoint
WHERE a.ApplyCode in ('{0}') AND a.WorkPoint = '{1}'
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,c.LocationCode ";
#endregion
}
#endregion
#region 委外领料
if (JsonData.TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription())
if (JsonData.TransType == TransTypeEnum.OOApply.GetDescription())
{
#region 委外领料SQL
sqls = @" select
x.MergeID,
a.ApplyCode as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.WhCode,
a.ExtensionID
FROM
ICSOApply a
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
sqls = sqls = @"select
a.ApplyCode as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.WhCode,
a.ExtensionID,
c.LocationCode
FROM
ICSOApply a
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSInventoryDetail c ON b.InvCode=c.INVCode AND a.WHCode=c.WHCode AND a.WorkPoint=c.WorkPoint
WHERE a.ApplyCode in ('{0}') AND a.WorkPoint = '{1}'
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,c.LocationCode";
#endregion
}
#endregion
#region 销售发货
if (JsonData.TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription())
if (JsonData.TransType == TransTypeEnum.SalesShipmentDoc.GetDescription())
{
#region 销售发货SQL
sqls = @" select
x.MergeID,
a.SDNCode as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.WhCode,
a.ExtensionID
FROM
ICSSDN a
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
WHERE a.SDNCode in ({0}) AND a.WorkPoint = '{1}'
GROUP BY a.SDNCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
sqls = @" select
a.SDNCode as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.WhCode,
a.ExtensionID,
c.LocationCode
FROM
ICSSDN a
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSInventoryDetail c ON b.InvCode=c.INVCode AND a.WHCode=c.WHCode AND a.WorkPoint=c.WorkPoint
WHERE a.SDNCode in ('{0}') AND a.WorkPoint = '{1}'
GROUP BY a.SDNCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,c.LocationCode";
#endregion
}
#endregion
#region 其他出库
if (JsonData.TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription())
if (JsonData.TransType == TransTypeEnum.OtherOutDoc.GetDescription())
{
#region 其它出库SQL
sqls = @" select
x.MergeID,
a.OutCode as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.WhCode,
a.ExtensionID
FROM
ICSOtherOut a
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
a.OutCode as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.WhCode,
a.ExtensionID,
c.LocationCode
FROM
ICSOtherOut a
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSInventoryDetail c ON b.InvCode=c.INVCode AND a.WHCode=c.WHCode AND a.WorkPoint=c.WorkPoint
WHERE a.OutCode in ('{0}') AND a.WorkPoint = '{1}'
GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,c.LocationCode";
#endregion
}
#endregion
#region 物料调拨
if (JsonData.TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription())
if (JsonData.TransType == TransTypeEnum.OneStepTransferDocIn.GetDescription())
{
#region 物料调拨
sqls = @" select
x.MergeID,
a.TransferNO as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.FromWarehouseCode as WhCode,
a.ExtensionID
FROM
ICSTransfer a
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
WHERE a.TransferNO in ({0}) AND a.WorkPoint = '{1}'
GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID,x.MergeID";
sqls = @"select
a.TransferNO as Code,
a.InvCode,
b.InvName,
b.InvStd,
b.InvUnit,
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
a.FromWarehouseCode as WhCode,
a.ExtensionID,
c.LocationCode
FROM
ICSTransfer a
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSInventoryDetail c ON b.InvCode=c.INVCode AND a.FromWarehouseCode=c.WHCode AND a.WorkPoint=c.WorkPoint
WHERE a.TransferNO in ('{0}') AND a.WorkPoint = '{1}'
GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID,c.LocationCode";
#endregion
}
#endregion
sqls = string.Format(sqls, JsonData.TransCode, JsonData.WorkPoint);
sqls = string.Format(sqls, JsonData.TransCode.ToString(), JsonData.WorkPoint.ToString());
#region sql
string sql = $@"SELECT row_number() over (order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
c.MergeID,
c.Code,
c.InvCode,
c.InvName,
c.InvStd,
c.InvUnit,
FLOOR(c.iQuantity) AS iQuantity,
d.WarehouseCode,
d.LocationCode,
d.LotNO,
FLOOR(ISNULL(d.Quantity, 0)) AS QTY,
CONVERT(varchar(100),d.MTIME, 23) MTIME,
FLOOR(f.QTYTotal) QTYTotal
FROM
({sqls}) c
left join (select d.WarehouseCode,d.Quantity,d.INVCode, m.LotNo, d.MTIME,d.LocationCode,m.ExtensionID
from ICSWareHouseLotInfo d ,ICSInventoryLot m
where d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint
and d.WorkPoint='{JsonData.WorkPoint}' AND d.Quantity>0 ) d
on c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode and d.ExtensionID=c.ExtensionID
LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='{JsonData.WorkPoint}' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
order by c.Code,c.InvCode,d.MTIME ";
string sql = $@"SELECT row_number() over ( order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
c.Code,
c.InvCode,
c.InvName,
c.InvStd,
c.InvUnit,
FLOOR(c.iQuantity) AS iQuantity,
c.WHCode AS WarehouseCode,
d.LotNO,
FLOOR(ISNULL(d.Quantity, 0)) AS QTY,
d.LocationCode AS LocationCode,
CONVERT(varchar(100),d.MTIME, 23) MTIME,
FLOOR(f.QTYTotal) QTYTotal
FROM
({sqls}) c
left join (select d.WarehouseCode,d.Quantity,d.INVCode, m.LotNo, d.MTIME,d.LocationCode,m.ExtensionID
from ICSWareHouseLotInfo d ,ICSInventoryLot m
where d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint
and d.WorkPoint='{JsonData.WorkPoint.ToString()}' AND d.Quantity>0 AND SUBSTRING(SUBSTRING(d.LocationCode, CHARINDEX('-',d.LocationCode)+1, LEN(d.LocationCode)),0,CHARINDEX('-', SUBSTRING(d.LocationCode, CHARINDEX('-',d.LocationCode)+1, LEN(d.LocationCode))))
Not IN(SELECT F_Define2 FROM Sys_SRM_ItemsDetail WHERE F_Define3='HGAreaConfig' AND F_Define1=d.WarehouseCode AND F_Define4=d.WorkPoint) ) d
on c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode and d.ExtensionID=c.ExtensionID
LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='{JsonData.WorkPoint.ToString()}' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
order by c.Code,c.InvCode,d.MTIME ";
#endregion
var dataset = DBHelper.SQlReturnDataSet(sql, cmd); ;
var dataset = DBHelper.SQlReturnDataSet(sql, cmd);
if (dataset.Tables.Count == 0)
return null;
DataTable table = dataset.Tables[0];

185
ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs

@ -335,190 +335,7 @@ namespace ICSSoft.WebAPI.Controllers
res.Success = false;
res.Message = LanguageHelper.GetNameSingle("WMSAPI003");//"未查询到相关数据!";
//res.Data = resultStr;
}
// string sqls = "";
// if (Type == "2")
// {
// #region 工单领料SQL
// sqls = @" select
// x.MergeID,
// a.ApplyCode as Code,
// a.InvCode,
// b.InvName,
// b.InvStd,
// b.InvUnit,
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
// a.WhCode,
// a.ExtensionID
// FROM
// ICSMOApply a
//inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
// WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
// GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,x.MergeID,a.ExtensionID";
// #endregion
// }
// if (Type == "5")
// {
// #region 委外领料SQL
// sqls = @" select
// x.MergeID,
// a.ApplyCode as Code,
// a.InvCode,
// b.InvName,
// b.InvStd,
// b.InvUnit,
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
// a.WhCode,
// a.ExtensionID
// FROM
// ICSOApply a
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
// WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
// GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
// #endregion
// }
// if (Type == "7")
// {
// #region 销售发货SQL
// sqls = @" select
// x.MergeID,
// a.SDNCode as Code,
// a.InvCode,
// b.InvName,
// b.InvStd,
// b.InvUnit,
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
// a.WhCode,
// a.ExtensionID
// FROM
// ICSSDN a
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
// WHERE a.SDNCode in ({0}) AND a.WorkPoint = '{1}'
// GROUP BY a.SDNCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
// #endregion
// }
// if (Type == "8")
// {
// #region 其它出库SQL
// sqls = @" select
//x.MergeID,
// a.OutCode as Code,
// a.InvCode,
// b.InvName,
// b.InvStd,
// b.InvUnit,
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
// a.WhCode,
// a.ExtensionID
// FROM
// ICSOtherOut a
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
// WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
// GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
// #endregion
// }
// if (Type == "10")
// {
// #region 物料调拨
// sqls = @" select
//x.MergeID,
// a.TransferNO as Code,
// a.InvCode,
// b.InvName,
// b.InvStd,
// b.InvUnit,
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
// a.FromWarehouseCode as WhCode,
// a.ExtensionID
// FROM
// ICSTransfer a
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
// WHERE a.TransferNO in ({0}) AND a.WorkPoint = '{1}'
// GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID,x.MergeID";
// #endregion
// }
// sqls = string.Format(sqls, string.IsNullOrWhiteSpace(ID) ? "''" : ID.TrimEnd(','), WorkPoint);
// #region sql
// string sql = $@"SELECT row_number() over (order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
// c.MergeID,
// c.Code,
// c.InvCode,
// c.InvName,
// c.InvStd,
// c.InvUnit,
// FLOOR(c.iQuantity) AS iQuantity,
// d.WarehouseCode,
// d.LocationCode,
// d.LotNO,
// FLOOR(ISNULL(d.Quantity, 0)) AS QTY,
// CONVERT(varchar(100),d.MTIME, 23) MTIME,
// FLOOR(f.QTYTotal) QTYTotal
// FROM
// ({sqls}) c
// left join (select d.WarehouseCode,d.Quantity,d.INVCode, m.LotNo, d.MTIME,d.LocationCode,m.ExtensionID
// from ICSWareHouseLotInfo d ,ICSInventoryLot m
// where d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint
// and d.WorkPoint='{WorkPoint}' AND d.Quantity>0 ) d
// on c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode and d.ExtensionID=c.ExtensionID
// LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='{WorkPoint}' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
// order by c.Code,c.InvCode,d.MTIME ";
// #endregion
// var dataset = Repository().FindDataSetBySql(sql);
// if (dataset.Tables.Count == 0)
// return null;
// DataTable table = dataset.Tables[0];
// decimal qtyCount = 0;
// bool remove = false;
// List<int> removeList = new List<int>();
// for (int i = 0; i < table.Rows.Count; i++)
// {
// if (i != 0
// && (!table.Rows[i]["InvCode"].ToString().Equals(table.Rows[i - 1]["InvCode"].ToString())
// || !table.Rows[i]["Code"].ToString().Equals(table.Rows[i - 1]["Code"].ToString()))
// )
// {
// qtyCount = 0;
// remove = false;
// }
// if (remove)
// {
// removeList.Add(i);
// }
// else
// {
// var lotQty = table.Rows[i]["QTY"].ToString().ToDecimal();
// var orderQty = table.Rows[i]["iQuantity"].ToString().ToDecimal();
// qtyCount += lotQty;
// if (qtyCount >= orderQty)
// {
// remove = true;
// }
// }
// }
// if (removeList.Count > 0)
// {
// removeList.Reverse();
// foreach (var item in removeList)
// {
// table.Rows.RemoveAt(item);
// }
// }
// var result = ConvertCellToString(table);
// if (Invmes.Rows.Count > 0)
// {
// result.Merge(Invmes, false);
// }
// return result;
}
}
}
catch (Exception ex)

Loading…
Cancel
Save