添加头像到百度

This commit is contained in:
2025-07-27 20:00:48 +08:00
parent 63eb85a30f
commit d46c8bddbe
8 changed files with 534 additions and 34 deletions
@@ -85,6 +85,16 @@
</f:Image>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:FileUpload ID="filePhoto1" runat="server" ButtonText="上传头像到百度" ButtonOnly="true"
AutoPostBack="true" OnFileSelected="filePhoto1_FileSelected">
</f:FileUpload>
<f:Image ID="imgPhoto1" CssClass="userphoto" runat="server" BoxFlex="1" MarginLeft="10px">
</f:Image>
</Items>
</f:FormRow>
</Rows>
<Toolbars>
<f:Toolbar ID="Toolbar1" Position="Top" runat="server" ToolbarAlign="Right">
@@ -1,13 +1,18 @@
namespace FineUIPro.Web.common.WelderManage
{
using System;
using System.Drawing;
using BLL;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SgManager.AI;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using ThoughtWorks.QRCode.Codec;
using ThoughtWorks.QRCode.Codec.Data;
using System.Text;
using System.IO;
public partial class WelderSave : PageBase
{
@@ -225,6 +230,8 @@
welder.ProjectId = this.CurrUser.LoginProjectId;
welder.AttachUrl = this.AttachUrl;
welder.SignatureUrl = imgPhoto.ImageUrl;
welder.PhotoUrl = imgPhoto1.ImageUrl;
welder.IsOAM = true;
if (string.IsNullOrEmpty(this.WED_ID))
{
@@ -237,9 +244,125 @@
BLL.HJGL_PersonManageService.UpdateBSWelder(welder);
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改人员信息!");
}
if (!string.IsNullOrEmpty(welder.PhotoUrl) )
{
Alert.ShowInParent(PersonFace(welder), MessageBoxIcon.Warning);
}
}
#endregion
public static string PersonFace(Model.HJGL_BS_Welder person)
{
string message = string.Empty;
string filePath = ConfigurationManager.AppSettings["localRoot"] + person.PhotoUrl;
List<SgManager.AI.faceResult> kqFace = null;
try
{
kqFace = (List<SgManager.AI.faceResult>)SgManager.AI.FaceClass.SearchFileFace(filePath);
if (kqFace != null || kqFace.Count > 0 || kqFace[0].errMess == "SUCCESS")
{
string result = FaceClass.FaceVerify(filePath);
JObject jresult = JObject.Parse(result);
JObject lvresult = jresult.Value<JObject>("result");
bool isOK = false;
if (jresult.Value<int>("error_code") == 0)
{
if (lvresult.Value<double>("face_liveness") >= ConfigAppSetting.getConfigAppSetting("BD_face_liveness") ? true : false)//99.5%//活体度
{
if (Convert.ToDouble(lvresult["face_list"][0]["location"]["width"]) > ConfigAppSetting.getConfigAppSetting("BD_width") ? true : false)
{
if (Convert.ToDouble(lvresult["face_list"][0]["location"]["height"]) > ConfigAppSetting.getConfigAppSetting("BD_height") ? true : false)
{
if (System.Math.Abs(Convert.ToDouble(lvresult["face_list"][0]["angle"]["roll"])) <= ConfigAppSetting.getConfigAppSetting("BD_roll") ? true : false)//角度正负度数
{
if (System.Math.Abs(Convert.ToDouble(lvresult["face_list"][0]["angle"]["yaw"])) <= ConfigAppSetting.getConfigAppSetting("BD_roll") + 1 ? true : false)//角度正负度数
{
if (System.Math.Abs(Convert.ToDouble(lvresult["face_list"][0]["angle"]["pitch"])) <= ConfigAppSetting.getConfigAppSetting("BD_roll") + 1 ? true : false)//角度正负度数
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["occlusion"]["left_eye"]) <= ConfigAppSetting.getConfigAppSetting("BD_occlusion") ? true : false)// 0为无遮挡,1是完全遮挡
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["occlusion"]["right_eye"]) <= ConfigAppSetting.getConfigAppSetting("BD_occlusion") ? true : false)// 0为无遮挡,1是完全遮挡
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["occlusion"]["nose"]) <= ConfigAppSetting.getConfigAppSetting("BD_occlusion") ? true : false)// 0为无遮挡,1是完全遮挡
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["occlusion"]["mouth"]) <= ConfigAppSetting.getConfigAppSetting("BD_occlusion") ? true : false)// 0为无遮挡,1是完全遮挡
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["occlusion"]["left_cheek"]) <= ConfigAppSetting.getConfigAppSetting("BD_occlusion") ? true : false)// 0为无遮挡,1是完全遮挡
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["occlusion"]["right_cheek"]) <= ConfigAppSetting.getConfigAppSetting("BD_occlusion") ? true : false)// 0为无遮挡,1是完全遮挡
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["occlusion"]["chin_contour"]) <= ConfigAppSetting.getConfigAppSetting("BD_occlusion") ? true : false)// 0为无遮挡,1是完全遮挡
{
if (Convert.ToDouble(lvresult["face_list"][0]["quality"]["blur"]) <= ConfigAppSetting.getConfigAppSetting("BD_blur") ? true : false)//模糊度,0---1,小于0.7
{ isOK = true; }
else message = "清晰度检测失败"; ;
}
else message = "遮挡检测失败";
}
else message = "遮挡检测失败";
}
else message = "遮挡检测失败";
}
else message = "遮挡检测失败";
}
else message = "遮挡检测失败";
}
else message = "遮挡检测失败";
}
else message = "遮挡检测失败";
}
else message = "角度检测失败";
}
else message = "角度检测失败";
}
else message = "角度检测失败";
}
else message = "宽高检测失败";
}
else message = "宽高检测失败";
}
else message = "人脸动态检测失败";
}
else message = "识别不到人脸";
if (isOK)
{
var faceResult = FaceClass.add(person.WED_ID, person.IdentityCard, System.Configuration.ConfigurationManager.AppSettings["CEMS_IMG_URL"].ToString() + person.PhotoUrl, AccessToken.getAccessToken());
var face = JsonConvert.DeserializeObject<dynamic>(faceResult);
// JsonConvert.DeserializeObject<dynamic>(myPunishItem);
if (face.error_code == 0 || face.error_code == 223105)
{
message = "人脸库注册成功!";
// face_token = face.result.face_token;
//APIPersonService.SaveSitePerson(person);
}
else
{
message = "注册人脸库失败" + face.error_code + face.error_msg;
}
}
else
{
message += "注册人脸库失败";
}
}
}
catch (Exception ex)
{
message = "注册人脸库失败";
ErrLogInfo.WriteLog(ex, "PC-人员信息保存", "SitePerson.PersonListEdit");
}
return message;
}
#region
/// <summary>
/// 上传照片
@@ -264,6 +387,27 @@
filePhoto.Reset();
}
}
protected void filePhoto1_FileSelected(object sender, EventArgs e)
{
if (filePhoto1.HasFile)
{
string fileName = filePhoto1.ShortFileName;
if (!ValidateFileType(fileName))
{
ShowNotify("无效的文件类型!");
return;
}
fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
fileName = DateTime.Now.Ticks.ToString() + "_" + fileName;
filePhoto1.SaveAs(Server.MapPath("~/upload/" + fileName));
imgPhoto1.ImageUrl = "~/upload/" + fileName;
// 清空文件上传组件
filePhoto1.Reset();
}
}
#endregion
//protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
//{
@@ -7,11 +7,13 @@
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.common.WelderManage {
public partial class WelderSave {
namespace FineUIPro.Web.common.WelderManage
{
public partial class WelderSave
{
/// <summary>
/// form1 控件。
/// </summary>
@@ -20,7 +22,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 控件。
/// </summary>
@@ -29,7 +31,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// SimpleForm1 控件。
/// </summary>
@@ -38,7 +40,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Form SimpleForm1;
/// <summary>
/// drpUnit 控件。
/// </summary>
@@ -47,7 +49,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DropDownList drpUnit;
/// <summary>
/// txtRecordDate 控件。
/// </summary>
@@ -56,7 +58,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DatePicker txtRecordDate;
/// <summary>
/// txtName 控件。
/// </summary>
@@ -65,7 +67,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtName;
/// <summary>
/// txtCode 控件。
/// </summary>
@@ -74,7 +76,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtCode;
/// <summary>
/// txtBirthday 控件。
/// </summary>
@@ -83,7 +85,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DatePicker txtBirthday;
/// <summary>
/// drpSex 控件。
/// </summary>
@@ -92,7 +94,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.RadioButtonList drpSex;
/// <summary>
/// txtWorkCode 控件。
/// </summary>
@@ -101,7 +103,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtWorkCode;
/// <summary>
/// txtLimitDate 控件。
/// </summary>
@@ -110,7 +112,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DatePicker txtLimitDate;
/// <summary>
/// txtClass 控件。
/// </summary>
@@ -119,7 +121,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtClass;
/// <summary>
/// drpIfOnGuard 控件。
/// </summary>
@@ -128,7 +130,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.CheckBox drpIfOnGuard;
/// <summary>
/// txtIdentityCard 控件。
/// </summary>
@@ -137,7 +139,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtIdentityCard;
/// <summary>
/// btnQR 控件。
/// </summary>
@@ -146,7 +148,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnQR;
/// <summary>
/// btnSee 控件。
/// </summary>
@@ -155,7 +157,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnSee;
/// <summary>
/// txtRemark 控件。
/// </summary>
@@ -164,7 +166,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextArea txtRemark;
/// <summary>
/// filePhoto 控件。
/// </summary>
@@ -173,7 +175,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.FileUpload filePhoto;
/// <summary>
/// imgPhoto 控件。
/// </summary>
@@ -182,7 +184,25 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Image imgPhoto;
/// <summary>
/// filePhoto1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.FileUpload filePhoto1;
/// <summary>
/// imgPhoto1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Image imgPhoto1;
/// <summary>
/// Toolbar1 控件。
/// </summary>
@@ -191,7 +211,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar1;
/// <summary>
/// lbWelderRead 控件。
/// </summary>
@@ -200,7 +220,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button lbWelderRead;
/// <summary>
/// btnWelderFaceRead 控件。
/// </summary>
@@ -209,7 +229,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnWelderFaceRead;
/// <summary>
/// btnSave 控件。
/// </summary>
@@ -218,7 +238,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnSave;
/// <summary>
/// Window1 控件。
/// </summary>
@@ -227,7 +247,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window1;
/// <summary>
/// Window2 控件。
/// </summary>
@@ -236,7 +256,7 @@ namespace FineUIPro.Web.common.WelderManage {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window2;
/// <summary>
/// Window3 控件。
/// </summary>