insert into business_machine_record(
file_time,machine_code,open_type_cd,id_card,machine_record_id,machine_id,operate,`name`,tel,community_id,b_id,file_id,record_type_cd
) values (
#{fileTime},#{machineCode},#{openTypeCd},#{idCard},#{machineRecordId},#{machineId},#{operate},#{name},#{tel},#{communityId},#{bId},#{fileId}
,#{recordTypeCd}
)
insert into machine_record(
file_time,machine_code,open_type_cd,id_card,status_cd,machine_record_id,machine_id,`name`,tel,community_id,b_id,file_id,record_type_cd
) select
t.file_time,t.machine_code,t.open_type_cd,t.id_card,'0',t.machine_record_id,t.machine_id,t.name,t.tel,t.community_id,t.b_id,t.file_id,t.record_type_cd
from business_machine_record t where 1=1
and t.file_time= #{fileTime}
and t.machine_code= #{machineCode}
and t.open_type_cd= #{openTypeCd}
and t.id_card= #{idCard}
and t.machine_record_id= #{machineRecordId}
and t.machine_id= #{machineId}
and t.operate= 'ADD'
and t.name= #{name}
and t.tel= #{tel}
and t.community_id= #{communityId}
and t.b_id= #{bId}
and t.file_id= #{fileId}
and t.record_type_cd= #{recordTypeCd}
update machine_record t set t.status_cd = #{statusCd}
,t.b_id = #{newBId}
, t.file_time= #{fileTime}
, t.machine_code= #{machineCode}
, t.open_type_cd= #{openTypeCd}
, t.id_card= #{idCard}
, t.machine_id= #{machineId}
, t.name= #{name}
, t.tel= #{tel}
, t.community_id= #{communityId}
, t.file_id= #{fileId}
, t.record_type_cd= #{recordTypeCd}
where 1=1
and t.machine_record_id= #{machineRecordId}
and t.b_id= #{bId}