From 59ec75d7d8cdacfae7b0f157993cd217743ae563 Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 30 三月 2017 16:47:14 +0800
Subject: [PATCH] 

---
 VisitFace/document/erdb api接口描述.txt |  170 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 154 insertions(+), 16 deletions(-)

diff --git "a/VisitFace/document/erdb api\346\216\245\345\217\243\346\217\217\350\277\260.txt" "b/VisitFace/document/erdb api\346\216\245\345\217\243\346\217\217\350\277\260.txt"
index 8611faf..1424f8d 100644
--- "a/VisitFace/document/erdb api\346\216\245\345\217\243\346\217\217\350\277\260.txt"
+++ "b/VisitFace/document/erdb api\346\216\245\345\217\243\346\217\217\350\277\260.txt"
@@ -29,27 +29,70 @@
 	}
 ]
 
+enum StatusID
+{
+鏅�氳瀹�
+榛戝悕鍗�
+鏁欏笀
+瀛︾敓
+棰嗗骞查儴
+}
 select ID, distinct label from VisitorType where RegisterCompanyID = 0 or RegisterCompanyID = "$companyID"
 
 1.2. ImageTypeID
+Request:
+{
+}
+Response:
+[
+	{
+		ID : "label"
+	}
+]
 
 enum ImageTypeID
 {
-	Face = 1,  // 鐓х墖
-	FaceUploaded = 2, // 涓婁紶鐓х墖
-	Icon, // 鍥炬爣
-	
-	
+	Face1 = 1,  // 姝i潰鐓х墖1锛堜氦缁欎汉鑴歌瘑鍒湇鍔★級
+	Face2 = 2,  // 姝i潰鐓х墖2锛堝瓨鏀惧埌FaceImage琛級
+	FaceLSide,  // 锛堜富浣撹瑙掞紝<=45搴︼級宸︿晶鑴哥収鐗囷紙瀛樻斁鍒癋aceImage琛級
+	FaceRSide,  // 锛堜富浣撹瑙掞紝<=45搴︼級鍙充晶鑴哥収鐗囷紙瀛樻斁鍒癋aceImage琛級
+	FaceTSide,  // 锛堜富浣撹瑙掞紝<=45搴︼級椤朵晶鑴哥収鐗囷紙瀛樻斁鍒癋aceImage琛級
+	FaceBSide,  // 锛堜富浣撹瑙掞紝<=45搴︼級搴曚晶鑴哥収鐗囷紙瀛樻斁鍒癋aceImage琛級
+	FaceUploaded, // 涓婁紶鐓х墖锛堝瓨鏀惧埌FaceImage琛級
+	Icon, // 鍥炬爣锛堝瓨鏀惧埌Image琛級
+	IdentificationCard, // 韬唤璇佺収鐗囷紙瀛樻斁鍒癐mage琛級
+	BusinessCard, // 鍚嶇墖鐓х墖锛堝瓨鏀惧埌Image琛級
+	OtherCard, // 鍏朵粬璇佷欢锛堝瓨鏀惧埌Image琛級
 }
 
 1.2. StatusID
+Request:
+{
+}
+Response:
+[
+	{
+		ID : "label"
+	}
+]
+
+enum StatusID
+{
+鏈敞鍐�
+宸叉敞鍐岋紙璁垮锛�
+鏉ヨ鐧昏锛堣瀹級
+绛剧锛堣瀹級
+绛惧埌锛堝憳宸ワ級
+绛鹃��锛堝憳宸ワ級
+}
+
 
 1.3. 浜鸿劯璇嗗埆
 閫氳繃鍥惧儚鑾峰緱faceID
 Request:
 {
 	registerCompanyID : 123, // 鑻ヤ负-1鍒欏彧鎼滅储VisitFaceDB
-	imgs : [ "image base64" ] // 瀵瑰簲澶氫釜浜虹殑浜鸿劯鍥惧儚
+	imgs : [ "image base64" ] // 瀵瑰簲澶氫釜浜虹殑浜鸿劯鍥惧儚 # 浣跨敤http form post
 }
 Response:
 [
@@ -57,16 +100,33 @@
 		registerCompanyID : 123, //鎵句笉鍒拌繑鍥濾isitDBFaceID锛屾椤逛负-1
 		faceID : 1,
 		isVisitDBFaceID : false, // <dbid=-1, faceid!=-1> : true, <dbid!=-1, faceid!=-1> : false
-		srcImgIdx : 1,
-		srcImgPosX : 123,
-		srcImgPosY : 456,
-		srcImgPosW : 123,
-		srcImgPosH : 456
+		imgUrl : "",
+		imgType : ""
 	},
 	{
 		faceID : -1, // 鎼滅储鏃犵粨鏋� <dbid=-1, faceid=-1>
 	}
 ]
