@ -251,7 +251,7 @@ group by MODetailID )a) h on a.MODetailID=h.MODetailID
sql + = " and a.MOCode = '" + MOCode + "' and a.Sequence = '" + Sequence + "' and a.WorkPoint='" + WorkPoint + "'" ;
sql = string . Format ( sql , Figure ) ;
return Repository ( ) . FindTableBySql ( sql . ToString ( ) ) ;
return Repository ( ) . FindTableBySql ( sql . ToString ( ) ) ;
}
@ -494,6 +494,8 @@ flag.F_Define1 as Prorate
string sql = @ "select a.ID,d.MOCode,d.Sequence+'~'+ a.Sequence as Sequence,a.PickID,a.InvCode as ZInvCode,d.InvCode as MInvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST ( a . Quantity AS DECIMAL ( 1 8 , { 0 } ) ) as Quantity , a . MODetailID ,
CAST ( a . Amount AS DECIMAL ( 1 8 , { 0 } ) ) as Amount , CAST ( a . IssueQuantity AS DECIMAL ( 1 8 , { 0 } ) ) as IssueQuantity , a . ExtensionID , a . MUSERName , a . MTIME , CAST ( c . LOTQTY AS DECIMAL ( 1 8 , { 0 } ) ) as LOTQTY
, case when d . EATTRIBUTE1 = '1' then 1 else 0 end MoTypeValue
, case when d . EATTRIBUTE1 = '1' then ' 非 标 准 ' else ' 标 准 ' end MoType
, 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 . EATTRIBUTE1 , a . EATTRIBUTE2 , a . EATTRIBUTE3 , a . EATTRIBUTE4 , a . EATTRIBUTE5 , a . EATTRIBUTE6 , a . EATTRIBUTE7 , a . EATTRIBUTE8 ,
a . EATTRIBUTE9 , a . EATTRIBUTE10
@ -652,21 +654,15 @@ where isnull(a.EATTRIBUTE1,'')=''
group by b . TransCode , b . TransSequence
) f on d . MOCode = f . TransCode and d . Sequence = f . TransSequence
left join
( select case when Flag > 0 then ( case when PSLNUM > MLNUM then MLNUM else PSLNUM end ) else PSLNUM end as BL , MODetailID from (
( select MinBL as BL , MODetailID from (
select a . MODetailID ,
case when isnull ( sum ( a . PSLYL ) , 0 ) = 0 then 0 else sum ( a . PSLLSS ) / sum ( a . PSLYL ) * max ( isnull ( F_Define1 , 0 ) / 1 0 0.0 ) end as PSLNUM ,
case when isnull ( sum ( a . MLYL ) , 0 ) = 0 then 0 else sum ( a . MLLSS ) / sum ( a . MLYL ) * max ( isnull ( F_Define1 , 0 ) / 1 0 0.0 ) end as MLNUM ,
sum ( Flag ) as Flag
min ( ALLBL ) * max ( isnull ( F_Define1 , 0 ) / 1 0 0.0 ) as MinBL
from (
select a . MODetailID ,
case when SUBSTRING ( b . ClassCode , 1 , 2 ) IN ( ' 0 1 ',' 0 4 ',' 0 5 ' ) then a . Quantity else 0 end PSLYL ,
case when SUBSTRING ( b . ClassCode , 1 , 2 ) IN ( ' 0 1 ',' 0 4 ',' 0 5 ' ) then a . IssueQuantity else 0 end PSLLSS ,
case when SUBSTRING ( b . ClassCode , 1 , 2 ) IN ( ' 0 3 ' ) then a . Quantity else 0 end MLYL ,
case when SUBSTRING ( b . ClassCode , 1 , 2 ) IN ( ' 0 3 ' ) then a . IssueQuantity else 0 end MLLSS ,
case when SUBSTRING ( b . ClassCode , 1 , 2 ) IN ( ' 0 3 ' ) then 1 else 0 end Flag
case when a . Quantity = 0 then 0 when a . IssueQuantity = 0 then 0 else a . IssueQuantity / a . Quantity end as ALLBL
from dbo . ICSMOPick a
inner join dbo . ICSInventory b on a . InvCode = b . InvCode and a . WorkPoint = b . WorkPoint
where a . EATTRIBUTE1 < > '1' ) a
where a . EATTRIBUTE1 < > '1' and a . IssueQuantity > 0 ) a
left join Sys_SRM_ItemsDetail flag on flag . F_ItemCode = ' GDCS0001 '
group by MODetailID ) a ) h on a . MODetailID = h . MODetailID
left join ICSExtension e on d . ExtensionID = e . ID and a . WorkPoint = e . WorkPoint