|
|
@ -1679,7 +1679,7 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
StringBuilder updateString = new StringBuilder(); |
|
|
|
StringBuilder checklot = new StringBuilder(); |
|
|
|
string sqlString = String.Empty; |
|
|
|
List < LotMessage > lotMessages= new List<LotMessage>(); |
|
|
|
List<LotMessage> lotMessages = new List<LotMessage>(); |
|
|
|
if (datasetModel.Tables[0].Rows.Count != 0) |
|
|
|
{ |
|
|
|
DataTable tableModel = datasetModel.Tables[0]; |
|
|
@ -1691,7 +1691,7 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo |
|
|
|
//循环验证条码信息是否与单据信息相符
|
|
|
|
for (int i = 0; i < tableModel.Rows.Count; i++) |
|
|
|
{ |
|
|
|
LotMessage lotMessage=new LotMessage(); |
|
|
|
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(); |
|
|
@ -1823,22 +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) |
|
|
|
{ |
|
|
|
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) |
|
|
|
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(); |
|
|
|
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()) |
|
|
@ -2536,6 +2536,9 @@ a.Sequence, |
|
|
|
if (table.Rows.Count != 0) |
|
|
|
{ |
|
|
|
#region 拣料时增加条码出入库记录,修改库存锁定数量,以作占料处理
|
|
|
|
string ccInspectJosn = ""; |
|
|
|
string ForkLiftUrl = System.Configuration.ConfigurationManager.AppSettings["ForkLiftUrl"]; |
|
|
|
string cclogsql = @""; |
|
|
|
int Count = 1; |
|
|
|
string BusinessCode = string.Empty; |
|
|
|
string TransType = ""; |
|
|
@ -2549,103 +2552,149 @@ a.Sequence, |
|
|
|
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 ccsql = @"select B.F_Id 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}' AND B.F_ItemCode Like 'ForkLiftAreaConfig%'";
|
|
|
|
ccsql = string.Format(ccsql, table.Rows[0]["InvCode"].ToString(), table.Rows[0]["WarehouseCode"].ToString() |
|
|
|
, WorkPoint); |
|
|
|
var ccds = Repository().FindDataSetBySql(ccsql); |
|
|
|
DataTable cctable = ccds.Tables[0]; |
|
|
|
if (cctable.Rows.Count != 0) |
|
|
|
{ |
|
|
|
List<string> SourceBinList = new List<string>(); |
|
|
|
#region 窄巷道
|
|
|
|
foreach (DataRow dr in table.Rows) |
|
|
|
{ |
|
|
|
if (!SourceBinList.Contains(dr["LocationCode"].ToString())) |
|
|
|
{ |
|
|
|
SourceBinList.Add(dr["LocationCode"].ToString()); |
|
|
|
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadForkLift"])) |
|
|
|
{ |
|
|
|
string Year = DateTime.Now.Year.ToString(); |
|
|
|
string Month = DateTime.Now.Month.ToString().PadLeft(2, '0'); |
|
|
|
string Day = DateTime.Now.Day.ToString().PadLeft(2, '0'); |
|
|
|
string Pre = "CC" + Year + Month + Day; |
|
|
|
string serialsql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}"; |
|
|
|
serialsql = string.Format(serialsql, "1701", "ICSForkLiftTaskLog", "TaskCode", Pre, 4); |
|
|
|
string TaskCode = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, serialsql, true, null).Rows[0][0].ToString(); |
|
|
|
string SerialNum = DateTime.Now.Hour.ToString().PadLeft(2, '0'); |
|
|
|
ccInspectJosn += "{"; |
|
|
|
ccInspectJosn += "\"ID\":\"" + TaskCode + "\",";//任务编号
|
|
|
|
ccInspectJosn += "\"TaskType\": \"PTWY\",";//任务类型
|
|
|
|
ccInspectJosn += "\"SourceBin\": \"" + dr["LocationCode"].ToString() + "\",";//起始点位
|
|
|
|
ccInspectJosn += "}"; |
|
|
|
#region 记录叉车的任务编号及相关信息
|
|
|
|
#endregion
|
|
|
|
cclogsql += @"INSERT INTO ICSForkLiftTaskLog
|
|
|
|
(ID,TaskCode,ContainerCode,TaskType,StartLocation,EndLocation,MTIME,WorkPoint) |
|
|
|
select NEWID(),'{0}','','PICK','{1}','',GETDATE(),'1701'";
|
|
|
|
cclogsql = string.Format(cclogsql, TaskCode, dr["LocationCode"].ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
string hgsql = @"select A.InvCode,A.LocationCode,B.F_Define3,C.LocationCode AS Area
|
|
|
|
#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 |
|
|
|
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 (table.Rows[i]["Code"].ToString() == table.Rows[i - 1]["Code"].ToString() && |
|
|
|
table.Rows[i]["Sequence"].ToString() == table.Rows[i - 1]["Sequence"].ToString()) |
|
|
|
if (!DocNoList.Contains(table.Rows[i]["Code"].ToString())) |
|
|
|
{ |
|
|
|
InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + Count.ToString() + "\""; |
|
|
|
Count++; |
|
|
|
DocNoList.Add(table.Rows[i]["Code"].ToString()); |
|
|
|
} |
|
|
|
else |
|
|
|
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() + "\""; |
|
|
|
Count = 1; |
|
|
|
} |
|
|
|
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 = 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"])) |
|
|
|
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 != "") |
|
|
|
{ |
|
|
|
string callresult = ""; |
|
|
|
#region 货柜接口调用前日志
|
|
|
|
object logID = Guid.NewGuid(); |
|
|
|
string logsql = @"insert into ICSWMS_HGLog
|
|
|
|
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}'
|
|
|
|
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
|
|
|
|
logsql = string.Format(logsql, callresult, logID); |
|
|
|
SqlHelper.CmdExecuteNonQueryLi(logsql); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
foreach (DataRow PickLog in table.Rows) |
|
|
|
{ |
|
|
@ -2670,7 +2719,7 @@ a.Sequence, |
|
|
|
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); |
|
|
|
CmdExecuteNonQueryWithAPI(pikTbLogsql, cclogsql, ccInspectJosn, ForkLiftUrl); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
@ -3850,7 +3899,62 @@ b.InvUnit, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//事务中执行SQL及调用接口
|
|
|
|
public static int CmdExecuteNonQueryWithAPI(string sql, string ccsql, string InputJson, string PostUrl, params SqlParameter[] spArr) |
|
|
|
{ |
|
|
|
using (SqlConnection conn = SqlHelper.GetDataCenterConn()) |
|
|
|
{ |
|
|
|
conn.Open(); |
|
|
|
SqlTransaction sqlTran = conn.BeginTransaction(); |
|
|
|
SqlCommand cmd = new SqlCommand(); |
|
|
|
cmd.Transaction = sqlTran; |
|
|
|
cmd.Connection = conn; |
|
|
|
try |
|
|
|
{ |
|
|
|
if (ccsql == "") |
|
|
|
{ |
|
|
|
cmd.CommandText = sql; |
|
|
|
int RES = cmd.ExecuteNonQuery(); |
|
|
|
cmd.Transaction.Commit(); |
|
|
|
return RES; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmd.CommandText = sql; |
|
|
|
int RES = cmd.ExecuteNonQuery(); |
|
|
|
cmd.CommandText = ccsql; |
|
|
|
RES = cmd.ExecuteNonQuery(); |
|
|
|
#region 叉车接口调用(写进事务中,报错可以回滚,保证数据正确)
|
|
|
|
string rest = HTTPHelper.HttpPost("WMS调用叉车接口出库", PostUrl, InputJson); |
|
|
|
ForkLiftResult result = JsonConvert.DeserializeObject<ForkLiftResult>(rest); |
|
|
|
if (result.Ret == 1) |
|
|
|
{ |
|
|
|
cmd.Transaction.Commit(); |
|
|
|
return RES; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new Exception(result.RetMsg); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
cmd.Transaction.Rollback(); |
|
|
|
throw new Exception(ex.Message); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
if (conn.State != ConnectionState.Closed) |
|
|
|
{ |
|
|
|
conn.Close(); |
|
|
|
conn.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|