|
|
@ -1661,10 +1661,509 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; |
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; |
|
|
|
ID = string.IsNullOrWhiteSpace(ID) ? "''" : ID.TrimEnd(','); |
|
|
|
string sqls = ""; |
|
|
|
#region sql
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
string sqls = ""; |
|
|
|
//调拨单拣料增加逻辑,如果memo字段有条码信息,那么拣料的条码为备注条码,否则走正常逻辑
|
|
|
|
if (Type == "10") |
|
|
|
{ |
|
|
|
string dataString = $@"select a.Memo,a.FromWarehouseCode,a.Quantity,a.TransferQuantity,a.InvCode,a.TransferNO,a.SAPSequence,a.Sequence FROM ICSTransfer a
|
|
|
|
WHERE a.TransferNO in ({ID}) AND a.WorkPoint = '{WorkPoint}' |
|
|
|
AND ISNULL(a.Quantity, 0)>ISNULL(a.TransferQuantity, 0) |
|
|
|
AND a.Memo is not null AND a.Memo!='' ";
|
|
|
|
|
|
|
|
var datasetModel = Repository().FindDataSetBySql(dataString); |
|
|
|
DataTable table1 = null; |
|
|
|
DataTable table = null; |
|
|
|
StringBuilder updateString = new StringBuilder(); |
|
|
|
string sqlString = String.Empty; |
|
|
|
if (datasetModel.Tables[0].Rows.Count != 0) |
|
|
|
{ |
|
|
|
DataTable tableModel = datasetModel.Tables[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tableModel.Rows.Count > 0) |
|
|
|
{ |
|
|
|
//循环验证条码信息是否与单据信息相符
|
|
|
|
for (int i = 0; i < tableModel.Rows.Count; i++) |
|
|
|
{ |
|
|
|
string transCode = tableModel.Rows[i]["TransferNO"].ToString(); |
|
|
|
string lotNo = tableModel.Rows[i]["Memo"].ToString(); |
|
|
|
string whCode = tableModel.Rows[i]["FromWarehouseCode"].ToString(); |
|
|
|
string sequence = tableModel.Rows[i]["Sequence"].ToString(); |
|
|
|
//验证信息
|
|
|
|
updateString.Append($@"IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo='{lotNo}' AND a.WorkPoint='{WorkPoint}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('条码{lotNo},不存在',16,1); |
|
|
|
RETURN |
|
|
|
END; |
|
|
|
IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{tableModel.Rows[i]["Memo"]}' AND a.WorkPoint='{WorkPoint}' AND a.WarehouseCode='{whCode}') |
|
|
|
BEGIN |
|
|
|
RAISERROR('条码{lotNo}和单据{transCode}行{tableModel.Rows[i]["SAPSequence"]}仓库不一致',16,1); |
|
|
|
RETURN |
|
|
|
END; |
|
|
|
IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{lotNo}' AND a.WorkPoint='{WorkPoint}' AND a.WarehouseCode='{whCode}' AND a.Quantity>A.LockQuantity+'{tableModel.Rows[i]["Quantity"]}') |
|
|
|
BEGIN |
|
|
|
RAISERROR('条码{lotNo}的库存可分配数量小于单据数量',16,1); |
|
|
|
RETURN |
|
|
|
END; |
|
|
|
IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo='2023052500001' AND a.WorkPoint='1701' AND InvCode='20064648') |
|
|
|
BEGIN |
|
|
|
RAISERROR('条码{lotNo}和单据{transCode}行号{tableModel.Rows[i]["SAPSequence"]}对应的物料不一致',16,1); |
|
|
|
RETURN |
|
|
|
END;"
|
|
|
|
); |
|
|
|
|
|
|
|
updateString.Append($@" INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
|
|
|
|
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity, |
|
|
|
Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID, |
|
|
|
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName, |
|
|
|
MTIME,WorkPoint,EATTRIBUTE1) |
|
|
|
SELECT NEWID(),NEWID(),'{transCode}','{sequence}',a.LotNo ,a.InvCode , |
|
|
|
a.WarehouseCode,a.LocationCode,'','','{tableModel.Rows[i]["Quantity"]}', |
|
|
|
'','1','15','47','0','', |
|
|
|
'','','','{MUSER}' ,'{MUSERNAME}' , |
|
|
|
GETDATE() ,'{WorkPoint}' ,'' |
|
|
|
FROM ICSWareHouseLotInfo a |
|
|
|
WHERE a.LotNo='{tableModel.Rows[i]["Memo"]}' AND a.WorkPoint='{WorkPoint}' |
|
|
|
|
|
|
|
update ICSWareHouseLotInfo set LockQuantity=LockQuantity+'{tableModel.Rows[i]["Quantity"]}' where LotNo='{lotNo}' AND WorkPoint='{WorkPoint}';");
|
|
|
|
|
|
|
|
} |
|
|
|
sqlString = $@"SELECT
|
|
|
|
a.TransferNO AS Code,a.Sequence,a.InvCode,b.InvName,b.InvStd,b.InvUnit, |
|
|
|
(SUM(ISNULL(a.Quantity, 0))-SUM(ISNULL(a.TransferQuantity, 0))) AS iQuantity,--应发数量 |
|
|
|
a.FromWarehouseCode As WarehouseCode, |
|
|
|
a.Memo AS LotNO, |
|
|
|
ISNULL(c.Quantity, 0) AS QTY,--条码库存 |
|
|
|
ISNULL(c.Quantity, 0) AS QTYLeft, |
|
|
|
a.Quantity as SendQTY, --占料数量 |
|
|
|
c.LocationCode, |
|
|
|
CONVERT(varchar(100),c.MTIME, 23) MTIME, |
|
|
|
SUM(c.Quantity-c.LockQuantity) AS QTYTotal, |
|
|
|
a.ExtensionID |
|
|
|
from ICSTransfer a |
|
|
|
Left JOIN ICSInventory b ON a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint |
|
|
|
LEFT JOIN ICSWareHouseLotInfo c ON c.LotNo=a.Memo AND a.FromWarehouseCode=c.WarehouseCode |
|
|
|
WHERE a.TransferNO in({ID}) AND a.Memo is NOT NULL and a.Memo!='' |
|
|
|
GROUP BY a.TransferNO,a.Sequence,a.InvCode,b.InvName,b.InvStd,b.InvUnit, |
|
|
|
a.Quantity,a.FromWarehouseCode ,a.Memo,c.LocationCode,c.MTIME,c.Quantity,a.ExtensionID,c.LockQuantity; ";
|
|
|
|
|
|
|
|
} |
|
|
|
//if (!String.IsNullOrEmpty(sqlString))
|
|
|
|
//{
|
|
|
|
// var dataSet1 = Repository().FindDataSetBySql(updateString.ToString()+ sqlString);
|
|
|
|
// if (dataSet1.Tables[0].Rows.Count != 0)
|
|
|
|
// {
|
|
|
|
// table1 = dataSet1.Tables[0];
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string sql = $@"SELECT row_number() over ( order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
|
|
|
|
c.Code, |
|
|
|
c.Sequence, |
|
|
|
c.InvCode, |
|
|
|
c.InvName, |
|
|
|
c.InvStd, |
|
|
|
c.InvUnit, |
|
|
|
c.iQuantity AS iQuantity, |
|
|
|
c.WHCode AS WarehouseCode, |
|
|
|
d.LotNO, |
|
|
|
ISNULL(d.Quantity, 0) AS QTY, |
|
|
|
ISNULL(d.Quantity, 0) AS QTYLeft, |
|
|
|
CONVERT(decimal(18,6),0) AS SendQTY, |
|
|
|
d.LocationCode AS LocationCode, |
|
|
|
CONVERT(varchar(100),d.MTIME, 23) MTIME, |
|
|
|
f.QTYTotal QTYTotal,c.ExtensionID |
|
|
|
FROM |
|
|
|
(select |
|
|
|
a.TransferNO as Code, |
|
|
|
a.Sequence, |
|
|
|
a.InvCode, |
|
|
|
b.InvName, |
|
|
|
b.InvStd, |
|
|
|
b.InvUnit, |
|
|
|
(SUM(ISNULL(a.Quantity, 0))-SUM(ISNULL(a.TransferQuantity, 0))) AS iQuantity, |
|
|
|
a.FromWarehouseCode as WhCode, |
|
|
|
a.ExtensionID |
|
|
|
FROM |
|
|
|
ICSTransfer a |
|
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint |
|
|
|
WHERE a.TransferNO in ({ID}) AND a.WorkPoint = '{WorkPoint}' AND ISNULL(a.Quantity, 0)>ISNULL(a.TransferQuantity, 0) |
|
|
|
and (a.Memo is null or a.Memo='' ) |
|
|
|
GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID,a.Sequence) c |
|
|
|
left join (select d.WarehouseCode,d.Quantity-d.LockQuantity as 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-d.LockQuantity>0 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-LockQuantity) 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,Convert(int,c.Sequence),d.MTIME,d.LotNO ";
|
|
|
|
|
|
|
|
var dataset = Repository().FindDataSetBySql(sql); |
|
|
|
if (dataset.Tables[0].Rows.Count != 0) |
|
|
|
{ |
|
|
|
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]["Sequence"].ToString().Equals(table.Rows[i - 1]["Sequence"].ToString()) |
|
|
|
|| !table.Rows[i]["Code"].ToString().Equals(table.Rows[i - 1]["Code"].ToString()) |
|
|
|
|| !table.Rows[i]["ExtensionID"].ToString().Equals(table.Rows[i - 1]["ExtensionID"].ToString())) |
|
|
|
) |
|
|
|
{ |
|
|
|
qtyCount = 0; |
|
|
|
remove = false; |
|
|
|
} |
|
|
|
if (table.Rows[i]["QTYLeft"].ToString().ToDecimal() == 0) |
|
|
|
{ |
|
|
|
removeList.Add(i); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (remove) |
|
|
|
{ |
|
|
|
removeList.Add(i); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var lotQty = table.Rows[i]["QTYLeft"].ToString().ToDecimal(); |
|
|
|
var orderQty = table.Rows[i]["iQuantity"].ToString().ToDecimal(); |
|
|
|
qtyCount += lotQty; |
|
|
|
foreach (DataRow dr in table.Rows) |
|
|
|
{ |
|
|
|
if (dr["LotNO"].ToString() == table.Rows[i]["LotNO"].ToString()) |
|
|
|
{ |
|
|
|
if (qtyCount > orderQty) |
|
|
|
{ |
|
|
|
dr["QTYLeft"] = Convert.ToDecimal(qtyCount) - Convert.ToDecimal(orderQty); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dr["QTYLeft"] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (qtyCount >= orderQty) |
|
|
|
{ |
|
|
|
table.Rows[i]["SendQTY"] = Convert.ToDecimal(lotQty) - (Convert.ToDecimal(qtyCount) - Convert.ToDecimal(orderQty)); |
|
|
|
remove = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
table.Rows[i]["SendQTY"] = lotQty; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (removeList.Count > 0) |
|
|
|
{ |
|
|
|
removeList.Reverse(); |
|
|
|
foreach (var item in removeList) |
|
|
|
{ |
|
|
|
table.Rows.RemoveAt(item); |
|
|
|
} |
|
|
|
} |
|
|
|
try |
|
|
|
{ |
|
|
|
#region 占料前增加验证,如果条码数量超出实际需要领料数量,直接报错
|
|
|
|
string chksql = ""; |
|
|
|
if (Type == "2" || Type == "12") |
|
|
|
{ |
|
|
|
chksql = @" select InvCode,WHCode,SUM(Quantity) as Quantity from ICSMOApply
|
|
|
|
where ApplyCode in ({0}) and WorkPoint='{1}' |
|
|
|
GROUP BY InvCode,WHCode";
|
|
|
|
} |
|
|
|
if (Type == "5") |
|
|
|
{ |
|
|
|
#region 委外领料SQL
|
|
|
|
chksql = @" select InvCode,WHCode,SUM(Quantity) as Quantity from ICSOApply
|
|
|
|
where ApplyCode in ({0}) and WorkPoint='{1}' |
|
|
|
GROUP BY InvCode,WHCode";
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|
if (Type == "7") |
|
|
|
{ |
|
|
|
#region 销售发货SQL
|
|
|
|
chksql = @" select InvCode,WHCode,SUM(Quantity) as Quantity from ICSSDN
|
|
|
|
where SDNCode in ({0}) and WorkPoint='{1}' |
|
|
|
GROUP BY InvCode,WHCode";
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|
if (Type == "8") |
|
|
|
{ |
|
|
|
#region 其它出库SQL
|
|
|
|
chksql = @" select InvCode,WHCode,SUM(Quantity) as Quantity from ICSOtherOut
|
|
|
|
where OutCode in ({0}) and WorkPoint='{1}' |
|
|
|
GROUP BY InvCode,WHCode";
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|
if (Type == "10") |
|
|
|
{ |
|
|
|
#region 物料调拨
|
|
|
|
chksql = @" select InvCode,FromWarehouseCode AS WHCode,SUM(Quantity) as Quantity from ICSTransfer
|
|
|
|
where TransferNO in ({0}) and WorkPoint='{1}' and (Memo is NULL or Memo='') |
|
|
|
GROUP BY InvCode,FromWarehouseCode";
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|
chksql = string.Format(chksql, ID, WorkPoint); |
|
|
|
var chkdata = Repository().FindDataSetBySql(chksql); |
|
|
|
DataTable chktable = chkdata.Tables[0]; |
|
|
|
foreach (DataRow chkdr in chktable.Rows) |
|
|
|
{ |
|
|
|
decimal ZLQty = 0; |
|
|
|
for (int i = 0; i < table.Rows.Count; i++) |
|
|
|
{ |
|
|
|
if (table.Rows[i]["WarehouseCode"].ToString() == chkdr["WHCode"].ToString() |
|
|
|
&& table.Rows[i]["InvCode"].ToString() == chkdr["InvCode"].ToString()) |
|
|
|
{ |
|
|
|
ZLQty += Convert.ToDecimal(table.Rows[i]["SendQTY"].ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (Convert.ToDecimal(chkdr["Quantity"]) < ZLQty) |
|
|
|
{ |
|
|
|
throw new Exception("物料:" + chkdr["InvCode"].ToString() + "实际拣料数量大于单据需求数量,请尝试重新拣料。"); |
|
|
|
} |
|
|
|
if (Convert.ToDecimal(chkdr["Quantity"]) > ZLQty && (Type == "2" || Type == "5" || Type == "12")) |
|
|
|
{ |
|
|
|
chksql = @" select B.F_Define2 from ICSInventoryDetail A
|
|
|
|
INNER JOIN Sys_SRM_ItemsDetail B ON B.F_Define1=A.WHCode AND B.F_Define2=A.LocationCode AND B.F_Define4=A.WorkPoint |
|
|
|
where INVCode='{0}' and WHCode='{1}' and WorkPoint='{2}'";
|
|
|
|
chksql = string.Format(chksql, chkdr["InvCode"].ToString(), chkdr["WHCode"].ToString(), WorkPoint); |
|
|
|
var chkds = Repository().FindDataSetBySql(chksql); |
|
|
|
DataTable chkdt = chkds.Tables[0]; |
|
|
|
if (chkdt.Rows.Count != 0) |
|
|
|
{ |
|
|
|
throw new Exception("物料:" + chkdr["InvCode"].ToString() + "实际拣料数量小于单据需求数量,货柜单据必须整单拣料,请先核对库存。"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
if (table.Rows.Count != 0) |
|
|
|
{ |
|
|
|
#region 拣料时增加条码出入库记录,修改库存锁定数量,以作占料处理
|
|
|
|
int Count = 1; |
|
|
|
string BusinessCode = string.Empty; |
|
|
|
string TransType = ""; |
|
|
|
if (Type == "2") { BusinessCode = "13"; TransType = "生产发料-领料申请单"; } |
|
|
|
if (Type == "12") { BusinessCode = "14"; TransType = "生产发料-领料申请单"; } |
|
|
|
if (Type == "5") { BusinessCode = "6"; TransType = "委外发料-委外领料申请单"; } |
|
|
|
if (Type == "7") { BusinessCode = "19"; TransType = "销售发货-销售发货单"; } |
|
|
|
if (Type == "8") { BusinessCode = "24"; TransType = "杂发"; } |
|
|
|
if (Type == "10") { BusinessCode = "47"; TransType = "调拨申请单"; } |
|
|
|
string Identification = Guid.NewGuid().ToString(); |
|
|
|
var pikTbLogTime = DateTime.Now; |
|
|
|
string pikTbLogsql = string.Empty; |
|
|
|
List<string> DocNoList = new List<string>(); |
|
|
|
if (Type == "2" || Type == "12" || Type == "5") |
|
|
|
{ |
|
|
|
#region 货柜
|
|
|
|
string InspectJosn = ""; |
|
|
|
string InspectJosnHead = ""; |
|
|
|
string InspectJosnBody = ""; |
|
|
|
InspectJosn += "{"; |
|
|
|
InspectJosn += "\"IMP_ORDINI\":["; |
|
|
|
InspectJosn += "货柜主表区域预留"; |
|
|
|
InspectJosn += "],"; |
|
|
|
InspectJosn += "\"IMP_ORDINI_RIGHE\":["; |
|
|
|
InspectJosn += "货柜子表区域预留"; |
|
|
|
InspectJosn += "]"; |
|
|
|
InspectJosn += "}"; |
|
|
|
for (int i = 0; i < table.Rows.Count; i++) |
|
|
|
{ |
|
|
|
string hgsql = @"select A.InvCode,A.LocationCode,B.F_Define3,C.LocationCode AS Area
|
|
|
|
from ICSWareHouseLotInfo A |
|
|
|
INNER JOIN Sys_SRM_ItemsDetail B ON B.F_Define2=A.LocationCode AND F_Define4=A.WorkPoint AND F_ItemName='HG_Location' |
|
|
|
INNER JOIN ICSInventoryDetail C ON C.INVCode=A.InvCode AND C.WHCode=A.WarehouseCode AND C.WorkPoint=A.WorkPoint |
|
|
|
where A.LotNo='{0}' AND A.WorkPoint='{1}'";
|
|
|
|
hgsql = string.Format(hgsql, table.Rows[i]["LotNO"].ToString(), WorkPoint); |
|
|
|
var hgds = Repository().FindDataSetBySql(hgsql); |
|
|
|
if (hgds.Tables.Count == 0) |
|
|
|
return null; |
|
|
|
DataTable hgtable = hgds.Tables[0]; |
|
|
|
if (hgtable.Rows.Count > 0) |
|
|
|
{ |
|
|
|
if (!DocNoList.Contains(table.Rows[i]["Code"].ToString())) |
|
|
|
{ |
|
|
|
DocNoList.Add(table.Rows[i]["Code"].ToString()); |
|
|
|
} |
|
|
|
InspectJosnBody += "{"; |
|
|
|
InspectJosnBody += "\"RIG_ORDINE\":\"" + table.Rows[i]["Code"].ToString() + "\","; |
|
|
|
InspectJosnBody += "\"RIG_ARTICOLO\": \"" + hgtable.Rows[0]["InvCode"].ToString() + "\","; |
|
|
|
InspectJosnBody += "\"RIG_SUB1\": \"\","; |
|
|
|
InspectJosnBody += "\"RIG_SUB2\": \"\","; |
|
|
|
InspectJosnBody += "\"RIG_ELERUOLI_GEST\": \"" + hgtable.Rows[0]["Area"].ToString() + "\","; |
|
|
|
InspectJosnBody += "\"RIG_ELEBAIE\": \"" + hgtable.Rows[0]["F_Define3"].ToString() + "\","; |
|
|
|
InspectJosnBody += "\"RIG_QTAR\": " + table.Rows[i]["SendQTY"].ToString() + ","; |
|
|
|
if (i == 0) |
|
|
|
{ |
|
|
|
InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + "\""; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (table.Rows[i]["Code"].ToString() == table.Rows[i - 1]["Code"].ToString() && |
|
|
|
table.Rows[i]["Sequence"].ToString() == table.Rows[i - 1]["Sequence"].ToString()) |
|
|
|
{ |
|
|
|
InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + Count.ToString() + "\""; |
|
|
|
Count++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + "\""; |
|
|
|
Count = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
InspectJosnBody += "},"; |
|
|
|
} |
|
|
|
} |
|
|
|
InspectJosnBody = InspectJosnBody.TrimEnd(','); |
|
|
|
foreach (string DocNo in DocNoList) |
|
|
|
{ |
|
|
|
InspectJosnHead += "{"; |
|
|
|
InspectJosnHead += "\"ORD_ORDINE\":\"" + DocNo.TrimStart('\'').TrimEnd('\'') + "\","; |
|
|
|
InspectJosnHead += "\"ORD_DES\":\"" + TransType + "\","; |
|
|
|
InspectJosnHead += "\"ORD_TIPOOP\":\"P\","; |
|
|
|
InspectJosnHead += "\"ORD_CLIENTE\":\"" + WorkPoint + "\""; |
|
|
|
InspectJosnHead += "},"; |
|
|
|
} |
|
|
|
InspectJosnHead = InspectJosnHead.TrimEnd(','); |
|
|
|
if (InspectJosnBody != "") |
|
|
|
{ |
|
|
|
InspectJosn = InspectJosn.Replace("货柜主表区域预留", InspectJosnHead); |
|
|
|
InspectJosn = InspectJosn.Replace("货柜子表区域预留", InspectJosnBody); |
|
|
|
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"])) |
|
|
|
{ |
|
|
|
string callresult = ""; |
|
|
|
#region 货柜接口调用前日志
|
|
|
|
object logID = Guid.NewGuid(); |
|
|
|
string logsql = @"insert into ICSWMS_HGLog
|
|
|
|
values |
|
|
|
('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}')";
|
|
|
|
logsql = string.Format(logsql, logID, InspectJosn, "", WorkPoint, MUSER, MUSERNAME); |
|
|
|
SqlHelper.CmdExecuteNonQueryLi(logsql); |
|
|
|
#endregion
|
|
|
|
callresult = HTTPHelper.RestFulGet(InspectJosn, postUrlStr); |
|
|
|
#region 货柜接口调用后日志
|
|
|
|
logsql = @"update ICSWMS_HGLog set ReturnResult='{0}'
|
|
|
|
where ID='{1}'";
|
|
|
|
logsql = string.Format(logsql, callresult, logID); |
|
|
|
SqlHelper.CmdExecuteNonQueryLi(logsql); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
foreach (DataRow PickLog in table.Rows) |
|
|
|
{ |
|
|
|
pikTbLogsql += @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{9}' AND a.WorkPoint='{8}' AND a.Quantity>A.LockQuantity+'{3}')
|
|
|
|
BEGIN |
|
|
|
|
|
|
|
RAISERROR('条码{9}的库存可分配数量小于单据数量', 16, 1); |
|
|
|
RETURN |
|
|
|
END; |
|
|
|
IF NOT EXISTS(SELECT TransCode FROM ICSWareHouseLotInfoLog WHERE TransCode='{1}' AND TransSequence='{2}' AND LotNo='{9}' AND WorkPoint='{8}' AND TransType='15') |
|
|
|
BEGIN |
|
|
|
INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode, |
|
|
|
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity, |
|
|
|
Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID, |
|
|
|
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName, |
|
|
|
MTIME,WorkPoint,EATTRIBUTE1) |
|
|
|
SELECT NEWID(),'{0}','{1}','{2}',a.LotNo ,a.InvCode , |
|
|
|
a.WarehouseCode,a.LocationCode,'','','{3}', |
|
|
|
'','1','15','{4}','0','', |
|
|
|
'','','','{5}' ,'{6}' , |
|
|
|
'{7}' ,'{8}' ,'' |
|
|
|
FROM ICSWareHouseLotInfo a |
|
|
|
WHERE a.LotNo='{9}' AND a.WorkPoint='{8}' |
|
|
|
|
|
|
|
update ICSWareHouseLotInfo set LockQuantity=LockQuantity+'{3}' where LotNo='{9}' AND WorkPoint='{8}' |
|
|
|
END |
|
|
|
UPDATE ICSMOApply SET MUSER='{6}' WHERE ApplyCode='{1}' and Sequence='{2}' ; ";
|
|
|
|
pikTbLogsql = string.Format(pikTbLogsql, Identification, PickLog["Code"].ToString(), PickLog["Sequence"].ToString(), PickLog["SendQTY"].ToString() |
|
|
|
, BusinessCode, MUSER, MUSERNAME, pikTbLogTime, WorkPoint, PickLog["LotNO"].ToString()); |
|
|
|
} |
|
|
|
SqlHelper.CmdExecuteNonQueryLi(pikTbLogsql + updateString.ToString()); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
//查询有条码的拣料信息
|
|
|
|
if (!String.IsNullOrEmpty(sqlString)) |
|
|
|
{ |
|
|
|
var dataSet1 = Repository().FindDataSetBySql(sqlString); |
|
|
|
if (dataSet1.Tables[0].Rows.Count != 0) |
|
|
|
{ |
|
|
|
table1 = dataSet1.Tables[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
//if (table1 != null)
|
|
|
|
//{
|
|
|
|
// table.Merge(table1);
|
|
|
|
//}
|
|
|
|
//var result = ConvertCellToString(table);
|
|
|
|
//if (Invmes.Rows.Count > 0)
|
|
|
|
//{
|
|
|
|
// result.Merge(Invmes, false);
|
|
|
|
//}
|
|
|
|
//return result;
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new Exception(ex.Message); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(updateString.ToString())) |
|
|
|
{ |
|
|
|
SqlHelper.CmdExecuteNonQueryLi(updateString.ToString()); |
|
|
|
} |
|
|
|
//查询有条码的拣料信息
|
|
|
|
if (!String.IsNullOrEmpty(sqlString)) |
|
|
|
{ |
|
|
|
var dataSet1 = Repository().FindDataSetBySql(sqlString); |
|
|
|
if (dataSet1.Tables[0].Rows.Count != 0) |
|
|
|
{ |
|
|
|
table1 = dataSet1.Tables[0]; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (table1 != null && table != null) |
|
|
|
{ |
|
|
|
table.Merge(table1); |
|
|
|
} |
|
|
|
else if (table == null && table1 != null) |
|
|
|
{ |
|
|
|
table = table1; |
|
|
|
} |
|
|
|
else if (table1 == null && table ==null) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
var result = ConvertCellToString(table); |
|
|
|
if (Invmes.Rows.Count > 0) |
|
|
|
{ |
|
|
|
result.Merge(Invmes, false); |
|
|
|
} |
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (Type == "1") |
|
|
|
{ |
|
|
|
#region 工单备料sql
|
|
|
@ -1853,6 +2352,7 @@ a.Sequence, |
|
|
|
ICSTransfer a |
|
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint |
|
|
|
WHERE a.TransferNO in ({0}) AND a.WorkPoint = '{1}' AND ISNULL(a.Quantity, 0)>ISNULL(a.TransferQuantity, 0) |
|
|
|
and a.Memo is null |
|
|
|
GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID,a.Sequence";
|
|
|
|
#endregion
|
|
|
|
} |
|
|
@ -2200,6 +2700,12 @@ c.Sequence, |
|
|
|
{ |
|
|
|
throw new Exception(ex.Message); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|