<!-- 根据条件查询出工具 -->
<select id="getAllList" resultMap="ResultMap" parameterType="java.util.Map">
SELECT mes_toolcar.name AS toolCarName,
mes_toolcar.serialNO AS toolCarSerialNo,
mes_tool.name,
mes_tool.serialNO,
mes_tool.torque,
mes_tool.validityDate,
mes_tool.status,
mes_tool.imagePath,
mes_tool.update_date
from mes_tool, mes_toolcar
<trim prefix="WHERE" prefixOverrides="AND | OR ">--------------------------------------------------------------------<trim>标签需要深入了解一下,参考下一篇文章
mes_toolcar.serialNO = mes_tool.toolCar_serialNO and mes_tool.abandon = 0
<if test="toolCarName!=null and toolCarName!=''">
AND mes_toolcar.name = #{toolCarName}
</if>
<if test="name!=null and name!=''">
AND mes_tool.name LIKE CONCAT(CONCAT('%', #{name}),'%') ————模糊查询
</if>
<if test="serialNo!=null and serialNo!=''">
AND mes_tool.serialNO = #{serialNo}
</if>
<if test="status!=null and status!=''">
AND mes_tool.status = #{status}
</if>
<if test="torqueStart!=null and torqueStart!=''">
AND mes_tool.torque >= #{torqueStart}
</if>
<if test="torqueTo!=null and torqueTo!=''">
AND mes_tool.torque <![CDATA[<=]]> #{torqueTo}——————当有小于号时候需要对其转义处理 <![CDATA[<=]]>
</if>
<if test="validityDateStart!=null and validityDateStart!=''">
AND mes_tool.validityDate >= #{validityDateStart}
</if>
<if test="validityDateTo!=null and validityDateTo!=''">
AND mes_tool.validityDate <![CDATA[<=]]> #{validityDateTo}
</if>
</trim>
</select>
<select id="getAllList" resultMap="ResultMap" parameterType="java.util.Map">
SELECT mes_toolcar.name AS toolCarName,
mes_toolcar.serialNO AS toolCarSerialNo,
mes_tool.name,
mes_tool.serialNO,
mes_tool.torque,
mes_tool.validityDate,
mes_tool.status,
mes_tool.imagePath,
mes_tool.update_date
from mes_tool, mes_toolcar
<trim prefix="WHERE" prefixOverrides="AND | OR ">--------------------------------------------------------------------<trim>标签需要深入了解一下,参考下一篇文章
mes_toolcar.serialNO = mes_tool.toolCar_serialNO and mes_tool.abandon = 0
<if test="toolCarName!=null and toolCarName!=''">
AND mes_toolcar.name = #{toolCarName}
</if>
<if test="name!=null and name!=''">
AND mes_tool.name LIKE CONCAT(CONCAT('%', #{name}),'%') ————模糊查询
</if>
<if test="serialNo!=null and serialNo!=''">
AND mes_tool.serialNO = #{serialNo}
</if>
<if test="status!=null and status!=''">
AND mes_tool.status = #{status}
</if>
<if test="torqueStart!=null and torqueStart!=''">
AND mes_tool.torque >= #{torqueStart}
</if>
<if test="torqueTo!=null and torqueTo!=''">
AND mes_tool.torque <![CDATA[<=]]> #{torqueTo}——————当有小于号时候需要对其转义处理 <![CDATA[<=]]>
</if>
<if test="validityDateStart!=null and validityDateStart!=''">
AND mes_tool.validityDate >= #{validityDateStart}
</if>
<if test="validityDateTo!=null and validityDateTo!=''">
AND mes_tool.validityDate <![CDATA[<=]]> #{validityDateTo}
</if>
</trim>
</select>