陆晔 2 years ago
parent
commit
724a43a476
  1. 427
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs
  2. 21
      ICSSoft.WMS.WebAPI/ICSSoft.Entity/ForkLiftStartTaskModel.cs
  3. 4
      ICSSoft.WMS.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj
  4. 34
      ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs

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

@ -2890,15 +2890,24 @@ namespace ICSSoft.DataProject
RETURN
END
IF NOT EXISTS (SELECT * FROM ICSContainerLot WHERE ContainerID=
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}'))
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}') AND LotNo='{0}')
BEGIN
update ICSContainer set LocationCode='{4}',EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
-- update ICSContainer set EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
INSERT INTO ICSContainerLot
(ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME,EATTRIBUTE1)
SELECT NEWID(),ID,'{0}','{3}'
,(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}'),'{2}',GETDATE(),'{4}' FROM ICSContainer
,(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}'),'{2}',GETDATE(),'' FROM ICSContainer
WHERE ContainerCode='{1}' AND WorkPoint='{2}'
END
ELSE
BEGIN
update ICSContainer set LocationCode='{4}',EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
UPDATE ICSContainerLot SET LotNo='{0}' WHERE ContainerID=
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')
END
-- ELSE
-- BEGIN
-- update ICSContainer set LocationCode='{4}',EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
@ -2962,7 +2971,7 @@ namespace ICSSoft.DataProject
rest.PostData = InspectJosn;
string strResult = rest.MakeRequest();
//string resultstr = HTTPHelper.Post(ERPUrl.AGVBineURL, InspectJosn);
ForkLiftStartTaskResultModel result = JsonConvert.DeserializeObject<ForkLiftStartTaskResultModel>(strResult);
ForkLiftResult result = JsonConvert.DeserializeObject<ForkLiftResult>(strResult);
if (result.Ret == 1)
{
sql = @"update ICSContainer set LocationCode='{2}',EATTRIBUTE1='已搬运' where ContainerCode='{0}' AND WorkPoint='{1}'";
@ -3299,11 +3308,31 @@ namespace ICSSoft.DataProject
if (OverLoad == false)
{
#region 正常入库
#region 获取已被超托入库占用的库位
string LocationIsTaken = "";
sql = @"SELECT A.EATTRIBUTE1 FROM ICSLocation A
INNER JOIN ICSWareHouseLotInfo B ON B.LocationCode=A.LocationCode AND B.WorkPoint=A.WorkPoint AND B.Quantity>0
WHERE ISNULL(A.EATTRIBUTE1,'')!='' AND A.LocationCode like ('{0}'+'-'+'{1}%')";
sql = string.Format(sql, InWHCode, InLocationCode);
dt = DBHelper.SQlReturnData(sql, cmd);
foreach (DataRow dr in dt.Rows)
{
if (LocationIsTaken == "")
{
LocationIsTaken += "'" + dr["EATTRIBUTE1"].ToString().Split(',')[0] + "','" + dr["EATTRIBUTE1"].ToString().Split(',')[1] + "'";
}
else
{
LocationIsTaken += ",'" + dr["EATTRIBUTE1"].ToString().Split(',')[0] + "','" + dr["EATTRIBUTE1"].ToString().Split(',')[1] + "'";
}
}
#endregion
sql = @"select TOP 1 A.LocationCode from ICSLocation A
LEFT JOIN ICSWareHouseLotInfo B ON B.LocationCode=A.LocationCode AND B.WorkPoint=A.WorkPoint AND B.Quantity>0
where B.LocationCode IS NULL AND A.LocationCode like ('{0}'+'-'+'{1}%')
where B.LocationCode IS NULL AND A.LocationCode like ('{0}'+'-'+'{1}%') AND ISNULL(A.EATTRIBUTE1,'')=''
AND A.LocationCode NOT IN ({2})
ORDER BY A.LocationCode";
sql = string.Format(sql, InWHCode, InLocationCode);
sql = string.Format(sql, InWHCode, InLocationCode, LocationIsTaken);
dt = DBHelper.SQlReturnData(sql, cmd);
if (dt.Rows.Count == 0)
{
@ -3327,23 +3356,25 @@ namespace ICSSoft.DataProject
InspectJosn += "\"PalletID\": \"" + ContainerCode + "\",";//料架号
//InspectJosn += "\"LaneCode\": \"\",";
InspectJosn += "\"TaskType\": \"PTWY\",";//任务类型
InspectJosn += "\"SourceBin\": \""+ currentPositionCode + "\",";//起始点位
InspectJosn += "\"SourceBin\": \"" + currentPositionCode + "\",";//起始点位
InspectJosn += "\"DestBin\": \"" + dt.Rows[0]["LocationCode"].ToString() + "\"";//目标点位
InspectJosn += "}";
RestHelper rest = new RestHelper(ForkLiftUrl, HttpVerb.POST);
rest.PostData = InspectJosn;
string strResult = rest.MakeRequest();
//string resultstr = HTTPHelper.Post(ERPUrl.AGVBineURL, InspectJosn);
ForkLiftStartTaskResultModel result = JsonConvert.DeserializeObject<ForkLiftStartTaskResultModel>(strResult);
ForkLiftResult result = JsonConvert.DeserializeObject<ForkLiftResult>(strResult);
if (result.Ret == 1)
{
#region 记录叉车的任务编号及相关信息
#endregion
sql = @"update ICSContainer set LocationCode='{2}',EATTRIBUTE1='已搬运' where ContainerCode='{0}' AND WorkPoint='{1}'";
//sql = string.Format(sql, ContainerCode, WorkPoint, LocationCode);
sql = @"INSERT INTO ICSForkLiftTaskLog
(ID,TaskCode,ContainerCode,TaskType,StartLocation,EndLocation,MTIME,WorkPoint)
select NEWID(),'{0}','{1}','PTWY','{2}','{3}',GETDATE(),'1701'";
sql = string.Format(sql, TaskCode, ContainerCode, currentPositionCode, dt.Rows[0]["LocationCode"].ToString());
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo207"));//料架状态更新失败
//throw new Exception("任务编码:" + TaskCode + ",日志记录失败");//料架状态更新失败
}
}
else
@ -3354,6 +3385,97 @@ namespace ICSSoft.DataProject
}
#endregion
}
else
{
#region 超托入库
#region 获取已被正常入库占用的库位
string LocationIsTaken = "";
sql = @"SELECT A.LocationCode,A.WorkPoint INTO #tempLocation FROM ICSLocation A
INNER JOIN ICSWareHouseLotInfo B ON B.LocationCode=A.LocationCode AND B.WorkPoint=A.WorkPoint AND B.Quantity>0
WHERE ISNULL(A.EATTRIBUTE1,'') = '' AND A.LocationCode like ('{0}'+'-'+'{1}%')
SELECT * INTO #tempOverLoad FROM ICSLocationOverLoad WHERE LocationCode like ('{0}'+'-'+'{1}%')
select Distinct A.OverLoadLocationCode from #tempOverLoad A
INNER JOIN #tempLocation B ON B.LocationCode=A.LocationCode AND B.WorkPoint=A.WorkPoint
drop table #tempLocation
drop table #tempOverLoad";
sql = string.Format(sql, InWHCode, InLocationCode);
dt = DBHelper.SQlReturnData(sql, cmd);
foreach (DataRow dr in dt.Rows)
{
if (LocationIsTaken == "")
{
LocationIsTaken += "'" + dr["OverLoadLocationCode"].ToString() + "'";
}
else
{
LocationIsTaken += ",'" + dr["OverLoadLocationCode"].ToString() + "'";
}
}
#endregion
sql = @"select TOP 1 A.LocationCode from ICSLocation A
LEFT JOIN ICSWareHouseLotInfo B ON B.LocationCode=A.LocationCode AND B.WorkPoint=A.WorkPoint AND B.Quantity>0
where B.LocationCode IS NULL AND A.LocationCode like ('{0}'+'-'+'{1}%') AND ISNULL(A.EATTRIBUTE1,'')!=''
AND A.LocationCode NOT IN ({2})
ORDER BY A.LocationCode";
sql = string.Format(sql, InWHCode, InLocationCode, LocationIsTaken);
dt = DBHelper.SQlReturnData(sql, cmd);
if (dt.Rows.Count == 0)
{
throw new Exception("仓库:" + InWHCode + ",区域:" + InLocationCode + "无可用库位,无法入库!");
}
else
{
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadForkLift"]))
{
string ForkLiftUrl = System.Configuration.ConfigurationManager.AppSettings["ForkLiftUrl"];
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.SQlReturnData(serialsql, cmd).Rows[0][0].ToString();
string SerialNum = DateTime.Now.Hour.ToString().PadLeft(2, '0');
string InspectJosn = "{";
InspectJosn += "\"ID\":\"" + TaskCode + "\",";//任务编号
InspectJosn += "\"PalletID\": \"" + ContainerCode + "\",";//料架号
//InspectJosn += "\"LaneCode\": \"\",";
InspectJosn += "\"TaskType\": \"PTWY\",";//任务类型
InspectJosn += "\"SourceBin\": \"" + currentPositionCode + "\",";//起始点位
InspectJosn += "\"DestBin\": \"" + dt.Rows[0]["LocationCode"].ToString() + "\"";//目标点位
InspectJosn += "}";
RestHelper rest = new RestHelper(ForkLiftUrl, HttpVerb.POST);
rest.PostData = InspectJosn;
string strResult = rest.MakeRequest();
//string resultstr = HTTPHelper.Post(ERPUrl.AGVBineURL, InspectJosn);
ForkLiftResult result = JsonConvert.DeserializeObject<ForkLiftResult>(strResult);
if (result.Ret == 1)
{
#region 记录叉车的任务编号及相关信息
sql = @"INSERT INTO ICSForkLiftTaskLog
(ID,TaskCode,ContainerCode,TaskType,StartLocation,EndLocation,MTIME,WorkPoint)
select NEWID(),'{0}','{1}','PTWY','{2}','{3}',GETDATE(),'1701'
Update ICSAGVCallBackLog set Result='',Message=''
where ReqCode='{4}'";
sql = string.Format(sql, TaskCode, ContainerCode, currentPositionCode, dt.Rows[0]["LocationCode"].ToString(), reqCode);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
//throw new Exception("任务编码:" + TaskCode + ",日志记录失败");//料架状态更新失败
}
#endregion
}
else
{
throw new Exception(result.RetMsg);
}
}
}
#endregion
}
#endregion
}
#endregion
@ -3366,96 +3488,239 @@ namespace ICSSoft.DataProject
}
}
/// <summary>
/// 料架单据绑定
/// 叉车搬运完成回调
/// </summary>
/// <param name="LotNo"></param>
/// <param name="ContainerCode"></param>
/// <param name="User"></param>
/// <param name="WorkPoint"></param>
/// <param name="TaskID"></param>
/// <param name="cmd"></param>
/// <param name="language"></param>
public static void ContainerTransCodeBind(List<string> tranCodes, string containerCode, string User, SqlCommand cmd, Dictionary<string, string> language)
public static void ActionForkLiftTaskEnd(string TaskID, SqlCommand cmd, Dictionary<string, string> language)
{
try
{
string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{1}' )
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{1}") + @"',16,1);
RETURN
END
IF NOT EXISTS(SELECT ID FROM ICSContainer WHERE ContainerCode='{0}' )
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo473"), "", "{0}") + @"',16,1);
RETURN
END;
SELECT top 1 Desks FROM ICSMOApply WHERE ApplyCode='{2}'
";
sql = string.Format(sql, containerCode, User, tranCodes.FirstOrDefault());
#region 获取任务ID相关的料架条码及目标库位信息
string ContainerCode = "";
string StartLocation = "";
string EndLocation = "";
string sql = @"select ContainerCode,StartLocation,EndLocation from ICSForkLiftTaskLog
where TaskCode='{0}'";
sql = string.Format(sql, TaskID);
DataTable dt = DBHelper.SQlReturnData(sql, cmd);
if (dt.Rows.Count == 0)
{
throw new Exception("任务ID:" + TaskID + ",未查询到相关任务记录,无法入库!");
}
else
{
ContainerCode = dt.Rows[0]["ContainerCode"].ToString();
StartLocation = dt.Rows[0]["StartLocation"].ToString();
EndLocation = dt.Rows[0]["EndLocation"].ToString();
}
#endregion
var table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count<=0)
#region 根据条码获取入库单据信息
string chksql = @"select COUNT(B.LotNo) AS LotCount from ICSContainer A
INNER JOIN ICSContainerLot B ON B.ContainerID=A.ContainerID AND B.WorkPoint=A.WorkPoint
WHERE ContainerCode='{0}'";
chksql = string.Format(chksql, ContainerCode);
DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
sql = @"select E.DNCode AS TransNO,E.Sequence AS TransLine,C.LotNo,C.Quantity,'采购入库' AS DocType
,A.WorkPoint,C.InvCode from ICSContainer A
INNER JOIN ICSContainerLot B ON B.ContainerID=A.ContainerID AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryLot C ON C.LotNo=B.LotNo AND C.WorkPoint=B.WorkPoint
INNER JOIN ICSInventoryLotDetail D ON D.LotNo=C.LotNo AND D.WorkPoint=C.WorkPoint
INNER JOIN ICSDeliveryNotice E ON E.DNCode=D.TransCode AND E.Sequence=D.TransSequence AND E.WorkPoint=D.WorkPoint
where A.ContainerCode='{0}'
UNION ALL
select E.ApplyNegCode AS TransNO,E.Sequence AS TransLine,C.LotNo,C.Quantity,'退' AS DocType
,A.WorkPoint,C.InvCode from ICSContainer A
INNER JOIN ICSContainerLot B ON B.ContainerID=A.ContainerID AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryLot C ON C.LotNo=B.LotNo AND C.WorkPoint=B.WorkPoint
INNER JOIN ICSInventoryLotDetail D ON D.LotNo=C.LotNo AND D.WorkPoint=C.WorkPoint
INNER JOIN ICSMOApplyNegDetail E ON E.ApplyNegCode=D.TransCode AND E.Sequence=D.TransSequence AND E.WorkPoint=D.WorkPoint
where A.ContainerCode='{0}'";
sql = string.Format(sql, ContainerCode);
dt = DBHelper.SQlReturnData(sql, cmd);
if (chkdt.Rows.Count != dt.Rows.Count)
{
throw new Exception("料架:" + ContainerCode + ",绑定条码的数量与实际查到的条码单据关联数据不符,请确认条码信息!");
}
#endregion
else
{
throw new Exception("单据对应的工位不存在,操作失败");
#region WMS入库
string Identification = Guid.NewGuid().ToString();
string BusinessCode = string.Empty;
foreach (DataRow dr in dt.Rows)
{
if (dr["DocType"].ToString() == "采购入库")
{
#region 采购入库
ICSPurchaseService.DeliveryNoticeIn(dr["LotNo"].ToString(), dr["Quantity"].ToString(), dr["WorkPoint"].ToString(), cmd, language);
BusinessCode = TransTypeEnum.DeliveryNotice.GetDescription<DBValue>();
#endregion
}
else
{
#region 生产退料入库
ICSManufactureService.MOIssueDocNegative(TransTypeEnum.MOIssueDocNegativeApply.GetDescription()
, "", dr["LotNo"].ToString(), dr["Quantity"].ToString(), dr["WorkPoint"].ToString(), cmd, language);
BusinessCode = TransTypeEnum.MOIssueDocNegative.GetDescription<DBValue>();
#endregion
}
WareHouseLotInfoUp(Identification, EndLocation, dr["LotNo"].ToString(), dr["Quantity"].ToString(),
"ForkLift", dr["WorkPoint"].ToString(), "2", BusinessCode
, cmd, language, "", dr["InvCode"].ToString() + EndLocation.Split('-')[0].ToString()
, DateTime.Now.ToString());
}
#endregion
}
foreach (string tranCode in tranCodes)
#region 判断单据是否全部完成入库,并过账SAP
string docsql = @"select DISTINCT E.DNCode AS TransNO,'采购入库' AS DocType,A.WorkPoint from ICSContainer A
INNER JOIN ICSContainerLot B ON B.ContainerID=A.ContainerID AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryLot C ON C.LotNo=B.LotNo AND C.WorkPoint=B.WorkPoint
INNER JOIN ICSInventoryLotDetail D ON D.LotNo=C.LotNo AND D.WorkPoint=C.WorkPoint
INNER JOIN ICSDeliveryNotice E ON E.DNCode=D.TransCode AND E.Sequence=D.TransSequence AND E.WorkPoint=D.WorkPoint
where A.ContainerCode='{0}'
UNION ALL
select DISTINCT E.ApplyNegCode AS TransNO,'退' AS DocType,A.WorkPoint from ICSContainer A
INNER JOIN ICSContainerLot B ON B.ContainerID=A.ContainerID AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryLot C ON C.LotNo=B.LotNo AND C.WorkPoint=B.WorkPoint
INNER JOIN ICSInventoryLotDetail D ON D.LotNo=C.LotNo AND D.WorkPoint=C.WorkPoint
INNER JOIN ICSMOApplyNegDetail E ON E.ApplyNegCode=D.TransCode AND E.Sequence=D.TransSequence AND E.WorkPoint=D.WorkPoint
where A.ContainerCode='{0}'";
docsql = string.Format(docsql, ContainerCode);
DataTable docdt = DBHelper.SQlReturnData(sql, cmd);
foreach (DataRow dr in docdt.Rows)
{
string sqlCheck = @"IF NOT EXISTS(select ID from ICSWareHouseLotInfoLog where TransType='15' AND TransCode='{0}')
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo478") + @"',16,1);
RETURN
END;
IF NOT EXISTS( SELECT ID FROM ICSMOApply WHERE ApplyCode='{0}' AND Desks='{1}')
BEGIN
RAISERROR('"+language.GetNameByCode("WMSAPIInfo477") + @"',16,1);
RETURN
END;
IF EXISTS(select ID from ICSContainerReceiptsNumber where ContainerCode='{2}' AND TransCode='{0}')
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo479"), "{0}","{2}") + @"',16,1);
RETURN
END;
INSERT INTO ICSContainerReceiptsNumber SELECT NEWID(),'{0}','{2}',F_Account,F_RealName,GETDATE(),NULL,NULL,NULL,NULL,NULL FROM Sys_SRM_User WHERE F_Account='{3}' ";
sqlCheck= string.Format(sqlCheck, tranCode, table.Rows[0]["Desks"].ToString(),containerCode, User);
if (!DBHelper.ExecuteNonQuery(sqlCheck, cmd))
if (dr["DocType"].ToString() == "采购入库")
{
throw new Exception("单据新增失败");
#region 检验合格单过账SAP(检验合格单为两层结构 一行对应一个序列号)
chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSDeliveryNotice
where DNCode='{0}' and WorkPoint='{1}'
GROUP BY DNCode,WorkPoint";
chksql = string.Format(chksql, dr["TransNO"].ToString(), dr["WorkPoint"].ToString());
chkdt = DBHelper.SQlReturnData(chksql, cmd);
if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"]))
{
continue;
}
sql = @"select A.DNCode,
CASE WHEN SUM(Convert(decimal(18,6),A.SAPSequence)) IS NULL THEN SUM(A.RCVQuantity)
ELSE SUM(Convert(decimal(18,6),A.SAPSequence)) END AS RCVQuantity,B.BatchCode from ICSDeliveryNotice A
LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
WHERE DNCode='{0}' AND A.WorkPoint='{1}'
GROUP BY A.DNCode,B.BatchCode";
sql = string.Format(sql, dr["TransNO"].ToString(), dr["WorkPoint"].ToString());
DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
if (Sapdt.Rows.Count == 0)
{
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo205"), dr["TransNO"].ToString()));//单据查询失败
}
SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU Client = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU();
SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU1 Info = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKU1();
Info.NEWID = Guid.NewGuid().ToString();
Info.PRUEFLOS = Sapdt.Rows[0]["DNCode"].ToString();
Info.L_LME = System.Decimal.Round(Convert.ToDecimal(Sapdt.Rows[0]["RCVQuantity"].ToString()), 3);
Info.SERNP = Sapdt.Rows[0]["BatchCode"].ToString();
Info.Z_GERNR = new SAPCallBackJYHGDVPN.ZWEBS_GERNR[0];
SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKUResponse result = new SAPCallBackJYHGDVPN.ZWMS_SK_WS_RUKUResponse();
result = Client.CallZWMS_SK_WS_RUKU(Info);
if (result.Z_NULL == "N")
{
string logsql = @"insert into ICSWMSCallSAPErrorLog
(ID,DocType,DocNO,WorkPoint,MTIME,WorkType,EATTRIBUTE1)
Select NEWID(),'{0}','{1}','{2}',GETDATE(),'','{3}'";
logsql = string.Format(logsql, "采购入库", dr["TransNO"].ToString(), dr["WorkPoint"].ToString()
, result.L_MESSAGE);
DBHelper.ExecuteNonQuery(logsql, cmd);
}
#endregion
}
else
{
#region SAP(三层结构)
string ErrorMessage = "";
chksql = @"select SUM(B.Quantity) AS Quantity,SUM(B.IssueNegQuantity) AS IssueQuantity from ICSMOApplyNeg A
LEFT JOIN ICSMOApplyNegDetail B ON B.ApplyNegCode=A.ApplyNegCode AND B.WorkPoint=A.WorkPoint
where A.ApplyNegCode='{0}' and A.WorkPoint='{1}'
GROUP BY A.ApplyNegCode,A.WorkPoint";
chksql = string.Format(chksql, dr["TransNO"].ToString(), dr["WorkPoint"].ToString());
chkdt = DBHelper.SQlReturnData(chksql, cmd);
if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) == Convert.ToDecimal(chkdt.Rows[0]["IssueQuantity"]))
{
SAPCallBackDocVPN.ZWMS_SK_WS_PZ Client = new SAPCallBackDocVPN.ZWMS_SK_WS_PZ();
SAPCallBackDocVPN.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDocVPN.ZWMS_SK_WS_PZ1();
Info.NEWID = Guid.NewGuid().ToString();
Info.DANJU = dr["TransNO"].ToString();
Info.STATE = "0";
List<SAPCallBackDocVPN.ZWMS_PZ> ItemList = new List<SAPCallBackDocVPN.ZWMS_PZ>();
List<SAPCallBackDocVPN.ZWEBS_GERNR> ItemLineList = new List<SAPCallBackDocVPN.ZWEBS_GERNR>();
Info.Z_FLAG = new SAPCallBackDocVPN.ZWEB_RETURN[1];
sql = @" select A.ApplyNegCode,B.SAPSequence,B.InvCode,B.Sequence,B.Quantity,B.IssueNegQuantity
,ISNULL(C.BatchCode,'') AS BatchCode from ICSMOApplyNeg A
LEFT JOIN ICSMOApplyNegDetail B ON B.ApplyNegCode=A.ApplyNegCode AND B.WorkPoint=A.WorkPoint
LEFT JOIN ICSExtension C ON C.ID=B.ExtensionID AND C.WorkPoint=B.WorkPoint
WHERE A.ApplyNegCode='{0}' AND A.WorkPoint='{1}'";
sql = string.Format(sql, dr["TransNO"].ToString(), dr["WorkPoint"].ToString());
DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
foreach (DataRow drs in Sapdt.Rows)
{
if (Convert.ToDecimal(drs["Quantity"].ToString()) == Convert.ToDecimal(drs["IssueNegQuantity"].ToString()))
{
SAPCallBackDocVPN.ZWMS_PZ Item = new SAPCallBackDocVPN.ZWMS_PZ();
SAPCallBackDocVPN.ZWEBS_GERNR ItemLine = new SAPCallBackDocVPN.ZWEBS_GERNR();
Item.DANJU = drs["ApplyNegCode"].ToString();
Item.POSNR = drs["SAPSequence"].ToString();
Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(drs["Quantity"].ToString()), 3);
ItemList.Add(Item);
if (drs["BatchCode"].ToString() != "")
{
ItemLine.DANJU = drs["ApplyNegCode"].ToString();
ItemLine.POSNR = drs["SAPSequence"].ToString();
ItemLine.MATNR = drs["InvCode"].ToString();
ItemLine.GERNR = drs["BatchCode"].ToString();
ItemLineList.Add(ItemLine);
}
}
}
if (ItemList.Count > 0)
{
Info.Z_ITEM = ItemList.ToArray();
if (ItemLineList.Count > 0)
{
Info.Z_GERNR = ItemLineList.ToArray();
}
else
{
Info.Z_GERNR = new SAPCallBackDocVPN.ZWEBS_GERNR[1];
}
SAPCallBackDocVPN.ZWMS_SK_WS_PZResponse result = new SAPCallBackDocVPN.ZWMS_SK_WS_PZResponse();
result = Client.CallZWMS_SK_WS_PZ(Info);
if (result.Z_NULL == "N")
{
foreach (SAPCallBackDocVPN.ZWEB_RETURN resultItem in result.Z_FLAG)
{
ErrorMessage += resultItem.L_MESSAGE + "/r/n";
}
string logsql = @"insert into ICSWMSCallSAPErrorLog
(ID,DocType,DocNO,WorkPoint,MTIME,WorkType,EATTRIBUTE1)
Select NEWID(),'{0}','{1}','{2}',GETDATE(),'','{3}'";
logsql = string.Format(logsql, "生产退料", dr["TransNO"].ToString(), dr["WorkPoint"].ToString()
, ErrorMessage);
DBHelper.ExecuteNonQuery(logsql, cmd);
}
}
}
#endregion
}
}
#endregion
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 根据条码获取仓库和区域信息
/// </summary>
/// <param name="LotNo"></param>
/// <param name="cmd"></param>
public static DataTable GetWHCodeArea(string LotNo,SqlCommand cmd)
{
try
{
string check = $@"SELECT C.WHCode,C.LocationCode FROM ICSInventoryLotDetail A
INNER JOIN ICSDeliveryNotice B ON B.DNCode=A.TransCode AND B.Sequence=A.TransSequence AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryDetail C ON C.INVCode=B.InvCode AND C.WHCode=B.WHCode AND C.WorkPoint=B.WorkPoint
WHERE A.LotNo='{LotNo}'
UNION ALL
SELECT C.WHCode,C.LocationCode FROM ICSInventoryLotDetail A
INNER JOIN ICSMOApplyNegDetail B ON B.ApplyNegCode=A.TransCode AND B.Sequence=A.TransSequence AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryDetail C ON C.INVCode=B.InvCode AND C.WHCode=B.WHCode AND C.WorkPoint=B.WorkPoint
WHERE A.LotNo='{LotNo}'";
var table = DBHelper.SQlReturnData(check, cmd);
return table;
}
catch (Exception ex)
{
throw ex;
throw new Exception(ex.Message);
}
}
}
}

