1、sqlserver迷你版
服务器名称一般是.,1688\MJ
标准语法:
- <add name="SQL" connectionString="server=.,1688\MJ;database=BSData;Trusted_Connection=SSPI"
- providerName="System.Data.SqlClient" />
有的电脑如果不需带端口,去掉“,1688”就行了。大部份是要带的。
2、进入数据库:
解锁密码一般是168168
如果没有左侧菜单:
TEmployee 表取人员数据,也可以直接将人员信息录入进去,不影响其他表
TEvent 表取刷卡数据
连接信息,也可以使用sqlserver用户密码登录,帐号sa 密码168168
备份的数据库后缀名是.sdb,在后缀添加一个.bak即可导入sqlserver库
恢复数据库参照:
http://www.yoyo88.cn/study/sqlserver/354.html
查询人员档案,读取部门表,职位表
SqlServer版查询:
- SELECT TOP 10
- EmployeeData.EmployeeID as door_id,
- EmployeeData.EmployeeCode,
- EmployeeData.EmployeeName as nickname,
- EmployeeData.CardNo as door_card_no,
- EmployeeData.Sex as gender,
- EmployeeData.Birthday,
- EmployeeData.Phone as phone,
- EmployeeData.JobID as door_job_id,
- EmployeeData.DeptID as door_dep_id,
- EmployeeData.RegDate,
- EmployeeData.EndDate,
- EmployeeData.Deleted,
- EmployeeData.Note1 as role_name,
- EmployeeData.Note2,
- EmployeeData.Note3,
- EmployeeData.Note4,
- EmployeeData.Note5,
- EmployeeData.[TimeStamp],
- DepartmentData.DeptLevel as door_dep_level,
- DepartmentData.DeptName as door_dep_name,
- DepartmentData.DeptNote as door_dep_note,
- JobData.JobName as door_job_name,
- JobData.JobNote as door_job_note
- FROM TEmployee as EmployeeData
- LEFT JOIN TDeptA as DepartmentData on EmployeeData.DeptID=DepartmentData.DeptID
- LEFT JOIN TJob as JobData on EmployeeData.JobID=JobData.JobID
- WHERE EmployeeData.Deleted = 0
根据Note1字段 别名是role_name 来区分,
如果role_name=管理员,则 door_dep_name 是部门名称,door_job_name 是职位名称
反之: 则 door_dep_name 是班组名称,door_job_name 是工种名称
SqlServer的配置文件参考:
Access的配置文件参考:
对接软件下载链接:
http://www.yoyo88.cn/e/extend/publish/common_door_synchronize4_out/Release.zip(托盘区右击设置,密码m123456,)
刷卡记录的SQL必须有eventID
- DROP TABLE IF EXISTS `monitor_door_tevent`;
- CREATE TABLE `monitor_door_tevent` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `EventID` int(11) DEFAULT '0',
- `EventTime` datetime DEFAULT NULL,
- `EmployeeID` int(11) DEFAULT '0' COMMENT '用户ID',
- `CardNo` varchar(50) COLLATE utf8_unicode_ci DEFAULT '',
- `DoorID` tinyint(2) DEFAULT '0',
- `ControlID` tinyint(2) DEFAULT '0',
- `ControlText` varchar(128) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '控制器名称',
- `EventType` tinyint(2) DEFAULT '0' COMMENT '刷卡类型',
- `EventText` varchar(50) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '刷卡动作名称',
- `created_at` int(11) DEFAULT NULL,
- `updated_at` int(11) DEFAULT NULL,
- PRIMARY KEY (`id`),
- KEY `EventTime` (`EventTime`) USING BTREE,
- KEY `EmployeeID` (`EmployeeID`) USING BTREE,
- KEY `CardNo` (`CardNo`) USING BTREE
- ) ENGINE=MyISAM AUTO_INCREMENT=22930 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
http://www.yoyo88.cn/e/extend/publish/common_door_synchronize2/publish.htm(版本二)
如果刷卡记录的主键选择int ,那么刷卡记录的SQL必须有eventID
如果刷卡记录的主键选择string,那么刷卡记录的SQL必须有primaryKey,可以用时间as
- DROP TABLE IF EXISTS `widom_monitor_door_tevent`;
- CREATE TABLE `widom_monitor_door_tevent` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `EventID` int(11) DEFAULT '0',
- `EventTime` datetime DEFAULT NULL,
- `EmployeeID` int(11) DEFAULT '0' COMMENT '用户ID',
- `Employee` varchar(60) COLLATE utf8_unicode_ci DEFAULT '',
- `CardNo` varchar(50) COLLATE utf8_unicode_ci DEFAULT '',
- `DoorID` tinyint(2) DEFAULT '0',
- `ControlID` tinyint(2) DEFAULT '0',
- `ControlText` varchar(128) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '控制器名称',
- `EventType` tinyint(2) DEFAULT '0' COMMENT '刷卡类型',
- `EventText` varchar(50) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '刷卡动作名称',
- `created_at` int(11) DEFAULT NULL,
- `updated_at` int(11) DEFAULT NULL,
- `primaryKey` varchar(128) COLLATE utf8_unicode_ci DEFAULT '',
- PRIMARY KEY (`id`),
- KEY `EventTime` (`EventTime`) USING BTREE,
- KEY `EmployeeID` (`EmployeeID`) USING BTREE,
- KEY `CardNo` (`CardNo`) USING BTREE
- ) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
接收刷卡记录:
- /**
- * 如果门禁没有主键ID,则获取当前最大的主键编号,一般为时间等
- * @return array
- */
- public function actionGetMaxPrimary()
- {
- $idx = DoorTevent::find()->max("primaryKey");
- exit($idx?$idx:"");
- }
- /**
- * 如果门禁有主键ID,则获取当前最大的门禁记录ID
- */
- public function actionGetMaxId()
- {
- $idx = DoorTevent::find()->max("EventID");
- exit($idx?$idx:"");
- }
- /**
- * 采集刷卡数据
- * @return array
- */
- public function actionSaveEvent()
- {
- $post = request()->post();
- $id = request()->post("EventID", null);
- $primaryKey = request()->post("primaryKey", null);
- $CardNo = request()->post("CardNo", null);
- $msg = "ok";
- $model = new DoorTevent();
- if ($id) {
- $res = DoorTevent::find()->where(['EventID' => $id])->one();
- if ($res) {
- // $model = $res;
- // $model->save(); // 不用再更新一次了
- $msg = "重复数据,跳过";
- return [
- "errmsg" => $msg
- ];
- } else {
- $msg = "新增成功";
- }
- }
- // 如果有主键和卡卡号,同一卡号,同一时间不允许重复录入
- if($primaryKey && $CardNo){
- $res = DoorTevent::find()->where(['primaryKey' => $primaryKey,'CardNo'=>$CardNo])->one();
- if ($res) {
- $msg = "重复数据,跳过";
- return [
- "errmsg" => $msg
- ];
- } else {
- $msg = "新增成功";
- }
- }
- $model->setAttributes($post);
- if ($model->save()) {
- return [
- "errmsg" => $msg
- ];
- } else {
- return [
- "errcode" => 400,
- "errmsg" => current($model->getFirstErrors())
- ];
- }
- }