select a.material_id,a.material_type_id, a.material_xingh, a.material_guig, a.material_diany, a.material_dw,
case when b.type_state != '0' then b.type_name+'(停用)' else b.type_name end type_name,
a.material_state
from c_material a
left join c_material_type b on a.material_type_id = b.type_no
insert into c_material
material_type_id,material_xingh,material_guig,material_diany,material_dw,material_state,#{materialTypeId},#{materialXingh},#{materialGuig},#{materialDiany},#{materialDw},#{materialState},
update c_material
material_type_id = #{materialTypeId},material_xingh = #{materialXingh},material_guig = #{materialGuig},material_diany = #{materialDiany},material_dw = #{materialDw},material_state = #{materialState},
where material_id = #{materialId}
delete from c_material where material_id = #{materialId}
delete from c_material where material_id in
#{materialId}
delete from c_material_cost where cost_material_id in
#{costMaterialId}
delete from c_material_cost where cost_material_id = #{costMaterialId}
insert into c_material_cost( cost_material_id, cost_cl_id, cost_cl_qty, cost_cl_qty_2) values
( #{item.costMaterialId}, #{item.costClId}, cast(#{item.costClQty} as decimal(18,4)), cast(#{item.costClQty2} as decimal(18,4)))