select
Average,
Homogen,
difference,
net_weight,
jsonb_array_elements(testData::jsonb) ->> 'MaxPower' AS maxpower,
jsonb_array_elements(testData::jsonb) ->> 'Thickness' AS thickness,
jsonb_array_elements(testData::jsonb) ->> 'Refraction' AS refraction,
FurnaceID,right(FurnaceID,2) as shebeihao,
equipmentNo as FurnaceID, equipmentNo as shebeihao,
lineNo as FurnaceID, lineNo as shebeihao,
creationDate
from bsga
where 1=1
and workshop = 'C1'
and ${reportCombox} = 2
and Average != '0.0'
and difference IS NOT NULL
and net_weight IS NOT NULL
and testData IS NOT NULL
and creationDate >= to_timestamp('${startDate}', 'YYYY-MM-DD HH24:MI:SS')
and creationDate < to_timestamp('${endDate}', 'YYYY-MM-DD HH24:MI:SS')
${if(len(deviceId) > 0," and FurnaceID in ('" +deviceId+ "') ","")}
${if(len(deviceId) > 0," and equipmentNo in ('" +deviceId+ "') ","")}
${if(len(deviceId) > 0," and lineNo in ('" +deviceId+ "') ","")}
order by FurnaceID
order by equipmentNo
order by lineNo