Esempio n. 1
0
        public ActionResult Edit(string contactId)
        {
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            //事项分类
            Global.Common.Models.ParamModel caseType = paramList.SingleOrDefault(m => m.ParamCode.Equals(Constants.SysParamType.ContactCaseType));
            ViewBag.CaseType = new SelectList(caseType.itemsList, "ParamItemValue", "ParamItemName");

            //公司名称
            Global.Common.Models.ParamModel company = paramList.SingleOrDefault(t => t.ParamCode == Constants.SysParamType.CompanyInfo);
            if (null == company)
            {
                company = new Global.Common.Models.ParamModel();
            }
            Global.Common.Models.ParamItemModel companyInfo = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("公司名称"));

            ContactModel model = null;

            if (contactId == "0")
            {
                model             = new ContactModel();
                model.CompanyName = companyInfo == null ? "" : companyInfo.ParamItemValue;
            }
            else
            {
                model = ServiceProvider.ContactService.GetById(UtilsHelper.Decrypt2Int(contactId));
                IList <BusinessAttachmentModel> businessAttachList = ServiceProvider.BusinessAttachmentService.GetByBusinessTypeAndId(Constants.AttachmentBusinessType.联络单.GetHashCode(), model.ContactId);
                if (businessAttachList.Count > 0 && businessAttachList.First() != null)
                {
                    ViewBag.FileId   = UtilsHelper.Encrypt(businessAttachList.First().FileId.ToString());
                    ViewBag.FileName = businessAttachList.First().FileName;
                }
            }
            return(View(model));
        }
        public ActionResult InstrumentScan()
        {
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            Global.Common.Models.ParamModel receiveLocale = paramList.SingleOrDefault(m => m.ParamCode.Equals(Constants.SysParamType.InstrumentReceiveLocale));
            ViewBag.InstrumentReceiveLocale = new SelectList(receiveLocale.itemsList, "ParamItemName", "ParamItemName");
            return(View());
        }
Esempio n. 3
0
        public string GetOrderListJsonData()
        {
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            Global.Common.Models.ParamModel company = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.CompanyInfo);
            if (null == company)
            {
                company = new Global.Common.Models.ParamModel();
            }
            Global.Common.Models.ParamItemModel pCompany = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("公司编号"));

            StringBuilder            sb            = new StringBuilder();
            List <MeasureOrderModel> orderBillList = new List <MeasureOrderModel>();
            string endDate                  = DateTime.Now.ToString("yyyy-MM-dd");
            string startDate                = DateTime.Now.AddYears(-2).ToString("yyyy-MM-dd");
            string orderJsonData            = WSProvider.MeasureLabProvider.OrderSearch(startDate, endDate, Global.Business.ServiceProvider.ParamService.GetaccessToken(Instrument.Common.Constants.SysParamType.CompanyInfo));
            Dictionary <string, object> dic = ToolsLib.Utility.CommonUtils.JsonDeserialize(orderJsonData, typeof(Dictionary <string, object>)) as Dictionary <string, object>;

            if (dic["Msg"].ToString() == "OK")
            {
                orderBillList = ToolsLib.Utility.CommonUtils.JsonDeserialize(dic["Data"].ToString(), typeof(List <MeasureOrderModel>)) as List <MeasureOrderModel>;
            }
            else
            {
                return("{\"data\":[]}");
            }
            sb.Insert(0, "{\"data\":[");
            foreach (var item in orderBillList)
            {
                if (LoginHelper.LoginUserAuthorize.ContainsKey("订单查询-查看仪器"))
                {
                    sb.AppendFormat("[\" <a href='#' OrderNumber='{0}'  onclick='fnCheckInstrument(this)'>查看仪器</a>&nbsp;&nbsp;", item.OrderNumber);
                }
                if (LoginHelper.LoginUserAuthorize.ContainsKey("/Order/BatchDownloadCert".ToLower()))
                {
                    sb.AppendFormat("<a href='#' orderNumber='{0}' onclick='fnBatchDownloadCert(this)'>批量下载证书</a>\"", item.OrderNumber);
                }
                sb.AppendFormat(",\"{0}\"", item.OrderNumber);
                sb.AppendFormat(",\"{0}\"", item.CreateDate.ToShortDateString());
                sb.AppendFormat(",\"{0}\"", item.SaleName);
                sb.AppendFormat(",\"{0}\"", item.InstrumentCount);
                sb.AppendFormat(",\"{0}\"", item.IsComplete == true ? "完工" : "未完工");
                sb.AppendFormat(",\"{0}\"", item.IsCompleteCert == true ? "完工" : "未完工");
                //sb.AppendFormat(",\"{0}\"", item.IsInvoice == true ? "已开票" : "未开票");
                //sb.AppendFormat(",\"{0}\"", item.IsPay == true ? "已付款" : "未付款");
                sb.Append("],");
            }
            if (orderBillList.Count > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]}");
            return(sb.ToString());
        }
