class DeviceInstanceTerm extends AbstractTermFragmentBuilder {

    public static final String termType = "dev-instance";

    public DeviceInstanceTerm() {
        super(termType, "根据设备信息查询");
    }

    @Override
    public SqlFragments createFragments(String columnFullName,
                                        RDBColumnMetadata column,
                                        Term term) {<FILL_FUNCTION_BODY>}


    static DeviceTermsBuilder builder = new DeviceTermsBuilder();

    static class DeviceTermsBuilder extends AbstractTermsFragmentBuilder<TableOrViewMetadata> {

        @Override
        protected SqlFragments createTermFragments(TableOrViewMetadata parameter,
                                                   List<Term> terms) {
            return super.createTermFragments(parameter, terms);
        }

        @Override
        protected SqlFragments createTermFragments(TableOrViewMetadata table,
                                                   Term term) {
            if (term.getValue() instanceof NativeSql) {
                NativeSql sql = ((NativeSql) term.getValue());
                return PrepareSqlFragments.of(sql.getSql(), sql.getParameters());
            }
            return table
                .getColumn(term.getColumn())
                .flatMap(column -> table
                    .findFeature(TermFragmentBuilder.createFeatureId(term.getTermType()))
                    .map(termFragment -> termFragment.createFragments(column.getFullName("_dev"), column, term)))
                .orElse(EmptySqlFragments.INSTANCE);
        }
    }
}

        List<Term> terms = ConverterUtils.convertTerms(term.getValue());
        PrepareSqlFragments sqlFragments = PrepareSqlFragments.of();
        if (term.getOptions().contains("not")) {
            sqlFragments.addSql("not");
        }
        sqlFragments.addSql("exists(select 1 from ", getTableName("dev_device_instance", column), " _dev where _dev.id = ", columnFullName);

        RDBTableMetadata metadata = column
            .getOwner()
            .getSchema()
            .getTable("dev_device_instance")
            .orElseThrow(() -> new UnsupportedOperationException("unsupported dev_device_instance"));

        SqlFragments where = builder.createTermFragments(metadata, terms);
        if (!where.isEmpty()) {
            sqlFragments.addSql("and")
                .addFragments(where);
        }
        sqlFragments.addSql(")");
        return sqlFragments;
    
<no_super_class>