fix:修改
This commit is contained in:
@@ -7,6 +7,10 @@ using SgManager.AI;
|
||||
using System.Configuration;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
{
|
||||
@@ -1005,5 +1009,262 @@ namespace WebAPI.Controllers
|
||||
// return responeData;
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 身份证上传+读取
|
||||
/// <summary>
|
||||
/// 身份证上传+读取
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData PostAddUrl()
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
HttpFileCollection files = HttpContext.Current.Request.Files;
|
||||
string typeName = HttpContext.Current.Request["typeName"];
|
||||
if (string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
typeName = "WebApi";
|
||||
}
|
||||
|
||||
// 定义允许上传的文件类型列表
|
||||
List<string> allowExtensions = BLL.Funs.AllowExtensions;
|
||||
string reUrl = string.Empty;
|
||||
if (files != null && files.Count > 0)
|
||||
{
|
||||
string folderUrl = "FileUpLoad/" + typeName + "/" + DateTime.Now.ToString("yyyy-MM") + "/";
|
||||
string localRoot = ConfigurationManager.AppSettings["localRoot"] + folderUrl; //物理路径
|
||||
if (!Directory.Exists(localRoot))
|
||||
{
|
||||
Directory.CreateDirectory(localRoot);
|
||||
}
|
||||
|
||||
foreach (string key in files.AllKeys)
|
||||
{
|
||||
string rootUrl = string.Empty;
|
||||
string fileName = string.Empty;
|
||||
string extensionstr = string.Empty;
|
||||
HttpPostedFile file = files[key]; //file.ContentLength文件长度
|
||||
if (!allowExtensions.Contains(Path.GetExtension(file.FileName)))
|
||||
{
|
||||
responeData.data = BadRequest($"Invalid file extension: {file.FileName}");
|
||||
return responeData;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(file.FileName))
|
||||
{
|
||||
extensionstr = Path.GetExtension(file.FileName).ToLower();
|
||||
fileName = SQLHelper.GetNewID() + extensionstr;
|
||||
rootUrl = localRoot + fileName;
|
||||
file.SaveAs(localRoot + fileName);
|
||||
}
|
||||
|
||||
if (extensionstr == ".jpg" || extensionstr == ".gif" || extensionstr == ".bmp" ||
|
||||
extensionstr == ".png")
|
||||
{
|
||||
string TakePicDateTime = string.Empty;
|
||||
System.Drawing.Image image = System.Drawing.Image.FromStream(file.InputStream, true, false);
|
||||
Encoding ascii = Encoding.ASCII;
|
||||
//遍历图像文件元数据,检索所有属性
|
||||
foreach (System.Drawing.Imaging.PropertyItem p in image.PropertyItems)
|
||||
{
|
||||
//如果是PropertyTagDateTime,则返回该属性所对应的值
|
||||
if (p.Id == 0x0132)
|
||||
{
|
||||
TakePicDateTime = ascii.GetString(p.Value);
|
||||
}
|
||||
}
|
||||
|
||||
TakePicDateTime = string.IsNullOrEmpty(TakePicDateTime)
|
||||
? string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now)
|
||||
: TakePicDateTime;
|
||||
if (!string.IsNullOrEmpty(TakePicDateTime))
|
||||
{
|
||||
////获取元数据中的拍照日期时间,以字符串形式保存
|
||||
//TakePicDateTime = GetTakePicDateTime(pi);
|
||||
//分析字符串分别保存拍照日期和时间的标准格式
|
||||
var SpaceLocation = TakePicDateTime.IndexOf(" ");
|
||||
var dt = TakePicDateTime.Substring(0, SpaceLocation);
|
||||
dt = dt.Replace(":", "-");
|
||||
var tm = TakePicDateTime.Substring(SpaceLocation + 1,
|
||||
TakePicDateTime.Length - SpaceLocation - 2);
|
||||
TakePicDateTime = dt + " " + tm;
|
||||
//由列表中的文件创建内存位图对象
|
||||
var Pic = new Bitmap(rootUrl);
|
||||
//由位图对象创建Graphics对象的实例
|
||||
var g = Graphics.FromImage(Pic);
|
||||
Font ft = new Font("宋体", 20, FontStyle.Regular, GraphicsUnit.Point,
|
||||
((byte)(134))); //定义字体
|
||||
//在Graphics表面绘制数码照片的日期/时间戳
|
||||
g.DrawString(TakePicDateTime, ft, Brushes.Gold, 0, Pic.Height - 100);
|
||||
// - 50);
|
||||
string newRoot = localRoot + "newfile/";
|
||||
if (!Directory.Exists(newRoot))
|
||||
{
|
||||
Directory.CreateDirectory(newRoot);
|
||||
}
|
||||
|
||||
//将添加日期/时间戳后的图像进行保存
|
||||
Pic.Save(newRoot + fileName);
|
||||
fileName = "newfile/" + fileName;
|
||||
//释放内存位图对象
|
||||
Pic.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
if (string.IsNullOrEmpty(reUrl))
|
||||
{
|
||||
reUrl += folderUrl + fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
reUrl += "," + folderUrl + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string url = Request.RequestUri.Scheme + "://" + Request.RequestUri.Host + ":" +
|
||||
Request.RequestUri.Port +
|
||||
"/JT/" + reUrl;
|
||||
|
||||
responeData.data = new {IDCard = APIIDCardInfoService.ReadIDCardInfo(url), IDCardUrl = reUrl,URL=url};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 小程序保存人员信息
|
||||
/// <summary>
|
||||
/// 小程序保存人员信息
|
||||
/// </summary>
|
||||
/// <param name="person">人员信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Model.ResponeData SavePerson([FromBody] Model.PersonItem person)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
if (person != null && !string.IsNullOrEmpty(person.IdentityCard))
|
||||
{
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == person.IdentityCard.Trim() && x.ProjectId == person.ProjectId);
|
||||
if (getPerson != null)
|
||||
{
|
||||
responeData.code = -1;
|
||||
responeData.message = "该身份证号码已存在两条记录,请联系管理员处理!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
|
||||
{
|
||||
PersonId = SQLHelper.GetNewID(),
|
||||
ProjectId = person.ProjectId,
|
||||
UnitId = person.UnitId,
|
||||
PersonName = person.PersonName,
|
||||
Sex = person.Sex ,
|
||||
IdentityCard = person.IdentityCard,
|
||||
Telephone = person.Telephone,
|
||||
WorkPostId = person.WorkPostId,
|
||||
IsUsedType = "2",
|
||||
IsUsed = true,
|
||||
IsCardUsed = false,
|
||||
|
||||
// IdcardType = "SHENFEN_ZHENGJIAN",
|
||||
// IdcardAddress = person.IdcardAddress,
|
||||
// IdcardForever = "N",
|
||||
// IdcardStartDate = Funs.GetNewDateTime(person.IdcardStartDate),
|
||||
// IdcardEndDate = Funs.GetNewDateTime(person.IdcardEndDate),
|
||||
// Address = person.Address,
|
||||
// OutResult = person.OutResult,
|
||||
// Birthday = person.Birthday,
|
||||
// InTime = Funs.GetNewDateTimeOrNow(person.InTime),
|
||||
// Password = BLL.PersonService.GetPersonPassWord(person.IdentityCard),
|
||||
// Isprint = "0",
|
||||
};
|
||||
PersonService.AddPerson(newPerson);
|
||||
|
||||
Model.ToDoItem toDoItem = new Model.ToDoItem
|
||||
{
|
||||
MenuId = Const.PersonListMenuId,
|
||||
DataId = newPerson.PersonId + "#1",
|
||||
UrlStr = person.AttachUrl1,
|
||||
};
|
||||
if (!string.IsNullOrEmpty(person.AttachUrl1))
|
||||
{
|
||||
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
||||
}
|
||||
|
||||
toDoItem.DataId = newPerson.PersonId + "#5";
|
||||
toDoItem.UrlStr = person.AttachUrl5;
|
||||
if (!string.IsNullOrEmpty(person.AttachUrl5))
|
||||
{
|
||||
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
||||
}
|
||||
|
||||
responeData.code = 1;
|
||||
responeData.message = "新增人员成功!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = -1;
|
||||
responeData.message = "人员信息有误!";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 岗位列表
|
||||
|
||||
public Model.ResponeData getWorkPostList(string WorkPostName)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var list = (from x in Funs.DB.Base_WorkPost
|
||||
orderby x.WorkPostCode
|
||||
select new
|
||||
{
|
||||
x.WorkPostId,
|
||||
x.WorkPostName
|
||||
}).ToList();
|
||||
if (!string.IsNullOrEmpty(WorkPostName))
|
||||
{
|
||||
list = list.Where(x => x.WorkPostName.Contains(WorkPostName)).ToList();
|
||||
}
|
||||
responeData.data = new { list };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user