<select id="getProjectEquipment" resultType="com.yeejoin.amos.boot.module.ugp.api.dto.ProjectResourceDto">
SELECT
equipment.name ,
equipment.`code`,
equipment.type ,
equipment.manufacturer,
equipment.manufacture_date ,
equipment.service_life,
equipment.verify_status,
equipment.sequence_nbr,
project.`name` AS projectName
FROM tz_ugp_project_resource resource
LEFT JOIN tz_ugp_project AS project ON project.sequence_nbr = resource.project_id
LEFT JOIN tz_ugp_equipment AS equipment ON equipment.sequence_nbr = resource.resource_id
<where>
resource.type = #{type}
<if test="projectResourceDto !=null">
<if test="projectResourceDto.name !=null and projectResourceDto.name != ''">
and equipment.`name` LIKE CONCAT("%",#{projectResourceDto.name},"%")
</if>
<if test="projectResourceDto.projectName !=null and projectResourceDto.projectName != ''">
and project.`name` LIKE CONCAT("%",#{projectResourceDto.projectName},"%")
</if>
</if>
<if test="codes !=null">
AND resource.project_id in
<foreach collection="codes" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
Set<String> codes = new HashSet<>();
codes.add(xxxxxx);
标签:resource,name,sequence,nbr,用法,project,equipment,foreach,sql From: https://www.cnblogs.com/LLW521/p/16880582.html