103 lines
3.9 KiB
C#
103 lines
3.9 KiB
C#
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
responeData.data = new { getData };
|
||
|
}
|
||
|
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]
|
||
|
public Model.ResponeData updateSignTime(string PersonId, DateTime? newSignTime = null)
|
||
|
{
|
||
|
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
|
{
|
||
|
var responeData = new Model.ResponeData();
|
||
|
try
|
||
|
{
|
||
|
// 查找要修改的记录
|
||
|
var person = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == PersonId);
|
||
|
if (person != null)
|
||
|
{
|
||
|
person.SignTime = newSignTime.HasValue ? newSignTime.Value : DateTime.Now; // 更新签字时间
|
||
|
db.SubmitChanges();
|
||
|
responeData.code = 1;
|
||
|
responeData.message = "保存成功。";
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
responeData.code = 0;
|
||
|
responeData.message = ex.Message;
|
||
|
}
|
||
|
|
||
|
return responeData;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|