left join logpm_basicdata_factory_category lbfc1 on lbfc1.brand = ltad.brand and lbfc1.firsts = ltad.first_pack_name and lbfc1.seconds = ltad.second_pack_name and lbfc1.thirds = ltad.third_pack_name and lbfc1.type = 1 AND lbfc1.materiel_name = ltad.material_name
left join logpm_basicdata_factory_category lbfc2 on lbfc2.brand = ltad.brand and lbfc2.firsts = ltad.first_pack_name and lbfc2.seconds = ltad.second_pack_name and lbfc2.thirds = ltad.third_pack_name and lbfc1.type = 2 AND lbfc2.materiel_name = ltad.material_name
left join logpm_basicdata_factory_category lbfc1 on lbfc1.brand = ltad.brand and IFNULL(lbfc1.firsts,1) = IFNULL(ltad.first_pack_name,1) and IFNULL(lbfc1.seconds,2) = IFNULL(ltad.second_pack_name,2) and IFNULL(lbfc1.thirds,3) = IFNULL(ltad.third_pack_name,3) and lbfc1.type = 1 AND IFNULL(lbfc1.materiel_name,4) = IFNULL(ltad.material_name,4)
left join logpm_basicdata_factory_category lbfc2 on lbfc2.brand = ltad.brand and IFNULL(lbfc2.firsts,1) = IFNULL(ltad.first_pack_name,1) and IFNULL(lbfc2.seconds,2) = IFNULL(ltad.second_pack_name,2) and IFNULL(lbfc2.thirds,3) = IFNULL(ltad.third_pack_name,3) and lbfc1.type = 2 AND IFNULL(lbfc2.materiel_name,4) = IFNULL(ltad.material_name,4)
where ltad.is_deleted = 0
<iftest="param.advanceIds != null and param.advanceIds.size() > 0">