|
|
@ -563,12 +563,15 @@ where a.EATTRIBUTE1='1' and SUBSTRING(b.ClassCode, 1, 2) not IN ('05') "; |
|
|
|
|
|
|
|
|
|
|
|
//副产品生成条码获取物料数量信息
|
|
|
|
public DataTable GetSubGridJsonFCPCreate(string FCPMOCode, string Sequence, string WorkPoint) |
|
|
|
public DataTable GetSubGridJsonFCPCreate(string FCPMOCode, string Sequence, string WorkPoint, string MoTypeValue) |
|
|
|
{ |
|
|
|
DataTable dt = new DataTable(); |
|
|
|
object Figure = GetDecimalDigits(); |
|
|
|
List<DbParameter> parameter = new List<DbParameter>(); |
|
|
|
string sql = @"
|
|
|
|
string sql = string.Empty; |
|
|
|
if (MoTypeValue=="0") |
|
|
|
{ |
|
|
|
sql = @"
|
|
|
|
select |
|
|
|
a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, a.Quantity as Quantity, |
|
|
|
cast( isnull(h.BL,0)*a.Quantity AS DECIMAL(18,4)) as AbsolveQty, |
|
|
@ -616,9 +619,62 @@ 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 |
|
|
|
|
|
|
|
WHERE 1=1 |
|
|
|
and d.MOCode='" + FCPMOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "'";
|
|
|
|
sql += " and a.WorkPoint='" + WorkPoint + "'"; |
|
|
|
WHERE 1=1 ";
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
sql = @"
|
|
|
|
select |
|
|
|
a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, a.Quantity as Quantity, |
|
|
|
cast( isnull(h.BL,0)*a.Quantity AS DECIMAL(18,4)) as AbsolveQty, |
|
|
|
cast( isnull(h.BL,0)*a.Amount AS DECIMAL(18,4)) as AbsolveAmount, |
|
|
|
cast( isnull(c.LOTQTY,0)+isnull(f.GDQTY,0) as DECIMAL(18,4)) as CreatedQty, |
|
|
|
CAST( ((isnull(h.BL,0)*a.Amount) -(isnull(c.LOTQTY,0)+isnull(f.GDQTY,0))) as DECIMAL(18,4)) as thisCreateQty, |
|
|
|
cast( a.Amount as DECIMAL(18,4)) as Amount, |
|
|
|
isnull(b.EffectiveEnable,0) as EffectiveEnable, |
|
|
|
cast( isnull(b.EffectiveDays,0) as DECIMAL(18,4)) as EffectiveDays |
|
|
|
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10 |
|
|
|
from ICSMOPick a |
|
|
|
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' |
|
|
|
--汇总副产品已生成条码数量 |
|
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint |
|
|
|
left join ( |
|
|
|
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a |
|
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18' |
|
|
|
where isnull(a.EATTRIBUTE1,'')='' |
|
|
|
group by b.TransCode,b.TransSequence |
|
|
|
) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence |
|
|
|
--汇总工单已生成条码 |
|
|
|
left join ( |
|
|
|
select b.TransCode,b.TransSequence ,sum(isnull(Quantity,0)) GDQTY from ICSInventoryLot a |
|
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3' |
|
|
|
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 a.MODetailID, |
|
|
|
case when isnull(sum(a.PSLYL),0)=0 then 0 else sum(a.PSLLSS)/sum(a.PSLYL)* max(isnull(F_Define1,0)/100.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)/100.0) end as MLNUM, |
|
|
|
sum(Flag) as Flag |
|
|
|
from ( |
|
|
|
select a.MODetailID , |
|
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('01','04','05') then a.Quantity else 0 end PSLYL, |
|
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('01','04','05') then a.IssueQuantity else 0 end PSLLSS, |
|
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then a.Quantity else 0 end MLYL, |
|
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then a.IssueQuantity else 0 end MLLSS, |
|
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then 1 else 0 end Flag |
|
|
|
from dbo.ICSMOPick a |
|
|
|
inner join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint |
|
|
|
where a.EATTRIBUTE1 <> '1')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 |
|
|
|
|
|
|
|
WHERE 1=1 ";
|
|
|
|
} |
|
|
|
|
|
|
|
sql += " and d.MOCode='" + FCPMOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoint + "'"; |
|
|
|
sql = string.Format(sql, Figure); |
|
|
|
return Repository().FindTableBySql(sql.ToString()); |
|
|
|
} |
|
|
|
xxxxxxxxxx