ry_dm_complaint.sql 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. -- ============================================
  2. -- 教育投诉平台 业务表建表脚本(达梦 DM8)
  3. -- 模式:COMPLAINT(用 COMPLAINT 用户执行)
  4. -- 说明:本脚本仅建"业务新增表",若依框架自带表请执行 ry_dm_schema.sql
  5. -- ============================================
  6. -- 1、投诉工单主表
  7. drop table if exists complaint_workorder;
  8. create table complaint_workorder (
  9. id bigint not null IDENTITY(1,1),
  10. complaint_no varchar(32) not null,
  11. openid varchar(64) default '',
  12. name varchar(30) default '',
  13. phone varchar(11) default '',
  14. "identity" varchar(10) default '',
  15. city varchar(30) default '',
  16. district varchar(30) default '',
  17. unit_uid varchar(64) default '',
  18. school_name varchar(100) default '',
  19. school_type varchar(20) default '',
  20. category varchar(30) default '',
  21. content varchar(1000) default '',
  22. images varchar(2000) default '',
  23. status tinyint default 0,
  24. investigation varchar(2000) default '',
  25. conclusion varchar(2000) default '',
  26. process_images varchar(2000) default '',
  27. reject_reason varchar(1000) default '',
  28. accept_time timestamp,
  29. close_time timestamp,
  30. create_by varchar(64) default '',
  31. create_time timestamp,
  32. update_by varchar(64) default '',
  33. update_time timestamp,
  34. remark varchar(500) default '',
  35. primary key (id)
  36. );
  37. COMMENT ON TABLE complaint_workorder IS '投诉工单主表';
  38. COMMENT ON COLUMN complaint_workorder.complaint_no IS '工单编号(TS+yyyyMMdd+4位流水)';
  39. COMMENT ON COLUMN complaint_workorder.openid IS '投诉人微信OpenID';
  40. COMMENT ON COLUMN complaint_workorder.name IS '举报人真实姓名';
  41. COMMENT ON COLUMN complaint_workorder.phone IS '联系电话(仅校方联系)';
  42. COMMENT ON COLUMN complaint_workorder."identity" IS '举报人身份(家长/教职工/学生/社会人员)';
  43. COMMENT ON COLUMN complaint_workorder.city IS '地市';
  44. COMMENT ON COLUMN complaint_workorder.district IS '县区(SSQYDM名称)';
  45. COMMENT ON COLUMN complaint_workorder.unit_uid IS '学校机构UID(东软,分派核心)';
  46. COMMENT ON COLUMN complaint_workorder.school_name IS '学校名称';
  47. COMMENT ON COLUMN complaint_workorder.school_type IS '学校类别';
  48. COMMENT ON COLUMN complaint_workorder.category IS '投诉分类(字典complaint_category)';
  49. COMMENT ON COLUMN complaint_workorder.content IS '投诉内容(≤500字)';
  50. COMMENT ON COLUMN complaint_workorder.images IS '附件图片(JSON数组,≤5张)';
  51. COMMENT ON COLUMN complaint_workorder.status IS '状态:0待受理 1处理中 2已办结 3已驳回 5复核中';
  52. COMMENT ON COLUMN complaint_workorder.investigation IS '调查经过(当前值)';
  53. COMMENT ON COLUMN complaint_workorder.conclusion IS '处置结论(当前值)';
  54. COMMENT ON COLUMN complaint_workorder.process_images IS '处置佐证附件(JSON)';
  55. COMMENT ON COLUMN complaint_workorder.reject_reason IS '驳回理由';
  56. COMMENT ON COLUMN complaint_workorder.accept_time IS '受理时间';
  57. COMMENT ON COLUMN complaint_workorder.close_time IS '办结时间';
  58. create unique index uk_workorder_no on complaint_workorder (complaint_no);
  59. create index idx_workorder_openid on complaint_workorder (openid);
  60. create index idx_workorder_unit on complaint_workorder (unit_uid);
  61. create index idx_workorder_status on complaint_workorder (status);
  62. -- 2、处置留痕表
  63. drop table if exists complaint_process_log;
  64. create table complaint_process_log (
  65. id bigint not null IDENTITY(1,1),
  66. complaint_no varchar(32) not null,
  67. "action" varchar(20) default '',
  68. investigation varchar(2000) default '',
  69. conclusion varchar(2000) default '',
  70. process_images varchar(2000) default '',
  71. reject_reason varchar(1000) default '',
  72. operator_id bigint default 0,
  73. operator_name varchar(30) default '',
  74. create_time timestamp,
  75. primary key (id)
  76. );
  77. COMMENT ON TABLE complaint_process_log IS '处置留痕表(受理/暂存/办结/驳回/复核)';
  78. COMMENT ON COLUMN complaint_process_log."action" IS '动作:受理/暂存/办结/驳回/复核';
  79. COMMENT ON COLUMN complaint_process_log.operator_id IS '操作管理员ID(sys_user或complaint_admin)';
  80. COMMENT ON COLUMN complaint_process_log.operator_name IS '操作人姓名';
  81. create index idx_process_no on complaint_process_log (complaint_no);
  82. -- 3、消息推送日志表
  83. drop table if exists complaint_message_log;
  84. create table complaint_message_log (
  85. id bigint not null IDENTITY(1,1),
  86. complaint_no varchar(32) default '',
  87. msg_type varchar(10) default '',
  88. receiver varchar(500) default '',
  89. templet_id varchar(50) default '',
  90. content varchar(2000) default '',
  91. msg_id varchar(64) default '',
  92. "result" tinyint default 0,
  93. error_msg varchar(500) default '',
  94. create_time timestamp,
  95. primary key (id)
  96. );
  97. COMMENT ON TABLE complaint_message_log IS '消息推送日志表(短信/公众号)';
  98. COMMENT ON COLUMN complaint_message_log.msg_type IS '消息类型:sms/wechat';
  99. COMMENT ON COLUMN complaint_message_log.receiver IS '接收人信息(姓名/手机号/学工号)';
  100. COMMENT ON COLUMN complaint_message_log.templet_id IS '模板id(短信templet_id/公众号wechat_templet_id)';
  101. COMMENT ON COLUMN complaint_message_log.msg_id IS '统一通讯平台返回的消息id';
  102. COMMENT ON COLUMN complaint_message_log."result" IS '推送结果:1成功 0失败';
  103. create index idx_msg_no on complaint_message_log (complaint_no);
  104. create index idx_msg_time on complaint_message_log (create_time);
  105. -- 4、免登令牌表
  106. drop table if exists complaint_token;
  107. create table complaint_token (
  108. id bigint not null IDENTITY(1,1),
  109. token varchar(64) not null,
  110. complaint_no varchar(32) default '',
  111. unit_uid varchar(64) default '',
  112. expire_time timestamp,
  113. used tinyint default 0,
  114. create_time timestamp,
  115. primary key (id)
  116. );
  117. COMMENT ON TABLE complaint_token IS '免登令牌表';
  118. COMMENT ON COLUMN complaint_token.token IS '随机token(UUID)';
  119. COMMENT ON COLUMN complaint_token.unit_uid IS '绑定学校(防越权)';
  120. COMMENT ON COLUMN complaint_token.expire_time IS '过期时间(建议72小时)';
  121. COMMENT ON COLUMN complaint_token.used IS '是否已用:0未用 1已用(一次性)';
  122. create unique index uk_token on complaint_token (token);
  123. -- 5、学校机构同步缓存表(UNITINFO_1)
  124. drop table if exists unit_school;
  125. create table unit_school (
  126. unit_uid varchar(64) not null,
  127. unit_name varchar(200) default '',
  128. ssqydm varchar(20) default '',
  129. ssqymc varchar(50) default '',
  130. dwlx varchar(10) default '',
  131. dwlxmc varchar(50) default '',
  132. xddm varchar(10) default '',
  133. yxbs varchar(2) default '1',
  134. data_update_time timestamp,
  135. data_update_flog char(1) default 'I',
  136. sync_time timestamp,
  137. primary key (unit_uid)
  138. );
  139. COMMENT ON TABLE unit_school IS '学校机构同步缓存表(东软UNITINFO_1)';
  140. COMMENT ON COLUMN unit_school.unit_uid IS '机构UID(主键)';
  141. COMMENT ON COLUMN unit_school.unit_name IS '机构名称';
  142. COMMENT ON COLUMN unit_school.ssqydm IS '所属区域代码(HBW/WD/HN)';
  143. COMMENT ON COLUMN unit_school.ssqymc IS '所属区域名称';
  144. COMMENT ON COLUMN unit_school.dwlx IS '单位类型代码(DWLX)';
  145. COMMENT ON COLUMN unit_school.dwlxmc IS '单位类型名称';
  146. COMMENT ON COLUMN unit_school.xddm IS '学段代码(XDDM)';
  147. COMMENT ON COLUMN unit_school.yxbs IS '有效标识:0无效 1有效';
  148. COMMENT ON COLUMN unit_school.data_update_flog IS '增量标识:I新增 U更新 D删除';
  149. create index idx_unit_dwlx on unit_school (dwlx);
  150. create index idx_unit_ssqy on unit_school (ssqydm);
  151. -- 6、学校管理员表(学校提供名单,手动维护)
  152. drop table if exists complaint_admin;
  153. create table complaint_admin (
  154. id bigint not null IDENTITY(1,1),
  155. unit_uid varchar(64) default '',
  156. admin_name varchar(30) default '',
  157. phone varchar(11) default '',
  158. staff_no varchar(32) default '',
  159. "identity" varchar(20) default '',
  160. status tinyint default 1,
  161. create_by varchar(64) default '',
  162. create_time timestamp,
  163. update_by varchar(64) default '',
  164. update_time timestamp,
  165. primary key (id)
  166. );
  167. COMMENT ON TABLE complaint_admin IS '学校管理员表(学校提供名单,后台手动维护)';
  168. COMMENT ON COLUMN complaint_admin.unit_uid IS '所属学校UID';
  169. COMMENT ON COLUMN complaint_admin.admin_name IS '管理员姓名';
  170. COMMENT ON COLUMN complaint_admin.phone IS '手机号(短信接收,必填)';
  171. COMMENT ON COLUMN complaint_admin.staff_no IS '学工号(公众号消息接收,选填)';
  172. COMMENT ON COLUMN complaint_admin."identity" IS '职务(校长/主任/经办人等)';
  173. COMMENT ON COLUMN complaint_admin.status IS '1启用 0停用';
  174. create index idx_admin_unit on complaint_admin (unit_uid);
  175. create index idx_admin_phone on complaint_admin (phone);
  176. -- 7、异议复核表
  177. drop table if exists complaint_review;
  178. create table complaint_review (
  179. id bigint not null IDENTITY(1,1),
  180. complaint_no varchar(32) not null,
  181. openid varchar(64) default '',
  182. reason varchar(1000) default '',
  183. images varchar(2000) default '',
  184. status tinyint default 0,
  185. review_result varchar(1000) default '',
  186. review_by varchar(30) default '',
  187. review_time timestamp,
  188. create_time timestamp,
  189. primary key (id)
  190. );
  191. COMMENT ON TABLE complaint_review IS '异议复核表';
  192. COMMENT ON COLUMN complaint_review.status IS '0待复核 1维持原判 2复核通过(重新处置)';
  193. COMMENT ON COLUMN complaint_review.review_result IS '复核处理意见';
  194. COMMENT ON COLUMN complaint_review.review_by IS '复核人';
  195. create index idx_review_no on complaint_review (complaint_no);
  196. -- 8、数据同步日志表
  197. drop table if exists data_sync_log;
  198. create table data_sync_log (
  199. id bigint not null IDENTITY(1,1),
  200. sync_type varchar(20) default '',
  201. interface_name varchar(50) default '',
  202. total int default 0,
  203. success int default 0,
  204. fail int default 0,
  205. status tinyint default 0,
  206. error_msg varchar(1000) default '',
  207. create_time timestamp,
  208. primary key (id)
  209. );
  210. COMMENT ON TABLE data_sync_log IS '数据同步日志表';
  211. COMMENT ON COLUMN data_sync_log.sync_type IS '同步类型:init全量/daily增量';
  212. COMMENT ON COLUMN data_sync_log.interface_name IS '接口名(UNITINFO_1等)';
  213. COMMENT ON COLUMN data_sync_log.status IS '0失败 1成功';
  214. -- ============================================
  215. -- 字典初始化(投诉业务字典)
  216. -- ============================================
  217. SET IDENTITY_INSERT sys_dict_type ON;
  218. insert into sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, remark)
  219. values (100, '投诉分类', 'complaint_category', '0', 'admin', sysdate, '教育投诉分类');
  220. insert into sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, remark)
  221. values (101, '学校类别', 'school_type', '0', 'admin', sysdate, '学校类别(映射东软DWLX)');
  222. SET IDENTITY_INSERT sys_dict_type OFF;
  223. SET IDENTITY_INSERT sys_dict_data ON;
  224. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  225. values (500, 1, '违规收费', '违规收费', 'complaint_category', 'N', '0', 'admin', sysdate, '');
  226. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  227. values (501, 2, '食品安全', '食品安全', 'complaint_category', 'N', '0', 'admin', sysdate, '');
  228. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  229. values (502, 3, '补课违规', '补课违规', 'complaint_category', 'N', '0', 'admin', sysdate, '');
  230. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  231. values (503, 4, '师德师风', '师德师风', 'complaint_category', 'N', '0', 'admin', sysdate, '');
  232. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  233. values (504, 5, '招生违规', '招生违规', 'complaint_category', 'N', '0', 'admin', sysdate, '');
  234. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  235. values (505, 6, '其他', '其他', 'complaint_category', 'N', '0', 'admin', sysdate, '');
  236. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  237. values (510, 1, '幼儿园', '幼儿园', 'school_type', 'N', '0', 'admin', sysdate, 'DWLX=11');
  238. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  239. values (511, 2, '小学', '小学', 'school_type', 'N', '0', 'admin', sysdate, 'DWLX=21');
  240. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  241. values (512, 3, '初级中学', '初级中学', 'school_type', 'N', '0', 'admin', sysdate, 'DWLX=31');
  242. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  243. values (513, 4, '普通高中', '普通高中', 'school_type', 'N', '0', 'admin', sysdate, 'DWLX=34');
  244. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  245. values (514, 5, '完全中学', '完全中学', 'school_type', 'N', '0', 'admin', sysdate, '');
  246. insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
  247. values (515, 6, '职业院校', '职业院校', 'school_type', 'N', '0', 'admin', sysdate, 'DWLX=36');
  248. SET IDENTITY_INSERT sys_dict_data OFF;
  249. commit;