--调岗调薪单据删除；

update bp_notify set active = False where instance_id in (
    SELECT id FROM bp_instance where bo_model = 'job.transfer' and bo_id in (
        SELECT id from job_transfer where name in ('JCA202206217516')
        )
    );


update bp_log set active = False where instance_id in (
    SELECT id FROM bp_instance where bo_model = 'job.transfer' and bo_id in (
        SELECT id from job_transfer where name in ('JCA202206217516')
        )
    );

update msg
set is_delete = 1
where outter_id in (select outter_id
 from reminder_overview
                    where bp_instance_id in (
                        select id
 from bp_instance
                        where bo_model = 'job.transfer' and bo_id in (
                                SELECT id from job_transfer where name in ('JCA202206217516')
                            )
                    ));

update bp_instance set active = false where bo_model = 'job.transfer' and bo_id in (
        SELECT id from job_transfer where name in ('JCA202206217516')
        );

delete from job_transfer where name in ('JCA202206217516');


--合同单据删除；

update bp_notify set active = False where instance_id in (
    SELECT id FROM bp_instance where bo_model = 'hr.contract' and bo_id in (
        SELECT id from hr_contract where code in ('HC20220705010258')
        )
    );

update bp_log set active = False where instance_id in (
    SELECT id FROM bp_instance where bo_model = 'hr.contract' and bo_id in (
        SELECT id from hr_contract where code in ('HC20220705010258')
        )
    );

update msg
set is_delete = 1
where outter_id in (select outter_id
 from reminder_overview
                    where bp_instance_id in (
                        select id
 from bp_instance
                        where bo_model = 'hr.contract' and bo_id in (
                                SELECT id from hr_contract where code in ('HC20220705010258')
                            )
                    ));

update bp_instance set active = false where bo_model = 'hr.contract' and bo_id in (
        SELECT id from hr_contract where code in ('HC20220705010258')
        );

delete from hr_contract where code in ('HC20220705010258');



