INSERT INTO bus_device_configuration ( device_id, alias, type, tenant_id, total_dose, first_dose, max_dose, append_dose, continue_dose, self_control_lock_time, patient_code ) SELECT #{entity.deviceId}, #{entity.alias}, #{entity.type, jdbcType=VARCHAR}, #{entity.tenantId}, #{entity.totalDose}, #{entity.firstDose}, #{entity.maxDose}, #{entity.appendDose}, #{entity.continueDose}, #{entity.selfControlLockTime}, #{entity.patientCode} FROM DUAL WHERE NOT EXISTS ( SELECT device_id FROM bus_device_configuration WHERE device_id = #{entity.deviceId} ) UPDATE bus_device_configuration alias = #{entity.alias}, type = #{entity.type, jdbcType=VARCHAR}, tenant_id = #{entity.tenantId}, total_dose = #{entity.totalDose}, first_dose = #{entity.firstDose}, max_dose = #{entity.maxDose}, append_dose = #{entity.appendDose}, continue_dose = #{entity.continueDose}, self_control_lock_time = #{entity.selfControlLockTime}, patient_code = #{entity.patientCode} WHERE device_id = #{entity.deviceId}