CREATE VIEW `mes_view_report_plan_detail` AS
SELECT `wp`.`id`                  AS `id`,
       `wp`.`report_id`           AS `report_id`,
       `wp`.`plan_id`             AS `plan_id`,
       `wp`.`product_id`          AS `product_id`,
       `wp`.`quality_number_plan` AS `quality_number_plan`,
       `wp`.`waste_number_plan`   AS `waste_number_plan`,
       `wp`.`report_time_plan`    AS `report_time_plan`,
       `wp`.`total_time_plan`     AS `total_time_plan`,
       `wp`.`creator`             AS `creator`,
       `wp`.`create_time`         AS `create_time`,
       `wp`.`updater`             AS `updater`,
       `wp`.`update_time`         AS `update_time`,
       `wp`.`deleted`             AS `deleted`,
       `wp`.`tenant_id`           AS `tenant_id`,
       `pd`.`user_id`             AS `user_id`,
       `pd`.`report_type`         AS `report_type`,
       `pd`.`group_type`          AS `group_type`,
       `pd`.`org_type`            AS `org_type`,
       `pd`.`org_id`              AS `org_id`,
       `pd`.`quality_number`      AS `quality_number`,
       `pd`.`waste_number`        AS `waste_number`,
       `pd`.`report_date`         AS `report_date`,
       `pd`.`report_status`       AS `report_status`,
       `pd`.`creator`             AS `report_creator`
FROM (
         `mes_work_report_plan` `wp`
             JOIN `mes_produce_report_detail` `pd` ON ((
             `wp`.`report_id` = `pd`.`id`
                 and `wp`.`deleted` = 0
                 and `pd`.`deleted` =0
             )))


UPDATE mes_org_worker wo
    JOIN mes_organization org ON wo.org_id = org.org_id
SET wo.org_type = org.org_type;