SELECT d.region_id, d.parent_id, d.ancestors, d.region_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.region_type, d.company_unified_social_credit_code, d.company_business_license, d.company_registered_address_of_business_license, d.company_scale, d.company_number_of_employees, d.company_established, d.company_area, d.company_registered_capital, d.company_total_assets, d.company_actual_income_of_the_previous_year, d.company_annual_profit, d.company_economic_type, d.company_industry, d.company_legal_representative, d.company_corporate_position, d.company_legal_person_phone, d.company_corporate_office_phone, d.company_person_in_charge_of_rectification, d.company_rectifier_phone, d.company_organizer, d.company_group_company_name, d.company_security_function, d.company_postal_code, d.company_introduction, d.company_other, c.company_id,c.company_name FROM tr_region d LEFT JOIN sys_company AS c ON d.company_id = c.company_id insert into tr_region( region_id, company_id, parent_id, region_name, ancestors, order_num, leader, phone, email, status, create_by, region_type, company_unified_social_credit_code, company_business_license, company_registered_address_of_business_license, company_scale, company_number_of_employees, company_established, company_area, company_registered_capital, company_total_assets, company_actual_income_of_the_previous_year, company_annual_profit, company_economic_type, company_industry, company_legal_representative, company_corporate_position, company_legal_person_phone, company_corporate_office_phone, company_person_in_charge_of_rectification, company_rectifier_phone, company_organizer, company_group_company_name, company_security_function, company_postal_code, company_introduction, company_other, create_time )values( #{regionId}, #{companyId}, #{parentId}, #{regionName}, #{ancestors}, #{orderNum}, #{leader}, #{phone}, #{email}, #{status}, #{createBy}, #{regionType}, #{companyUnifiedSocialCreditCode}, #{companyBusinessLicense}, #{companyRegisteredAddressOfBusinessLicense}, #{companyScale}, #{companyNumberOfEmployees}, #{companyEstablished}, #{companyArea}, #{companyRegisteredCapital}, #{companyTotalAssets}, #{companyActualIncomeOfThePreviousYear}, #{companyAnnualProfit}, #{companyEconomicType}, #{companyIndustry}, #{companyLegalRepresentative}, #{companyCorporatePosition}, #{companyLegalPersonPhone}, #{companyCorporateOfficePhone}, #{companyPersonInChargeOfRectification}, #{companyRectifierPhone}, #{companyOrganizer}, #{companyGroupCompanyName}, #{companySecurityFunction}, #{companyPostalCode}, #{companyIntroduction}, #{companyOther}, sysdate() ) update tr_region parent_id = #{parentId}, company_id = #{companyId}, region_name = #{regionName}, ancestors = #{ancestors}, order_num = #{orderNum}, leader = #{leader}, phone = #{phone}, email = #{email}, status = #{status}, update_by = #{updateBy}, region_type = #{regionType}, company_unified_social_credit_code = #{companyUnifiedSocialCreditCode}, company_business_license = #{companyBusinessLicense}, company_registered_address_of_business_license = #{companyRegisteredAddressOfBusinessLicense}, company_scale = #{companyScale}, company_number_of_employees = #{companyNumberOfEmployees}, company_established = #{companyEstablished}, company_area = #{companyArea}, company_registered_capital = #{companyRegisteredCapital}, company_total_assets = #{companyTotalAssets}, company_actual_income_of_the_previous_year = #{companyActualIncomeOfThePreviousYear}, company_annual_profit = #{companyAnnualProfit}, company_economic_type = #{companyEconomicType}, company_industry = #{companyIndustry}, company_legal_representative = #{companyLegalRepresentative}, company_corporate_position = #{companyCorporatePosition}, company_legal_person_phone = #{companyLegalPersonPhone}, company_corporate_office_phone = #{companyCorporateOfficePhone}, company_person_in_charge_of_rectification = #{companyPersonInChargeOfRectification}, company_rectifier_phone = #{companyRectifierPhone}, company_organizer = #{companyOrganizer}, company_group_company_name = #{companyGroupCompanyName}, company_security_function = #{companySecurityFunction}, company_postal_code = #{companyPostalCode}, company_introduction = #{companyIntroduction}, company_other = #{companyOther}, update_time = sysdate() where region_id = #{regionId} update tr_region set ancestors = when #{item.regionId} then #{item.ancestors} where region_id in #{item.regionId} update tr_region set del_flag = '2' where region_id = #{regionId} update tr_region status = #{status}, update_by = #{updateBy}, update_time = sysdate() where region_id in (${ancestors})