plan_id, plan_no, plan_status, prod_status, sort_no,
in_mat_no, sg_sign, in_mat_thick, in_mat_width, in_mat_wt, in_mat_len,
in_mat_in_dia, in_mat_dia, out_thick, pass_count, recipe_id, recipe_no,
del_flag, create_by, create_time, update_by, update_time, remark
INSERT INTO mill_production_plan (
plan_no, plan_status, prod_status, sort_no,
in_mat_no, sg_sign, in_mat_thick, in_mat_width, in_mat_wt, in_mat_len,
in_mat_in_dia, in_mat_dia, out_thick, pass_count, recipe_id, recipe_no,
create_by, create_time, update_by, update_time, remark, del_flag
) VALUES (
#{planNo}, IFNULL(#{planStatus},'0'), IFNULL(#{prodStatus},'Idle'), IFNULL(#{sortNo},0),
#{inMatNo}, #{alloyNo}, #{inMatThick}, #{inMatWidth}, #{inMatWeight}, #{inMatLength},
#{inMatId}, #{inMatOd}, #{outThick}, IFNULL(#{passCount},0), #{recipeId}, #{recipeNo},
#{createBy}, NOW(), #{updateBy}, NOW(), #{remark}, '0'
)
UPDATE mill_production_plan
SET plan_status = #{planStatus},
prod_status = #{prodStatus},
in_mat_no = #{inMatNo},
sg_sign = #{alloyNo},
in_mat_thick = #{inMatThick},
in_mat_width = #{inMatWidth},
in_mat_wt = #{inMatWeight},
in_mat_len = #{inMatLength},
in_mat_in_dia = #{inMatId},
in_mat_dia = #{inMatOd},
out_thick = #{outThick},
pass_count = #{passCount},
recipe_id = #{recipeId},
recipe_no = #{recipeNo},
update_by = #{updateBy},
update_time = NOW(),
remark = #{remark}
WHERE plan_id = #{planId}
UPDATE mill_production_plan SET del_flag = '2', update_time = NOW()
WHERE plan_id = #{planId}
UPDATE mill_production_plan SET sort_no = #{sortNo} WHERE plan_id = #{planId}
UPDATE mill_production_plan SET sort_no = sort_no + 1
WHERE sort_no >= #{targetSort} AND del_flag = '0'