master
wet 2 years ago
parent ef19f02605
commit 3ed55b8b2e

@ -54,6 +54,10 @@ namespace djy.Paas.IService
List<CodeCityDto> GetCodeCity(string provinceCode);
string SaveTemplate(AMS_AddrTemplate dto, string userid);
List<AMS_AddrTemplate> GetTemplate(string companyid, string type,string TemPlateName);
byte[] PDF(string GID);
}

@ -43,7 +43,7 @@ namespace djy.IService.Isf
/// 获取模板
/// </summary>
/// <returns></returns>
List<ISF_CompanyTemplate> GetTemplate(string companyid, string CompanyType, string InFoType);
List<ISF_CompanyTemplate> GetTemplate(string companyid, string CompanyType, string InFoType,string TemPlateName);
/// <summary>

@ -0,0 +1,56 @@
using FreeSql.DataAnnotations;
using Newtonsoft.Json;
using System;
using System.ComponentModel.DataAnnotations;
namespace djy.Model.Ams
{
[JsonObject(MemberSerialization.OptIn), Table(Name = "AMS_AddrTemplate", DisableSyncStructure = true)]
public class AMS_AddrTemplate
{
[MaxLength(50)]
public string GID { get; set; }
[MaxLength(50)]
public string TemPlateName { get; set; }
[MaxLength(50)]
public string Type { get; set; }
[MaxLength(50)]
public string Name { get; set; }
[MaxLength(200)]
public string ADDR { get; set; }
[MaxLength(50)]
public string Country { get; set; }
[MaxLength(50)]
public string CountryCode { get; set; }
[MaxLength(50)]
public string City { get; set; }
public bool? IsDel { get; set; }
[MaxLength(50)]
public string UserID { get; set; }
[MaxLength(50)]
public string UserName { get; set; }
[MaxLength(50)]
public string CompID { get; set; }
[MaxLength(100)]
public string CompName { get; set; }
public DateTime CreateTime { get; set; }
public DateTime? LastUpdate { get; set; }
}
}

