改太多
This commit is contained in:
1 parent
be5352efed
commit
1cb2a7a35e
48 files changed
+17970
-485
No files matched your search
@@ -1,17 +1,21 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml.Office2010.PowerPoint;
|
||||
//using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
//using DocumentFormat.OpenXml.Office2010.PowerPoint;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
//using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PagedList;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
|
||||
/// <summary>
|
||||
/// shuwensController 的摘要描述
|
||||
@@ -146,13 +150,31 @@ public class shuwensController : BaseApiController
|
||||
public IHttpActionResult RenderShuWenByGong([FromBody] dynamic data)
|
||||
{
|
||||
var jsonData = data;
|
||||
var nums = (string)jsonData.activitynum;
|
||||
string[] numSplit = nums.Split(',');
|
||||
|
||||
var mode=(string)jsonData.mode;
|
||||
var xStart=(jsonData==null||jsonData.xStart==null)?"":(string)jsonData.xStart;
|
||||
var sStart = (jsonData == null || jsonData.sStart==null) ? "" : (string)jsonData.sStart;
|
||||
mode = "A";
|
||||
StringBuilder sb= new StringBuilder();
|
||||
List<int> args = new List<int>();
|
||||
List<string> parameters =new List<string>();
|
||||
List<SqlParameter> parameterList = new List<SqlParameter>();
|
||||
int a = 1;
|
||||
foreach (var num in numSplit)
|
||||
{
|
||||
args.Append(int.Parse(num));
|
||||
parameterList.Add(new SqlParameter($"num{a}", num));
|
||||
parameters.Add($"@num{a}");
|
||||
a++;
|
||||
}
|
||||
|
||||
|
||||
sb.Append("with gong as (select* from pro_order_detail ");
|
||||
sb.Append("where order_no in (select order_no from pro_order ");
|
||||
sb.Append("where activity_num in (72, 73)) ");
|
||||
sb.Append("and(actItem_num in ");
|
||||
sb.Append($"where activity_num in ({string.Join(",",parameters.ToArray())})) ");
|
||||
sb.Append("and (actItem_num in ");
|
||||
sb.Append("(select item_num from act_bom a ");
|
||||
sb.Append("left join actItem b on a.item_num = b.num ");
|
||||
sb.Append("where a.package_num is null)) ");
|
||||
@@ -160,13 +182,19 @@ public class shuwensController : BaseApiController
|
||||
sb.Append("select * from pro_order_detail a ");
|
||||
sb.Append("where (num in (select num from gong) ");
|
||||
sb.Append("or parent_num in (select num from gong)) ");
|
||||
var list=_db.Database.SqlQuery<Model.pro_order_detail>(sb.ToString()).ToList();
|
||||
Console.WriteLine(sb.ToString());
|
||||
var list=_db.Database.SqlQuery<Model.pro_order_detail>(sb.ToString(), parameterList.ToArray()).ToList();
|
||||
var head_list=list.Where(x=>x.parent_num==null).ToList();//消災,要參數化
|
||||
|
||||
var qry = _db.TabletStyleDetail.AsQueryable();
|
||||
var styles = qry.ToList();
|
||||
var ret = new object() { };
|
||||
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create("d://HelloWorld.docx", WordprocessingDocumentType.Document))
|
||||
if( !Directory.Exists( Path.Combine(HttpContext.Current.Server.MapPath("~/rpt"), "shuwen")))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(HttpContext.Current.Server.MapPath("~/rpt"), "shuwen"));
|
||||
}
|
||||
string templatePath = Path.Combine(HttpContext.Current.Server.MapPath("~/rpt"), "shuwen", "template.docx");
|
||||
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(templatePath, WordprocessingDocumentType.Document))
|
||||
{
|
||||
// Add a main document part
|
||||
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
|
||||
@@ -175,10 +203,31 @@ public class shuwensController : BaseApiController
|
||||
|
||||
List<string> result = new List<string>();
|
||||
var nowContent = new List<string>();
|
||||
|
||||
Paragraph para0 = new Paragraph();
|
||||
Run run0 = new Run();
|
||||
RunProperties runProps0 = new RunProperties(
|
||||
new Bold(),
|
||||
new FontSize() { Val = "36" },
|
||||
new RunFonts()
|
||||
{
|
||||
Ascii = "DFKai-SB", // 英數字型使用標楷體
|
||||
EastAsia = "DFKai-SB" // 中文字型使用標楷體
|
||||
}
|
||||
);
|
||||
run0.Append(runProps0);
|
||||
for (int gg=1;gg<=12;gg++)
|
||||
{
|
||||
Text txt = new Text($" ") { Space = DocumentFormat.OpenXml.SpaceProcessingModeValues.Preserve };
|
||||
run0.AppendChild(txt);
|
||||
}
|
||||
run0.AppendChild(new Text($"消災祈福名單"));
|
||||
para0.Append(run0);
|
||||
body.AppendChild(para0);
|
||||
foreach (var item in head_list)
|
||||
{
|
||||
//消災牌位
|
||||
var detail_list = list.Where(x => x.parent_num == item.num && x.print_id.Contains("X")).ToList();
|
||||
var detail_list = list.Where(x => x.parent_num == item.num && x.print_id.Contains(xStart)).ToList();
|
||||
|
||||
foreach (var d in detail_list)
|
||||
{
|
||||
@@ -360,115 +409,9 @@ public class shuwensController : BaseApiController
|
||||
if (leftItemsArray != null && leftItemsArray.Count > 0)
|
||||
nowContent.Add(string.Join(" ", leftItemsArray.Select(token => token["fam_name"]?.ToString().Replace("\r", "").Replace("\n", ""))) + ";");
|
||||
}
|
||||
//if (nowContent.Count > 6)
|
||||
//{
|
||||
// Paragraph para1 = new Paragraph();
|
||||
// //Run run1 = para1.AppendChild(new Run());
|
||||
// Run run1 = new Run();
|
||||
// RunProperties runProps1 = new RunProperties(
|
||||
// //new Bold(),
|
||||
// //new Italic(),
|
||||
// new FontSize() { Val = "36" }, // 12 pt
|
||||
// //new Color() { Val = "FF0000" }, // Red Text
|
||||
// new RunFonts()
|
||||
// {
|
||||
// Ascii = "DFKai-SB", // 英數字型使用標楷體
|
||||
// EastAsia = "DFKai-SB" // 中文字型使用標楷體
|
||||
// }
|
||||
// );
|
||||
|
||||
// // 建立段落屬性
|
||||
// ParagraphProperties pPr1 = new ParagraphProperties();
|
||||
// pPr1.Append(new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft });
|
||||
// // 建立縮排物件
|
||||
// // 設定左縮排為 0,首行縮排 480 dxa (約 2 中文字寬)
|
||||
// Indentation ind = new Indentation() { Left = "720", LeftChars = 300 };
|
||||
|
||||
// // 將縮排加入段落屬性
|
||||
// pPr1.Append(ind);
|
||||
// para1.Append(pPr1);
|
||||
// run1.Append(runProps1);
|
||||
// string[] splits = string.Join("", nowContent).Split(';');
|
||||
// int j = 0;
|
||||
// foreach (var txt in splits)
|
||||
// {
|
||||
// run1.Append(new Text($"{string.Join(" ", txt)}"));
|
||||
// if (j != splits.Length - 1)
|
||||
// {
|
||||
// run1.Append(new Break());
|
||||
// }
|
||||
// j++;
|
||||
// }
|
||||
// para1.Append(run1);
|
||||
// body.AppendChild(para1);
|
||||
// nowContent.Clear();
|
||||
//}
|
||||
//if(string.Join(" ",nowContent).Length > 6)
|
||||
//{
|
||||
// if (result.Count > 0)
|
||||
// {
|
||||
// Paragraph para = body.AppendChild(new Paragraph());
|
||||
// Run run = para.AppendChild(new Run());
|
||||
// RunProperties runProps = new RunProperties(
|
||||
// //new Bold(),
|
||||
// //new Italic(),
|
||||
// new FontSize() { Val = "36" }, // 12 pt
|
||||
// //new Color() { Val = "FF0000" }, // Red Text
|
||||
// new RunFonts()
|
||||
// {
|
||||
// Ascii = "DFKai-SB", // 英數字型使用標楷體
|
||||
// EastAsia = "DFKai-SB" // 中文字型使用標楷體
|
||||
// }
|
||||
// );
|
||||
// run.Append(runProps);
|
||||
// run.AppendChild(new Text($"{string.Join(" ", result)}"));
|
||||
// }
|
||||
// result = new List<string>();
|
||||
|
||||
|
||||
// Paragraph para1 = body.AppendChild(new Paragraph());
|
||||
// Run run1 = para1.AppendChild(new Run());
|
||||
// RunProperties runProps1 = new RunProperties(
|
||||
// //new Bold(),
|
||||
// //new Italic(),
|
||||
// new FontSize() { Val = "36" }, // 12 pt
|
||||
// //new Color() { Val = "FF0000" }, // Red Text
|
||||
// new RunFonts()
|
||||
// {
|
||||
// Ascii = "DFKai-SB", // 英數字型使用標楷體
|
||||
// EastAsia = "DFKai-SB" // 中文字型使用標楷體
|
||||
// }
|
||||
// );
|
||||
// run1.Append(runProps1);
|
||||
// run1.AppendChild(new Text($"{string.Join(" ", nowContent)}"));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// result.AddRange(nowContent);
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
//if (result.Count > 5)
|
||||
//{
|
||||
// Paragraph para = body.AppendChild(new Paragraph());
|
||||
// Run run = para.AppendChild(new Run());
|
||||
// RunProperties runProps = new RunProperties(
|
||||
// //new Bold(),
|
||||
// //new Italic(),
|
||||
// new FontSize() { Val = "36" }, // 12 pt
|
||||
// //new Color() { Val = "FF0000" }, // Red Text
|
||||
// new RunFonts()
|
||||
// {
|
||||
// Ascii = "DFKai-SB", // 英數字型使用標楷體
|
||||
// EastAsia = "DFKai-SB" // 中文字型使用標楷體
|
||||
// }
|
||||
// );
|
||||
// run.Append(runProps);
|
||||
// run.AppendChild(new Text($"{string.Join(" ", result)}"));
|
||||
|
||||
// result = new List<string>();
|
||||
//}
|
||||
|
||||
if (nowContent.Count > 10000)
|
||||
{
|
||||
Paragraph para1 = new Paragraph();
|
||||
@@ -524,7 +467,7 @@ public class shuwensController : BaseApiController
|
||||
if (nowContent.Count > 0)
|
||||
{
|
||||
Paragraph para1 = new Paragraph();
|
||||
//Run run1 = para1.AppendChild(new Run());
|
||||
|
||||
Run run1 = new Run();
|
||||
RunProperties runProps1 = new RunProperties(
|
||||
//new Bold(),
|
||||
@@ -572,27 +515,7 @@ public class shuwensController : BaseApiController
|
||||
body.AppendChild(para1);
|
||||
nowContent.Clear();
|
||||
}
|
||||
//if (result.Count > 0)
|
||||
//{
|
||||
// Paragraph para = body.AppendChild(new Paragraph());
|
||||
// Run run = para.AppendChild(new Run());
|
||||
// RunProperties runProps = new RunProperties(
|
||||
// //new Bold(),
|
||||
// //new Italic(),
|
||||
// new FontSize() { Val = "36" }, // 12 pt
|
||||
// //new Color() { Val = "FF0000" }, // Red Text
|
||||
// new RunFonts()
|
||||
// {
|
||||
// Ascii = "DFKai-SB", // 英數字型使用標楷體
|
||||
// EastAsia = "DFKai-SB" // 中文字型使用標楷體
|
||||
// }
|
||||
// );
|
||||
// run.Append(runProps);
|
||||
// run.AppendChild(new Text($"{string.Join(" ", result)}"));
|
||||
|
||||
// result = new List<string>();
|
||||
//}
|
||||
|
||||
|
||||
Paragraph pageBreakParagraph = new Paragraph(
|
||||
new Run(
|
||||
new Break() { Type = BreakValues.Page }
|
||||
@@ -603,11 +526,31 @@ public class shuwensController : BaseApiController
|
||||
body.Append(pageBreakParagraph);
|
||||
//先強制換頁
|
||||
//在處理超薦牌位
|
||||
Paragraph para9 = new Paragraph();
|
||||
Run run9 = new Run();
|
||||
RunProperties runProps9 = new RunProperties(
|
||||
new Bold(),
|
||||
new FontSize() { Val = "36" },
|
||||
new RunFonts()
|
||||
{
|
||||
Ascii = "DFKai-SB", // 英數字型使用標楷體
|
||||
EastAsia = "DFKai-SB" // 中文字型使用標楷體
|
||||
}
|
||||
);
|
||||
run9.Append(runProps9);
|
||||
for (int gg = 1; gg <= 12; gg++)
|
||||
{
|
||||
Text txt= new Text($" ") { Space = DocumentFormat.OpenXml.SpaceProcessingModeValues.Preserve };
|
||||
run9.AppendChild(txt);
|
||||
}
|
||||
run9.AppendChild(new Text($"佛力超薦名單"));
|
||||
para9.Append(run9);
|
||||
body.AppendChild(para9);
|
||||
result = new List<string>();
|
||||
foreach (var item in head_list)
|
||||
{
|
||||
//S要參數化
|
||||
var detail_list = list.Where(x => x.parent_num == item.num && x.print_id.Contains("S")).ToList();
|
||||
var detail_list = list.Where(x => x.parent_num == item.num && x.print_id.Contains(sStart)).ToList();
|
||||
|
||||
//分兩種,一種每一張呈現,一種同樣陽上的拚在一起
|
||||
foreach(var d in detail_list)
|
||||
@@ -857,9 +800,9 @@ public class shuwensController : BaseApiController
|
||||
run1.Append(runProps1);
|
||||
string[] splits = string.Join("", nowContent).Split(';');
|
||||
int j = 0;
|
||||
foreach (var txt in splits)
|
||||
foreach (var txt1 in splits)
|
||||
{
|
||||
run1.Append(new Text($"{string.Join(" ", txt)}"));
|
||||
run1.Append(new Text($"{string.Join(" ", txt1)}"));
|
||||
if (j != splits.Length - 1)
|
||||
{
|
||||
run1.Append(new Break());
|
||||
@@ -900,7 +843,8 @@ public class shuwensController : BaseApiController
|
||||
}
|
||||
);
|
||||
run2.Append(runProps2);
|
||||
run2.AppendChild(new Text($"陽上報恩人 "));
|
||||
Text txt = new Text($"陽上報恩人 ") { Space = DocumentFormat.OpenXml.SpaceProcessingModeValues.Preserve };
|
||||
run2.AppendChild(txt);
|
||||
|
||||
Run run4 = para2.AppendChild(new Run());
|
||||
RunProperties runProps4 = new RunProperties(
|
||||
@@ -951,7 +895,8 @@ public class shuwensController : BaseApiController
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
list= head_list
|
||||
//list= head_list,
|
||||
filePath="/rpt/shuwen/template.docx"
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user