From a52a446843ea0b433934bbfdab5a13610fda58f1 Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Tue, 26 Mar 2019 11:09:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E5=BC=80=E5=8F=91=E5=8C=BB?= =?UTF-8?q?=E7=96=97=E6=9C=BA=E6=9E=84=E5=89=8D=E7=BD=AE=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cmdjy/CmdjyHisFront/Bll/PostHelper.cs | 69 ++++++++++++++++++- .../CmdjyHisFront/Dal/Tables/DjyDrugInfo.cs | 30 ++++++++ .../Dal/Tables/DjyPrescriptionInfo.cs | 27 ++++++++ WebSiteCode/Cmdjy/CmdjyHisFront/Web.config | 2 +- 4 files changed, 126 insertions(+), 2 deletions(-) diff --git a/WebSiteCode/Cmdjy/CmdjyHisFront/Bll/PostHelper.cs b/WebSiteCode/Cmdjy/CmdjyHisFront/Bll/PostHelper.cs index 778c6cb..afb48b2 100644 --- a/WebSiteCode/Cmdjy/CmdjyHisFront/Bll/PostHelper.cs +++ b/WebSiteCode/Cmdjy/CmdjyHisFront/Bll/PostHelper.cs @@ -7,13 +7,17 @@ using CmdjyHisFront.Dal; using HisInterfaceModels; using CommonHelper; using Newtonsoft.Json; +using CmdjyHisFront.Dal.Tables; namespace CmdjyHisFront.Bll { public interface IPostHelper { void PostPrescription(); + void PostPrescriptionById(int id); void PostDrug(); + void PostDrugByDrugId(int id); + void PostDrugByPrescriptionId(int id); } public class PostHelper:IPostHelper, IRegisterBaseInterface @@ -21,13 +25,76 @@ namespace CmdjyHisFront.Bll public Lazy Db { get; set; } public void PostDrug() { - throw new NotImplementedException(); + var db = this.Db.Value; + var qu = db.DrugInfo.Join(db.DrugInfoLogs,a => a.Id,b => b.HisDrugInfoId,(a,b) => new { info = a,log = b,}) + .Where(); } public void PostPrescription() { throw new NotImplementedException(); } + public void PostPrescriptionById(int id) { + var qu = this.Db.Value.PrescriptionInfo.Where(m => m.Id == id); + if(!qu.Any()) { + throw new Exception($"处方没有找到,编号{id}。"); + } + var data = new HisPrescriptionInfo(); + data.CopyFrom(qu.First()); + var result = prescription(data); + var model = new DjyPrescriptionInfoLog(); + if(int.TryParse(result.PrescriptionId,out var ipid)) { + model.PrescriptionId = ipid; + } + model.HisPrescriptionInfoId = id; + model.PostDatatime = DateTime.Now; + model.ResultCode = (int)result.Code; + model.ResultMsg = result.Msg; + this.Db.Value.Entry(model).State = System.Data.Entity.EntityState.Added; + this.Db.Value.SaveChanges(); + } + + public void PostDrugByDrugId(int id) { + var db = this.Db.Value; + var qu = db.DrugInfo.Where(m => m.Id == id); + if(!qu.Any()) { + throw new Exception($"药品没有找到,编号{id}"); + } + var data = new HisDrugInfo(); + data.CopyFrom(qu.First()); + var result = drug(data); + var model = new DjyDrugInfoLog(); + if(int.TryParse(result.DrugId,out var idid)) { + model.DrugId = idid; + } + model.HisDrugInfoId = id; + model.PostDatatime = DateTime.Now; + model.ResultCode = (int)result.Code; + model.ResultMsg = result.Msg; + db.Entry(model).State = System.Data.Entity.EntityState.Added; + db.SaveChanges(); + } + + public void PostDrugByPrescriptionId(int id) { + var db = this.Db.Value; + var qu = db.DrugInfo.Where(m => m.PrescriptionId == id); + foreach(var item in qu) { + var data = new HisDrugInfo(); + data.CopyFrom(item); + var result = drug(data); + var model = new DjyDrugInfoLog(); + if(int.TryParse(result.DrugId,out var idid)) { + model.DrugId = idid; + } + model.HisDrugInfoId = id; + model.PostDatatime = DateTime.Now; + model.ResultCode = (int)result.Code; + model.ResultMsg = result.Msg; + db.Entry(model).State = System.Data.Entity.EntityState.Added; + db.SaveChanges(); + } + } + private HisPrescriptionResult prescription(HisPrescriptionInfo info) { using(var server = new HisServer.HisInterfaceSoapClient()) { var msg = JsonConvert.SerializeObject(info); diff --git a/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyDrugInfo.cs b/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyDrugInfo.cs index 02f44d7..5aa6db3 100644 --- a/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyDrugInfo.cs +++ b/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyDrugInfo.cs @@ -63,5 +63,35 @@ namespace CmdjyHisFront.Dal.Tables /// 特殊要求 /// public string Remark { get; set; } + /// + /// 上传状态 + /// + public EnumDrugPostStatus PostStatus { get; set; } + } + + /// + /// 处方信息上传状态 + /// + [Flags] + public enum EnumDrugPostStatus + { + /// + /// 新药品,未上传 + /// + NewOrder = 0, + /// + /// 成功上传 + /// + Sucess = 1, + /// + /// 上传异常 + /// + Exception = 2, + /// + /// 取消上传 + /// + Cancel = 4 + } + } \ No newline at end of file diff --git a/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyPrescriptionInfo.cs b/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyPrescriptionInfo.cs index 317a2a4..2c22d24 100644 --- a/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyPrescriptionInfo.cs +++ b/WebSiteCode/Cmdjy/CmdjyHisFront/Dal/Tables/DjyPrescriptionInfo.cs @@ -167,6 +167,10 @@ namespace CmdjyHisFront.Dal.Tables /// 代煎药厂商名称 /// public string CompanyName { get; set; } + /// + /// 上传状态 + /// + public EnumPrescriptionPostStatus PostStatus { get; set; } } /// @@ -188,4 +192,27 @@ namespace CmdjyHisFront.Dal.Tables /// TestOrder = 4, } + /// + /// 处方信息上传状态 + /// + [Flags] + public enum EnumPrescriptionPostStatus + { + /// + /// 新处方,未上传 + /// + NewOrder = 0, + /// + /// 成功上传 + /// + Sucess = 1, + /// + /// 上传异常 + /// + Exception = 2, + /// + /// 取消上传 + /// + Cancel = 4 + } } \ No newline at end of file diff --git a/WebSiteCode/Cmdjy/CmdjyHisFront/Web.config b/WebSiteCode/Cmdjy/CmdjyHisFront/Web.config index 3029a4a..1770490 100644 --- a/WebSiteCode/Cmdjy/CmdjyHisFront/Web.config +++ b/WebSiteCode/Cmdjy/CmdjyHisFront/Web.config @@ -9,7 +9,7 @@
- +