using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.IO;
|
using System.Linq;
|
using System.Web;
|
using System.Web.Mvc;
|
|
using BatchService.Framework.Utility;
|
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
|
using PalGain.Core;
|
|
using sbcLabSystem.App_Start.Attribute;
|
using sbcLabSystem.Data.Domain.Account;
|
using sbcLabSystem.Data.Domain.Backstage;
|
using sbcLabSystem.Models.Backstage;
|
using sbcLabSystem.Service;
|
using sbcLabSystem.Service.Account;
|
using sbcLabSystem.Service.QC;
|
|
namespace sbcLabSystem.Controllers
|
{
|
|
public class BackstageController : Controller
|
{
|
private AccountService m_AccountService;
|
private QCService _qcService;
|
|
public BackstageController(AccountService l_AccountService,
|
QCService i_qcService)
|
{
|
_qcService = i_qcService;
|
this.m_AccountService = l_AccountService;
|
}
|
public ActionResult Login(string returnurl)
|
{
|
|
Cookie.Remove("login_admin");
|
|
return View(new UserInfo()
|
{
|
UserNo = "",
|
Password = "",
|
Remark = "",
|
CurrentEnvirnoment = returnurl,
|
});
|
}
|
public ActionResult DoLogin(UserInfo userInfo)
|
{
|
try
|
{
|
LogHelper.Debug("管理员用户请求登录");
|
if (userInfo.Remark != Session["ValidateCode"].ToString())
|
{
|
return Json("yzm", JsonRequestBehavior.AllowGet);
|
}
|
//if (!string.IsNullOrEmpty(Cookie.GetValue("loginNumber")) && int.Parse(Cookie.GetValue("loginNumber")) > 3)
|
//{
|
// return Json("3", JsonRequestBehavior.AllowGet);
|
//}
|
//else
|
//{
|
// if (Cookie.GetValue("loginNumber") == null || Cookie.GetValue("loginNumber") == "")
|
// {
|
// Cookie.Save("loginNumber", "1", 1);
|
// }
|
// else
|
// {
|
// string number = (int.Parse(Cookie.GetValue("loginNumber")) + 1).ToString();
|
// Cookie.Save("loginNumber", number, 1);
|
// }
|
//}
|
string md5_password = MD5Helper.MD5Encrypt3(userInfo.Password);
|
UserInfo existsUser = m_AccountService.GetUsers().FirstOrDefault(p => p.UserNo == userInfo.UserNo
|
&& (p.Password == userInfo.Password || p.Password == md5_password));
|
if (existsUser != null)
|
{
|
Cookie.Save("login_admin", existsUser.Id.ToString(), 60);
|
LogHelper.Debug("管理员登录成功");
|
return Json("ok", JsonRequestBehavior.AllowGet);
|
}
|
else
|
{
|
throw new Exception("无效的用户名密码!");
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
return Json(ex.Message, JsonRequestBehavior.AllowGet);
|
}
|
|
}
|
public ActionResult UpdatePwdView()
|
{
|
string id = Cookie.GetValue("login_admin");
|
UserInfo viewModel = new UserInfo();
|
if (string.IsNullOrEmpty(id) == false && int.Parse(id) > 0)
|
{
|
viewModel = m_AccountService.Users(int.Parse(id));
|
return View(viewModel);
|
}
|
return View(viewModel);
|
}
|
public ActionResult UpdatePwd(UserInfo info)
|
{
|
m_AccountService.UpdeteUser(info);
|
return Json("ok");
|
}
|
public ActionResult GetAdmin()
|
{
|
UserInfo viewModel = new UserInfo();
|
string id = Cookie.GetValue("login_admin");
|
if (string.IsNullOrEmpty(id) == false && int.Parse(id) > 0)
|
{
|
viewModel = m_AccountService.Users(int.Parse(id));
|
return Json(viewModel, JsonRequestBehavior.AllowGet);
|
}
|
return Json(viewModel);
|
}
|
[AdminLogin]
|
public ActionResult Approvals()
|
{
|
return View(new StandAnswerManagePageViewModel());
|
}
|
[AdminLogin]
|
public ActionResult ApprovalDetail(int qcDistributionId)
|
{
|
return View(new ApprovalDetailsPageViewModel(qcDistributionId));
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult ImportApprovals(int qcTargetDistId, int qcSourceDistId)
|
{
|
var approvals = _qcService.GetApprovals().Where(p => p.QCDistributionID == qcSourceDistId).ToList();
|
var nowApprovals = _qcService.GetApprovals().Where(p => p.QCDistributionID == qcTargetDistId).ToList();
|
nowApprovals.ForEach(x =>
|
{
|
_qcService.DeleteApproval(x);
|
});
|
approvals.ForEach(x =>
|
{
|
ApprovalInfo copy = ClassValueCopier.Mapper<ApprovalInfo, ApprovalInfo>(x);
|
copy.Id = 0;
|
copy.QCDistributionID = qcTargetDistId;
|
_qcService.SaveApproval(copy);
|
});
|
return Json(new ApprovalDetailsPageViewModel(qcTargetDistId));
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult SaveApprovalDetail(ApprovalDetailsPageViewModel viewModel)
|
{
|
viewModel.Approvals.ForEach(x =>
|
{
|
x.QCDistributionID = viewModel.qcDistributionId;
|
_qcService.SaveApproval(ApprovalInfoViewModel.ToEntity(x));
|
});
|
return Json("");
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult DeleteApprovalDetail(ApprovalInfoViewModel viewModel)
|
{
|
_qcService.DeleteApproval(PalGainEngine.Instance.Resolve<QCService>().GetApprovals()
|
.FirstOrDefault(p => p.Id == viewModel.Id));
|
return Json("");
|
}
|
[AdminLogin]
|
public ActionResult QCDistribution()
|
{
|
return View(new QCDistributionPageViewModel());
|
}
|
[AdminLogin]
|
public ActionResult QCDistributionLabs(int qcDistId, int pageIndex)
|
{
|
return View(new QCDistributionPageViewModel(qcDistId, pageIndex, 20));
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult QCDistributionLabs(int qcDistId, string keyWord)
|
{
|
return Json(new QCDistributionPageViewModel(qcDistId, keyWord, 1, 20));
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult DosendBatchEmail(int type, int qcDistributionId, int projectId)
|
{
|
var regList = _qcService.GetQcDistributionRegisters()
|
.Where(p => p.QCDistributionId == qcDistributionId);
|
if (projectId > 0)
|
{
|
regList = regList.Where(p => p.ProjectId == projectId);
|
}
|
if (regList == null || regList.Count() == 0)
|
{
|
return Json("nolab");
|
}
|
regList.ToList().ForEach(x =>
|
{
|
_qcService.SendMail(x.LabInfo, x, type);
|
});
|
return Json("OK");
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult SendEmail(int type, int qcDistRegInfoId)
|
{
|
QCDistributionRegisterInfo regInfo = _qcService.GetQcDistributionRegisters().FirstOrDefault(p => p.Id == qcDistRegInfoId);
|
if (regInfo.LabInfo == null)
|
{
|
return Json("nolab");
|
}
|
_qcService.SendMail(regInfo.LabInfo, regInfo, type);
|
return Json("OK");
|
}
|
[AdminLogin]
|
public ActionResult ConfigrmFee(QCDistributionRegisterInfoViewModel regInfoivewModel)
|
{
|
QCDistributionRegisterInfo entity = regInfoivewModel.ToEntityByLabCode(regInfoivewModel);
|
if (entity == null)
|
{
|
return Json(regInfoivewModel);
|
}
|
entity.LetterNo = regInfoivewModel.LetterNo;
|
entity.ChargeRemark = regInfoivewModel.ChargeRemark;
|
entity.IsCharged = true;
|
entity.ChargeTime = DateTime.Now;
|
_qcService.SaveQcDistributionRegister(entity);
|
//发送邮件
|
var labInfo = m_AccountService.GetUserRequestInfoQueryable()
|
.FirstOrDefault(p => p.LabCode == regInfoivewModel.LabCode);
|
if (labInfo != null)
|
{
|
_qcService.SendMail(labInfo, entity, 14);
|
}
|
regInfoivewModel.IsCharged = true;
|
//发送邮件结束
|
return Json(regInfoivewModel);
|
}
|
[AdminLogin]
|
public ActionResult ConfigrmEMS(QCDistributionRegisterInfoViewModel regInfoivewModel)
|
{
|
QCDistributionRegisterInfo entity = regInfoivewModel.ToEntityByLabCode(regInfoivewModel);
|
if (entity == null)
|
{
|
return Json(regInfoivewModel);
|
}
|
entity.EMSNo = regInfoivewModel.EMSNo;
|
entity.IsSendEMS = true;
|
entity.SendEMSTime = DateTime.Now;
|
_qcService.SaveQcDistributionRegister(entity);
|
if (regInfoivewModel.IsSendEmail)
|
{
|
//发送邮件
|
var labInfo = m_AccountService.GetUserRequestInfoQueryable()
|
.FirstOrDefault(p => p.LabCode == regInfoivewModel.LabCode);
|
if (labInfo != null)
|
{
|
_qcService.SendMail(labInfo, entity, 13);
|
}
|
//发送邮件结束
|
}
|
return Json(regInfoivewModel);
|
}
|
[HttpPost]
|
public ActionResult ImportLabs(int oriDistId, int TargetDistId)
|
{
|
QCDistribution qcDistInfo = _qcService.GetQcDistributions()
|
.FirstOrDefault(p => p.Id == TargetDistId);
|
var delList = _qcService.GetQcDistributionRegisters().Where(p => p.QCDistributionId == TargetDistId).ToList();
|
for (int i = 0; i < delList.Count; i++)
|
{
|
_qcService.DeleteQcDistributionRegister(delList[i]);
|
}
|
_qcService.GetQcDistributionRegisters().Where(p => p.QCDistributionId == oriDistId
|
&& p.LabInfo.State == 1).ToList().ForEach(x =>
|
{
|
var newEntityInfo = new QCDistributionRegisterInfo();
|
newEntityInfo.QCDistributionId = TargetDistId;
|
newEntityInfo.Id = 0;
|
newEntityInfo.LabId = x.LabId;
|
newEntityInfo.ProjectId = x.ProjectId;
|
newEntityInfo.ModifyTime = DateTime.Now;
|
qcDistInfo.QCDistributionRegisters.Add(newEntityInfo);
|
});
|
_qcService.SaveQcDistribution(qcDistInfo);
|
return Json(new QCDistributionPageViewModel(TargetDistId, 1, 20));
|
}
|
public ActionResult switchNextOne(QCDistributionRegisterInfoViewModel regInfoivewModel)
|
{
|
QCDistributionRegisterInfo entity = regInfoivewModel.ToEntityByLabCode(regInfoivewModel);
|
if (entity == null)
|
{
|
return Json(regInfoivewModel);
|
}
|
QCDistributionRegisterInfo regInfo = _qcService.GetNextOneQCDistRegInfo(entity);
|
QCDistributionRegisterInfoViewModel viewModel = QCDistributionRegisterInfoViewModel.FromEntity(regInfo);
|
viewModel.AnswerInfo = null;
|
viewModel.AnswerJSON = "";
|
return Json(viewModel);
|
}
|
[AdminLogin]
|
public ActionResult StandAnswerManage()
|
{
|
return View(new StandAnswerManagePageViewModel());
|
}
|
[AdminLogin]
|
public ActionResult StandAnswerInfo(int qcDistributionId)
|
{
|
return View(new ShowPageViewModel().GetStandAnswerInfo(qcDistributionId));
|
}
|
[AdminLogin]
|
public ActionResult SaveStandAnswerInfo(QCDistributionRegisterInfoViewModel viewModel)
|
{
|
_qcService.SaveQcDistribution(
|
QCDistributionInfoViewModel.ToEntityForAnswerInfo(new QCDistributionInfoViewModel()
|
{
|
AnswerInfo = viewModel.AnswerInfo,
|
AnswerJSON = viewModel.AnswerJSON,
|
Id = viewModel.QCDistributionId,
|
}));
|
return Json("");
|
}
|
|
|
private ShowPageViewModel calc(int qcId)
|
{
|
ShowPageViewModel viewModel = new ShowPageViewModel(qcId, 1, 2000);
|
|
//LogHelper.Debug("calc:" + JsonConvert.SerializeObject(viewModel));
|
|
var scores = viewModel.RegList.Where(p => p.Scores != null).SelectMany(p => p.Scores).ToList();
|
var tempArray = "Patient1X,Patient1Y,Patient1Z,Patient2X,Patient2Y,Patient2Z,Patient3X,Patient3Y,Patient3Z,Filter1,Filter2,Filter3,Identity1,Identity2,Identity3,ZhiKang1,ZhiKang2,ZhiKang3".Split(",");
|
tempArray.ForEach(temp =>
|
{
|
var tempList = scores.Where(p => p.Name == temp).ToList();
|
var allCount = tempList.Count();
|
var errCount = tempList.Where(p => p.RealValue != p.StandValue).Count();
|
|
var percentage = 1 - ((double)errCount / (double)allCount);
|
double adjust = 1;
|
if (percentage < 0.8)
|
{
|
adjust = 0.5;
|
}
|
if (percentage < 0.6)
|
{
|
adjust = 0.25;
|
}
|
tempList.ForEach(scoreInfo =>
|
{
|
scoreInfo.RealScore = scoreInfo.RealScore * adjust;
|
});
|
});
|
return viewModel;
|
}
|
|
[AdminLogin]
|
public ActionResult AnswerList(int qcDistributionId, string pageIndex)
|
{
|
try
|
{
|
int PageIndex = 1;
|
if (string.IsNullOrEmpty(pageIndex) == false)
|
{
|
PageIndex = Convert.ToInt32(pageIndex);
|
}
|
//ShowPageViewModel viewModel = new ShowPageViewModel(qcDistributionId, PageIndex, 20);
|
ShowPageViewModel viewModel = calc(qcDistributionId);
|
viewModel.RegList = viewModel.RegList.Skip((PageIndex - 1) * 20).Take(20).ToList();
|
viewModel.PageNavInfo = new PageNavigationViewModel(PageIndex, viewModel.regListCount, 20);
|
|
var DbCount = _qcService.GetResultSpercentages().ToList().FirstOrDefault(p => p.QCDistributionId == qcDistributionId);
|
viewModel.RegList.ForEach(regInfo =>
|
{
|
if (DbCount == null)
|
{
|
regInfo.IsCount = false;
|
}
|
else
|
{
|
regInfo.IsCount = true;
|
}
|
regInfo.AnswerInfo = null;
|
regInfo.AnswerJSON = "";
|
});
|
viewModel.selectList = new SelectExcelCell() { QCid = qcDistributionId };
|
return View(viewModel);
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
return Content("出现错误:" + ex.ToString());
|
}
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult AnswerListSearch(int qcDistributionId, int? pageIndex,
|
string searchField, string searchValue)
|
{
|
var DbCount = _qcService.GetResultSpercentages().ToList().FirstOrDefault(p => p.QCDistributionId == qcDistributionId);
|
ShowPageViewModel viewModel = new ShowPageViewModel().DoSearch(qcDistributionId,
|
pageIndex.GetValueOrDefault(), 99, searchField, searchValue);
|
viewModel.RegList.ForEach(regInfo =>
|
{
|
regInfo.AnswerInfo = null;
|
regInfo.AnswerJSON = "";
|
if (DbCount == null)
|
{
|
regInfo.IsCount = false;
|
}
|
else
|
{
|
regInfo.IsCount = true;
|
}
|
});
|
return Json(viewModel);
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult DoSubmitAll(int qcDistributionId)
|
{
|
|
string Useerid = Cookie.GetValue("login_admin");
|
var distInfo = _qcService.GetQcDistributions().FirstOrDefault(p => p.Id == qcDistributionId);
|
if (distInfo != null && distInfo.QCDistributionRegisters.Count > 0)
|
{
|
distInfo.QCDistributionRegisters.ForEach(info =>
|
{
|
info.IsSubmit = true;
|
info.SubmitTime = DateTime.Now;
|
info.SubmitUserNo = Useerid;
|
_qcService.SaveQcDistributionRegister(info);
|
});
|
}
|
distInfo.IsAllSubmit = true;
|
distInfo.AllSubmitTime = DateTime.Now;
|
_qcService.SaveQcDistribution(distInfo);
|
return GetAnswerList(qcDistributionId, 1, 20);
|
}
|
//报表统计%比
|
public ActionResult DoStatistics(int qcDistributionId)
|
{
|
try
|
{
|
CountModel c = new CountModel();
|
c.Calculation(qcDistributionId);
|
return Json("ok");
|
}
|
catch (Exception e)
|
{
|
LogHelper.Error(e);
|
return Json(e.Message);
|
}
|
}
|
[AdminLogin]
|
public ActionResult GetAnswerList(int qcDistributionId, int pageIndex, int maxItemsInPage)
|
{
|
return Json(new ShowPageViewModel(qcDistributionId, pageIndex, maxItemsInPage));
|
}
|
[AdminLogin]
|
public ActionResult AnswerManage()
|
{
|
return View(new StandAnswerManagePageViewModel());
|
}
|
[AdminLogin]
|
public ActionResult UserAnswerInfo(int qcDistributionId, int LabId)
|
{
|
ShowPageViewModel viewModel = null;
|
try
|
{
|
viewModel = new ShowPageViewModel(qcDistributionId, LabId);
|
viewModel.IsAdmin = true;
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
}
|
return View(viewModel);
|
}
|
[AdminLogin]
|
public ActionResult SwitchSubmitState(QCDistributionRegisterInfoViewModel viewModel)
|
{
|
try
|
{
|
var entity = QCDistributionRegisterInfoViewModel.ToEntity(viewModel);
|
entity.ModifyUser = "admin";
|
entity.ModifyTime = DateTime.Now;
|
entity.IsSubmit = viewModel.IsSubmit;
|
_qcService.SaveQcDistributionRegister(entity);
|
return Json(viewModel, JsonRequestBehavior.AllowGet);
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
return Json("");
|
}
|
}
|
[AdminLogin]
|
public ActionResult saveAnswerInfo(QCDistributionRegisterInfoViewModel viewModel)
|
{
|
var entity = QCDistributionRegisterInfoViewModel.ToEntity(viewModel);
|
entity.ModifyUser = "admin";
|
entity.ModifyTime = DateTime.Now;
|
entity.AnswerJSON = JsonConvert.SerializeObject(viewModel.AnswerInfo);
|
_qcService.SaveQcDistributionRegister(entity);
|
return Json(viewModel, JsonRequestBehavior.AllowGet);
|
}
|
public ActionResult GetPaperContent(int qcDistributionId, int LabId)
|
{
|
return Json(new ShowPageViewModel(qcDistributionId, LabId));
|
}
|
|
public ActionResult PrintLabInfo(string rdlcName, int labInfoId, int qcDistributionId)
|
{
|
string rdlcPath = Path.Combine(Directory.GetParent(AssemblyHelper.GetBaseDirectory()).FullName,
|
"Reports", rdlcName);
|
string savePath = Path.Combine(Directory.GetParent(AssemblyHelper.GetBaseDirectory()).FullName,
|
"Reports", "temp");
|
if (System.IO.Directory.Exists(savePath) == false)
|
{
|
Directory.CreateDirectory(savePath);
|
}
|
string filePath = _qcService.GetPDFFromEMS(rdlcPath, labInfoId, qcDistributionId);
|
FileInfo fileInfo = new FileInfo(filePath);
|
System.IO.File.Copy(filePath, Path.Combine(savePath, fileInfo.Name), true);
|
return Json(string.Format("{0}/Reports/temp/{1}", Request.Url.Authority, fileInfo.Name));
|
}
|
|
public ActionResult PrintEnvelope(int labInfoId, int qcDistributionId)
|
{
|
string rdlcPath = Path.Combine(Directory.GetParent(AssemblyHelper.GetBaseDirectory()).FullName,
|
"Reports", "EnvelopeInfo.rdlc");
|
string savePath = Path.Combine(Directory.GetParent(AssemblyHelper.GetBaseDirectory()).FullName,
|
"Reports", "temp");
|
if (System.IO.Directory.Exists(savePath) == false)
|
{
|
Directory.CreateDirectory(savePath);
|
}
|
string filePath = _qcService.GetPDFFromEMS(rdlcPath, labInfoId, qcDistributionId);
|
FileInfo fileInfo = new FileInfo(filePath);
|
System.IO.File.Copy(filePath, Path.Combine(savePath, fileInfo.Name), true);
|
return Json(string.Format("{0}/Reports/temp/{1}", Request.Url.Authority, fileInfo.Name));
|
|
|
}
|
|
public ActionResult sendEMSEmail(int labInfoId, int qcDistributionId)
|
{
|
Menus emailTemplateInfo = m_AccountService.GetMenus().FirstOrDefault(p => p.Category == "4" && p.Name.ToLower() == "质评发放ems");
|
UserRequestInfo labInfo = m_AccountService.GetUserRequestInfoQueryable().FirstOrDefault(p => p.Id == labInfoId);
|
sbcLabSystem.Data.Domain.Backstage.QCDistribution qcDistributionInfo = _qcService.GetQcDistributions().FirstOrDefault(p => p.Id == qcDistributionId);
|
var content = emailTemplateInfo.Contents.Replace("[负责人名称]", labInfo.ManagerName)
|
.Replace("[操作人名称]", labInfo.OperatorName)
|
.Replace("[质评号]", qcDistributionInfo.DistNo)
|
.Replace("[实验室编码]", labInfo.LabCode)
|
.Replace("[实验室登录名]", labInfo.LabLoginName)
|
.Replace("[实验室密码]", labInfo.LabPassword)
|
.Replace("[质评开始日期]", qcDistributionInfo.IssuedDate.GetValueOrDefault().ToString("yyyy-MM-dd"))
|
.Replace("[质评结束日期]", qcDistributionInfo.CloseDate.GetValueOrDefault().ToString("yyyy-MM-dd")); ;
|
sbcLabSystem.Data.Domain.Backstage.EmileInfo emailInfo = new EmileInfo()
|
{
|
Boody = content,
|
Type = int.Parse(emailTemplateInfo.Category),
|
Explain = emailTemplateInfo.Title,
|
EmileName = labInfo.ManagerEmail,
|
Title = emailTemplateInfo.Title,
|
SendOutDatetime = DateTime.Now,
|
};
|
m_AccountService.InserEmilinfo(emailInfo);
|
return Json("");
|
}
|
[AdminLogin]
|
public ActionResult GetLabList(int qcDistNo, int pageIndex)
|
{
|
int maxItemCountInPage = 10;
|
int tempIndex = 0;
|
int rowCount = m_AccountService.GetUserRequestInfoQueryable().Count();
|
if (rowCount % maxItemCountInPage > 0)
|
{
|
tempIndex = (rowCount / maxItemCountInPage) + 1;
|
}
|
else
|
{
|
tempIndex = rowCount / maxItemCountInPage;
|
}
|
if (pageIndex > tempIndex)
|
{
|
pageIndex = tempIndex;
|
}
|
QCDistributionInfoViewModel qcDistInfoViewModel = QCDistributionInfoViewModel.FromEntity(
|
_qcService.GetQcDistributions().FirstOrDefault(p => p.Id == qcDistNo), pageIndex, maxItemCountInPage);
|
qcDistInfoViewModel.CurrentPageIndex = pageIndex;
|
qcDistInfoViewModel.LastPageIndex = tempIndex;
|
return Json(qcDistInfoViewModel, JsonRequestBehavior.AllowGet);
|
}
|
[AdminLogin]
|
public ActionResult SaveLabList(QCDistributionInfoViewModel viewModel)
|
{
|
try
|
{
|
_qcService.SaveQcDistribution(QCDistributionInfoViewModel.ToEntity(viewModel));
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
throw ex;
|
}
|
return Json("", JsonRequestBehavior.AllowGet);
|
}
|
[AdminLogin]
|
public ActionResult addNewQcDistribution(QCDistributionPageViewModel viewModel)
|
{
|
if (viewModel.QCDistributions == null)
|
{
|
viewModel.QCDistributions = new List<QCDistributionInfoViewModel>();
|
}
|
viewModel.QCDistributions.Add(new QCDistributionInfoViewModel());
|
return Json(viewModel, JsonRequestBehavior.AllowGet);
|
}
|
public ActionResult SaveDistribution(QCDistributionPageViewModel viewModel)
|
{
|
viewModel.QCDistributions.ForEach(x =>
|
{
|
_qcService.SaveQcDistribution(QCDistributionInfoViewModel.ToEntity(x));
|
});
|
viewModel.QCDistributions = QCDistributionInfoViewModel.ToList();
|
return Json(viewModel, JsonRequestBehavior.AllowGet);
|
}
|
[AdminLogin]
|
public ActionResult deleteDistribution(QCDistributionInfoViewModel viewModel)
|
{
|
_qcService.DeleteQcDistribution(QCDistributionInfoViewModel.ToEntity(viewModel));
|
QCDistributionPageViewModel viewModel2 = new QCDistributionPageViewModel();
|
viewModel2.QCDistributions = QCDistributionInfoViewModel.ToList();
|
return Json(viewModel2, JsonRequestBehavior.AllowGet);
|
}
|
public ActionResult deleteDistributionRegisterInfo(UserRequestViewModel viewModel)
|
{
|
QCDistributionRegisterInfo registerInfo = _qcService.GetQcDistributionRegisters()
|
.FirstOrDefault(p => p.Id == viewModel.QCDistributionRegisterId);
|
_qcService.DeleteQcDistributionRegister(registerInfo);
|
return Json("");
|
}
|
|
|
[AdminLogin]
|
//
|
// GET: /Backstage/
|
public ActionResult Index(string Page, string State, DateTime? date1, DateTime? date2)
|
{
|
int pageInt = 1;
|
int StateInt = 0;
|
if (string.IsNullOrEmpty(State) == false)
|
{
|
int.TryParse(State, out StateInt);
|
}
|
if (string.IsNullOrEmpty(Page) == false)
|
{
|
int.TryParse(Page, out pageInt);
|
}
|
if (pageInt == 0)
|
{
|
pageInt = 1;
|
}
|
if (date1 != null)
|
{
|
UserRequestViewModel1 viewModel2 = UserRequestViewModel1.GetUserRequestViewModel2(pageInt, date1, date2);
|
viewModel2.CurrentPageIndex = pageInt;
|
return View(viewModel2);
|
}
|
UserRequestViewModel1 viewModel = UserRequestViewModel1.GetUserRequestViewModel(pageInt, StateInt, "", "", "");
|
viewModel.CurrentPageIndex = pageInt;
|
return View(viewModel);
|
}
|
public ActionResult PageIndex(string Page, string State, DateTime? date1, DateTime? date2)
|
{
|
int pageInt = 1;
|
int StateInt = 0;
|
if (string.IsNullOrEmpty(State) == false)
|
{
|
int.TryParse(State, out StateInt);
|
}
|
if (string.IsNullOrEmpty(Page) == false)
|
{
|
int.TryParse(Page, out pageInt);
|
}
|
if (pageInt == 0)
|
{
|
pageInt = 1;
|
}
|
if (date1 != null)
|
{
|
UserRequestViewModel1 viewModel2 = UserRequestViewModel1.GetUserRequestViewModel2(pageInt, date1, date2);
|
viewModel2.CurrentPageIndex = pageInt;
|
return Json(viewModel2);
|
}
|
UserRequestViewModel1 viewModel = UserRequestViewModel1.GetUserRequestViewModel(pageInt, StateInt, "", "", "");
|
viewModel.CurrentPageIndex = pageInt;
|
return Json(viewModel);
|
}
|
public ActionResult IndexSou(string Page, DateTime date1, DateTime date2)
|
{
|
int pageInt = 1;
|
if (string.IsNullOrEmpty(Page) == false)
|
{
|
int.TryParse(Page, out pageInt);
|
}
|
if (pageInt == 0)
|
{
|
pageInt = 1;
|
}
|
UserRequestViewModel1 viewModel = UserRequestViewModel1.GetUserRequestViewModel2(pageInt, date1, date2);
|
viewModel.CurrentPageIndex = pageInt;
|
return Json(viewModel);
|
}
|
[AdminLogin]
|
public ActionResult ViewAdmin()
|
{
|
MenusViewModel viewModel = new MenusViewModel();
|
viewModel.MenusList = m_AccountService.GetMenus().Where(p => p.Category == "1").ToList();
|
return View(viewModel);
|
}
|
[ValidateInput(false)]
|
[AdminLogin]
|
public ActionResult ViewDetailed(string MenuId)
|
{
|
Menus model = new Menus();
|
if (string.IsNullOrEmpty(MenuId) == false)
|
{
|
Menus info = m_AccountService.MenusId(Convert.ToInt32(MenuId));
|
if (info != null)
|
{
|
model = info;
|
|
}
|
}
|
return View(model);
|
}
|
[AdminLogin]
|
public ActionResult UpdeteMenus(Menus info)
|
{
|
if (info != null)
|
{
|
if (info.Id > 0)
|
{
|
m_AccountService.UpdateMenu(info);
|
}
|
else if (info.Id == 0 && info.Category == "4")
|
{
|
info.Time = DateTime.Now;
|
info.Category = "4";
|
m_AccountService.InsertMenu(info);
|
}
|
else if (info.Id == 0)
|
{
|
info.Time = DateTime.Now;
|
info.Category = "2";
|
m_AccountService.InsertMenu(info);
|
}
|
|
|
}
|
|
return Json(info.Category);
|
}
|
[AdminLogin]
|
public ActionResult Notices()
|
{
|
MenusViewModel viewModel = new MenusViewModel();
|
viewModel.MenusList = m_AccountService.GetMenus().Where(p => p.Category == "2").ToList();
|
return View(viewModel);
|
|
}
|
|
public ActionResult GetNoticeinfo()
|
{
|
MenusViewModel viewModel = new MenusViewModel();
|
viewModel.MenusList = m_AccountService.GetMenus().Where(p => p.Category == "2").ToList();
|
return Json(viewModel, JsonRequestBehavior.AllowGet);
|
}
|
[AdminLogin]
|
public ActionResult Noticeinfo(string MenuId)
|
{
|
Menus model = new Menus();
|
if (string.IsNullOrEmpty(MenuId) == false)
|
{
|
Menus info = m_AccountService.MenusId(Convert.ToInt32(MenuId));
|
if (info != null)
|
{
|
model = info;
|
|
}
|
}
|
return View(model);
|
}
|
[AdminLogin]
|
public ActionResult Template(string MenuId)
|
{
|
Menus model = new Menus();
|
if (string.IsNullOrEmpty(MenuId) == false)
|
{
|
model.Url = "管理员";
|
model.Category = "4";
|
Menus info = m_AccountService.MenusId(Convert.ToInt32(MenuId));
|
if (info != null)
|
{
|
model = info;
|
|
}
|
}
|
|
return View(model);
|
}
|
[AdminLogin]
|
public ActionResult DeletenNotice(string Id)
|
{
|
if (string.IsNullOrEmpty(Id) == false)
|
{
|
Menus info = m_AccountService.MenusId(Convert.ToInt32(Id));
|
if (info != null)
|
{
|
m_AccountService.DeleteMenu(info);
|
|
}
|
}
|
return Json("ok");
|
}
|
[AdminLogin]
|
public ActionResult AddLab(string LabId, string state)
|
{
|
LabViewModel viewModel = new LabViewModel().Init(int.Parse(LabId));
|
viewModel.State = string.IsNullOrEmpty(state) == false ? 1 : 0;
|
return View(viewModel);
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult GetSimilarLab(string LabName)
|
{
|
LabViewModel viewModel = new LabViewModel().Search(LabName);
|
return Json(viewModel);
|
}
|
[HttpPost, AdminLogin]
|
public ActionResult ConfirmLabInfo(int oriLabId, UserRequestInfoModel targetLab)
|
{
|
UserRequestInfo targetLabs = ClassValueCopier.Mapper<UserRequestInfo, UserRequestInfoModel>(targetLab);
|
m_AccountService.ConfirmLabInfo(oriLabId, targetLabs);
|
LabViewModel viewModel = new LabViewModel().Init(targetLab.Id);
|
return Json(viewModel);
|
}
|
[AdminLogin]
|
public ActionResult LabAdminAddLab(string LabId, string state)
|
{
|
LabViewModel viewModel = new LabViewModel();
|
viewModel.Labinfo = new UserRequestInfoModel();
|
viewModel.State = 0;
|
|
if (string.IsNullOrEmpty(state) == false)
|
{
|
viewModel.State = 1;
|
}
|
if (string.IsNullOrEmpty(LabId) == false)
|
{
|
viewModel.Labinfo = UserRequestInfoModel.FromEntity(m_AccountService.UserRequestInfo(int.Parse(LabId)));
|
|
}
|
return View(viewModel);
|
}
|
/// <summary>
|
/// 上一个
|
/// </summary>
|
/// <param name="LabCode"></param>
|
/// <returns></returns>
|
public ActionResult SetpLab(string LabCode, string shang)
|
{
|
UserRequestInfoModel model = new UserRequestInfoModel();
|
var LIST = m_AccountService.GetAllUserRequestInfoQueryable().Where(p => p.State == 1).OrderBy(p => p.LabCode).ToList();
|
for (int x = 0; x < LIST.Count; x++)
|
{
|
if (LIST[x].LabCode == LabCode)
|
{
|
if (shang == "shang")
|
{
|
if ((x - 1) >= 0)
|
{
|
model = UserRequestInfoModel.FromEntity(LIST[x - 1]);
|
break;
|
}
|
|
}
|
else if (x + 1 < LIST.Count)
|
{
|
model = UserRequestInfoModel.FromEntity(LIST[x + 1]);
|
break;
|
}
|
}
|
}
|
return Json(model);
|
}
|
[AdminLogin]
|
public ActionResult CheckLab(string Id, string CompanyName)
|
{
|
CheckLabViewMod viewModel = new CheckLabViewMod();
|
if (string.IsNullOrEmpty(Id) == false)
|
{
|
viewModel.LabId = int.Parse(Id);
|
}
|
|
return RedirectToRoute(new { controller = "Backstage", action = "AddLab", LabId = Id });
|
}
|
[AdminLogin]
|
//实验室保存
|
public ActionResult SubmitLab(UserRequestInfo info)
|
{
|
if (info.Id > 0)
|
{
|
info.UpdateTime = DateTime.Now;
|
Random rd = new Random();
|
string str = "";
|
if (string.IsNullOrEmpty(info.LabPassword))
|
{
|
while (str.Length < 6)
|
{
|
int temp = rd.Next(0, 9);
|
str += temp;
|
}
|
info.LabPassword = str;
|
}
|
var stage = info.State;
|
info.State = 1;
|
m_AccountService.UpdateUserRequestInfo(info);
|
if (stage == 0)
|
{
|
_qcService.SendMail(info.Id, 12);
|
}
|
return Json(info);
|
}
|
else
|
{
|
info.UpdateTime = DateTime.Now;
|
info.RequestTime = DateTime.Now;
|
m_AccountService.InsertUserRequestInfo(info);
|
}
|
return Json(info);
|
}
|
[AdminLogin]
|
public ActionResult DeleteLab(string ID)
|
{
|
if (string.IsNullOrEmpty(ID) == false)
|
{
|
int temp = 0;
|
int.TryParse(ID, out temp);
|
if (temp > 0)
|
{
|
m_AccountService.DeleteUserRequestInfo(temp);
|
}
|
}
|
return Json("ok");
|
}
|
[AdminLogin]
|
public ActionResult DeleteLabs(string LabIds)
|
{
|
if (string.IsNullOrEmpty(LabIds) == false)
|
{
|
string[] sArray = LabIds.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
if (sArray.Length > 0)
|
{
|
|
for (int x = 0; x < sArray.Length; x++)
|
{
|
if (string.IsNullOrEmpty(sArray[x].ToString()) == false)
|
{
|
DeleteLab(sArray[x].ToString());
|
}
|
}
|
}
|
}
|
|
return RedirectToAction("LabAdmin", "Backstage");
|
}
|
[AdminLogin]
|
public ActionResult LabAdmin(string Page, string where, string name)
|
{
|
int pageInt = 1;
|
int StateInt = 1;
|
|
if (string.IsNullOrEmpty(Page) == false)
|
{
|
int.TryParse(Page, out pageInt);
|
}
|
if (pageInt == 0)
|
{
|
pageInt = 1;
|
}
|
UserRequestViewModel1 viewModel = UserRequestViewModel1.GetUserRequestViewModel(pageInt, StateInt, where, name, "admin");
|
viewModel.CurrentPageIndex = pageInt;
|
viewModel.UserRequestInfoList.OrderBy(p => p.LabCode).ToList();
|
viewModel.where = where;
|
viewModel.name = name;
|
return View(viewModel);
|
}
|
public ActionResult LabExcelDate(DateTime Date1, DateTime Date2)
|
{
|
List<UserRequestInfo> UserRequestInfoList = m_AccountService.GetUserRequestInfo().Where(p => p.State == 1 && p.UpdateTime > Date1 && p.UpdateTime < Date2).OrderBy(p => p.LabCode).ToList();
|
DataTable dt = ExcelUtil.ConvertToDataTable(UserRequestInfoList);
|
string TableName = DateTime.Now.ToString("yyMMddHHmmssfff") + "实验室.xls";
|
string[] headers = { "实验室编号", "用户名", "单位名称", "实验室名称", "地址", "城市", "参加项目代号", "负责人", "固话", "传真", "手机号码", "邮箱", "操作人", "固话", "传真", "手机号码", "邮箱", "申请时间", "审核时间" };
|
string[] cellKes = { "LabCode", "LabLoginName", "CompanyName", "LabName", "Address", "Province", "ProjectId", "ManagerName", "ManagerPhone", "ManagerFax", "ManagerMobile", "ManagerEmail", "OperatorName", "OperatorPhone", "OperatorFax", "OperatorMobile", "OperatorEmail", "RequestTime", "UpdateTime" };
|
ExcelUtil.ExportByWeb(dt, "实验室列表", headers, cellKes, TableName);
|
return View("LabAdmin");
|
}
|
[AdminLogin]
|
public ActionResult LabExcel()
|
{
|
List<UserRequestInfo> UserRequestInfoList = m_AccountService.GetUserRequestInfo().Where(p => p.State == 1).OrderBy(p => p.LabCode).ToList();
|
DataTable dt = ExcelUtil.ConvertToDataTable(UserRequestInfoList);
|
string TableName = DateTime.Now.ToString("yyMMddHHmmssfff") + "实验室.xls";
|
string[] headers = { "实验室编号", "用户名", "单位名称", "实验室名称", "邮编", "地址", "城市", "参加项目代号", "负责人", "固话", "传真", "手机号码", "邮箱", "操作人", "固话", "传真", "手机号码", "邮箱", "申请时间", "审核时间" };
|
string[] cellKes = { "LabCode", "LabLoginName", "CompanyName", "LabName", "PostCode", "Address", "Province", "ProjectId", "ManagerName", "ManagerPhone", "ManagerFax", "ManagerMobile", "ManagerEmail", "OperatorName", "OperatorPhone", "OperatorFax", "OperatorMobile", "OperatorEmail", "RequestTime", "UpdateTime" };
|
ExcelUtil.ExportByWeb(dt, "实验室列表", headers, cellKes, TableName);
|
return View("LabAdmin");
|
}
|
|
//[AdminLogin]
|
public ActionResult downloadStat(int qcDistributionId)
|
{
|
try
|
{
|
List<StatInfo> statInfos = new List<StatInfo>();
|
Dictionary<string, int> statResultInfo = new Dictionary<string, int>();
|
List<string> fields_1 = new List<string>();
|
List<string> fields_2 = new List<string>();
|
fields_1.AddRange(new string[] { "CB3_11", "CB3_12", "CB3_13", "CB3_14", "CB3_15", "CB3_16", "CB3_17", "CB3_18", "CB3_19" });
|
for (int i = 1; i <= 7; i++)
|
{
|
for (int j = 1; j <= 5; j++)
|
{
|
fields_2.Add("CB5_" + i.ToString() + j.ToString());
|
}
|
}
|
var list = this._qcService.GetQcDistributionRegisters().Where(p => p.IsSubmit && p.QCDistributionId == qcDistributionId).ToList();
|
list.ForEach(n =>
|
{
|
if (string.IsNullOrEmpty(n.AnswerJSON))
|
{
|
return;
|
}
|
JObject answerJson = JsonConvert.DeserializeObject<JObject>(n.AnswerJSON);
|
if (answerJson["Part1"].HasValues == false)
|
{
|
return;
|
}
|
if (answerJson["Part2"].HasValues == false)
|
{
|
return;
|
}
|
//LogHelper.Info(answerJson.ToString());
|
#region 第3题统计
|
fields_1.ForEach(p =>
|
{
|
LogHelper.Info(p);
|
if (answerJson["Part1"][p] == null)
|
{
|
return;
|
}
|
string field = "";
|
if (!string.IsNullOrEmpty(answerJson["Part1"][p].Value<string>()))
|
{
|
field = p + "ok";
|
}
|
else
|
{
|
field = p + "no";
|
}
|
int value2;
|
statResultInfo.TryGetValue(field, out value2);
|
value2++;
|
statResultInfo.AddOrUpdate(field, value2);
|
LogHelper.Info("解析完成");
|
});
|
#endregion
|
|
#region 第5题统计
|
fields_2.ForEach(p =>
|
{
|
string field = "";
|
if (!string.IsNullOrEmpty(answerJson["Part2"][p].Value<string>()))
|
{
|
field = p + "ok";
|
}
|
else
|
{
|
field = p + "no";
|
}
|
int value2;
|
statResultInfo.TryGetValue(field, out value2);
|
value2++;
|
statResultInfo.AddOrUpdate(field, value2);
|
});
|
#endregion
|
|
});
|
|
for (int i = 1; i <= 2; i++)
|
{
|
statInfos.Add(new StatInfo());
|
}
|
statInfos[0].item = "满意";
|
statInfos[1].item = "不满意";
|
int value;
|
statResultInfo.TryGetValue("CB3_11ok", out value);
|
statInfos[0].blood_p1 = value;
|
statResultInfo.TryGetValue("CB3_11no", out value);
|
statInfos[1].blood_p1 = value;
|
|
statResultInfo.TryGetValue("CB3_12ok", out value);
|
statInfos[0].blood_p2 = value;
|
statResultInfo.TryGetValue("CB3_12no", out value);
|
statInfos[1].blood_p2 = value;
|
|
statResultInfo.TryGetValue("CB3_13ok", out value);
|
statInfos[0].blood_p3 = value;
|
statResultInfo.TryGetValue("CB3_13no", out value);
|
statInfos[1].blood_p3 = value;
|
|
statResultInfo.TryGetValue("CB3_14ok", out value);
|
statInfos[0].cell_p1 = value;
|
statResultInfo.TryGetValue("CB3_14no", out value);
|
statInfos[1].cell_p1 = value;
|
|
statResultInfo.TryGetValue("CB3_15ok", out value);
|
statInfos[0].cell_p2 = value;
|
statResultInfo.TryGetValue("CB3_15no", out value);
|
statInfos[1].cell_p2 = value;
|
|
statResultInfo.TryGetValue("CB3_16ok", out value);
|
statInfos[0].cell_p3 = value;
|
statResultInfo.TryGetValue("CB3_16no", out value);
|
statInfos[1].cell_p3 = value;
|
|
statResultInfo.TryGetValue("CB3_17ok", out value);
|
statInfos[0].cell2_p1 = value;
|
statResultInfo.TryGetValue("CB3_17no", out value);
|
statInfos[1].cell2_p1 = value;
|
|
statResultInfo.TryGetValue("CB3_18ok", out value);
|
statInfos[0].cell2_p2 = value;
|
statResultInfo.TryGetValue("CB3_18no", out value);
|
statInfos[1].cell2_p2 = value;
|
|
statResultInfo.TryGetValue("CB3_19ok", out value);
|
statInfos[0].cell2_p3 = value;
|
statResultInfo.TryGetValue("CB3_19no", out value);
|
statInfos[1].cell2_p3 = value;
|
|
List<string> items = new List<string>() { "盐水试管", "抗人球试管", "聚凝胺", "柱凝集", "酶法", "微量板法", "其他" };
|
for (int i = 0; i < 7; i++)
|
{
|
StatInfo statInfo = new StatInfo();
|
statInfo.item = items[i];
|
statInfos.Add(statInfo);
|
statResultInfo.TryGetValue("CB5_" + (i + 1).ToString() + "1ok", out value);
|
statInfos[i + 2].abo = value;
|
statResultInfo.TryGetValue("CB5_" + (i + 1).ToString() + "2ok", out value);
|
statInfos[i + 2].d = value;
|
statResultInfo.TryGetValue("CB5_" + (i + 1).ToString() + "3ok", out value);
|
statInfos[i + 2].filter = value;
|
statResultInfo.TryGetValue("CB5_" + (i + 1).ToString() + "4ok", out value);
|
statInfos[i + 2].filter2 = value;
|
statResultInfo.TryGetValue("CB5_" + (i + 1).ToString() + "5ok", out value);
|
statInfos[i + 2].jiaochablood = value;
|
}
|
|
DataTable dt = ExcelUtil.ConvertToDataTable(statInfos);
|
string TableName = DateTime.Now.ToString("yyMMddHHmmssfff") + "结果统计.xls";
|
string[] headers = { "结果","患者血清P1", "患者血清P2", "患者血清P3", "患者细胞P1", "患者细胞P2", "患者细胞P3", "献血者细胞Dw", "献血者细胞Dy", "献血者细胞Dz"
|
, "ABO定型", "D定型", "抗体筛选", "抗体鉴定", "交叉配血"};
|
string[] cellKes = { "item","blood_p1", "blood_p2", "blood_p3", "cell_p1", "cell_p2", "cell_p3", "cell2_p1", "cell2_p2", "cell2_p3"
|
, "abo", "d", "filter", "filter2", "jiaochablood"};
|
ExcelUtil.ExportByWeb(dt, "结果统计", headers, cellKes, TableName);
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
}
|
return View("AnswerManage");
|
}
|
|
[AdminLogin]
|
public ActionResult OutputUnderTakenLabs(int qcDistId)
|
{
|
string distName = "";
|
List<OutputUnderTakenLabViewModel> qcLabList = this._qcService.GetQcDistributionRegisters()
|
.Where(p => p.QCDistributionId == qcDistId)
|
.OrderBy(p => p.LabInfo.LabCode)
|
.Select(p => new OutputUnderTakenLabViewModel()
|
{
|
distName = p.QCDistributionInfo.DistNo,
|
companyName = p.LabInfo.CompanyName,
|
isCharged = p.IsCharged ? 1 : 0,
|
labCode = p.LabInfo.LabCode,
|
labName = p.LabInfo.LabName,
|
projectClass = p.ProjectId,
|
province = p.LabInfo.Province,
|
address = p.LabInfo.Address,
|
email = p.LabInfo.ManagerEmail,
|
manager = p.LabInfo.ManagerName,
|
postcode = p.LabInfo.PostCode,
|
managerMobile = p.LabInfo.ManagerMobile,
|
operatorEmail = p.LabInfo.OperatorEmail,
|
operatorMobile = p.LabInfo.OperatorMobile,
|
operatorName = p.LabInfo.OperatorName,
|
})
|
.ToList();
|
|
DataTable dt = ExcelUtil.ConvertToDataTable(qcLabList);
|
if (qcLabList.Count > 0)
|
{
|
distName = qcLabList.FirstOrDefault().distName.ToUpper();
|
}
|
string TableName = distName + "参与实验室.xls";
|
string[] headers = { "实验室编号", "实验室名称", "单位名称", "省份", "质评项目",
|
"地址", "邮编","Email","管理员","手机号","操作员姓名","操作员Email","操作员手机号" };
|
string[] cellKes = { "labCode", "labName", "companyName", "province", "projectClass",
|
"address","postcode","email","manager","managerMobile","operatorName","operatorEmail","operatorMobile"};
|
ExcelUtil.ExportByWeb(dt, distName + "参与实验室列表", headers, cellKes, TableName);
|
return View("QCDistributionLabs");
|
}
|
|
|
|
public void ToExcel(int model)
|
{
|
try
|
{
|
var regInfo = _qcService.GetQcDistributionRegisters().FirstOrDefault(p => p.Id == model);
|
var viewModel = this.calc(regInfo.QCDistributionId);
|
string excelFileName = Server.MapPath(string.Format("~/Excel/{0}.xlsx", viewModel.QCDistInfo.DistNo));
|
//var regViewModelInfo = QCDistributionRegisterInfoViewModel.FromEntity(regInfo);
|
|
var regViewModelInfo = viewModel.RegList.Where(p => p.Id == model).FirstOrDefault();
|
var answerObject = JsonConvert.SerializeObject(regViewModelInfo.Scores);
|
var pdfFileName = _qcService.ExportPDF(excelFileName, regInfo, answerObject);
|
pdfFileName.Save(Response, string.Format("Report_{0}_{1}.pdf",
|
regInfo.QCDistributionInfo.DistNo,
|
regInfo.LabInfo.LabCode));
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
}
|
////输出
|
////System.IO.FileInfo filet = new System.IO.FileInfo(pdfFileName);
|
//Response.Clear();
|
//Response.Charset = "GB2312";
|
//Response.ContentEncoding = System.Text.Encoding.UTF8;
|
////添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
//Response.AddHeader("Content-Disposition", "attachment; filename=" +
|
// Server.UrlEncode(string.Format("Report_{0}_{1}.pdf",
|
// regInfo.QCDistributionInfo.DistNo,
|
// regInfo.LabInfo.LabCode)));
|
//// 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
//Response.AddHeader("Content-Length", pdfFileName.Length.ToString());
|
|
//// //指定返回的是一个不能被客户端读取的流,必须被下载
|
//Response.ContentType = "application/ms-excel";
|
//Response.Write(pdfFileName);
|
//// 停止页面的执行
|
|
//Response.End();
|
}
|
[AdminLogin]
|
public ActionResult UpdatePassword(UserRequestInfo info)
|
{
|
Random rd = new Random();
|
string str = "";
|
while (str.Length < 6)
|
{
|
int temp = rd.Next(0, 9);
|
str += temp;
|
}
|
info.LabPassword = str;
|
info.UpdateTime = DateTime.Now;
|
m_AccountService.UpdateUserRequestInfo(info);
|
_qcService.SendMail(info.Id, 17);
|
return Json("密码修改成功,更改密码已经发送至负责人邮箱");
|
}
|
[AdminLogin]
|
public ActionResult SeveEmile(UserRequestInfo info)
|
{
|
if (info != null)
|
{
|
EmileInfo emil = new EmileInfo();
|
Menus ent = m_AccountService.MenusId(12);
|
StringOperation service = new StringOperation();
|
string bodly = service.StringContents(info, null, ent.Contents);
|
if (service.Contains(ent.Url, "管理员"))
|
{
|
EmileInfo model = new EmileInfo();
|
model.Boody = bodly;
|
model.EmileName = "";
|
model.Title = ent.Name;
|
model.Type = ent.Id;
|
model.Explain = ent.Title;
|
model.SendOutDatetime = DateTime.Now;
|
m_AccountService.InserEmilinfo(model);
|
}
|
if (service.Contains(ent.Url, "操作人"))
|
{
|
EmileInfo model = new EmileInfo();
|
model.Boody = bodly;
|
model.EmileName = info.ManagerEmail;
|
model.Title = ent.Name;
|
model.Type = ent.Id;
|
model.Explain = ent.Title;
|
model.SendOutDatetime = DateTime.Now;
|
m_AccountService.InserEmilinfo(model);
|
}
|
if (service.Contains(ent.Url, "负责人"))
|
{
|
EmileInfo model = new EmileInfo();
|
model.Boody = bodly;
|
model.EmileName = info.OperatorEmail;
|
model.Title = ent.Name;
|
model.Type = ent.Id;
|
model.Explain = ent.Title;
|
model.SendOutDatetime = DateTime.Now;
|
m_AccountService.InserEmilinfo(model);
|
}
|
}
|
return Json("邮件已发送");
|
}
|
[AdminLogin]
|
|
public ActionResult PrintTemplate()
|
{
|
MenusViewModel viewModel = new MenusViewModel();
|
viewModel.MenusList = m_AccountService.GetMenus().Where(p => p.Category == "3").ToList();
|
return View(viewModel);
|
}
|
public ActionResult FileUpload(string id)
|
{
|
var s = AssemblyHelper.GetBaseDirectory();
|
LogHelper.Debug("开始上传图片;" + s);
|
var oFile = Request.Files["txt_file"];
|
string filePath = "";
|
string file = "";
|
if (oFile != null)
|
{
|
var oStream = oFile.InputStream;
|
//得到了文件的流对象,我们不管是用NPOI、GDI还是直接保存文件都不是问题了吧。。。。
|
var newFileName = oFile.FileName.Replace(System.IO.Path.GetFileNameWithoutExtension(oFile.FileName), "timp" + id);
|
file = "../files/" + newFileName;
|
filePath = Server.MapPath("~/files/" + newFileName);
|
LogHelper.Debug("文件路径;" + filePath);
|
Menus info = m_AccountService.MenusId(int.Parse(id));
|
info.Contents = newFileName;
|
m_AccountService.UpdateMenu(info);
|
oFile.SaveAs(filePath);
|
|
}
|
return Json(new { file }, JsonRequestBehavior.AllowGet);
|
}
|
public void DownloadFile(string fileName)
|
{
|
string savedFileName = Path.Combine(Server.MapPath("~/files"), fileName);
|
FileInfo fileInfo = new FileInfo(savedFileName);
|
if (System.IO.File.Exists(savedFileName))//判断文件是否存在
|
{
|
Response.Clear();
|
Response.ClearHeaders();
|
Response.Buffer = false;
|
Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
|
Response.AddHeader("cintent_length", "attachment;filename=" + HttpUtility.UrlDecode(fileName));
|
Response.AddHeader("cintent_length", fileInfo.Length.ToString());
|
Response.ContentType = "application/octet-stream";
|
Response.WriteFile(fileInfo.FullName);//通过response对象,执行下载操作
|
Response.Flush();
|
Response.End();
|
}
|
else
|
{
|
Response.Clear();
|
Response.ClearHeaders();
|
Response.Buffer = false;
|
Response.Flush();
|
Response.End();
|
}
|
}
|
[AdminLogin]
|
public ActionResult EmileTemplate()
|
{
|
MenusViewModel viewModel = new MenusViewModel();
|
viewModel.MenusList = m_AccountService.GetMenus().Where(p => p.Category == "4").ToList();
|
return View(viewModel);
|
}
|
[AdminLogin]
|
public ActionResult EmileMass(string Page, string QCId, string ProjectId, string LabName, string Province1)
|
{
|
int pageInt = 1;
|
if (string.IsNullOrEmpty(Page) == false)
|
{
|
int.TryParse(Page, out pageInt);
|
}
|
if (pageInt == 0)
|
{
|
pageInt = 1;
|
}
|
EmileMassViewModel viewModel = EmileMassViewModel.GetEmileMassViewModel(pageInt, QCId, ProjectId, LabName, Province1);
|
viewModel.CurrentPageIndex = pageInt;
|
viewModel.Menus = m_AccountService.MenusId(18);
|
return View(viewModel);
|
|
}
|
[AdminLogin]
|
public ActionResult SeveEmileMass(EmileMassViewModel info)
|
{
|
EmileMassViewModel viewModel = EmileMassViewModel.GetEmileMassViewModel(info.QCId.ToString(), info.ProjectId.ToString(), info.LabName, info.Province1);
|
if (viewModel.UserRequestInfoList.Count > 0 && info.Menus != null)
|
{
|
viewModel.UserRequestInfoList.ForEach(ent =>
|
{
|
UserRequestInfo models = UserRequestInfoModel.FromEntity(ent);
|
StringOperation service = new StringOperation();
|
string bodly = service.StringContents(models, null, info.Menus.Contents);
|
if (service.Contains(info.Menus.Url, "管理员"))
|
{
|
EmileInfo model = new EmileInfo();
|
model.Boody = bodly;
|
model.EmileName = "";
|
model.Title = info.Menus.Name;
|
model.Type = info.Menus.Id;
|
model.Explain = info.Menus.Title;
|
model.SendOutDatetime = DateTime.Now;
|
m_AccountService.InserEmilinfo(model);
|
}
|
if (service.Contains(info.Menus.Url, "操作人"))
|
{
|
EmileInfo model = new EmileInfo();
|
model.Boody = bodly;
|
model.EmileName = ent.ManagerEmail;
|
model.Title = info.Menus.Name;
|
model.Type = info.Menus.Id;
|
model.Explain = info.Menus.Title;
|
model.SendOutDatetime = DateTime.Now;
|
m_AccountService.InserEmilinfo(model);
|
}
|
if (service.Contains(info.Menus.Url, "负责人"))
|
{
|
EmileInfo model = new EmileInfo();
|
model.Boody = bodly;
|
model.EmileName = ent.OperatorEmail;
|
model.Title = info.Menus.Name;
|
model.Type = info.Menus.Id;
|
model.Explain = info.Menus.Title;
|
model.SendOutDatetime = DateTime.Now;
|
m_AccountService.InserEmilinfo(model);
|
}
|
});
|
}
|
return Json(info, JsonRequestBehavior.AllowGet);
|
}
|
//质评下载
|
public ActionResult Quality_Excel(string selectModel)
|
{
|
try
|
{
|
string TableName = DateTime.Now.ToString("yyMMddHHmmssfff") + "质评实验室明细.xls";
|
List<string> headers = new List<string>() { "实验室编号", "用户名", "单位名称", "实验室名称", "邮编", "地址", "城市", "参加项目代号", "负责人", "固话", "传真", "手机号码", "邮箱", "操作人", "固话", "传真", "手机号码", "邮箱", "申请时间", "审核时间" };
|
List<string> cellKes = new List<string>() { "LabCode", "LabLoginName", "CompanyName", "LabName", "PostCode", "Address", "Province", "ProjectId", "ManagerName", "ManagerPhone", "ManagerFax", "ManagerMobile", "ManagerEmail", "OperatorName", "OperatorPhone", "OperatorFax", "OperatorMobile", "OperatorEmail", "RequestTime", "UpdateTime" };
|
|
SelectExcelCell cells = JsonConvert.DeserializeObject<SelectExcelCell>(selectModel);
|
if (!string.IsNullOrEmpty(cells.option1))
|
{
|
headers.Add("1: 收到日期");
|
cellKes.Add("Form1");
|
}
|
if (!string.IsNullOrEmpty(cells.option2))
|
{
|
headers.Add("2: 测试日期");
|
cellKes.Add("Form2");
|
}
|
if (!string.IsNullOrEmpty(cells.option3))
|
{
|
headers.Add("3: 样本质量");
|
cellKes.Add("Form3");
|
}
|
if (!string.IsNullOrEmpty(cells.option4))
|
{
|
headers.Add("4: 完成日期");
|
cellKes.Add("Form4");
|
}
|
if (!string.IsNullOrEmpty(cells.option5))
|
{
|
headers.Add("5. 实验方法");
|
cellKes.Add("Form5");
|
}
|
if (!string.IsNullOrEmpty(cells.option6))
|
{
|
headers.Add("6. 试剂说明");
|
cellKes.Add("Form6");
|
|
}
|
if (!string.IsNullOrEmpty(cells.option7))
|
{
|
headers.Add("7. ABO和RhD定型");
|
cellKes.Add("Form7");
|
}
|
if (!string.IsNullOrEmpty(cells.option8))
|
{
|
headers.Add("8. 交叉配型结果");
|
cellKes.Add("Form8");
|
}
|
if (!string.IsNullOrEmpty(cells.option9))
|
{
|
headers.Add("9. 直接抗球蛋白实验(直抗)");
|
cellKes.Add("Form9");
|
|
}
|
if (!string.IsNullOrEmpty(cells.option10))
|
{
|
headers.Add("10.抗体筛选实验");
|
cellKes.Add("Form10");
|
|
}
|
if (!string.IsNullOrEmpty(cells.option11))
|
{
|
headers.Add("11.试剂红细胞数量");
|
cellKes.Add("Form11");
|
|
}
|
if (!string.IsNullOrEmpty(cells.option12))
|
{
|
headers.Add("12.抗体筛选实验");
|
cellKes.Add("Form12");
|
}
|
headers.Add("实验室得分");
|
cellKes.Add("Form13");
|
var list = _qcService.GetResultSpercentages().Where(p => p.QCDistributionId == cells.QCid).ToList();
|
List<ExcelModel> listmodel = new List<ExcelModel>();
|
list.ForEach(ent =>
|
{
|
QCDistributionRegisterInfo info = _qcService.GetQcDistributionRegister(ent.QcDistributionRegisterId);
|
ExcelModel Model = new ExcelModel();
|
#region 实验室信息
|
if (info == null)
|
{
|
return;
|
}
|
Model.CompanyName = info.LabInfo.CompanyName;
|
Model.ProjectId = info.ProjectId;
|
if (info.IsCharged == false)
|
{
|
Model.Remarks = "否";
|
}
|
else
|
{
|
Model.Remarks = "是";
|
}
|
Model.Address = info.LabInfo.Address;
|
Model.Province = info.LabInfo.Province;
|
Model.City = info.LabInfo.City;
|
Model.District = info.LabInfo.District;
|
Model.PostCode = info.LabInfo.PostCode;
|
Model.ManagerName = info.LabInfo.ManagerName;
|
Model.ManagerPhone = info.LabInfo.ManagerPhone;
|
Model.ManagerFax = info.LabInfo.ManagerFax;
|
Model.ManagerMobile = info.LabInfo.ManagerMobile;
|
Model.ManagerEmail = info.LabInfo.ManagerEmail;
|
Model.OperatorName = info.LabInfo.OperatorName;
|
Model.OperatorPhone = info.LabInfo.OperatorPhone;
|
Model.OperatorFax = info.LabInfo.OperatorFax;
|
Model.OperatorMobile = info.LabInfo.OperatorMobile;
|
Model.OperatorEmail = info.LabInfo.OperatorEmail;
|
|
Model.RequestTime = info.LabInfo.RequestTime;
|
Model.UpdateTime = info.LabInfo.UpdateTime;
|
Model.LabCode = info.LabInfo.LabCode;
|
Model.LabLoginName = info.LabInfo.LabLoginName;
|
Model.LabName = info.LabInfo.LabName;
|
#endregion
|
Model.Form1 = ent.RevDate;
|
Model.Form2 = ent.TestDate;
|
Model.Form3 = ent.SampleQuality;
|
Model.Form4 = ent.FinishDate;
|
Model.Form5 = ent.laboratoryMethod;
|
Model.Form6 = ent.Reagents;
|
Model.Form7 = string.Format("患者1:ABO血型报告:{0},Rh血型报告{1},患者2:ABO血型报告:{2},Rh血型报告{3},患者3:ABO血型报告:{4},Rh血型报告{5}",
|
ent.Abo1, ent.RH1, ent.Abo2, ent.RH2, ent.Abo3, ent.RH3);
|
Model.Form8 = string.Format("患者1献血者w:{0},患者1献血者y:{1},患者1献血者z:{2},患者2献血者w:{3},患者2献血者y:{4},患者2献血者z:{5},患者3献血者w:{6},患者3献血者y:{7},患者3献血者z:{8}",
|
ent.JiaoChaPeiXing1W, ent.JiaoChaPeiXing1Y, ent.JiaoChaPeiXing1Z, ent.JiaoChaPeiXing2W, ent.JiaoChaPeiXing2Y, ent.JiaoChaPeiXing2Z, ent.JiaoChaPeiXing3W, ent.JiaoChaPeiXing3Y, ent.JiaoChaPeiXing3Z);
|
Model.Form9 = string.Format("患者1:{0},患者2:{1},患者3:{2}", ent.ZhiKang1, ent.ZhiKang2, ent.ZhiKang3);
|
Model.Form10 = string.Format("患者1:{0},患者2:{1},患者3:{2}", ent.KangTiFilter1, ent.KangTiFilter2, ent.KangTiFilter3);
|
Model.Form11 = ent.CellNumber;
|
Model.Form12 = string.Format("患者1:{0},患者2:{1},患者3:{2}", ent.KangTiIdentity1, ent.KangTiIdentity2, ent.KangTiIdentity3);
|
Model.Form13 =
|
string.Format("ABO分:{0},RhD分:{1},抗体筛选分:{2},抗体鉴定分:{3},交叉配型分:{4},Z值:{5}",
|
ent.ABO_Score, ent.RH_Score, ent.KangtiFilter_Score, ent.KangtiIdentity_Score,
|
ent.JiaoChaPeiXing_Score, ent.ZValueScore.ToString("0.##"));
|
listmodel.Add(Model);
|
});
|
DataTable dt = ExcelUtil.ConvertToDataTable(listmodel);
|
ExcelUtil.ExportByWeb(dt, "实验室质评明细列表", headers.ToArray(), cellKes.ToArray(), TableName);
|
return View("AnswerList");
|
|
}
|
catch (Exception e)
|
{
|
LogHelper.Error(e);
|
return Content(e.Message);
|
}
|
|
}
|
}
|
}
|