/// <summary> /// 添加安全专项检查 /// </summary> /// <param name="checkSpecial"></param> public static void AddCheckSpecial(Model.Check_CheckSpecial checkSpecial) { Model.SUBHSSEDB db = Funs.DB; Model.Check_CheckSpecial newCheckSpecial = new Model.Check_CheckSpecial { CheckSpecialId = checkSpecial.CheckSpecialId, CheckSpecialCode = checkSpecial.CheckSpecialCode, ProjectId = checkSpecial.ProjectId, CheckPerson = checkSpecial.CheckPerson, CheckTime = checkSpecial.CheckTime, ScanUrl = checkSpecial.ScanUrl, DaySummary = checkSpecial.DaySummary, PartInUnits = checkSpecial.PartInUnits, PartInPersons = checkSpecial.PartInPersons, PartInPersonIds = checkSpecial.PartInPersonIds, PartInPersonNames = checkSpecial.PartInPersonNames, CheckAreas = checkSpecial.CheckAreas, States = checkSpecial.States, CompileMan = checkSpecial.CompileMan, CheckType = checkSpecial.CheckType, CheckItemSetId = checkSpecial.CheckItemSetId, }; db.Check_CheckSpecial.InsertOnSubmit(newCheckSpecial); db.SubmitChanges(); ////增加一条编码记录 BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ProjectCheckSpecialMenuId, checkSpecial.ProjectId, null, checkSpecial.CheckSpecialId, checkSpecial.CheckTime); if (!string.IsNullOrEmpty(newCheckSpecial.PartInPersonIds)) { } }
/// <summary> /// 保存数据 /// </summary> /// <param name="type"></param> private void SaveData(string type) { Model.Check_CheckSpecial checkSpecial = new Model.Check_CheckSpecial { CheckSpecialCode = this.txtCheckSpecialCode.Text.Trim(), ProjectId = this.ProjectId }; ///组成员 string partInPersonIds = string.Empty; string partInPersons = string.Empty; foreach (var item in this.drpPartInPersons.SelectedValueArray) { var user = BLL.UserService.GetUserByUserId(item); if (user != null) { partInPersonIds += user.UserId + ","; partInPersons += user.UserName + ","; } } if (!string.IsNullOrEmpty(partInPersonIds)) { checkSpecial.PartInPersonIds = partInPersonIds.Substring(0, partInPersonIds.LastIndexOf(",")); checkSpecial.PartInPersons = partInPersons.Substring(0, partInPersons.LastIndexOf(",")); } checkSpecial.PartInPersonNames = this.txtPartInPersonNames.Text.Trim(); checkSpecial.CheckTime = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim()); ////单据状态 checkSpecial.States = Const.State_0; if (type == Const.BtnSubmit) { checkSpecial.States = Const.State_1; } if (!string.IsNullOrEmpty(this.drpSupCheckItemSet.SelectedValue) && this.drpSupCheckItemSet.SelectedValue != Const._Null) { checkSpecial.CheckItemSetId = this.drpSupCheckItemSet.SelectedValue; } if (!string.IsNullOrEmpty(this.CheckSpecialId)) { checkSpecial.CheckSpecialId = this.CheckSpecialId; Check_CheckSpecialService.UpdateCheckSpecial(checkSpecial); LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnModify); Check_CheckSpecialDetailService.DeleteCheckSpecialDetails(this.CheckSpecialId); } else { checkSpecial.CheckSpecialId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecial)); this.CheckSpecialId = checkSpecial.CheckSpecialId; checkSpecial.CompileMan = this.CurrUser.UserId; Check_CheckSpecialService.AddCheckSpecial(checkSpecial); LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnAdd); } this.SaveDetail(type, checkSpecial); }
/// <summary> /// /// </summary> private void SaveNew() { if (string.IsNullOrEmpty(this.CheckSpecialId)) { Model.Check_CheckSpecial checkSpecial = new Model.Check_CheckSpecial { CheckSpecialId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecial)), CheckSpecialCode = this.txtCheckSpecialCode.Text.Trim(), ProjectId = this.ProjectId }; ///组成员 string partInPersonIds = string.Empty; string partInPersons = string.Empty; foreach (var item in this.drpPartInPersons.SelectedValueArray) { var user = BLL.UserService.GetUserByUserId(item); if (user != null) { partInPersonIds += user.UserId + ","; partInPersons += user.UserName + ","; } } if (!string.IsNullOrEmpty(partInPersonIds)) { checkSpecial.PartInPersonIds = partInPersonIds.Substring(0, partInPersonIds.LastIndexOf(",")); checkSpecial.PartInPersons = partInPersons.Substring(0, partInPersons.LastIndexOf(",")); } checkSpecial.PartInPersonNames = this.txtPartInPersonNames.Text.Trim(); checkSpecial.CheckTime = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim()); ////单据状态 checkSpecial.States = Const.State_0; this.CheckSpecialId = checkSpecial.CheckSpecialId; checkSpecial.CompileMan = this.CurrUser.UserId; BLL.Check_CheckSpecialService.AddCheckSpecial(checkSpecial); BLL.LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnAdd); } }
/// <summary> /// 修改安全专项检查 /// </summary> /// <param name="checkSpecial"></param> public static void UpdateCheckSpecial(Model.Check_CheckSpecial checkSpecial) { Model.SUBHSSEDB db = Funs.DB; Model.Check_CheckSpecial newCheckSpecial = db.Check_CheckSpecial.FirstOrDefault(e => e.CheckSpecialId == checkSpecial.CheckSpecialId); if (newCheckSpecial != null) { newCheckSpecial.CheckSpecialCode = checkSpecial.CheckSpecialCode; //newCheckSpecial.ProjectId = checkSpecial.ProjectId; newCheckSpecial.CheckPerson = checkSpecial.CheckPerson; newCheckSpecial.CheckTime = checkSpecial.CheckTime; newCheckSpecial.ScanUrl = checkSpecial.ScanUrl; newCheckSpecial.DaySummary = checkSpecial.DaySummary; newCheckSpecial.PartInUnits = checkSpecial.PartInUnits; newCheckSpecial.PartInPersons = checkSpecial.PartInPersons; newCheckSpecial.PartInPersonIds = checkSpecial.PartInPersonIds; newCheckSpecial.PartInPersonNames = checkSpecial.PartInPersonNames; newCheckSpecial.CheckAreas = checkSpecial.CheckAreas; newCheckSpecial.States = checkSpecial.States; newCheckSpecial.CheckType = checkSpecial.CheckType; newCheckSpecial.CheckItemSetId = checkSpecial.CheckItemSetId; db.SubmitChanges(); } }
/// <summary> /// 保存Check_CheckSpecial /// </summary> /// <param name="newItem">处罚通知单</param> /// <returns></returns> public static string SaveCheckSpecial(Model.CheckSpecialItem newItem) { using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString)) { string message = string.Empty; Model.Check_CheckSpecial newCheckSpecial = new Model.Check_CheckSpecial { CheckSpecialId = newItem.CheckSpecialId, CheckSpecialCode = newItem.CheckSpecialCode, CheckItemSetId = newItem.CheckItemSetId, CheckType = newItem.CheckType, ProjectId = newItem.ProjectId, CheckPerson = newItem.CheckPersonId, CheckTime = Funs.GetNewDateTime(newItem.CheckTime), DaySummary = System.Web.HttpUtility.HtmlEncode(newItem.DaySummary), PartInUnits = newItem.PartInUnitIds, PartInPersonIds = newItem.PartInPersonIds, PartInPersons = UserService.getUserNamesUserIds(newItem.PartInPersonIds), PartInPersonNames = newItem.PartInPersonNames2, CompileMan = newItem.CompileManId, States = Const.State_2, }; if (newItem.States != "1") { newCheckSpecial.States = Const.State_0; } var updateCheckSpecial = db.Check_CheckSpecial.FirstOrDefault(x => x.CheckSpecialId == newItem.CheckSpecialId); if (updateCheckSpecial == null) { newCheckSpecial.CheckSpecialId = SQLHelper.GetNewID(); newCheckSpecial.CheckSpecialCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectCheckSpecialMenuId, newCheckSpecial.ProjectId, string.Empty); db.Check_CheckSpecial.InsertOnSubmit(newCheckSpecial); db.SubmitChanges(); ////增加一条编码记录 BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ProjectCheckSpecialMenuId, newCheckSpecial.ProjectId, null, newCheckSpecial.CheckSpecialId, newCheckSpecial.CheckTime); } else { Check_CheckSpecialService.UpdateCheckSpecial(newCheckSpecial); //// 删除专项检查明细项 Check_CheckSpecialDetailService.DeleteCheckSpecialDetails(newCheckSpecial.CheckSpecialId); } if (newCheckSpecial.States == "1") { CommonService.btnSaveData(newCheckSpecial.ProjectId, Const.ProjectCheckSpecialMenuId, newCheckSpecial.CheckSpecialId, newCheckSpecial.CompileMan, true, newCheckSpecial.CheckSpecialCode, "../Check/CheckSpecialView.aspx?CheckSpecialId={0}"); } ////保存附件 if (!string.IsNullOrEmpty(newItem.AttachUrl1)) { UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newItem.AttachUrl1, 10, null), newItem.AttachUrl1, Const.ProjectCheckSpecialMenuId, newCheckSpecial.CheckSpecialId); } else { CommonService.DeleteAttachFileById(Const.ProjectCheckSpecialMenuId, newCheckSpecial.CheckSpecialId); } ///// 新增检查项 if (newItem.CheckSpecialDetailItems != null && newItem.CheckSpecialDetailItems.Count() > 0) { foreach (var item in newItem.CheckSpecialDetailItems) { item.CheckSpecialId = newCheckSpecial.CheckSpecialId; SaveCheckSpecialDetail(item); } //// 单据完成后 系统自动按照单位 整改要求生成隐患整改单 if (newCheckSpecial.States == Const.State_2) { SaveNewRectifyNotices(newItem); message = "已生成整改单,请在隐患整改单待提交中签发!"; } } return(message); } }
/// <summary> /// 保存明细项 /// </summary> private void SaveDetail(string type, Model.Check_CheckSpecial checkSpecial) { List <Model.Check_CheckSpecialDetail> detailLists = new List <Model.Check_CheckSpecialDetail>(); JArray teamGroupData = Grid1.GetMergedData(); foreach (JObject teamGroupRow in teamGroupData) { JObject values = teamGroupRow.Value <JObject>("values"); Model.Check_CheckSpecialDetail newDetail = new Model.Check_CheckSpecialDetail { CheckSpecialDetailId = SQLHelper.GetNewID(), CheckSpecialId = this.CheckSpecialId, CheckContent = values.Value <string>("CheckItemName"), Unqualified = values.Value <string>("Unqualified"), WorkArea = values.Value <string>("WorkArea"), }; var getUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == values.Value <string>("UnitName")); if (getUnit != null) { newDetail.UnitId = getUnit.UnitId; } var getHandleStep = Funs.DB.Sys_Const.FirstOrDefault(x => x.GroupId == ConstValue.Group_HandleStep && x.ConstText == values.Value <string>("HandleStepStr")); if (getHandleStep != null) { newDetail.HandleStep = getHandleStep.ConstValue; } if (values.Value <string>("CompleteStatusName") == "已整改") { newDetail.CompleteStatus = true; newDetail.CompletedDate = DateTime.Now; } else { newDetail.CompleteStatus = false; } var getCheckItem = Funs.DB.Technique_CheckItemSet.FirstOrDefault(x => x.SupCheckItem == this.drpSupCheckItemSet.SelectedValue && x.CheckItemName == newDetail.CheckContent); if (getCheckItem != null) { newDetail.CheckItem = getCheckItem.CheckItemSetId; } Check_CheckSpecialDetailService.AddCheckSpecialDetail(newDetail); if (type == Const.BtnSubmit) { if (newDetail.CompleteStatus == false) { detailLists.Add(newDetail); } } } if (detailLists.Count() > 0) { ////隐患整改单 var getDetail1 = detailLists.Where(x => x.HandleStep == "1"); if (getDetail1.Count() > 0) { var getUnitList = getDetail1.Select(x => x.UnitId).Distinct(); foreach (var unitItem in getUnitList) { Model.RectifyNoticesItem rectifyNotices = new Model.RectifyNoticesItem { ProjectId = checkSpecial.ProjectId, UnitId = unitItem, CompleteManId = this.CurrUser.UserId, CheckManNames = checkSpecial.PartInPersons, CheckManIds = checkSpecial.PartInPersonIds, CheckedDate = string.Format("{0:yyyy-MM-dd HH:mm:ss}", checkSpecial.CheckTime), States = Const.State_0, }; rectifyNotices.RectifyNoticesItemItem = new List <Model.RectifyNoticesItemItem>(); var getUnitDItem = getDetail1.Where(x => x.UnitId == unitItem); foreach (var item in getUnitDItem) { Model.RectifyNoticesItemItem newRItem = new Model.RectifyNoticesItemItem(); if (!string.IsNullOrEmpty(item.WorkArea)) { newRItem.WrongContent = item.WorkArea + item.Unqualified; } else { newRItem.WrongContent = item.Unqualified; } if (string.IsNullOrEmpty(rectifyNotices.CheckSpecialDetailId)) { rectifyNotices.CheckSpecialDetailId = item.CheckSpecialDetailId; } else { rectifyNotices.CheckSpecialDetailId += "," + item.CheckSpecialDetailId; } var getAtt = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == item.CheckSpecialDetailId); if (getAtt != null && !string.IsNullOrEmpty(getAtt.AttachUrl)) { newRItem.PhotoBeforeUrl = getAtt.AttachUrl; } rectifyNotices.RectifyNoticesItemItem.Add(newRItem); } APIRectifyNoticesService.SaveRectifyNotices(rectifyNotices); } } ///处罚单 var getDetail2 = detailLists.Where(x => x.HandleStep == "2"); if (getDetail2.Count() > 0) { var getUnitList = getDetail2.Select(x => x.UnitId).Distinct(); foreach (var unitItem in getUnitList) { Model.PunishNoticeItem punishNotice = new Model.PunishNoticeItem { ProjectId = checkSpecial.ProjectId, PunishNoticeDate = string.Format("{0:yyyy-MM-dd HH:mm:ss}", checkSpecial.CheckTime), UnitId = unitItem, CompileManId = this.CurrUser.UserId, PunishStates = Const.State_0, }; var getUnitDItem = getDetail2.Where(x => x.UnitId == unitItem); foreach (var item in getUnitDItem) { Model.RectifyNoticesItemItem newRItem = new Model.RectifyNoticesItemItem(); punishNotice.IncentiveReason += item.Unqualified; if (string.IsNullOrEmpty(punishNotice.CheckSpecialDetailId)) { punishNotice.CheckSpecialDetailId = item.CheckSpecialDetailId; } else { punishNotice.CheckSpecialDetailId += "," + item.CheckSpecialDetailId; } var getAtt = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == item.CheckSpecialDetailId); if (getAtt != null && !string.IsNullOrEmpty(getAtt.AttachUrl)) { punishNotice.PunishUrl = getAtt.AttachUrl; } } APIPunishNoticeService.SavePunishNotice(punishNotice); } } ///暂停令 var getDetail3 = detailLists.Where(x => x.HandleStep == "3"); if (getDetail3.Count() > 0) { var getUnitList = getDetail3.Select(x => x.UnitId).Distinct(); foreach (var unitItem in getUnitList) { Model.PauseNoticeItem pauseNotice = new Model.PauseNoticeItem { ProjectId = checkSpecial.ProjectId, UnitId = unitItem, PauseTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", checkSpecial.CheckTime), PauseStates = Const.State_0, }; var getUnitDItem = getDetail3.Where(x => x.UnitId == unitItem); foreach (var item in getUnitDItem) { Model.RectifyNoticesItemItem newRItem = new Model.RectifyNoticesItemItem(); pauseNotice.ThirdContent += item.Unqualified; if (string.IsNullOrEmpty(pauseNotice.ProjectPlace)) { pauseNotice.ProjectPlace = item.WorkArea; } else { if (!pauseNotice.ProjectPlace.Contains(item.WorkArea)) { pauseNotice.ProjectPlace += "," + item.WorkArea; } } if (string.IsNullOrEmpty(pauseNotice.CheckSpecialDetailId)) { pauseNotice.CheckSpecialDetailId = item.CheckSpecialDetailId; } else { pauseNotice.CheckSpecialDetailId += "," + item.CheckSpecialDetailId; } var getAtt = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == item.CheckSpecialDetailId); if (getAtt != null && !string.IsNullOrEmpty(getAtt.AttachUrl)) { pauseNotice.PauseNoticeAttachUrl = getAtt.AttachUrl; } } APIPauseNoticeService.SavePauseNotice(pauseNotice); } } } }