parent
34003dd3da
commit
d8aa65ff8e
|
@ -23,15 +23,14 @@ namespace Cmdjy.Bll
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte[] IV { get; set; }
|
public byte[] IV { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密key
|
|
||||||
/// </summary>
|
|
||||||
public string Key { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 加密字符串获取Base64密文
|
/// 加密字符串获取Base64密文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="str">要加密的字符串</param>
|
/// <param name="str">要加密的字符串</param>
|
||||||
public string Encrypty(string str) {
|
public string Encrypty(string key,string str) {
|
||||||
byte[] bKey = Encoding.UTF8.GetBytes(Key.Substring(0,8));
|
if(key.Length < 8) {
|
||||||
|
throw new Exception("加密用的key长度为8位");
|
||||||
|
}
|
||||||
|
byte[] bKey = Encoding.UTF8.GetBytes(key.Substring(0,8));
|
||||||
byte[] bStr = Encoding.UTF8.GetBytes(str);
|
byte[] bStr = Encoding.UTF8.GetBytes(str);
|
||||||
var desc = createProvider();
|
var desc = createProvider();
|
||||||
using(var mStream = new MemoryStream()) {
|
using(var mStream = new MemoryStream()) {
|
||||||
|
@ -46,9 +45,12 @@ namespace Cmdjy.Bll
|
||||||
/// 从Base64密文解密,获取字符串
|
/// 从Base64密文解密,获取字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="str">密文</param>
|
/// <param name="str">密文</param>
|
||||||
public string DesCrypty(string str) {
|
public string DesCrypty(string key,string str) {
|
||||||
|
if(key.Length < 8) {
|
||||||
|
throw new Exception("加密用的key长度为8位");
|
||||||
|
}
|
||||||
var bStr = Convert.FromBase64String(str);
|
var bStr = Convert.FromBase64String(str);
|
||||||
byte[] bKey = Encoding.UTF8.GetBytes(Key.Substring(0,8));
|
byte[] bKey = Encoding.UTF8.GetBytes(key.Substring(0,8));
|
||||||
var desc = createProvider();
|
var desc = createProvider();
|
||||||
using(var mStream = new MemoryStream()) {
|
using(var mStream = new MemoryStream()) {
|
||||||
using(var cStream = new CryptoStream(mStream,desc.CreateDecryptor(bKey,IV),CryptoStreamMode.Write)) {
|
using(var cStream = new CryptoStream(mStream,desc.CreateDecryptor(bKey,IV),CryptoStreamMode.Write)) {
|
||||||
|
@ -75,9 +77,8 @@ namespace Cmdjy.Bll
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static DesHelper GetHelper() {
|
public static DesHelper GetHelper() {
|
||||||
if(_deshelper == null) {
|
if(_deshelper == null) {
|
||||||
var key = WebSettings.DesKey;
|
|
||||||
byte[] IV = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 };
|
byte[] IV = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 };
|
||||||
_deshelper = GetHelper(PaddingMode.PKCS7,CipherMode.CBC,IV,key);
|
_deshelper = GetHelper(PaddingMode.PKCS7,CipherMode.CBC,IV);
|
||||||
|
|
||||||
}
|
}
|
||||||
return _deshelper;
|
return _deshelper;
|
||||||
|
@ -89,12 +90,9 @@ namespace Cmdjy.Bll
|
||||||
/// <param name="cipher">加密算法模式</param>
|
/// <param name="cipher">加密算法模式</param>
|
||||||
/// <param name="IV">初始化向量</param>
|
/// <param name="IV">初始化向量</param>
|
||||||
/// <param name="key">加密关键字</param>
|
/// <param name="key">加密关键字</param>
|
||||||
public static DesHelper GetHelper(PaddingMode padding,CipherMode cipher,byte[] IV,string key) {
|
public static DesHelper GetHelper(PaddingMode padding,CipherMode cipher,byte[] IV) {
|
||||||
if(key.Length < 8) {
|
|
||||||
throw new Exception("加密用的key长度为8位");
|
|
||||||
}
|
|
||||||
return new DesHelper {
|
return new DesHelper {
|
||||||
Cipher = cipher,IV = IV,Key = key,Padding = padding,
|
Cipher = cipher,IV = IV,Padding = padding,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,9 +189,11 @@
|
||||||
<Compile Include="Bll\ObjExtend.cs" />
|
<Compile Include="Bll\ObjExtend.cs" />
|
||||||
<Compile Include="Controllers\HisInfoController.cs" />
|
<Compile Include="Controllers\HisInfoController.cs" />
|
||||||
<Compile Include="Dal\Configuration.cs" />
|
<Compile Include="Dal\Configuration.cs" />
|
||||||
|
<Compile Include="Dal\DbContextFactory.cs" />
|
||||||
<Compile Include="Dal\Queryes\HisDrugQuery.cs" />
|
<Compile Include="Dal\Queryes\HisDrugQuery.cs" />
|
||||||
<Compile Include="Dal\Queryes\HisPrescriptionQuery.cs" />
|
<Compile Include="Dal\Queryes\HisPrescriptionQuery.cs" />
|
||||||
<Compile Include="Dal\Queryes\IDbQuery.cs" />
|
<Compile Include="Dal\Queryes\IDbQuery.cs" />
|
||||||
|
<Compile Include="Dal\Tables\CompanyInfo.cs" />
|
||||||
<Compile Include="Dal\Tables\WsdRequestLog.cs" />
|
<Compile Include="Dal\Tables\WsdRequestLog.cs" />
|
||||||
<Compile Include="Dal\Wappers\HisDrugInfoWapper.cs" />
|
<Compile Include="Dal\Wappers\HisDrugInfoWapper.cs" />
|
||||||
<Compile Include="Dal\Wappers\HisPrescriptyInfoWapper.cs" />
|
<Compile Include="Dal\Wappers\HisPrescriptyInfoWapper.cs" />
|
||||||
|
|
15
WebSiteCode/Cmdjy/Cmdjy/Dal/DbContextFactory.cs
Normal file
15
WebSiteCode/Cmdjy/Cmdjy/Dal/DbContextFactory.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
namespace Cmdjy.Dal
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据上下文工厂
|
||||||
|
/// </summary>
|
||||||
|
public class DbContextFactory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取代煎药数据库
|
||||||
|
/// </summary>
|
||||||
|
public static DjyDbContext CreateDbContext() {
|
||||||
|
return DjyDbContext.GetContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,11 @@ namespace Cmdjy.Dal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DjyDbContext:DbContext
|
public partial class DjyDbContext:DbContext
|
||||||
{
|
{
|
||||||
public DjyDbContext() : base("DjyDbContext") {
|
public static DjyDbContext GetContext() {
|
||||||
|
return new DjyDbContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
private DjyDbContext() : base("DjyDbContext") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -32,5 +36,9 @@ namespace Cmdjy.Dal
|
||||||
/// 万仕达下载日志
|
/// 万仕达下载日志
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DbSet<WsdRequestLog> WsdRequestLogs { get; set; }
|
public DbSet<WsdRequestLog> WsdRequestLogs { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商信息
|
||||||
|
/// </summary>
|
||||||
|
public DbSet<CompanyInfo> CompanyInfos { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ namespace Cmdjy.Dal.Queryes
|
||||||
|
|
||||||
|
|
||||||
public IEnumerable<HisDrugInfo> GetAll() {
|
public IEnumerable<HisDrugInfo> GetAll() {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
return GetQuery(db).ToList();
|
return GetQuery(db).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace Cmdjy.Dal.Queryes
|
||||||
var key = getPKey(pId.ToString());
|
var key = getPKey(pId.ToString());
|
||||||
var val = this.Cache.Value.GetData<IEnumerable<HisDrugInfo>>(key);
|
var val = this.Cache.Value.GetData<IEnumerable<HisDrugInfo>>(key);
|
||||||
if(val == null) {
|
if(val == null) {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
val = GetQuery(db).Where(m => m.PrescriptionId == pId).ToList();
|
val = GetQuery(db).Where(m => m.PrescriptionId == pId).ToList();
|
||||||
if(val != null) this.Cache.Value.SetData(key,val);
|
if(val != null) this.Cache.Value.SetData(key,val);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace Cmdjy.Dal.Queryes
|
||||||
var key = getKey(id.ToString());
|
var key = getKey(id.ToString());
|
||||||
var val = this.Cache.Value.GetData<HisDrugInfo>(key);
|
var val = this.Cache.Value.GetData<HisDrugInfo>(key);
|
||||||
if(val == null) {
|
if(val == null) {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
val = db.DrugInfos.Find(id);
|
val = db.DrugInfos.Find(id);
|
||||||
if(val != null) this.Cache.Value.SetData(key,val);
|
if(val != null) this.Cache.Value.SetData(key,val);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ namespace Cmdjy.Dal.Queryes
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Insert(HisDrugInfo obj) {
|
public void Insert(HisDrugInfo obj) {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
db.Entry(obj).State = EntityState.Added;
|
db.Entry(obj).State = EntityState.Added;
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Cmdjy.Dal.Queryes
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<HisPrescriptionInfo> GetAll() {
|
public IEnumerable<HisPrescriptionInfo> GetAll() {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
return db.PrescriptionInfos.ToList();
|
return db.PrescriptionInfos.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace Cmdjy.Dal.Queryes
|
||||||
var key = getKey(id.ToString());
|
var key = getKey(id.ToString());
|
||||||
var val = this.Cache.Value.GetData<HisPrescriptionInfo>(key);
|
var val = this.Cache.Value.GetData<HisPrescriptionInfo>(key);
|
||||||
if(val == null) {
|
if(val == null) {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
val = db.PrescriptionInfos.Find(id);
|
val = db.PrescriptionInfos.Find(id);
|
||||||
if(val != null) this.Cache.Value.SetData(key,val);
|
if(val != null) this.Cache.Value.SetData(key,val);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace Cmdjy.Dal.Queryes
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Insert(HisPrescriptionInfo obj) {
|
public void Insert(HisPrescriptionInfo obj) {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
db.Entry(obj).State = EntityState.Added;
|
db.Entry(obj).State = EntityState.Added;
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
49
WebSiteCode/Cmdjy/Cmdjy/Dal/Tables/CompanyInfo.cs
Normal file
49
WebSiteCode/Cmdjy/Cmdjy/Dal/Tables/CompanyInfo.cs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Cmdjy.Dal.Tables
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商信息
|
||||||
|
/// </summary>
|
||||||
|
[Table("CompanyInfo")]
|
||||||
|
public class CompanyInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 厂商编号
|
||||||
|
/// </summary>
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 厂商名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 厂商地址
|
||||||
|
/// </summary>
|
||||||
|
public string Address { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 厂商电话
|
||||||
|
/// </summary>
|
||||||
|
public string Phone { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 安全关键字
|
||||||
|
/// </summary>
|
||||||
|
public string SecurityKey { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 厂商状态
|
||||||
|
/// </summary>
|
||||||
|
public EnumComanyInfo Status { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 厂家状态
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum EnumComanyInfo
|
||||||
|
{
|
||||||
|
Enable = 0,
|
||||||
|
Disable = 1,
|
||||||
|
}
|
||||||
|
}
|
|
@ -147,6 +147,14 @@ namespace Cmdjy.Dal.Tables
|
||||||
/// 用法
|
/// 用法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Usage { get; set; }
|
public string Usage { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商代码
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyCode { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商名称
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Cmdjy.Models
|
||||||
public static class HisInfo
|
public static class HisInfo
|
||||||
{
|
{
|
||||||
public static IEnumerable<HisPrescriptionInfo> GetPreInfos(PreFilter filter) {
|
public static IEnumerable<HisPrescriptionInfo> GetPreInfos(PreFilter filter) {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
var qu = db.PrescriptionInfos.AsQueryable();
|
var qu = db.PrescriptionInfos.AsQueryable();
|
||||||
if(filter == null) return qu.ToList();
|
if(filter == null) return qu.ToList();
|
||||||
if(!string.IsNullOrEmpty(filter.Start) && int.TryParse(filter.Start,out var s)) {
|
if(!string.IsNullOrEmpty(filter.Start) && int.TryParse(filter.Start,out var s)) {
|
||||||
|
@ -25,7 +25,7 @@ namespace Cmdjy.Models
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<HisDrugInfo> GetDrugInfos(int preId) {
|
public static IEnumerable<HisDrugInfo> GetDrugInfos(int preId) {
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
var qu = db.DrugInfos.Where(m => m.PrescriptionId == preId);
|
var qu = db.DrugInfos.Where(m => m.PrescriptionId == preId);
|
||||||
return qu.ToList();
|
return qu.ToList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Cmdjy.ws
|
||||||
[WebMethod(Description = "医疗机构上传处方信息")]
|
[WebMethod(Description = "医疗机构上传处方信息")]
|
||||||
public string PostPrescriptionInfo(HisPrescriptionInfo info) {
|
public string PostPrescriptionInfo(HisPrescriptionInfo info) {
|
||||||
HisPrescriptionResult result = null;
|
HisPrescriptionResult result = null;
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
var en = new HisPrescriptyInfoWapper(info) as Dal.Tables.HisPrescriptionInfo;
|
var en = new HisPrescriptyInfoWapper(info) as Dal.Tables.HisPrescriptionInfo;
|
||||||
en.RawAddress = this.Context.Request.UserHostAddress;
|
en.RawAddress = this.Context.Request.UserHostAddress;
|
||||||
en.CreateDatetime = DateTime.Now;
|
en.CreateDatetime = DateTime.Now;
|
||||||
|
@ -49,7 +49,7 @@ namespace Cmdjy.ws
|
||||||
[WebMethod(Description = "医疗机构上传药品信息")]
|
[WebMethod(Description = "医疗机构上传药品信息")]
|
||||||
public string PostDrugInfo(HisDrugInfo info) {
|
public string PostDrugInfo(HisDrugInfo info) {
|
||||||
HisDrugResult result = null;
|
HisDrugResult result = null;
|
||||||
using(var db = new DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
var en = new HisDrugInfoWapper(info) as Dal.Tables.HisDrugInfo;
|
var en = new HisDrugInfoWapper(info) as Dal.Tables.HisDrugInfo;
|
||||||
en.RawAddress = this.Context.Request.UserHostAddress;
|
en.RawAddress = this.Context.Request.UserHostAddress;
|
||||||
en.CreateDatetime = DateTime.Now;
|
en.CreateDatetime = DateTime.Now;
|
||||||
|
@ -213,6 +213,14 @@ namespace Cmdjy.ws
|
||||||
/// 收费费用序号
|
/// 收费费用序号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Sffyxh { get; set; }
|
public string Sffyxh { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商代码
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyCode { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商名称
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyName { get; set; }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// HIS发送处方信息应答
|
/// HIS发送处方信息应答
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Web.Services;
|
||||||
using Cmdjy.Bll;
|
using Cmdjy.Bll;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Cmdjy.Dal;
|
||||||
|
|
||||||
namespace Cmdjy.ws
|
namespace Cmdjy.ws
|
||||||
{
|
{
|
||||||
|
@ -22,8 +23,19 @@ namespace Cmdjy.ws
|
||||||
[WebMethod(Description = "获取代煎药处方信息")]
|
[WebMethod(Description = "获取代煎药处方信息")]
|
||||||
public string GetData(WsdRequest info) {
|
public string GetData(WsdRequest info) {
|
||||||
var result = new WsdResult {
|
var result = new WsdResult {
|
||||||
|
Code = EnumCode.Success,
|
||||||
};
|
};
|
||||||
result.Prescriptions = new List<WsdPrescriptionInfo>();
|
string cKey = null;
|
||||||
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
|
var companyInfo = db.CompanyInfos.Where(m => m.Id.ToString() == info.CompanyCode);
|
||||||
|
if(companyInfo.Any()) {
|
||||||
|
cKey = companyInfo.First().SecurityKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(string.IsNullOrEmpty(cKey)) {
|
||||||
|
result.Code = EnumCode.Exception;
|
||||||
|
result.Msg = "CompanyCode值错误";
|
||||||
|
}
|
||||||
//获取数据
|
//获取数据
|
||||||
int start = 0;
|
int start = 0;
|
||||||
if(!int.TryParse(info.StartNo,out start)) {
|
if(!int.TryParse(info.StartNo,out start)) {
|
||||||
|
@ -37,23 +49,26 @@ namespace Cmdjy.ws
|
||||||
}
|
}
|
||||||
if(count <= 0) {
|
if(count <= 0) {
|
||||||
result.Code = EnumCode.Exception;
|
result.Code = EnumCode.Exception;
|
||||||
result.Msg = "Count值小于0。";
|
result.Msg = "Count值错误。";
|
||||||
}
|
}
|
||||||
if(result.Code != EnumCode.Exception) {
|
if(result.Code != EnumCode.Exception) {
|
||||||
|
result.Prescriptions = new List<WsdPrescriptionInfo>();
|
||||||
count = count > WebSettings.WsdMaxCount ? WebSettings.WsdMaxCount : count;
|
count = count > WebSettings.WsdMaxCount ? WebSettings.WsdMaxCount : count;
|
||||||
var cache = CacheFactory.Cache;
|
var cache = CacheFactory.Cache;
|
||||||
for(int i = start;i < start + count;i++) {
|
for(int i = start;i < start + count;i++) {
|
||||||
//从缓存获取
|
//从缓存获取
|
||||||
var pkey = $"Wsd:Pre:Id:{i}";
|
var pkey = $"Company:Id:{info.CompanyCode}:Pre:Id:{i}";
|
||||||
var one = cache.GetData<WsdPrescriptionInfo>(pkey);
|
var one = cache.GetData<WsdPrescriptionInfo>(pkey);
|
||||||
if(one == null) {
|
if(one == null) {
|
||||||
//从数据库获取处方信息
|
//从数据库获取处方信息
|
||||||
one = getPrescriptionInfoFromDb(i);
|
one = getPrescriptionInfoFromDb(info.CompanyCode,i);
|
||||||
|
//判断是否为
|
||||||
//获取药品信息
|
//获取药品信息
|
||||||
if(one != null) one.Drugs = getDrugInfoFromDb(one.Id);
|
if(one != null) one.Drugs = getDrugInfoFromDb(one.Id);
|
||||||
//存缓存
|
//存缓存
|
||||||
if(one != null) cache.SetData(pkey,one);
|
if(one != null) cache.SetData(pkey,one);
|
||||||
}
|
}
|
||||||
|
//对应代煎药厂商
|
||||||
if(one == null) {
|
if(one == null) {
|
||||||
one = new WsdPrescriptionInfo {
|
one = new WsdPrescriptionInfo {
|
||||||
Type = WsdPrescriptionType.NullOrder,Id = i,
|
Type = WsdPrescriptionType.NullOrder,Id = i,
|
||||||
|
@ -64,14 +79,14 @@ namespace Cmdjy.ws
|
||||||
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 = "";
|
||||||
using(var db = new Dal.DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
result.More = db.PrescriptionInfos.Max(m => m.Id) > (start + count);
|
result.More = db.PrescriptionInfos.Max(m => m.Id) > (start + count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//编码:json串 + 加密信息
|
//编码:json串 + 加密信息
|
||||||
try {
|
try {
|
||||||
var resStr = JsonConvert.SerializeObject(result);
|
var resStr = JsonConvert.SerializeObject(result);
|
||||||
var mw = DesHelper.GetHelper().Encrypty(resStr);
|
var mw = DesHelper.GetHelper().Encrypty(cKey,resStr);
|
||||||
logWsdRequest(info,result,resStr,mw);
|
logWsdRequest(info,result,resStr,mw);
|
||||||
return mw;
|
return mw;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +102,7 @@ namespace Cmdjy.ws
|
||||||
/// <param name="resStr">响应字符串</param>
|
/// <param name="resStr">响应字符串</param>
|
||||||
/// <param name="mw">响应密文</param>
|
/// <param name="mw">响应密文</param>
|
||||||
private void logWsdRequest(WsdRequest info,WsdResult result,string resStr,string mw) {
|
private void logWsdRequest(WsdRequest info,WsdResult result,string resStr,string mw) {
|
||||||
using(var db = new Dal.DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
if(result != null && result.Prescriptions != null) {
|
if(result != null && result.Prescriptions != null) {
|
||||||
foreach(var p in result.Prescriptions) {
|
foreach(var p in result.Prescriptions) {
|
||||||
if(p.Drugs != null) {
|
if(p.Drugs != null) {
|
||||||
|
@ -113,7 +128,7 @@ namespace Cmdjy.ws
|
||||||
/// <param name="id">处方号</param>
|
/// <param name="id">处方号</param>
|
||||||
private static List<WsdDrugInfo> getDrugInfoFromDb(int id) {
|
private static List<WsdDrugInfo> getDrugInfoFromDb(int id) {
|
||||||
List<WsdDrugInfo> result = null;
|
List<WsdDrugInfo> result = null;
|
||||||
using(var db = new Dal.DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
var qu = db.DrugInfos.Where(m => m.PrescriptionId == id);
|
var qu = db.DrugInfos.Where(m => m.PrescriptionId == id);
|
||||||
if(qu.Any()) {
|
if(qu.Any()) {
|
||||||
result = new List<WsdDrugInfo>();
|
result = new List<WsdDrugInfo>();
|
||||||
|
@ -130,11 +145,11 @@ namespace Cmdjy.ws
|
||||||
/// 从数据库获取处方
|
/// 从数据库获取处方
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="i">处方号</param>
|
/// <param name="i">处方号</param>
|
||||||
private static WsdPrescriptionInfo getPrescriptionInfoFromDb(int i) {
|
private static WsdPrescriptionInfo getPrescriptionInfoFromDb(string cId,int i) {
|
||||||
WsdPrescriptionInfo result = null;
|
WsdPrescriptionInfo result = null;
|
||||||
using(var db = new Dal.DjyDbContext()) {
|
using(var db = DbContextFactory.CreateDbContext()) {
|
||||||
var qu = db.PrescriptionInfos
|
var qu = db.PrescriptionInfos
|
||||||
.Where(m => m.Id == i)
|
.Where(m => m.Id == i && m.CompanyCode == cId)
|
||||||
.Where(m => m.Type == Dal.Tables.PrescriptionType.Order || m.Type == Dal.Tables.PrescriptionType.CancelOrder);
|
.Where(m => m.Type == Dal.Tables.PrescriptionType.Order || m.Type == Dal.Tables.PrescriptionType.CancelOrder);
|
||||||
if(qu.Any()) {
|
if(qu.Any()) {
|
||||||
var fir = qu.First();
|
var fir = qu.First();
|
||||||
|
@ -151,6 +166,14 @@ namespace Cmdjy.ws
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WsdRequest
|
public class WsdRequest
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商编码。
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyCode { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代煎药厂商名称
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyName { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处方起始流水号。按照数字从1开始累加。返回结果包含此编号的处方。
|
/// 处方起始流水号。按照数字从1开始累加。返回结果包含此编号的处方。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using System;
|
||||||
using Cmdjy.Bll;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace Cmdjy.Bll.Tests
|
namespace Cmdjy.Bll.Tests
|
||||||
{
|
{
|
||||||
|
@ -14,21 +10,25 @@ namespace Cmdjy.Bll.Tests
|
||||||
{
|
{
|
||||||
[TestMethod()]
|
[TestMethod()]
|
||||||
public void EncryptyTest() {
|
public void EncryptyTest() {
|
||||||
byte[] IV = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 };
|
byte[] IV = { 0x01,0x02,0x03,0x14,0x05,0x06,0x17,0x08 };
|
||||||
var des = DesHelper.GetHelper(PaddingMode.PKCS7,CipherMode.CBC,IV,"12365478");
|
string key = "12365478";
|
||||||
Console.WriteLine($"Key:{des.Key}");
|
var des = DesHelper.GetHelper(PaddingMode.PKCS7,CipherMode.CBC,IV);
|
||||||
|
Console.WriteLine($"Key:{key}");
|
||||||
string mingwen = getMingWen();
|
string mingwen = getMingWen();
|
||||||
Console.WriteLine($"明文:{mingwen}");
|
Console.WriteLine($"明文:{mingwen}");
|
||||||
var miwen = des.Encrypty(mingwen);
|
var miwen = des.Encrypty(key,mingwen);
|
||||||
Console.WriteLine($"密文:{miwen}");
|
Console.WriteLine($"密文:{miwen}");
|
||||||
var mingwen2 = des.DesCrypty(miwen);
|
var miwen2 = des.Encrypty(key,mingwen);
|
||||||
|
Console.WriteLine($"密文2:{miwen2}");
|
||||||
|
Assert.AreEqual(miwen,miwen2);
|
||||||
|
var mingwen2 = des.DesCrypty(key,miwen);
|
||||||
Assert.AreEqual(mingwen,mingwen2);
|
Assert.AreEqual(mingwen,mingwen2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string getMingWen() {
|
public string getMingWen() {
|
||||||
string str = "abcdefghijklmnopqrstuvwxyz123456789,./*-+";
|
string str = "abcdefghijklmnopqrstuvwxyz1234567890,./*-+";
|
||||||
var result = new StringBuilder();
|
var result = new StringBuilder();
|
||||||
int len = 1000;
|
int len = 100;
|
||||||
var rean = new Random();
|
var rean = new Random();
|
||||||
for(int i = 0;i < len;i++) {
|
for(int i = 0;i < len;i++) {
|
||||||
var p = rean.Next(str.Length);
|
var p = rean.Next(str.Length);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user