@ -823,34 +823,102 @@ namespace djy.Service.Ams
Document document = new Document(PageSize.A4);
//指定字体文件IDENTITY_H支持中文
BaseFont customfont = BaseFont.CreateFont(@"C:\Windows\Fonts\MSYH.TTC,0", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
var baseFont = new Font(customfont, 12);
var Fonttable = new Font(customfont, 12);
Font font = new Font(customfont, 14);
Font datefont = new Font(customfont, 9);
MemoryStream baos = new MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(document, baos);
document.Open();
document.NewPage();
//配置中文
//定义标题
PdfPTable tableRow_1 = new PdfPTable(1); //生成只有一列的行数据
tableRow_1.DefaultCell.Border = Rectangle.NO_BORDER; //无边框
tableRow_1.DefaultCell.MinimumHeight = 40f; //高度
float[] headWidths_1 = new float[] { 500f }; //宽度
tableRow_1.SetWidths(headWidths_1);
var Row_1_Cell_1 = new PdfPCell(new Paragraph("AMS", baseFont));//文件名以及标题名称
Row_1_Cell_1.HorizontalAlignment = Element.ALIGN_CENTER;//居中
tableRow_1.AddCell(Row_1_Cell_1);
document.Add(tableRow_1);
document.NewPage();
int total = 2; //总列数
for (int i = 0; i < 1; i++)
{
PdfPTable tableRow_2 = new PdfPTable(total);
var Row_2_Cell_1 = new PdfPCell(new Paragraph("3333", baseFont));
tableRow_2.AddCell(Row_2_Cell_1);
document.Add(tableRow_2);
}
///获取数据源
var houselist = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.PID == GID).ToList();
var masterlist = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(x => x.GID == GID).ToOne();
var cARRIERIDList = DbBus.Get(DbList.Common).Select<MappingCarrier>().Where(map => map.Module == "AMS").ToList();
if (houselist!=null&& masterlist!=null) {
for (int i = 0; i < houselist.Count(); i++)
{
string heardText = "NIAV" + houselist[i].HBLNo + " ISF INFORMATION";
Paragraph heardTexts = new Paragraph(heardText, font);
heardTexts.IndentationLeft = 150;
heardTexts.IndentationRight = 130;
document.Add(heardTexts);
document.Add(new Paragraph("\r"));//换行
PdfPTable table = new PdfPTable(2); //生成只有2列的行数据
table.DefaultCell.Border = Rectangle.NO_BORDER; //无边框
table.DefaultCell.MinimumHeight = 40f; //高度
float[] widths = new float[] { 100f,200f }; //宽度
table.SetWidths(widths);
var Row_1 = new PdfPCell(new Paragraph("AMS B/L NO.", Fonttable));
Row_1.HorizontalAlignment = Element.ALIGN_RIGHT;//靠右
table.AddCell(Row_1);
var Row_2 = new PdfPCell(new Paragraph("NIAV"+houselist[i].HBLNo, Fonttable));
Row_2.HorizontalAlignment = Element.ALIGN_LEFT;//靠左
table.AddCell(Row_2);
var Row_3 = new PdfPCell(new Paragraph("HNL.NO.", Fonttable));
Row_3.HorizontalAlignment = Element.ALIGN_RIGHT;//靠右
table.AddCell(Row_3);
var Row_4 = new PdfPCell(new Paragraph(houselist[i].HBLNo, Fonttable));
Row_4.HorizontalAlignment = Element.ALIGN_LEFT;//靠左
table.AddCell(Row_4);
var Row_5 = new PdfPCell(new Paragraph("HNL SCAC CODE.", Fonttable));
Row_5.HorizontalAlignment = Element.ALIGN_RIGHT;//靠右
table.AddCell(Row_5);
var Row_6 = new PdfPCell(new Paragraph("NIAV", Fonttable));
Row_6.HorizontalAlignment = Element.ALIGN_LEFT;//靠左
table.AddCell(Row_6);
var Row_7 = new PdfPCell(new Paragraph("MBL NO.", Fonttable));
Row_7.HorizontalAlignment = Element.ALIGN_RIGHT;//靠右
table.AddCell(Row_7);
var Row_8 = new PdfPCell(new Paragraph(cARRIERIDList.Where(x => x.Code == masterlist.CARRIERID).Select(x => x.MapCode).FirstOrDefault() + masterlist.MBLNO, Fonttable));
Row_8.HorizontalAlignment = Element.ALIGN_LEFT;//靠左
table.AddCell(Row_8);
var Row_9= new PdfPCell(new Paragraph("MBL SCAC CODE.", Fonttable));
Row_9.HorizontalAlignment = Element.ALIGN_RIGHT;//靠右
table.AddCell(Row_9);
var Row_0 = new PdfPCell(new Paragraph(cARRIERIDList.Where(x => x.Code == masterlist.CARRIERID).Select(x => x.MapCode).FirstOrDefault(), Fonttable));
Row_0.HorizontalAlignment = Element.ALIGN_LEFT;//靠左
table.AddCell(Row_0);
document.Add(table);
string dateText = "DATE PRINTED:"+DateTime.Now.ToString("yyyy-MM-dd HH:mm");
Paragraph dateTexts = new Paragraph(dateText, datefont);
dateTexts.IndentationLeft = 380f;
document.Add(dateTexts);
document.Add(new Paragraph("\r"));//换行
Image image = Image.GetInstance(@"F:\DJY.Ams\djyweb_ams\ams\djy.WebApi\logo.png");
image.ScalePercent(10f);
//设置图片的宽高
image.ScaleAbsolute(180f, 66f);
image.Alignment = Element.ALIGN_CENTER;
//设置图片具体位置 PDF左下角为原点
image.SetAbsolutePosition(400f, 20f);//出现在屏幕左下角 图片左下角做为锚点
document.Add(image);
if ((i+1)%4==0) {
document.NewPage();
}
}
}
document.Close();
writer.Close();
return baos.GetBuffer();
@ -859,8 +927,58 @@ namespace djy.Service.Ams
#endregion
#region 保存模板
public string SaveTemplate(AMS_AddrTemplate dto, string userid)
{
string guid = "";
var user = DbBus.Get(DbList.djydb).Select<User>().Where(w => w.GID == userid).ToOne();
if (dto.GID.IsNull())
{
AMS_AddrTemplate template = dto.MapTo<AMS_AddrTemplate>();
template.CreateTime = DateTime.Now;
template.LastUpdate = DateTime.Now;
template.GID = Guid.NewGuid().ToString("N");
template.UserID = user.GID;
template.UserName = user.SHOWNAME;
template.CompID = user.CompId;
template.CompName = user.COMNAME;
template.IsDel = false;
DbBus.Get(DbList.AMSCenter).Insert(template).ExecuteAffrows();
guid = template.GID;
}
return guid;
}
#endregion
#region 获取模板
public List<AMS_AddrTemplate> GetTemplate(string companyid, string type, string TemPlateName)
{
try
{
var List = DbBus.Get(DbList.Common).Select<AMS_AddrTemplate>().
Where(x => x.IsDel == false || x.IsDel == null).
WhereIf(companyid != "", x => x.CompID == companyid).
WhereIf(type != "", x => x.Type == type).
WhereIf(TemPlateName != "", x => TemPlateName.Contains(x.TemPlateName)).
ToList();
return List;
}
catch (Exception e)
{
throw;
}
}
#endregion
}
}

