create table ir_user
(
    id             varchar(64)         not null
        constraint ir_user_pk
            primary key,
    user_account   varchar(255)        not null
        constraint ir_user_pk2
            unique,
    real_name      varchar(255)        not null,
    ps             varchar(255)        not null,
    create_user_id varchar(64),
    create_time    timestamp default CURRENT_TIMESTAMP,
    update_user_id varchar(64),
    update_time    timestamp default CURRENT_TIMESTAMP,
    state          integer   default 1,
    role_type      integer   default 2 not null
);

comment on table ir_user is '用户表';

comment on column ir_user.id is '主键';

comment on column ir_user.user_account is '用户账户';

comment on column ir_user.real_name is '真实姓名';

comment on column ir_user.ps is '用户密码';

comment on column ir_user.create_user_id is '创建人ID';

comment on column ir_user.create_time is '创建时间';

comment on column ir_user.update_user_id is '更新人ID';

comment on column ir_user.update_time is '更新时间';

comment on column ir_user.state is '状态(1启动 2禁用)';

comment on column ir_user.role_type is '用户角色(1管理员 2普通用户)';

alter table ir_user
    owner to postgres;


create table ir_sql_param
(
    id             varchar(64) not null
        constraint ir_sql_param_pk
            primary key,
    knowledge_id   varchar(64),
    param_name     varchar(64),
    param_type     varchar(64),
    param_require  integer   default 2,
    param_desc     varchar(255),
    create_user_id varchar(64),
    create_time    timestamp default CURRENT_TIMESTAMP,
    update_user_id varchar(64),
    update_time    timestamp default CURRENT_TIMESTAMP
);

comment on table ir_sql_param is '问题模板参数';

comment on column ir_sql_param.knowledge_id is '知识库ID';

comment on column ir_sql_param.param_name is '参数名称';

comment on column ir_sql_param.param_type is '参数类型';

comment on column ir_sql_param.param_require is '是否必填(1必填,2非必填)';

comment on column ir_sql_param.param_desc is '参数注释';

alter table ir_sql_param
    owner to postgres;

create table ir_session_param
(
    id             varchar(64) not null
        constraint ir_session_param_pk
            primary key,
    session_id     varchar(64),
    param_name     varchar(255),
    param_value    varchar(255),
    param_type     varchar(64),
    create_user_id varchar(64),
    create_time    timestamp default CURRENT_TIMESTAMP,
    update_user_id varchar(64),
    update_time    timestamp default CURRENT_TIMESTAMP
);

comment on table ir_session_param is '会话参数';

comment on column ir_session_param.id is '主键';

comment on column ir_session_param.session_id is '会话ID';

comment on column ir_session_param.param_name is '参数名称';

comment on column ir_session_param.param_value is '参数值';

comment on column ir_session_param.param_type is '参数类型';

alter table ir_session_param
    owner to postgres;

create table ir_session_history
(
    id                     varchar(64)                         not null
        constraint ir_session_history_pk
            primary key,
    session_id             varchar(64),
    user_question          varchar(1024),
    user_question_voice_id varchar(64),
    match_knowledge_id     varchar(64),
    user_id                varchar(64),
    threshold              numeric(5, 2),
    score_cause            integer,
    answer_time            timestamp default CURRENT_TIMESTAMP not null,
    deal_state             integer   default 0                 not null,
    create_user_id         varchar(64),
    create_time            timestamp default CURRENT_TIMESTAMP,
    update_user_id         varchar(64),
    update_time            timestamp default CURRENT_TIMESTAMP,
    answer                 varchar(1024),
    answer_voice_id        varchar(64),
    answer_file_id         varchar(1024),
    answer_type            integer
);

comment on table ir_session_history is '会话历史记录表';

comment on column ir_session_history.id is '主键';

comment on column ir_session_history.session_id is '所属会话ID';

comment on column ir_session_history.user_question is '用户问题';

comment on column ir_session_history.user_question_voice_id is '用户语音ID(关联语音表ID)';

comment on column ir_session_history.match_knowledge_id is '匹配知识库ID';

comment on column ir_session_history.user_id is '提问用户ID';

comment on column ir_session_history.threshold is '阈值';

comment on column ir_session_history.score_cause is '(原因 1信息错误 2答非所问 3其他),只有不满意时触发';

comment on column ir_session_history.answer_time is '应答时间';

comment on column ir_session_history.deal_state is '处理状态(0无需处理 1未处理 2已处理)';

