227 lines
8.2 KiB
C#
227 lines
8.2 KiB
C#
|
|
using dccdc.BLL;
|
|
using dccdc.Models;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Spire.Pdf;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
namespace dccdc.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 肺功能
|
|
/// </summary>
|
|
public class pftController : Controller
|
|
{
|
|
/// <summary>
|
|
/// 获取人员信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult getPeopleInfo(string physicalNum)
|
|
{
|
|
BLL.ProfessionalExamRegisterBll bll = new BLL.ProfessionalExamRegisterBll();
|
|
BLL.professionalExam_project_resultBll pr = new BLL.professionalExam_project_resultBll();
|
|
// 查询登记信息
|
|
Models.ProfessionalExamRegisterModel pe = bll.getModel(physicalNum);
|
|
// 查询体检人员体检项目
|
|
System.Collections.Generic.List<Models.ProfessionalExamProjectResultModel> lists = pr.getPersonResult(pe.id, null);
|
|
string height = "";
|
|
string weight = "";
|
|
|
|
lists.ForEach(item =>
|
|
{
|
|
if (item.project_name.Contains("身高"))
|
|
{
|
|
height = item.project_result;
|
|
}
|
|
if (item.project_name.Contains("体重"))
|
|
{
|
|
weight = item.project_result;
|
|
}
|
|
});
|
|
FileStream fsw = new FileStream("C:/进行了获取.txt", FileMode.OpenOrCreate);
|
|
//字符串转byte[]
|
|
byte[] writeBytes = Encoding.UTF8.GetBytes(DateTime.Now.ToString());
|
|
//写入
|
|
//fsw.Write(null, 0, 0);
|
|
fsw.Write(writeBytes, 0, writeBytes.Length);
|
|
//关闭文件流
|
|
fsw.Close();
|
|
return new JsonResult()
|
|
{
|
|
Data = new
|
|
{
|
|
physicalNum = pe.physical_num,
|
|
sex = pe.sex,
|
|
age = pe.person_age,
|
|
birthday = pe.birth,
|
|
address = pe.home_address,
|
|
height,
|
|
weight,
|
|
name = pe.person_name,
|
|
phone = pe.phone
|
|
},
|
|
JsonRequestBehavior = JsonRequestBehavior.AllowGet
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传结果报告
|
|
/// </summary>
|
|
/// <param name="physicalNum">体检编号</param>
|
|
/// <param name="resultValue">检查结果</param>
|
|
/// <param name="file">文件base64</param>
|
|
/// <returns></returns>
|
|
public string putReport(string physicalNum, string resultValue)
|
|
{
|
|
var fs = HttpContext.Request.Files;
|
|
string path = "file/pft/" + DateTime.Now.ToString("yyMMdd") + "/";
|
|
|
|
if (!Directory.Exists(Server.MapPath("~/" + path)))
|
|
{
|
|
Directory.CreateDirectory(Server.MapPath("~/" + path));
|
|
}
|
|
|
|
StringBuilder retmsg = new StringBuilder();
|
|
retmsg.Append("\r\n -------physicalNum:").Append(physicalNum);
|
|
retmsg.Append("\r\n -------resultValue:").Append(resultValue);
|
|
//retmsg.Append("\r\n -------file:").Append(file);
|
|
|
|
|
|
FileStream fsw = new FileStream("C:/参数查看.txt", FileMode.OpenOrCreate);
|
|
//字符串转byte[]
|
|
byte[] writeBytes = Encoding.UTF8.GetBytes(retmsg.ToString());
|
|
//写入
|
|
fsw.Write(writeBytes, 0, writeBytes.Length);
|
|
//关闭文件流
|
|
fsw.Close();
|
|
|
|
BLL.ProfessionalExamRegisterBll bll = new BLL.ProfessionalExamRegisterBll();
|
|
BLL.professionalExam_project_resultBll pr = new BLL.professionalExam_project_resultBll();
|
|
// 查询登记信息
|
|
Models.ProfessionalExamRegisterModel pe = bll.getModel(physicalNum);
|
|
if (null == pe)
|
|
{
|
|
return "failed:无此条码";
|
|
}
|
|
// 查询体检人员体检项目
|
|
//List<Models.ProfessionalExamProjectResultModel> lists = pr.getPersonResult(pe.id, null);
|
|
List<ProfessionalExamProjectResultModel> lists = new BLL.ProfessionalExamRegisterBll().getResult(physicalNum);
|
|
|
|
|
|
JObject v = (JObject)JsonConvert.DeserializeObject(resultValue);
|
|
int projectId = 0;
|
|
int projectResultId = 0;
|
|
|
|
//bool FEV1, FVC, FEV1_FVC;
|
|
// 获取相对应的数据
|
|
lists.ForEach(item =>
|
|
{
|
|
//FEV1 = item.project_name == "FEV1%" && jp.Name == "FEV_1";
|
|
//FVC = item.project_name == "FVC%" && jp.Name == "FVC";
|
|
//FEV1_FVC = item.project_name == "FEV1/FVC%" && jp.Name == "FEV_1_100";
|
|
//if (FEV1 || FVC || FEV1_FVC)
|
|
//{
|
|
// item.project_result = jp.Value.ToString();
|
|
// pr.updatePft(item);
|
|
// if (FVC)
|
|
// {
|
|
// projectId = int.Parse(item.project_id);
|
|
// projectResultId = item.id;
|
|
// }
|
|
// return;
|
|
//}
|
|
|
|
foreach (var jp in v.Properties())
|
|
{
|
|
if (item.special_conf == jp.Name)
|
|
{
|
|
item.project_result = jp.Value.ToString();
|
|
pr.updatePft(item);
|
|
if (item.special_conf == "FVC")
|
|
{
|
|
projectId = int.Parse(item.project_id);
|
|
projectResultId = item.id;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
if (fs.Count > 0)
|
|
{
|
|
path += physicalNum + ".jpg";
|
|
|
|
//Aspose.Pdf.License l = new Aspose.Pdf.License();
|
|
//string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
|
|
//l.SetLicense("");
|
|
//Aspose.Pdf.Document document = new Aspose.Pdf.Document(fs[0].InputStream);
|
|
//var device = new Aspose.Pdf.Devices.JpegDevice();
|
|
|
|
//for (var i = 1; i <= document.Pages.Count; i++)
|
|
//{
|
|
// FileStream fsJpg = new FileStream(Server.MapPath("~/" + path), FileMode.OpenOrCreate);
|
|
// try
|
|
// {
|
|
// device.Process(document.Pages[i], fsJpg);
|
|
// fsJpg.Close();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// fsJpg.Close();
|
|
// System.IO.File.Delete(Server.MapPath("~/" + path));
|
|
// }
|
|
//}
|
|
|
|
//初始化一个PdfDocument类实例,并加载PDF文档
|
|
|
|
PdfDocument doc = new PdfDocument();
|
|
|
|
doc.LoadFromStream(fs[0].InputStream);
|
|
|
|
|
|
|
|
//遍历PDF每一页
|
|
|
|
for (int i = 0; i < doc.Pages.Count; i++)
|
|
{
|
|
//将PDF页转换成Bitmap图形
|
|
|
|
System.Drawing.Image bmp = doc.SaveAsImage(i);
|
|
|
|
//将Bitmap图形保存为Png格式的图片
|
|
|
|
//string fileName = string.Format("Page-{0}.png", i + 1);
|
|
|
|
bmp.Save(Server.MapPath("~/" + path), System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//fs[0].SaveAs(Server.MapPath("~/" + path));
|
|
// 将文件插入到result_img表
|
|
List<ProfessionalExamProjectResultImgsModel> list = new List<ProfessionalExamProjectResultImgsModel>();
|
|
ProfessionalExamProjectResultImgsModel resImg = new ProfessionalExamProjectResultImgsModel();
|
|
|
|
resImg.img_path = path;
|
|
resImg.img_type = "肺功能图片";
|
|
resImg.person_id = int.Parse(pe.id);
|
|
resImg.project_id = projectId;
|
|
resImg.project_result_id = projectResultId;
|
|
list.Add(resImg);
|
|
|
|
new professionalExamProjectResultImgsBll().saveResultImgs(list);
|
|
}
|
|
|
|
return "ok";
|
|
}
|
|
|
|
}
|
|
} |