Esempio n. 4
0
        /// <summary>
        /// 获取公司编号
        /// </summary>
        /// <param name="CompanyInfo"></param>
        /// <returns></returns>
        public string GetCompanyCode(string CompanyInfo)
        {
            IList <ParamModel> paramList = ServiceProvider.ParamService.GetAll();
            ParamModel         company   = paramList.SingleOrDefault(t => t.ParamCode == CompanyInfo);

            if (null == company)
            {
                company = new Global.Common.Models.ParamModel();
            }
            ParamItemModel pCompany = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("公司编号"));

            return(pCompany == null ? "" : pCompany.ParamItemValue);
        }
Esempio n. 5
0
        /// <summary>
        /// 获取accessToken
        /// </summary>
        /// <returns></returns>
        public string GetaccessToken(string CompanyInfo)
        {
            IList <Global.Common.Models.ParamModel> paramList = ServiceProvider.ParamService.GetAll();
            ParamModel company = paramList.SingleOrDefault(t => t.ParamCode == CompanyInfo);

            if (null == company)
            {
                company = new Global.Common.Models.ParamModel();
            }
            ParamItemModel pCompany = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("公司编号"));
            ParamItemModel Pwd      = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("密码"));

            return(SSOHelper.Encrypt(string.Format("{0}|{1}", pCompany == null ? "" : pCompany.ParamItemValue, Pwd == null ? "" : Pwd.ParamItemValue)));
        }
Esempio n. 6
0
        /// <summary>
        /// 生成委托单号
        /// </summary>
        /// <returns></returns>
        public string GenerateUniqueOrderNumber()
        {
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            Global.Common.Models.ParamModel company = paramList.SingleOrDefault(t => t.ParamCode == Constants.SysParamType.CompanyInfo);
            if (null == company)
            {
                company = new Global.Common.Models.ParamModel();
            }
            Global.Common.Models.ParamItemModel CompanyCode = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("公司编号"));
            string orderNumber = "";

            do
            {
                orderNumber = CompanyCode.ParamItemValue + DateTime.Now.ToString("yyyyMMdd") + ToolsLib.Utility.StrUtils.GetRandomNumb(4);
            }while (DBProvider.OrderDAO.IsExistOrderNumber(orderNumber));
            return(orderNumber);
        }
        /// <summary>
        /// 知识库明细
        /// </summary>
        /// <param name="knowledgeId"></param>
        /// <returns></returns>
        public ActionResult Details(string knowledgeId)
        {
            KnowledgesModel model = ServiceProvider.KnowledgesService.GetKnowledgeDetailInfo(UtilsHelper.Decrypt2Int(knowledgeId));
            //内容类型
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            Global.Common.Models.ParamModel kType = paramList.SingleOrDefault(m => m.ParamCode.Equals(UtilConstants.SysParamType.KnowledgeType));
            ViewBag.KType = kType.itemsList.FirstOrDefault(s => s.ParamItemValue == String.Format("{0}", model.KType)).ParamItemName;

            //业务附件
            StringBuilder sb = new StringBuilder();

            sb.Append("[");
            if (model.swfFileByte != null && model.swfFileByte.Length > 0)
            {
                string swfFilePath = "/tempFile/" + Guid.NewGuid().ToString() + ".swf";
                ToolsLib.FileService.NormalFile.SaveInfoToFile(model.swfFileByte, swfFilePath);
                ViewBag.FilePath = swfFilePath;
            }
            else
            {
                ViewBag.FilePath = "";
            }
            int i = 1;

            if (model.businessAttachList != null)
            {
                foreach (Hashtable item in model.businessAttachList)
                {
                    sb.Append("[");
                    sb.AppendFormat("\"{0}\"", i++);
                    sb.AppendFormat(",\"<a href='#' onclick='fnDownLoad(this);' data-id='{0}'>{1}</a>\"", UtilsHelper.Encrypt(String.Format("{0}", item["FileId"])), item["FileName"]);
                    sb.Append("],");
                }
                if (model.businessAttachList.Count > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                }
            }
            sb.Append("]");
            ViewBag.Data = sb.ToString();
            return(View(model));
        }
