@ -6,20 +6,34 @@
<resultMap type= "com.zdxt.code.domain.ComprehensiveAnalysis" id= "ComprehensiveAnalysisResult" >
<result property= "enterpriseNumber" column= "enterprise_number" />
<result property= "enterpriseName" column= "enterprise_name" />
<result property= "enterpriseAddress" column= "enterprise_address" />
<result property= "checkCategory" column= "check_category" />
<result property= "companyOrgType" column= "company_org_type" />
<result property= "complaintType" column= "complaint_type" />
<result property= "bureauDeptId" column= "bureau_dept_id" />
<result property= "bureauDeptName" column= "bureau_dept_name" />
</resultMap>
<select id= "primarySectionA" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select r.check_category, e.company_org_type,e.enterprise_number
select r.check_category, e.company_org_type,r.enterprise_number,r.enterprise_name,e.enterprise_address,r.bureau_dept_id,r.bureau_dept_name
from enforcement_registration r
left join enterprise_information e
left join (select * from enterprise_information group by enterprise_number) e
on r.enterprise_number = e.enterprise_number
<where >
and r.enterprise_number is not null
and r.check_category is not null
<if test= "userId != null and userId != '' " > and( r.law_enforcer_id=#{userId} or r.law_enforcer_id_two=#{userId})</if>
<if test= "userId != null and userId != '' " > and( r.law_enforcer_id=#{userId} or
r.law_enforcer_id_two=#{userId})
</if>
<if test= "bureauDeptId != null and bureauDeptId != '' " > and r.bureau_dept_id=#{bureauDeptId}</if>
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(r.create_time)=#{year}
</if>
@ -38,9 +52,9 @@
</where>
</select>
<select id= "huanSectionA" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select r.check_category, e.company_org_type
select r.check_category, e.company_org_type,e.enterprise_address
from enforcement_registration r
left join enterprise_information e
left join (select * from enterprise_information group by enterprise_number) e
on r.enterprise_number = e.enterprise_number
<where >
and r.enterprise_number is not null
@ -49,6 +63,14 @@
r.law_enforcer_id_two=#{userId})
</if>
<if test= "bureauDeptId != null and bureauDeptId != '' " > and r.bureau_dept_id=#{bureauDeptId}</if>
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(r.create_time)+1=#{year}
</if>
@ -67,9 +89,9 @@
</where>
</select>
<select id= "tongSectionA" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select r.check_category, e.company_org_type
select r.check_category, e.company_org_type,e.enterprise_address
from enforcement_registration r
left join enterprise_information e
left join (select * from enterprise_information group by enterprise_number) e
on r.enterprise_number = e.enterprise_number
<where >
and r.enterprise_number is not null
@ -78,6 +100,14 @@
r.law_enforcer_id_two=#{userId})
</if>
<if test= "bureauDeptId != null and bureauDeptId != '' " > and r.bureau_dept_id=#{bureauDeptId}</if>
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(r.create_time)+1=#{year}
</if>
@ -149,7 +179,8 @@
</select>
<select id= "complaintTypeList" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select c.enforce_type as complaint_type from complaint_statistics c
left join (select id,bureau_dept_id,law_enforcer_id,law_enforcer_id_two from enforcement_registration where enterprise_number is not null and check_category is not null) r
left join (select id,bureau_dept_id,law_enforcer_id,law_enforcer_id_two from enforcement_registration where
enterprise_number is not null and check_category is not null) r
on c.rid=r.id
<where >
and (c.rid is not null or c.complaint_department_id is not null)
@ -157,7 +188,9 @@
<if test= "userId != null and userId != '' " > and( r.law_enforcer_id=#{userId} or
r.law_enforcer_id_two=#{userId})
</if>
<if test= "bureauDeptId != null and bureauDeptId != '' " > and( r.bureau_dept_id=#{bureauDeptId} or c.complaint_department_id=#{bureauDeptId})</if>
<if test= "bureauDeptId != null and bureauDeptId != '' " > and( r.bureau_dept_id=#{bureauDeptId} or
c.complaint_department_id=#{bureauDeptId})
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(c.complaint_time)=#{year}
</if>
@ -175,4 +208,429 @@
</if>
</where>
</select>
<select id= "primaryNotice" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address from enterprise_law_enforcement n
left join (select * from enterprise_information group by enterprise_number) e
on n.enterprise_number=e.enterprise_number
<where >
and n.enterprise_number is not null
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(n.create_time)=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(n.create_time)=#{year}
and QUARTER(n.create_time)=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(n.create_time)=#{year}
and MONTH(n.create_time)=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(n.create_time,'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(n.create_time,'%Y-%m-%d')
</if>
</where>
</select>
<select id= "huanNotice" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address from enterprise_law_enforcement n
left join (select * from enterprise_information group by enterprise_number) e
on n.enterprise_number=e.enterprise_number
<where >
and n.enterprise_number is not null
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(n.create_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(n.create_time,INTERVAL -1 quarter))=#{year}
and QUARTER(DATE_SUB(n.create_time,INTERVAL -1 quarter))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(n.create_time,INTERVAL -1 month))=#{year}
and MONTH(DATE_SUB(n.create_time,INTERVAL -1 month))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and n.create_time>=DATE_SUB(beginTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)
and DATE_SUB(endTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)>=n.create_time
</if>
</where>
</select>
<select id= "tongNotice" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address from enterprise_law_enforcement n
left join (select * from enterprise_information group by enterprise_number) e
on n.enterprise_number=e.enterprise_number
<where >
and n.enterprise_number is not null
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(n.create_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(n.create_time,INTERVAL -1 year))=#{year}
and QUARTER(DATE_SUB(n.create_time,INTERVAL -1 year))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(n.create_time,INTERVAL -1 year))=#{year}
and MONTH(DATE_SUB(n.create_time,INTERVAL -1 year))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(DATE_SUB(n.create_time,INTERVAL -1 year),'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(DATE_SUB(n.create_time,INTERVAL -1 year),'%Y-%m-%d')
</if>
</where>
</select>
<select id= "primaryComplaint" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address,c.enforce_type from complaint_statistics c
left join (select * from enterprise_information group by enterprise_number) e
on c.enterprise_number=e.enterprise_number
<where >
and (c.rid is not null or c.complaint_department_id is not null)
and c.enforce_type is not null
and c.enterprise_number is not null
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(c.complaint_time)=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(c.complaint_time)=#{year}
and QUARTER(c.complaint_time)=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(c.complaint_time)=#{year}
and MONTH(c.complaint_time)=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(c.complaint_time,'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(c.complaint_time,'%Y-%m-%d')
</if>
</where>
</select>
<select id= "huanComplaint" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address,c.enforce_type from complaint_statistics c
left join (select * from enterprise_information group by enterprise_number) e
on c.enterprise_number=e.enterprise_number
<where >
and (c.rid is not null or c.complaint_department_id is not null)
and c.enforce_type is not null
and c.enterprise_number is not null
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(c.complaint_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(c.complaint_time,INTERVAL -1 quarter))=#{year}
and QUARTER(DATE_SUB(c.complaint_time,INTERVAL -1 quarter))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(c.complaint_time,INTERVAL -1 month))=#{year}
and MONTH(DATE_SUB(c.complaint_time,INTERVAL -1 month))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and c.complaint_time>=DATE_SUB(beginTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)
and DATE_SUB(endTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)>=c.complaint_time
</if>
</where>
</select>
<select id= "tongComplaint" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address,c.enforce_type from complaint_statistics c
left join (select * from enterprise_information group by enterprise_number) e
on c.enterprise_number=e.enterprise_number
<where >
and (c.rid is not null or c.complaint_department_id is not null)
and c.enforce_type is not null
and c.enterprise_number is not null
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(c.complaint_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{year}
and QUARTER(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{year}
and MONTH(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(DATE_SUB(c.complaint_time,INTERVAL -1 year),'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(DATE_SUB(c.complaint_time,INTERVAL -1 year),'%Y-%m-%d')
</if>
</where>
</select>
<select id= "primaryWarning" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address from law_enforcement_warning_list w
left join (select * from enterprise_information group by enterprise_number) e
on w.enterprise_number=e.enterprise_number
<where >
and w.enterprise_number is not null
and warn_type = 1
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(w.create_time)=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(w.create_time)=#{year}
and QUARTER(w.create_time)=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(w.create_time)=#{year}
and MONTH(w.create_time)=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(w.create_time,'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(w.create_time,'%Y-%m-%d')
</if>
</where>
</select>
<select id= "huanWarning" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address from law_enforcement_warning_list w
left join (select * from enterprise_information group by enterprise_number) e
on w.enterprise_number=e.enterprise_number
<where >
and w.enterprise_number is not null
and warn_type = 1
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(w.create_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(w.create_time,INTERVAL -1 quarter))=#{year}
and QUARTER(DATE_SUB(w.create_time,INTERVAL -1 quarter))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(w.create_time,INTERVAL -1 month))=#{year}
and MONTH(DATE_SUB(w.create_time,INTERVAL -1 month))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and w.create_time>=DATE_SUB(beginTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)
and DATE_SUB(endTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)>=w.create_time
</if>
</where>
</select>
<select id= "tongWarning" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select e.enterprise_address from law_enforcement_warning_list w
left join (select * from enterprise_information group by enterprise_number) e
on w.enterprise_number=e.enterprise_number
<where >
and w.enterprise_number is not null
and warn_type = 1
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(w.create_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(w.create_time,INTERVAL -1 year))=#{year}
and QUARTER(DATE_SUB(w.create_time,INTERVAL -1 year))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(w.create_time,INTERVAL -1 year))=#{year}
and MONTH(DATE_SUB(w.create_time,INTERVAL -1 year))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(DATE_SUB(w.create_time,INTERVAL -1 year),'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(DATE_SUB(w.create_time,INTERVAL -1 year),'%Y-%m-%d')
</if>
</where>
</select>
<select id= "primaryEnterprise" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select enterprise_address,company_org_type from enterprise_information
<where >
and is_unsubscribe is not null
and company_org_type is not null
and enterprise_address is not null
<if test= "qy != null and qy != ''" >
and (enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(create_time)=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(create_time)=#{year}
and QUARTER(create_time)=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(create_time)=#{year}
and MONTH(create_time)=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(create_time,'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(create_time,'%Y-%m-%d')
</if>
</where>
group by enterprise_number
</select>
<select id= "huanEnterprise" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select enterprise_address,company_org_type from enterprise_information
<where >
and is_unsubscribe is not null
and company_org_type is not null
and enterprise_address is not null
<if test= "qy != null and qy != ''" >
and (enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(create_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(create_time,INTERVAL -1 quarter))=#{year}
and QUARTER(DATE_SUB(create_time,INTERVAL -1 quarter))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(create_time,INTERVAL -1 month))=#{year}
and MONTH(DATE_SUB(create_time,INTERVAL -1 month))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and create_time>=DATE_SUB(beginTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)
and DATE_SUB(endTime,INTERVAL TO_DAY(endTime)-TO_DAY(beginTime)+1 day)>=create_time
</if>
</where>
group by enterprise_number
</select>
<select id= "tongEnterprise" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select enterprise_address,company_org_type from enterprise_information
<where >
and is_unsubscribe is not null
and company_org_type is not null
and enterprise_address is not null
<if test= "qy != null and qy != ''" >
and (enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(create_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(create_time,INTERVAL -1 year))=#{year}
and QUARTER(DATE_SUB(create_time,INTERVAL -1 year))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(create_time,INTERVAL -1 year))=#{year}
and MONTH(DATE_SUB(create_time,INTERVAL -1 year))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(DATE_SUB(create_time,INTERVAL -1 year),'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(DATE_SUB(create_time,INTERVAL -1 year),'%Y-%m-%d')
</if>
</where>
group by enterprise_number
</select>
<select id= "complaintGetBureauDept" parameterType= "ComprehensiveAnalysis" resultMap= "ComprehensiveAnalysisResult" >
select bureau_dept_id,bureau_dept_name,count(*) as total from(
select ( CASE WHEN c.rid IS NULL THEN c.complaint_department_id ELSE r.bureau_dept_id END ) AS bureau_dept_id,
( CASE WHEN c.rid IS NULL THEN c.complaint_department ELSE r.bureau_dept_name END ) AS bureau_dept_name
from complaint_statistics c
left join (select id,bureau_dept_id,bureau_dept_name from enforcement_registration where
enterprise_number is not null and check_category is not null) r
on c.rid=r.id
left join (select * from enterprise_information group by enterprise_number) e
on c.enterprise_number=e.enterprise_number
<where >
and (c.rid is not null or c.complaint_department_id is not null)
and c.enforce_type is not null
and c.enterprise_number is not null
<if test= "qy != null and qy != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区%'))
<if test= "jd != null and jd != ''" >
and (e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '区',#{jd},'%')or
e.enterprise_address like concat('深圳市',substring_index(#{qy}, "区",1), '新区',#{jd},'%'))
</if>
</if>
<if test= "dateType != null and dateType != '' and dateType == 'year' " >
and YEAR(c.complaint_time)+1=#{year}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'quarter' " >
and YEAR(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{year}
and QUARTER(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{quarter}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'month' " >
and YEAR(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{year}
and MONTH(DATE_SUB(c.complaint_time,INTERVAL -1 year))=#{month}
</if>
<if test= "dateType != null and dateType != '' and dateType == 'day' " >
and DATE_FORMAT(DATE_SUB(c.complaint_time,INTERVAL -1 year),'%Y-%m-%d') >= #{beginTime}
and #{endTime} >= DATE_FORMAT(DATE_SUB(c.complaint_time,INTERVAL -1 year),'%Y-%m-%d')
</if>
</where>
)x
group by bureau_dept_id order by total desc
</select>
</mapper>