From 5b6455cb91f59303e48f04ba7f42bda55405cd7d Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Thu, 4 Apr 2019 16:52:50 +0800 Subject: [PATCH] =?UTF-8?q?(#18)=E4=B8=87=E4=BA=8B=E8=AF=9A=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=82=E6=95=B0=E5=A2=9E=E5=8A=A0=E5=A4=84=E6=96=B9?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/WsdInterfaceController.cs | 64 ++++++++++++------- .../Cmdjy/WsdInterfaceModels/WsdRequest.cs | 4 ++ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/WebSiteCode/Cmdjy/Cmdjy/Controllers/WsdInterfaceController.cs b/WebSiteCode/Cmdjy/Cmdjy/Controllers/WsdInterfaceController.cs index ec1e1de..bbbb1ed 100644 --- a/WebSiteCode/Cmdjy/Cmdjy/Controllers/WsdInterfaceController.cs +++ b/WebSiteCode/Cmdjy/Cmdjy/Controllers/WsdInterfaceController.cs @@ -51,36 +51,52 @@ namespace Cmdjy.Controllers result.Code = EnumCode.Exception; result.Msg = "Count值错误。"; } - if(result.Code != EnumCode.Exception) { - result.Prescriptions = new List(); - count = count > WebSettings.WsdMaxCount ? WebSettings.WsdMaxCount : count; - var cache = CacheFactory.Cache; - for(int i = start;i < start + count;i++) { - //从缓存获取 - var pkey = $"Company:Id:{info.CompanyCode}:Pre:Id:{i}"; - var one = cache.GetData(pkey); - if(one == null) { - //从数据库获取处方信息 - one = getPrescriptionInfoFromDb(info.CompanyCode,i); - //判断是否为 - //获取药品信息 - if(one != null) one.Drugs = getDrugInfoFromDb(one.Id); - //存缓存 - if(one != null) cache.SetData(pkey,one); + DateTime sd = DateTime.MinValue; + if(!string.IsNullOrEmpty(info.StartDate) && !DateTime.TryParse(info.StartDate,out sd)) { + result.Code = EnumCode.Exception; + result.Msg = "StartDate值格式错误,请修改正确格式或不提供该值。"; + } + sd = new DateTime(sd.Year,sd.Month,sd.Day,0,0,0);//起始时间 + int i = start;//起始编号 + int maxId = db.PrescriptionInfos.Max(m => m.Id);//最大Id + count = Math.Min(WebSettings.WsdMaxCount,count);//最大获取数量 + result.MaxId = maxId.ToString();//处方最大Id + result.Prescriptions = new List(); + var cache = CacheFactory.Cache; + while(result.Code != EnumCode.Exception && i <= maxId && result.Prescriptions.Count < count) { + var pkey = $"Company:Id:{info.CompanyCode}:Pre:Id:{i}"; + var one = cache.GetData(pkey); + if(one == null) { + //从数据库获取处方信息 + one = getPrescriptionInfoFromDb(info.CompanyCode,i); + //判断是否为 + //获取药品信息 + if(one != null) one.Drugs = getDrugInfoFromDb(one.Id); + //存缓存 + if(one != null) cache.SetData(pkey,one); + } + if(one != null) { + //处方日期要大于起始日期 + if(DateTime.TryParse(one.PrescriptionDatatime,out DateTime odt)) { + if(odt < sd) { + one = null; + } } - if(needNull != null && one == null) { - one = new WsdPrescriptionInfo { - Type = WsdPrescriptionType.NullOrder,Id = i, - }; - } - if(one != null) { - result.Prescriptions.Add(one); + else { + result.Code = EnumCode.Exception; + result.Msg = $"处方({i})中PrescriptionDatatime错误。"; + break; } } + if(one != null) { + result.Prescriptions.Add(one); + } + i++; + } + if(result.Code != EnumCode.Exception) { result.Code = EnumCode.Success; result.Count = result.Prescriptions.Where(m => m.Type != WsdPrescriptionType.NullOrder).Count(); result.Msg = ""; - result.MaxId = db.PrescriptionInfos.Max(m => m.Id).ToString(); result.More = db.PrescriptionInfos.Max(m => m.Id) > (start + count); } //编码:json串 + 加密信息 diff --git a/WebSiteCode/Cmdjy/WsdInterfaceModels/WsdRequest.cs b/WebSiteCode/Cmdjy/WsdInterfaceModels/WsdRequest.cs index 883d3b3..99b4e70 100644 --- a/WebSiteCode/Cmdjy/WsdInterfaceModels/WsdRequest.cs +++ b/WebSiteCode/Cmdjy/WsdInterfaceModels/WsdRequest.cs @@ -21,5 +21,9 @@ /// 最大本次获取的处方数量。根据客户网络和服务器配置情况自行调整 /// public string MaxCount { get; set; } + /// + /// 查询开始时间 + /// + public string StartDate { get; set; } } }