Browse Source

监督端-执法分析导出

dev-V1.10.0
niujiyi 9 hours ago
parent
commit
79fdb683cd
  1. 134
      zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/report/EnforcementRegistrationReportMapper.xml

134
zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/report/EnforcementRegistrationReportMapper.xml

@ -660,6 +660,140 @@
</choose> </choose>
</select> </select>
<!-- 查询执法记录导出excel -->
<select id="selectAnalysisExportV2" resultType="com.zdxt.enforcementcode.domain.vo.report.RegistrationAnalysisVo">
SELECT
er.district,
er.street,
er.enterprise_name AS enterpriseName,
er.enterprise_number AS enterpriseNumber,
er.bureau_dept_name AS bureauDeptName,
CONCAT_WS(',', er.law_enforcer, NULLIF(er.law_enforcer_two, '')) AS lawEnforcer,
er.law_enforcement_item_text AS lawEnforcementItemText,
DATE_FORMAT(er.enforcement_time, '%Y-%m-%d') AS enforcementTime,
stat.totalCount
FROM enforcement_registration er
INNER JOIN (
SELECT
enterprise_number,
MAX(CONCAT(enforcement_time, '|', id)) AS max_key,
COUNT(1) AS totalCount
FROM enforcement_registration er
<where>
AND er.is_submit = 1
AND er.is_delete = 0
AND er.bureau_dept_name is not null
AND er.law_enforcement_id is not null
AND er.enterprise_name is not null
AND er.enterprise_number is not null AND er.enterprise_number != ''
AND er.law_enforcer is not null
AND er.is_complaint is not null
AND er.check_category is not null
AND er.bureau_dept_id is not null
AND (er.status = 0 OR er.status IS NULL)
<if test="bo.bureauDeptName != null and bo.bureauDeptName != ''">
AND er.bureau_dept_name LIKE CONCAT('%', #{bo.bureauDeptName}, '%')
</if>
<if test="bo.lawEnforcer != null and bo.lawEnforcer != ''">
AND (er.law_enforcer LIKE CONCAT('%', #{bo.lawEnforcer}, '%')
OR er.law_enforcer_two LIKE CONCAT('%', #{bo.lawEnforcer}, '%'))
</if>
<if test="bo.enterpriseName != null and bo.enterpriseName != ''">
AND er.enterprise_name LIKE CONCAT('%', #{bo.enterpriseName}, '%')
</if>
<if test="bo.lawEnforcementItemText != null and bo.lawEnforcementItemText != ''">
AND er.law_enforcement_item_text LIKE CONCAT('%', #{bo.lawEnforcementItemText}, '%')
</if>
<if test="bo.district != null and bo.district != ''">
AND (er.enterprise_address LIKE CONCAT('深圳市', SUBSTRING_INDEX(#{bo.district}, '区', 1), '区%')
OR er.enterprise_address LIKE CONCAT('深圳市', SUBSTRING_INDEX(#{bo.district}, '区', 1), '新区%'))
</if>
<if test="bo.street != null and bo.street != ''">
AND (er.enterprise_address LIKE CONCAT('深圳市', SUBSTRING_INDEX(#{bo.district}, '区', 1), '区', #{bo.street}, '%')
OR er.enterprise_address LIKE CONCAT('深圳市', SUBSTRING_INDEX(#{bo.district}, '区', 1), '新区', #{bo.street}, '%'))
</if>
<if test="bo.dateType != null and bo.dateType == 1">
AND er.enforcement_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01')
AND er.enforcement_time &lt; DATE_FORMAT(DATE_ADD(LAST_DAY(CURDATE()),INTERVAL 1 DAY),'%Y-%m-01')
</if>
<if test="bo.dateType != null and bo.dateType == 2">
AND er.enforcement_time >= MAKEDATE(YEAR(CURDATE()),1) + INTERVAL (QUARTER(CURDATE())-1)*3 MONTH
AND er.enforcement_time &lt; MAKEDATE(YEAR(CURDATE()),1) + INTERVAL QUARTER(CURDATE())*3 MONTH
</if>
<if test="bo.dateType != null and bo.dateType == 3">
AND er.enforcement_time >= DATE_FORMAT(CURDATE(), '%Y-01-01')
AND er.enforcement_time &lt; DATE_FORMAT(DATE_ADD(MAKEDATE(YEAR(CURDATE()), 1),INTERVAL 1 YEAR),'%Y-%m-01')
</if>
<if test="bo.dateSearch != null and bo.dateSearch != ''">
AND er.enforcement_time >= STR_TO_DATE(CONCAT(#{bo.dateSearch},'-01'),'%Y-%m-%d')
AND er.enforcement_time &lt; DATE_ADD(STR_TO_DATE(CONCAT(#{bo.dateSearch},'-01'),'%Y-%m-%d'),INTERVAL 1 MONTH)
</if>
<if test="bo.beginTime != null and bo.beginTime != ''">
AND er.enforcement_time >= #{bo.beginTime}
</if>
<if test="bo.endTime != null and bo.endTime != ''">
AND er.enforcement_time &lt; DATE_ADD(#{bo.endTime}, INTERVAL 1 DAY)
</if>
<if test="dataFilter != null and dataFilter != ''">
${dataFilter}
</if>
</where>
GROUP BY enterprise_number
) stat ON er.enterprise_number = stat.enterprise_number AND CONCAT(er.enforcement_time,'|',er.id)=stat.max_key
LEFT JOIN sys_dict_data area
ON area.dict_type = 'address_type'
AND area.status = '0'
AND area.dict_label = er.district
LEFT JOIN sys_dict_data str
ON str.dict_type = area.dict_value
AND str.status = '0'
AND str.dict_label = er.street
WHERE er.is_delete=0 AND er.is_submit=1
<if test="bo.numLeft != null and bo.numLeft != ''">
AND stat.totalCount >= #{bo.numLeft}
</if>
<if test="bo.numRight != null and bo.numRight != ''">
AND stat.totalCount &lt;= #{bo.numRight}
</if>
<if test="bo.num != null and bo.num != ''">
AND stat.totalCount >= #{bo.num}
</if>
<!-- orderByColumn 有值 → 走白名单映射(避免 ${} 注入);没值 → 默认按区域-街道-时间排序 -->
ORDER BY
<choose>
<when test="bo.orderByColumn != null and bo.orderByColumn != ''">
<choose>
<when test="bo.orderByColumn == 'totalCount'">stat.totalCount</when>
<when test="bo.orderByColumn == 'enterpriseName'">er.enterprise_name</when>
<when test="bo.orderByColumn == 'enterpriseNumber'">er.enterprise_number</when>
<when test="bo.orderByColumn == 'bureauDeptName'">er.bureau_dept_name</when>
<when test="bo.orderByColumn == 'district'">er.district</when>
<when test="bo.orderByColumn == 'street'">er.street</when>
<when test="bo.orderByColumn == 'enforcementTime'">er.enforcement_time</when>
<otherwise>stat.totalCount</otherwise>
</choose>
<if test="bo.isAsc == 'desc'">desc</if>
</when>
<otherwise>
CASE
WHEN er.district IS NULL OR er.district = '' THEN 2
WHEN area.dict_sort IS NULL THEN 1
ELSE 0
END,
area.dict_sort,
er.district,
CASE
WHEN er.street IS NULL OR er.street = '' THEN 2
WHEN str.dict_sort IS NULL THEN 1
ELSE 0
END,
str.dict_sort,
er.street,
er.enforcement_time DESC
</otherwise>
</choose>
</select>
<!-- 执法分析-详情(指定企业的执法明细聚合) --> <!-- 执法分析-详情(指定企业的执法明细聚合) -->
<select id="selectAnalysisDetail" resultType="com.zdxt.enforcementcode.domain.vo.report.RegistrationStatisticsAnalysisDetailVo"> <select id="selectAnalysisDetail" resultType="com.zdxt.enforcementcode.domain.vo.report.RegistrationStatisticsAnalysisDetailVo">
SELECT SELECT

Loading…
Cancel
Save