using dccdc.DAL; using dccdc.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using ZWL.Common; using dccdc.BLL; using System.IO; using System.Data; namespace dccdc.Controllers { public class DataInputController : Controller { // GET: DataInput public ActionResult Index() { return View(); } public ActionResult NCZSJ() { return View(); } public string uploadNczsjHistory() { if (Request.Files.Count == 0) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有要处理的文件" }); } else { try { string path = Server.MapPath("~/exec/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = path + Guid.NewGuid().ToString("N") + Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf(".")); Request.Files[0].SaveAs(path); DataTable[] dts = xiaoy.Excel.ExcelFile.GetData(path, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes, false); var bll = new BLL.NCZSJBll(); var erpUser = Session["loginUser"] as Models.ERPUser; for (int i = 0; i < dts[0].Rows.Count; i++) { if (string.IsNullOrEmpty(dts[0].Rows[i]["卡片编号"].ToString())) continue; NCZSJModel oh = new NCZSJModel(); oh.id = 0; oh.bgdw = dts[0].Rows[i]["报告单位"].ToString(); oh.yxzjh = dts[0].Rows[i]["身份证号码"].ToString(); oh.icd10 = dts[0].Rows[i]["ICD-10编码"].ToString(); oh.icdname = dts[0].Rows[i]["ICD-10名称"].ToString(); oh.hzxm = dts[0].Rows[i]["姓名"].ToString(); oh.xb = dts[0].Rows[i]["性别"].ToString(); oh.csrq = DateTime.Parse(dts[0].Rows[i]["出生日期"].ToString()); oh.nl = dts[0].Rows[i]["年龄(周岁/月/天)"].ToString(); oh.xxzz = dts[0].Rows[i]["常住详细住址"].ToString(); oh.zzbm = dts[0].Rows[i]["常住地址编码"].ToString(); oh.tkys = dts[0].Rows[i]["报卡医师"].ToString(); oh.zd = dts[0].Rows[i]["脑卒中诊断"].ToString(); oh.bklrsj = Convert.ToDateTime(dts[0].Rows[i]["报卡日期"].ToString()); oh.kpbm = dts[0].Rows[i]["卡片编号"].ToString(); bll.save(oh, erpUser); } } catch (Exception ex) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "处理结果文件失败!" + ex.Message }); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "处理上报结果成功!" }); } } public ActionResult DataInputInfo() { return View(); } public JsonResult getNCZSJ(int page, int pagesize, string key) { var bll = new BLL.NCZSJBll(); List ctList = bll.getList(page, pagesize, key); var c = bll.getCount(key); return Json(new { Rows = ctList, Total = c }); } public ActionResult crbsj() { return View(); } public string uploadcrbsjHistory() { if (Request.Files.Count == 0) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有要处理的文件" }); } else { try { string path = Server.MapPath("~/exec/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = path + Guid.NewGuid().ToString("N") + Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf(".")); Request.Files[0].SaveAs(path); DataTable[] dts = xiaoy.Excel.ExcelFile.GetData(path, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes, false); var bll = new BLL.crbsjBll(); var erpUser = Session["loginUser"] as Models.ERPUser; for (int i = 0; i < dts[0].Rows.Count; i++) { crbsjModel oh = new crbsjModel(); oh.id = 0; oh.kpdm = dts[0].Rows[i]["卡片编号"].ToString(); oh.hzxm = dts[0].Rows[i]["患者姓名"].ToString(); oh.jzxm = dts[0].Rows[i]["患儿家长姓名"].ToString(); oh.yxzjh = dts[0].Rows[i]["有效证件号"].ToString(); oh.xb = dts[0].Rows[i]["性别"].ToString(); oh.csrq = dts[0].Rows[i]["出生日期"].ToString(); oh.nl = dts[0].Rows[i]["年龄"].ToString(); oh.gzdw = dts[0].Rows[i]["患者工作单位"].ToString(); oh.lxdh = dts[0].Rows[i]["联系电话"].ToString(); oh.zzbm = dts[0].Rows[i]["现住地址国标"].ToString(); oh.xxzz = dts[0].Rows[i]["现住详细地址"].ToString(); oh.rqfl = dts[0].Rows[i]["人群分类"].ToString(); oh.zd = dts[0].Rows[i]["疾病名称"].ToString(); oh.zdsj = DateTime.Parse(dts[0].Rows[i]["诊断时间"].ToString()); oh.tkys = dts[0].Rows[i]["填卡医生"].ToString(); oh.bgdw = dts[0].Rows[i]["报告单位"].ToString(); oh.bklrsj = dts[0].Rows[i]["报告卡录入时间"].ToString(); bll.save(oh, erpUser); } } catch (Exception ex) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "处理结果文件失败!" + ex.Message }); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "处理上报结果成功!" }); } } public JsonResult getcrbsj(int page, int pagesize, string key) { var bll = new BLL.crbsjBll(); List ctList = bll.getList(page, pagesize, key); var c = bll.getCount(key); return Json(new { Rows = ctList,Total=c }); } public ActionResult zldata() { return View(); } public string uploadZLHistory() { if (Request.Files.Count == 0) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有要处理的文件" }); } else { var erpUser = Session["loginUser"] as Models.ERPUser; /* byte[] buffer = new byte[1024]; MemoryStream ms = new MemoryStream(); while (true) { int sz = Request.Files[0].InputStream.Read(buffer, 0, 1024); if (sz == 0) break; ms.Write(buffer, 0, sz); } ms.Position = 0;*/ try { string path = Server.MapPath("~/exec/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = path + Guid.NewGuid().ToString("N") + Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf(".")); Request.Files[0].SaveAs(path); DataTable[] dts = xiaoy.Excel.ExcelFile.GetData(path, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes, false); new DAL.DataInput().uploadOldDatazl(dts[0],erpUser.TrueName); } catch (Exception ex) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "处理结果文件失败!" + ex.Message }); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "处理上报结果成功!" }); } } public string getZLSJ(string key,int page,int pagesize) { var dal = new DAL.DataInput(); var list = dal.getzlListPage(page, pagesize, key); int c = dal.getzlcount(key); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = list, Total = c }); } public ActionResult gxbsj() { return View(); } public string uploadgxbsjHistory() { if (Request.Files.Count == 0) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有要处理的文件" }); } else { try { string path = Server.MapPath("~/exec/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = path + Guid.NewGuid().ToString("N") + Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf(".")); Request.Files[0].SaveAs(path); DataTable[] dts = xiaoy.Excel.ExcelFile.GetData(path, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes, false); var bll = new BLL.NCZSJBll(); var erpUser = Session["loginUser"] as Models.ERPUser; for (int i = 0; i < dts[0].Rows.Count; i++) { if (string.IsNullOrEmpty(dts[0].Rows[i]["卡片编号"].ToString())) continue; NCZSJModel oh = new NCZSJModel(); oh.id = 0; oh.bgdw = dts[0].Rows[i]["报告单位"].ToString(); oh.yxzjh = dts[0].Rows[i]["身份证号码"].ToString(); oh.icd10 = dts[0].Rows[i]["ICD-10编码"].ToString(); oh.icdname = dts[0].Rows[i]["ICD-10名称"].ToString(); oh.hzxm = dts[0].Rows[i]["姓名"].ToString(); oh.xb = dts[0].Rows[i]["性别"].ToString(); oh.csrq = DateTime.Parse(dts[0].Rows[i]["出生日期"].ToString()); oh.nl = dts[0].Rows[i]["年龄(周岁/月/天)"].ToString(); oh.xxzz = dts[0].Rows[i]["常住详细住址"].ToString(); oh.zzbm= dts[0].Rows[i]["常住地址编码"].ToString(); oh.tkys = dts[0].Rows[i]["报卡医师"].ToString(); oh.zd= dts[0].Rows[i]["冠心病诊断"].ToString(); oh.bklrsj =Convert.ToDateTime( dts[0].Rows[i]["报卡日期"].ToString()); oh.kpbm = dts[0].Rows[i]["卡片编号"].ToString(); bll.savegxb(oh, erpUser); } } catch (Exception ex) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "处理结果文件失败!" + ex.Message }); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "处理上报结果成功!" }); } } public JsonResult getgxbsj(int page, int pagesize, string key) { var bll = new BLL.NCZSJBll(); List ctList = bll.getListgxb(page, pagesize, key); var c = bll.getCountgxb(key); return Json(new { Rows = ctList, Total = c }); } } }