update TousseDefinition set materialAmount=(
	select sum(c.tousseAmount*mi.count)
	from ComboTousseComposite c 
	join MaterialInstance mi on mi.tousse_id=c.tousseDefinitionId
	where c.comboTousseDefinitionId=TousseDefinition.id 
)
where tousseType='聚合包' and materialAmount is null;
update TousseDefinition set materialSplitAmount=(
	select sum(c.tousseAmount * (case when md.splitAmount is null then 1 else md.splitAmount end * mi.count))
	from ComboTousseComposite c 
	join MaterialInstance mi on mi.tousse_id=c.tousseDefinitionId
	join MaterialDefinition md on md.id=mi.materialDefinition_id
	where c.comboTousseDefinitionId=TousseDefinition.id 
)
where tousseType='聚合包' and materialSplitAmount is null;