bitscn.com 001set @prov_code:=32;002set @prov_name=省厅;003set @area_code:=3201;004set @area_name=市局;005 006 007set foreign_key_checks=0;008-- ----------------------------009-- table structure for `alertinfo`010-- ----------------------------011drop table if exists `alertinfo`;012create table `alertinfo` (013 `alertid` bigint(20) not null auto_increment comment '唯一、非空、自增、主键',014 `deviceid` bigint(20) default null comment '告警设备的安装单位的单位编号',015 `lineidondevice` bigint(20) default null comment '该线路在录音设备上的线路编号',016 `alertdate` datetime default null comment '告警日期,仅日期有效,时间为00:00:00',017 `allcallcount` int(10) default null comment '当天总通话次数',018 `timeoutcount` int(10) default null comment '当天通话超时次数',019 `linelostcount` int(10) default null comment '当前断线次数',020 `comfirmalert` tinyint(4) default '0' comment '告警是否已经确认',021 primary key (`alertid`)022) engine=innodb default charset=utf8 comment='告警信息表';023 024-- ----------------------------025-- records of alertinfo026-- ----------------------------027 028-- ----------------------------029-- table structure for `departdescinfo`030-- ----------------------------031drop table if exists `departdescinfo`;032create table `departdescinfo` (033 `departclass` bigint(20) not null comment '单位级别',034 `departdesc` varchar(50) default null comment '单位级别描述',035 primary key (`departclass`)036) engine=innodb default charset=utf8 comment='部门级别名称描述信息表';037 038-- ----------------------------039-- records of departdescinfo040-- ----------------------------041 insert into departdescinfo values ('1', '市局');042insert into departdescinfo values ('2', '区分局');043insert into departdescinfo values ('3', '派出所');044 045-- ----------------------------046-- table structure for `departinfo`047-- ----------------------------048drop table if exists `departinfo`;049create table `departinfo` (050 `departid` bigint(20) not null comment '单位编号',051 `departname` varchar(50) default null comment '单位名称',052 primary key (`departid`)053) engine=innodb default charset=utf8 comment='部门信息表';054 055-- ----------------------------056-- records of departinfo057-- ----------------------------058insert into departinfo values (concat(@prov_code,'000000'),@prov_name);059insert into departinfo values (concat(@area_code,'0000'),@area_name);060 061-- ----------------------------062-- table structure for `deviceconnect`063 -- ----------------------------064drop table if exists `deviceconnect`;065create table `deviceconnect` (066 `connectid` bigint(20) not null auto_increment comment '唯一、非空、自增、主键',067 `deviceid` bigint(20) default null comment '设备id',068 `connectdate` datetime default null comment '告警日期',069 `connectstatus` int(20) default null comment '告警状态',070 `comfirmalert` tinyint(4) default '0' comment '是否已确认告警 未确认0,已确认1',071 `comfirmtime` datetime default null comment '确认告警日期',072 `comfirmuserid` bigint(20) default null comment '确认告警人',073 primary key (`connectid`)074) engine=innodb default charset=utf8 comment='设备告警信息表';075 076-- ----------------------------077-- records of deviceconnect078-- ----------------------------079 080-- ----------------------------081-- table structure for `deviceinfo`082-- ----------------------------083drop table if exists `deviceinfo`;084create table `deviceinfo` (085 `deviceid` bigint(20) not null auto_increment comment '设备、服务器编号',086 `departid` bigint(20) default null comment '设备安装的单位编号',087 `devicetype` int(11) default null comment '设备类型',088 `devicename` varchar(100) default null comment '设备名称',089 `linecount` int(11) default null comment '线路数量',090 `ipaddr` varchar(50) default null comment '设备的ip地址',091 `httpport` int(11) default null comment '设备查询语音时使用的端口号',092 `manageport` int(11) default null comment '设备管理端口号',093 `username` varchar(50) default null comment '管理用户名',094 `userpwd` varchar(50) default null comment '管理密码',095 `uploadpolicy` int(20) default null comment '上传策略',096 `uploadtime` varchar(50) default null comment '上传时间,时分,如需要随时上传,则为2400',097 `lastcleandate` datetime default null,098 `statusmid` int(20) default null comment '录音服务器和录音终端设备,数据由哪个矩阵服务器采集',099 primary key (`deviceid`)100) engine=innodb default charset=utf8 comment='设备信息表';101 102-- ----------------------------103-- records of deviceinfo104-- ----------------------------105 106-- ----------------------------107-- table structure for `importantnote`108-- ----------------------------109drop table if exists `importantnote`;110create table `importantnote` (111 `noteid` bigint(20) not null auto_increment comment '编号',112 `note` varchar(8000) default null comment '信息内容',113 `indate` datetime default null comment '输入日期',114 `userid` bigint(20) default null comment '添加该信息的用户id',115 primary key (`noteid`)116) engine=innodb default charset=utf8 comment='重要提示信息表';117 118-- ----------------------------119-- records of importantnote120-- ----------------------------121 122-- ----------------------------123-- table structure for `linelost`124-- ----------------------------125drop table if exists `linelost`;126create table `linelost` (127 `lostid` bigint(20) not null auto_increment comment '编号',128 `deviceid` bigint(20) default null comment '设备编号',129 `lineidondevice` bigint(20) default null comment '设备上的线路号',130 `starttime` datetime default null comment '断线开始时间',131 `endtime` datetime default null comment '断线结束时间',132 primary key (`lostid`)133) engine=innodb default charset=utf8 comment='断线信息表';134 135-- ----------------------------136-- records of linelost137-- ----------------------------138 139-- ----------------------------140-- table structure for `phoneline`141-- ----------------------------142drop table if exists `phoneline`;143create table `phoneline` (144 `lineid` bigint(20) not null auto_increment comment '电话号码线路编号',145 `departid` bigint(20) default null comment '号码所在单位',146 `phoneno` varchar(50) default null comment '电话号码',147 `shortphoneno` varchar(50) default null comment '电话号码',148 `linedesc` varchar(50) default null comment '描述信息',149 primary key (`lineid`)150) engine=innodb default charset=utf8 comment='电话号码表';151 152-- ----------------------------153-- records of phoneline154 -- ----------------------------155 156-- ----------------------------157-- table structure for `queryrecord`158-- ----------------------------159drop table if exists `queryrecord`;160create table `queryrecord` (161 `queryid` bigint(20) not null auto_increment comment '编号',162 `userid` bigint(20) not null comment '该查询的用户编号',163 `querytime` datetime default null comment '查询时间',164 `fileid` bigint(20) default null comment '查询的文件的编号',165 primary key (`queryid`)166) engine=innodb default charset=utf8 comment='用户查询记录表';167 168-- ----------------------------169-- records of queryrecord170-- ----------------------------171 172-- ----------------------------173-- table structure for `realmonitor`174-- ----------------------------175drop table if exists `realmonitor`;176create table `realmonitor` (177 `realmonitorid` bigint(20) not null auto_increment comment '编号',178 `matrixserverid` bigint(20) default null comment '数据提供的矩阵服务器的编号',179 `deviceid` bigint(20) default null comment '该线路的设备的编号',180 `lineidondevice` bigint(20) default null comment '该线路在设备上的编号',181 `linetype` int(11) default '0' comment '线路类型',182 `callstatus` int(20) default null comment '呼叫结果',183 `calldirection` int(20) default null comment '呼叫方向',184 `myphoneno` varchar(50) default null comment '本方号码',185 `myshortphoneno` varchar(50) default null comment '本方短号',186 `remotephoneno` varchar(50) default null comment '对方号码',187 `refleshtime` datetime default null comment '该信息刷新的时间',188 primary key (`realmonitorid`)189) engine=innodb default charset=utf8 comment='实时监控信息表';190 191-- ----------------------------192 -- records of realmonitor193-- ----------------------------194 195-- ----------------------------196-- table structure for `uploadfile`197-- ----------------------------198drop table if exists `uploadfile`;199create table `uploadfile` (200 `fileid` bigint(20) not null auto_increment comment '编号',201 `filedesc` varchar(1500) default null comment '文件描述',202 `filename` varchar(100) default null comment '文件名称',203 `indate` datetime default null comment '上传时间',204 `userid` bigint(20) not null comment '上传该文件的用户的编号',205 primary key (`fileid`)206) engine=innodb default charset=utf8 comment='文件下载信息表';207 208-- ----------------------------209-- records of uploadfile210-- ----------------------------211 212-- ----------------------------213 -- table structure for `userlist`214-- ----------------------------215drop table if exists `userlist`;216create table `userlist` (217 `userid` bigint(20) not null auto_increment comment '用户编号',218 `departid` bigint(20) default null comment '设备编号',219 `username` varchar(20) default null comment '用户名',220 `userpwd` varchar(200) default null comment '用户密码',221 `fullname` varchar(100) default null comment '用户姓名',222 `userdesc` varchar(50) default null comment '用户描述信息',223 `idcard` varchar(40) default null comment '身份证号',224 `userpopedom` int(20) default '0' comment '用户权限值',225 primary key (`userid`)226) engine=innodb default charset=utf8 comment='用户信息表';227 228-- ----------------------------229-- records of userlist230-- ----------------------------231 232insert into userlist values ('1', concat(@prov_code,'000000') , 'styh', '698d51a19d8a121ce581499d7b701668', 'styh', @prov_name, '123456789987654', '63');233insert into userlist values ('2', concat(@area_code,'0000') , 'admin', '698d51a19d8a121ce581499d7b701668', 'sjyh', @area_name, '123456789987654', '63');234 235-- ----------------------------236-- table structure for `userauthenticate`237-- ----------------------------238drop table if exists `userauthenticate`;239create table `userauthenticate` (240 `authid` bigint(20) not null auto_increment comment '授权编号',241 `userid` bigint(20) default null comment '用户编号',242 `managedepartid` bigint(20) default null comment '授权给该用户的可以访问的单位的编号',243 primary key (`authid`) 244) engine=innodb default charset=utf8 comment='用户权限信息表';245 246-- ----------------------------247-- records of userauthenticate248-- ----------------------------249insert into userauthenticate values ('1', '1', concat(@prov_code,'000000'));250insert into userauthenticate values ('2', '2', concat(@area_code,'0000'));251 252-- ----------------------------253-- table structure for `userlog`254-- ----------------------------255drop table if exists `userlog`;256create table `userlog` (257 `logid` bigint(16) not null auto_increment comment '登录编号',258 `userid` bigint(16) not null comment '用户编号',259 `ipaddr` varchar(50) default null comment '用户登录时使用的ip地址',260 `logintime` datetime default null comment '登录时间',261 `logouttime` datetime default null comment '注销时间',262 primary key (`logid`) 263) engine=innodb default charset=latin1 comment='用户登录记录表';264 265-- ----------------------------266-- records of userlog267-- ----------------------------268 269-- ----------------------------270-- table structure for `voicefilelist`271-- ----------------------------272drop table if exists `voicefilelist`;273create table `voicefilelist` (274 `fileid` bigint(20) not null auto_increment comment '文件编号',275 `deviceid` bigint(20) default null comment '当前文件所在设备的编号',276 `lineid` bigint(20) default null comment '该通话局内号码对应的线路编号',277 `phoneno` varchar(50) default null comment '对方电话号码',278 `rectime` datetime default null comment '通话开始时间',279 `ringlength` int(20) default null comment '响铃时间长度',280 `reclength` int(20) default null comment '通话时间长度',281 `filename` varchar(100) default null comment '文件名称',282 `iscallout` int(20) default null comment '呼入呼出',283 `istate` int(20) default null comment '呼叫结果',284 `ifilelevel` int(20) default null comment '文件重要等级',285 `filememo` varchar(50) default null comment '文件描述',286 `isdeled` int(20) default null comment '是否已被删除',287 `orgdeviceid` bigint(20) default null comment '该文件在原始录音设备编号',288 `orglineidondevice` bigint(20) default null comment '该文件在原始录音设备上的线路编号',289 `orgstoragetypeondevice` bigint(20) default null comment '该文件在原始录音设备上的存储介质类型',290 `orgfileidondevice` bigint(20) default null comment '该文件在原始录音设备上的文件编号',291 primary key (`fileid`)292) engine=innodb default charset=utf8 comment='通话记录清单';293 294-- ----------------------------295-- records of voicefilelist296-- ----------------------------297 298-- ----------------------------299-- table structure for `longcallinfo`300-- ----------------------------301drop table if exists `longcallinfo`;302create table `longcallinfo` (303 `longcallid` int(11) not null auto_increment comment '编号',304 `deviceid` bigint(11) not null comment '设备编号',305 `lineidondevice` bigint(11) not null comment '线路编号',306 `iscallout` int(1) not null comment '呼入呼出',307 `phoneno` varchar(64) not null comment '本方号码',308 `remotephoneno` varchar(64) not null comment '对方号码',309 `shortphoneno` varchar(64) not null comment '本方短号',310 `starttime` datetime not null comment '开始时间',311 `endtime` datetime not null comment '结束时间',312 primary key (`longcallid`)313) engine=innodb default charset=utf8 comment='长时间通话信息表';314 315-- ----------------------------316-- records of longcallinfo317-- ----------------------------01-- ----------------------------02-- function structure for `getdeplevelbyid`03-- ----------------------------04drop function if exists `getdeplevelbyid`;05delimiter ;;06create definer=`root`@`%` function `getdeplevelbyid`(depid bigint) returns int(11)07 comment '根据部门的编号id来查找部门的级别'08begin09 declare tmpdepid bigint default depid; 10 declare deplevel bigint default 1; 11 while tmpdepid>100 do 12 if (tmpdepid mod 100)0 then13 set deplevel=deplevel+1;14 end if;15 set tmpdepid=tmpdepid/100;16 end while; 17 return deplevel;18 end19;;20delimiter ;01-- ----------------------------02-- function structure for `getlistnums`03-- ----------------------------04drop function if exists `getlistnums`;05delimiter ;; 06create definer=`root`@`%` function `getlistnums`(curlogid bigint) returns bigint(20)07begin08return (select count(*) as listennums from queryrecord, userlog where userlog.logid=curlogid and queryrecord.userid = userlog.userid09 and queryrecord.querytime >= userlog.logintime and queryrecord.querytime 32000000/r/n'09begin10 declare pardepid bigint default depid;11 declare levelpar bigint default 0;12 declare i int default 0; 13 14 if getdeplevelbyid(depid)deplevel then15 while pardepid>power(100,deplevel) do16 set levelpar=power(100,i);17 set pardepid=depid p levelpar; 18 set i=i+1;19 end while;20 set levelpar=power(100,i-1); 21 set pardepid=pardepid*levelpar;22 return pardepid;23 24 else25 return depid;26 end if;27end28;;29delimiter ; 作者 bug哥 bitscn.com