+
+a)鎺ユ敹imgs浜岃繘鍒舵暟鎹�
+b)杞彂鍒颁汉鑴歌瘑鍒湇鍔�(registerCompanyID, imgs)
+c)鎺ユ敹璇嗗埆缁撴灉锛�<dbid, faceid>锛屽叾涓�<(<0),0>琛ㄧず鏈壘鍒扮粨鏋滐紝<(<0),N>琛ㄧず鍦ㄨ瀹㈡暟鎹簱涓壘鍒颁汉鑴革紝<N,M>琛ㄧず鍦∟鍏徃涓尮閰嶄汉鑴窶
+d) 瀵逛簬鍗曚釜浜鸿劯缁撴灉锛�
+  if <0,0>
+  {
+	// 鎼滅储鏃犵粨鏋�
+  }
+  else if (dbid < 0 && faceid != 0)
+  { // 璁垮
+	// select PersonID from FaceImage where RegisterCompanyID="$dbid" and faceid="$faceid";
+	// select * from Person where PersonID="$PersonID"
+  }
+  else if (dbid > 0 && faceid != 0)
+  { // 鍛樺伐
+  	// select * from FaceImage where RegisterCompanyID="$dbid" and faceid="$faceid";
+	// select * from Person where PersonID="$PersonID"
+  }
+  
 
 1.4. 浜鸿劯鎬讳綋淇℃伅鏌ヨ
 閫氳繃faceID鑾峰緱Person绠�瑕佷俊鎭�
@@ -106,7 +166,7 @@
 Request:
 {
 	placeID : 123, // 鑻ヤ负-1鍒欏彧鎼滅储VisitFaceDB
-	visitStatusID : 1 // 绛惧埌銆佺閫�/绛剧
+	enterOrExit : 1 // 绛惧埌銆佺閫�/绛剧
 	imgs : [ "image base64" ] // 瀵瑰簲澶氫釜浜虹殑浜鸿劯鍥惧儚
 }
 Response:
@@ -122,6 +182,49 @@
 		//涓氬姟閿欒锛� 9.1. 閫氱敤鎴愬姛/閿欒缁撴灉
 	}
 ]
+
+
+鍙傝��1.3. a)b)c)d)
+e) 瀵逛簬鍗曚釜浜鸿劯缁撴灉锛�
+   // "$person.id"
+   select CompanyID from Place where placeID="$placeID"
+   isChecking = select * CheckingCompany where CompanyID = "$CompanyID" and PersonID="$PersonID"
+   if (enterOrExit == 绛惧埌) // 鍏ュ彛鎽勫儚澶�
+   {
+	 if (isChecking)
+		checking(PersonID, placeID);
+		return person current status
+	 else
+	    return person status not changed;
+   }
+   else if (enterOrExit == 绛鹃��/绛剧) // 鍑哄彛鎽勫儚澶�
+   {
+	 if (isChecking)
+		unchecking(PersonID, placeID);
+		return person current status
+	 else
+	    unvisit(PersonID, placeID);
+		return person current status
+   }
+   
+   checking:
+   noNeedInsertNewRecord = select * from Checking where StatusID = "$NewStatusID" and statusDt + 5second > now() and PersonID = "$PersonID" and PlaceID="$PlaceID"
+   if (!noNeedInsertNewRecord)
+   {
+	insert into Checking(...);
+   }
+   
+   unvisit
+   noNeedInsertNewRecord = ...
+   if (!noNeedInsertNewRecord)
+   {
+    // get last visit event
+    select * from Visit where VisitorPersonID="$PersonID" and CompanyID="$CompanyID" order by startTime desc limit 1
+	
+    insert into Visiting
+	update Visit LastStatusID, lastTime
+   }
+
 
 1.7. 鏌ヨ浜哄憳鏉ヨ/绛惧埌鐘舵��
 闇�瑕佹敮鎸佹壒閲忔煡璇�
@@ -148,7 +251,6 @@
 	name : "",
 	companyName : "",
 	// ...
