Commit 99e7db36 authored by 季圣华's avatar 季圣华
Browse files

日期和sql优化

parent f04dcd22
...@@ -26,16 +26,20 @@ ...@@ -26,16 +26,20 @@
where 1=1 where 1=1
and me.default_flag=1 and me.default_flag=1
<if test="barCode != null"> <if test="barCode != null">
and me.bar_code like '%${barCode}%' <bind name="bindBarCode" value="'%'+barCode+'%'"/>
and me.bar_code like #{bindBarCode}
</if> </if>
<if test="name != null"> <if test="name != null">
and m.name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and m.name like #{bindName}
</if> </if>
<if test="standard != null"> <if test="standard != null">
and m.standard like '%${standard}%' <bind name="bindStandard" value="'%'+standard+'%'"/>
and m.standard like #{bindStandard}
</if> </if>
<if test="model != null"> <if test="model != null">
and m.model like '%${model}%' <bind name="bindModel" value="'%'+model+'%'"/>
and m.model like #{bindModel}
</if> </if>
<if test="idList.size()>0"> <if test="idList.size()>0">
and m.category_id in and m.category_id in
...@@ -60,16 +64,20 @@ ...@@ -60,16 +64,20 @@
WHERE 1=1 WHERE 1=1
and me.default_flag=1 and me.default_flag=1
<if test="barCode != null"> <if test="barCode != null">
and me.bar_code like '%${barCode}%' <bind name="bindBarCode" value="'%'+barCode+'%'"/>
and me.bar_code like #{bindBarCode}
</if> </if>
<if test="name != null"> <if test="name != null">
and m.name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and m.name like #{bindName}
</if> </if>
<if test="standard != null"> <if test="standard != null">
and m.standard like '%${standard}%' <bind name="bindStandard" value="'%'+standard+'%'"/>
and m.standard like #{bindStandard}
</if> </if>
<if test="model != null"> <if test="model != null">
and m.model like '%${model}%' <bind name="bindModel" value="'%'+model+'%'"/>
and m.model like #{bindModel}
</if> </if>
<if test="idList.size()>0"> <if test="idList.size()>0">
and m.category_id in and m.category_id in
...@@ -83,14 +91,14 @@ ...@@ -83,14 +91,14 @@
<select id="findUnitList" resultType="com.jsh.erp.datasource.entities.Unit"> <select id="findUnitList" resultType="com.jsh.erp.datasource.entities.Unit">
select u.* from jsh_unit u select u.* from jsh_unit u
left join jsh_material m on m.unit_id=u.id and ifnull(m.delete_flag,'0') !='1' left join jsh_material m on m.unit_id=u.id and ifnull(m.delete_flag,'0') !='1'
where m.id = ${mId} where m.id = #{mId}
and ifnull(u.delete_flag,'0') !='1' and ifnull(u.delete_flag,'0') !='1'
</select> </select>
<select id="findById" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap"> <select id="findById" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
select m.*,u.name unit_name from jsh_material m select m.*,u.name unit_name from jsh_material m
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_flag,'0') !='1' left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_flag,'0') !='1'
where m.id = ${id} where m.id = #{id}
and ifnull(m.delete_flag,'0') !='1' and ifnull(m.delete_flag,'0') !='1'
</select> </select>
...@@ -100,7 +108,7 @@ ...@@ -100,7 +108,7 @@
from jsh_material m from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1' left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1' left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where me.id = ${meId} where me.id = #{meId}
and ifnull(m.delete_flag,'0') !='1' and ifnull(m.delete_flag,'0') !='1'
</select> </select>
...@@ -133,7 +141,8 @@ ...@@ -133,7 +141,8 @@
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1' left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where m.enabled=1 and me.id is not null where m.enabled=1 and me.id is not null
<if test="q != null"> <if test="q != null">
and (m.name like '%${q}%' or me.bar_code like '%${q}%') <bind name="bindKey" value="'%'+q+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if> </if>
<if test="idList.size()>0"> <if test="idList.size()>0">
and m.category_id in and m.category_id in
...@@ -154,16 +163,20 @@ ...@@ -154,16 +163,20 @@
where 1=1 where 1=1
and me.default_flag=1 and me.default_flag=1
<if test="barCode != null"> <if test="barCode != null">
and me.bar_code like '%${barCode}%' <bind name="bindBarCode" value="'%'+barCode+'%'"/>
and me.bar_code like #{bindBarCode}
</if> </if>
<if test="name != null"> <if test="name != null">
and m.name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and m.name like #{bindName}
</if> </if>
<if test="standard != null"> <if test="standard != null">
and m.standard like '%${standard}%' <bind name="bindStandard" value="'%'+standard+'%'"/>
and m.standard like #{bindStandard}
</if> </if>
<if test="model != null"> <if test="model != null">
and m.model like '%${model}%' <bind name="bindModel" value="'%'+standard+'%'"/>
and m.model like #{bindModel}
</if> </if>
<if test="idList.size()>0"> <if test="idList.size()>0">
and m.category_id in and m.category_id in
...@@ -264,7 +277,7 @@ ...@@ -264,7 +277,7 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1' left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1 where 1=1
<if test="meId != null"> <if test="meId != null">
and me.id = ${meId} and me.id = #{meId}
</if> </if>
and ifnull(m.delete_flag,'0') !='1' and ifnull(m.delete_flag,'0') !='1'
</select> </select>
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
FROM jsh_material_property FROM jsh_material_property
where 1=1 where 1=1
<if test="name != null"> <if test="name != null">
and native_name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and native_name like #{bindName}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
...@@ -19,7 +20,8 @@ ...@@ -19,7 +20,8 @@
FROM jsh_material_property FROM jsh_material_property
WHERE 1=1 WHERE 1=1
<if test="name != null"> <if test="name != null">
and native_name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and native_name like #{bindName}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
WHERE 1=1 WHERE 1=1
and ifnull(delete_Flag,'0') !='1' and ifnull(delete_Flag,'0') !='1'
<if test="name != null"> <if test="name != null">
and msg_title like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and msg_title like #{bindName}
</if> </if>
order by create_time desc order by create_time desc
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
...@@ -21,7 +22,8 @@ ...@@ -21,7 +22,8 @@
WHERE 1=1 WHERE 1=1
and ifnull(delete_Flag,'0') !='1' and ifnull(delete_Flag,'0') !='1'
<if test="name != null"> <if test="name != null">
and msg_title like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and msg_title like #{bindName}
</if> </if>
</select> </select>
<update id="batchDeleteMsgByIds"> <update id="batchDeleteMsgByIds">
...@@ -54,7 +56,7 @@ ...@@ -54,7 +56,7 @@
WHERE 1=1 WHERE 1=1
and ifnull(delete_Flag,'0') !='1' and ifnull(delete_Flag,'0') !='1'
<if test="msgTitle != null"> <if test="msgTitle != null">
and msg_title = '${msgTitle}' and msg_title = #{msgTitle}
</if> </if>
</select> </select>
...@@ -65,7 +67,7 @@ ...@@ -65,7 +67,7 @@
WHERE 1=1 WHERE 1=1
and ifnull(delete_Flag,'0') !='1' and ifnull(delete_Flag,'0') !='1'
<if test="status != null"> <if test="status != null">
and status = '${status}' and status = #{status}
</if> </if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
FROM jsh_person FROM jsh_person
where 1=1 where 1=1
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if> </if>
<if test="type != null and type != ''"> <if test="type != null and type != ''">
and type='${type}' and type=#{type}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
...@@ -22,10 +23,11 @@ ...@@ -22,10 +23,11 @@
FROM jsh_person FROM jsh_person
WHERE 1=1 WHERE 1=1
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if> </if>
<if test="type != null and type != ''"> <if test="type != null and type != ''">
and type='${type}' and type=#{type}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
WHERE 1=1 WHERE 1=1
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
<if test="name != null"> <if test="name != null">
and name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if> </if>
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
limit #{offset},#{rows} limit #{offset},#{rows}
...@@ -20,7 +21,8 @@ ...@@ -20,7 +21,8 @@
WHERE 1=1 WHERE 1=1
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
<if test="name != null"> <if test="name != null">
and name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if> </if>
</select> </select>
<update id="batchDeleteRoleByIds"> <update id="batchDeleteRoleByIds">
......
...@@ -6,16 +6,19 @@ ...@@ -6,16 +6,19 @@
FROM jsh_supplier FROM jsh_supplier
where 1=1 where 1=1
<if test="supplier != null and supplier !=''"> <if test="supplier != null and supplier !=''">
and supplier like '%${supplier}%' <bind name="bindSupplier" value="'%'+supplier+'%'"/>
and supplier like #{bindSupplier}
</if> </if>
<if test="type != null and type !=''"> <if test="type != null and type !=''">
and type='${type}' and type=#{type}
</if> </if>
<if test="phonenum != null and phonenum !=''"> <if test="phonenum != null and phonenum !=''">
and phone_num like '%${phonenum}%' <bind name="bindPhoneNum" value="'%'+phonenum+'%'"/>
and phone_num like #{bindPhoneNum}
</if> </if>
<if test="telephone != null and telephone !=''"> <if test="telephone != null and telephone !=''">
and telephone like '%${telephone}%' <bind name="bindTelephone" value="'%'+telephone+'%'"/>
and telephone like #{bindTelephone}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
order by id desc order by id desc
...@@ -29,16 +32,19 @@ ...@@ -29,16 +32,19 @@
FROM jsh_supplier FROM jsh_supplier
WHERE 1=1 WHERE 1=1
<if test="supplier != null and supplier !=''"> <if test="supplier != null and supplier !=''">
and supplier like '%${supplier}%' <bind name="bindSupplier" value="'%'+supplier+'%'"/>
and supplier like #{bindSupplier}
</if> </if>
<if test="type != null and type !=''"> <if test="type != null and type !=''">
and type='${type}' and type=#{type}
</if> </if>
<if test="phonenum != null and phonenum !=''"> <if test="phonenum != null and phonenum !=''">
and phone_num like '%${phonenum}%' <bind name="bindPhoneNum" value="'%'+phonenum+'%'"/>
and phone_num like #{bindPhoneNum}
</if> </if>
<if test="telephone != null and telephone !=''"> <if test="telephone != null and telephone !=''">
and telephone like '%${telephone}%' <bind name="bindTelephone" value="'%'+telephone+'%'"/>
and telephone like #{bindTelephone}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>
...@@ -48,16 +54,19 @@ ...@@ -48,16 +54,19 @@
FROM jsh_supplier FROM jsh_supplier
where 1=1 where 1=1
<if test="supplier != null and supplier !=''"> <if test="supplier != null and supplier !=''">
and supplier like '%${supplier}%' <bind name="bindSupplier" value="'%'+supplier+'%'"/>
and supplier like #{bindSupplier}
</if> </if>
<if test="type != null and type !=''"> <if test="type != null and type !=''">
and type='${type}' and type=#{type}
</if> </if>
<if test="phonenum != null and phonenum !=''"> <if test="phonenum != null and phonenum !=''">
and phone_num like '%${phonenum}%' <bind name="bindPhoneNum" value="'%'+phonenum+'%'"/>
and phone_num like #{bindPhoneNum}
</if> </if>
<if test="telephone != null and telephone !=''"> <if test="telephone != null and telephone !=''">
and telephone like '%${telephone}%' <bind name="bindTelephone" value="'%'+telephone+'%'"/>
and telephone like #{bindTelephone}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
order by id desc order by id desc
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
FROM jsh_system_config FROM jsh_system_config
where 1=1 where 1=1
<if test="companyName != null"> <if test="companyName != null">
and company_name like '%${companyName}%' <bind name="bindCompanyName" value="'%'+companyName+'%'"/>
and company_name like #{bindCompanyName}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
...@@ -19,7 +20,8 @@ ...@@ -19,7 +20,8 @@
FROM jsh_system_config FROM jsh_system_config
WHERE 1=1 WHERE 1=1
<if test="companyName != null"> <if test="companyName != null">
and company_name like '%${companyName}%' <bind name="bindCompanyName" value="'%'+companyName+'%'"/>
and company_name like #{bindCompanyName}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
FROM jsh_tenant FROM jsh_tenant
where 1=1 where 1=1
<if test="loginName != null"> <if test="loginName != null">
and login_name like '%${loginName}%' <bind name="bindLoginName" value="'%'+loginName+'%'"/>
and login_name like #{bindLoginName}
</if> </if>
order by id desc order by id desc
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
...@@ -23,7 +24,8 @@ ...@@ -23,7 +24,8 @@
FROM jsh_tenant FROM jsh_tenant
WHERE 1=1 WHERE 1=1
<if test="loginName != null"> <if test="loginName != null">
and login_name like '%${loginName}%' <bind name="bindLoginName" value="'%'+loginName+'%'"/>
and login_name like #{bindLoginName}
</if> </if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
FROM jsh_unit FROM jsh_unit
where 1=1 where 1=1
<if test="name != null"> <if test="name != null">
and name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
...@@ -19,7 +20,8 @@ ...@@ -19,7 +20,8 @@
FROM jsh_unit FROM jsh_unit
WHERE 1=1 WHERE 1=1
<if test="name != null"> <if test="name != null">
and name like '%${name}%' <bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>
......
...@@ -25,10 +25,12 @@ ...@@ -25,10 +25,12 @@
where 1=1 where 1=1
and ifnull(user.status,'0') not in('1','2') and ifnull(user.status,'0') not in('1','2')
<if test="userName != null"> <if test="userName != null">
and user.username like '%${userName}%' <bind name="bindUserName" value="'%'+userName+'%'"/>
and user.username like #{bindUserName}
</if> </if>
<if test="loginName != null"> <if test="loginName != null">
and user.login_name like '%${loginName}%' <bind name="bindLoginName" value="'%'+loginName+'%'"/>
and user.login_name like #{bindLoginName}
</if> </if>
order by rel.user_blng_orga_dspl_seq,user.id desc order by rel.user_blng_orga_dspl_seq,user.id desc
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
...@@ -41,10 +43,12 @@ ...@@ -41,10 +43,12 @@
where 1=1 where 1=1
and ifnull(user.status,'0') not in('1','2') and ifnull(user.status,'0') not in('1','2')
<if test="userName != null"> <if test="userName != null">
and user.username like '%${userName}%' <bind name="bindUserName" value="'%'+userName+'%'"/>
and user.username like #{bindUserName}
</if> </if>
<if test="loginName != null"> <if test="loginName != null">
and user.login_name like '%${loginName}%' <bind name="bindLoginName" value="'%'+loginName+'%'"/>
and user.login_name like #{bindLoginName}
</if> </if>
</select> </select>
<select id="getUserListByUserNameOrLoginName" resultMap="com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap"> <select id="getUserListByUserNameOrLoginName" resultMap="com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment