Compare commits

...

7 Commits

11 changed files with 224 additions and 40 deletions

View File

@ -1,3 +1,3 @@
# 万仕达代煎药项目接口
<a href="http://39.105.71.191/cmdjy/wsd_djy/src/branch/master/WebSiteCode/Cmdjy/Cmdjy/ws/HisInterface.asmx.cs">医疗机构HIS接定义</a>
<a href="http://39.105.71.191/cmdjy/wsd_djy/src/branch/master/WebSiteCode/Cmdjy/WsdInterfaceModels">万事诚接口定义</a>

View File

@ -203,6 +203,7 @@
<Compile Include="Controllers\HisInfoController.cs" />
<Compile Include="Controllers\HisUpdataController.cs" />
<Compile Include="Controllers\HospitalInfoController.cs" />
<Compile Include="Controllers\InterFaceDocController.cs" />
<Compile Include="Controllers\WsdInterfaceController.cs" />
<Compile Include="Dal\Configuration.cs" />
<Compile Include="Dal\DbContextFactory.cs" />
@ -266,6 +267,8 @@
<Content Include="Scripts\jquery.validate.unobtrusive.js" />
<Content Include="Scripts\jquery.validate.unobtrusive.min.js" />
<Content Include="Scripts\modernizr-2.8.3.js" />
<Content Include="Views\HospitalInfo\Index.cshtml" />
<Content Include="Views\InterFaceDoc\Index.cshtml" />
<None Include="Web.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
@ -289,7 +292,6 @@
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Views\HisUpdata\" />
<Folder Include="Views\HospitalInfo\" />
<Folder Include="Views\Test\" />
</ItemGroup>
<ItemGroup>

View File

@ -16,7 +16,7 @@ namespace Cmdjy.Controllers
public Lazy<IHospitalInfoDataQuery> HosInfo { get; set; }
public ActionResult Index() {
return View();
return PartialView();
}
public ActionResult HospitalList() {

View File

@ -0,0 +1,12 @@
using System.Web.Mvc;
namespace Cmdjy.Controllers
{
public class InterFaceDocController : Controller
{
public ActionResult Index()
{
return PartialView();
}
}
}

View File

@ -17,7 +17,7 @@ namespace Cmdjy.Controllers
public ActionResult Index() {
var model = new WsdRequest {
StartNo = "0",MaxCount = "10",
CompanyCode = "1",CompanyName = "万仕",
CompanyCode = "1",CompanyName = "万仕诚代煎药",
};
return PartialView(model);
}
@ -51,44 +51,64 @@ namespace Cmdjy.Controllers
result.Code = EnumCode.Exception;
result.Msg = "Count值错误。";
}
if(result.Code != EnumCode.Exception) {
result.Prescriptions = new List<WsdPrescriptionInfo>();
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<WsdPrescriptionInfo>(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<WsdPrescriptionInfo>();
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<WsdPrescriptionInfo>(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串 + 加密信息
//return Json(result);
var resStr = JsonConvert.SerializeObject(result);
var mw = noDes == null ? DesHelper.GetHelper().Encrypty(cKey,resStr) : resStr;
logWsdRequest(info,result,resStr,mw);
return Content(mw);
if(noDes == null) {
var resStr = JsonConvert.SerializeObject(result);
var mw = DesHelper.GetHelper().Encrypty(cKey,resStr);
logWsdRequest(info,result,resStr,mw);
return Content(mw);
}
else {
return Json(result,JsonRequestBehavior.AllowGet);
}
}
/// <summary>
/// 记录日志
@ -150,6 +170,11 @@ namespace Cmdjy.Controllers
var fir = qu.First();
result = new WsdPrescriptionInfo();
result.CopyFrom(fir);
result.Type =
fir.Type == Dal.Tables.PrescriptionType.Order ? WsdPrescriptionType.Order :
fir.Type == Dal.Tables.PrescriptionType.CancelOrder ? WsdPrescriptionType.CancelOrder :
fir.Type == Dal.Tables.PrescriptionType.TestOrder ? WsdPrescriptionType.TestOrder :
WsdPrescriptionType.NullOrder;
}
return result;
}

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//
// 你可以指定所有值,也可以让修订版本和内部版本号采用默认值,
// 方法是按如下所示使用 "*":
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]

