r.law_enforcement_item_text as lawEnforcementItemText,
r.unite_check as uniteCheck,
r.check_category as checkCategory,
r.check_css as checkCss,
r.is_complaint as isComplaint,
r.create_time as createTime,
r.law_id as lawId,
r.enforcement_time as enforcementTime,
r.law_enforce_category as lawEnforceCategory,
r.entrust_dept_name as entrustDeptName,
r.has_auto as hasAuto,
r.has_union as hasUnion,
r.union_no as unionNo
from enforcement_registration r
<where>
and r.bureau_dept_name is not null
and r.law_enforcement_id is not null
and r.enterprise_name is not null
and r.enterprise_number is not null
and r.law_enforcer is not null
and r.law_enforcer_two is not null
and r.is_complaint is not null
and r.check_category is not null
and r.bureau_dept_id is not null
and is_submit=1
<iftest="bo.qy != null and bo.qy != ''">
and (r.enterprise_address like concat('深圳市',substring_index(#{bo.qy}, "区",1), '区%')or r.enterprise_address like concat('深圳市',substring_index(#{bo.qy}, "区",1), '新区%'))
<iftest="bo.jd != null and bo.jd != ''">
and (r.enterprise_address like concat('深圳市',substring_index(#{bo.qy}, "区",1), '区',#{jd},'%')or r.enterprise_address like concat('深圳市',substring_index(#{bo.qy}, "区",1), '新区',#{bo.jd},'%'))
</if>
</if>
<iftest="bo.deptQx != null and bo.deptQx != ''">and r.bureau_dept_id =#{bo.deptQx}</if>
<iftest="bo.lawEnforcement != null and bo.lawEnforcement != ''"> and r.law_enforcement like concat('%', #{bo.lawEnforcement}, '%')</if>
<iftest="bo.bureauDeptName != null and bo.bureauDeptName != ''"> and r.bureau_dept_name like concat('%', #{bo.bureauDeptName}, '%')</if>
<iftest="bo.enterpriseName != null and bo.enterpriseName != ''"> and r.enterprise_name like concat('%', #{bo.enterpriseName}, '%')</if>
<iftest="bo.enterpriseNumber != null and bo.enterpriseNumber != ''"> and r.enterprise_number like concat('%', #{bo.enterpriseNumber}, '%')</if>
<iftest="bo.entrustDeptName != null and bo.entrustDeptName != ''"> and r.entrust_dept_name like concat('%', #{bo.entrustDeptName}, '%')</if>
<iftest="bo.lawEnforcer != null and bo.lawEnforcer != ''"> and (r.law_enforcer like concat('%',#{bo.lawEnforcer} ,'%') or r.law_enforcer_two like concat('%',#{bo.lawEnforcer} ,'%'))</if>
<iftest="bo.isComplaint != null "> and r.is_complaint = #{bo.isComplaint}</if>
<iftest="bo.uniteCheck == '0'.toString()"> and r.unite_check is not null</if>
<iftest="bo.uniteCheck == '1'.toString()"> and r.unite_check is null</if>
<iftest="bo.enforce == '0'.toString()"> and r.check_css is null</if>
<iftest="bo.enforce == '1'.toString()"> and r.check_css is not null</if>
<iftest="bo.unionNo != null and bo.unionNo != ''"> and union_no = #{bo.unionNo}</if>
<iftest="bo.hasUnion != null"> and has_union = #{bo.hasUnion}</if>
<iftest="bo.isRealUnion != null"> and is_real_union = #{bo.isRealUnion}</if>
<iftest="bo.hasAuto != null"> and has_auto = #{bo.hasAuto}</if>
<iftest="bo.checkCategory != null and bo.checkCategory != ''"> and r.check_category = #{bo.checkCategory}</if>
<iftest="bo.checkCss != null and bo.checkCss != ''"> and r.check_css = #{bo.checkCss}</if>
<iftest="bo.lawEnforcementItemText != null and bo.lawEnforcementItemText != ''"> and law_enforcement_item_text like concat('%', #{bo.lawEnforcementItemText,jdbcType=VARCHAR}, '%')</if>
<iftest="bo.beginTime != null and bo.beginTime != ''"><!-- 开始时间检索 -->
and DATE_FORMAT(r.enforcement_time,'%Y-%m-%d') >= STR_TO_DATE(#{bo.beginTime},'%Y-%m-%d')
</if>
<iftest="bo.endTime != null and bo.endTime != ''"><!-- 结束时间检索 -->
and DATE_FORMAT(r.enforcement_time,'%Y-%m-%d') <= STR_TO_DATE(#{bo.endTime},'%Y-%m-%d')
<iftest="bo.dateSearch != null and bo.dateSearch == 'select-time' and (bo.beginTime == null or bo.beginTime == '') and (bo.endTime == null or bo.endTime == '')">
AND YEAR(r.enforcement_time) = YEAR(NOW())
</if>
<iftest="bo.beginEnforcementTime != null and bo.beginEnforcementTime != ''"><!-- 开始时间检索用于预警搜索 -->
and DATE_FORMAT(r.enforcement_time,'%Y-%m-%d') >= STR_TO_DATE(#{bo.beginEnforcementTime},'%Y-%m-%d')
</if>
<iftest="bo.endEnforcementTime != null and bo.endEnforcementTime != ''"><!-- 结束时间检索用于预警搜索 -->
and DATE_FORMAT(r.enforcement_time,'%Y-%m-%d') <= STR_TO_DATE(#{bo.endEnforcementTime},'%Y-%m-%d')
</if>
<iftest="bo.year != null and bo.year != ''">
AND YEAR(r.enforcement_time) = #{bo.year}
</if>
<iftest="bo.quarter != null and bo.quarter != '' ">
AND QUARTER(r.enforcement_time) = #{bo.quarter}
</if>
<iftest="bo.month != null and bo.month != '' ">
AND DATE_FORMAT(r.enforcement_time, '%m') = #{bo.month}
</if>
<iftest="bo.lawEnforceCategory != null and bo.lawEnforceCategory!=''"> and law_enforce_category = #{bo.lawEnforceCategory}</if>
<!-- 数据范围过滤 -->
<!-- <if test="params.dataScope != null and params.dataScope != ''">