/// <summary> /// 盘点 /// </summary> /// <param name="barCode"></param> /// <param name="operatorJobNo"></param> /// <returns></returns> public string AssetCheck(string barCode, int userId, string userName) { string msg = "你不是该设备盘点人员!"; Instrument.Common.Models.InstrumentModel instrumentModel = ServiceProvider.InstrumentService.GetByBarCode(barCode); if (instrumentModel == null) { return(msg = "该设备不存在,请盘盈!"); } IList <AssetCheckPlanDetailModel> detailList = ServiceProvider.AssetCheckPlanDetailService.GetCheckingPlanDetailByBarCode(barCode); if (detailList.Count == 0) { return(msg = "没有该设备的盘点任务!"); } foreach (AssetCheckPlanDetailModel detail in detailList) { IList <AssetCheckOperatorModel> operatorList = ServiceProvider.AssetCheckOperatorService.GetByPlanId(detail.PlanId); if (operatorList.Where(W => W.UserId == userId).Count() > 0) { DBProvider.AssetCheckPlanDetailDAO.AssetCheck(detail.PlanDetailId, Constants.AssetsCheckStatus.已盘点.GetHashCode(), userName); msg = "OK"; } } //更新最近盘点人和最近盘点时间 instrumentModel.LastCheckUser = userName; ServiceProvider.InstrumentService.UpdateLastCheckInfo(instrumentModel); return(msg); }
/// <summary> /// 盘点地点是否一致 /// </summary> /// <param name="barCode"></param> /// <param name="operatorJobNo"></param> /// <returns></returns> public string AssetIsRightAddressAndRemark(string barCode, int userId, string remark, int isRightAddress) { string msg = "你不是该设备盘点人员!"; Instrument.Common.Models.InstrumentModel instrumentModel = ServiceProvider.InstrumentService.GetByBarCode(barCode); if (instrumentModel == null) { return(msg = "该设备不存在,请盘盈!"); } IList <AssetCheckPlanDetailModel> detailList = ServiceProvider.AssetCheckPlanDetailService.GetCheckingPlanDetailByBarCode(barCode); if (detailList.Count == 0) { return(msg = "没有该设备的盘点任务!"); } foreach (AssetCheckPlanDetailModel detail in detailList) { IList <AssetCheckOperatorModel> operatorList = ServiceProvider.AssetCheckOperatorService.GetByPlanId(detail.PlanId); if (operatorList.Where(W => W.UserId == userId).Count() > 0) { DBProvider.AssetCheckPlanDetailDAO.AssetIsRightAddressAndRemark(detail.PlanDetailId, isRightAddress, remark); msg = "OK"; } } return(msg); }
public ActionResult Save(string barCode, InstrumentFlowModel model) { Instrument.Common.Models.InstrumentModel instrument = ServiceProvider.InstrumentService.GetByBarCode(barCode); if (instrument == null) { return(Json(new { Msg = "Not Found" })); } string InstrumentInfo = "<b>仪器名称:</b>" + instrument.InstrumentName + " | <b>仪器型号:</b>" + instrument.Specification + " | <b>出厂编号:</b>" + instrument.SerialNo + " | <b>管理编号:</b>" + instrument.ManageNo; model.InstrumentId = instrument.InstrumentId; model.Creator = LoginHelper.LoginUser.UserName; model.Place = ""; ServiceProvider.InstrumentFlowService.Save(model); return(Json(new { Msg = "OK", InstrumentInfo = InstrumentInfo, InstrumentId = UtilsHelper.Encrypt(instrument.InstrumentId.ToString()) }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 多处使用方法 /// </summary> /// <param name="instrumentId"></param> public string BeginSynInstrument(int instrumentId) { try { Instrument.Common.Models.InstrumentModel model = ServiceProvider.InstrumentService.GetById(instrumentId); if (model == null) { return("{\"Msg\":\"该仪器不存在\"}"); } model.ownCheckLogList = ServiceProvider.InstrumentCertificationService.GetByInstrumentId(instrumentId).Where(c => c.RecordState == Constants.InstrumentCertificationState.完成周检.GetHashCode()).ToList(); return(WSProvider.CommonProvider.SendInstrumentData(ToolsLib.Utility.CommonUtils.JsonSerialize(model))); } catch (Exception ex) { return("仪器同步到业务系统时失败"); } }
/// <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); }
/// <summary> /// 删除记录. /// </summary> public string DeleteById(int LogId, int InstrumentId) { string msg = "OK"; //IList<InstrumentCertificationModel> certList = GetByInstrumentId(InstrumentId); //if (certList.Count == 1) return "只有一条周期校准记录,不能删除"; DBProvider.InstrumentCertificationDAO.DeleteById(LogId); //找出仪器下到期日期最大并且当前日期在有效期之内同时完成周检的证书记录并更新 UpdateCertificationAndState(InstrumentId); Instrument.Common.Models.InstrumentModel model = new Instrument.Common.Models.InstrumentModel(); model.InstrumentId = InstrumentId; model.LastUpdateUser = LoginHelper.LoginUser.UserName; ServiceProvider.InstrumentService.UpdateLastUpdateInfo(model); if (LoginHelper.LoginUserAuthorize.Contains("/Instrument/SynInstrument".ToLower())) { ServiceProvider.InstrumentService.BeginSynInstrument(InstrumentId); } return(msg); }
/// <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); } }
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); } }