@ -149,6 +149,24 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'";
{
sqlString . Append ( $@" and detail.LocationCode like '%{queryParam[" Area "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Order" ] . ToString ( ) ) )
{
sqlString . Append ( $@" and a.OrderNumber like '%{queryParam[" Order "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sqlString . Append ( $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ");
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "CreateDate" ] . ToString ( ) ) )
{
sqlString . Append ( $@" and a.CreateDateTime >='{queryParam[" CreateDate "].ToDate()}' and a.CreateDateTime <'{queryParam[" CreateDate "].ToDate().AddDays(+1)}' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "NeedDate" ] . ToString ( ) ) )
{
sqlString . Append ( $@" and a.NeedDate like '%{queryParam[" NeedDate "]}%' " ) ;
}
}
sqlString . Append ( @ " group by a.ApplyCode, a.WorkPoint,a.IssueQuantity,a.CreateDateTime,a.createperson,
@ -169,7 +187,7 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'";
var queryParam = queryJson . ToJObject ( ) ;
List < DbParameter > parameter = new List < DbParameter > ( ) ;
string sql = @ "SELECT * FROM (select row_number() over(partition by a.ApplyCode,a.InvCode,a.Sequence ORDER BY a.ApplyCode) as row,
a . ID , a . ApplyCode as Code , a . Sequence , a . MTIME , a . MUSERName , a . MUSER , a . WHCode , b . WarehouseName , a . InvCode ,
a . ID , a . ApplyCode as Code , a . Sequence , a . MTIME , a . MUSERName , a . MUSER , a . WHCode , b . WarehouseName , a . InvCode , a . OrderNumber ,
a . EATTRIBUTE , a . Sets , a . OrderInvCode , a . OrderInvDescribe , a . BillType , a . Remarks , a . Desks , a . DispatchNumber , a . DispatcherName ,
a . ReceiverNumber , a . ReceiverName , a . Urgency , a . NeedDate , a . NeedTime , a . RemarksTerm , a . TextNumber , a . InvDescribe , a . Unit , a . StockIndicator ,
d . InvName , d . InvDesc , d . InvStd , d . InvUnit , detail . LocationCode AS Area ,
@ -197,6 +215,24 @@ where b.MOCode='{0}' and a.WorkPoint='{1}'";
{
sql + = " and a.InvCode like '%" + queryParam [ "InvCode" ] . ToString ( ) + "%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Order" ] . ToString ( ) ) )
{
sql + = $@" and a.OrderNumber like '%{queryParam[" Order "]}%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sql + = $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ";
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "CreateDate" ] . ToString ( ) ) )
{
sql + = $@" and a.CreateDateTime like '%{queryParam[" CreateDate "]}%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "NeedDate" ] . ToString ( ) ) )
{
sql + = $@" and a.NeedDate like '%{queryParam[" NeedDate "]}%' " ;
}
}
sql + = " ) c WHERE c.row=1 " ;
sql = string . Format ( sql , Code , WorkPoint ) ;
@ -387,6 +423,12 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sqlString . Append ( $@" and detail.LocationCode like '%{queryParam[" Area "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sqlString . Append ( $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ");
}
}
sqlString . Append ( @ "group by a.ApplyCode,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,
@ -431,6 +473,12 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sql + = " and a.InvCode like '%" + queryParam [ "InvCode" ] . ToString ( ) + "%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sql + = $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ";
}
}
sql + = " ) c WHERE c.row=1 " ;
sql = string . Format ( sql , Code , WorkPoint ) ;
@ -546,6 +594,7 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
LEFT JOIN ICSMOPickMerge e ON a . ID = e . SourceID AND a . WorkPoint = e . WorkPoint
LEFT JOIN ICSExtension f ON a . ExtensionID = f . ID AND a . WorkPoint = f . WorkPoint
LEFT JOIN ICSInventory d on a . InvCode = d . InvCode and a . WorkPoint = d . WorkPoint
LEFT JOIN ICSInventoryDetail detail ON d . InvCode = detail . INVCode AND a . WHCode = detail . WHCode AND a . WorkPoint = detail . WorkPoint
WHERE a . WorkPoint = ' { WorkPoint } ' ");
if ( ! string . IsNullOrWhiteSpace ( queryJson ) )
{
@ -565,6 +614,20 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sqlString . Append ( $@" and detail.LocationCode like '%{queryParam[" Area "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "CusCode" ] . ToString ( ) ) )
{
sqlString . Append ( $@" and a.CusCode like '%{queryParam[" CusCode "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "CusName" ] . ToString ( ) ) )
{
sqlString . Append ( $@" and a.CusName like '%{queryParam[" CusName "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sqlString . Append ( $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ");
}
}
sqlString . Append ( @ "GROUP BY a.SDNCode, a.CreateDateTime, a.CreatePerson, f.Colspan, f.ProjectCode, f.BatchCode, f.Version, f.Brand,
@ -609,6 +672,20 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sql + = " and a.InvCode like '%" + queryParam [ "InvCode" ] . ToString ( ) + "%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "CusCode" ] . ToString ( ) ) )
{
sql + = $@" and a.CusCode like '%{queryParam[" CusCode "]}%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "CusName" ] . ToString ( ) ) )
{
sql + = $@" and a.CusName like '%{queryParam[" CusName "]}%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sql + = $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ";
}
}
sql + = " ) c WHERE c.row=1 " ;
sql = string . Format ( sql , Code , WorkPoint ) ;
@ -667,6 +744,12 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sqlString . Append ( $@" and detail.LocationCode like '%{queryParam[" Area "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sqlString . Append ( $ @ " (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ");
}
}
sqlString . Append ( @ " group by a.OutCode,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,f.BatchCode,
@ -712,6 +795,12 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sql + = " and a.InvCode like '%" + queryParam [ "InvCode" ] . ToString ( ) + "%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sql + = $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . WHCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ";
}
}
sql + = " ) c WHERE c.row=1 " ;
sql = string . Format ( sql , Code , WorkPoint ) ;
@ -840,7 +929,13 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sqlString . Append ( $@" and detail.LocationCode like '%{queryParam[" Area "]}%' " ) ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sqlString . Append ( $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . FromWarehouseCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ");
}
}
sqlString . Append ( @ "group by a.TransferNO,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,
f . BatchCode , f . Version , f . Brand , f . cFree1 , f . cFree2 , f . cFree3 , f . cFree4 ,
@ -887,6 +982,12 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
{
sql + = " and a.InvCode like '%" + queryParam [ "InvCode" ] . ToString ( ) + "%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Container" ] . ToString ( ) ) & & queryParam [ "Container" ] . ToString ( ) = = "2" )
{
sql + = $ @ " and (detail.LocationCode not in (SELECT F_Define2 FROM Sys_SRM_ItemsDetail
WHERE
F_Define3 = ' HGAreaConfig ' AND F_Define1 = a . FromWarehouseCode AND F_Define4 = a . WorkPoint ) OR detail . LocationCode is null OR detail . LocationCode = ' ' ) ";
}
}
sql + = " ) as t where t.row=1" ;
sql = string . Format ( sql , Code , WorkPoint ) ;
@ -1494,9 +1595,9 @@ where a.IssueCode='{0}' and a.WorkPoint='{1}'";
from ICSWareHouseLotInfo d , ICSInventoryLot m
where d . LotNo = m . LotNo and d . WorkPoint = m . WorkPoint
and d . WorkPoint = ' { WorkPoint } ' 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
- - 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 ) 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 , c . InvCode , d . MTIME ";