コード例 #1
0
        /// <summary>
        /// 获取周检明细
        /// </summary>
        /// <param name="logId"></param>
        /// <param name="instrumentId"></param>
        /// <returns></returns>
        public ActionResult GetInstrumentCertificationDetail(int logId)
        {
            InstrumentCertificationModel model = null;

            model = ServiceProvider.InstrumentCertificationService.GetById(logId);
            ViewBag.RecordState            = (Constants.InstrumentCertificationState)model.RecordState;
            ViewBag.AttachmentBusinessType = Constants.AttachmentBusinessType.周期校准记录.GetHashCode();
            ViewBag.BusinessId             = UtilsHelper.Encrypt(model.LogId.ToString());
            return(View("InstrumentCertificationDetail", model));
        }
コード例 #2
0
        /// <summary>
        /// 是否存在证书编号
        /// </summary>
        /// <param name="certificationCode"></param>
        /// <returns></returns>
        public bool IsExistCertificationCode(int logId, string certificationCode)
        {
            InstrumentCertificationModel model = new InstrumentCertificationModel();

            model.LogId             = logId;
            model.CertificationCode = certificationCode;
            int count = DBProvider.dbMapper.SelectObject <int>("Instrument_Certification.IsExistCertificationCode", model);

            return(count > 0);
        }
コード例 #3
0
 /// <summary>
 /// 仪器证书保存方法(不含附件信息)
 /// </summary>
 /// <param name="model"></param>
 public void SaveCert(InstrumentCertificationModel model)
 {
     if (model.LogId == 0)
     {
         model.CreateUser = LoginHelper.LoginUser.UserName;
         model.ItemCode   = Guid.NewGuid().ToString();
         DBProvider.InstrumentCertificationDAO.Add(model);
     }
     else
     {
         DBProvider.InstrumentCertificationDAO.Update(model);
     }
 }
コード例 #4
0
        /// <summary>
        /// 找出仪器下到期日期最大并且当前日期在有效期之内同时完成周检的证书记录并更新
        /// </summary>
        /// <param name="instrumentId"></param>
        public void UpdateCertificationAndState(int instrumentId)
        {
            Instrument.Common.Models.InstrumentModel instrument = new Instrument.Common.Models.InstrumentModel();
            instrument.InstrumentId = instrumentId;
            //找出仪器下到期日期最大并且当前日期在有效期之内同时完成周检的证书记录
            InstrumentCertificationModel certModel = DBProvider.InstrumentCertificationDAO.GetMaxEndDateByInstrumentId(instrumentId, DateTime.Now.ToString("yyyy-MM-dd"));

            if (certModel == null)
            {
                instrument = ServiceProvider.InstrumentService.GetById(instrumentId);
                instrument.CertificateNo = null;
                instrument.DueStartDate  = null;
                instrument.DueEndDate    = null;
                instrument.InspectOrg    = null;
                if (instrument.ManageLevel != "C")
                {
                    instrument.RecordState = UtilConstants.InstrumentState.过期禁用.GetHashCode();
                }
            }
            else
            {
                instrument.CertificateNo = certModel.CertificationCode;
                instrument.DueStartDate  = certModel.CheckDate;
                instrument.DueEndDate    = certModel.EndDate;
                instrument.InspectOrg    = certModel.MeasureOrg;
                if (certModel.EndDate < DateTime.Now)
                {
                    instrument.RecordState = UtilConstants.InstrumentState.过期禁用.GetHashCode();
                    //找到,将该条记录设为正在使用
                    certModel.IsUseding = false;
                }
                else
                {
                    instrument.RecordState = UtilConstants.InstrumentState.合格.GetHashCode();
                    certModel.IsUseding    = true;
                }
            }
            //更新仪器的证书信息
            ServiceProvider.InstrumentService.UpdateCertificationInfo(instrument);
            //更新当前证书正在使用状态,其他设为未使用
            UpdateIsUseding(certModel);
        }
コード例 #5
0
        /// <summary>
        /// 保存实体数据.
        /// </summary>
        public void Save(InstrumentCertificationModel model, HttpFileCollectionBase Files)
        {
            if (Files.Count > 0 && Files[0].ContentLength > 0)
            {
                string          targetPath = WebUtils.GetSettingsValue("InstrumentCertificationPath");
                string          targetFile = string.Format(@"{0}/{1}{2}", targetPath, StrUtils.GetUniqueFileName(null), Path.GetExtension(Files[0].FileName));
                AttachmentModel attModel   = UtilsHelper.FileUpload(Files[0], targetFile, (UtilConstants.ServerType)Convert.ToInt32(WebUtils.GetSettingsValue("WebFileType") == null ? "1" : WebUtils.GetSettingsValue("WebFileType")));
                attModel.FileType = (int)UtilConstants.AttachmentType.仪器周检证书;
                attModel.UserId   = LoginHelper.LoginUser.UserId;
                attModel.UserName = LoginHelper.LoginUser.UserName;
                if (model.LogId != 0)//重新上传删除原来文件
                {
                    Global.Business.ServiceProvider.AttachmentService.DeleteById(model.FileId);
                }
                Global.Business.ServiceProvider.AttachmentService.Save(attModel);
                model.FileId = attModel.FileId;//新文件位置
                //model.FileVirtualPath = WebUtils.GetSettingsValue("WebFileServer")+targetFile;
            }
            if (model.LogId == 0)
            {
                model.CreateUser = LoginHelper.LoginUser.UserName;
                model.ItemCode   = Guid.NewGuid().ToString();
                DBProvider.InstrumentCertificationDAO.Add(model);
            }
            else
            {
                DBProvider.InstrumentCertificationDAO.Update(model);
            }
            //找出仪器下到期日期最大并且当前日期在有效期之内同时完成周检的证书记录并更新
            UpdateCertificationAndState(model.InstrumentId);
            //更新上次修改人和修改时间
            Instrument.Common.Models.InstrumentModel instrumentModel = new Instrument.Common.Models.InstrumentModel();
            instrumentModel.InstrumentId   = model.InstrumentId;
            instrumentModel.LastUpdateUser = LoginHelper.LoginUser.UserName;
            ServiceProvider.InstrumentService.UpdateLastUpdateInfo(instrumentModel);

            if (LoginHelper.LoginUserAuthorize.Contains("/Instrument/SynInstrument".ToLower()))
            {
                ServiceProvider.InstrumentService.BeginSynInstrument(model.InstrumentId);
            }
        }
