public string GetInstrumentListByKeyWorks(string keyworks, string instrumentForm, string accessToKen) { try { if (!ToKenHelper.CheckAccessToKen(accessToKen)) { return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = commonErrorMsg })); } IList <object> resultList = new List <object>(); if (string.IsNullOrWhiteSpace(keyworks)) { return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = "OK", Data = resultList })); } IList <InstrumentModel> instrumentList = ServiceProvider.InstrumentService.GetInstrumentListByKeyWorks(keyworks, instrumentForm); //所属部门 IList <Global.Common.Models.OrgModel> orgList = Global.Business.ServiceProvider.OrgService.GetAll(); for (int i = 0; i < (instrumentList.Count > 100 ? 100 : instrumentList.Count); i++) { Global.Common.Models.OrgModel org = orgList.SingleOrDefault(S => S.OrgCode == instrumentList[i].BelongDepart); string orgName = org == null ? string.Empty : org.OrgName; resultList.Add(new { InstrumentName = instrumentList[i].InstrumentName, AssetsNo = instrumentList[i].AssetsNo, SerialNo = instrumentList[i].SerialNo, ManageNo = instrumentList[i].ManageNo, Specification = instrumentList[i].Specification, BelongDepart = orgName, BarCode = instrumentList[i].BarCode }); } return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = "OK", Data = resultList })); } catch (Exception ex) { log.Error(ex); return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = ex.Message })); } }
public string GetInstrumentList(string instrumentName, string specification, string serialNo, string accessToKen) { try { if (!ToKenHelper.CheckAccessToKen(accessToKen)) { return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = commonErrorMsg })); } StringBuilder where = new StringBuilder(); where.Append("1=1"); if (!string.IsNullOrWhiteSpace(instrumentName)) { where.AppendFormat(" And InstrumentName Like '%{0}%'", instrumentName); } if (!string.IsNullOrWhiteSpace(specification)) { where.AppendFormat(" And Specification Like '%{0}%'", specification); } if (!string.IsNullOrWhiteSpace(serialNo)) { where.AppendFormat(" And SerialNo Like '%{0}%'", serialNo); } IList <InstrumentModel> instrumentList = ServiceProvider.InstrumentService.GetAllInstrumentListByWhere(where.ToString()); //所属部门 IList <Global.Common.Models.OrgModel> orgList = Global.Business.ServiceProvider.OrgService.GetAll(); IList <object> resultList = new List <object>(); foreach (InstrumentModel e in instrumentList) { Global.Common.Models.OrgModel org = orgList.SingleOrDefault(S => S.OrgCode == e.BelongDepart); string orgName = org == null ? string.Empty : org.OrgName; resultList.Add(new { InstrumentName = e.InstrumentName, AssetsNo = e.AssetsNo, SerialNo = e.SerialNo, ManageNo = e.ManageNo, Specification = e.Specification, BelongDepart = orgName, BarCode = e.BarCode, InstrumentId = e.InstrumentId }); } return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = "OK", Data = resultList })); } catch (Exception ex) { log.Error(ex); return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = ex.Message })); } }
public JsonResult GetAllCertificationJsonData() { DataTableUtils.DataTableModel dtm = DataTableUtils.GetJquerydataTableParams(); //string where = GetCertificationSearchCondition(dtm); PagingModel paging = new PagingModel(); paging.PageSize = dtm.PageSize; paging.PageCurrent = dtm.PageIndex; dtm.iTotalDisplayRecords = dtm.iTotalRecords; paging.FieldShow = @"LogId,InstrumentId,CertificationCode,FileId,CheckDate,EndDate,SendInstrumentDate,CheckResult,ErrorValue,RecordState,IsUseding,CertMoney,CreateDate,CreateUser"; paging.Where = string.IsNullOrWhiteSpace(dtm.FieldCondition) ? dtm.FieldCondition = "1=1" : dtm.FieldCondition; //是否超期 string overTime = Request["searchIsOverTime"]; if (!string.IsNullOrEmpty(overTime)) { if (overTime == "0") { paging.Where = string.Format("{0} and {1}", paging.Where, "GetDate()<=EndDate");//未超期 } else { paging.Where = string.Format("{0} and {1}", paging.Where, "GetDate()>EndDate");//已超期 } } //是否上传报告 string UpdateReport = Request["searchIsUpdateReport"]; if (!string.IsNullOrEmpty(UpdateReport)) { paging.Where = string.Format("{0} and {1}", paging.Where, UpdateReport == "0" ? "(FileId IS null or FileId=0)" : "FileId>0"); } //添加委托单查询条件. string orderParam = Request["InstrumentParam"]; if (!string.IsNullOrWhiteSpace(orderParam)) { orderParam = string.Format(" and {0}", orderParam); } paging.Where = string.Format("{0} and (InstrumentId In (Select InstrumentId From Instrument_BaseInfo Where {2}{1}))", paging.Where, orderParam, GetManageCondition("InstrumentForm=0 ")); DateTime dueEndDate; bool isOverTime = false; IList <Hashtable> instrumentCertificationList = ServiceProvider.InstrumentCertificationService.GetInstrumentCertificationListForPaging(paging); IList <int> instrumentIds = instrumentCertificationList.Select(s => Convert.ToInt32(s["InstrumentId"])).Distinct().ToList(); IList <InstrumentModel> instrumentList = ServiceProvider.InstrumentService.GetByIds(instrumentIds); dtm.iTotalRecords = paging.RecordCount; dtm.iTotalDisplayRecords = dtm.iTotalRecords; ////系统参数 IList <ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll(); Global.Common.Models.OrgModel belongDeptModel = new Global.Common.Models.OrgModel(); Global.Common.Models.ParamItemModel mInstrumentCate = null; IList <Global.Common.Models.ParamItemModel> paramItemList = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.InstrumentCate).itemsList; ///周检状态 IList <ParamItemModel> CertificationState = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.InstrumentCertificationState).itemsList; ParamItemModel mParamItem = new ParamItemModel(); StringBuilder sbData = new StringBuilder(); dtm.aaData = new List <List <string> >(); foreach (var item in instrumentCertificationList) { InstrumentModel instrumentModel = instrumentList.SingleOrDefault(p => p.InstrumentId == Convert.ToInt32(item["InstrumentId"])); if (instrumentModel == null) { instrumentModel = new InstrumentModel(); } if (item["EndDate"] == null) { isOverTime = true; } else { dueEndDate = Convert.ToDateTime(string.Format("{0:d}", item["EndDate"])); //是否过期 isOverTime = DateTime.Now.CompareTo(dueEndDate) > 0 ? true : false; } dtm.aaData.Add(new List <string>()); sbData.Clear(); sbData.AppendFormat("<a href='#' onclick='fnDetails({0})'>详细</a> ", item["LogId"]); if (item["FileId"] != null) { sbData.Append("<a href='#' onclick='fnDownFile(\"" + UtilsHelper.Encrypt(item["FileId"].ToString()) + "\");'>下 载</a> "); //sbData.Append(string.Format("<a href='/Certification/ReadCert?Id={1}' target='_blank' >{0}</a>","浏 览", UtilsHelper.Encrypt(item["FileId"].ToString()))); } dtm.aaData[dtm.aaData.Count - 1].Add(sbData.ToString()); mParamItem = CertificationState.SingleOrDefault(c => c.ParamItemValue == string.Format("{0}", item["RecordState"])); dtm.aaData[dtm.aaData.Count - 1].Add(mParamItem == null ? "" : mParamItem.ParamItemName); //状态 dtm.aaData[dtm.aaData.Count - 1].Add(isOverTime ? "已超期" : "未超期"); //证书超期 dtm.aaData[dtm.aaData.Count - 1].Add(item["FileId"] == null || item["FileId"].ToString() == "" ? "否" : "是"); //是否上传证书 dtm.aaData[dtm.aaData.Count - 1].Add(item["EndDate"] == null ? null : string.Format("{0:yyyy-MM-dd}", item["EndDate"])); dtm.aaData[dtm.aaData.Count - 1].Add(item["CertificationCode"] == null ? "" : item["CertificationCode"].ToString()); dtm.aaData[dtm.aaData.Count - 1].Add(string.Format("{0:F2}", item["CertMoney"])); dtm.aaData[dtm.aaData.Count - 1].Add(instrumentModel.InstrumentName); mInstrumentCate = paramItemList.SingleOrDefault(t => t.ParamItemValue == Convert.ToString(instrumentModel.InstrumentCate)); dtm.aaData[dtm.aaData.Count - 1].Add(mInstrumentCate == null ? "" : mInstrumentCate.ParamItemName); dtm.aaData[dtm.aaData.Count - 1].Add(instrumentModel.ManageNo); dtm.aaData[dtm.aaData.Count - 1].Add(instrumentModel.Specification); dtm.aaData[dtm.aaData.Count - 1].Add(instrumentModel.SerialNo); dtm.aaData[dtm.aaData.Count - 1].Add(item["CheckDate"] == null ? null : string.Format("{0:yyyy-MM-dd}", item["CheckDate"])); dtm.aaData[dtm.aaData.Count - 1].Add(item["CheckResult"] == null ? null : item["CheckResult"].ToString()); dtm.aaData[dtm.aaData.Count - 1].Add(item["ErrorValue"] == null ? null : item["ErrorValue"].ToString()); dtm.aaData[dtm.aaData.Count - 1].Add(item["CreateDate"] == null ? null : string.Format("{0:yyyy-MM-dd}", item["CreateDate"])); dtm.aaData[dtm.aaData.Count - 1].Add(item["CreateUser"] == null ? null : item["CreateUser"].ToString()); } JsonResult jr = Json(new { sEcho = dtm.sEcho, iTotalRecords = dtm.iTotalRecords, iTotalDisplayRecords = dtm.iTotalDisplayRecords, aaData = dtm.aaData, }, JsonRequestBehavior.AllowGet); return(jr); }
public string GetInstrumentDetailByBarCode(string barCode, string accessToKen) { try { if (!ToKenHelper.CheckAccessToKen(accessToKen)) { return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = commonErrorMsg })); } InstrumentModel model = ServiceProvider.InstrumentService.GetByBarCode(barCode); if (model == null) { return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = "设备不存在!" })); } #region 数据处理 IList <Global.Common.Models.OrgModel> orgList = Global.Business.ServiceProvider.OrgService.GetAll(); Global.Common.Models.OrgModel org = orgList.SingleOrDefault(S => S.OrgCode == model.BelongDepart); //系统参数 IList <ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll(); IList <ParamItemModel> InstrumentCate = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.InstrumentCate).itemsList; IList <ParamItemModel> CalibrationType = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.CalibrationType).itemsList; IList <ParamItemModel> InstrumentType = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.InstrumentType).itemsList; IList <ParamItemModel> RecordState = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.InstrumentState).itemsList; IList <ParamItemModel> VerificationType = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.VerificationType).itemsList; IList <ParamItemModel> AssetsState = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.AssetsState).itemsList; IList <ParamItemModel> manageLevel = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.ManageLevel).itemsList; ParamItemModel mInstrumentCate = InstrumentCate.SingleOrDefault(p => p.ParamItemValue.Equals(model.InstrumentCate.ToString())); ParamItemModel mSubInstrumentCate = InstrumentCate.SingleOrDefault(p => p.ParamItemValue.Equals(model.SubInstrumentCate.ToString())); ParamItemModel mCalibrationType = CalibrationType.SingleOrDefault(p => p.ParamItemValue.Equals(model.CalibrationType.ToString())); ParamItemModel mInstrumentType = InstrumentType.SingleOrDefault(p => p.ParamItemValue.Equals(model.InstrumentType.ToString())); ParamItemModel mRecordState = RecordState.SingleOrDefault(p => p.ParamItemValue.Equals(model.RecordState.ToString())); ParamItemModel mAssetsState = AssetsState.SingleOrDefault(p => p.ParamItemValue.Equals(model.RecordState.ToString())); ParamItemModel mVerificationType = VerificationType.SingleOrDefault(p => p.ParamItemValue.Equals(model.VerificationType.ToString())); ParamItemModel mmanageLevel = manageLevel.SingleOrDefault(p => p.ParamItemValue.Equals(string.IsNullOrEmpty(model.ManageLevel) ? "" : model.ManageLevel.ToString())); DateTime dueEndDate; bool isOverTime = false; int warnDay = 0; if (!string.IsNullOrWhiteSpace(string.Format("{0}", model.DueEndDate))) { dueEndDate = Convert.ToDateTime(string.Format("{0:d}", model.DueEndDate)); } else { dueEndDate = DateTime.MinValue; } //预警天数 isOverTime = dueEndDate < Convert.ToDateTime(string.Format("{0:d}", DateTime.Now)); warnDay = (dueEndDate - Convert.ToDateTime(string.Format("{0:d}", DateTime.Now))).Days; warnDay = warnDay < 0 ? 0 : warnDay; //超期无预警天数 if (isOverTime) { warnDay = 0; } IList <Hashtable> htList = new List <Hashtable>(); Hashtable ht = new Hashtable(); ht.Add("Name", model.InstrumentForm == Instrument.Common.Constants.InstrumentForm.仪器.GetHashCode() ? "仪器名称" : "资产名称"); ht.Add("Value", string.Format("{0}", model.InstrumentName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", model.InstrumentForm == Instrument.Common.Constants.InstrumentForm.仪器.GetHashCode() ? "仪器型号" : "型号规格"); ht.Add("Value", string.Format("{0}", model.Specification)); htList.Add(ht); if (model.InstrumentForm == Instrument.Common.Constants.InstrumentForm.仪器.GetHashCode()) { ht = new Hashtable(); ht.Add("Name", "证书超期"); ht.Add("Value", model.DueEndDate == null ? "" : isOverTime ? "已超期" : "未超期"); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "超期预警"); ht.Add("Value", string.Format("{0}", (warnDay == 0) ? "无预警" : warnDay.ToString() + "天")); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "到期日期"); ht.Add("Value", model.DueEndDate == null ? string.Empty : DateTime.Parse(model.DueEndDate.ToString()).ToString("yyyy-MM-dd")); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "设备状态"); ht.Add("Value", string.Format("{0}", mRecordState == null ? string.Empty : mRecordState.ParamItemName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "证书编号"); ht.Add("Value", string.Format("{0}", model.CertificateNo)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "校准日期"); ht.Add("Value", model.DueStartDate == null ? string.Empty : DateTime.Parse(model.DueStartDate.ToString()).ToString("yyyy-MM-dd")); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "管理级别"); ht.Add("Value", string.Format("{0}", mmanageLevel == null ? string.Empty : mmanageLevel.ParamItemName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "校准周期"); ht.Add("Value", string.Format("{0}", model.InspectCycle)); htList.Add(ht); ht = new Hashtable(); } else { ht = new Hashtable(); ht.Add("Name", "资产状态"); ht.Add("Value", string.Format("{0}", mAssetsState == null ? string.Empty : mAssetsState.ParamItemName)); htList.Add(ht); } ht = new Hashtable(); ht.Add("Name", "管理编号"); ht.Add("Value", string.Format("{0}", model.ManageNo)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "资产编号"); ht.Add("Value", string.Format("{0}", model.AssetsNo)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "出厂编号"); ht.Add("Value", string.Format("{0}", model.SerialNo)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "所属部门"); ht.Add("Value", string.Format("{0}", org == null ? string.Empty : org.OrgName)); htList.Add(ht); if (model.InstrumentForm == Instrument.Common.Constants.InstrumentForm.仪器.GetHashCode()) { ht = new Hashtable(); ht.Add("Name", "设备分类"); ht.Add("Value", string.Format("{0}", mInstrumentCate == null ? string.Empty : mInstrumentCate.ParamItemName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "设备子分类"); ht.Add("Value", string.Format("{0}", mSubInstrumentCate == null ? string.Empty : mSubInstrumentCate.ParamItemName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "计量类别"); ht.Add("Value", string.Format("{0}", mVerificationType == null ? string.Empty : mVerificationType.ParamItemName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "技术特征"); ht.Add("Value", string.Format("{0}", model.TechniqueCharacter)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "计量特性"); ht.Add("Value", string.Format("{0}", model.MeasureCharacter)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "存放地点"); ht.Add("Value", string.Format("{0}", model.StorePalce)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "设备类别"); ht.Add("Value", string.Format("{0}", mInstrumentType == null ? string.Empty : mInstrumentType.ParamItemName)); htList.Add(ht); } ht = new Hashtable(); ht.Add("Name", "资产属性"); ht.Add("Value", string.Format("{0}", mCalibrationType == null ? string.Empty : mCalibrationType.ParamItemName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "保管人"); ht.Add("Value", string.Format("{0}", model.LeaderName)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "存放地点"); ht.Add("Value", string.Format("{0}", model.StorePalce)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "购置日期"); ht.Add("Value", model.BuyDate == null ? string.Empty : DateTime.Parse(model.BuyDate.ToString()).ToString("yyyy-MM-dd")); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "购置金额"); ht.Add("Value", string.Format("{0:F2}", model.Price)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "生产厂家"); ht.Add("Value", string.Format("{0}", model.Manufacturer)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "联系信息"); ht.Add("Value", string.Format("{0}", model.ManufactureContactor)); htList.Add(ht); ht = new Hashtable(); ht.Add("Name", "备注"); ht.Add("Value", string.Format("{0}", model.Remark)); htList.Add(ht); #endregion object result = new { Msg = "OK", Data = htList }; return(ToolsLib.Utility.CommonUtils.JsonSerialize(result)); } catch (Exception ex) { log.Error(ex); object msg = new { Msg = ex.Message }; return(ToolsLib.Utility.CommonUtils.JsonSerialize(msg)); } }