21
ICSSoft.WMS.WebAPI/ICSSoft.Entity/ForkLiftStartTaskModel.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ICSSoft.Entity
{
public class ForkLiftStartTaskResultModel
{
/// <summary>
/// 结果编码(0:成功)
/// </summary>
public int Ret { get; set; }
/// <summary>
/// 返回信息
/// </summary>
public string RetMsg { get; set; }
}
}

4
ICSSoft.WMS.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj

@ -53,9 +53,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ForkLiftCallBackModel.cs" />
<Compile Include="AGVResult.cs" />
<Compile Include="BarCodeCheckModel.cs" />
<Compile Include="ForkLiftStartTaskModel.cs" />
<Compile Include="ForkLiftResult.cs" />
<Compile Include="AGVStartTaskModel.cs" />
<Compile Include="BarCodeModel.cs" />
<Compile Include="ControlMode.cs" />
@ -67,7 +68,6 @@
<Compile Include="AGVCallBackModel.cs" />
<Compile Include="ICSContainerInfo.cs" />
<Compile Include="ICSContainerBind.cs" />
<Compile Include="ICSContainerTransCodeBind.cs" />
<Compile Include="ICSLocationRecommend.cs" />
<Compile Include="ICSMTDocModel.cs" />
<Compile Include="ICSUser.cs" />

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

@ -2834,6 +2834,40 @@ namespace ICSSoft.WebAPI.Controllers
}
#endregion
#region 提供给叉车调用的回写接口,用于叉车完成搬运任务后回传任务编号,WMS入库并过账SAP(入库)
/// <summary>
/// 提供给AGV调用的回写接口
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
[HttpPost]
[Route("api/ForkLiftTaskEndIn/Get")]
public HttpResponseMessage ForkLiftTaskEndIn([FromBody] object JsonData)
{
log.Info("合并传入值" + JsonData);
try
{
if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
{
forkliftres = ICSSubmitService.ForkLiftTaskEndIn(JsonConvert.DeserializeObject<ForkLiftCallBackModel>(JsonData.ToString()), JsonData.ToString());
}
}
catch (Exception ex)
{
log.Error("转换失败:" + ex.ToString());
forkliftres.Ret = 0;
forkliftres.RetMsg = ex.Message;
}
finally
{
str = JsonConvert.SerializeObject(forkliftres);
result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
}
return result;
}
#endregion
#region 根据单据获取占料信息
[HttpPost]
[Route("api/MaterialOccupy/Get")]

Loading…
Cancel
Save