comment on column ir_session_history.answer is '回答内容';

comment on column ir_session_history.answer_voice_id is '回答音频ID';

comment on column ir_session_history.answer_file_id is '回答文件ID,支持多个文件,用;分割';

comment on column ir_session_history.answer_type is '回答类型 1:文字 2：语音 3：文件';

alter table ir_session_history
    owner to postgres;

create table ir_robot_config
(
    id                 varchar(64)         not null
        constraint robot_config_pk
            primary key,
    device_name        varchar(255),
    dept_name          varchar(255),
    device_code        varchar(255),
    state              integer   default 1 not null,
    talk_speed         numeric(2, 1),
    icon_base64        text,
    active_language    varchar(255),
    error_language     varchar(255),
    unrecognized_one   varchar(255),
    unrecognized_two   varchar(255),
    unrecognized_three varchar(255),
    unrecognized_four  varchar(255),
    create_user_id     varchar(64),
    create_time        timestamp default CURRENT_TIMESTAMP,
    update_user_id     varchar(64),
    update_time        timestamp default CURRENT_TIMESTAMP
);

comment on table ir_robot_config is '机器人配置';

comment on column ir_robot_config.id is '主键';

comment on column ir_robot_config.device_name is '设备名称';

comment on column ir_robot_config.dept_name is '所属机构名称';

comment on column ir_robot_config.device_code is '设备编码';

comment on column ir_robot_config.state is '设备状态(1启用 2禁用)';

comment on column ir_robot_config.talk_speed is '语速配置';

comment on column ir_robot_config.icon_base64 is '机器人图表';

comment on column ir_robot_config.active_language is '主动话术';

comment on column ir_robot_config.error_language is '异常话术';

comment on column ir_robot_config.unrecognized_one is '未识别话术1';

comment on column ir_robot_config.unrecognized_two is '未识别话术2';

comment on column ir_robot_config.unrecognized_three is '未识别话术3';

comment on column ir_robot_config.unrecognized_four is '未识别话术5';

alter table ir_robot_config
    owner to postgres;

create table ir_session
(
    id             varchar(255)        not null
        constraint ir_session_pk
            primary key,
    session_name   varchar(255),
    session_state  integer   default 1 not null,
    user_id        varchar(64),
    video_speed    numeric(2, 1),
    broadcast_type integer   default 1,
    session_score  integer,
    create_user_id varchar(64),
    create_time    timestamp default CURRENT_TIMESTAMP,
    update_user_id varchar(64),
    update_time    timestamp default CURRENT_TIMESTAMP
);

comment on table ir_session is '会话表';

comment on column ir_session.id is '主键';

comment on column ir_session.session_name is '会话名称';

comment on column ir_session.session_state is '会话状态(1进行中,2已结束)';

comment on column ir_session.user_id is '会话用户ID';

comment on column ir_session.video_speed is '播放速度(2位,小数后1位,例如:1.5)';

comment on column ir_session.broadcast_type is '播报方式(1语音 2文字)';

comment on column ir_session.session_score is '会话评分(1满意 2不满意,3未评估)';

alter table ir_session
    owner to postgres;



create table ir_voice
(
    id           varchar(64) not null
        constraint ir_voice_pk
            primary key,
    voice_base64 text        not null,
    length       integer
);

comment on table ir_voice is '音频文件表';

comment on column ir_voice.id is '主键';

comment on column ir_voice.voice_base64 is '音频文件base64编码';

comment on column ir_voice.length is '长度,以秒为单位';

alter table ir_voice
    owner to postgres;

create table ir_file
(
    id        varchar(64) not null
        constraint ir_file_pk
            primary key,
    file_name varchar(255),
    file_byte bytea,
    file_type varchar(255),
    file_size integer
);

comment on table ir_file is '文件表';

comment on column ir_file.id is '主键';

comment on column ir_file.file_name is '文件名称';

comment on column ir_file.file_byte is '文件字节编码';

comment on column ir_file.file_type is '文件类型 1: base64 2:原生(未经过base64编码)';

comment on column ir_file.file_size is '文件大小';

alter table ir_file
    owner to postgres;
create table ir_knowledge
(
    id                varchar(64)  not null
        constraint ir_knowledge_pk
            primary key,
    standard_question varchar(255) not null,
    state             integer,
    sql_template      text,
    result_template   text,
    create_user_id    varchar(64),
    create_time       timestamp default CURRENT_TIMESTAMP,
    update_user_id    varchar(64),
    update_time       timestamp default CURRENT_TIMESTAMP,
    result_type       integer   default 1
);

