|
|
@ -1677,7 +1677,9 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
DataTable table1 = null; |
|
|
|
DataTable table = null; |
|
|
|
StringBuilder updateString = new StringBuilder(); |
|
|
|
StringBuilder checklot = new StringBuilder(); |
|
|
|
string sqlString = String.Empty; |
|
|
|
List < LotMessage > lotMessages= new List<LotMessage>(); |
|
|
|
if (datasetModel.Tables[0].Rows.Count != 0) |
|
|
|
{ |
|
|
|
DataTable tableModel = datasetModel.Tables[0]; |
|
|
@ -1689,12 +1691,16 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
//循环验证条码信息是否与单据信息相符
|
|
|
|
for (int i = 0; i < tableModel.Rows.Count; i++) |
|
|
|
{ |
|
|
|
LotMessage lotMessage=new LotMessage(); |
|
|
|
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(); |
|
|
|
lotMessage.LotNo = lotNo; |
|
|
|
lotMessage.Quantity = Convert.ToDecimal(tableModel.Rows[i]["Quantity"].ToString()); |
|
|
|
lotMessages.Add(lotMessage); |
|
|
|
//验证信息
|
|
|
|
updateString.Append($@"IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo='{lotNo}' AND a.WorkPoint='{WorkPoint}')
|
|
|
|
checklot.Append($@"IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo='{lotNo}' AND a.WorkPoint='{WorkPoint}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('条码{lotNo},不存在',16,1); |
|
|
|
RETURN |
|
|
@ -1732,6 +1738,8 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
update ICSWareHouseLotInfo set LockQuantity=LockQuantity+'{tableModel.Rows[i]["Quantity"]}' where LotNo='{lotNo}' AND WorkPoint='{WorkPoint}';");
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SqlHelper.CmdExecuteNonQueryLi(checklot.ToString()); |
|
|
|
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,--应发数量 |
|
|
@ -1815,8 +1823,22 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
decimal qtyCount = 0; |
|
|
|
bool remove = false; |
|
|
|
List<int> removeList = new List<int>(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < table.Rows.Count; i++) |
|
|
|
{ |
|
|
|
if (lotMessages!=null && lotMessages.Count>0) |
|
|
|
{ |
|
|
|
//排除指定条码的锁定库存数量
|
|
|
|
List<LotMessage> models= lotMessages.Where(e => e.LotNo == table.Rows[i]["LotNO"].ToString()).ToList(); |
|
|
|
if (models!=null&& models.Count>0) |
|
|
|
{ |
|
|
|
decimal quantity= models.Select(e => e.Quantity).ToList().Sum(); |
|
|
|
table.Rows[i]["QTYLeft"] = table.Rows[i]["QTYLeft"].ToString().ToDecimal() - quantity; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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()) |
|
|
@ -1878,44 +1900,13 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
{ |
|
|
|
#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
|
|
|
|
|
|
|
|
#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
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
chksql = string.Format(chksql, ID, WorkPoint); |
|
|
|
var chkdata = Repository().FindDataSetBySql(chksql); |
|
|
|
DataTable chktable = chkdata.Tables[0]; |
|
|
@ -1953,14 +1944,8 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
{ |
|
|
|
#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 BusinessCode = "10"; |
|
|
|
string TransType = "调拨申请单"; |
|
|
|
string Identification = Guid.NewGuid().ToString(); |
|
|
|
var pikTbLogTime = DateTime.Now; |
|
|
|
string pikTbLogsql = string.Empty; |
|
|
@ -2120,13 +2105,13 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
throw new Exception(ex.Message); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(updateString.ToString())) |
|
|
|
{ |
|
|
|
SqlHelper.CmdExecuteNonQueryLi(updateString.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
//查询有条码的拣料信息
|
|
|
|
if (!String.IsNullOrEmpty(sqlString)) |
|
|
|
{ |
|
|
@ -2135,7 +2120,7 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
{ |
|
|
|
table1 = dataSet1.Tables[0]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -2149,7 +2134,7 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
{ |
|
|
|
table = table1; |
|
|
|
} |
|
|
|
else if (table1 == null && table ==null) |
|
|
|
else if (table1 == null && table == null) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
@ -3858,6 +3843,12 @@ b.InvUnit, |
|
|
|
return Repository().FindTableBySql(sql.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
public class LotMessage |
|
|
|
{ |
|
|
|
public string LotNo { get; set; } |
|
|
|
public decimal Quantity { get; set; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|