select count(1) as num from tzs_jg_change_registration_name a, privilege_company b where a.receive_org_code= b.company_code and b.org_code like CONCAT(#{orgCode}, '%') and a.audit_status != '使用单位已撤回' and a.audit_status != '使用单位待提交' and a.audit_status !='已作废' and a.audit_status !='已完成' and date_ge(CAST(a.apply_date as date),#{dto.beginDate}) and date_le(CAST(a.apply_date as date),#{dto.endDate})
select count(1) as num from tzs_jg_change_registration_name a, privilege_company b where a.receive_org_code= b.company_code and b.org_code like CONCAT(#{orgCode}, '%') and a.audit_status != '使用单位已撤回' and a.audit_status != '使用单位待提交' and a.audit_status !='已作废' and a.audit_status !='已完成' and date_ge(CAST(a.apply_date as date),#{dto.beginDate}) and date_le(CAST(a.apply_date as date),#{dto.endDate})
union all
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_reform" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status != '使用单位待提交' and audit_status != '使用单位已撤回' and audit_status != '已作废' and date_ge(CAST(reg_date as date),#{dto.beginDate}) and date_le(CAST(reg_date as date),#{dto.endDate})
SELECT count(1) as num FROM "tzs_jg_change_registration_reform" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status != '使用单位待提交' and audit_status != '使用单位已撤回' and audit_status != '已作废' and audit_status != '已完成' and date_ge(CAST(reg_date as date),#{dto.beginDate}) and date_le(CAST(reg_date as date),#{dto.endDate})
union all
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_transfer" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status != '使用单位待提交' and audit_status != '使用单位已撤回' and audit_status != '已作废' and audit_status != '已完成' and date_ge(CAST(reg_date as date),#{dto.beginDate}) and date_le(CAST(reg_date as date),#{dto.endDate})
SELECT count(1) as num FROM "tzs_jg_change_registration_transfer" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status != '使用单位待提交' and audit_status != '使用单位已撤回' and audit_status != '已作废' and audit_status != '已完成' and date_ge(CAST(reg_date as date),#{dto.beginDate}) and date_le(CAST(reg_date as date),#{dto.endDate})
(SELECT cdd1.NAME from cb_data_dictionary cdd1 where cdd1.code = tzjia.inspection_classify AND cdd1.TYPE = 'JYJCLB' limit 1) as inspectionClassify,
(SELECT cdd2.NAME from cb_data_dictionary cdd2 where cdd2.code = tzjia.status and cdd2.type = 'JYLCZT' limit 1) AS statusName,
(SELECT cdd3.NAME from cb_data_dictionary cdd3 where cdd3.code = tzjia.status and cdd3.type = 'JYJC' limit 1) AS inspectionType,
(SELECT name FROM "tz_equipment_category" ca where ca.code = tzjia.equip_classify) AS equipClassify
FROM
tz_jyjc_inspection_application AS tzjia,
tz_base_enterprise_info b
<where>
tzjia.inspection_unit_code= b.use_unit_code
and ((b.supervise_org_code != '50' and b.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (b.supervise_org_code = '50' and b.office_region LIKE CONCAT ('%', #{dto.cityCode}, '%')))
<iftest="dto.applicationNo != null and dto.applicationNo != ''">
and tzjia.application_no like concat('%',#{dto.applicationNo},'%')
</if>
<iftest="dto.inspectionType != null and dto.inspectionType != ''">
and tzjia.inspection_type = #{dto.inspectionType}
</if>
<iftest="dto.equipClassify != null and dto.equipClassify != ''">
and tzjia.equip_classify = #{dto.equipClassify}
</if>
<iftest="dto.applicationDate != null">
and date_eq(tzjia.application_date, #{dto.applicationDate})
</if>
<iftest="dto.acceptDate != null">
and tzjia.accept_date = #{dto.acceptDate}
</if>
<iftest="dto.inspectionChargePerson != null and dto.inspectionChargePerson != ''">
and tzjia.inspection_charge_person like concat('%',#{dto.inspectionChargePerson},'%')
</if>
<iftest="dto.inspectionChargePersonName != null and dto.inspectionChargePersonName != ''">
and tzjia.inspection_charge_person_name like concat('%',#{dto.inspectionChargePersonName},'%')
</if>
<iftest="dto.status != null and dto.status != ''">
and tzjia.status = #{dto.status}
</if>
<iftest="dto.bizType != null and dto.bizType != ''">
and tzjia.biz_type = #{dto.bizType}
</if>
<iftest="dto.inspectionUnitName != null and dto.inspectionUnitName != ''">
and tzjia.inspection_unit_name like concat('%',#{dto.inspectionUnitName},'%')
</if>
<iftest="dto.applicationUnitName != null and dto.applicationUnitName != ''">
and tzjia.application_unit_name like concat('%',#{dto.applicationUnitName},'%')
</if>
<iftest="dto.inspectionUnitCode != null and dto.inspectionUnitCode != ''">
and tzjia.inspection_unit_code = #{dto.inspectionUnitCode} and tzjia.status != '6610'
</if>
<iftest="dto.applicationUnitCode != null and dto.applicationUnitCode != ''">
and tzjia.application_unit_code = #{dto.applicationUnitCode}