Esempio n. 8
0
        public ActionResult Detail(string contactId)
        {
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();
            ContactModel model = ServiceProvider.ContactService.GetById(UtilsHelper.Decrypt2Int(contactId));

            //事项分类
            Global.Common.Models.ParamModel caseType = paramList.SingleOrDefault(m => m.ParamCode.Equals(Constants.SysParamType.ContactCaseType));
            ParamItemModel item = caseType.itemsList.SingleOrDefault(p => p.ParamItemValue.Equals(model.CaseType.ToString()));

            ViewBag.CaseType = item.ParamItemName;
            IList <BusinessAttachmentModel> businessAttachList = ServiceProvider.BusinessAttachmentService.GetByBusinessTypeAndId(Constants.AttachmentBusinessType.联络单.GetHashCode(), model.ContactId);

            if (businessAttachList.Count > 0 && businessAttachList.First() != null)
            {
                ViewBag.FileId   = UtilsHelper.Encrypt(businessAttachList.First().FileId.ToString());
                ViewBag.FileName = businessAttachList.First().FileName;
            }
            return(View(model));
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="knowledgeId"></param>
        /// <returns></returns>
        public ActionResult Edit(string knowledgeId)
        {
            KnowledgesModel model = new KnowledgesModel();

            if (knowledgeId != "0")
            {
                model = ServiceProvider.KnowledgesService.GetById(UtilsHelper.Decrypt2Int(knowledgeId));
            }
            //内容类型
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            Global.Common.Models.ParamModel kType = paramList.SingleOrDefault(m => m.ParamCode.Equals(UtilConstants.SysParamType.KnowledgeType));
            ViewBag.KType = new SelectList(kType.itemsList, "ParamItemValue", "ParamItemName");

            if (model.FileId != 0)
            {
                AttachmentModel attach = Global.Business.ServiceProvider.AttachmentService.GetById(model.FileId);
                ViewBag.FileName = attach.FileName;
            }

            return(View(model));
        }
Esempio n. 10
0
        /// <summary>
        /// 仪器送检
        /// 仪器手机App接口和网页功能公用方法
        /// </summary>
        /// <param name="instrumentIds">以逗号分隔的仪器标识(未加密)</param>
        /// <param name="orderJson">送检单Json数据(送检人SendUser,App和网页分别独立赋值)</param>
        /// <returns></returns>
        public string SendOrder(string instrumentIds, string orderJson, string OrgName, string UserName, int UserId)
        {
            string result = "";
            //组装数据
            JObject orderObj         = JObject.Parse(orderJson);
            var     instrumentIdArr  = instrumentIds.Split(',');
            var     instrumentIdList = instrumentIdArr.Select(l => Convert.ToInt32(l)).ToList();
            IList <InstrumentModel>         instrumentList         = ServiceProvider.InstrumentService.GetByIdList(instrumentIdList);                            //对应的仪器列表
            IList <InstrumentWaitSendModel> instrumentWaitSendList = ServiceProvider.InstrumentWaitSendService.GetByInstrumentIdsList(instrumentIdList, UserId); //对应的送检仪器备注
            //单号
            string orderNumber = ServiceProvider.OrderService.GenerateUniqueOrderNumber();
            //组装送检仪器MD5Code字典
            Dictionary <int, string> dictionaryMd5 = new Dictionary <int, string>();

            foreach (int instrumentId in instrumentIdList)
            {
                dictionaryMd5.Add(instrumentId, Guid.NewGuid().ToString());
            }
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            Global.Common.Models.ParamModel company = paramList.SingleOrDefault(t => t.ParamCode == Constants.SysParamType.CompanyInfo);
            if (null == company)
            {
                company = new Global.Common.Models.ParamModel();
            }
            Global.Common.Models.ParamItemModel CompanyName = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("公司名称"));
            Global.Common.Models.ParamItemModel CompanyCode = company.itemsList.SingleOrDefault(s => s.ParamItemName.Equals("公司编号"));

            orderObj.Add("OrderNumber", orderNumber);
            orderObj.Add("CompanyName", CompanyName == null ? "" : CompanyName.ParamItemValue);
            orderObj.Add("CompanyCode", CompanyCode == null ? "" : CompanyCode.ParamItemValue);
            //送检人部门

            orderObj.Add("SendUserOrgName", OrgName);
            orderObj.Add("InstrumentCount", instrumentList.Count);
            //orderObj.Add("SendUser", LoginHelper.LoginUser.UserName);//送检人

            //仪器Json数据组装
            JArray projectJArr = new JArray();
            int    maxLen      = int.Parse(string.IsNullOrEmpty(WebUtils.GetSettingsValue("SendOrderLength")) ? "1000" : WebUtils.GetSettingsValue("SendOrderLength"));//一次送检的最大仪器数量
            int    leftCout    = instrumentList.Count % maxLen;
            int    count       = 0;
            InstrumentWaitSendModel instrumentWaitSendModel = null;

            foreach (var item in instrumentList)
            {
                instrumentWaitSendModel = instrumentWaitSendList.SingleOrDefault(I => I.InstrumentId.Equals(item.InstrumentId));
                count++;
                JObject projectObj = new JObject();
                projectObj.Add("CertificationNumber", item.CertificateNo);
                projectObj.Add("InstrumentName", item.InstrumentName);
                projectObj.Add("Specification", item.Specification);
                projectObj.Add("ManageNumber", item.ManageNo);
                projectObj.Add("MadeNumber", item.SerialNo);
                projectObj.Add("InspectDate", item.DueStartDate);
                projectObj.Add("DueEndDate", item.DueEndDate);
                projectObj.Add("InspectOrg", item.InspectOrg);
                projectObj.Add("Remark", instrumentWaitSendModel.Remark);
                projectObj.Add("MD5Code", dictionaryMd5[item.InstrumentId]);
                projectJArr.Add(projectObj);
                if (count % maxLen == 0 || (count % maxLen == leftCout))
                {
                    string En_Order   = SSOHelper.Encrypt(orderObj.ToString());
                    string En_Project = SSOHelper.Encrypt(projectJArr.ToString());

                    string jsonData = GRGTCommonUtils.WSProvider.EbusinessProvider.SendOrder(En_Order, En_Project, Global.Business.ServiceProvider.ParamService.GetaccessToken(Instrument.Common.Constants.SysParamType.CompanyInfo));
                    Dictionary <string, object> dic = ToolsLib.Utility.CommonUtils.JsonDeserialize(jsonData, typeof(Dictionary <string, object>)) as Dictionary <string, object>;
                    result = dic["Msg"].ToString();
                    projectJArr.Clear();
                    if (!result.Equals("OK"))//一次不成功则终止推送
                    {
                        break;
                    }
                }
            }

            if (result.Equals("OK"))
            {
                OrderModel order = new OrderModel();
                order.OrderNumber     = orderNumber;//单号
                order.SendUser        = UserName;
                order.UserId          = UserId;
                order.CreateUser      = order.SendUser;
                order.ReceivedUser    = "";
                order.InstrumentCount = instrumentIdList.Count;
                ServiceProvider.OrderService.Save(order);
                //新增送检仪器清单
                InstrumentModel instrumentModel = null;

                foreach (int instrumentId in instrumentIdList)
                {
                    OrderSendInstrumentModel model = new OrderSendInstrumentModel();
                    instrumentModel         = instrumentList.SingleOrDefault(I => I.InstrumentId.Equals(instrumentId));
                    instrumentWaitSendModel = instrumentWaitSendList.SingleOrDefault(I => I.InstrumentId.Equals(instrumentId));
                    if (instrumentModel == null)
                    {
                        continue;
                    }
                    model.InstrumentId        = instrumentId;
                    model.ItemCode            = dictionaryMd5[instrumentId];
                    model.OrderId             = order.OrderId;
                    model.InstrumentName      = instrumentModel.InstrumentName;
                    model.CertificationNumber = instrumentModel.CertificateNo;
                    model.SerialNo            = instrumentModel.SerialNo;
                    model.Specification       = instrumentModel.Specification;
                    model.ManageNo            = instrumentModel.ManageNo;
                    model.InspectDate         = instrumentModel.DueStartDate;
                    model.DueEndDate          = instrumentModel.DueEndDate;
                    model.InspectOrg          = "广电计量";//
                    model.Remark = instrumentWaitSendModel.Remark;
                    ServiceProvider.OrderSendInstrumentService.Save(model);
                }
            }

            return(result);
        }
