001 set @ Prov_Code: = 32; 002 set @ Prov_Name = "Provincial/Municipal Departments"; 003 set @ Area_Code: = 3201; 004 set @ Area_Name = "Municipal Bureau "; 005 www.2cto.com 006 007 SET FOREIGN_KEY_CHECKS = 0; 008 -- ---------------------------- 009 -- Table structure for 'alertinfo '010 -- dropping 011 drop table if exists 'alertinfo '; 012 create table 'alertinfo' (013 'alertid' bigint (20) not null auto_increment COMMENT 'unique, non-empty, auto-increment, primary key', 014 'deviceid' bigint (20) default null comment 'unit no. of the alert device installation unit ', 015 www.2cto.com 'lineidondevice' bigint (20) default NULL comment' line No. of the line on the recording device ', 016 'alertdate' datetime default NULL comment' alert date, valid only for date, time: 00:00:00, 017 'allcallcount' int (10) default null comment 'total calls of the day ', 018 'timeoutcount' int (10) default NULL comment' number of calls timed out on the current day ', 019 'linelostcount' int (10) default NULL comment' current disconnection count ', 020 'comfirmalert 'tinyint (4) default '0' comment' whether the alarm has been confirmed', 021 primary key ('alertid') 022) ENGINE = InnoDB default charset = utf8 COMMENT = 'alert info table '; 023 024 -- primary 025 -- Records of AlertInfo026 -- -------------------------- 027 028 -- partition 029 -- Table structure for 'partition descinfo '030 -- partition 031 drop table if exists' limit descinfo '; 032 create table 'your descinfo' (033 'your class' bigint (20) not null comment' unit level ', 034 'your desc' varchar (50) default NULL comment' unit level description ', 035 primary key ('Primary class') 036) ENGINE = InnoDB default charset = utf8 COMMENT = 'department-level Name Description information '; 037 038 -- 2017039 -- Records of includescinfo040 -- 2017041 www.2cto.com insert into includescinfo VALUES ('1', 'registry '); 042 insert into includescinfo VALUES ('2 ', 'area subauthorization'); 043 insert into includescinfo VALUES ('3', 'police station '); 044 045 -- limit 046 -- Table structure for 'desttinfo '047 -- limit 048 drop table if exists' DepartInfo '; 049 create table 'deptinfo' (050 'destentid' bigint (20) not null comment 'unit number', 051 'Organization name' varchar (50) default NULL comment' unit name', 052 primary key ('departid') 053) ENGINE = InnoDB default charset = utf8 COMMENT = 'department info table '; 054 055 -- 2017056 -- Records of DepartInfo057 -- ------------------------ 058 insert into DepartInfo VALUES (concat (@ Prov_Code, '20140901'), @ Prov_Name); 059 insert into DepartInfo VALUES (concat (@ Area_Code, '20140901'), @ Area_Name ); 060 061 -- defaults 062 -- Table structure for 'deviceconnect '063 www.2cto.com -- Comment 064 drop table if exists 'deviceconnect'; 065 create table 'deviceconnect '(066 'd d' bigint (20) not null auto_increment COMMENT 'unique, non-empty, auto-incrementing, primary key', 067 'deviceid' bigint (20) default NULL comment' device id ', 068 'date date' datetime default null comment 'alert date', 069 'connectstatus' int (20) default null comment 'alert status', 070 'comfirmalert 'tinyint (4) whether the default '0' comment' has been confirmed. The alarm is not confirmed. 0, 1, 071 'comfirmtime' datetime default null comment' Confirm alert date ', 072 'comfirmuserid' bigint (20) default null comment' Confirm alert contact ', 073 primary key ('d D') 074) ENGINE = InnoDB default charset = utf8 COMMENT = 'device alert info table '; 075 076 -- limit 077 -- Records of DeviceConnect078 -- -------------------------- 079 080 -- limit 081 -- Table structure for 'deviceinfo' 082 -- limit 083 drop table if exists 'deviceinfo '; 084 create table 'deviceinfo' (085 'deviceid' bigint (20) not null auto_increment COMMENT 'device, server number', 086 'demotid' bigint (20) default null comment 'device installation unit number', 087 'devicetype 'int (11) default null comment 'device type', 088 'devicename' varchar (100) default null comment 'device name', 089 'linecount' int (11) default null comment 'line number', 090 'ipadd' varchar (50) default null comment 'IP address of the device ', 091 'httppport' int (11) default null comment 'port number used by the device for Voice Query', 092 www.2cto.com 'manageport 'int (11) default null comment 'device Management port number', 093 'username' varchar (50) default null comment 'Manage username', 094 'userpwd' varchar (50) default null comment 'administrative password', 095 'uploadpolicy' int (20) default null comment 'upload policy', 096 'uploadtime' varchar (50) default NULL comment' upload time, time, if you need to upload at any time, it is 2400 ', 097 'lastcleandate' datetime default NULL, 098 'statusmid' int (20) default null comment 'Recording server and recording terminal device, which matrix server collects data? ', 099 primary key ('deviceid') 100) ENGINE = InnoDB default charset = utf8 COMMENT = 'device infotable '; 101 102 -- reset 103 -- Records of DeviceInfo104 -- ---------------------------- 105 106 -- reset 107 -- Table structure for 'importantnote' 108 -- limit 109 drop table if exists' ImportantNote '; 110 create table 'importantnote' (111 'noteid' bigint (20) not null auto_increment COMMENT 'number', 112 'note' varchar (8000) default NULL comment' information content ', 113 'indate' datetime default NULL comment' input date ', 114 'userid' bigint (20) default NULL comment' Add User ID for this information ', 115 primary key ('noteid') 116) ENGINE = InnoDB default charset = utf8 COMMENT = 'important prompt information '; 117 118 -- lifecycle 119 -- Records of ImportantNote120 -- ------------------------------ 121 122 -- -------------------------- 123 -- Table structure for 'linelost' 124 -- limit 125 drop table if exists 'linelost '; 126 create table 'linelost' (127 'lostid' bigint (20) not null auto_increment COMMENT 'number', 128 'deviceid' bigint (20) default null comment 'device number ', 129 'lineidondevice' bigint (20) default NULL comment' line number on the device ', 130 'starttime' datetime default null comment 'disconnection start time ', 131 'endtime' datetime default NULL comment' disconnection End Time', 132 www.2cto.com primary key ('lostid') 133) ENGINE = InnoDB default charset = utf8 COMMENT = 'disconnection information '; 134 135 -- lifecycle 136 -- Records of LineLost137 -- ---------------------------- 138 139 -- ---------------------------- 140 -- Table structure for 'python' 141 -- limit 142 drop table if exists' 'python '; 143 create table 'python' (144 'lineid' bigint (20) not null auto_increment COMMENT 'phone number line number', 145 'demotid' bigint (20) default null comment 'unit of the number', 146 'phoneno' varchar (50) default null comment 'phone number', 147 'your phoneno' varchar (50) default null comment 'phone number', 148 'linedesc' varchar (50) default NULL comment' description information', 149 primary key ('lineid') 150) ENGINE = InnoDB default charset = utf8 COMMENT = 'phone number docker '; 151 152 -- lifecycle 153 -- Records of PhoneLine154 www.2cto.com -- -------------------------- 155 156 -- lifecycle 157 -- Table structure for 'queryrecord' 158 -- limit 159 drop table if exists 'queryrecord '; 160 create table 'queryrecord' (161 'queryid' bigint (20) not null auto_increment comment' No. ', 162 'userid' bigint (20) not null comment 'user ID of the query', 163 'querytime' datetime default null comment 'query time', 164 'fileid' bigint (20) default null comment 'number of the queried File ', 165 primary key ('queryid') 166) ENGINE = InnoDB default charset = utf8 COMMENT = 'user query record table '; 167 168 -- lifecycle 169 -- Records of QueryRecord170 -- ------------------------------ 171 172 -- -------------------------- 173 -- Table structure for 'realmonitor '174 -- limit 175 drop table if exists 'realmonitor '; 176 create table 'realmonitor '(177 'realmonitorid' bigint (20) not null auto_increment COMMENT 'number', 178 'matrixserverid' bigint (20) default null comment 'number of the matrix server provided by data', 179 'deviceid' bigint (20) default NULL comment' device Number of the line ', 180 'lineidondevice' bigint (20) default NULL comment' Number of the line on the device ', 181 'linetype' int (11) default '0' comment' line type ', 182 'callstatus' int (20) default null comment 'call result', 183 'calldirection' int (20) default null comment 'call direction', 184 'myphoneno' varchar (50) default null comment 'local number', 185 'myusers' phoneno 'varchar (50) default NULL comment' local short number ', 186 'remotephoneno' varchar (50) default null comment 'peer number', 187 'refleshtime' datetime default NULL comment' the information refresh time', 188 primary key ('realmonitorid') 189) ENGINE = InnoDB default charset = utf8 COMMENT = 'real-time monitoring information '; 190 191 -- expose 192 www.2cto.com -- Records of RealMonitor193 -- -------------------------- 194 195 -- expose 196 -- Table structure for 'uploadfile' 197 -- expose 198 drop table if exists 'uploadfile '; 199 create table 'uploadfile' (200 'fileid' bigint (20) not null auto_increment comment' No. ', 201 'filedesc' varchar (1500) default NULL comment' file description ', 202 'filename' varchar (100) default NULL comment' file name', 203 'indate' datetime default null comment 'upload time', 204 'userid' bigint (20) not null comment 'user ID for uploading this file', 205 primary key ('fileid') 206) ENGINE = InnoDB default charset = utf8 COMMENT = 'file download information '; 207 208 -- lifecycle 209 -- Records of UploadFile210 -- lifecycle 211 212 -- ---------------------------- 213 www.2cto.com -- Table structure for 'userlist' 214 -- limit 215 drop table if exists 'userlist '; 216 create table 'userlist' (217 'userid' bigint (20) not null auto_increment COMMENT 'user number', 218 'demotid' bigint (20) default null comment 'device number ', 219 'username' varchar (20) default null comment 'username', 220 'userpwd' varchar (200) default null comment 'user password', 221 'fullname' varchar (100) default null comment 'user name', 222 'userdesc' varchar (50) default NULL comment' user description information', 223 'idcard 'varchar (40) default null comment 'id card No ', 224 'userpopedom 'int (20) default '0' COMMENT 'user permission value', 225 primary key ('userid') 226) ENGINE = InnoDB default charset = utf8 COMMENT = 'user info table'; 227 228 -- ---------------------------- 229 -- Records of UserList230 -- -------------------------- 231 232 insert into UserList VALUES ('1 ', concat (@ Prov_Code, '20140901'), 'styh', '698d51a19d8a121ce581499d7b701668 ', 'styh', @ Prov_Name, '20170901', '63 '); 233 insert into UserList VALUES ('2', concat (@ Area_Code, '000000'), 'admin', '698d51a19d8a121ce581499d7b701668 ', 'sjyh', @ Area_Name, '2016 ', '63'); 234 235 -- -------------------------- 236 -- Table structure for 'userauthenticate' 237 -- ---------------------------- 238 drop table if exist' UserAuthenticate '; 239 create table 'userauthenticate' (240 'authid' bigint (20) not null auto_increment COMMENT 'authorization number', 241 'userid' bigint (20) default null comment 'user number ', 242 'managedepartid' bigint (20) default NULL comment' Number of the units authorized to this user ', 243 primary key ('authid') www.2cto.com 244) ENGINE = InnoDB default charset = utf8 COMMENT = 'user permission information'; 245 246 -- privileges 247 -- Records of UserAuthenticate248 -- ------------------------ 249 insert into UserAuthenticate VALUES ('1', '1 ', concat (@ Prov_Code, '20140901'); 000000 insert into UserAuthenticate VALUES ('2', '2', concat (@ Area_Code, '20140901 ')); 251 252 -- ---------------------------- 253 -- Table structure for 'userlog' 254 -- -------------------------- 255 drop table if exists 'userlog'; 256 create table 'userlog' (257 'logid' bigint (16) not null auto_increment COMMENT 'logon number', 258 'userid' bigint (16) not null comment 'user number', 259 'ipadd' varchar (50) default null comment 'IP address used for user logon ', 260 'logintime' datetime default NULL comment' logon time', 261 'logouttime' datetime default null comment 'logout time ', 262 primary key ('logid') www.2cto.com 263) ENGINE = InnoDB default charset = latin1 COMMENT = 'user logon record table '; 264 265 -- lifecycle 266 -- Records of UserLog267 -- ---------------------------- 268 269 -- lifecycle 270 -- Table structure for 'voicefilelist' 271 -- limit 272 drop table if exists 'voicefilelist '; 273 create table 'voicefilelist' (274 'fileid' bigint (20) not null auto_increment COMMENT 'file number', 275 'deviceid' bigint (20) default null comment 'device Number of the current file', 276 'lineid' bigint (20) default NULL comment' line number corresponding to the call board number ', 277 'python' varchar (50) default NULL comment' other party's phone number ', 278 'rectime' datetime default null comment 'call start time', 279 'ringlength' int (20) default null comment 'alert time length', 280 'reclength' int (20) default NULL comment' call time length', 281 'filename' varchar (100) default null comment 'file name', 282 'iscallout' int (20) default NULL comment' incoming call out', 283 www.2cto.com 'istate' int (20) default null comment 'call result', 284 'ifilelevel' int (20) default NULL comment' file importance level', 285 'filememo' varchar (50) default null comment 'file description', 286 'isdeled' int (20) default NULL comment' whether it has been deleted ', 287 'orgdeviceid' bigint (20) default null comment 'number of the file on the original recording device ', 288 'orglineidondevice' bigint (20) default NULL comment' line number of the file on the original recording device ', 289 'orgstoragetypeondevic' bigint (20) default NULL comment' storage media type of the file on the original recording device ', 290 'orgfileidondevic' bigint (20) default null comment 'number of the file on the original recording device ', 291 primary key ('fileid') 292) ENGINE = InnoDB default charset = utf8 COMMENT = 'call record list '; 293 294 -- lifecycle 295 -- Records of VoiceFileList296 -- -------------------------- 297 298 299 -- lifecycle 300 -- Table structure for 'longcallinfo '301 -- limit drop table if exists 'longcallinfo '; 302 create table 'longcallinfo' (303 'longcallid' int (11) not null auto_increment comment' No. ', 304 'deviceid' bigint (11) not null comment' device No ', 305 'lineidondevic' bigint (11) not null comment 'line number', 306 'iscallout' int (1) not null comment 'Incoming call out', 307 'pythoneno' varchar (64) not null comment 'local number', 308 'remotephoneno 'varchar (64) not null comment 'peer number', 309 'your phoneno' varchar (64) not null comment 'start time', 310 'starttime' datetime not null comment' start time', 311 'endtime' datetime not null comment' End Time ', 312 www.2cto.com primary key ('longcallid') 313) ENGINE = InnoDB default charset = utf8 COMMENT = 'long call information '; 314 315 -- lifecycle 316 -- Records of LongCallInfo317 -- -------------------------- 01 -- objective 02 -- Function structure for 'getplevelbyid' 03 -- Comment 04 drop function if exists 'getplevelbyid'; 05 DELIMITER ;; 06 create definer = 'root' @ '% 'function' getdeplevelbyid' (depID bigint) RETURNS int (11) 07 COMMENT 'Find the department level '08inin09 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; 20 DELIMITER; 01 -- -------------------------- 02 -- Function structure for 'getlistnums' 03 -- Define 04 drop function if exists 'getlistnums'; 05 DELIMITER ;; www.2cto.com 06 create 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 <= UserLog. logOUTTime); 10end11; 12 DELIMITER; 01 -- Comment 02 -- Function structure for 'getpardepidbylevel' 03 -- -------------------------- 04 drop function if exists 'getpardepidbylevel'; 05 DELIMITER ;; 06 create definer = 'root' @ '% 'function' GetParDepIDByLevel' (depID bigint, 07 depLevel int) RETURNS bigint (20) 08 COMMENT: Find the Department ID \ r \ n corresponding to this level based on the department ID and the level to be searched, for example, 32010101,1 ---> 32000000 \ r \ n' 09inin10 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 div levelPar; 18 set I = I + 1; 19 END WHILE; 20 set levelPar = power (100, i-1); 21 set parDepID = parDepID * levelPar; 22 www.2cto.com return parDepID; 23 24 else25 return depID; 26 end if; 27end28; 29 DELIMITER; author bug brother