From d46b179a4ef851a82cbce02c9d96da2657fc2f77 Mon Sep 17 00:00:00 2001 From: ddlucky Date: Tue, 28 Mar 2023 17:55:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=8D=95=E6=9D=A1=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DSWeb.Common/DB/Comm.cs | 26 ++++ DSWeb.Common/DB/CommonDataContext.cs | 7 +- DSWeb/Areas/CommMng/DAL/PDFHelper.cs | 140 ++++++++++++++++-- .../Controllers/BillCheckOutController.cs | 6 + .../DAL/BillCheckOut/BillCheckOutDAL.cs | 71 ++++++++- .../DAL/MsInfoClient/MsInfoClientDAL.cs | 43 ++++++ 6 files changed, 271 insertions(+), 22 deletions(-) diff --git a/DSWeb.Common/DB/Comm.cs b/DSWeb.Common/DB/Comm.cs index 9acb2292..59bb7c1e 100644 --- a/DSWeb.Common/DB/Comm.cs +++ b/DSWeb.Common/DB/Comm.cs @@ -2419,6 +2419,32 @@ namespace DSWeb.Common.DB public string VOYNO { get; set; } } + + [Table("VW_BILL_BLISSUE_WORKLOG")] + public partial class VW_BILL_BLISSUE_WORKLOG_md + { + [Key] + public string GID { get; set; } + public string DOBSNO { get; set; } + public DateTime? OPDATE { get; set; } + public string ACTNAME { get; set; } + public string REMARK { get; set; } + public string BSNO { get; set; } + } + + [Table("WorkLog")] + public partial class WorkLog_md + { + [Key] + public string GID { get; set; } + public string BSNO { get; set; } + public string OP { get; set; } + public DateTime? OPDATE { get; set; } + public string ACTNAME { get; set; } + public string REMARK { get; set; } + public string ACTRESULT { get; set; } + } + public static class StrHelper { #region 将一个dictionary转化为用;;和::隔开的文本 diff --git a/DSWeb.Common/DB/CommonDataContext.cs b/DSWeb.Common/DB/CommonDataContext.cs index 0b56b3a8..9f1a3a37 100644 --- a/DSWeb.Common/DB/CommonDataContext.cs +++ b/DSWeb.Common/DB/CommonDataContext.cs @@ -84,7 +84,12 @@ namespace DSWeb.Common.DB public DbSet BillCheckOut { get; set; } public DbSet BillCheckOut_Detail { get; set; } public DbSet VW_BillCheckOut_Detail { get; set; } - + public DbSet VW_BILL_BLISSUE_WORKLOG { get; set; } + + + public DbSet WorkLog { get; set; } + + } diff --git a/DSWeb/Areas/CommMng/DAL/PDFHelper.cs b/DSWeb/Areas/CommMng/DAL/PDFHelper.cs index 3a1ca430..dd12bce0 100644 --- a/DSWeb/Areas/CommMng/DAL/PDFHelper.cs +++ b/DSWeb/Areas/CommMng/DAL/PDFHelper.cs @@ -9,6 +9,11 @@ using iTextSharp.text.pdf; using DSWeb.Common.DB; using System.Data.Entity.Migrations; using HcUtility.Comm; +using DSWeb.MvcShipping.DAL.MsInfoClient; +using DSWeb.MvcShipping.DAL.MsOpSeaeDAL; +using NPOI.OpenXmlFormats; +using DSWeb.MvcShipping.Models.MsOpSeae; +using NPOI.SS.Formula.Functions; namespace DSWeb.Areas.CommMng.DAL { @@ -78,17 +83,37 @@ namespace DSWeb.Areas.CommMng.DAL //幼圆 //BaseFont bfComic = BaseFont.CreateFont("c://windows//fonts//SIMYOU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); + var companyinfo = cdc.company.FirstOrDefault(x => x.GID == head.CORPID); - iTextSharp.text.Font title = new iTextSharp.text.Font(bfComic, 24, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK); + var stlinfo = MsInfoClientDAL.GetSTLNAME(head.CUSTOMERNAME, "海运出口", DateTime.Now.ToString("yyyy-MM-dd"), ""); + var BodyList = cdc.BillCheckOut_Detail.Where(x => x.LINKGID == head.GID).ToList(); + var firstbsno = BodyList[0].BSNO; + var firstopseae = cdc.v_op_bs.FirstOrDefault(x => x.BSNO == firstbsno); + var 操作 = firstopseae.OP; + var 操作user = cdc.VW_user.FirstOrDefault(x => x.SHOWNAME == 操作 ); + var 操作baseinfo = BasicDataRefDAL.GetUserLinkRefList($" u.showname='{操作}'", firstopseae.SALECORPID); + + //标题字体 黑色26 + iTextSharp.text.Font title = new iTextSharp.text.Font(bfComic, 26, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK); + + //公司名称 黑色加粗22 + iTextSharp.text.Font companyname = new iTextSharp.text.Font(bfComic, 20, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK); + + //表格抬头字体 黑色加粗12 iTextSharp.text.Font heads = new iTextSharp.text.Font(bfComic, 12, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK); + + //内容文字字体 黑色11 iTextSharp.text.Font infos = new iTextSharp.text.Font(bfComic, 11, 0, iTextSharp.text.BaseColor.BLACK); + //抬头地址字体 黑色11 下划线 + iTextSharp.text.Font address = new iTextSharp.text.Font(bfComic, 14, Font.UNDERLINE, iTextSharp.text.BaseColor.BLACK); - var 标题 = new iTextSharp.text.Paragraph("--总标题--", title); + //红色内容 红色11 + iTextSharp.text.Font redinfos = new iTextSharp.text.Font(bfComic, 12, 0, iTextSharp.text.BaseColor.RED); - 标题.Alignment = iTextSharp.text.Element.ALIGN_CENTER; - 标题.Leading = 50; + + #region 条码号 BarCodeDrawing _Code39 = new BarCodeDrawing(); _Code39.Height = 50; _Code39.Magnify = 1; @@ -103,24 +128,71 @@ namespace DSWeb.Areas.CommMng.DAL _codeImage.Save(markPath); iTextSharp.text.Image im = iTextSharp.text.Image.GetInstance(markPath); - im.SetAbsolutePosition(width - 280, height - 60); + im.SetAbsolutePosition(width - 280, height - 60-80); im.ScaleAbsolute(260, 40); + //document.Add(im); + + #endregion + + #region 抬头 + //公司标志图片放置在../../UploadFiles/MailFile/companyid.png + var 公司标志图片路径 = path + "\\" + companyinfo.GID + ".png"; + iTextSharp.text.Image 公司标志 = iTextSharp.text.Image.GetInstance(公司标志图片路径); + 公司标志.SetAbsolutePosition(40, height - 60-8); + 公司标志.ScaleAbsolute(160, 48); + //document.Add(公司标志); + + var 公司名称 = new iTextSharp.text.Paragraph(companyinfo.FULLNAME, companyname); + + 公司名称.Alignment = iTextSharp.text.Element.ALIGN_CENTER; + 公司名称.Leading = 24; + 公司名称.Add(im); + 公司名称.Add(公司标志); + document.Add(公司名称); + + + var 英文名称 = new iTextSharp.text.Paragraph(companyinfo.ENNAME, companyname); + + 英文名称.Alignment = iTextSharp.text.Element.ALIGN_CENTER; + 英文名称.Leading = 24; + document.Add(英文名称); + + var 地址 = new iTextSharp.text.Paragraph(" " + companyinfo.PRTHEADXML5+ " ", address); + + 地址.Alignment = iTextSharp.text.Element.ALIGN_CENTER; + 地址.Leading = 22; + document.Add(地址); + + + #endregion - document.Add(标题); - document.Add(im); + var 标题 = new iTextSharp.text.Paragraph("领单申请书", title); + + 标题.Alignment = iTextSharp.text.Element.ALIGN_CENTER; + 标题.Leading = 35; + + + + document.Add(标题); var body = cdc.VW_BillCheckOut_Detail.Where(x => x.LINKGID == head.GID).ToList(); - var newinfo1 = new iTextSharp.text.Paragraph($"客户名称:{head.CUSTOMERNAME} 客户类型: 联系人:{head.SENDER} 联系电话:" , infos); + var newinfo1 = new iTextSharp.text.Paragraph($"客户名称:{head.CUSTOMERNAME} 客户类型:{stlinfo.STLNAME} 联系人:{操作} 联系电话:{操作baseinfo[0].Tel}" , infos); newinfo1.FirstLineIndent = 100; - newinfo1.Leading = 30; + newinfo1.Leading = 20; document.Add(newinfo1); + //有效期至 + var newinfo2 = new iTextSharp.text.Paragraph($"有效期:自收到48小时内({DateTime.Now.AddDays(2).ToString("yyyy-MM-dd HH:mm")})", heads); + newinfo2.FirstLineIndent = 100; + newinfo2.Leading = 20; + document.Add(newinfo2); + var blankline = new iTextSharp.text.Paragraph($" ", infos); //blankline.FirstLineIndent = 100; - blankline.Leading = 30; + blankline.Leading = 10; document.Add(blankline); PdfPTable table = new PdfPTable(6); @@ -136,6 +208,14 @@ namespace DSWeb.Areas.CommMng.DAL table.AddCell(new Phrase("提单签入日期", heads)); table.AddCell(new Phrase("二次改单", heads)); + var bsnolist = body.Select(s => s.BSNO).ToList(); + //var bsnolistStr = "'" + string.Join("','", bsnolist) + "'"; + var billlist = new List(); + foreach (var bsno in bsnolist) { + var rec = MsOpSeaeDAL.GetData($"B.BSNO='{bsno}'"); + billlist.Add(rec); + } + foreach (var item in body) { var MBLNO = new iTextSharp.text.Paragraph(item.MBLNO, infos); @@ -147,13 +227,30 @@ namespace DSWeb.Areas.CommMng.DAL var VOYNO = new iTextSharp.text.Paragraph(item.VOYNO, infos); table.AddCell(VOYNO); - var ISSUETYPE = new iTextSharp.text.Paragraph("", infos); + var bill = billlist.First(x => x.BSNO == item.BSNO); + + var ISSUETYPE = new iTextSharp.text.Paragraph(bill.ISSUETYPE, infos); table.AddCell(ISSUETYPE); - var CHECKINDATE = new iTextSharp.text.Paragraph("", infos); + + var CHECKINDATE = new iTextSharp.text.Paragraph(bill.ISSUEDATE, infos); table.AddCell(CHECKINDATE); - var ECGD = new iTextSharp.text.Paragraph("", infos); + var workloglist = cdc.VW_BILL_BLISSUE_WORKLOG.Where(x => x.BSNO == item.BSNO).ToList(); + + + var 二次改单 = ""; + var 提单签入次数 = 0; + if (workloglist != null && workloglist.Count > 0) + { + 提单签入次数 = workloglist.Where(x => x.ACTNAME == "提单签入").ToList().Count(); + if (提单签入次数 > 1) + { + 二次改单 = ((DateTime)workloglist.Where(x => x.ACTNAME == "提单签入").Select(s => s.OPDATE).Max()).ToString("yyyy-MM-dd"); + } + } + + var ECGD = new iTextSharp.text.Paragraph(二次改单, infos); table.AddCell(ECGD); //newinfo.FirstLineIndent = 100; @@ -163,13 +260,26 @@ namespace DSWeb.Areas.CommMng.DAL document.Add(table); - var footer = new iTextSharp.text.Paragraph("结尾落款", infos); + //感谢 + var newinfo3 = new iTextSharp.text.Paragraph($"感谢您对我司的支持与信任,聚焦专注,用心服务", heads); + newinfo3.FirstLineIndent = 100; + newinfo3.Leading = 30; + document.Add(newinfo3); + + var footer = new iTextSharp.text.Paragraph("签字 ", infos); //footer.FirstLineIndent = 150; - footer.Leading = 60; + footer.Leading = 30; footer.Alignment = iTextSharp.text.Element.ALIGN_RIGHT; document.Add(footer); + var footer2 = new iTextSharp.text.Paragraph($"时间 ", infos); + //footer.FirstLineIndent = 150; + + footer2.Leading = 30; + footer2.Alignment = iTextSharp.text.Element.ALIGN_RIGHT; + document.Add(footer2); + document.Close(); File.Delete(markPath); diff --git a/DSWeb/Areas/MvcShipping/Controllers/BillCheckOutController.cs b/DSWeb/Areas/MvcShipping/Controllers/BillCheckOutController.cs index b765b23b..9ff68ffa 100644 --- a/DSWeb/Areas/MvcShipping/Controllers/BillCheckOutController.cs +++ b/DSWeb/Areas/MvcShipping/Controllers/BillCheckOutController.cs @@ -371,6 +371,12 @@ namespace DSWeb.MvcShipping.Controllers return BasicDataRefDAL.GetContentResult(result); } + /// + /// 签字板签名完成后,记录签名后文档 + /// + /// + /// + /// public ContentResult SaveSignPdf(string GID,string Base64Str) { var canlogin = BasicDataRefDAL.CheckLogin(Session); diff --git a/DSWeb/Areas/MvcShipping/DAL/BillCheckOut/BillCheckOutDAL.cs b/DSWeb/Areas/MvcShipping/DAL/BillCheckOut/BillCheckOutDAL.cs index d03ea233..597104e8 100644 --- a/DSWeb/Areas/MvcShipping/DAL/BillCheckOut/BillCheckOutDAL.cs +++ b/DSWeb/Areas/MvcShipping/DAL/BillCheckOut/BillCheckOutDAL.cs @@ -333,7 +333,7 @@ namespace DSWeb.MvcShipping.DAL.BillCheckOut } } cdc.SaveChanges(); - + result.OK("发送成功"); return result; } @@ -401,7 +401,7 @@ namespace DSWeb.MvcShipping.DAL.BillCheckOut var filename = result.Message; //2作为附件发出 - result = SendCheckOutEmail(head); + result = SendCheckOutEmail(head, path); return result; @@ -418,7 +418,7 @@ namespace DSWeb.MvcShipping.DAL.BillCheckOut return result; } - public static DBResult SendCheckOutEmail(BillCheckOut_md head) + public static DBResult SendCheckOutEmail(BillCheckOut_md head,string path) { var cdc = new CommonDataContext(); var result = new DBResult(true, ""); @@ -427,11 +427,11 @@ namespace DSWeb.MvcShipping.DAL.BillCheckOut head = cdc.BillCheckOut.FirstOrDefault(x => x.GID == head.GID); - var mailtitle = "签单表"; + var mailtitle = "领单申请书"; var Body = new StringBuilder(); Body.Append(" "); - Body.Append("
签单表内容:
业务编号:"); + Body.Append("
领单申请书:
具体内容请查看附件"); //Body.Append("
客户名称:" + headData.CUSTOMERNAME); //Body.Append("
揽货人" + headData.SALE); //Body.Append("
录入人" + headData.INPUTBY); @@ -471,7 +471,66 @@ namespace DSWeb.MvcShipping.DAL.BillCheckOut // result = MsSeaeOrderDAL.SendMailWithFile(mailtitle, Body.ToString(), filepath, mailto, Convert.ToString(Session["SHOWNAME"])); //} - result = MsSeaeOrderDAL.MsSeaeOrderDAL.SendMailWithFile(mailtitle, Body.ToString(), head.MAILPDFURL, mailto, head.SENDER); + + //20230328 首先trycatch删除 head.MAILPDFURL_*的文件 + //然后复制一个head.MAILPDFURL文件,至head.MAILPDFURL_yyyyMMddHHmm.pdf + + + //DirectoryInfo direction = new DirectoryInfo(filepath); + //var allfilename = head.MAILPDFURL.Replace(".pdf", "_*"); + //FileInfo[] files= direction.GetFiles(allfilename,SearchOption.AllDirectories); + //if (files != null && files.Length > 0) { + // for (int i = 0; i < files.Length; i++) + // { + // try { + // File.Delete(files[i].FullName); + // } + // catch(Exception ex) + // { + + // } + // } + //} + + var filedic = GetLogicInfo(head.GID, "filename"); + var upddic = new Dictionary(); + if (filedic!=null && filedic.Count>0) + foreach (var item in filedic) { + + if (item.Value == "1") { + try + { + File.Delete(path+"/" + item.Key); + upddic.Add(item.Key, "0"); + } + catch(Exception ex) + { + + } + + } + } + + + + string sourceFile = path+"/" + head.CHECKOUTNO+".pdf"; + string filelastname = DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; + string destinationFile = sourceFile.Replace(".pdf","_") + filelastname ; + //记录复制的附件到 + if (System.IO.File.Exists(sourceFile)) + { + // true is overwrite + System.IO.File.Copy(sourceFile, destinationFile, true); + } + + upddic.Add(head.CHECKOUTNO + "_" + filelastname , "1"); + + SaveLogicInfo(head.GID, "filename", upddic); + + var sendpath = destinationFile.Replace(path, "../../UploadFiles/MailFile"); + + + result = MsSeaeOrderDAL.MsSeaeOrderDAL.SendMailWithFile(mailtitle, Body.ToString(), sendpath, mailto, head.SENDER); result.OK("发送成功"); } diff --git a/DSWeb/Areas/MvcShipping/DAL/MsInfoClient/MsInfoClientDAL.cs b/DSWeb/Areas/MvcShipping/DAL/MsInfoClient/MsInfoClientDAL.cs index a0316fc3..0d314bb4 100644 --- a/DSWeb/Areas/MvcShipping/DAL/MsInfoClient/MsInfoClientDAL.cs +++ b/DSWeb/Areas/MvcShipping/DAL/MsInfoClient/MsInfoClientDAL.cs @@ -2696,6 +2696,49 @@ namespace DSWeb.MvcShipping.DAL.MsInfoClient #endregion + #region 根据业务类型和业务日期判断客户账期类型(月结/票结) + + static public STLDATEmb GetSTLNAME(string CUSTOMERNAME, string OPLBNAME, string BUSDATE, string SALE) + { + var strcondition = new StringBuilder(); + strcondition.Append(" LINKGID=(SELECT GID from info_client where Shortname='" + CUSTOMERNAME + + "') and Convert(datetime,'" + BUSDATE + "') between BGNDATE and ENDDATE and (OPLBNAME='" + OPLBNAME + "' or ISNULL(OPLBNAME,'')='') "); + + if (!string.IsNullOrEmpty(SALE)) + { + strcondition.Append(" and (isnull(SALE,'')='" + SALE + "' or isnull(SALE,'')='') "); + } + else + { + strcondition.Append(" and isnull(SALE,'')='' "); + } + strcondition.Append(" order by SALE desc,BGNDATE ASC "); + + var ClientACCDATEList = GetACCDATEList(strcondition.ToString()); + if (ClientACCDATEList.Count == 0) + { + var _r = new STLDATEmb(); + _r.STLDATE = BUSDATE; + _r.STLNAME = ""; + _r.BSSOURCE = ""; + return _r; + } + else + { + var CA = ClientACCDATEList[0]; + + var _r = new STLDATEmb(); + _r.STLNAME = CA.ACCTYPE; + _r.BSSOURCE = CA.BSSOURCE; + + return _r; + } + + + } + + + #endregion #region 往来单位审核 public static DBResult IC_Start ( List _List, string USERID ) //申请签入