Esempio n. 11
0
        /// <summary>
        /// 批量导入固定资产
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="sucessMsg"></param>
        /// <returns></returns>
        public string BatchImportAssets(DataTable dt, ref string sucessMsg)
        {
            StringBuilder result = new StringBuilder();

            Global.Common.Models.ParamItemModel   paranItem = new Global.Common.Models.ParamItemModel();
            IList <Global.Common.Models.OrgModel> orgList   = Global.Business.ServiceProvider.OrgService.GetAll();
            //系统参数
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            //器具状态
            Global.Common.Models.ParamModel instrumentState = paramList.SingleOrDefault(t => t.ParamCode == Constants.SysParamType.AssetsState);
            if (null == instrumentState)
            {
                instrumentState = new Global.Common.Models.ParamModel();
            }
            //资产属性
            Global.Common.Models.ParamModel calibrationType = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.CalibrationType);
            if (null == calibrationType)
            {
                calibrationType = new Global.Common.Models.ParamModel();
            }

            IList <Global.Common.Models.OrgModel> belongDepartList = new List <Global.Common.Models.OrgModel>();
            InstrumentModel instrument  = new InstrumentModel();
            int             sucessCount = 0;

            foreach (DataRow dr in dt.Rows)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(dr["资产名称"].ToString()))
                    {
                        continue;
                    }
                    instrument.InstrumentForm = Constants.InstrumentForm.固定资产.GetHashCode();
                    instrument.InstrumentName = UtilsHelper.SpecialCharValidate(dr["资产名称"].ToString());
                    instrument.Specification  = UtilsHelper.SpecialCharValidate(dr["型号规格"].ToString());
                    instrument.SerialNo       = UtilsHelper.SpecialCharValidate(dr["出厂编号"].ToString());
                    //设备状态
                    paranItem = instrumentState.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["设备状态"].ToString()));
                    instrument.RecordState = paranItem == null ? 0 : Convert.ToInt32(paranItem.ParamItemValue);
                    //资产属性
                    paranItem = calibrationType.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["资产属性"].ToString()));
                    instrument.CalibrationType = paranItem == null ? 0 : Convert.ToInt32(paranItem.ParamItemValue);
                    //所属部门
                    belongDepartList = orgList.Where(o => o.OrgName.Equals(dr["所属部门"].ToString().Trim())).ToList();
                    if (belongDepartList.Count > 0)
                    {
                        instrument.BelongDepart = belongDepartList[0].OrgCode;
                    }
                    else
                    {
                        instrument.BelongDepart = "";
                    }
                    instrument.AssetsNo   = UtilsHelper.SpecialCharValidate(dr["资产编号"].ToString());
                    instrument.ManageNo   = UtilsHelper.SpecialCharValidate(dr["管理编号"].ToString());
                    instrument.LeaderName = UtilsHelper.SpecialCharValidate(dr["保管人"].ToString());
                    instrument.StorePalce = UtilsHelper.SpecialCharValidate(dr["存放地点"].ToString());
                    if (!string.IsNullOrWhiteSpace(dr["购置日期"].ToString()))
                    {
                        DateTime buyDate;
                        if (DateTime.TryParse(dr["购置日期"].ToString(), out buyDate))
                        {
                            instrument.BuyDate = buyDate;
                        }
                        else
                        {
                            result.AppendLine("购置日期【" + dr["购置日期"].ToString() + "】格式不正确");
                            continue;
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(dr["购置金额"].ToString()))
                    {
                        instrument.Price = Convert.ToDecimal(dr["购置金额"].ToString());
                    }
                    instrument.Manufacturer         = UtilsHelper.SpecialCharValidate(dr["生产厂家"].ToString());
                    instrument.ManufactureContactor = UtilsHelper.SpecialCharValidate(dr["厂家联系信息"].ToString());
                    instrument.Remark = UtilsHelper.SpecialCharValidate(dr["备注"].ToString());

                    instrument.CreateUser     = LoginHelper.LoginUser.UserName;
                    instrument.LastUpdateUser = LoginHelper.LoginUser.UserName;
                    instrument.BarCode        = DateTime.Now.ToString("yyyyMMddff") + ToolsLib.Utility.StrUtils.GetRandomNumb(6);
                    instrument.ItemCode       = Guid.NewGuid().ToString();
                    //新增
                    DBProvider.InstrumentDAO.Add4Assets(instrument);

                    //导入成功记录
                    sucessCount++;
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message);
                    result.AppendLine("未成功导入资产:名称(" + instrument.InstrumentName + ") 资产编号(" + instrument.AssetsNo + ")");
                }
            }
            sucessMsg = "共导入" + sucessCount + "条记录";
            return(result.ToString());
        }
