Commit d35bf474 by 徐建业
parents dc493468 3f0149a0
using G.Buss.BaseInfo.Services.ChemotherapySVC; using G.Buss.BaseInfo.Services.ChemotherapySVC;
using G.MES.API.App_Start;
using G.MES.DataModel; using G.MES.DataModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.Http;
namespace G.MES.API.Controllers namespace G.MES.API.Controllers
{ {
...@@ -16,9 +18,30 @@ namespace G.MES.API.Controllers ...@@ -16,9 +18,30 @@ namespace G.MES.API.Controllers
/// <summary> /// <summary>
/// 获取化药结果 /// 获取化药结果
/// </summary> /// </summary>
[HttpGet]
[NoAuthAttribute]
public List<Chemotherapy> GetChemotherapy() public List<Chemotherapy> GetChemotherapy()
{ {
return svc.GetChemotherapy(); return svc.GetChemotherapy();
} }
/// <summary>
/// 导入化疗结果
/// </summary>
/// <returns></returns>
[HttpPost]
[NoAuthAttribute]
public bool ImportChemotherapy()
{
try
{
HttpPostedFile file = HttpContext.Current.Request.Files["Excel"];
return svc.ImportChemotherapy(file);
}
catch (Exception e)
{
throw new Exception("表格导入错误" + e.Message);
}
}
} }
} }
\ No newline at end of file
...@@ -10,6 +10,10 @@ CREATE TABLE [dbo].[Chemotherapy]( ...@@ -10,6 +10,10 @@ CREATE TABLE [dbo].[Chemotherapy](
[Genotype] [VARCHAR](50) NULL, [Genotype] [VARCHAR](50) NULL,
[MedicationPrompts] [TEXT] NULL, [MedicationPrompts] [TEXT] NULL,
[Levels] [VARCHAR](50) NULL, [Levels] [VARCHAR](50) NULL,
[CurrentIndex] [INT] NULL,
[Sys_Create] [DATETIME] NULL,
[ParentOID] [UNIQUEIDENTIFIER] NULL,
[SampleNumber] [INT] NULL,
CONSTRAINT [PK_Chemotherapy] PRIMARY KEY CLUSTERED CONSTRAINT [PK_Chemotherapy] PRIMARY KEY CLUSTERED
( (
[ChemotherapyOID] ASC [ChemotherapyOID] ASC
......
using Chloe.SqlServer; using Chloe.SqlServer;
using G.Buss.BaseInfo.Services.SummarySVC;
using G.MES.DataModel; using G.MES.DataModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
namespace G.Buss.BaseInfo.Services.ChemotherapySVC namespace G.Buss.BaseInfo.Services.ChemotherapySVC
{ {
...@@ -22,5 +25,74 @@ namespace G.Buss.BaseInfo.Services.ChemotherapySVC ...@@ -22,5 +25,74 @@ namespace G.Buss.BaseInfo.Services.ChemotherapySVC
return chemotherapies; return chemotherapies;
} }
} }
public bool ImportChemotherapy(HttpPostedFile file)
{
try
{
DataTable table = SummarySvc.RenderDataTableFromExcel(file.InputStream, 0, 0);
List<Chemotherapy> chemotherapys = new List<Chemotherapy>();
List<string> SampleNumber = new List<string>();
Guid PreOID = Guid.Empty;
for (int i = 0; i < table.Rows.Count; i++)
{
Chemotherapy chemotherapy = new Chemotherapy();
Guid OID = Guid.NewGuid();
if (string.IsNullOrEmpty(table.Rows[i]["药物"].ToString()))
{
if (PreOID == Guid.Empty)
{
throw new Exception("excel第一行数据不能为空");
}
chemotherapy.ParentOID = PreOID;
chemotherapy.ChemotherapyOID = OID;
chemotherapy.DrugPlan = table.Rows[i]["药物"].ToString();
chemotherapy.Gene = table.Rows[i]["基因"].ToString();
chemotherapy.TestSite = table.Rows[i]["检测位点"].ToString();
chemotherapy.Genotype = table.Rows[i]["基因型"].ToString();
chemotherapy.MedicationPrompts = table.Rows[i]["用药提示"].ToString();
chemotherapy.Levels = table.Rows[i]["级别"].ToString();
//summary.Sys_CreateBy = user.Sys_UserOID;
chemotherapy.Sys_Create = DateTime.Now;
chemotherapy.CurrentIndex = i;
}
else
{
chemotherapy.ParentOID = Guid.Empty;
chemotherapy.ChemotherapyOID = OID;
chemotherapy.DrugPlan = table.Rows[i]["药物"].ToString();
chemotherapy.Gene = table.Rows[i]["基因"].ToString();
chemotherapy.TestSite = table.Rows[i]["检测位点"].ToString();
chemotherapy.Genotype = table.Rows[i]["基因型"].ToString();
chemotherapy.MedicationPrompts = table.Rows[i]["用药提示"].ToString();
chemotherapy.Levels = table.Rows[i]["级别"].ToString();
chemotherapy.SampleNumber = table.Rows[i]["受试者ID"].ToString();
chemotherapy.Sys_Create = DateTime.Now;
chemotherapy.CurrentIndex = i;
PreOID = OID;
SampleNumber.Add(chemotherapy.SampleNumber);
}
chemotherapys.Add(chemotherapy);
}
using (var context = new MsSqlContext(sqlConn))
{
List<Chemotherapy> summarie = context.Query<Chemotherapy>().Where(n => SampleNumber.Contains(n.SampleNumber)).ToList();
List<Guid> guids = summarie.Select(n => n.ChemotherapyOID).ToList();
List<string> numbers = summarie.Select(n => n.SampleNumber).ToList();
//删除已存在的数据再重新插入
if (summarie.Any())
{
context.Delete<Chemotherapy>(m => numbers.Contains(m.SampleNumber) || guids.Contains(m.ParentOID));
}
context.InsertRange(chemotherapys);
}
return true;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
} }
} }
...@@ -105,13 +105,10 @@ namespace G.Buss.BaseInfo.Services.ExportWordSVC ...@@ -105,13 +105,10 @@ namespace G.Buss.BaseInfo.Services.ExportWordSVC
/// <summary> /// <summary>
/// 获取化疗药物 /// 获取化疗药物
/// </summary> /// </summary>
public List<Chemotherapy> GetChemotherapyDrugs() public DataTable GetChemotherapyDrugs()
{ {
using (var context = new MsSqlContext(sqlConn)) SqlHelper context = new SqlHelper();
{ return context.ExcuteDatatable("SELECT * FROM dbo.Chemotherapy ORDER BY CurrentIndex ASC", null);
List<Chemotherapy> chemotherapies = context.Query<Chemotherapy>().ToList();
return chemotherapies;
}
} }
/// <summary> /// <summary>
/// 获取遗传风险 /// 获取遗传风险
......
...@@ -94,7 +94,7 @@ namespace G.Buss.BaseInfo.Services.SummarySVC ...@@ -94,7 +94,7 @@ namespace G.Buss.BaseInfo.Services.SummarySVC
} }
} }
private static DataTable RenderDataTableFromExcel(Stream ExcelFileStream, int SheetIndex, int HeaderRowIndex) public static DataTable RenderDataTableFromExcel(Stream ExcelFileStream, int SheetIndex, int HeaderRowIndex)
{ {
XSSFWorkbook workbook = new XSSFWorkbook(ExcelFileStream); XSSFWorkbook workbook = new XSSFWorkbook(ExcelFileStream);
ISheet sheet = workbook.GetSheetAt(SheetIndex); ISheet sheet = workbook.GetSheetAt(SheetIndex);
......
...@@ -33,5 +33,13 @@ namespace G.MES.DataModel ...@@ -33,5 +33,13 @@ namespace G.MES.DataModel
public virtual string MedicationPrompts { get;set; } public virtual string MedicationPrompts { get;set; }
///<summary><summary> ///<summary><summary>
public virtual string Levels { get;set; } public virtual string Levels { get;set; }
///<summary><summary>
public virtual Nullable<int> CurrentIndex { get;set; }
///<summary><summary>
public virtual Nullable<System.DateTime> Sys_Create { get;set; }
///<summary><summary>
public virtual System.Guid ParentOID { get;set; }
///<summary><summary>
public virtual string SampleNumber { get;set; }
} }
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</defaultConnectionFactory> </defaultConnectionFactory>
</entityFramework> </entityFramework>
<connectionStrings> <connectionStrings>
<add name="DbModelEntities" connectionString="metadata=res://*/DbModel.csdl|res://*/DbModel.ssdl|res://*/DbModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=SYSMANAGE;persist security info=True;user id=sa;password=123456;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /> <add name="DbModelEntities" connectionString="metadata=res://*/DbModel.csdl|res://*/DbModel.ssdl|res://*/DbModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=47.96.124.15;initial catalog=JCBB_MB;persist security info=True;user id=sa;password=valtai;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings> </connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup>
<runtime> <runtime>
......
...@@ -61,8 +61,9 @@ namespace G.MES.DataAdapter ...@@ -61,8 +61,9 @@ namespace G.MES.DataAdapter
public DbSet<CodeClassify> CodeClassify { get; set; } public DbSet<CodeClassify> CodeClassify { get; set; }
public DbSet<CodeValue> CodeValue { get; set; } public DbSet<CodeValue> CodeValue { get; set; }
public DbSet<Gene> Gene { get; set; } public DbSet<Gene> Gene { get; set; }
public DbSet<Chemotherapy> Chemotherapy { get; set; }
public DbSet<GeneCorrelation> GeneCorrelation { get; set; } public DbSet<GeneCorrelation> GeneCorrelation { get; set; }
public DbSet<Summary> Summary { get; set; }
public DbSet<ClientInfo> ClientInfo { get; set; } public DbSet<ClientInfo> ClientInfo { get; set; }
public DbSet<Chemotherapy> Chemotherapy { get; set; }
} }
} }
// 为模型“D:\Project\NEWAPI\3.SourceCode\NEWJCBGAPI\G.MES.DbAdapter\DbModel.edmx”启用了 T4 代码生成。 // 为模型“F:\Work\Project\报告系统\Git\ReportingSystemAPI\G.MES.DbAdapter\DbModel.edmx”启用了 T4 代码生成。
// 要启用旧代码生成功能,请将“代码生成策略”设计器属性的值 // 要启用旧代码生成功能,请将“代码生成策略”设计器属性的值
// 更改为“旧的 ObjectContext”。当在设计器中打开该模型时,此属性会出现在 // 更改为“旧的 ObjectContext”。当在设计器中打开该模型时,此属性会出现在
// “属性”窗口中。 // “属性”窗口中。
......
...@@ -41,9 +41,10 @@ ...@@ -41,9 +41,10 @@
<EntityTypeShape EntityType="DbModel.CodeClassify" Width="1.5" PointX="9.375" PointY="9.75" /> <EntityTypeShape EntityType="DbModel.CodeClassify" Width="1.5" PointX="9.375" PointY="9.75" />
<EntityTypeShape EntityType="DbModel.CodeValue" Width="1.5" PointX="11.375" PointY="4.75" /> <EntityTypeShape EntityType="DbModel.CodeValue" Width="1.5" PointX="11.375" PointY="4.75" />
<EntityTypeShape EntityType="DbModel.Gene" Width="1.5" PointX="11.375" PointY="9.75" /> <EntityTypeShape EntityType="DbModel.Gene" Width="1.5" PointX="11.375" PointY="9.75" />
<EntityTypeShape EntityType="DbModel.Chemotherapy" Width="1.5" PointX="0.75" PointY="13.75" />
<EntityTypeShape EntityType="DbModel.GeneCorrelation" Width="1.5" PointX="3.375" PointY="13.75" /> <EntityTypeShape EntityType="DbModel.GeneCorrelation" Width="1.5" PointX="3.375" PointY="13.75" />
<EntityTypeShape EntityType="DbModel.Summary" Width="1.5" PointX="9.375" PointY="14.75" />
<EntityTypeShape EntityType="DbModel.ClientInfo" Width="1.5" PointX="13.375" PointY="0.75" /> <EntityTypeShape EntityType="DbModel.ClientInfo" Width="1.5" PointX="13.375" PointY="0.75" />
<EntityTypeShape EntityType="DbModel.Chemotherapy" Width="1.5" PointX="0.75" PointY="13.75" />
</Diagram> </Diagram>
</edmx:Diagrams> </edmx:Diagrams>
......
...@@ -18,7 +18,7 @@ namespace WordByDocx.Word ...@@ -18,7 +18,7 @@ namespace WordByDocx.Word
{ {
Spire.Doc.Document document = new Spire.Doc.Document(); Spire.Doc.Document document = new Spire.Doc.Document();
document.LoadFromFile(BaseDic); document.LoadFromFile(BaseDic);
Guid guids = new Guid("7AFD11CC-259F-438B-B5DC-3469C891C5F0"); Guid guids = new Guid("09B141B3-2E2A-4DF7-A9B9-B281B7AC0DAE");
ReplaceText replaceText = new ReplaceText(document); ReplaceText replaceText = new ReplaceText(document);
replaceText.ReplaceUserInfo(guids); replaceText.ReplaceUserInfo(guids);
replaceText.ReplaceTMBTable(); replaceText.ReplaceTMBTable();
...@@ -27,6 +27,7 @@ namespace WordByDocx.Word ...@@ -27,6 +27,7 @@ namespace WordByDocx.Word
replaceText.ReplaceChemicalMedicineReferences(); replaceText.ReplaceChemicalMedicineReferences();
replaceText.ReplaceGeneList(); replaceText.ReplaceGeneList();
replaceText.ReplaceSummary(); replaceText.ReplaceSummary();
replaceText.ReplaceChemotherapy();
document.SaveToFile(OutDic + "out.docx"); document.SaveToFile(OutDic + "out.docx");
using (var documentDocx = DocX.Load(OutDic + "out.docx")) using (var documentDocx = DocX.Load(OutDic + "out.docx"))
{ {
......
...@@ -44,6 +44,15 @@ namespace WordByDocx.Word ...@@ -44,6 +44,15 @@ namespace WordByDocx.Word
} }
/// <summary> /// <summary>
/// 获取化疗结果
/// </summary>
/// <returns></returns>
public static DataTable GetChemotherapy()
{
return svc.GetChemotherapyDrugs();
}
/// <summary>
/// 获取TMB表格(这里不考虑线程的问题) /// 获取TMB表格(这里不考虑线程的问题)
/// </summary> /// </summary>
public static List<TMBTable> GetTMBTable() public static List<TMBTable> GetTMBTable()
......
...@@ -80,7 +80,7 @@ namespace WordByDocx.Word ...@@ -80,7 +80,7 @@ namespace WordByDocx.Word
p3.AppendText(heards[i]); p3.AppendText(heards[i]);
} }
bool mergeFlag = false; bool mergeFlag = false;
Guid preOID = Guid.Empty; string preOID = string.Empty;
for (int r = 0; r < summaries.Rows.Count; r++) for (int r = 0; r < summaries.Rows.Count; r++)
{ {
TableRow dataRow = table.Rows[r + 1]; TableRow dataRow = table.Rows[r + 1];
...@@ -90,14 +90,77 @@ namespace WordByDocx.Word ...@@ -90,14 +90,77 @@ namespace WordByDocx.Word
dataRow.Cells[i].CellFormat.VerticalAlignment = Spire.Doc.Documents.VerticalAlignment.Middle; dataRow.Cells[i].CellFormat.VerticalAlignment = Spire.Doc.Documents.VerticalAlignment.Middle;
Paragraph p = dataRow.Cells[i].AddParagraph(); Paragraph p = dataRow.Cells[i].AddParagraph();
p.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center; p.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
p.AppendText(summaries.Rows[r][tableHeards[i]].ToString()); string val = summaries.Rows[r][tableHeards[i]].ToString();
p.AppendText(val);
if (string.IsNullOrEmpty(val))
{
table.ApplyVerticalMerge(i, r, r + 1);
}
//else
//{
// preOID = summaries.Rows[r]["SummaryOID"].ToString();
//}
} }
} }
body.ChildObjects.Remove(paragraph); body.ChildObjects.Remove(paragraph);
body.ChildObjects.Insert(index, table); body.ChildObjects.Insert(index, table);
} }
/// <summary>
/// 替换化疗结果
/// </summary>
public void ReplaceChemotherapy()
{
DataTable summaries = GetData.GetChemotherapy();
string[] heards = new string[] { "药物", "基因", "检测位点", "基因型", "用药提示", "级别" };
string[] tableHeards = new string[] { "DrugPlan", "Gene", "TestSite", "Genotype", "MedicationPrompts", "Levels" };
Section section = document.Sections[0];
TextSelection selection = document.FindString("#{Chemotherapy}", true, true);
TextRange range = selection.GetAsOneRange();
Paragraph paragraph = range.OwnerParagraph;
Body body = paragraph.OwnerTextBody;
int index = body.ChildObjects.IndexOf(paragraph);
Table table = section.AddTable(true);
table.ResetCells(summaries.Rows.Count + 1, heards.Length);
//填充数据与样式
for (int i = 0; i < heards.Length; i++)
{
TableRow Frow = table.Rows[0];
Frow.IsHeader = true;
Frow.Height = 30;
Frow.HeightType = TableRowHeightType.Exactly;
Frow.RowFormat.BackColor = Color.LightGoldenrodYellow;
Frow.Cells[i].CellFormat.VerticalAlignment = Spire.Doc.Documents.VerticalAlignment.Middle;
Paragraph p3 = Frow.Cells[i].AddParagraph();
p3.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
p3.AppendText(heards[i]);
}
bool mergeFlag = false;
string preOID = string.Empty;
for (int r = 0; r < summaries.Rows.Count; r++)
{
TableRow dataRow = table.Rows[r + 1];
dataRow.Height = 25;
for (int i = 0; i < tableHeards.Length; i++)
{
dataRow.Cells[i].CellFormat.VerticalAlignment = Spire.Doc.Documents.VerticalAlignment.Middle;
Paragraph p = dataRow.Cells[i].AddParagraph();
p.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
string val = summaries.Rows[r][tableHeards[i]].ToString();
p.AppendText(val);
if (string.IsNullOrEmpty(val))
{
table.ApplyVerticalMerge(i, r, r + 1);
}
//else
//{
// preOID = summaries.Rows[r]["SummaryOID"].ToString();
//}
}
}
body.ChildObjects.Remove(paragraph);
body.ChildObjects.Insert(index, table);
}
/// <summary> /// <summary>
/// 替换TMB表格 /// 替换TMB表格
/// </summary> /// </summary>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论