2025-04-16 10:19:33 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Net;
|
|
|
|
using System.Net.Http;
|
|
|
|
using System.Web.Http;
|
|
|
|
using BLL;
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
namespace WebAPI.Controllers.HSSE
|
|
|
|
{
|
|
|
|
public class InformedConsentFormController:ApiController
|
|
|
|
{
|
|
|
|
#region 根据用户获取告知书
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="PersonId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public Model.ResponeData getFormByWorkPostName(string PersonId)
|
|
|
|
{
|
|
|
|
var responeData = new Model.ResponeData();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var person = Funs.DB.View_SitePerson_Person.FirstOrDefault(x => x.PersonId == PersonId);
|
|
|
|
InformedConsentForm getData = new InformedConsentForm();
|
|
|
|
if (person != null)
|
|
|
|
{
|
|
|
|
string projectName = Funs.DB.Base_Project.First(z => z.ProjectId == person.ProjectId).ProjectName;
|
|
|
|
string name = person.PersonName;
|
|
|
|
string IdentityCard = person.IdentityCard;
|
|
|
|
string Telephone = person.Telephone;
|
|
|
|
string year = person.InTime.HasValue ? person.InTime.Value.Year.ToString() : "";
|
|
|
|
string month = person.InTime.HasValue ? person.InTime.Value.Month.ToString() : "";
|
|
|
|
string day = person.InTime.HasValue ? person.InTime.Value.Day.ToString() : "";
|
|
|
|
getData = (from x in Funs.DB.InformedConsentForm
|
|
|
|
where x.WorkPostName == person.WorkPostName
|
|
|
|
select x).FirstOrDefault();
|
|
|
|
if (getData != null)
|
|
|
|
{
|
|
|
|
// 替换$name占位符
|
|
|
|
getData.JobRiskNotice = getData.JobRiskNotice.Replace("$name", name);
|
|
|
|
// 替换多个占位符
|
|
|
|
getData.HealthCommitment = getData.HealthCommitment.Replace("$name", name)
|
|
|
|
.Replace("$IdentityCard", IdentityCard)
|
|
|
|
.Replace("$Telephone", Telephone)
|
|
|
|
.Replace("$year", year)
|
|
|
|
.Replace("$month", month)
|
|
|
|
.Replace("$day", day)
|
|
|
|
.Replace("$projectName", projectName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-04-17 11:38:17 +08:00
|
|
|
responeData.data = new { getData = getData, person = person };
|
2025-04-16 10:19:33 +08:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
responeData.code = 0;
|
|
|
|
responeData.message = ex.Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
return responeData;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 签字保存后根据人员id修改签字时间
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// </summary> 保存签字图片的时格式是tokenkey=PersonId_1
|
|
|
|
/// <param name="PersonId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
2025-04-21 09:33:45 +08:00
|
|
|
public Model.ResponeData updateSignTime([FromBody] Item item)
|
2025-04-16 10:19:33 +08:00
|
|
|
{
|
|
|
|
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
|
|
|
{
|
|
|
|
var responeData = new Model.ResponeData();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// 查找要修改的记录
|
2025-04-21 09:33:45 +08:00
|
|
|
var person = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == item.PersonId);
|
2025-04-16 10:19:33 +08:00
|
|
|
if (person != null)
|
|
|
|
{
|
2025-04-21 09:33:45 +08:00
|
|
|
person.SignTime = item.newSignTime.HasValue ? item.newSignTime.Value : DateTime.Now; // 更新签字时间
|
2025-04-16 10:19:33 +08:00
|
|
|
db.SubmitChanges();
|
2025-04-21 09:33:45 +08:00
|
|
|
|
|
|
|
Model.ToDoItem toDoItem = new Model.ToDoItem
|
|
|
|
{
|
|
|
|
MenuId = Const.PersonListMenuId,
|
|
|
|
DataId = item.PersonId + "_1",
|
|
|
|
UrlStr = item.AttachUrl1,
|
|
|
|
};
|
|
|
|
if (!string.IsNullOrEmpty(item.AttachUrl1))
|
|
|
|
{
|
|
|
|
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
toDoItem.DataId = item.PersonId + "_2";
|
|
|
|
toDoItem.UrlStr = item.AttachUrl2;
|
|
|
|
if (!string.IsNullOrEmpty(item.AttachUrl2))
|
|
|
|
{
|
|
|
|
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
toDoItem.DataId = item.PersonId + "_3";
|
|
|
|
toDoItem.UrlStr = item.AttachUrl3;
|
|
|
|
if (!string.IsNullOrEmpty(item.AttachUrl3))
|
|
|
|
{
|
|
|
|
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
toDoItem.DataId = item.PersonId + "_4";
|
|
|
|
toDoItem.UrlStr = item.AttachUrl4;
|
|
|
|
if (!string.IsNullOrEmpty(item.AttachUrl4))
|
|
|
|
{
|
|
|
|
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
|
|
|
}
|
|
|
|
|
2025-04-16 10:19:33 +08:00
|
|
|
responeData.code = 1;
|
|
|
|
responeData.message = "保存成功。";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
responeData.code = 0;
|
|
|
|
responeData.message = ex.Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
return responeData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
2025-04-21 09:33:45 +08:00
|
|
|
|
|
|
|
public class Item
|
|
|
|
{
|
|
|
|
public string PersonId { get; set; }
|
|
|
|
public string AttachUrl1 { get; set; }
|
|
|
|
public string AttachUrl2 { get; set; }
|
|
|
|
public string AttachUrl3 { get; set; }
|
|
|
|
public string AttachUrl4 { get; set; }
|
|
|
|
public DateTime? newSignTime { get; set; }
|
|
|
|
}
|
2025-04-16 10:19:33 +08:00
|
|
|
}
|