select id, name, big_class, small_class, type, is_main, methods, create_by, create_time, update_by, update_time, review_status from sys_dishes SELECT * FROM( SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit, remark FROM sys_dishes_ingredient WHERE dishes_id = #{id} ) dishes LEFT JOIN ( SELECT id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, not_rec, not_rec_ids, rec, rec_ids FROM sys_ingredient igd LEFT JOIN ( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec, GROUP_CONCAT(notRec.id SEPARATOR ',') not_rec_ids FROM( SELECT physical_signs_id as id, ingredient_id FROM sys_ingredient_not_rec ) notRec JOIN sys_physical_signs phy USING(id) GROUP BY id ) notRecT USING(id) LEFT JOIN ( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec, GROUP_CONCAT(rec.id SEPARATOR ',') rec_ids FROM( SELECT physical_signs_id as id, ingredient_id FROM sys_ingredient_rec ) rec JOIN sys_physical_signs phy USING(id) GROUP BY id ) recT USING(id) ) ing USING(id) insert into sys_dishes name, big_class, small_class, type, is_main, methods, create_by, review_status, create_time, update_by, update_time, #{name}, #{bigClass}, #{smallClass}, #{type}, #{isMain}, #{methods}, #{createBy}, #{reviewStatus}, #{createTime}, #{updateBy}, #{updateTime}, update sys_dishes name = #{name}, big_class = #{bigClass}, small_class = #{smallClass}, type = #{type}, is_main = #{isMain}, methods = #{methods}, create_by = #{createBy}, review_status = #{reviewStatus}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, where id = #{id} update sys_dishes set del_flag=1 where id = #{id} delete from sys_dishes_ingredient where dishes_id = #{id} delete from sys_dishes_ingredient where dishes_id in #{id} insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark) values (#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight}, #{item.remark}) insert into sys_dishes_rec(dishes_id, physical_signs_id) values (#{item.targetId},#{item.physicalSignsId}) insert into sys_dishes_not_rec(dishes_id, physical_signs_id) values (#{item.targetId},#{item.physicalSignsId}) delete from sys_dishes_rec where dishes_id=#{dishesId} delete from sys_dishes_not_rec where dishes_id=#{dishesId}