2026-09-19 13:45:38 +08:00
|
|
|
namespace BLL
|
2022-09-05 16:36:31 +08:00
|
|
|
{
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-09-19 13:45:38 +08:00
|
|
|
/// 人员上岗证打印服务。
|
2022-09-05 16:36:31 +08:00
|
|
|
/// </summary>
|
|
|
|
|
public static class PrinterDocService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2026-09-19 13:45:38 +08:00
|
|
|
/// 输出人员上岗证打印内容。
|
2022-09-05 16:36:31 +08:00
|
|
|
/// </summary>
|
|
|
|
|
public static void PrinterDocMethod(string menuId, string id, string name)
|
|
|
|
|
{
|
|
|
|
|
System.Web.HttpContext.Current.Response.ClearContent();
|
2026-09-19 13:45:38 +08:00
|
|
|
string htmlStr = menuId == Const.SendCardMenuId ? GetSendCardHtml(id) : string.Empty;
|
2024-03-27 18:07:03 +08:00
|
|
|
if (!string.IsNullOrEmpty(htmlStr))
|
|
|
|
|
{
|
|
|
|
|
string filename = name + Funs.GetNewFileName();
|
|
|
|
|
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename="
|
|
|
|
|
+ System.Web.HttpUtility.UrlEncode(filename, Encoding.UTF8) + ".doc");
|
|
|
|
|
System.Web.HttpContext.Current.Response.ContentType = "application/word";
|
|
|
|
|
System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
|
|
|
|
|
System.Web.HttpContext.Current.Response.Write(htmlStr);
|
|
|
|
|
System.Web.HttpContext.Current.Response.End();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-05 16:36:31 +08:00
|
|
|
|
2024-03-27 18:07:03 +08:00
|
|
|
/// <summary>
|
2026-09-19 13:45:38 +08:00
|
|
|
/// 生成人员上岗证打印表格。
|
2024-03-27 18:07:03 +08:00
|
|
|
/// </summary>
|
2026-09-19 13:45:38 +08:00
|
|
|
public static string GetSendCardHtml(string personIds)
|
2024-03-27 18:07:03 +08:00
|
|
|
{
|
2026-09-19 13:45:38 +08:00
|
|
|
Model.SGGLDB db = Funs.DB;
|
2024-03-27 18:07:03 +08:00
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("<meta http-equiv=\"content-type\" content=\"application/word; charset=UTF-8\"/>");
|
2026-09-19 13:45:38 +08:00
|
|
|
sb.Append("<table width=\"100%\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse;\">");
|
|
|
|
|
List<string> personIdList = Funs.GetStrListByStr(personIds, ',');
|
|
|
|
|
foreach (string personId in personIdList)
|
2022-09-05 16:36:31 +08:00
|
|
|
{
|
2026-09-19 13:45:38 +08:00
|
|
|
Model.SitePerson_Person sitePerson = SitePerson_PersonService.GetSitePersonById(personId);
|
|
|
|
|
if (sitePerson == null)
|
2022-09-05 16:36:31 +08:00
|
|
|
{
|
2026-09-19 13:45:38 +08:00
|
|
|
continue;
|
2022-09-05 16:36:31 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-19 13:45:38 +08:00
|
|
|
Model.Person_Persons person = Person_PersonsService.GetPerson_PersonsByIdCard(sitePerson.IdentityCard);
|
|
|
|
|
if (person == null)
|
2022-09-05 16:36:31 +08:00
|
|
|
{
|
2026-09-19 13:45:38 +08:00
|
|
|
continue;
|
2022-09-05 16:36:31 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-19 13:45:38 +08:00
|
|
|
string qrUrl = person.QRCodeAttachUrl;
|
|
|
|
|
if (string.IsNullOrEmpty(qrUrl) || !CreateQRCodeService.isHaveImage(qrUrl))
|
2022-09-05 16:36:31 +08:00
|
|
|
{
|
2026-09-19 13:45:38 +08:00
|
|
|
qrUrl = CreateQRCodeService.CreateCode_Simple(sitePerson.IdentityCard);
|
|
|
|
|
person.QRCodeAttachUrl = qrUrl;
|
|
|
|
|
db.SubmitChanges();
|
2022-09-05 16:36:31 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-19 13:45:38 +08:00
|
|
|
sb.Append("<tr style=\"height:180px;\">");
|
|
|
|
|
sb.Append("<td align=\"center\" style=\"width:30%;\">");
|
|
|
|
|
sb.AppendFormat("<img width='85' height='110' src='{0}'></img>", (Funs.SGGLUrl + person.PhotoUrl).Replace('\\', '/'));
|
|
|
|
|
sb.Append("</td>");
|
|
|
|
|
sb.Append("<td align=\"left\" style=\"width:45%;font-size:10pt;line-height:28px;\">");
|
|
|
|
|
sb.AppendFormat("公司:{0}<br />", "赛鼎工程有限公司");
|
|
|
|
|
sb.AppendFormat("项目:{0}<br />", ProjectService.GetShortNameByProjectId(sitePerson.ProjectId));
|
|
|
|
|
sb.AppendFormat("单位:{0}<br />", UnitService.GetUnitNameByUnitId(sitePerson.UnitId));
|
|
|
|
|
sb.AppendFormat("岗位:{0}<br />", WorkPostService.getWorkPostNameById(sitePerson.WorkPostId));
|
|
|
|
|
sb.AppendFormat("姓名:{0}<br />编号:{1}", sitePerson.PersonName, sitePerson.CardNo);
|
|
|
|
|
sb.Append("</td>");
|
|
|
|
|
sb.AppendFormat("<td align=\"center\" style=\"width:25%;\"><img width='60' height='50' src='{0}'></img></td>", (Funs.SGGLUrl + qrUrl).Replace('\\', '/'));
|
2022-09-05 16:36:31 +08:00
|
|
|
sb.Append("</tr>");
|
|
|
|
|
}
|
2026-09-19 13:45:38 +08:00
|
|
|
sb.Append("</table>");
|
2022-09-05 16:36:31 +08:00
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-09-19 13:45:38 +08:00
|
|
|
}
|