-	imgIdentity : "image base64"
 }
 Response:
 {
@@ -156,24 +258,37 @@
 	personID : 123
 }
 
-2.4. 娉ㄥ唽浜鸿劯
+a) find by name, (IdentityTypeID, identity), phone ... from Person
+b) if Person exists return error
+c) else insert into Person
+d) companyID = (select * from or insert Company where name = "$companyName")
+e) department_id , Post_id
+f)
+
+2.4. 娉ㄥ唽璁垮浜鸿劯(visit face register)
 Request:
 {
 	registerCompanyID : 123,
 	personID : 123,
-	imgs : [ "image base64" ] // 瀵瑰簲涓�涓汉鐨勮嫢骞蹭釜浜鸿劯鍥惧儚
+	imgs : { ImageTypeID : "image base64" } // 瀵瑰簲涓�涓汉鐨勮嫢骞蹭釜浜鸿劯鍥惧儚
 }
 Response:
 {
 	faceIDs : [ 123 ]
 }
 
+a)select exists(*) from person where id="$personID"
+b)if not exists return error
+c)鏍规嵁image type淇濆瓨鍥剧墖
+d)璋冪敤浜鸿劯璇嗗埆鏈嶅姟[faceids]=(registerCompanyID, dbid=-1, img)
+e)瀵逛簬姣忎竴涓猣aceid锛宨nsert into VisitFace ("$FaceID", $PersonID, "$VisitFace.imagePath")
+
 3. 鏉ヨ鐧昏
 3.1. 鑾峰緱鏉ヨ浜哄憳鍒楄〃
 杩斿洖鎸夊鍚嶇缉鍐欏崌搴忕殑缁撴灉
 Request:
 {
-	companyID : 123, // 璁惧鎵�鍦ㄥ鏍D
+	companyID : 123, // 璁惧鎵�鍦ㄥ鏍D锛�0琛ㄧず鎵�鏈夊叕鍙革紝浠呬緵绠$悊鎺ュ彛浣跨敤
 	beginPage : 0,
 	endPage : 0
 }
@@ -181,10 +296,19 @@
 [
 	{
 		personID : 123,
+		RegisterCompanyID : 123,
 		name : "aaa",
 		img : "image url" // 闈炲瓧绗︿覆琛ㄧず浣跨敤榛樿鍥炬爣
 	}
 ]
+
+set @companyID =1;
+select vs.person_id, vs.register_company_id, pe.name, img.image_type, img.image_path
+  from visit_stat vs join person pe
+  on (@companyID=0 or vs.register_company_id = @companyID) and (vs.person_id = pe.id)
+  left outer join Image img
+  on (pe.id = img.person_id and img.image_type=8) -- icon
+  limit ...
 
 3.2. 鑾峰緱琚浜哄憳鍒楄〃
 杩斿洖鎸夊鍚嶇缉鍐欏崌搴忕殑缁撴灉
@@ -204,6 +328,9 @@
 	}
 ]
 
+set @companyID =1;
+select * from person pe where pe.company_id = @companyID
+
 3.2. 鎼滅储
 (3. 4. 5. 6.)
 鏉ヨ浜哄憳锛屽鏋滄病鏈夌粰鍑烘悳绱㈠瓧娈垫椂锛屾樉绀烘湰鏍℃浘缁忔潵璁夸汉鍛樺垪琛╒isitStat锛涘鏋滅粰鍑哄叧閿瓧锛屽垯鎼滅储鍏ㄩ儴浜哄憳
@@ -221,6 +348,15 @@
 }
 
 #todo 琚鑰冭檻鍜屼汉鍛樺垪琛ㄥ悎骞�
+
+if isVisitor
+	select * 
+	  from visit_stat vs left outer join person pe
+	  on vs.person_id = person.id
+	  where vs.register_company_id = "$registerCompanyID" and pe.name_spell like "$nameSpell%"
+else
+	select * from  person
+	where CompanyID = "$registerCompanyID" and name_spell like "$nameSpell%"
 
 3.3. 鑾峰緱鏉ヨ/琚浜哄憳璇︾粏淇℃伅锛坴isitor/visitee锛�
 Request:
@@ -250,6 +386,8 @@
 Response:
 鎴愬姛/閿欒缁撴灉
 
+insert or update VisitStat
+
 3.5. 鑾峰緱鎷滆浜嬬敱閫夐」鍒楄〃
 Request:
 {

--
Gitblit v1.8.0