public async Task <ObjectResultModule> CreateDoctorRules([FromBody] DoctorRules DoctorRulesInfo) { if (!Commons.CheckSecret(DoctorRulesInfo.Secret)) { this.ObjectResultModule.StatusCode = 422; this.ObjectResultModule.Message = "Wrong Secret"; this.ObjectResultModule.Object = ""; return(this.ObjectResultModule); } var userid = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0; //ApplyClinicID 前段按照1,2,3,4格式返回后端 string[] IDArray = null; int[] iNums = null; if (!string.IsNullOrEmpty(DoctorRulesInfo.ApplyClinicID)) { IDArray = DoctorRulesInfo.ApplyClinicID.TrimEnd(',').Split(','); } if (IDArray.Length < 1) { return(new ObjectResultModule("", 400, "医生制度必须选择科室!")); } //转换方法 iNums = Array.ConvertAll <string, int>(IDArray, s => int.Parse(s)); var clin = new ClinicInfomationIn(); clin.AndAlso(t => !t.IsDelete); var clinicinfo = await _clinicInfomationService.ClinicInfomationListByArrId(clin, iNums.ToList()); string clinicname = ""; foreach (var item in clinicinfo) { string ClinicType = item.ClinicType == 1 ? "(成人)" : "(儿童)"; clinicname += item.ClinicName + ClinicType + ","; } var CreateDoctorRules = new DoctorRules() { RulesType = DoctorRulesInfo.RulesType, RulesTitle = DoctorRulesInfo.RulesTitle, RulesContent = DoctorRulesInfo.RulesContent, ApplyClinicName = clinicname.TrimEnd(','), ImageFie = DoctorRulesInfo.ImageFie, ApplyClinicID = "," + DoctorRulesInfo.ApplyClinicID.TrimEnd(',') + ",", CreatedBy = userid, CreatedOn = DateTime.Now }; var result = await _doctorRulesService.CreateDoctorRules(CreateDoctorRules); if (result.Id > 0) { this.ObjectResultModule.Object = result; this.ObjectResultModule.StatusCode = 200; this.ObjectResultModule.Message = "success"; } else { this.ObjectResultModule.Object = ""; this.ObjectResultModule.StatusCode = 400; this.ObjectResultModule.Message = "error!"; } #region 操作日志 var CreateYaeherOperList = new YaeherOperList() { OperExplain = "CreateDoctorRules", OperContent = JsonHelper.ToJson(DoctorRulesInfo), OperType = "CreateDoctorRules", CreatedBy = userid, CreatedOn = DateTime.Now }; var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList); #endregion return(ObjectResultModule); }
public async Task <string> SendWecharMesaage(string KeyWord) { // 查询标签关联的组数据 RelationLabelGroupIn relationLabelGroupIn = new RelationLabelGroupIn(); relationLabelGroupIn.AndAlso(a => a.IsDelete == false); if (!string.IsNullOrEmpty(KeyWord)) { relationLabelGroupIn.AndAlso(a => a.LableName.Contains(KeyWord)); } else { // 当输入为空时 不查询 return(null); } var LabelGroupList = await _RelationLabelGrouprepository.GetAll().Where(relationLabelGroupIn.Expression).ToListAsync(); List <LabelGroup> labelGroups = new List <LabelGroup>(); if (LabelGroupList != null) { foreach (var Item in LabelGroupList) { string[] LableID = Item.LableID.Split(','); string[] LableName = Item.LableName.Split(','); if (LableID.Length > 0) { for (int a = 0; a < LableID.Length; a++) { LabelGroup labelGroup = new LabelGroup(); labelGroup.GroupName = Item.GroupName; labelGroup.LableID = int.Parse(LableID[a]); labelGroup.LableName = LableName[a]; labelGroups.Add(labelGroup); } } } } // 查询业务与标签之间的关系 RelationLabelListIn relationLabelListIn = new RelationLabelListIn(); relationLabelListIn.AndAlso(a => a.IsDelete == false); var relationLabelList = _RelationLabelListrepository.GetAll().Where(relationLabelListIn.Expression); List <RelationLabelList> relationLabelLists = new List <RelationLabelList>(); if (LabelGroupList != null) { var RelationLabelLists = from a in labelGroups join b in relationLabelList on a.LableID equals b.LableID select b; if (RelationLabelLists != null) { relationLabelLists = RelationLabelLists.Distinct().ToList(); } } StringBuilder sbClinic = new StringBuilder(); StringBuilder sbDoctor = new StringBuilder(); StringBuilder sbPaper = new StringBuilder(); StringBuilder sbQuestion = new StringBuilder(); if (relationLabelLists != null) { // 关键字查询科室信息 var ClinicList = relationLabelLists.Where(a => a.RelationCode == "Clinic").ToList(); if (ClinicList != null && ClinicList.Count > 0) { ClinicInfomationIn clinicInfomationIn = new ClinicInfomationIn(); clinicInfomationIn.AndAlso(a => a.IsDelete == false); // 增加查询状态 var YaeherCinlinList = _ClinicInfomationrepository.GetAll().Where(clinicInfomationIn.Expression); var RecomCinlinList = from a in ClinicList join b in YaeherCinlinList on a.BusinessID equals b.Id select b; if (RecomCinlinList != null) { var CinlinList = RecomCinlinList.Distinct().ToList().OrderBy(a => a.OrderSort).ThenByDescending(a => a.CreatedOn).Take(4); //int CinlinCount = 0; foreach (var Item in CinlinList) { var ClinicUrl = Commons.WecharWeb + "doctor-list-patient?id=" + Item.Id + "&clinicNmae=" + Item.ClinicName + "&rShow=no"; sbClinic.Append("<a href=\"" + ClinicUrl + "\">" + Item.ClinicName + "</a> "); sbClinic.Append("\n"); // 去掉科室换行 //CinlinCount += 1; //if (CinlinCount >= 2) //{ // sbClinic.Append("\n"); // sbClinic.Append("\n"); // CinlinCount = 0; //} } } } #region 关键字查询医生信息 暂时去掉 // 关键字查询医生信息 //var DoctorList = relationLabelLists.Where(a => a.RelationCode == "Doctor").ToList(); //if (DoctorList != null&&DoctorList.Count>0) //{ // YaeherDoctorIn yaeherDoctorIn = new YaeherDoctorIn(); // yaeherDoctorIn.AndAlso(a => a.IsDelete == false); // yaeherDoctorIn.AndAlso(a => a.AuthCheckRes =="success"); // // 增加查询状态 // var YaeherDoctotList = _YaeherDoctorrepository.GetAll().Where(yaeherDoctorIn.Expression); // //查询医生开启状态 // ServiceMoneyListIn serviceMoneyListIn = new ServiceMoneyListIn(); // serviceMoneyListIn.AndAlso(a => a.IsDelete == false); // serviceMoneyListIn.AndAlso(a => a.ServiceState == true); // var DocotorService= _ServiceMoneyListrepository.GetAll().Where(serviceMoneyListIn.Expression); // var RecomDoctotList = from a in DoctorList // join b in YaeherDoctotList on a.BusinessID equals b.Id // join c in DocotorService on b.Id equals c.DoctorID // select b; // if (RecomDoctotList != null) // { // var DoctotList = RecomDoctotList.Distinct().ToList().OrderByDescending(a=>a.CreatedOn).Take(12); // int DoctotCount = 0; // foreach (var Item in DoctotList) // { // var DoctotUrl= Commons.WecharWeb + "doctor-detail-patient?id="+Item.Id+"&rShow=no"; // sbDoctor.Append("<a href=\""+DoctotUrl+"\">"+Item.DoctorName+"</a> "); // DoctotCount += 1; // if (DoctotCount >=3) // { // sbDoctor.Append("\n"); // sbDoctor.Append("\n"); // DoctotCount = 0; // } // } // } //} //// 关键字查询文章信息 //var PaperList = relationLabelLists.Where(a => a.RelationCode == "Paper").ToList(); //if (PaperList != null&&PaperList.Count>0) //{ // ReleaseManageIn releaseManageIn = new ReleaseManageIn(); // releaseManageIn.AndAlso(a => a.IsDelete == false); // // 增加查询状态 // var ReleasList = _ReleaseManagerepository.GetAll().Where(releaseManageIn.Expression); // var RecomReleasList = from a in PaperList // join b in ReleasList on a.BusinessID equals b.Id // select b; // if (RecomReleasList != null) // { // var ReleasLists = RecomReleasList.Distinct().ToList().OrderByDescending(a=>a.CreatedOn).Take(5); // foreach (var Item in ReleasLists) // { // var ReleasUrl= Commons.WecharWeb + "article-detail?id="+Item.Id+"&rShow=no&look=no"; // sbPaper.Append("<a href=\""+ReleasUrl+"\">"+Item.PaperTiltle+"</a>\n"); // } // } //} //// 关键字查询问答信息 //var QuestionList = relationLabelLists.Where(a => a.RelationCode == "Question").ToList(); //if (QuestionList != null&&QuestionList.Count>0) //{ // QuestionReleaseIn questionReleaseIn = new QuestionReleaseIn(); // questionReleaseIn.AndAlso(a => a.IsDelete == false); // // 增加查询状态 // var QuestinList = _QuestionReleaserepository.GetAll().Where(questionReleaseIn.Expression); // var RecomQuestionList = from a in QuestionList // join b in QuestinList on a.BusinessID equals b.Id // select b; // if (RecomQuestionList != null) // { // var QuestionLists = RecomQuestionList.Distinct().ToList().OrderByDescending(a=>a.CreatedOn).Take(5); // foreach (var Item in QuestionLists) // { // var QuestionUrl= Commons.WecharWeb + "question-detail?id="+Item.Id+"&rShow=no"; // sbQuestion.Append("<a href=\""+QuestionUrl+"\">"+Item.Title+"</a>\n"); // } // } //} #endregion } StringBuilder sbWecharMessage = new StringBuilder(); if (sbClinic.ToString() != null && sbClinic.ToString() != "") { sbWecharMessage.Append("推荐科室: \n"); sbWecharMessage.Append(sbClinic.ToString() + "\n"); } #region 暂时去掉 //if (sbDoctor.ToString() != null&&sbDoctor.ToString()!="") //{ // sbWecharMessage.Append("推荐医生: \n"); // sbWecharMessage.Append(sbDoctor.ToString() +"\n"); //} //if (sbPaper.ToString() != null&&sbPaper.ToString()!="") //{ // sbWecharMessage.Append("推荐文章: \n"); // sbWecharMessage.Append(sbPaper.ToString() +"\n"); //} //if (sbQuestion.ToString() != null&&sbQuestion.ToString()!="") //{ // sbWecharMessage.Append("推荐问答: \n"); // sbWecharMessage.Append(sbQuestion.ToString() +"\n"); //} #endregion return(sbWecharMessage.ToString()); }