@ -167,11 +167,17 @@ namespace djy.Service.ISF
#region 获取模板
public List<ISF_CompanyTemplate> GetTemplate(string companyid, string CompanyType, string InFoType)
public List<ISF_CompanyTemplate> GetTemplate(string companyid, string CompanyType, string InFoType,string TemPlateName)
{
try
{
var List = DbBus.Get(DbList.Common).Select<ISF_CompanyTemplate>().WhereIf(companyid != "", x => x.CompID==companyid&& (x.IsDel == false || x.IsDel == null)&&x.CompanyType==CompanyType&&x.InFoType==InFoType).ToList();
var List = DbBus.Get(DbList.Common).Select<ISF_CompanyTemplate>().
Where(x=> x.IsDel == false || x.IsDel == null).
WhereIf(companyid != "", x => x.CompID==companyid).
WhereIf(CompanyType != "", x => x.CompanyType == CompanyType).
WhereIf(InFoType != "", x => x.InFoType == InFoType).
WhereIf(TemPlateName != "", x => TemPlateName.Contains(x.TemPlateName)).
ToList();
return List;
}
catch (Exception e)

@ -336,133 +336,53 @@ namespace djy_AmsApi.Controllers
byte[] bytes = ser.PDF(Gid);
return File(bytes, "application/octet-stream");
}
#endregion
[HttpGet("ExportPDF1")]
public FileResult ExportSignARPAPdf()
#region 获取模板
[HttpGet("GetTemplate")]
public Response<List<AMS_AddrTemplate>> GetTemplate(string type, string TemPlateName=null)
{
//定义一个Document并设置页面大小为A4竖向
Document doc = new Document(PageSize.A4, 72, 72, 60, 0);
MemoryStream baos = new MemoryStream();
PdfWriter writer =PdfWriter.GetInstance(doc, baos);
doc.Open();
#region 创建字体
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
BaseFont baseFT = BaseFont.CreateFont("C:\\Windows\\Fonts\\simhei.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);//获取系统的字体
Font font = new Font(baseFT, 10); //写入一个段落, Paragraph
Font title = new Font(baseFT, 16);
Font bold = new Font(baseFT, 10, 1); //字体加粗
Font italics = new Font(baseFT, 10, 2); //字体斜体
Font underline = new Font(baseFT, 10, 4); //下划线
Font boldAndItalics = new Font(Font.TIMES_ROMAN, 11f, Font.BOLD | Font.ITALIC, BaseColor.Black);
#endregion
#region 文本数据
string heardText = "Restricted Project Information Acknowledgement";
string text = "You, the undersigned, are involved in the development of a highly confidential Apple project code-named. The following guidelines are intended to protect the secrecy of the project. Please acknowledge that you have read and agree to follow the guidelines by signing below.";
List clauseList = new List(true, 20);
clauseList.Add(new ListItem("Only refer to Apple by the code-name provided by your employer.\r\r", font));
clauseList.Add(new ListItem("Only refer to the project by the code - name provided by your employer.\r\r", font));
clauseList.Add(new ListItem("Do not disclose any confidential information related to the project or any confidential prototypes, drawings, images, or other materials to anyone other than those that have a need to know in connection with the project and who have been approved by Apple.To determine whether someone has been approved, please contact your project manager.\r\r", font));
clauseList.Add(new ListItem("Comply with the Apple Security Requirements and any confidentiality agreements related to the project.Ask your project manager if you do not know what these requirements are.\r\r", font));
clauseList.Add(new ListItem("Your obligation to maintain the confidentiality of the project continues even after your work on the project or your service to your employer has ended.\r\r", font));
clauseList.Add(new ListItem("Unauthorized use or disclosure of confidential information or prototypes related to the project is a violation of the confidentiality agreement between Apple and your employer and may be a violation of the law.\r\r", font));
string agreedText = "Acknowledged and agreed:";
string signature = "Signature: ___________________________________\r\r";
string name = " Name: ___________________________________\r\r";
string titleDown = " Title: ___________________________________\r\r";
string companyUs = " Company: Shenzhen INCUBE Automation Co., Ltd.\r\r";
string companyCh = "深圳市智立方自动化设备有限公司 ";
string date = "\r Date: ___________________________________\r\r";
PdfPTable tableRow_2 = new PdfPTable(2);
var Row_2_Cell_1 = new PdfPCell(new Phrase("3333", font));
tableRow_2.AddCell(Row_2_Cell_1);
#endregion
#region 给文本添加字体
Paragraph heardTexts = new Paragraph(heardText, title);
Paragraph texts = new Paragraph(text, font);
Paragraph agreed = new Paragraph(agreedText, boldAndItalics);
Paragraph signatures = new Paragraph(signature, font);
Paragraph names = new Paragraph(name, font);
Paragraph titleDowns = new Paragraph(titleDown, font);
Paragraph companyUss = new Paragraph(companyUs, font);
Paragraph companyChs = new Paragraph(companyCh, underline);
Paragraph dates = new Paragraph(date, font);
#endregion
#region 缩进
heardTexts.IndentationLeft = 20;
heardTexts.IndentationRight = 20;
texts.IndentationLeft = 20;
texts.IndentationRight = 20;
clauseList.IndentationLeft = 40;
clauseList.IndentationRight = 40;
agreed.IndentationLeft = 20;
agreed.IndentationRight = 20;
signatures.IndentationLeft = 70;
names.IndentationLeft = 70;
titleDowns.IndentationLeft = 70;
companyUss.IndentationLeft = 70;
companyChs.IndentationLeft = 130;
dates.IndentationLeft = 70;
#endregion
var result = new Response<List<AMS_AddrTemplate>>();
try
{
if (GetLoginCompId == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
result.Result = ser.GetTemplate("9f3b3526-4dd4-4997-b974-1f2adb2793c7", type, TemPlateName);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
#region 文本添加到PDF
doc.Add(heardTexts);
doc.Add(new Paragraph("\r"));//换行
doc.Add(texts);
doc.Add(new Paragraph("\r"));//换行
doc.Add(clauseList);
doc.Add(agreed);
doc.Add(new Paragraph("\r"));//换行
doc.Add(signatures);
doc.Add(names);
doc.Add(titleDowns);
doc.Add(companyUss);
doc.Add(companyChs);
doc.Add(dates);
doc.Add(new Paragraph("\r"));//换行
#endregion
//关闭document
doc.Close();
writer.Close();
return File(baos.GetBuffer(), "application/octet-stream");
return result;
}
#endregion
#region 保存模板
[HttpPost("SaveTemplate")]
public Response SaveTemplate(AMS_AddrTemplate Dto)
{
var result = new Response();
//if (GetLoginId == null)
//{
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
//}
if (Dto == null)
{
result.Code = 500;
result.Message = "无效数据!";
}
result.data = ser.SaveTemplate(Dto, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
return result;
}
#endregion
}
}

@ -85,7 +85,7 @@ namespace djy_AmsApi.Controllers.ISF
#region 获取模板
[HttpGet("GetTemplate")]
public Response<List<ISF_CompanyTemplate>> GetTemplate(string InFoType, string CompanyType)
public Response<List<ISF_CompanyTemplate>> GetTemplate(string InFoType, string CompanyType,string TemPlateName=null)
{
var result = new Response<List<ISF_CompanyTemplate>>();
try
@ -96,7 +96,7 @@ namespace djy_AmsApi.Controllers.ISF
result.Message = "登录过期,请重新登录!";
return result;
}
result.Result = ser.GetTemplate("9f3b3526-4dd4-4997-b974-1f2adb2793c7", CompanyType, InFoType);
result.Result = ser.GetTemplate("9f3b3526-4dd4-4997-b974-1f2adb2793c7", CompanyType, InFoType, TemPlateName);
}
catch (Exception ex)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Loading…
Cancel
Save