Esempio n. 12
0
        public string BatchImportInstrument(DataTable dt, ref string sucessMsg)
        {
            StringBuilder result = new StringBuilder();

            Global.Common.Models.ParamItemModel   paranItem = new Global.Common.Models.ParamItemModel();
            IList <Global.Common.Models.OrgModel> orgList   = Global.Business.ServiceProvider.OrgService.GetAll();
            ////组织根目录
            //orgList.SingleOrDefault(o=>o.OrgCode
            //系统参数
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();

            //器具状态
            Global.Common.Models.ParamModel instrumentState = paramList.SingleOrDefault(t => t.ParamCode == Constants.SysParamType.InstrumentState);
            if (null == instrumentState)
            {
                instrumentState = new Global.Common.Models.ParamModel();
            }

            Global.Common.Models.ParamModel instrumentType = paramList.SingleOrDefault(t => t.ParamCode == UtilConstants.SysParamType.InstrumentType);
            if (null == instrumentType)
            {
                instrumentType = new Global.Common.Models.ParamModel();
            }

            //设备分类
            Global.Common.Models.ParamModel instrumentCate = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.InstrumentCate);
            if (null == instrumentCate)
            {
                instrumentCate = new Global.Common.Models.ParamModel();
            }

            //资产属性
            Global.Common.Models.ParamModel calibrationType = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.CalibrationType);
            if (null == calibrationType)
            {
                calibrationType = new Global.Common.Models.ParamModel();
            }

            //管理级别
            Global.Common.Models.ParamModel manageLevel = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.ManageLevel);
            if (null == manageLevel)
            {
                manageLevel = new Global.Common.Models.ParamModel();
            }

            //计量类别
            Global.Common.Models.ParamModel verificationType = paramList.SingleOrDefault(t => t.ParamCode == Instrument.Common.Constants.SysParamType.VerificationType);
            if (null == verificationType)
            {
                verificationType = new Global.Common.Models.ParamModel();
            }

            IList <Global.Common.Models.OrgModel> belongDepartList = new List <Global.Common.Models.OrgModel>();
            IList <InstrumentModel> instrumentList = new List <InstrumentModel>();
            //判断是否需要检测管理编号存在
            string IsJudgeExistManageNo = WebUtils.GetSettingsValue("IsJudgeExistManageNo");

            if (IsJudgeExistManageNo == "true")
            {
                instrumentList = GetAll().Where(t => !string.IsNullOrWhiteSpace(t.ManageNo)).ToList();
            }
            IList <string>  manageNoList    = new List <string>();
            int             count           = 0;
            bool            IsSynInstrument = LoginHelper.LoginUserAuthorize.Contains("/Instrument/SynInstrument".ToLower());
            InstrumentModel instrument      = new InstrumentModel();
            int             sucessCount     = 0;

            foreach (DataRow dr in dt.Rows)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(dr["仪器名称"].ToString()))
                    {
                        //result.AppendLine("仪器名称不能为空");
                        continue;
                    }
                    instrument.InstrumentForm = Constants.InstrumentForm.仪器.GetHashCode();//仪器
                    instrument.InstrumentName = UtilsHelper.SpecialCharValidate(dr["仪器名称"].ToString());
                    //型号
                    instrument.Specification = UtilsHelper.SpecialCharValidate(dr["仪器型号"].ToString());
                    //管理编号
                    instrument.ManageNo = UtilsHelper.SpecialCharValidate(dr["管理编号"].ToString());

                    if (IsJudgeExistManageNo == "true")
                    {
                        //在库中查找管理编号
                        count = instrumentList.Where(t => t.ManageNo.Trim().Equals(instrument.ManageNo.Trim())).Count();
                        //在导入的数据中找管理编号
                        if (count == 0)
                        {
                            count = manageNoList.Where(t => t.Trim().Equals(instrument.ManageNo.Trim())).Count();
                        }
                        if (count > 0)
                        {
                            result.AppendLine("存在相同的管理编号(" + instrument.ManageNo + ")");
                            continue;
                        }
                        if (!string.IsNullOrWhiteSpace(instrument.ManageNo))
                        {
                            manageNoList.Add(instrument.ManageNo);
                        }
                    }

                    //出厂编号
                    instrument.SerialNo = UtilsHelper.SpecialCharValidate(dr["出厂编号"].ToString());
                    //技术特征
                    instrument.TechniqueCharacter = UtilsHelper.SpecialCharValidate(dr["技术特征"].ToString());
                    //计量特性
                    instrument.MeasureCharacter = UtilsHelper.SpecialCharValidate(dr["计量特性"].ToString());
                    //设备状态
                    paranItem = instrumentState.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["设备状态"].ToString()));
                    instrument.RecordState = paranItem == null ? 0 : Convert.ToInt32(paranItem.ParamItemValue);

                    //设备分类
                    paranItem = instrumentCate.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["设备分类"].ToString()));
                    instrument.InstrumentCate = paranItem == null ? 1 : Convert.ToInt32(paranItem.ParamItemValue);

                    //资产属性
                    paranItem = calibrationType.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["资产属性"].ToString()));
                    instrument.CalibrationType = paranItem == null ? 0 : Convert.ToInt32(paranItem.ParamItemValue);

                    //设备类别
                    paranItem = instrumentType.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["设备类别"].ToString()));
                    instrument.InstrumentType = paranItem == null ? 0 : Convert.ToInt32(paranItem.ParamItemValue);

                    //管理级别
                    paranItem = manageLevel.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["管理级别"].ToString()));
                    instrument.ManageLevel = paranItem == null ? "A" : paranItem.ParamItemValue;

                    //计量类别
                    paranItem = verificationType.itemsList.SingleOrDefault(i => i.ParamItemName.Equals(dr["计量类别"].ToString()));
                    instrument.VerificationType = paranItem == null ? 0 : Convert.ToInt32(paranItem.ParamItemValue);
                    //英文名称
                    instrument.EnglishName = UtilsHelper.SpecialCharValidate(dr["英文名称"].ToString());
                    //所属部门
                    belongDepartList = orgList.Where(o => o.OrgName.Equals(dr["所属部门"].ToString().Trim())).ToList();
                    if (belongDepartList.Count > 0)
                    {
                        instrument.BelongDepart = belongDepartList[0].OrgCode;
                    }
                    else
                    {
                        instrument.BelongDepart = "";
                    }
                    //仪器证书信息
                    //证书编号
                    instrument.CertificateNo = UtilsHelper.SpecialCharValidate(dr["证书编号"].ToString());
                    if (!string.IsNullOrWhiteSpace(dr["校准日期"].ToString()))
                    {
                        instrument.DueStartDate = Convert.ToDateTime(dr["校准日期"].ToString());
                    }
                    if (!string.IsNullOrWhiteSpace(dr["到期日期"].ToString()))
                    {
                        instrument.DueEndDate = Convert.ToDateTime(dr["到期日期"].ToString());
                    }
                    //计量机构
                    instrument.InspectOrg = UtilsHelper.SpecialCharValidate(dr["计量机构"].ToString());

                    //资产编号
                    instrument.AssetsNo = UtilsHelper.SpecialCharValidate(dr["资产编号"].ToString());

                    //校验周期
                    instrument.InspectCycle = UtilsHelper.SpecialCharValidate(dr["检验周期"].ToString());
                    //使用年限
                    instrument.DurableYears = UtilsHelper.SpecialCharValidate(dr["使用年限"].ToString());
                    //保管人
                    instrument.LeaderName = UtilsHelper.SpecialCharValidate(dr["保管人"].ToString());
                    //项目组
                    instrument.ProjectTeam = UtilsHelper.SpecialCharValidate(dr["项目组"].ToString());
                    //说明书编号
                    //instrument.SpecificationCode = dr[23].ToString();
                    //存放地点
                    instrument.StorePalce = UtilsHelper.SpecialCharValidate(dr["存放地点"].ToString());
                    //购置日期
                    if (!string.IsNullOrWhiteSpace(dr["购置日期"].ToString()))
                    {
                        instrument.BuyDate = Convert.ToDateTime(dr["购置日期"].ToString());
                    }
                    //购置金额
                    if (!string.IsNullOrWhiteSpace(dr["购置金额"].ToString()))
                    {
                        instrument.Price = Convert.ToDecimal(dr["购置金额"].ToString());
                    }
                    //生产厂家
                    instrument.Manufacturer = UtilsHelper.SpecialCharValidate(dr["生产厂家"].ToString());
                    //厂家联系信息
                    instrument.ManufactureContactor = UtilsHelper.SpecialCharValidate(dr["厂家联系信息"].ToString());
                    //备注
                    instrument.Remark = UtilsHelper.SpecialCharValidate(dr["备注"].ToString());

                    instrument.CreateUser     = LoginHelper.LoginUser.UserName;
                    instrument.LastUpdateUser = LoginHelper.LoginUser.UserName;
                    instrument.BarCode        = DateTime.Now.ToString("yyyyMMddff") + ToolsLib.Utility.StrUtils.GetRandomNumb(6);
                    instrument.ItemCode       = Guid.NewGuid().ToString();
                    //新增仪器
                    DBProvider.InstrumentDAO.Add4Instrument(instrument);

                    //仪器证书信息 当三个都不为空时保存
                    if (!string.IsNullOrWhiteSpace(instrument.CertificateNo) && (instrument.DueStartDate != null) && (instrument.DueEndDate != null))
                    {
                        InstrumentCertificationModel cert = new InstrumentCertificationModel();
                        cert.InstrumentId      = instrument.InstrumentId;
                        cert.CertificationCode = UtilsHelper.SpecialCharValidate(instrument.CertificateNo);
                        cert.CheckDate         = instrument.DueStartDate;
                        cert.EndDate           = instrument.DueEndDate;
                        cert.MeasureOrg        = instrument.InspectOrg;
                        cert.RecordState       = Constants.InstrumentCertificationState.完成周检.GetHashCode();
                        ServiceProvider.InstrumentCertificationService.SaveCert(cert);
                        ServiceProvider.InstrumentCertificationService.UpdateCertificationAndState(instrument.InstrumentId);
                    }
                    //同步到业务系统
                    if (IsSynInstrument && instrument.InstrumentCate > 0)
                    {
                        BeginSynInstrument(instrument.InstrumentId);
                    }
                    //导入成功记录
                    sucessCount++;
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message);
                    result.AppendLine("未成功导入仪器:名称(" + instrument.InstrumentName + ") 管理编号(" + instrument.ManageNo + ")");
                }
            }
            sucessMsg = "共导入" + sucessCount + "条记录";
            return(result.ToString());
        }