Browse Source

库位 条码物料查询

master
冒林杰 2 years ago
parent
commit
9c189bed2d
  1. 4
      ICSSoft.WMS.WebAPI/ICSSoft.Common/TransTypeEnum.cs
  2. 466
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
  3. 4
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

4
ICSSoft.WMS.WebAPI/ICSSoft.Common/TransTypeEnum.cs

@ -189,6 +189,10 @@ namespace ICSSoft.Common
[DBValue("68")] [DBValue("68")]
LOTMerge, LOTMerge,
[Description("库位查询")]
[DBValue("69")]
LocationSeatch,
[Description("合并前")] [Description("合并前")]
[DBValue("33")] [DBValue("33")]
LOTMergeBefore, LOTMergeBefore,

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

@ -912,6 +912,7 @@ namespace ICSSoft.DataProject
public static Result BarCodeInformationGet(BarCodeModel JsonData) public static Result BarCodeInformationGet(BarCodeModel JsonData)
{ {
var language = LanguageHelper.GetName("WMSAPIInfo"); var language = LanguageHelper.GetName("WMSAPIInfo");
DataTable table = new DataTable();
using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString)) using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
{ {
conn.Open(); conn.Open();
@ -939,11 +940,122 @@ namespace ICSSoft.DataProject
string TransType = JsonData.TransType; string TransType = JsonData.TransType;
string sql = ""; string sql = "";
string Losql = "";
string sqlNew = ""; string sqlNew = "";
#region SLQ #region SLQ
if (ScanType == "LOTNO")
if (TransType == TransTypeEnum.LocationSeatch.GetDescription())
{ {
sql = @"SELECT a.ID,
//Losql = @"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.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 {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.Quantity>0 and a.WorkPoint='{3}'";
Losql = @"DECLARE @aa VARCHAR(MAX)
DECLARE @bb VARCHAR(MAX)
DECLARE @cc VARCHAR(MAX)
DECLARE @b VARCHAR(MAX)
set @b =
'SELECT a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,
inv.InvName,
inv.InvStd,
inv.InvUnit,
inv.LotEnable,
s.WarehouseCode,sum(a.Quantity) as Qty,s.sumQty,
inv.AmountUnit,
ext.ID AS ExtensionID,
ext.ProjectCode,
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 ICSWareHouseLotInfo a
LEFT JOIN ICSLocation b ON a.LocationCode = b.LocationCode 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
LEFT JOIN (select SUM(Quantity) AS sumQty,WarehouseCode,INVCode from ICSWareHouseLotInfo group by WarehouseCode,INVCode)s ON a.INVCode=s.INVCode
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.Quantity>0 and a.WorkPoint=''{3}'' and'
select @aa=id from ICSWareHouseLotInfo where LotNo='{2}'
IF @aa IS NOT NULL
BEGIN
set @b = @b+' lot.invcode IN(SELECT invcode FROM ICSWareHouseLotInfo where LotNo=''{2}'')
group by a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,inv.LotEnable,s.WarehouseCode, inv.INVCODE,inv.INVNAME,inv.INVSTD,s.sumQty,inv.AmountUnit,
ext.ID,ext.ProjectCode,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 ,a.MTIME
'
END
select @bb=id from ICSLocation where LocationCode='{2}'
IF @bb IS not NULL
BEGIN
set @b = @b+' a.WarehouseCode=s.WarehouseCode and a.LocationCode=''{2}''
group by a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,inv.LotEnable,s.WarehouseCode, inv.INVCODE,inv.INVNAME,inv.INVSTD,s.sumQty,inv.AmountUnit,
ext.ID,ext.ProjectCode,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 ,a.MTIME'
END
select @cc=id from ICSInventory where invcode='{2}'
IF @cc IS not NULL
BEGIN
set @b = @b+' a.WarehouseCode=s.WarehouseCode and inv.invcode=''{2}''
group by a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,inv.LotEnable,s.WarehouseCode, inv.INVCODE,inv.INVNAME,inv.INVSTD,s.sumQty,inv.AmountUnit,
ext.ID,ext.ProjectCode,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 ,a.MTIME'
END
exec(@b)
";
}
else
{
if (ScanType == "LOTNO")
{
sql = @"SELECT a.ID,
con.ContainerCode, con.ContainerCode,
con.ContainerName, con.ContainerName,
a.LotNo, a.LotNo,
@ -975,10 +1087,10 @@ namespace ICSSoft.DataProject
LEFT JOIN ICSContainer con ON conlot.ContainerID=con.ID AND conlot.WorkPoint=con.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 INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' "; WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' ";
}
else
{
sql = @"SELECT a.ID,
}
else
{
sql = @"SELECT a.ID,
con.ContainerCode, con.ContainerCode,
con.ContainerName, con.ContainerName,
a.LotNo, a.LotNo,
@ -1010,12 +1122,17 @@ namespace ICSSoft.DataProject
LEFT JOIN ICSContainer con ON conlot.ContainerID=con.ID AND conlot.WorkPoint=con.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 INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
WHERE bom.ContainerCode='{2}' AND a.WorkPoint='{3}' "; WHERE bom.ContainerCode='{2}' AND a.WorkPoint='{3}' ";
}
} }
#endregion #endregion
bool isOut = false; //出库标记 bool isOut = false; //出库标记
string columns = string.Empty; //查询源头单据表的特殊列名 string columns = string.Empty; //查询源头单据表的特殊列名
string tableName = string.Empty; //查询源头单据表名 string tableName = string.Empty; //查询源头单据表名
string where = string.Empty; //排序
if (TransType == TransTypeEnum.PurchaseReceiveDoctNegative.GetDescription() //采购退货 if (TransType == TransTypeEnum.PurchaseReceiveDoctNegative.GetDescription() //采购退货
|| TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription() //委外发料 || TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription() //委外发料
|| TransType == TransTypeEnum.OutsourcingReturnBack.GetDescription() //委外退货 || TransType == TransTypeEnum.OutsourcingReturnBack.GetDescription() //委外退货
@ -1039,16 +1156,34 @@ namespace ICSSoft.DataProject
{ {
isOut = true; isOut = true;
} }
//两步调入条码
if (TransType == TransTypeEnum.TwoStepTransferDocIn.GetDescription())
//库位查询
if (TransType == TransTypeEnum.LocationSeatch.GetDescription())
{ {
if (string.IsNullOrEmpty(JsonData.TransCode))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo001"));//"单据号不能为空!"
}
if (ScanType == "LOTNO")
// Losql = @"" + Losql + "group by a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,inv.LotEnable,s.WarehouseCode, inv.INVCODE,inv.INVNAME,inv.INVSTD,s.sumQty,inv.AmountUnit,ext.ID,ext.ProjectCode,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 ,a.MTIME";
// columns = @"s.WarehouseCode, inv.INVCODE,inv.INVNAME,inv.INVSTD,sum(a.Quantity) as Qty,s.sumQty,";
// tableName = @"ICSWareHouseLotInfo a
//LEFT JOIN ICSLocation b ON a.LocationCode = b.LocationCode 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
//LEFT JOIN (select SUM(Quantity) AS sumQty,WarehouseCode,INVCode from ICSWareHouseLotInfo group by WarehouseCode,INVCode)s
//ON a.INVCode=s.INVCode ";
}
else
{
//两步调入条码
if (TransType == TransTypeEnum.TwoStepTransferDocIn.GetDescription())
{ {
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSOtherIn Otin
if (string.IsNullOrEmpty(JsonData.TransCode))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo001"));//"单据号不能为空!"
}
if (ScanType == "LOTNO")
{
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSOtherIn Otin
INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint
INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint
INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint
@ -1063,7 +1198,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit, wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit,
ext.ID,ext.ProjectCode,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,a.MTIME"; ext.ID,ext.ProjectCode,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,a.MTIME";
columns = @"SUM(log.Quantity) AS Quantity,
columns = @"SUM(log.Quantity) AS Quantity,
SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount, SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1071,7 +1206,7 @@ namespace ICSSoft.DataProject
loc.LocationName, loc.LocationName,
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,"; 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,";
tableName = @"ICSOtherIn Otin
tableName = @"ICSOtherIn Otin
INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint
INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint
INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint
@ -1081,10 +1216,10 @@ namespace ICSSoft.DataProject
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
else
{
sql = @"WITH ICSBomALL AS
}
else
{
sql = @"WITH ICSBomALL AS
( (
SELECT SELECT
ContainerCode AS TContainerCode, ContainerCode AS TContainerCode,
@ -1116,7 +1251,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit, wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit,
ext.ID,ext.ProjectCode,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,a.MTIME"; ext.ID,ext.ProjectCode,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,a.MTIME";
columns = @"SUM(log.Quantity) AS Quantity,
columns = @"SUM(log.Quantity) AS Quantity,
SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount, SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1124,7 +1259,7 @@ namespace ICSSoft.DataProject
loc.LocationName, loc.LocationName,
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,"; 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,";
tableName = @"ICSOtherIn Otin
tableName = @"ICSOtherIn Otin
INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint
INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint
INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint
@ -1134,20 +1269,20 @@ namespace ICSSoft.DataProject
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
}
}
//销售退货-原条码(可支持一个条码多次发货,汇总数量,目前加了限制:785-793行)
else if (TransType == TransTypeEnum.SalesReturnBack.GetDescription())
{
if (string.IsNullOrEmpty(JsonData.TransCode))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo001"));//"单据号不能为空!"
} }
if (ScanType == "LOTNO")
//销售退货-原条码(可支持一个条码多次发货,汇总数量,目前加了限制:785-793行)
else if (TransType == TransTypeEnum.SalesReturnBack.GetDescription())
{ {
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSSDN sdn
if (string.IsNullOrEmpty(JsonData.TransCode))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo001"));//"单据号不能为空!"
}
if (ScanType == "LOTNO")
{
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSSDN sdn
INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint
INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND sdn.Type='1') WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND sdn.Type='1')
@ -1169,7 +1304,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit, wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit,
ext.ID,ext.ProjectCode,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,a.MTIME"; ext.ID,ext.ProjectCode,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,a.MTIME";
columns = @"SUM(log.Quantity) AS Quantity,
columns = @"SUM(log.Quantity) AS Quantity,
SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount, SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1177,7 +1312,7 @@ namespace ICSSoft.DataProject
loc.LocationName, loc.LocationName,
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,"; 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,";
tableName = @"ICSSDN sdn
tableName = @"ICSSDN sdn
INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint
INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
@ -1185,10 +1320,10 @@ namespace ICSSoft.DataProject
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
else
{
sql = @"WITH ICSBomALL AS
}
else
{
sql = @"WITH ICSBomALL AS
( (
SELECT SELECT
ContainerCode AS TContainerCode, ContainerCode AS TContainerCode,
@ -1220,7 +1355,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit, wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit,
ext.ID,ext.ProjectCode,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,a.MTIME"; ext.ID,ext.ProjectCode,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,a.MTIME";
columns = @"SUM(log.Quantity) AS Quantity,
columns = @"SUM(log.Quantity) AS Quantity,
SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount, SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1228,7 +1363,7 @@ namespace ICSSoft.DataProject
loc.LocationName, loc.LocationName,
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,"; 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,";
tableName = @"ICSSDN sdn
tableName = @"ICSSDN sdn
INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint
INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
@ -1236,49 +1371,49 @@ namespace ICSSoft.DataProject
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
} }
}
//生产(委外)退料-原条码+新条码
//先校验日志里面是否有原条码(同一种类型的条码只能发一次料才能原条码退,不然更新源头单据数量有问题,根据LogID判断是否原条码退回),如果没有查询新条码
else if (TransType == TransTypeEnum.MOIssueDocNegative.GetDescription()
|| TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription()
|| TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription()
|| TransType == TransTypeEnum.ICSOutsourcingIssueDoNegative.GetDescription()
|| TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeApply.GetDescription()
|| TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeIssue.GetDescription())
{
string type = "13";
string msglanguage = "WMSAPIInfo185";
if (TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription())
{
type = "14";
msglanguage = "WMSAPIInfo186";
}
else if (TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription())
{
type = "15";
msglanguage = "WMSAPIInfo187";
}
else if (TransType == TransTypeEnum.ICSOutsourcingIssueDoNegative.GetDescription())
{
type = "5";
msglanguage = "WMSAPIInfo188";
}
else if(TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeApply.GetDescription())
{
type = "6";
msglanguage = "WMSAPIInfo189";
}
else if (TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeIssue.GetDescription())
{
type = "7";
msglanguage = "WMSAPIInfo190";
}
#region 新条码
if (ScanType == "LOTNO")
//生产(委外)退料-原条码+新条码
//先校验日志里面是否有原条码(同一种类型的条码只能发一次料才能原条码退,不然更新源头单据数量有问题,根据LogID判断是否原条码退回),如果没有查询新条码
else if (TransType == TransTypeEnum.MOIssueDocNegative.GetDescription()
|| TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription()
|| TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription()
|| TransType == TransTypeEnum.ICSOutsourcingIssueDoNegative.GetDescription()
|| TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeApply.GetDescription()
|| TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeIssue.GetDescription())
{ {
sqlNew = @"IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}')
string type = "13";
string msglanguage = "WMSAPIInfo185";
if (TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription())
{
type = "14";
msglanguage = "WMSAPIInfo186";
}
else if (TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription())
{
type = "15";
msglanguage = "WMSAPIInfo187";
}
else if (TransType == TransTypeEnum.ICSOutsourcingIssueDoNegative.GetDescription())
{
type = "5";
msglanguage = "WMSAPIInfo188";
}
else if (TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeApply.GetDescription())
{
type = "6";
msglanguage = "WMSAPIInfo189";
}
else if (TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeIssue.GetDescription())
{
type = "7";
msglanguage = "WMSAPIInfo190";
}
#region 新条码
if (ScanType == "LOTNO")
{
sqlNew = @"IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}')
BEGIN BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{2}") + @"',16,1); RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{2}") + @"',16,1);
RETURN RETURN
@ -1298,7 +1433,7 @@ namespace ICSSoft.DataProject
END END
" + sql; " + sql;
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
a.Quantity*(a.Amount/a.Quantity) AS Amount, a.Quantity*(a.Amount/a.Quantity) AS Amount,
'' AS WHCode, '' AS WHCode,
'' AS WHName, '' AS WHName,
@ -1306,13 +1441,13 @@ namespace ICSSoft.DataProject
'' AS LocationName, '' AS LocationName,
ext.BatchCode AS BatchCode,"; ext.BatchCode AS BatchCode,";
tableName = @"ICSInventoryLot a
tableName = @"ICSInventoryLot a
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint"; LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint";
}
else
{
sqlNew = @"WITH ICSBomALL AS
}
else
{
sqlNew = @"WITH ICSBomALL AS
( (
SELECT SELECT
ContainerCode AS TContainerCode, ContainerCode AS TContainerCode,
@ -1341,7 +1476,7 @@ namespace ICSSoft.DataProject
) )
" + sql; " + sql;
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
a.Quantity*(a.Amount/a.Quantity) AS Amount, a.Quantity*(a.Amount/a.Quantity) AS Amount,
'' AS WHCode, '' AS WHCode,
'' AS WHName, '' AS WHName,
@ -1349,21 +1484,21 @@ namespace ICSSoft.DataProject
'' AS LocationName, '' AS LocationName,
ext.BatchCode AS BatchCode,"; ext.BatchCode AS BatchCode,";
tableName = @"ICSInventoryLot a
tableName = @"ICSInventoryLot a
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint"; LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint";
}
sqlNew = string.Format(sqlNew, columns, tableName, JsonData.Code, JsonData.WorkPoint);
#endregion
#region 原条码
if (ScanType == "LOTNO")
{
sql = sql + @" AND log.BusinessCode IN('" + type + @"') GROUP BY log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
}
sqlNew = string.Format(sqlNew, columns, tableName, JsonData.Code, JsonData.WorkPoint);
#endregion
#region 原条码
if (ScanType == "LOTNO")
{
sql = sql + @" AND log.BusinessCode IN('" + type + @"') GROUP BY log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN(invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')= '1') OR ISNULL(invBat.BatchEnable, '0')= '1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit, wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN(invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')= '1') OR ISNULL(invBat.BatchEnable, '0')= '1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit,
ext.ID,ext.ProjectCode,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,a.MTIME ext.ID,ext.ProjectCode,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,a.MTIME
"; ";
sql = @"IF EXISTS(" + sql + @")
sql = @"IF EXISTS(" + sql + @")
BEGIN BEGIN
" + sql + @" " + sql + @"
END END
@ -1371,7 +1506,7 @@ namespace ICSSoft.DataProject
BEGIN BEGIN
" + sqlNew + @" " + sqlNew + @"
END"; END";
sql = @"IF EXISTS(SELECT log.LotNo FROM ICSWareHouseLotInfoLog log
sql = @"IF EXISTS(SELECT log.LotNo FROM ICSWareHouseLotInfoLog log
INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND log.BusinessCode='" + type + @"' WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND log.BusinessCode='" + type + @"'
GROUP BY log.LotNo HAVING COUNT(log.LotNo)>=2) GROUP BY log.LotNo HAVING COUNT(log.LotNo)>=2)
@ -1381,7 +1516,7 @@ namespace ICSSoft.DataProject
END END
" + sql; " + sql;
columns = @"SUM(log.Quantity) AS Quantity,
columns = @"SUM(log.Quantity) AS Quantity,
SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount, SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1390,21 +1525,21 @@ namespace ICSSoft.DataProject
log.ID AS LogID, log.ID AS LogID,
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,"; 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,";
tableName = @"ICSWareHouseLotInfoLog log
tableName = @"ICSWareHouseLotInfoLog log
INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.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 ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
else
{
sql = sql + @" AND log.BusinessCode IN('" + type + @"') GROUP BY log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
}
else
{
sql = sql + @" AND log.BusinessCode IN('" + type + @"') GROUP BY log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN(invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')= '1') OR ISNULL(invBat.BatchEnable, '0')= '1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit, wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN(invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')= '1') OR ISNULL(invBat.BatchEnable, '0')= '1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,inv.AmountUnit,
ext.ID,ext.ProjectCode,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,a.MTIME ext.ID,ext.ProjectCode,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,a.MTIME
"; ";
sql = @"IF EXISTS(" + sql + @")
sql = @"IF EXISTS(" + sql + @")
BEGIN BEGIN
" + sql + @" " + sql + @"
END END
@ -1412,7 +1547,7 @@ namespace ICSSoft.DataProject
BEGIN BEGIN
" + sqlNew + @" " + sqlNew + @"
END"; END";
sql = @"WITH ICSBomALL AS
sql = @"WITH ICSBomALL AS
( (
SELECT SELECT
ContainerCode AS TContainerCode, ContainerCode AS TContainerCode,
@ -1441,7 +1576,7 @@ namespace ICSSoft.DataProject
) )
" + sql; " + sql;
columns = @"SUM(log.Quantity) AS Quantity,
columns = @"SUM(log.Quantity) AS Quantity,
SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount, SUM(log.Quantity*(lot.Amount/lot.Quantity)) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1450,28 +1585,28 @@ namespace ICSSoft.DataProject
log.ID AS LogID, log.ID AS LogID,
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,"; 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,";
tableName = @"ICSWareHouseLotInfoLog log
tableName = @"ICSWareHouseLotInfoLog log
INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.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 ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
#endregion
} }
#endregion
}
//分批
else if (TransType == TransTypeEnum.LOTSplit.GetDescription()|| TransType == TransTypeEnum.LOTMerge.GetDescription())
{
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND a.Quantity>0)
//分批
else if (TransType == TransTypeEnum.LOTSplit.GetDescription() || TransType == TransTypeEnum.LOTMerge.GetDescription())
{
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND a.Quantity>0)
BEGIN BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{2}") + @"',16,1); RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{2}") + @"',16,1);
RETURN RETURN
END END
" + sql; " + sql;
columns = @"a.Quantity,
columns = @"a.Quantity,
a.Quantity*(lot.Amount/lot.Quantity) AS Amount, a.Quantity*(lot.Amount/lot.Quantity) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1480,28 +1615,28 @@ namespace ICSSoft.DataProject
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, 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(split.SplitLotNo, a.LotNo+'-1') AS SplitLotNo,"; ISNULL(split.SplitLotNo, a.LotNo+'-1') AS SplitLotNo,";
tableName = @"ICSWareHouseLotInfo a
tableName = @"ICSWareHouseLotInfo a
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.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 ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN (SELECT EATTRIBUTE1 AS LotNo,WorkPoint,EATTRIBUTE1+'-'+CAST((MAX(CAST(SUBSTRING(LotNo, CHARINDEX('-', LotNo)+1, LEN(LotNo)-CHARINDEX('-', LotNo)) AS INT))+1) AS VARCHAR) AS SplitLotNo FROM ICSInventoryLot GROUP BY EATTRIBUTE1,WorkPoint) split ON a.LotNo=split.LotNo AND a.WorkPoint=split.WorkPoint LEFT JOIN (SELECT EATTRIBUTE1 AS LotNo,WorkPoint,EATTRIBUTE1+'-'+CAST((MAX(CAST(SUBSTRING(LotNo, CHARINDEX('-', LotNo)+1, LEN(LotNo)-CHARINDEX('-', LotNo)) AS INT))+1) AS VARCHAR) AS SplitLotNo FROM ICSInventoryLot GROUP BY EATTRIBUTE1,WorkPoint) split ON a.LotNo=split.LotNo AND a.WorkPoint=split.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
//出库条码
else if (isOut)
{
if (ScanType == "LOTNO")
}
//出库条码
else if (isOut)
{ {
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND a.Quantity>0)
if (ScanType == "LOTNO")
{
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND a.Quantity>0)
BEGIN BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{2}") + @"',16,1); RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{2}") + @"',16,1);
RETURN RETURN
END END
" + sql; " + sql;
columns = @"a.Quantity,
columns = @"a.Quantity,
a.Quantity*(lot.Amount/lot.Quantity) AS Amount, a.Quantity*(lot.Amount/lot.Quantity) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1509,16 +1644,16 @@ namespace ICSSoft.DataProject
loc.LocationName, loc.LocationName,
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,"; 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,";
tableName = @"ICSWareHouseLotInfo a
tableName = @"ICSWareHouseLotInfo a
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.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 ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint"; LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
else
{
sql = @"
}
else
{
sql = @"
WITH ICSBomALL AS WITH ICSBomALL AS
( (
SELECT SELECT
@ -1548,7 +1683,7 @@ namespace ICSSoft.DataProject
) )
" + sql; " + sql;
columns = @"a.Quantity,
columns = @"a.Quantity,
a.Quantity*(lot.Amount/lot.Quantity) AS Amount, a.Quantity*(lot.Amount/lot.Quantity) AS Amount,
a.WarehouseCode AS WHCode, a.WarehouseCode AS WHCode,
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
@ -1556,24 +1691,24 @@ namespace ICSSoft.DataProject
loc.LocationName, loc.LocationName,
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,"; 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,";
tableName = @"ICSWareHouseLotInfo a
tableName = @"ICSWareHouseLotInfo a
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.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 ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint INNER JOIN ICSWarehouse wh ON a.WarehouseCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint INNER JOIN ICSLocation loc ON a.LocationCode=loc.LocationCode AND a.WorkPoint=loc.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
"; ";
}
}
}
//入库条码
else
{
if (ScanType == "LOTNO")
}
//入库条码
else
{ {
sql = @"
if (ScanType == "LOTNO")
{
sql = @"
IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo = '{2}' AND a.WorkPoint = '{3}') IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo = '{2}' AND a.WorkPoint = '{3}')
BEGIN BEGIN
@ -1596,7 +1731,7 @@ namespace ICSSoft.DataProject
END END
" + sql; " + sql;
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
a.Quantity*(a.Amount/a.Quantity) AS Amount, a.Quantity*(a.Amount/a.Quantity) AS Amount,
'' AS WHCode, '' AS WHCode,
'' AS WHName, '' AS WHName,
@ -1604,13 +1739,13 @@ namespace ICSSoft.DataProject
'' AS LocationName, '' AS LocationName,
ext.BatchCode AS BatchCode,"; ext.BatchCode AS BatchCode,";
tableName = @"ICSInventoryLot a
tableName = @"ICSInventoryLot a
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint"; LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint";
}
else
{
sql = @"
}
else
{
sql = @"
WITH ICSBomALL AS WITH ICSBomALL AS
( (
SELECT SELECT
@ -1640,7 +1775,7 @@ namespace ICSSoft.DataProject
) )
" + sql; " + sql;
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
a.Quantity*(a.Amount/a.Quantity) AS Amount, a.Quantity*(a.Amount/a.Quantity) AS Amount,
'' AS WHCode, '' AS WHCode,
'' AS WHName, '' AS WHName,
@ -1648,18 +1783,35 @@ namespace ICSSoft.DataProject
'' AS LocationName, '' AS LocationName,
ext.BatchCode AS BatchCode,"; ext.BatchCode AS BatchCode,";
tableName = @"ICSInventoryLot a
tableName = @"ICSInventoryLot a
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint"; LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint";
}
} }
} }
if (string.IsNullOrWhiteSpace(columns) || string.IsNullOrWhiteSpace(tableName))
throw new Exception(language.GetNameByCode("WMSAPIInfo003"));
sql = string.Format(sql, columns, tableName, JsonData.Code, JsonData.WorkPoint);
DataTable table = DBHelper.SQlReturnData(sql, cmd);
if (TransType != TransTypeEnum.LocationSeatch.GetDescription())
{
if (string.IsNullOrWhiteSpace(columns) || string.IsNullOrWhiteSpace(tableName))
throw new Exception(language.GetNameByCode("WMSAPIInfo003"));
}
if (TransType == TransTypeEnum.LocationSeatch.GetDescription())
{
Losql = string.Format(Losql, columns, tableName, JsonData.Code, JsonData.WorkPoint);
table = DBHelper.SQlReturnData(Losql, cmd);
}
else
{
sql = string.Format(sql, columns, tableName, JsonData.Code, JsonData.WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
}
if (table == null || table.Rows.Count <= 0) if (table == null || table.Rows.Count <= 0)
throw new Exception(language.GetNameByCode("WMSAPIInfo008"));//"未查询到条码数据!" throw new Exception(language.GetNameByCode("WMSAPIInfo008"));//"未查询到条码数据!"
@ -1692,7 +1844,7 @@ namespace ICSSoft.DataProject
} }
} }
else
else if(TransType != TransTypeEnum.LocationSeatch.GetDescription())
{ {
if (string.IsNullOrEmpty(JsonData.TransCode)) if (string.IsNullOrEmpty(JsonData.TransCode))
{ {

4
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

@ -264,7 +264,7 @@ namespace ICSSoft.DataProject
a.InvCode, a.InvCode,
b.InvName, b.InvName,
b.InvStd, b.InvStd,
a.Quantity/c.Quantity*{2} AS Quantity,
a.ParentQuantity/c.Quantity*{2} AS Quantity,
a.Amount, a.Amount,
a.Sequence AS TransSequence, a.Sequence AS TransSequence,
a.IssueQuantity, a.IssueQuantity,
@ -388,7 +388,7 @@ namespace ICSSoft.DataProject
#endregion #endregion
sql = String.Format(sql,LotNo,WorkPoint, Quantity); sql = String.Format(sql,LotNo,WorkPoint, Quantity);
DataTable table = DBHelper.SQlReturnData(sql,cmd); DataTable table = DBHelper.SQlReturnData(sql,cmd);
string json = JsonConvert.SerializeObject(table);
string json = JsonConvert.SerializeObject(table);
List<DownItemModel> downItemModels = JsonConvert.DeserializeObject<List<DownItemModel>>(json); List<DownItemModel> downItemModels = JsonConvert.DeserializeObject<List<DownItemModel>>(json);
foreach (DownItemModel model in downItemModels) foreach (DownItemModel model in downItemModels)
{ {

Loading…
Cancel
Save