insert into business_application_key(
application_key_id,id_card,sex,end_time,machine_id,operate,type_cd,name,tel,start_time,state,community_id,b_id,age,type_flag,pwd
) values (
#{applicationKeyId},#{idCard},#{sex},#{endTime},#{machineId},#{operate},#{typeCd},#{name},#{tel},
#{startTime},#{state},#{communityId},#{bId},#{age},#{typeFlag},#{pwd}
)
insert into application_key(
application_key_id,id_card,sex,status_cd,end_time,machine_id,type_cd,name,tel,start_time,state,community_id,b_id,age,type_flag,pwd
) select
t.application_key_id,t.id_card,t.sex,'0',t.end_time,t.machine_id,t.type_cd,t.name,t.tel,t.start_time,t.state,t.community_id,t.b_id,t.age,
t.type_flag,t.pwd
from business_application_key t
where 1=1
and t.application_key_id= #{applicationKeyId}
and t.id_card= #{idCard}
and t.sex= #{sex}
and t.end_time= #{endTime}
and t.machine_id= #{machineId}
and t.operate= 'ADD'
and t.type_cd= #{typeCd}
and t.name= #{name}
and t.tel= #{tel}
and t.start_time= #{startTime}
and t.state= #{state}
and t.community_id= #{communityId}
and t.b_id= #{bId}
and t.age= #{age}
and t.type_flag= #{typeFlag}
and t.pwd= #{pwd}
update application_key t set t.status_cd = #{statusCd}
,t.b_id = #{newBId}
, t.id_card= #{idCard}
, t.sex= #{sex}
, t.end_time= #{endTime}
, t.machine_id= #{machineId}
, t.type_cd= #{typeCd}
, t.name= #{name}
, t.tel= #{tel}
, t.start_time= #{startTime}
, t.state= #{state}
, t.community_id= #{communityId}
, t.age= #{age}
, t.type_flag= #{typeFlag}
, t.pwd= #{pwd}
where 1=1
and t.application_key_id= #{applicationKeyId}
and t.b_id= #{bId}