feat:调试修改

This commit is contained in:
雷雨
2025-10-14 10:31:00 +08:00
parent be0bc661e2
commit 9d0457ea39
5 changed files with 120 additions and 84 deletions

View File

@@ -2,7 +2,10 @@ from service.cus_vanna_srevice import CustomVanna
from util import train_ddl
from util import q_and_a_dict
table_ddls = [
train_ddl.person_ddl_sql,train_ddl.rule_ddl,train_ddl.user_status_ddl
train_ddl.person_ddl_sql,train_ddl.user_status_ddl,
train_ddl.user_attendance_ddl,train_ddl.person_ac_area,
train_ddl.org_orgs_ddl
]
list_documentions = [
train_ddl.train_document,

View File

@@ -1,33 +1,5 @@
question_and_answer = [
{"question": "考勤地点有哪些",
"answer": '''
SELECT DISTINCT CASE "region"
WHEN '1' THEN '北京'
WHEN '2' THEN '成都'
WHEN '3' THEN '秭归'
WHEN '4' THEN '拉萨'
WHEN '5' THEN '林芝' END AS "考勤地点"
FROM "YJOA_APPSERVICE_DB"."t_yj_person_attendance_rules"
WHERE "region" IS NOT NULL LIMIT 1000
'''
},
{"question": "成都的考勤规则是什么",
"answer": '''
SELECT "region" AS "region_code",
CASE
WHEN "region" = '1' THEN '北京'
WHEN "region" = '2' THEN '成都'
WHEN "region" = '3' THEN '秭归'
WHEN "region" = '4' THEN '拉萨'
WHEN "region" = '5' THEN '林芝' END AS "region_name",
"morning_check_time" AS "morning_check_time",
"afternoon_check_time" AS "afternoon_check_time",
"before_lunch_time" AS "before_lunch_time",
"after_lunch_time" AS "after_lunch_time"
FROM "YJOA_APPSERVICE_DB"."t_yj_person_attendance_rules"
WHERE "region" = '2' LIMIT 1000
'''
},
{"question": "所有员工男女各有多少人",
"answer": '''
SELECT CASE WHEN "gender" = '1' THEN '' WHEN "gender" = '2' THEN '' END AS "gender",
@@ -39,16 +11,16 @@ question_and_answer = [
'''
},
{
"question": "联通下面有哪些员工",
"question": "外部单位是联通下面有哪些员工",
"answer": '''
SELECT "id" AS "id",
"code" AS "工号",
"name" AS "姓名",
"internal_unit" AS "内部单位",
"external_unit" AS "外部单位"
FROM "YJOA_APPSERVICE_DB"."t_pr3rl2oj_yj_person_database"
WHERE "internal_unit" LIKE '%联通%'
OR "external_unit" LIKE '%联通%' LIMIT 1000
WHERE
"external_unit" LIKE '%联通%' LIMIT 1000
'''
},
{
@@ -176,7 +148,7 @@ question_and_answer = [
FROM "YJOA_APPSERVICE_DB"."t_pr3rl2oj_yj_person_database"
WHERE "work_content" LIKE '%智能体%' LIMIT 1000
'''
},{
}, {
"question": "9月旷工迟到分别有多少人",
"answer": '''
SELECT CASE WHEN "status" = '1006' THEN '迟到' WHEN "status" = '1005' THEN '旷工' END AS "status_name",
@@ -188,7 +160,7 @@ question_and_answer = [
GROUP BY "status"
ORDER BY "status" LIMIT 1000
'''
},{
}, {
"question": "在研发基地工作的有哪些员工",
"answer": '''
SELECT "id" AS "id",
@@ -201,6 +173,94 @@ question_and_answer = [
WHERE ("office_address" LIKE '%研发基地%' OR "office_city" LIKE '%研发基地%')
AND "dr" = '0' LIMIT 1000
'''
},
{
"question": "查询张三9月在林芝的打卡记录",
"answer": '''
SELECT a."person_name" AS "姓名",
a."person_id" AS "人员ID",
a."attendance_time" AS "考勤时间",
a."attendance_address" AS "考勤地址",
CASE
WHEN a."status" = 0 THEN '在岗'
WHEN a."status" = 1 THEN '出差'
WHEN a."status" = 2 THEN '休假' END AS "状态",
CASE
WHEN a."enter_or_exit" = 0 THEN ''
WHEN a."enter_or_exit" = 1
THEN '' END AS "进出类型",
CASE
WHEN b."region" = 1 THEN '水科院大厦'
WHEN b."region" = 2 THEN '成都'
WHEN b."region" = 3 THEN '秭归'
WHEN b."region" = 5 THEN '林芝' END AS "地区",
a."access_control_point" AS "门禁点"
FROM "YJOA_APPSERVICE_DB"."t_yj_person_attendance" a
JOIN "YJOA_APPSERVICE_DB"."t_yj_person_ac_area" b ON a."access_control_point" = b."ac_point"
WHERE a."person_name" = '张三'
AND b."region" = 5
AND a."attendance_time" >= '2025-09-01'
AND a."attendance_time" < '2025-10-01'
AND a."dr" = 0
ORDER BY a."attendance_time" DESC LIMIT 1000
'''
},{
"question": "查询张三9月份有多少天在岗",
"answer": '''
SELECT p."code" AS "工号",
p."name" AS "姓名",
CASE
WHEN p."internal_unit" IS NOT NULL AND p."internal_unit" != '' THEN p."internal_unit"
ELSE p."external_unit"
END AS "单位",
COUNT(CASE WHEN ps."status" = '1001' THEN 1 END) AS "在岗天数"
FROM YJOA_APPSERVICE_DB."t_yj_person_status" ps
JOIN YJOA_APPSERVICE_DB."t_pr3rl2oj_yj_person_database" p ON ps."person_id" = p."code"
WHERE p."name" = '张三'
AND ps."date_value" LIKE '2025-09%'
AND ps."dr" = 0
AND p."dr" = 0
GROUP BY p."code", p."name",
CASE
WHEN p."internal_unit" IS NOT NULL AND p."internal_unit" != '' THEN p."internal_unit"
ELSE p."external_unit"
END LIMIT 1000
'''
},{
"question": "数信中心 部门下有多少员工",
"answer": '''
select count(*)
from YJOA_APPSERVICE_DB.t_pr3rl2oj_yj_person_database
where internal_dept in (select id
from IUAP_APDOC_BASEDOC.org_orgs
where parentid in
(select id from IUAP_APDOC_BASEDOC.org_orgs where name like '数信中心'))
'''
},
{
"question": "各个外部单位下的员工人数统计",
"answer": '''
sELECT "external_unit" AS "外部单位", COUNT(*) AS "员工人数"
FROM "YJOA_APPSERVICE_DB"."t_pr3rl2oj_yj_person_database"
WHERE "external_unit" IS NOT NULL
AND "external_unit" != ''
GROUP BY "external_unit"
ORDER BY "员工人数" DESC LIMIT 1000
'''
},
{
"question": "数信中心下各个处室分别有多少人",
"answer": '''
SELECT o.name AS "处室名称", COUNT(p.id) AS "人数"
FROM YJOA_APPSERVICE_DB.t_pr3rl2oj_yj_person_database p
JOIN IUAP_APDOC_BASEDOC.org_orgs o ON p.internal_dept = o.id
WHERE o.parentid IN (SELECT id FROM IUAP_APDOC_BASEDOC.org_orgs WHERE name LIKE '数信中心')
AND p.dr = 0
GROUP BY o.name
ORDER BY "人数" DESC LIMIT 1000
'''
}
]

View File

@@ -475,8 +475,8 @@ train_document='''
查询地址籍贯公司单位时尽量使用like查询;
查询人员信息时,由于数据表字段过多。只需要展示人员关键信息字段id工号姓名单位以及用户问题中需要查询的字段;
表字段信息以及字段枚举信息在values下注意相关字段枚举值的转换;
查询单位信息时内部单位和外部单位都需要查询用OR条件查询;
查询单位通过orgs表查询且需要基于parentID查询单位下的子单位
查询内部单位时则可以直接查询人员信息表通过like模糊查询
'''
rule_ddl='''
@@ -636,7 +636,7 @@ user_status_ddl='''
user_attendance_ddl = '''
{
"db_name": "YJOA_APPSERVICE_DB",
"table_name": "t_person_attendance_records",
"table_name": "t_yj_person_attendance",
"table_comment": "人员考勤记录表,存储员工的打卡记录、考勤状态和位置信息",
"columns": [
{
@@ -691,7 +691,7 @@ user_attendance_ddl = '''
"2": "休假"
},
"role": "dimension",
"tags": ["状态标识", "人员在岗状态"]
"tags": ["状态标识", "人员在岗状态","枚举"]
},
{
"name": "original_id",
@@ -723,13 +723,7 @@ user_attendance_ddl = '''
"role": "dimension",
"tags": ["软删除", "数据状态"]
},
{
"name": "create_time",
"type": "DATETIME",
"comment": "创建时间",
"role": "dimension",
"tags": ["时间戳", "记录创建时间"]
},
{
"name": "enter_or_exit",
"type": "INT",
@@ -748,34 +742,6 @@ user_attendance_ddl = '''
"role": "dimension",
"tags": ["门禁位置", "打卡设备点"]
},
{
"name": "by_st",
"type": "VARCHAR(20)",
"comment": "上午打卡时间",
"role": "dimension",
"tags": ["时间范围", "开始时间"]
},
{
"name": "by_et",
"type": "VARCHAR(20)",
"comment": "下午打卡时间",
"role": "dimension",
"tags": ["时间范围", "结束时间"]
},
{
"name": "by_st_field",
"type": "VARCHAR(50)",
"comment": "午休前打卡时间",
"role": "dimension",
"tags": ["中间打卡","时间配置"]
},
{
"name": "by_et_field",
"type": "VARCHAR(50)",
"comment": "午休后打卡时间",
"role": "dimension",
"tags": ["中间打卡", "时间配置"]
},
{
"name": "by_go_type",
"type": "VARCHAR(8)",
@@ -867,18 +833,14 @@ person_ac_area = '''
"1":"北京",
"2":"成都",
"3":"秭归",
"4":"林芝市区",
"5":"拉萨",
"6":"米林",
"7":"派镇",
"8":"墨脱",
"5":"林芝"
},
"role": "dimension",
"tags": ["门禁所属地区"]
},
],
"tags": ["门禁详情","门禁区域位置","门禁地区信息"]
"tags": ["门禁详情","门禁区域位置","门禁地区信息","枚举"]
}
'''
@@ -895,6 +857,13 @@ org_orgs_ddl = '''
"comment": "主键ID",
"role": "dimension",
"tags": ["主键", "id标识"]
},
{
"name": "parentid",
"type": "VARCHAR(36)",
"comment": "父级部门ID",
"role": "dimension",
"tags": ["主键", "id标识"]
},
{
"name": "code",