insert into business_complaint( operate,complaint_id,type_cd,context,complaint_name,tel,state,store_id,b_id,room_id,community_id,start_user_id ) values ( #{operate},#{complaintId},#{typeCd},#{context},#{complaintName},#{tel},#{state},#{storeId},#{bId},#{roomId},#{communityId}, #{startUserId} ) insert into complaint( complaint_id,type_cd,context,complaint_name,tel,status_cd,state,store_id,b_id,room_id,community_id, start_user_id ) select t.complaint_id,t.type_cd,t.context,t.complaint_name,t.tel,'0',t.state,t.store_id,t.b_id,t.room_id, t.community_id,t.start_user_id from business_complaint t where 1=1 and t.operate= 'ADD' and t.complaint_id= #{complaintId} and t.type_cd= #{typeCd} and t.context= #{context} and t.complaint_name= #{complaintName} and t.tel= #{tel} and t.state= #{state} and t.store_id= #{storeId} and t.b_id= #{bId} and t.room_id= #{roomId} update complaint t set t.status_cd = #{statusCd} ,t.b_id = #{newBId} , t.type_cd= #{typeCd} , t.context= #{context} , t.complaint_name= #{complaintName} , t.tel= #{tel} , t.state= #{state} , t.store_id= #{storeId} , t.room_id= #{roomId} where 1=1 and t.complaint_id= #{complaintId} and t.community_id= #{communityId} and t.b_id= #{bId}