comment on table ir_knowledge is '知识库';

comment on column ir_knowledge.id is '主键';

comment on column ir_knowledge.standard_question is '标准问题';

comment on column ir_knowledge.state is '状态(1生效 2部分生效 3未部署)';

comment on column ir_knowledge.sql_template is 'SQL模板(使用模板工具)';

comment on column ir_knowledge.result_template is '回答模板格式(使用模板工具)';

comment on column ir_knowledge.result_type is '查询结果数据类型：1：Map<String,Object> 2:List<Map<String,Object>> 3 : bytea';

alter table ir_knowledge
    owner to postgres;

INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984441624252418', '本次冻结涉及多少张卡?', 1, e'select count(distinct jykh) jykh_count
from yxyc_robot_data.yxyc_djmd
where ajid = #{ajid};', '本次冻结涉及${jykh_count}张银行卡', null, '2024-03-22 09:22:49.128999', null, '2024-03-22 09:22:49.128999', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442718965762', '代理或会员的充值、提现情况', 1, null, null, null, '2024-03-22 09:22:49.240794', null, '2024-03-22 09:22:49.240794', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442979012610', '是否为团伙', 1, e'<script>
SELECT
    CASE
        WHEN EXISTS (
            SELECT 1
            FROM yxyc_robot_data.yxyc_zhbq
            WHERE ajmc = #{ajid} AND jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
              AND js LIKE \'%团伙%\'
        ) THEN \'是团伙\'
        ELSE \'不是团伙\'
    END AS result;
</script>', '${result}', null, '2024-03-22 09:22:49.299090', null, '2024-03-22 09:22:49.299090', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443440386666', '我要下载案件材料', 1, null, e'<#if fileContent??>
    我们已为您准备了相关案件材料，供您随时下载查阅。
<#else>
    暂时还没有相关案件材料可以下载查阅。
</#if>', null, '2024-03-29 05:16:18.426524', null, '2024-03-29 05:16:18.426524', 4);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443155173377', '冻结资金的依据', 1, e'<script>
select xyzjlxt as byte_content, guid as byte_content_id
from yxyc_robot_data.yxyc_xyzjyjt
where ajid = #{ajid}
  and jykh  IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