コード例 #6
0
        public void Synchronous(InstrumentCertificationModel model, Stream stream, string fileName, string targetFileName)
        {
            //(System.IO.Stream inputStream, string sourceFileName, string targetFileName, UtilConstants.ServerType targetServer)
            if (stream != null)
            {
                AttachmentModel attModel = UtilsHelper.FileUpload(stream, fileName, targetFileName, (UtilConstants.ServerType)Convert.ToInt32(WebUtils.GetSettingsValue("WebFileType") == null ? "1" : WebUtils.GetSettingsValue("WebFileType")));
                attModel.FileType = (int)UtilConstants.AttachmentType.仪器周检证书;
                attModel.UserId   = LoginHelper.LoginUser.UserId;
                attModel.UserName = LoginHelper.LoginUser.UserName;
                if (model.LogId != 0)//重新上传删除原来文件
                {
                    Global.Business.ServiceProvider.AttachmentService.DeleteById(model.FileId);
                }
                Global.Business.ServiceProvider.AttachmentService.Save(attModel);
                model.FileId = attModel.FileId;//新文件位置
            }
            if (model.LogId == 0)
            {
                model.CreateUser = LoginHelper.LoginUser.UserName;
                model.ItemCode   = Guid.NewGuid().ToString();
                DBProvider.InstrumentCertificationDAO.Add(model);
            }
            else
            {
                DBProvider.InstrumentCertificationDAO.Update(model);
            }
            //找出仪器下到期日期最大并且当前日期在有效期之内同时完成周检的证书记录并更新
            UpdateCertificationAndState(model.InstrumentId);
            //更新上次修改人和修改时间
            Instrument.Common.Models.InstrumentModel instrumentModel = new Instrument.Common.Models.InstrumentModel();
            instrumentModel.InstrumentId   = model.InstrumentId;
            instrumentModel.LastUpdateUser = LoginHelper.LoginUser.UserName;
            ServiceProvider.InstrumentService.UpdateLastUpdateInfo(instrumentModel);

            if (LoginHelper.LoginUserAuthorize.Contains("/Instrument/SynInstrument".ToLower()))
            {
                ServiceProvider.InstrumentService.BeginSynInstrument(model.InstrumentId);
            }
        }
コード例 #7
0
 /// <summary>
 /// 更新周检记录.
 /// </summary>
 public void Update(InstrumentCertificationModel model)
 {
     DBProvider.dbMapper.Update("BaseData_InstrumentCertification.Update", model);
 }
コード例 #8
0
 /// <summary>
 /// 增加周检记录.
 /// </summary>
 public void Add(InstrumentCertificationModel model)
 {
     DBProvider.dbMapper.Insert("BaseData_InstrumentCertification.Insert", model);
 }
コード例 #9
0
 public void UpdateIsUseding(InstrumentCertificationModel model)
 {
     DBProvider.dbMapper.Update("Instrument_Certification.UpdateIsUseding", model);
 }
コード例 #10
0
 public void UpdateCertInfo(InstrumentCertificationModel model)
 {
     DBProvider.dbMapper.Update("Instrument_Certification.UpdateCertInfo", model);
 }
コード例 #11
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());
        }
コード例 #12
0
 /// <summary>
 /// 更新当前证书正在使用状态,其他设为未使用
 /// </summary>
 /// <param name="model"></param>
 public void UpdateIsUseding(InstrumentCertificationModel model)
 {
     DBProvider.InstrumentCertificationDAO.UpdateIsUseding(model);
 }
コード例 #13
0
 /// <summary>
 /// 更新证书编号,校准时间,到期日期
 /// </summary>
 /// <param name="model"></param>
 public void UpdateCertInfo(InstrumentCertificationModel model)
 {
     DBProvider.InstrumentCertificationDAO.UpdateCertInfo(model);
 }
コード例 #14
0
 //同步周期校准记录时使用
 public void Insert(InstrumentCertificationModel model)
 {
     DBProvider.InstrumentCertificationDAO.Add(model);
     //找出仪器下到期日期最大并且当前日期在有效期之内同时完成周检的证书记录并更新
     UpdateCertificationAndState(model.InstrumentId);
 }