Browse Source

所有出库单据加上状态(未配料 已配料 已过账)

master
陆晔 2 years ago
parent
commit
efc78f9c8b
  1. 215
      WMS-BS/NFine.Application/WMS/PickMaterialApp.cs

215
WMS-BS/NFine.Application/WMS/PickMaterialApp.cs

@ -123,8 +123,11 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'";
a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator, a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator,
case when max(e.SourceID) is null then '' else '' end as IsNew,f.Colspan , case when max(e.SourceID) is null then '' else '' end as IsNew,f.Colspan ,
case when max(k.TransCode) is null then '' else '' end as IsOccupy, case when max(k.TransCode) is null then '' else '' end as IsOccupy,
case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName != 'JOB' then ''
else (case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName = 'JOB' then '' else '' end) end as Status,
case when (a.EATTRIBUTE='01' OR a.EATTRIBUTE='20') then(
case when sum(a.Quantity)=sum(IssueQuantity) and a.MUSERName != 'JOB' then ''
when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName = 'JOB' then '' else '' end)
else (case when sum(a.Quantity) =sum(IssueQuantity) then ''
when sum(a.Quantity)!=sum(IssueQuantity) AND sum(IssueQuantity)>0 then '' else '' end) END as Status,
f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 , f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,
f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.ID, f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.ID,
case when a.MUSER!= 'JOB' then a.MUSER else '' end AS PickName case when a.MUSER!= 'JOB' then a.MUSER else '' end AS PickName
@ -303,8 +306,9 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'";
a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator, a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator,
case when max(e.SourceID) is null then '' else '' end as IsNew,f.Colspan , case when max(e.SourceID) is null then '' else '' end as IsNew,f.Colspan ,
case when max(k.TransCode) is null then '' else '' end as IsOccupy, case when max(k.TransCode) is null then '' else '' end as IsOccupy,
case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName != 'JOB' then ''
else (case when sum(a.Quantity) =sum(IssueQuantity) and a.MUSERName = 'JOB' then '' else '' end) end as Status,
case when sum(a.Quantity) =sum(IssueQuantity) then ''
when sum(a.Quantity)!=sum(IssueQuantity) AND sum(IssueQuantity)>0 then ''
else '' end as Status,
f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 , f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,
f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.ID f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.ID
from ICSMOApply a from ICSMOApply a
@ -615,7 +619,10 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
else '' else ''
end as IsNew, end as IsNew,
case when max(k.TransCode) is null then '' else '' end as IsOccupy, case when max(k.TransCode) is null then '' else '' end as IsOccupy,
f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
case when sum(a.Quantity) =sum(IssueQuantity) then ''
when sum(a.Quantity)!=sum(IssueQuantity) AND sum(IssueQuantity)>0 then ''
else '' end as Status,
f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID
from ICSOApply a from ICSOApply a
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
@ -808,6 +815,9 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo
a.CusCode,a.CusName, a.CusCode,a.CusName,
(CASE WHEN max(e.SourceID) IS NULL THEN '' ELSE '' END) AS IsNew, (CASE WHEN max(e.SourceID) IS NULL THEN '' ELSE '' END) AS IsNew,
case when max(k.TransCode) is null then '' else '' end as IsOccupy, case when max(k.TransCode) is null then '' else '' end as IsOccupy,
case when sum(a.Quantity) =sum(SDNQuantity) then ''
when sum(a.Quantity)!=sum(SDNQuantity) AND sum(SDNQuantity)>0 then ''
else '' end as Status,
f.Colspan, f.ProjectCode, f.BatchCode, f.Version, f.Brand, f.Colspan, f.ProjectCode, f.BatchCode, f.Version, f.Brand,
f.cFree1, f.cFree2, f.cFree3, f.cFree4, f.cFree5, f.cFree6, f.cFree7, f.cFree8, f.cFree9, f.cFree10,a.ID f.cFree1, f.cFree2, f.cFree3, f.cFree4, f.cFree5, f.cFree6, f.cFree7, f.cFree8, f.cFree9, f.cFree10,a.ID
FROM ICSSDN a FROM ICSSDN a
@ -938,7 +948,10 @@ left join (select distinct TransCode,TransType,WorkPoint from dbo.ICSWareHouseLo
when max(e.SourceID) is null then '' when max(e.SourceID) is null then ''
else '' else ''
end as IsNew, end as IsNew,
case when max(k.TransCode) is null then '' else '' end as IsOccupy,
case when max(k.TransCode) is null then '' else '' end as IsOccupy,
case when sum(a.Quantity)=sum(a.OutQuantity) then ''
when sum(a.Quantity)!=sum(a.OutQuantity) and sum(a.OutQuantity)>0 then ''
else '' END AS Status,
f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1, f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID
from ICSOtherOut a from ICSOtherOut a
@ -1129,6 +1142,9 @@ f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
else '' else ''
end as IsNew, end as IsNew,
case when max(k.TransCode) is null then '' else '' end as IsOccupy, case when max(k.TransCode) is null then '' else '' end as IsOccupy,
case when sum(a.Quantity)=sum(a.TransferQuantity) then ''
when sum(a.Quantity)!=sum(a.TransferQuantity) and a.TransferQuantity>0 then ''
else '' END AS Status,
f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1, f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10 f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
from ICSTransfer a from ICSTransfer a
@ -1913,105 +1929,107 @@ c.Sequence,
} }
try try
{ {
#region 拣料时增加条码出入库记录,修改库存锁定数量,以作占料处理
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>();
#region 货柜
string InspectJosn = "";
string InspectJosnHead = "";
string InspectJosnBody = "";
InspectJosn += "{";
InspectJosn += "\"IMP_ORDINI\":[";
InspectJosn += "货柜主表区域预留";
InspectJosn += "],";
InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
InspectJosn += "货柜子表区域预留";
InspectJosn += "]";
InspectJosn += "}";
foreach (DataRow PickLog in table.Rows)
{
string hgsql = @"select A.InvCode,A.LocationCode,B.F_Define3,C.LocationCode AS Area
if (table.Rows.Count != 0)
{
#region 拣料时增加条码出入库记录,修改库存锁定数量,以作占料处理
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>();
#region 货柜
string InspectJosn = "";
string InspectJosnHead = "";
string InspectJosnBody = "";
InspectJosn += "{";
InspectJosn += "\"IMP_ORDINI\":[";
InspectJosn += "货柜主表区域预留";
InspectJosn += "],";
InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
InspectJosn += "货柜子表区域预留";
InspectJosn += "]";
InspectJosn += "}";
foreach (DataRow PickLog in table.Rows)
{
string hgsql = @"select A.InvCode,A.LocationCode,B.F_Define3,C.LocationCode AS Area
from ICSWareHouseLotInfo A 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 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 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}'"; where A.LotNo='{0}' AND A.WorkPoint='{1}'";
hgsql = string.Format(hgsql, PickLog["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(PickLog["Code"].ToString()))
hgsql = string.Format(hgsql, PickLog["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)
{ {
DocNoList.Add(PickLog["Code"].ToString());
if (!DocNoList.Contains(PickLog["Code"].ToString()))
{
DocNoList.Add(PickLog["Code"].ToString());
}
InspectJosnBody += "{";
InspectJosnBody += "\"RIG_ORDINE\":\"" + PickLog["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\": " + PickLog["SendQTY"].ToString() + ",";
InspectJosnBody += "\"RIG_HOSTINF\": \"" + PickLog["Sequence"].ToString() + "\"";
InspectJosnBody += "},";
} }
InspectJosnBody += "{";
InspectJosnBody += "\"RIG_ORDINE\":\"" + PickLog["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\": " + PickLog["SendQTY"].ToString() + ",";
InspectJosnBody += "\"RIG_HOSTINF\": \"" + PickLog["Sequence"].ToString() + "\"";
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.TrimEnd(',');
if (InspectJosnBody != "")
{
InspectJosn = InspectJosn.Replace("货柜主表区域预留", InspectJosnHead);
InspectJosn = InspectJosn.Replace("货柜子表区域预留", InspectJosnBody);
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
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.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 values
('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}')"; ('{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}'"; where ID='{1}'";
logsql = string.Format(logsql, callresult, logID);
SqlHelper.CmdExecuteNonQueryLi(logsql);
#endregion
//if (!callresult.Contains("successo"))
//{
// ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(callresult.TrimStart('[').TrimEnd(']'));
// throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
//}
logsql = string.Format(logsql, callresult, logID);
SqlHelper.CmdExecuteNonQueryLi(logsql);
#endregion
//if (!callresult.Contains("successo"))
//{
// ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(callresult.TrimStart('[').TrimEnd(']'));
// throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
//}
}
} }
}
#endregion
foreach (DataRow PickLog in table.Rows)
{
pikTbLogsql += @" IF NOT EXISTS(SELECT TransCode FROM ICSWareHouseLotInfoLog WHERE TransCode='{1}' AND TransSequence='{2}' AND LotNo='{9}' AND WorkPoint='{8}' AND TransType='15')
#endregion
foreach (DataRow PickLog in table.Rows)
{
pikTbLogsql += @" IF NOT EXISTS(SELECT TransCode FROM ICSWareHouseLotInfoLog WHERE TransCode='{1}' AND TransSequence='{2}' AND LotNo='{9}' AND WorkPoint='{8}' AND TransType='15')
BEGIN BEGIN
INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode, INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity, FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
@ -2028,12 +2046,13 @@ c.Sequence,
update ICSWareHouseLotInfo set LockQuantity=LockQuantity+'{3}' where LotNo='{9}' AND WorkPoint='{8}' update ICSWareHouseLotInfo set LockQuantity=LockQuantity+'{3}' where LotNo='{9}' AND WorkPoint='{8}'
END "; END ";
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);
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);
#endregion
#endregion
}
var result = ConvertCellToString(table); var result = ConvertCellToString(table);
if (Invmes.Rows.Count > 0) if (Invmes.Rows.Count > 0)

Loading…
Cancel
Save