|
|
@@ -62,7 +62,7 @@ type Req struct { |
|
|
|
} |
|
|
|
|
|
|
|
func RegStaff(param Req) (*common.Response, error) { |
|
|
|
url := common.ConfigData.PushDataUrl |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.PushDataUrl |
|
|
|
common.Info(common.GenLogLine()+"reg staff url:%s\n", url) |
|
|
|
method := "POST" |
|
|
|
|
|
|
@@ -110,12 +110,15 @@ func RegStaff(param Req) (*common.Response, error) { |
|
|
|
fmt.Println("Error:", err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
if response.Code != 200 || response.Code != 0 { |
|
|
|
return response, errors.New(response.Msg) |
|
|
|
} |
|
|
|
common.Error(common.GenLogLine()+"reg result %s", string(body)) |
|
|
|
return response, nil |
|
|
|
} |
|
|
|
|
|
|
|
func RegOnlineStaff(param Req) error { |
|
|
|
url := common.ConfigData.PushDataUrl |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.PushDataUrl |
|
|
|
fmt.Printf("url:%s\n", url) |
|
|
|
method := "POST" |
|
|
|
|
|
|
@@ -154,27 +157,39 @@ func RegOnlineStaff(param Req) error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func HandleStaff(emp Req) error { |
|
|
|
func HandleStaff(emp Req) (*common.Response, error) { |
|
|
|
if emp.StaffBase64Img != "" { |
|
|
|
//feature = FetchStaffFaceFeature(emp.StaffBase64Img) |
|
|
|
//emp.FaceFeature = LocalFetchStaffFaceFeature(emp.StaffBase64Img) |
|
|
|
} |
|
|
|
var sType int |
|
|
|
if emp.StaffType > 70 { |
|
|
|
sType = 4 |
|
|
|
} else { |
|
|
|
sType = 5 |
|
|
|
|
|
|
|
if common.ConfigData.Mode != "online" { |
|
|
|
emp.StaffBase64Img = "" |
|
|
|
} |
|
|
|
emp.StaffType = sType |
|
|
|
var sDels = []int{5, 6, 7, 8} |
|
|
|
if common.AryContainInt(sDels, emp.DelFlag) { |
|
|
|
emp.DelFlag = 1 |
|
|
|
} else { |
|
|
|
emp.DelFlag = 0 |
|
|
|
|
|
|
|
//======东方微银逻辑======start==== |
|
|
|
if strings.Contains(common.ConfigData.EnterpriseName, "东方微银") { |
|
|
|
var sType int |
|
|
|
if emp.StaffType > 70 { |
|
|
|
sType = 4 |
|
|
|
} else { |
|
|
|
sType = 5 |
|
|
|
} |
|
|
|
emp.StaffType = sType |
|
|
|
var sDels = []int{5, 6, 7, 8} |
|
|
|
if common.AryContainInt(sDels, emp.DelFlag) { |
|
|
|
emp.DelFlag = 1 |
|
|
|
} else { |
|
|
|
emp.DelFlag = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
//======东方微银逻辑======end==== |
|
|
|
|
|
|
|
RegStaff(emp) |
|
|
|
return nil |
|
|
|
resp, err := RegStaff(emp) |
|
|
|
if err != nil { |
|
|
|
return resp, err |
|
|
|
} |
|
|
|
return resp, nil |
|
|
|
} |
|
|
|
|
|
|
|
// Fetch2 获取员工信息,模拟获取saas的人员数据 |
|
|
@@ -260,7 +275,7 @@ func Fetch2() []Staff { |
|
|
|
// AbleSendCode 发送验证码 |
|
|
|
func AbleSendCode(phone string) string { |
|
|
|
|
|
|
|
url := common.ConfigData.CheckSendCodeUrl + "/" + phone |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.CheckSendCodeUrl + "/" + phone |
|
|
|
method := "GET" |
|
|
|
|
|
|
|
payload := strings.NewReader("") |
|
|
@@ -297,7 +312,7 @@ func SendCode(phone string) string { |
|
|
|
|
|
|
|
ableSend := AbleSendCode(phone) |
|
|
|
fmt.Println("ableSend:", ableSend) |
|
|
|
url := common.ConfigData.SendCodeUrl |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.SendCodeUrl |
|
|
|
method := "POST" |
|
|
|
|
|
|
|
payload := strings.NewReader(`{ |
|
|
@@ -341,7 +356,7 @@ func SendCode(phone string) string { |
|
|
|
func ValidCode(phone string, code string) (string, error) { |
|
|
|
ableSend := AbleSendCode(phone) |
|
|
|
fmt.Println("ableSend:", ableSend) |
|
|
|
url := common.ConfigData.ValidCodeUrl + phone + "/" + code |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.ValidCodeUrl + phone + "/" + code |
|
|
|
method := "GET" |
|
|
|
|
|
|
|
payload := strings.NewReader(``) |
|
|
@@ -371,7 +386,7 @@ func ValidCode(phone string, code string) (string, error) { |
|
|
|
|
|
|
|
func StaffInfo(staffId string) (map[string]interface{}, error) { |
|
|
|
fmt.Println("staffId:", staffId) |
|
|
|
url := common.ConfigData.StaffInfoUrl |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.StaffInfoUrl |
|
|
|
method := "GET" |
|
|
|
token, err := common.GetToken() |
|
|
|
if err != nil { |
|
|
@@ -431,7 +446,7 @@ func StaffInfo(staffId string) (map[string]interface{}, error) { |
|
|
|
} |
|
|
|
|
|
|
|
func MgrLogin(userName string, password string) string { |
|
|
|
url := common.ConfigData.MgrLoginUrl |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.MgrLoginUrl |
|
|
|
fmt.Println("url:", url) |
|
|
|
enterpriseName := common.ConfigData.EnterpriseName |
|
|
|
method := "POST" |
|
|
@@ -471,7 +486,7 @@ func MgrLogin(userName string, password string) string { |
|
|
|
} |
|
|
|
|
|
|
|
func PhoneLogin(phone string) (map[string]interface{}, error) { |
|
|
|
url := common.ConfigData.PhoneLoginUrl |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.PhoneLoginUrl |
|
|
|
method := "POST" |
|
|
|
|
|
|
|
payload := strings.NewReader(`{ |
|
|
@@ -632,7 +647,7 @@ func FetchStaffImage(ygbh string) string { |
|
|
|
fmt.Println("Error:", err) |
|
|
|
} |
|
|
|
|
|
|
|
var result string = "" |
|
|
|
var result = "" |
|
|
|
|
|
|
|
for _, item := range response.Data { |
|
|
|
var s string |
|
|
@@ -645,8 +660,8 @@ func FetchStaffImage(ygbh string) string { |
|
|
|
return strings.Replace(result, "\n", "", -1) |
|
|
|
} |
|
|
|
|
|
|
|
func FetchStaffFaceFeature(base64 string) string { |
|
|
|
url := "http://39.105.51.226:5000/cv/feature-extraction-service/1.7" |
|
|
|
func FetchStaffFaceFeature(base64 string) (string, error) { |
|
|
|
url := "http://" + common.ConfigData.ServerIp + ":8080/" + common.ConfigData.FaceDetectUrl |
|
|
|
method := "POST" |
|
|
|
|
|
|
|
err := common.SaveBase64ImageToFile(base64, "images/"+fmt.Sprintf("%d", time.Now().Unix())+"test.jpg") |
|
|
@@ -662,7 +677,7 @@ func FetchStaffFaceFeature(base64 string) string { |
|
|
|
if err != nil { |
|
|
|
fmt.Errorf(common.GenLogLine()+"%s", err) |
|
|
|
common.Error(common.GenLogLine()+"%s", err) |
|
|
|
return "" |
|
|
|
return "", err |
|
|
|
} |
|
|
|
req.Header.Add("Authorization", "Bearer ") |
|
|
|
req.Header.Add("Content-Type", "application/json") |
|
|
@@ -671,7 +686,7 @@ func FetchStaffFaceFeature(base64 string) string { |
|
|
|
if err != nil { |
|
|
|
fmt.Errorf(common.GenLogLine()+"%s", err) |
|
|
|
common.Error(common.GenLogLine()+"%s", err) |
|
|
|
return "" |
|
|
|
return "", err |
|
|
|
} |
|
|
|
defer res.Body.Close() |
|
|
|
|
|
|
@@ -679,7 +694,7 @@ func FetchStaffFaceFeature(base64 string) string { |
|
|
|
if err != nil { |
|
|
|
fmt.Errorf(common.GenLogLine()+"%s", err) |
|
|
|
common.Error(common.GenLogLine()+"%s", err) |
|
|
|
return "" |
|
|
|
return "", err |
|
|
|
} |
|
|
|
fmt.Println(string(body)) |
|
|
|
|
|
|
@@ -687,12 +702,16 @@ func FetchStaffFaceFeature(base64 string) string { |
|
|
|
err = json.Unmarshal([]byte(string(body)), &response) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("Error:", err) |
|
|
|
return "", err |
|
|
|
} |
|
|
|
|
|
|
|
var result string |
|
|
|
result, err = extractFeature(response.Result[0]) |
|
|
|
if err != nil { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
fmt.Printf(" success data : %+v\n", result) |
|
|
|
return result |
|
|
|
return result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func extractFeature(data interface{}) (string, error) { |
|
|
@@ -768,6 +787,7 @@ func LocalFetchStaffFaceFeature(base64 string) (string, string, error) { |
|
|
|
faces, ok := response["data"].(map[string]interface{}) |
|
|
|
if !ok { |
|
|
|
fmt.Errorf("No faces found") |
|
|
|
return "", imgName, errors.New("No faces found") |
|
|
|
} |
|
|
|
|
|
|
|
feature, ok1 := faces["faceData"].(map[string]interface{})["theFeature"].([]interface{}) |
|
|
@@ -861,7 +881,7 @@ func TimerHandle() { |
|
|
|
if t3.After(t1) { |
|
|
|
staff.StaffBase64Img = FetchStaffImage(staff.Code) |
|
|
|
common.Info(common.GenLogLine()+"----%v", "" == staff.StaffBase64Img) |
|
|
|
str := HandleStaff(staff) |
|
|
|
_, str := HandleStaff(staff) |
|
|
|
common.Info(common.GenLogLine()+"--2.2注册人员 姓名:%s 编号:%s 更新时间:%s--\n", staff.StaffName, staff.Code, staff.Modified) |
|
|
|
//str := RegOnlineStaff(staff) |
|
|
|
ss := "" |
|
|
@@ -892,7 +912,8 @@ func EmpToReq(emp mydatabase.Emp) Req { |
|
|
|
req.StaffName = emp.Name |
|
|
|
req.StaffType = 5 //普通员工 |
|
|
|
req.Phone = emp.Phone |
|
|
|
req.StaffBase64Img = emp.Avatar |
|
|
|
str, _ := common.FileToBase64(emp.Avatar) |
|
|
|
req.StaffBase64Img = str |
|
|
|
req.FaceFeature = emp.Features |
|
|
|
return req |
|
|
|
} |