(#18)万事诚接口参数增加处方开始时间

This commit is contained in:
falcon 2019-04-04 16:52:50 +08:00
parent 2c1ff5b7cd
commit 5b6455cb91
2 changed files with 44 additions and 24 deletions

View File

@ -51,36 +51,52 @@ namespace Cmdjy.Controllers
result.Code = EnumCode.Exception; result.Code = EnumCode.Exception;
result.Msg = "Count值错误。"; result.Msg = "Count值错误。";
} }
if(result.Code != EnumCode.Exception) { DateTime sd = DateTime.MinValue;
result.Prescriptions = new List<WsdPrescriptionInfo>(); if(!string.IsNullOrEmpty(info.StartDate) && !DateTime.TryParse(info.StartDate,out sd)) {
count = count > WebSettings.WsdMaxCount ? WebSettings.WsdMaxCount : count; result.Code = EnumCode.Exception;
var cache = CacheFactory.Cache; result.Msg = "StartDate值格式错误请修改正确格式或不提供该值。";
for(int i = start;i < start + count;i++) { }
//从缓存获取 sd = new DateTime(sd.Year,sd.Month,sd.Day,0,0,0);//起始时间
var pkey = $"Company:Id:{info.CompanyCode}:Pre:Id:{i}"; int i = start;//起始编号
var one = cache.GetData<WsdPrescriptionInfo>(pkey); int maxId = db.PrescriptionInfos.Max(m => m.Id);//最大Id
if(one == null) { count = Math.Min(WebSettings.WsdMaxCount,count);//最大获取数量
//从数据库获取处方信息 result.MaxId = maxId.ToString();//处方最大Id
one = getPrescriptionInfoFromDb(info.CompanyCode,i); result.Prescriptions = new List<WsdPrescriptionInfo>();
//判断是否为 var cache = CacheFactory.Cache;
//获取药品信息 while(result.Code != EnumCode.Exception && i <= maxId && result.Prescriptions.Count < count) {
if(one != null) one.Drugs = getDrugInfoFromDb(one.Id); var pkey = $"Company:Id:{info.CompanyCode}:Pre:Id:{i}";
//存缓存 var one = cache.GetData<WsdPrescriptionInfo>(pkey);
if(one != null) cache.SetData(pkey,one); 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) { else {
one = new WsdPrescriptionInfo { result.Code = EnumCode.Exception;
Type = WsdPrescriptionType.NullOrder,Id = i, result.Msg = $"处方({i})中PrescriptionDatatime错误。";
}; break;
}
if(one != null) {
result.Prescriptions.Add(one);
} }
} }
if(one != null) {
result.Prescriptions.Add(one);
}
i++;
}
if(result.Code != EnumCode.Exception) {
result.Code = EnumCode.Success; result.Code = EnumCode.Success;
result.Count = result.Prescriptions.Where(m => m.Type != WsdPrescriptionType.NullOrder).Count(); result.Count = result.Prescriptions.Where(m => m.Type != WsdPrescriptionType.NullOrder).Count();
result.Msg = ""; result.Msg = "";
result.MaxId = db.PrescriptionInfos.Max(m => m.Id).ToString();
result.More = db.PrescriptionInfos.Max(m => m.Id) > (start + count); result.More = db.PrescriptionInfos.Max(m => m.Id) > (start + count);
} }
//编码json串 + 加密信息 //编码json串 + 加密信息

View File

@ -21,5 +21,9 @@
/// 最大本次获取的处方数量。根据客户网络和服务器配置情况自行调整 /// 最大本次获取的处方数量。根据客户网络和服务器配置情况自行调整
/// </summary> /// </summary>
public string MaxCount { get; set; } public string MaxCount { get; set; }
/// <summary>
/// 查询开始时间
/// </summary>
public string StartDate { get; set; }
} }
} }