case when jl_key_person_rating_dual_person.community_id = #{params._scope.scope_area_id} then '1' else '0' end as dualPerson
</when>
<otherwise>
'0' as dualPerson
</otherwise>
</choose>
from jl_key_person
from jl_key_person
left join sys_area city on jl_key_person.city_id = city.code
left join sys_area city on jl_key_person.city_id = city.code
left join sys_area area on jl_key_person.area_id = area.code
left join sys_area area on jl_key_person.area_id = area.code
left join sys_area street on jl_key_person.street_id = street.code
left join sys_area street on jl_key_person.street_id = street.code
left join sys_area community on jl_key_person.community_id = community.code
left join sys_area community on jl_key_person.community_id = community.code
left join jl_key_person_rating_history history on jl_key_person.id = history.key_person_id and history.rating_dict_type = #{params.sysType} and history.is_history = '1'
left join jl_key_person_rating_summary summary on jl_key_person.id = summary.key_person_id and summary.rating_dict_type = #{params.sysType} and summary.is_history = '1'
left join sys_dict rating_dict on rating_dict.type = 'rating_level' and rating_dict.del_flag = '0' and rating_dict.value = summary.rating_type
left join jl_key_person_rating_dual_person on jl_key_person.id = jl_key_person_rating_dual_person.key_person_id
<where> 1=1
<where> 1=1
<iftest="params.involvingConflictsDisputes != null and params.involvingConflictsDisputes != ''">
<iftest="params.involvingConflictsDisputes != null and params.involvingConflictsDisputes != ''">
and involving_conflicts_disputes like concat('%',#{params.involvingConflictsDisputes},'%')
and involving_conflicts_disputes like concat('%',#{params.involvingConflictsDisputes},'%')
</if>
</if>
<iftest="params.ratingLevel != null and params.ratingLevel != ''">
and summary.rating_type like concat('%',#{params.ratingLevel},'%')
</if>
<!-- 处理doStatus=0的情况:查询do_status为null -->
<iftest="params.doStatus != null and params.doStatus == 0">
and history.do_status is null
</if>
<!-- 处理doStatus=1的情况:模糊查询do_status包含1 -->
<iftest="params.doStatus != null and params.doStatus == 1">
and history.do_status like concat('%',#{params.doStatus},'%')
</if>
<iftest="params.doStatus != null and params.doStatus == 2">
and history.do_status like concat('%',#{params.doStatus},'%')
</if>
<iftest="params.isOverdue != null and params.isOverdue != ''">
and history.is_overdue like concat('%',#{params.isOverdue},'%')
</if>
<iftest="params.name != null and params.name != ''">
<iftest="params.name != null and params.name != ''">
and jl_key_person.name like concat('%',#{params.name},'%')
and jl_key_person.name like concat('%',#{params.name},'%')
</if>
</if>
<iftest="params.sysType != null and params.sysType != ''">
<iftest="params.sysType != null and params.sysType != ''">
and jl_key_person.sys_type = #{params.sysType}
and sys_type = #{params.sysType}
</if>
</if>
<iftest="params.cardNo != null and params.cardNo != ''">
<iftest="params.cardNo != null and params.cardNo != ''">
<!--and card_no like concat('%',#{params.cardNo},'%')-->
<!--and card_no like concat('%',#{params.cardNo},'%')-->
case when jl_key_person_rating_dual_person.community_id = #{params._scope.scope_area_id} then '1' else '0' end as dualPerson
</when>
<otherwise>
'0' as dualPerson
</otherwise>
</choose>
from jl_key_person
left join sys_area city on jl_key_person.city_id = city.code
left join sys_area area on jl_key_person.area_id = area.code
left join sys_area street on jl_key_person.street_id = street.code
left join sys_area community on jl_key_person.community_id = community.code
left join jl_key_person_rating_history history on jl_key_person.id = history.key_person_id and history.rating_dict_type = #{params.sysType} and history.is_history = '1'
left join jl_key_person_rating_summary summary on jl_key_person.id = summary.key_person_id and summary.rating_dict_type = #{params.sysType} and summary.is_history = '1'
left join sys_dict rating_dict on rating_dict.type = 'rating_level' and rating_dict.del_flag = '0' and rating_dict.value = summary.rating_type
left join jl_key_person_rating_dual_person on jl_key_person.id = jl_key_person_rating_dual_person.key_person_id
<where> 1=1
<iftest="params.involvingConflictsDisputes != null and params.involvingConflictsDisputes != ''">
and involving_conflicts_disputes like concat('%',#{params.involvingConflictsDisputes},'%')
</if>
<iftest="params.ratingLevel != null and params.ratingLevel != ''">
and summary.rating_type like concat('%',#{params.ratingLevel},'%')
</if>
<!-- 处理doStatus=0的情况:查询do_status为null -->
<iftest="params.doStatus != null and params.doStatus == 0">
and history.do_status is null
</if>
<!-- 处理doStatus=1的情况:模糊查询do_status包含1 -->
<iftest="params.doStatus != null and params.doStatus == 1">
and history.do_status like concat('%',#{params.doStatus},'%')
</if>
<iftest="params.doStatus != null and params.doStatus == 2">
and history.do_status like concat('%',#{params.doStatus},'%')
</if>
<iftest="params.isOverdue != null and params.isOverdue != ''">
and history.is_overdue like concat('%',#{params.isOverdue},'%')
</if>
<iftest="params.name != null and params.name != ''">
and jl_key_person.name like concat('%',#{params.name},'%')
</if>
<iftest="params.sysType != null and params.sysType != ''">
and jl_key_person.sys_type = #{params.sysType}
</if>
<iftest="params.cardNo != null and params.cardNo != ''">
<!--and card_no like concat('%',#{params.cardNo},'%')-->
and card_no like concat('%',TO_BASE64(AES_ENCRYPT(#{params.cardNo},'*#id#')),'%')
</if>
<iftest="params.registeredResidence != null and params.registeredResidence != ''">
and registered_residence = #{params.registeredResidence}
</if>
<iftest="params.phone != null and params.phone != ''">
and phone like concat('%',#{params.phone},'%')
</if>
<iftest="params.hazardAssessmentLevel != null and params.hazardAssessmentLevel != ''">
and hazard_assessment_level like concat('%',#{params.hazardAssessmentLevel},'%')
</if>
<iftest="params.responsibleCompanyByAssistance != null and params.responsibleCompanyByAssistance != ''">
and responsible_company_by_assistance like concat('%',#{params.responsibleCompanyByAssistance},'%')
</if>
<iftest="params.responsiblePersonByAssistance != null and params.responsiblePersonByAssistance != ''">
and responsible_person_by_assistance like concat('%',#{params.responsiblePersonByAssistance},'%')
</if>
<iftest="params.responsibleCompanyByKeyPersonnel != null and params.responsibleCompanyByKeyPersonnel != ''">
and responsible_company_by_key_personnel like concat('%',#{params.responsibleCompanyByKeyPersonnel},'%')
</if>
<iftest="params.responsiblePersonKeyPersonnel != null and params.responsiblePersonKeyPersonnel != ''">
and responsible_person_key_personnel like concat('%',#{params.responsiblePersonKeyPersonnel},'%')
</if>
<iftest="params.responsiblePerson != null and params.responsiblePerson != ''">
and responsible_person like concat('%',#{params.responsiblePerson},'%')
</if>
<iftest="params.responsibleCompany != null and params.responsibleCompany != ''">
and responsible_company like concat('%',#{params.responsibleCompany},'%')
</if>
<iftest="params.sex != null and params.sex != ''">
and sex = #{params.sex}
</if>
<iftest="params.address != null and params.address != ''">
and address = #{params.address}
</if>
<iftest="params.criminalTendency != null and params.criminalTendency != ''">
and criminal_tendency = #{params.criminalTendency}
</if>
<iftest="params.criminalTendencySituation != null and params.criminalTendencySituation != ''">
and criminal_tendency_situation = #{params.criminalTendencySituation}
</if>
<iftest="params.lettersVisitsType != null and params.lettersVisitsType != ''">
and letters_visits_type = #{params.lettersVisitsType}
</if>
<iftest="params.folk != null and params.folk != ''">
and folk = #{params.folk}
</if>
<iftest="params.relatedPersonName != null and params.relatedPersonName != ''">
and related_person_name = #{params.relatedPersonName}
</if>
<iftest="params.relatedPersonRelation != null and params.relatedPersonRelation != ''">
and related_person_relation = #{params.relatedPersonRelation}
</if>
<iftest="params.relatedPersonPhone != null and params.relatedPersonPhone != ''">
and related_person_phone = #{params.relatedPersonPhone}
</if>
<iftest="params.relatedPersonAddress != null and params.relatedPersonAddress != ''">
and related_person_address = #{params.relatedPersonAddress}
</if>
<iftest="params.controlCompanySupervisor != null and params.controlCompanySupervisor != ''">
and control_company_supervisor = #{params.controlCompanySupervisor}
</if>
<iftest="params.controlCompanySupervisorPerson != null and params.controlCompanySupervisorPerson != ''">
and control_company_supervisor_person = #{params.controlCompanySupervisorPerson}
</if>
<iftest="params.riskLevel != null and params.riskLevel != ''">
and risk_level = #{params.riskLevel}
</if>
<iftest="params.cityId!=null and params.cityId!=''">
AND jl_key_person.city_id = #{params.cityId}
</if>
<iftest="params.areaId!=null and params.areaId!=''">
AND jl_key_person.area_id = #{params.areaId}
</if>
<iftest="params.streetId!=null and params.streetId!=''">
AND jl_key_person.street_id = #{params.streetId}
</if>
<iftest="params.communityId!=null and params.communityId!=''">
AND jl_key_person.community_id = #{params.communityId}
cast(AES_DECRYPT(FROM_BASE64(card_no),'*#id#') as char) cardNo,
registered_residence as registeredResidence,
phone,
responsible_company_by_assistance as responsibleCompanyByAssistance,
responsible_person_by_assistance as responsiblePersonByAssistance,
responsible_company_by_key_personnel as responsibleCompanyByKeyPersonnel,
responsible_person_key_personnel as responsiblePersonKeyPersonnel,
responsible_person as responsiblePerson,
responsible_company as responsibleCompany,
<!--sex,-->
case sex when '1' then '男' when '2' then '女' end as sex,
address,
<!--criminal_tendency as criminalTendency,-->
case criminal_tendency when '1' then '有' when '2' then '无' end as criminalTendency,
(select group_concat(highly_concerned_situation) from jl_key_person_highly_concerned_rel where key_person_id=jl_key_person.id) as highly_concerned_situation,
criminal_tendency_situation as criminalTendencySituation,
letters_visits_type lettersVisitsType,
folk,
involving_conflicts_disputes as involvingConflictsDisputes,
city_id as cityId,
area_id as areaId,
street_id as streetId,
community_id as communityId,
community.name communityName,
jl_key_person.remarks as remarks,
hazard_assessment_level as hazardAssessmentLevel,
city.name cityName,
area.name areaName,
street.name streetName,
city.sort as sort1,
area.sort as sort2,
street.sort as sort3,
related_person_name as relatedPersonName,
related_person_relation relatedPersonRelation,
related_person_phone as relatedPersonPhone,
related_person_address as relatedPersonAddress,
control_company_supervisor as controlCompanySupervisor,
control_company_supervisor_person as controlCompanySupervisorPerson,
risk_level as riskLevel,
jl_key_person.create_date as createDate,
jl_key_person.update_date as updateDate,
jl_key_person.create_user as createUser,
jl_key_person.update_user as updateUser
from jl_key_person
left join sys_area city on jl_key_person.city_id = city.code
left join sys_area area on jl_key_person.area_id = area.code
left join sys_area street on jl_key_person.street_id = street.code
left join sys_area community on jl_key_person.community_id = community.code
<where> 1=1
<iftest="involvingConflictsDisputes != null and involvingConflictsDisputes != ''">
and involving_conflicts_disputes like concat('%',#{involvingConflictsDisputes},'%')
</if>
<iftest="name != null and name != ''">
and jl_key_person.name like concat('%',#{name},'%')
</if>
<iftest="sysType != null and sysType != ''">
and sys_type = #{sysType}
</if>
<iftest="cardNo != null and cardNo != ''">
and card_no like concat('%',#{cardNo},'%')
</if>
<iftest="registeredResidence != null and registeredResidence != ''">
and registered_residence = #{registeredResidence}
</if>
<iftest="phone != null and phone != ''">
and phone like concat('%',#{phone},'%')
</if>
<iftest="hazardAssessmentLevel != null and hazardAssessmentLevel != ''">
and hazard_assessment_level like concat('%',#{hazardAssessmentLevel},'%')
</if>
<iftest="responsibleCompanyByAssistance != null and responsibleCompanyByAssistance != ''">
and responsible_company_by_assistance like concat('%',#{responsibleCompanyByAssistance},'%')
</if>
<iftest="responsiblePersonByAssistance != null and responsiblePersonByAssistance != ''">
and responsible_person_by_assistance like concat('%',#{responsiblePersonByAssistance},'%')
</if>
<iftest="responsibleCompanyByKeyPersonnel != null and responsibleCompanyByKeyPersonnel != ''">
and responsible_company_by_key_personnel like concat('%',#{responsibleCompanyByKeyPersonnel},'%')
</if>
<iftest="responsiblePersonKeyPersonnel != null and responsiblePersonKeyPersonnel != ''">
and responsible_person_key_personnel like concat('%',#{responsiblePersonKeyPersonnel},'%')
</if>
<iftest="responsiblePerson != null and responsiblePerson != ''">
and responsible_person like concat('%',#{responsiblePerson},'%')
</if>
<iftest="responsibleCompany != null and responsibleCompany != ''">
and responsible_company like concat('%',#{responsibleCompany},'%')
</if>
<iftest="sex != null and sex != ''">
and sex = #{sex}
</if>
<iftest="address != null and address != ''">
and address = #{address}
</if>
<iftest="criminalTendency != null and criminalTendency != ''">
and criminal_tendency = #{criminalTendency}
</if>
<iftest="criminalTendencySituation != null and criminalTendencySituation != ''">
and criminal_tendency_situation = #{criminalTendencySituation}
</if>
<iftest="lettersVisitsType != null and lettersVisitsType != ''">
and letters_visits_type = #{lettersVisitsType}
</if>
<iftest="folk != null and folk != ''">
and folk = #{folk}
</if>
<iftest="relatedPersonName != null and relatedPersonName != ''">
and related_person_name = #{relatedPersonName}
</if>
<iftest="relatedPersonRelation != null and relatedPersonRelation != ''">
and related_person_relation = #{relatedPersonRelation}
</if>
<iftest="relatedPersonPhone != null and relatedPersonPhone != ''">
and related_person_phone = #{relatedPersonPhone}
</if>
<iftest="relatedPersonAddress != null and relatedPersonAddress != ''">
and related_person_address = #{relatedPersonAddress}
</if>
<iftest="controlCompanySupervisor != null and controlCompanySupervisor != ''">
and control_company_supervisor = #{controlCompanySupervisor}
</if>
<iftest="controlCompanySupervisorPerson != null and controlCompanySupervisorPerson != ''">
and control_company_supervisor_person = #{controlCompanySupervisorPerson}
</if>
<iftest="riskLevel != null and riskLevel != ''">
and risk_level = #{riskLevel}
</if>
<iftest="_user.company_grade != '2'.toString()">
and (
create_user=#{_user.id}
or create_user in (
select id from sys_user where company_id in (
select id from sys_office where parent_ids LIKE CONCAT('%', #{_user.company_id}, '%') and del_flag='0'