</script>', '未查询到资金冻结的依据。', null, '2024-03-22 09:22:49.339301', null, '2024-03-22 09:22:49.339301', 3);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443096453122', '账户主要扮演哪些角色', 1, e'<script>
select string_agg(distinct js, \'、\') js_agg
from yxyc_robot_data.yxyc_zhbq
where ajmc = #{ajid}
  and jykh  IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
</script>', e'<#if js_agg??>
    扮演的角色有：${js_agg}
<#else>
    无扮演的角色
</#if>', null, '2024-03-22 09:22:49.327274', null, '2024-03-22 09:22:49.327274', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442920292354', '资金信息基本情况', 1, e'<script>
select count(distinct jykh)                                       dqzhs,
       count(distinct jyhm)                                       dqzts,
       count(distinct dszh)                                       sjdss,
       count(*)                                                   jyzbs,
       sum(jyje::numeric)                                         jyzje,
       sum(case when sfbz = \'进\' then 1 else 0 end)               jzcs,
       sum(case when sfbz = \'进\' then jyje::numeric else \'0\' end) jzje,
       sum(case when sfbz = \'出\' then 1 else 0 end)               czcs,
       sum(case when sfbz = \'出\' then jyje::numeric else \'0\' end) czje,
       min(jyrq)                                                  zzjyrq,
       max(jyrq)                                                  zwjyrq
from yxyc_robot_data.yxyc_fx_zjmx_case where ajid = #{ajid} and jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
and jyzjhm = #{khrzjhm};
</script>', e'<#macro formatMoney amount>
    <#if amount < 10000>
        ${amount} 元
    <#elseif amount gte 10000 && amount  < 100000000 >
        ${(amount / 10000) ?string[\'0.00\']} 万元
    <#else>
        ${(amount / 100000000)?string[\'0.00\']} 亿元
    </#if>
</#macro>
<#if jyzbs gt 0>
    经数据清洗（补充缺失值、处理特殊字符、剔除无效数据、删除重复数据）后，本案件共调取了${dqzts}个主体的${dqzhs}个账户自${zzjyrq}到${zwjyrq}的交易记录${jyzbs}条；
    其中涉及交易对手账号${sjdss}个，涉及金额交易总金额约<@formatMoney amount=jyzje/>，转出金额约<@formatMoney amount=czje/>，转入金额<@formatMoney amount=jzje/>。转出笔数${czcs}笔，转入笔数${jzcs}笔。
<#else>
    经数据清洗（补充缺失值、处理特殊字符、剔除无效数据、删除重复数据）后，未查询到相关的交易记录。
</#if>', null, '2024-03-22 09:22:49.284770', null, '2024-03-22 09:22:49.284770', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442635079681', '是否为代理或会员？', 1, e'<script>
    SELECT js
    FROM yxyc_robot_data.yxyc_zhbq
    WHERE jykh in
    <foreach collection="jykh" item="kh" open="(" separator="," close=")">
            #{kh}
        </foreach>
      AND ajmc = #{ajid}
</script>', e'<#assign dataList = dataList?default([])>
<#assign isMember = false>
<#assign isAgent = false>
<#list dataList as item>
    <#if item.js?contains("会员")>
        <#assign isMember = true>
    <#elseif item.js?contains("代理")>
        <#assign isAgent = true>
    </#if>
</#list>
<#if isMember>
是会员<#elseif isAgent>是代理<#else>不是代理或者会员</#if>', null, '2024-03-22 09:22:49.222509', null, '2024-03-22 09:22:49.222509', 2);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443201310722', '主要关联了哪些问题账户', 1, e'<script>
 SELECT
    string_agg(dshm || \':\' || dszh, \',\') AS result
FROM yxyc_robot_data.result_jylxfx_bq
WHERE ajid = #{ajid}
    AND jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
    AND dsfbq IS NOT NULL;
</script>', e'<#if result??>
    关联问题账户有:${result}
<#else>
	没有关联问题账户。
</#if>', null, '2024-03-22 09:22:49.352463', null, '2024-03-22 09:22:49.352463', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443385860098', '关联的出账对手情况', 1, e'<script>
select jykh,
       gldss gldss,
       czdsh czdsh,
       czje  czje,
       czbs  czbs,
       czts  czts
from yxyc_robot_data.yxyc_zhxzsb where ajid = ${ajid} and jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach> and  jyzjhm = #{khrzjhm};
</script>', e'<#assign dataList = dataList?default([])>
关联的出账对手情况：
<#list dataList as item>
卡号：${item.jykh}，关联对手数：${item.gldss}，出账对手数：${item.czdsh}，出账金额：${item.czje}，出账笔数：${item.czbs}，出账天数:${item.czts}
</#list>', null, '2024-03-22 09:22:49.395498', null, '2024-03-22 09:22:49.395498', 2);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443268419585', '为几级卡', 1, e'<script>
SELECT jykh,sfbz,dsfbq
FROM yxyc_robot_data.result_jylxfx_bq where ajid = #{ajid} and jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
</script>', e'<#assign dataList = dataList?default([])>
<#assign card_map = {}>
<#list dataList as item>
    <#if item.jykh?? && item.jykh?trim?length != 0>
        <#assign key = item.jykh?trim>
        <#if !card_map[key]??>
            <#assign card_map = card_map + {key : item}>
        <#elseif item.sfbz?? && item.sfbz == "进" && item.dsfbq?? && item.dsfbq?contains("会员")>
            <#assign card_map = card_map + {key : item}>
        <#elseif (item.dsfbq ?? && (item.dsfbq?contains("收款账户") || item.dsfbq?contains("返款账户")) && (card_map[key].sfbz != "进"))>
            <#assign card_map = card_map + {key : item}>
        </#if>
    </#if>
</#list>
<#list card_map?values as item>
    卡号：${item.jykh} 卡级别：
    <#if item.sfbz?? && item.sfbz == "进" && item.dsfbq?? &&  item.dsfbq?contains("会员")>
        一级卡
    <#elseif item.sfbz?? &&  item.sfbz == "出" ||  (item.dsfbq?? && (item.dsfbq?contains("收款账户") || item.dsfbq?contains("返款账户")))>
        二级卡
    <#else>
        三级卡
    </#if>
</#list>', null, '2024-03-22 09:22:49.366105', null, '2024-03-22 09:22:49.366105', 2);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443327139841', '关联的进账对手情况', 1, e'<script>
select jykh,
       gldss  gldss,
       jzdss  jzdss,
       jzcszb jzcszb,
       jzjezb jzjezb,
       jzdsszb jzdsszb,
       jzje   jzje,
       jzbs   jzbs,
       jzts   jzts
from yxyc_robot_data.yxyc_zhxzsb where ajid = #{ajid} and jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach> and  jyzjhm = #{khrzjhm};
</script>', e'<#assign dataList = dataList?default([])>
关联的进账对手情况：
<#list dataList as item>
卡号：${item.jykh}，关联对手数：${item.gldss}，进账对手数：${item.jzdss}，进账次数占比：${item.jzcszb}，进账金额占比：${item.jzjezb}，进账对手数占比:${item.jzdsszb}， 进账金额：${item.jzje}，进账笔数：${item.jzbs}，进账天数：${item.jzts}
</#list>', null, '2024-03-22 09:22:49.381933', null, '2024-03-22 09:22:49.381933', 2);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443440386050', '银行基本信息情况', 1, e'select t0.jykh,t0.t0_zhkhmc_agg,t1.* ,t2.联系电话 ,t3.住宅地址, t3.住宅电话 ,t4.银行账号
   from
 (select jykh,khrzjhm ,string_agg(distinct zhkhmc,\'、\') t0_zhkhmc_agg
    from yxyc_robot_data.yxyc_cj_zj_khxx  where ajid=2 and khrzjhm = #{khrzjhm}
    group by jykh,khrzjhm
    ) t0
   left join
   (select zjhm t1_zjhm,
   string_agg(distinct email,\'、\') 联系邮箱,string_agg(distinct gzdw,\'、\') 工作单位,string_agg(distinct dwdh,\'、\') 单位电话
    from yxyc_robot_data.yxyc_cj_zj_kehxx  where  ajid=2  and zjhm=#{khrzjhm}
    group by zjhm
    ) t1
   on t0.khrzjhm=t1.t1_zjhm
    left join
    (
     select zzhm t2_zzhm,string_agg(distinct khmc,\'、\') 开户名称,string_agg(distinct lxdh,\'、\') 联系电话
      from yxyc_robot_data.yxyc_cj_zj_lxfsxx where  ajid=2 and zzhm=#{khrzjhm}
        group by zzhm
    ) t2
    on t1.t1_zjhm = t2.t2_zzhm
    left join
    (
     select zjhm t3_zjhm,string_agg(distinct khmc,\'、\') 开户名称,string_agg(distinct zzdz,\'、\') 住宅地址, string_agg(distinct zzdh,\'、\') 住宅电话
      from yxyc_robot_data.yxyc_cj_zj_zzxx where  ajid=2 and zjhm=#{khrzjhm}
        group by zjhm
    ) t3
    on  t1.t1_zjhm = t3.t3_zjhm
    left join
    (
     select khrzjhm t4_khrzjhm,string_agg(distinct zhkhmc,\'、\') 开户名称,string_agg(distinct zhkhyh||\'-\'||jykh,\'、\') 银行账号
      from yxyc_robot_data.yxyc_cj_zj_khxx where  ajid=2  and khrzjhm= #{khrzjhm}
        group by khrzjhm
    ) t4
    on t1.t1_zjhm = t4.t4_khrzjhm;', '基本情况: 交易卡号:${((jykh!'''')?length>0)?string(jykh!'''',''无'')}，开户名称：${((t0_zhkhmc_agg!'''')?length>0)?string(t0_zhkhmc_agg!'''',''无'')}，证照号码：${((t1_zjhm!'''')?length>0)?string(t1_zjhm!'''',''无'')}，联系邮箱：${((联系邮箱!'''')?length>0)?string(联系邮箱!'''',''无'')}，工作单位：${((工作单位!'''')?length>0)?string(工作单位!'''',''无'')}，单位电话：${((单位电话!'''')?length>0)?string(单位电话!'''',''无'')}，联系电话：${((联系电话!'''')?length>0)?string(联系电话!'''',''无'')}，住宅地址：${((住宅地址!'''')?length>0)?string(住宅地址!'''',''无'')}，住宅电话：${((住宅电话!'''')?length>0)?string(住宅电话!'''',''无'')}，银行账号：${((银行账号!'''')?length>0)?string(银行账号!'''',''无'')}。', null, '2024-03-22 09:22:49.407176', null, '2024-03-22 09:22:49.407176', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442857377793', '是否符合立案打击标准', 1, e'<script>
select jykh,saje
from yxyc_robot_data.yxyc_djmd
where ajid = #{ajid}
  and jykh in
    <foreach collection="jykh" item="kh" open="(" separator="," close=")">
            #{kh}
        </foreach>
  and khrzjhm = #{khrzjhm};
</script>', e'<#list dataList as item>
    <#assign jykh = item["jykh"]>
    <#assign saje = item["saje"]>
交易卡号: ${jykh}元，交易金额: ${saje}元,</#list>总交易金额: <#assign totalAmount = 0><#list dataList as item><#assign saje = item["saje"]?number> <#assign totalAmount = totalAmount + saje></#list>${totalAmount} 元', null, '2024-03-22 09:22:49.269374', null, '2024-03-22 09:22:49.269374', 2);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442509250562', '本案调集了几轮数据，涉及多少账户', 1, e'select count(distinct djpc) as count_djpc, count(distinct jykh) as count_ykjh
from yxyc_robot_data.yxyc_djmd where ajid = #{ajid};', e'<#assign count_ykjh = count_ykjh?default(0)>
<#assign count_djpc = count_djpc?default(0)>
本案调集了${count_djpc}轮数据，涉及${count_ykjh}个账户。', null, '2024-03-22 09:22:49.186871', null, '2024-03-22 09:22:49.186871', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984443037732866', '团伙依据', 1, e'<script>
select string_agg(distinct jyhm,\'、\') jyhm_agg
from yxyc_robot_data.yxyc_thsb a
where a.thfz in (select distinct thfz
                 from yxyc_robot_data.yxyc_thsb
                 where ajid = #{ajid}
                   and jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
                   and jyzjhm = #{khrzjhm})
  and a.jyhm is not null;
</script>', e'<#if jyhm_agg??>
团伙人员有：${jyhm_agg}
<#else>
没有团伙成员
</#if>', null, '2024-03-22 09:22:49.312666', null, '2024-03-22 09:22:49.312666', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442387615746', '涉及哪些银行，各银行卡数量', 1, e'SELECT STRING_AGG(result_0, \'、\') result
FROM (SELECT yhmc || \':\' || count(distinct jykh) || \'张\' as result_0
      FROM yxyc_robot_data.yxyc_djmd
      where ajid = #{ajid}
      GROUP BY yhmc
      ) subquery;', e'<#if result?has_content>
  ${result}
<#else>
  没有相关数据
</#if>', null, '2024-03-22 09:22:49.159600', null, '2024-03-22 09:22:49.159600', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442458918914', '本次账户涉案情况', 1, e'select SUM(CAST(saje AS DECIMAL(18, 2)))  as sum_asje
from yxyc_robot_data.yxyc_djmd
where ajid = #{ajid};', '账户涉案金额是${(sum_asje!0)?c}元', null, '2024-03-22 09:22:49.172509', null, '2024-03-22 09:22:49.172509', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442811240449', '代理获取佣金情况', 1, null, null, null, '2024-03-22 09:22:49.256425', null, '2024-03-22 09:22:49.256425', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442572165122', '是否为本次冻结打击对象？', 1, e'<script>
SELECT
    CASE
        WHEN count(id) > 0 THEN \'是\'
        ELSE \'不是\'
    END AS result
FROM yxyc_robot_data.yxyc_djmd
WHERE ajid = #{ajid}
    AND jykh IN
     <foreach collection="jykh" item="kh" open="(" separator="," close=")">
        #{kh}
    </foreach>
    AND khrzjhm = #{khrzjhm};
</script>', '${result}本次冻结打击对象', null, '2024-03-22 09:22:49.201885', null, '2024-03-22 09:22:49.201885', 1);


create table ir_knowledge_similar
(
    id               varchar(64) not null
        constraint ir_similar_question_pk
            primary key,
    knowledge_id     varchar(64),
    similar_question varchar(255),
    state            integer,
    create_user_id   varchar(64),
    create_time      timestamp default CURRENT_TIMESTAMP,
    update_user_id   varchar(64),
    update_time      timestamp default CURRENT_TIMESTAMP
);

comment on table ir_knowledge_similar is '相似问法表';

comment on column ir_knowledge_similar.id is '主键';

comment on column ir_knowledge_similar.knowledge_id is '知识库ID';

comment on column ir_knowledge_similar.similar_question is '相似问法';

comment on column ir_knowledge_similar.state is '生效状态(1生效 2部分生效 3未部署)';

alter table ir_knowledge_similar
    owner to postgres;

INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012620', '1770984443096453122', '账号主要扮演了哪些角色', 1, null, '2024-04-02 02:39:34.766612', null, '2024-04-02 02:39:34.766612');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012621', '1770984442635079681', '是否为会员或代理', 1, null, '2024-04-02 02:40:35.245391', null, '2024-04-02 02:40:35.245391');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012622', '1770984443268419585', '为几类卡', 1, null, '2024-04-02 02:42:03.044403', null, '2024-04-02 02:42:03.044403');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012623', '1770984443268419585', '卡是几级', 1, null, '2024-04-02 02:42:49.833125', null, '2024-04-02 02:42:49.833125');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012624', '1770984443268419585', '卡是几类', 1, null, '2024-04-02 02:43:28.832981', null, '2024-04-02 02:43:28.832981');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012625', '1770984443440386050', '银行基本信息情况是什么', 1, null, '2024-04-02 02:46:52.157471', null, '2024-04-02 02:46:52.157471');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012626', '1770984443201310722', '有关联的问题账号主要有哪些', 1, null, '2024-04-02 03:01:16.219558', null, '2024-04-02 03:01:16.219558');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012627', '1770984443201310722', '哪些账户与本案相关联', 1, null, '2024-04-02 03:01:52.268242', null, '2024-04-02 03:01:52.268242');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012628', '1770984443201310722', '哪些账户与本案有关系', 1, null, '2024-04-02 03:02:27.067425', null, '2024-04-02 03:02:27.067425');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012629', '1770984443201310722', '与本案有关系的主要账户有哪些', 1, null, '2024-04-02 03:03:37.523851', null, '2024-04-02 03:03:37.523851');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012630', '1770984442387615746', '涉及的银行有哪些，它们分别有多少张银行卡？', 1, null, '2024-04-02 03:10:04.519138', null, '2024-04-02 03:10:04.519138');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012631', '1770984442387615746', '可以列出涉及的银行及各自发行的银行卡数量吗？', 1, null, '2024-04-02 03:10:41.965494', null, '2024-04-02 03:10:41.965494');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012611', '1770984442979012610', '是不是团伙?', 1, null, '2024-04-01 09:00:09.759290', null, '2024-04-01 09:00:09.759290');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012612', '1770984442979012610', '是不是团伙作案?', 1, null, '2024-04-01 09:00:41.802338', null, '2024-04-01 09:00:41.802338');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012613', '1770984442857377793', '是否符合立案标准', 1, null, '2024-04-01 09:33:08.288781', null, '2024-04-01 09:33:08.288781');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012614', '1770984441624252418', '本次一共冻结多少张银行卡', 1, null, '2024-04-01 09:36:09.877843', null, '2024-04-01 09:36:09.877843');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012615', '1770984441624252418', '本案冻结涉及多少张卡', 1, null, '2024-04-01 09:36:41.845686', null, '2024-04-01 09:36:41.845686');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012616', '1770984441624252418', '本案一共冻结多少张银行卡', 1, null, '2024-04-01 09:37:59.555677', null, '2024-04-01 09:37:59.555677');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012617', '1770984442718965762', '代理或会员的充值提现情况', 1, null, '2024-04-01 09:41:08.463625', null, '2024-04-01 09:41:08.463625');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012618', '1770984442509250562', '本案涉及多少账号，调集了几轮数据', 1, null, '2024-04-02 01:17:52.878350', null, '2024-04-02 01:17:52.878350');
INSERT INTO ir_knowledge_similar (id, knowledge_id, similar_question, state, create_user_id, create_time, update_user_id, update_time) VALUES ('1870984442979012619', '1770984443155173377', '冻结资金的依据是什么', 1, null, '2024-04-02 02:36:00.138586', null, '2024-04-02 02:36:00.138586');


INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('1', '1770984441624252418', 'ajid', 'String', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('3', '1770984442458918914', 'ajid', 'String', 1, '案件id', null, '2024-03-25 05:26:34.311383', null, '2024-03-25 05:26:34.311383');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('4', '1770984442509250562', 'ajid', 'String', 1, '案件id', null, '2024-03-25 07:08:43.372256', null, '2024-03-25 07:08:43.372256');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('5', '1770984442572165122', 'ajid', 'String', 1, '案件id', null, '2024-03-25 07:09:41.774286', null, '2024-03-25 07:09:41.774286');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('6', '1770984442572165122', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('7', '1770984442572165122', 'khrzjhm', 'String', 1, '开户人证件号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('8', '1770984442635079681', 'ajid', 'String', 1, '案件id(对应字段ajmc)', null, '2024-03-25 07:47:00.489829', null, '2024-03-25 07:47:00.489829');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('9', '1770984442635079681', 'jykh', 'List', 1, '交易卡号', null, '2024-03-25 07:47:00.489829', null, '2024-03-25 07:47:00.489829');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('10', '1770984442857377793', 'ajid', 'String', 1, '案件id', null, '2024-03-26 02:07:06.982040', null, '2024-03-26 02:07:06.982040');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('11', '1770984442857377793', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('12', '1770984442857377793', 'khrzjhm', 'String', 1, '开户人证件号码', null, '2024-03-26 02:07:06.982040', null, '2024-03-26 02:07:06.982040');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('13', '1770984442920292354', 'ajid', 'String', 1, '案件id', null, '2024-03-26 02:07:06.982040', null, '2024-03-26 02:07:06.982040');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('14', '1770984442920292354', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('15', '1770984442920292354', 'khrzjhm', 'String', 1, '开户人证件号码', null, '2024-03-26 02:07:06.982040', null, '2024-03-26 02:07:06.982040');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('16', '1770984442979012610', 'ajid', 'String', 1, '案件id', null, '2024-03-26 02:07:06.982040', null, '2024-03-26 02:07:06.982040');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('17', '1770984442979012610', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('18', '1770984443037732866', 'ajid', 'String', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('19', '1770984443037732866', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('20', '1770984443037732866', 'khrzjhm', 'String', 1, '开户人证件号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('21', '1770984443096453122', 'ajid', 'String', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('22', '1770984443096453122', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('24', '1770984443155173377', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('23', '1770984443155173377', 'ajid', 'Integer', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('25', '1770984443201310722', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('26', '1770984443201310722', 'ajid', 'Integer', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('27', '1770984443268419585', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('28', '1770984443268419585', 'ajid', 'Integer', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('29', '1770984443327139841', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('30', '1770984443327139841', 'ajid', 'Integer', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('31', '1770984443327139841', 'khrzjhm', 'String', 1, '开户人证件号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('32', '1770984443385860098', 'jykh', 'List', 1, '交易卡号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('33', '1770984443385860098', 'ajid', 'Integer', 1, '案件id', null, '2024-03-25 05:24:38.653214', null, '2024-03-25 05:24:38.653214');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('34', '1770984443385860098', 'khrzjhm', 'String', 1, '开户人证件号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('35', '1770984443440386050', 'khrzjhm', 'String', 1, '开户人证件号', null, null, null, null);
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('2', '1770984442387615746', 'ajid', 'String', 1, '案件id', null, '2024-03-25 05:25:40.475951', null, '2024-03-25 05:25:40.475951');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('36', '1770984443440386666', 'ajid', 'String', 1, '案件id', null, '2024-03-29 06:25:32.732249', null, '2024-03-29 06:25:32.732249');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('37', '1770984443440386666', 'khrzjhm', 'String', 1, '开户人证件号', null, '2024-03-29 06:25:32.732249', null, '2024-03-29 06:25:32.732249');
INSERT INTO ir_sql_param (id, knowledge_id, param_name, param_type, param_require, param_desc, create_user_id, create_time, update_user_id, update_time) VALUES ('38', '1770984443440386666', 'khrmc', 'String', 2, '开户人名称', null, '2024-03-29 06:25:32.732249', null, '2024-03-29 06:25:32.732249');

INSERT INTO ir_robot_config (id, device_name, dept_name, device_code, state, talk_speed, icon_base64, active_language, error_language, unrecognized_one, unrecognized_two, unrecognized_three, unrecognized_four, create_user_id, create_time, update_user_id, update_time) VALUES ('111', '审讯机器人', '沈阳公安', '001', 1, 1.0, null, '您好，我是审讯机器人，咨询时需提供案件编号或嫌疑人信息，有助于我更快帮您查询结果.', '您好，没有听清您说什么', '抱歉，我目前还没有足够的信息来回答您的问题。我会不断学习和进步，以便在将来能够更好地帮助您', '我已记录下您设置的信息，你可以继续问询。', null, null, null, '2024-03-21 05:20:32.679530', null, '2024-03-21 05:20:32.679530');
