<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keypersonTask" name="重点人员">
    <select id="selectKeyPersonTaskList" resultType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPerson">
        SELECT
            id,
            int_id intId,
            docking_id dockingId,
            type,
            name,
            sys_type sysType,
            card_no cardNo,
            registered_residence registeredResidence,
            phone,
            responsible_company_by_assistance responsibleCompanyByAssistance,
            responsible_person_by_assistance responsiblePersonByAssistance,
            responsible_company_by_key_personnel responsibleCompanyByKeyPersonnel,
            responsible_person_key_personnel responsiblePersonKeyPersonnel,
            responsible_person responsiblePerson,
            responsible_company responsibleCompany,
            sex,
            address,
            criminal_tendency criminalTendency,
            criminal_tendency_situation criminalTendencySituation,
            letters_visits_type lettersVisitsType,
            folk,
            related_person_name relatedPersonName,
            related_person_relation relatedPersonRelation,
            related_person_phone relatedPersonPhone,
            related_person_address relatedPersonAddress,
            control_company_supervisor controlCompanySupervisor,
            control_company_supervisor_person controlCompanySupervisorPerson,
            risk_level riskLevel,
            involving_conflicts_disputes involvingConflictsDisputes,
            create_date createDate,
            update_date updateDate,
            (SELECT id FROM sys_user WHERE company_id = city_id ORDER BY create_date DESC LIMIT 1) createUser,
            update_user updateUser,
            region,
            city_id cityId,
            area_id areaId,
            street_id streetId,
            community_id communityId,
            remarks,
            hazard_assessment_level hazardAssessmentLevel,
            type,
            appid,
            operate_type operateType,
            data_reception_time dataReceptionTime,
            data_processing_time dataProcessingTime
        FROM
            jl_key_person_post
        WHERE
            operate_type = '0'
        ORDER BY create_date ASC
    </select>

    <insert id="insertKeyPersonTask" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPerson">
        insert into jl_key_person (
            id,
            docking_id,
            hazard_assessment_level,
            name,
            sys_type,
            card_no,
            registered_residence,
            phone,
            responsible_company_by_assistance,
            responsible_person_by_assistance,
            responsible_company_by_key_personnel,
            responsible_person_key_personnel,
            responsible_person,
            responsible_company,
            sex,
            address,
            criminal_tendency,
            criminal_tendency_situation,
            letters_visits_type,
            folk,
            related_person_name,
            related_person_relation,
            related_person_phone,
            related_person_address,
            control_company_supervisor,
            control_company_supervisor_person,
            risk_level,
            create_date,
            update_date,
            create_user,
            update_user,
            remarks,
            region,
            city_id,
            area_id,
            street_id,
            community_id,
            involving_conflicts_disputes,
            appid
        ) values (
            UUID(),
            #{dockingId},
            #{hazardAssessmentLevel},
            #{name},
            #{sysType},
            #{cardNo},
            #{registeredResidence},
            #{phone},
            #{responsibleCompanyByAssistance},
            #{responsiblePersonByAssistance},
            #{responsibleCompanyByKeyPersonnel},
            #{responsiblePersonKeyPersonnel},
            #{responsiblePerson},
            #{responsibleCompany},
            #{sex},
            #{address},
            #{criminalTendency},
            #{criminalTendencySituation},
            #{lettersVisitsType},
            #{folk},
            #{relatedPersonName},
            #{relatedPersonRelation},
            #{relatedPersonPhone},
            #{relatedPersonAddress},
            #{controlCompanySupervisor},
            #{controlCompanySupervisorPerson},
            #{riskLevel},
            #{createDate},
            #{updateDate},
            #{createUser},
            #{createUser},
            #{remarks},
            #{region},
            #{cityId},
            #{areaId},
            #{streetId},
            #{communityId},
            #{involvingConflictsDisputes},
            #{appid}
        )
    </insert>

    <update id="updateKeyPersonTask" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPerson">
        UPDATE
            jl_key_person
        SET
            hazard_assessment_level = #{hazardAssessmentLevel},
            name = #{name},
            sys_type = #{sysType},
            card_no = #{cardNo},
            registered_residence = #{registeredResidence},
            phone = #{phone},
            responsible_company_by_assistance = #{responsibleCompanyByAssistance},
            responsible_person_by_assistance = #{responsiblePersonByAssistance},
            responsible_company_by_key_personnel = #{responsibleCompanyByKeyPersonnel},
            responsible_person_key_personnel = #{responsiblePersonKeyPersonnel},
            responsible_person = #{responsiblePerson},
            responsible_company = #{responsibleCompany},
            sex = #{sex},
            address = #{address},
            criminal_tendency = #{criminalTendency},
            criminal_tendency_situation = #{criminalTendencySituation},
            letters_visits_type = #{lettersVisitsType},
            folk = #{folk},
            related_person_name = #{relatedPersonName},
            related_person_relation = #{relatedPersonRelation},
            related_person_phone = #{relatedPersonPhone},
            related_person_address = #{relatedPersonAddress},
            control_company_supervisor = #{controlCompanySupervisor},
            control_company_supervisor_person = #{controlCompanySupervisorPerson},
            risk_level = #{riskLevel},
            update_date = #{updateDate},
            update_user = #{createUser},
            remarks = #{remarks},
            region = #{region},
            city_id = #{cityId},
            area_id = #{areaId},
            street_id = #{streetId},
            community_id = #{communityId},
            involving_conflicts_disputes = #{involvingConflictsDisputes}
        WHERE
            docking_id = #{dockingId}
        AND appid = #{appid}
    </update>

    <delete id="deleteKeyPersonTask" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPerson">
        delete from jl_key_person  WHERE docking_id = #{dockingId} AND appid = #{appid}
    </delete>

    <update id="updateOperateTypeKeyPerson" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPerson">
        UPDATE
            jl_key_person_post
        SET
            operate_type = #{operateType},
            data_processing_time = NOW()
        WHERE
            appid = #{appid}
        AND docking_id = #{dockingId}
        AND int_id = #{intId}
    </update>

    <select id="selectKeyPersonHighlyConcernedRelTaskList" resultType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPersonHighlyConcernedRel">
        SELECT
            id,
            int_id,
            docking_id,
            key_person_id,
            card_no,
            highly_concerned_situation,
            create_date,
            update_date,
            create_user,
            update_user,
            type,
            appid,
            operate_type,
            data_reception_time,
            data_processing_time
        FROM
            jl_key_person_highly_concerned_rel_post
        WHERE
            operate_type = '0'
    </select>

    <insert id="insertKeyPersonHighlyConcernedRelTask" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPersonHighlyConcernedRel">
        insert into jl_key_person_highly_concerned_rel
        (
            id,
            docking_id,
            key_person_id,
            card_no,
            highly_concerned_situation,
            create_date,
            create_user,
            appid
        ) values
        (
            UUID(),
            #{dockingId},
            #{keyPersonId},
            #{cardNo},
            #{highlyConcernedSituation},
            #{createDate},
            #{appid},
            #{appid}
        )
    </insert>

    <update id="updateKeyPersonHighlyConcernedRelTask" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPersonHighlyConcernedRel">
        UPDATE
        jl_key_person_highly_concerned_rel
        SET
        key_person_id = #{keyPersonId},
        card_no = #{cardNo},
        highly_concerned_situation = #{highlyConcernedSituation},
        update_date = #{createDate},
        update_user = #{appid}
        WHERE
        docking_id = #{dockingId}
        AND appid = #{appid}
    </update>

    <delete id="deleteKeyPersonHighlyConcernedRelTask" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPerson">
        delete from jl_key_person_highly_concerned_rel  WHERE docking_id = #{dockingId} AND appid = #{appid}
    </delete>

    <update id="updateOperateTypeKeyPersonHighlyConcernedRel" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.task.JlKeyPerson">
        UPDATE
            jl_key_person_highly_concerned_rel
        SET
            operate_type = #{operateType},
            data_processing_time = NOW()
        WHERE
            appid = #{appid}
        AND docking_id = #{dockingId}
        AND int_id = #{intId}
    </update>
</mapper>