View File

@ -1,9 +1,11 @@
<h1>代煎药平台</h1>
<hr />
<ol class="toolBar">
<li>版本1.0</li>
<li>版本2.0</li>
<li>@Ajax.ActionLink("接口说明","Index","InterFaceDoc",new AjaxOptions { UpdateTargetId = "main" })</li>
<li>@Ajax.ActionLink("厂商列表","Index","Company",new AjaxOptions { UpdateTargetId = "main" })</li>
<li>@Ajax.ActionLink("医疗机构处方列表","Index","HisInfo",new AjaxOptions { UpdateTargetId = "main" })</li>
<li>@Ajax.ActionLink("医疗机构列表","Index","HospitalInfo",new AjaxOptions { UpdateTargetId = "main" })</li>
<li>@Ajax.ActionLink("万仕达下载测试","Index","WsdInterface",new AjaxOptions { UpdateTargetId = "main" })</li>
</ol>
<hr />

View File

@ -0,0 +1 @@
<a href="@Url.Action("HospitalList")" target="_blank">接口跳转</a>

View File

@ -0,0 +1,138 @@

<style type="text/css">
#ifd_l {
display: block;
width: 300px;
float: left;
border-right: 1px solid #000;
}
#ifd_l ul {
list-style: none;
padding: 5px;
}
#ifd_l ul li {
padding: 3px 0px;
}
#ifd_r {
float: left;
padding: 3px;
}
</style>
<script type="text/javascript">
$(function () {
$("#ifd_r > div").hide();
});
$(function () {
$("#ifd_l input[type=button]").click(function () {
$("#ifd_r > div").hide();
var sid = $(this).attr("viewId");
$("#ifd_r #" + sid).show();
});
});
</script>
<fieldset>
<legend>接口说明文档</legend>
<div id="ifd_l">
<ul>
<li>API列表</li>
<li><input type="button" viewId="cfxx" value="处方信息" /></li>
<li><input type="button" viewId="yyjglb" value="医院机构列表" /></li>
</ul>
</div>
<div id="ifd_r">
<div id="cfxx">
<div>接口地址:@Url.Action("GetData","WsdInterface")</div>
<table>
<caption>处方信息接口请求参数</caption>
<thead>
<tr>
<th>字段</th>
<th>可为空</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>CompanyCode</td>
<td>否</td>
<td>接口方代码。</td>
</tr>
<tr>
<td>CompanyName</td>
<td>是</td>
<td>接口方名称</td>
</tr>
<tr>
<td>StartNo</td>
<td>否</td>
<td>开始的编号</td>
</tr>
<tr>
<td>MaxCount</td>
<td>否</td>
<td>最大获取数量</td>
</tr>
<tr>
<td>StartDate</td>
<td>是</td>
<td>处方开始时间</td>
</tr>
</tbody>
</table>
<table>
<caption>处方信息响应参数</caption>
<thead>
<tr>
<th>字段</th>
<th>可为空</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">暂缺</td>
</tr>
</tbody>
</table>
</div>
<div id="yyjglb">
<div>接口地址:@Url.Action("HospitalList","HospitalInfo")</div>
<table>
<caption>医院机构列表请求参数</caption>
<thead>
<tr>
<th>字段</th>
<th>可为空</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">无参数</td>
</tr>
</tbody>
</table>
<table>
<caption>处方信息响应参数</caption>
<thead>
<tr>
<th>字段</th>
<th>可为空</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">暂缺</td>
</tr>
</tbody>
</table>
</div>
</div>
</fieldset>

View File

@ -22,11 +22,11 @@
<script type="text/javascript">
$("#wsdMsg").hide();
function wsdSucc(data) {
if (!data.match("^\{(.+:.+,*){1,}\}$")) {
$("#wsdMsg").show().text(data);
function wsdSucc(data, status, xhr) {
if (xhr.getResponseHeader("Content-Type").indexOf("application/json") >= 0) {
$("#wsdMsg").show().text(JSON.stringify(data, null, 2));
} else {
$("#wsdMsg").show().text(JSON.stringify(JSON.parse(data), null, 2));
$("#wsdMsg").show().text(data);
}
}
function wsdBeg() {

View File

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