Beispiel #1
0
        /// <summary>
        /// 获取HSE日志信息
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="userId"></param>
        /// <param name="diaryDate"></param>
        /// <returns></returns>
        public static Model.HSEDiaryItem getHSEDiary(string projectId, string userId, string diaryDate)
        {
            DateTime?getDiaryDate = Funs.GetNewDateTime(diaryDate);

            Model.HSEDiaryItem getItem = new Model.HSEDiaryItem();
            if (getDiaryDate.HasValue && !string.IsNullOrEmpty(projectId) && !string.IsNullOrEmpty(userId))
            {
                var getFlowOperteList = ReturnFlowOperteList(projectId, userId, getDiaryDate.Value);
                getItem.ProjectId  = projectId;
                getItem.UserId     = userId;
                getItem.UserName   = UserService.GetUserNameByUserId(userId);
                getItem.DiaryDate  = diaryDate;
                getItem.HSEDiaryId = SQLHelper.GetNewID();
                getItem.Value1     = getValues1(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value2     = getValues2(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value3     = getValues3(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value4     = getValues4(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value5     = getValues5(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value6     = getValues6(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value7     = getValues7(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value8     = getValues8(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value9     = getValues9(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value10    = getValues10(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                var getInfo = Funs.DB.Project_HSEDiary.FirstOrDefault(x => x.UserId == userId && x.DiaryDate == getDiaryDate);
                if (getInfo != null)
                {
                    getItem.HSEDiaryId   = getInfo.HSEDiaryId;
                    getItem.DailySummary = getInfo.DailySummary;
                    getItem.TomorrowPlan = getInfo.TomorrowPlan;
                }
            }
            return(getItem);
        }
Beispiel #2
0
        /// <summary>
        /// 保存ReceiveFileManager
        /// </summary>
        /// <param name="newItem">来文信息</param>
        /// <returns></returns>
        public static void SaveReceiveFileManager(Model.ReceiveFileManagerItem newItem)
        {
            Model.SUBHSSEDB db     = Funs.DB;
            string          menuId = string.Empty;

            Model.InformationProject_ReceiveFileManager newReceiveFile = new Model.InformationProject_ReceiveFileManager
            {
                FileType             = newItem.FileType,
                ReceiveFileManagerId = newItem.ReceiveFileManagerId,
                ProjectId            = newItem.ProjectId,
                ReceiveFileCode      = newItem.ReceiveFileCode,
                ReceiveFileName      = newItem.ReceiveFileName,
                Version     = newItem.Version,
                FileCode    = newItem.FileCode,
                FilePageNum = newItem.FilePageNum,
                GetFileDate = Funs.GetNewDateTime(newItem.GetFileDate),
                MainContent = System.Web.HttpUtility.HtmlEncode(newItem.MainContent),
                UnitIds     = newItem.UnitIds,
                States      = Const.State_2,
            };
            if (!string.IsNullOrEmpty(newItem.FileUnitId))
            {
                newReceiveFile.FileUnitId = newItem.FileUnitId;
            }
            if (!string.IsNullOrEmpty(newItem.SendPersonId))
            {
                newReceiveFile.SendPersonId = newItem.SendPersonId;
            }
            if (newItem.States != "1")
            {
                newReceiveFile.States = Const.State_0;
            }

            var updateFile = Funs.DB.InformationProject_ReceiveFileManager.FirstOrDefault(x => x.ReceiveFileManagerId == newItem.ReceiveFileManagerId);

            if (updateFile == null)
            {
                newItem.ReceiveFileManagerId   = newReceiveFile.ReceiveFileManagerId = SQLHelper.GetNewID();
                newReceiveFile.ReceiveFileCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ReceiveFileManagerMenuId, newReceiveFile.ProjectId, null);
                ReceiveFileManagerService.AddReceiveFileManager(newReceiveFile);
            }
            else
            {
                ReceiveFileManagerService.UpdateReceiveFileManager(newReceiveFile);
            }
            if (newItem.States == "1")
            {
                CommonService.btnSaveData(newItem.ProjectId, Const.ReceiveFileManagerMenuId, newReceiveFile.ReceiveFileManagerId, newReceiveFile.SendPersonId, true, newReceiveFile.ReceiveFileName, "../ReceiveFileManager/ReceiveFileManagerView.aspx?ReceiveFileManagerId={0}");
            }

            ////保存附件
            if (!string.IsNullOrEmpty(newItem.FileAttachUrl))
            {
                UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newItem.FileAttachUrl, 10, null), newItem.FileAttachUrl, Const.ReceiveFileManagerMenuId, newItem.ReceiveFileManagerId);
            }
            else
            {
                CommonService.DeleteAttachFileById(Const.ReceiveFileManagerMenuId, newItem.ReceiveFileManagerId);
            }
        }
Beispiel #3
0
 /// <summary>
 /// 保存HSE日志
 /// </summary>
 /// <param name="item"></param>
 public static void SaveHSEDiary(Model.HSEDiaryItem item)
 {
     DeleteHSEDiary(item.HSEDiaryId);
     using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
     {
         Model.Project_HSEDiary newHSEDiary = new Model.Project_HSEDiary
         {
             HSEDiaryId   = item.HSEDiaryId,
             ProjectId    = item.ProjectId,
             DiaryDate    = Funs.GetNewDateTime(item.DiaryDate),
             UserId       = item.UserId,
             DailySummary = item.DailySummary,
             TomorrowPlan = item.TomorrowPlan,
             Value1       = item.Value1,
             Value2       = item.Value2,
             Value3       = item.Value3,
             Value4       = item.Value4,
             Value5       = item.Value5,
             Value6       = item.Value6,
             Value7       = item.Value7,
             Value8       = item.Value8,
             Value9       = item.Value9,
             Value10      = item.Value10,
         };
         if (string.IsNullOrEmpty(newHSEDiary.HSEDiaryId))
         {
             newHSEDiary.HSEDiaryId = SQLHelper.GetNewID();
         }
         db.Project_HSEDiary.InsertOnSubmit(newHSEDiary);
         db.SubmitChanges();
     }
 }
        /// <summary>
        /// 根据类型获取图型数据
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List <Model.ChartAnalysisItem> getChartAnalysisByType(string projectId, string type, string startDate, string endDate)
        {
            List <Model.ChartAnalysisItem> getDataLists = new List <Model.ChartAnalysisItem>();
            var getHazardRegister = from x in Funs.DB.HSSE_Hazard_HazardRegister
                                    where x.ProjectId == projectId
                                    select x;

            if (!string.IsNullOrEmpty(startDate))
            {
                var sDate = Funs.GetNewDateTime(startDate);
                getHazardRegister = getHazardRegister.Where(x => x.RegisterDate >= sDate);
            }
            if (!string.IsNullOrEmpty(endDate))
            {
                var eDate = Funs.GetNewDateTime(endDate);
                getHazardRegister = getHazardRegister.Where(x => x.RegisterDate <= eDate);
            }
            if (type == "1")
            {
                var getUnitlistIds = getHazardRegister.Select(x => x.ResponsibleUnit).Distinct().ToList();
                foreach (var unitItem in getUnitlistIds)
                {
                    var getUnitRegister             = getHazardRegister.Where(x => x.ResponsibleUnit == unitItem);
                    Model.ChartAnalysisItem newItem = new Model.ChartAnalysisItem
                    {
                        DataId       = unitItem,
                        Type         = type,
                        DataName     = UnitService.GetUnitCodeByUnitId(unitItem),
                        DataSumCount = getUnitRegister.Count(),
                        DataCount1   = getUnitRegister.Where(x => x.States == "2" || x.States == "3").Count(),
                    };

                    getDataLists.Add(newItem);
                }
            }
            else if (type == "2")
            {
                var getRegisterTypesIds = getHazardRegister.Select(x => x.RegisterTypesId).Distinct().ToList();
                foreach (var typeItem in getRegisterTypesIds)
                {
                    var getUnitRegister             = getHazardRegister.Where(x => x.RegisterTypesId == typeItem);
                    Model.ChartAnalysisItem newItem = new Model.ChartAnalysisItem
                    {
                        DataId       = typeItem,
                        Type         = type,
                        DataName     = Funs.DB.HSSE_Hazard_HazardRegisterTypes.First(y => y.RegisterTypesId == typeItem).RegisterTypesName,
                        DataSumCount = getUnitRegister.Count(),
                        DataCount1   = getUnitRegister.Where(x => x.States == "2" || x.States == "3").Count(),
                    };

                    getDataLists.Add(newItem);
                }
            }
            return(getDataLists);
        }
        /// <summary>
        /// 保存Check_IncentiveNotice
        /// </summary>
        /// <param name="newItem">奖励通知单</param>
        /// <returns></returns>
        public static void SaveIncentiveNotice(Model.IncentiveNoticeItem newItem)
        {
            Model.SUBHSSEDB             db = Funs.DB;
            Model.Check_IncentiveNotice newIncentiveNotice = new Model.Check_IncentiveNotice
            {
                IncentiveNoticeId   = newItem.IncentiveNoticeId,
                IncentiveNoticeCode = newItem.IncentiveNoticeCode,
                ProjectId           = newItem.ProjectId,
                IncentiveDate       = Funs.GetNewDateTime(newItem.IncentiveDate),
                UnitId         = newItem.UnitId,
                PersonId       = newItem.PersonId,
                RewardType     = newItem.RewardTypeId,
                BasicItem      = newItem.BasicItem,
                IncentiveMoney = newItem.IncentiveMoney,
                Currency       = newItem.Currency,
                TitleReward    = newItem.TitleReward,
                MattleReward   = newItem.MattleReward,
                SignMan        = newItem.SignManId,
                ApproveMan     = newItem.ApproveManId,
                FileContents   = System.Web.HttpUtility.HtmlEncode(newItem.FileContents),
                CompileMan     = newItem.CompileManId,
                AttachUrl      = newItem.AttachUrl,
                States         = Const.State_2,
            };

            if (!string.IsNullOrEmpty(newItem.TeamGroupId))
            {
                newIncentiveNotice.TeamGroupId = newItem.TeamGroupId;
            }

            if (newItem.States != "1")
            {
                newIncentiveNotice.States = Const.State_0;
            }

            var updateIncentiveNotice = Funs.DB.Check_IncentiveNotice.FirstOrDefault(x => x.IncentiveNoticeId == newItem.IncentiveNoticeId);

            if (updateIncentiveNotice == null)
            {
                newIncentiveNotice.CompileDate         = DateTime.Now;
                newIncentiveNotice.IncentiveNoticeId   = SQLHelper.GetNewID();
                newIncentiveNotice.IncentiveNoticeCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectIncentiveNoticeMenuId, newIncentiveNotice.ProjectId, newIncentiveNotice.UnitId);
                IncentiveNoticeService.AddIncentiveNotice(newIncentiveNotice);
            }
            else
            {
                IncentiveNoticeService.UpdateIncentiveNotice(newIncentiveNotice);
            }
            if (newIncentiveNotice.States == "1")
            {
                CommonService.btnSaveData(newIncentiveNotice.ProjectId, Const.ProjectIncentiveNoticeMenuId, newIncentiveNotice.IncentiveNoticeId, newIncentiveNotice.CompileMan, true, newIncentiveNotice.IncentiveNoticeCode, "../Check/IncentiveNoticeView.aspx?IncentiveNoticeId={0}");
            }
        }
Beispiel #6
0
        /// <summary>
        /// 保存QualityAudit_EquipmentQuality
        /// </summary>
        /// <param name="newItem">机具设备资质</param>
        /// <returns></returns>
        public static void SaveEquipmentQuality(Model.EquipmentQualityItem newItem)
        {
            Model.SUBHSSEDB db = Funs.DB;
            Model.QualityAudit_EquipmentQuality newEquipmentQuality = new Model.QualityAudit_EquipmentQuality
            {
                EquipmentQualityId   = newItem.EquipmentQualityId,
                ProjectId            = newItem.ProjectId,
                EquipmentQualityCode = newItem.EquipmentQualityCode,
                UnitId               = newItem.UnitId,
                SpecialEquipmentId   = newItem.SpecialEquipmentId,
                EquipmentQualityName = newItem.EquipmentQualityName,
                SizeModel            = newItem.SizeModel,
                FactoryCode          = newItem.FactoryCode,
                CertificateCode      = newItem.CertificateCode,
                CheckDate            = Funs.GetNewDateTime(newItem.CheckDate),
                LimitDate            = Funs.GetNewDateTimeOrNow(newItem.LimitDate),
                InDate               = Funs.GetNewDateTime(newItem.InDate),
                OutDate              = Funs.GetNewDateTime(newItem.OutDate),
                ApprovalPerson       = newItem.ApprovalPerson,
                CarNum               = newItem.CarNum,
                Remark               = newItem.Remark,
                CompileMan           = newItem.CompileManId,
            };

            var updateEquipmentQuality = Funs.DB.QualityAudit_EquipmentQuality.FirstOrDefault(x => x.EquipmentQualityId == newItem.EquipmentQualityId);

            if (updateEquipmentQuality == null)
            {
                newEquipmentQuality.CompileDate          = DateTime.Now;
                newEquipmentQuality.EquipmentQualityId   = SQLHelper.GetNewID();
                newEquipmentQuality.EquipmentQualityCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.EquipmentQualityMenuId, newEquipmentQuality.ProjectId, newEquipmentQuality.UnitId);
                EquipmentQualityService.AddEquipmentQuality(newEquipmentQuality);
            }
            else
            {
                EquipmentQualityService.UpdateEquipmentQuality(newEquipmentQuality);
            }
            if (!string.IsNullOrEmpty(newItem.AttachUrl))
            {
                ////保存附件
                UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newItem.AttachUrl, 10, null), newItem.AttachUrl, Const.EquipmentQualityMenuId, newEquipmentQuality.EquipmentQualityId);
            }
            else
            {
                CommonService.DeleteAttachFileById(newEquipmentQuality.EquipmentQualityId);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 获取HSE日志列表信息
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="userId"></param>
        /// <param name="diaryDate"></param>
        /// <returns></returns>
        public static List <Model.HSEDiaryItem> getHSEDiaryList(string projectId, string userId, string diaryDate)
        {
            DateTime?getDiaryDate = Funs.GetNewDateTime(diaryDate);
            var      getDataList  = from x in Funs.DB.Project_HSEDiary
                                    where x.ProjectId == projectId && (userId == null || x.UserId == userId) &&
                                    (diaryDate == null || x.DiaryDate == getDiaryDate)
                                    orderby x.DiaryDate descending
                                    select new Model.HSEDiaryItem
            {
                HSEDiaryId   = x.HSEDiaryId,
                ProjectId    = x.ProjectId,
                DiaryDate    = string.Format("{0:yyyy-MM-dd}", x.DiaryDate),
                UserId       = x.UserId,
                UserName     = Funs.DB.Sys_User.First(u => u.UserId == x.UserId).UserName,
                DailySummary = x.DailySummary,
                TomorrowPlan = x.TomorrowPlan,
            };

            return(getDataList.ToList());
        }
Beispiel #8
0
        /// <summary>
        /// 获取HSE管理月报列表信息
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="reportMonths"></param>
        /// <returns></returns>
        public static List <Model.HSEMonthItem> getHSEMonthList(string projectId, string reportMonths)
        {
            DateTime?getMonthDate = Funs.GetNewDateTime(reportMonths);
            var      getDataList  = from x in Funs.DB.Manager_MonthReport
                                    where x.ProjectId == projectId &&
                                    (!getMonthDate.HasValue || x.ReportMonths == getMonthDate)
                                    orderby x.ReportMonths descending
                                    select new Model.HSEMonthItem
            {
                MonthReportId   = x.MonthReportId,
                ProjectId       = x.ProjectId,
                ReportManId     = x.ReportMan,
                ReportManName   = Funs.DB.Sys_User.First(u => u.UserId == x.ReportMan).UserName,
                ReportMonths    = string.Format("{0:yyyy-MM}", x.ReportMonths),
                ReportStartDate = string.Format("{0:yyyy-MM}", x.MonthReportStartDate),
                ReportEndDate   = string.Format("{0:yyyy-MM}", x.MonthReportDate),
                AllManhoursData = x.AllManhoursData,
            };

            return(getDataList.ToList());
        }
Beispiel #9
0
        /// <summary>
        /// 插入培训记录 2
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="arr"></param>
        public static bool AddTrainRecord(string projectId, JArray arr, Model.Sys_User user)
        {
            Model.SUBHSSEDB db   = Funs.DB;
            bool            isOk = true;

            try
            {
                foreach (var item in arr)
                {
                    string fromRecordId = item["ID"].ToString();
                    string trainTypeId  = null; ////培训类型
                    var    getTrainType = db.Base_TrainType.FirstOrDefault(x => x.TrainTypeName == item["TrainType"].ToString());
                    if (getTrainType != null)
                    {
                        trainTypeId = getTrainType.TrainTypeId;
                    }
                    string unitId = null;
                    if (!string.IsNullOrEmpty(item["TrainDepart"].ToString()))
                    {
                        var lists = Funs.GetStrListByStr(item["TrainDepart"].ToString(), ',');
                        if (lists.Count() > 0)
                        {
                            foreach (var itemList in lists)
                            {
                                var getUnit = db.Base_Unit.FirstOrDefault(x => x.UnitName == itemList);
                                if (getUnit != null)
                                {
                                    if (string.IsNullOrEmpty(unitId))
                                    {
                                        unitId = getUnit.UnitId;
                                    }
                                    else
                                    {
                                        unitId += ("," + getUnit.UnitId);
                                    }
                                }
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(unitId) && !string.IsNullOrEmpty(fromRecordId))
                    {
                        Model.EduTrain_TrainRecord newTrainRecord = new Model.EduTrain_TrainRecord
                        {
                            FromRecordId = fromRecordId,

                            ProjectId      = projectId,
                            TrainTitle     = item["RecordName"].ToString(),
                            TrainContent   = item["TrainContent"].ToString(),
                            TrainStartDate = Funs.GetNewDateTime(item["TrainStartDate"].ToString()),
                            TrainEndDate   = Funs.GetNewDateTime(item["TrainEndDate"].ToString()),
                            TeachHour      = Funs.GetNewDecimalOrZero(item["TrainPeriod"].ToString()),
                            TeachMan       = item["TrainPrincipal"].ToString(),
                            Remark         = item["TrainDescript"].ToString(),
                            TrainTypeId    = trainTypeId,
                            UnitIds        = unitId,
                            States         = Const.State_0,
                            CompileMan     = item["CreateUser"].ToString(),
                            TrainPersonNum = Funs.GetNewInt(item["PersonCount"].ToString()),
                        };

                        newTrainRecord.TrainingCode = Funs.GetNewFileName(newTrainRecord.TrainStartDate);
                        var getTrainRecord = Funs.DB.EduTrain_TrainRecord.FirstOrDefault(x => x.FromRecordId == fromRecordId);
                        if (getTrainRecord == null)
                        {
                            newTrainRecord.TrainingId = SQLHelper.GetNewID(typeof(Model.EduTrain_TrainRecord));
                            EduTrain_TrainRecordService.AddTraining(newTrainRecord);
                            BLL.LogService.AddSys_Log(user, newTrainRecord.TrainingCode, newTrainRecord.TrainingId, BLL.Const.ProjectTrainRecordMenuId, BLL.Const.BtnAdd);
                        }
                        else
                        {
                            getTrainRecord.TrainingCode   = newTrainRecord.TrainingCode;
                            getTrainRecord.TrainTitle     = newTrainRecord.TrainTitle;
                            getTrainRecord.TrainContent   = newTrainRecord.TrainContent;
                            getTrainRecord.UnitIds        = newTrainRecord.UnitIds;
                            getTrainRecord.TrainStartDate = newTrainRecord.TrainStartDate;
                            if (newTrainRecord.TrainEndDate.HasValue)
                            {
                                getTrainRecord.TrainEndDate = newTrainRecord.TrainEndDate;
                            }
                            else
                            {
                                getTrainRecord.TrainEndDate = newTrainRecord.TrainStartDate;
                            }
                            getTrainRecord.TeachHour    = newTrainRecord.TeachHour;
                            getTrainRecord.TeachMan     = newTrainRecord.TeachMan;
                            getTrainRecord.TeachAddress = newTrainRecord.TeachAddress;

                            getTrainRecord.Remark = newTrainRecord.Remark;
                            EduTrain_TrainRecordService.UpdateTraining(getTrainRecord);
                            BLL.LogService.AddSys_Log(user, getTrainRecord.TrainingCode, getTrainRecord.TrainingId, BLL.Const.ProjectTrainRecordMenuId, BLL.Const.BtnModify);
                        }
                    }
                    else
                    {
                        isOk = false;
                    }
                }
            }
            catch (Exception ex)
            {
                isOk = false;
                ErrLogInfo.WriteLog(string.Empty, ex);
            }
            return(isOk);
        }
Beispiel #10
0
        /// <summary>
        /// 插入人员信息 0
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="arr"></param>
        public static bool AddPerson(string projectId, JArray arr, Model.Sys_User user)
        {
            Model.SUBHSSEDB db   = Funs.DB;
            bool            isOk = true;

            try
            {
                foreach (var item in arr)
                {
                    ////单位
                    string unitId  = null;
                    var    getUnit = db.Base_Unit.FirstOrDefault(x => x.FromUnitId == item["DepartId"].ToString());
                    if (getUnit != null)
                    {
                        unitId = getUnit.UnitId;
                    }

                    ///区域
                    string workAreaId  = null;
                    var    getWorkArea = db.ProjectData_WorkArea.FirstOrDefault(x => x.ProjectId == projectId && x.WorkAreaName == item["BuildArea"].ToString());
                    if (getWorkArea != null)
                    {
                        workAreaId = getWorkArea.WorkAreaId;
                    }
                    ///岗位
                    string workPostId  = null;
                    var    getWorkPost = db.Base_WorkPost.FirstOrDefault(x => x.WorkPostName == item["Station"].ToString());
                    if (getWorkPost != null)
                    {
                        workPostId = getWorkPost.WorkPostId;
                    }
                    DateTime?inTime  = Funs.GetNewDateTime(item["EntranceDate"].ToString());
                    DateTime?outTime = Funs.GetNewDateTime(item["LeaveDate"].ToString());
                    if (outTime < inTime)
                    {
                        outTime = null;
                    }
                    string IdentifyID = item["IdentifyID"].ToString();
                    if (!string.IsNullOrEmpty(IdentifyID))
                    {
                        Model.SitePerson_Person newPerson = new Model.SitePerson_Person
                        {
                            FromPersonId = item["ID"].ToString(),
                            CardNo       = item["JobNumber"].ToString(),
                            PersonName   = item["Name"].ToString(),
                            Sex          = item["Sex"].ToString(),
                            IdentityCard = IdentifyID,
                            Address      = item["Address"].ToString(),
                            ProjectId    = projectId,
                            UnitId       = unitId,   /////映射取值
                            //TeamGroupId = person.TeamGroupId,
                            WorkAreaId = workAreaId, /////关联映射取值
                            WorkPostId = workPostId, /////关联映射取值
                            InTime     = inTime,
                            OutTime    = outTime,
                            Telephone  = item["ContactTel"].ToString(),
                            IsUsed     = true,
                            IsCardUsed = true,
                        };

                        var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.ProjectId == projectId && x.IdentityCard == IdentifyID);
                        if (getPerson == null)
                        {
                            newPerson.PersonId = SQLHelper.GetNewID(typeof(Model.SitePerson_Person));
                            PersonService.AddPerson(newPerson);
                            BLL.LogService.AddSys_Log(user, newPerson.PersonName, newPerson.PersonId, BLL.Const.PersonListMenuId, BLL.Const.BtnAdd);
                        }
                        else
                        {
                            getPerson.FromPersonId = newPerson.FromPersonId;
                            getPerson.InTime       = newPerson.InTime;
                            getPerson.OutTime      = newPerson.OutTime;
                            getPerson.Telephone    = newPerson.Telephone;
                            if (!string.IsNullOrEmpty(unitId))
                            {
                                getPerson.UnitId = unitId;
                            }
                            if (!string.IsNullOrEmpty(workAreaId))
                            {
                                getPerson.WorkAreaId = workAreaId;
                            }
                            if (!string.IsNullOrEmpty(workPostId))
                            {
                                getPerson.WorkPostId = workPostId;
                            }
                            PersonService.UpdatePerson(getPerson);
                            BLL.LogService.AddSys_Log(user, getPerson.PersonName, getPerson.PersonId, BLL.Const.PersonListMenuId, BLL.Const.BtnModify);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isOk = false;
                ErrLogInfo.WriteLog(string.Empty, ex);
            }

            return(isOk);
        }
Beispiel #11
0
        /// <summary>
        /// 保存TestPlan
        /// </summary>
        /// <param name="getTestPlan">考试计划记录</param>
        public static string SaveTestPlan(Model.TestPlanItem getTestPlan)
        {
            string alterStr = string.Empty;

            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                Model.Training_TestPlan newTestPlan = new Model.Training_TestPlan
                {
                    TestPlanId = getTestPlan.TestPlanId,
                    ProjectId  = getTestPlan.ProjectId,
                    PlanCode   = getTestPlan.TestPlanCode,
                    PlanName   = getTestPlan.TestPlanName,
                    PlanManId  = getTestPlan.TestPlanManId,
                    //PlanDate= getTestPlan.TestPlanDate,
                    TestStartTime = Funs.GetNewDateTimeOrNow(getTestPlan.TestStartTime),
                    TestEndTime   = Funs.GetNewDateTimeOrNow(getTestPlan.TestEndTime),
                    Duration      = getTestPlan.Duration,
                    SValue        = getTestPlan.SValue,
                    MValue        = getTestPlan.MValue,
                    JValue        = getTestPlan.JValue,
                    TotalScore    = getTestPlan.TotalScore,
                    QuestionCount = getTestPlan.QuestionCount,
                    TestPalce     = getTestPlan.TestPalce,
                    UnitIds       = getTestPlan.UnitIds,
                    WorkPostIds   = getTestPlan.WorkPostIds,
                    States        = getTestPlan.States,
                    PlanDate      = DateTime.Now,
                };

                if (!string.IsNullOrEmpty(getTestPlan.TrainingPlanId))
                {
                    newTestPlan.PlanId = getTestPlan.TrainingPlanId;
                }
                var isUpdate = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestPlan.TestPlanId);
                if (isUpdate == null)
                {
                    string unitId = string.Empty;
                    var    user   = db.Sys_User.FirstOrDefault(e => e.UserId == newTestPlan.PlanManId);
                    if (user != null)
                    {
                        unitId = user.UnitId;
                    }
                    newTestPlan.PlanCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, unitId);
                    if (string.IsNullOrEmpty(newTestPlan.TestPlanId))
                    {
                        newTestPlan.TestPlanId = SQLHelper.GetNewID();
                    }

                    db.Training_TestPlan.InsertOnSubmit(newTestPlan);
                    db.SubmitChanges();

                    CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, null, newTestPlan.TestPlanId, newTestPlan.PlanDate);
                }
                else
                {
                    isUpdate.States = newTestPlan.States;
                    if (isUpdate.States == "0" || isUpdate.States == "1")
                    {
                        isUpdate.PlanName      = newTestPlan.PlanName;
                        isUpdate.PlanManId     = newTestPlan.PlanManId;
                        isUpdate.PlanDate      = newTestPlan.PlanDate;
                        isUpdate.TestStartTime = newTestPlan.TestStartTime;
                        isUpdate.TestEndTime   = newTestPlan.TestEndTime;
                        isUpdate.Duration      = newTestPlan.Duration;
                        isUpdate.TotalScore    = newTestPlan.TotalScore;
                        isUpdate.QuestionCount = newTestPlan.QuestionCount;
                        isUpdate.TestPalce     = newTestPlan.TestPalce;
                        isUpdate.UnitIds       = newTestPlan.UnitIds;
                        isUpdate.WorkPostIds   = newTestPlan.WorkPostIds;
                        ////删除 考生记录
                        var deleteRecords = from x in db.Training_TestRecord
                                            where x.TestPlanId == isUpdate.TestPlanId
                                            select x;
                        if (deleteRecords.Count() > 0)
                        {
                            foreach (var item in deleteRecords)
                            {
                                var testRecordItem = from x in db.Training_TestRecordItem
                                                     where x.TestRecordId == item.TestRecordId
                                                     select x;
                                if (testRecordItem.Count() > 0)
                                {
                                    db.Training_TestRecordItem.DeleteAllOnSubmit(testRecordItem);
                                    db.SubmitChanges();
                                }
                            }

                            db.Training_TestRecord.DeleteAllOnSubmit(deleteRecords);
                            db.SubmitChanges();
                        }

                        ////删除 考试题目类型
                        var deleteTestPlanTrainings = from x in db.Training_TestPlanTraining where x.TestPlanId == isUpdate.TestPlanId select x;
                        if (deleteTestPlanTrainings.Count() > 0)
                        {
                            db.Training_TestPlanTraining.DeleteAllOnSubmit(deleteTestPlanTrainings);
                            db.SubmitChanges();
                        }
                    }
                    else if (isUpdate.States == "3") ////考试状态3时 更新培训计划状态 把培训计划写入培训记录中
                    {
                        DateTime?endTime = Funs.GetNewDateTime(getTestPlan.TestEndTime);
                        ////判断是否有未考完的考生
                        var getTrainingTestRecords = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == isUpdate.TestPlanId &&
                                                                                           (!x.TestStartTime.HasValue || ((!x.TestEndTime.HasValue || !x.TestScores.HasValue) && x.TestStartTime.Value.AddMinutes(isUpdate.Duration) >= DateTime.Now)));
                        if (getTrainingTestRecords != null && endTime.HasValue && endTime.Value.AddMinutes(isUpdate.Duration) < DateTime.Now)
                        {
                            alterStr        = "当前存在未交卷考生,不能提前结束考试!";
                            isUpdate.States = "2";
                        }
                        else
                        {
                            SubmitTest(isUpdate);
                        }
                    }
                    else if (newTestPlan.States == "2") ////开始考试 只更新考试计划状态为考试中。
                    {
                        if (isUpdate.TestStartTime > DateTime.Now)
                        {
                            isUpdate.States = "1";
                            alterStr        = "未到考试扫码开始时间,不能开始考试!";
                        }
                    }
                    if (string.IsNullOrEmpty(alterStr))
                    {
                        db.SubmitChanges();
                    }
                }

                if (newTestPlan.States == "0" || newTestPlan.States == "1")
                {
                    if (getTestPlan.TestRecordItems.Count() > 0)
                    {
                        ////新增考试人员明细
                        foreach (var item in getTestPlan.TestRecordItems)
                        {
                            var person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == item.TestManId);
                            if (person != null)
                            {
                                Model.Training_TestRecord newTrainDetail = new Model.Training_TestRecord
                                {
                                    TestRecordId = SQLHelper.GetNewID(),
                                    ProjectId    = newTestPlan.ProjectId,
                                    TestPlanId   = newTestPlan.TestPlanId,
                                    TestManId    = item.TestManId,
                                    TestType     = item.TestType,
                                    Duration     = newTestPlan.Duration,
                                };
                                db.Training_TestRecord.InsertOnSubmit(newTrainDetail);
                                db.SubmitChanges();
                            }
                        }
                    }
                    if (getTestPlan.TestPlanTrainingItems.Count() > 0)
                    {
                        foreach (var item in getTestPlan.TestPlanTrainingItems)
                        {
                            var trainingType = TestTrainingService.GetTestTrainingById(item.TrainingTypeId);
                            if (trainingType != null)
                            {
                                Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining
                                {
                                    TestPlanTrainingId = SQLHelper.GetNewID(),
                                    TestPlanId         = newTestPlan.TestPlanId,
                                    TrainingId         = item.TrainingTypeId,
                                    TestType1Count     = item.TestType1Count,
                                    TestType2Count     = item.TestType2Count,
                                    TestType3Count     = item.TestType3Count,
                                };

                                db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem);
                                db.SubmitChanges();
                            }
                        }
                    }
                }
            }
            return(alterStr);
        }
Beispiel #12
0
        /// <summary>
        /// 增加人员信息
        /// </summary>
        /// <param name="person">人员实体</param>
        public static void AddPerson(Model.SitePerson_Person person)
        {
            Model.SUBHSSEDB         db        = Funs.DB;
            Model.SitePerson_Person newPerson = new Model.SitePerson_Person
            {
                PersonId     = person.PersonId,
                CardNo       = person.CardNo,
                PersonName   = person.PersonName,
                Sex          = person.Sex,
                IdentityCard = person.IdentityCard,
                Address      = person.Address,
                ProjectId    = person.ProjectId,
                UnitId       = person.UnitId,
                TeamGroupId  = person.TeamGroupId,
                WorkAreaId   = person.WorkAreaId,
                WorkPostId   = person.WorkPostId,
                OutTime      = person.OutTime,
                OutResult    = person.OutResult,
                Telephone    = person.Telephone,
                PositionId   = person.PositionId,
                PostTitleId  = person.PostTitleId,
                PhotoUrl     = person.PhotoUrl,
                IsUsed       = person.IsUsed,
                IsCardUsed   = person.IsCardUsed,
                DepartId     = person.DepartId,
                FromPersonId = person.FromPersonId,
                Password     = GetPersonPassWord(person.IdentityCard),
                AuditorId    = person.AuditorId,
                AuditorDate  = person.AuditorDate,
                IsForeign    = person.IsForeign,
                IsOutside    = person.IsOutside,
                Isprint      = "0",
            };

            if (person.InTime.HasValue)
            {
                newPerson.InTime = person.InTime;
            }
            else
            {
                newPerson.InTime = Funs.GetNewDateTime(DateTime.Now.ToShortDateString());
            }

            db.SitePerson_Person.InsertOnSubmit(newPerson);
            db.SubmitChanges();
            if (!CommonService.GetIsThisUnit(Const.UnitId_SEDIN))
            {
                ///写入人员出入场时间表
                Model.SitePerson_PersonInOut newPersonInOut = new Model.SitePerson_PersonInOut
                {
                    ProjectId = person.ProjectId,
                    UnitId    = person.UnitId,
                    PersonId  = person.PersonId
                };

                if (newPerson.InTime.HasValue)
                {
                    newPersonInOut.ChangeTime = person.InTime;
                    newPersonInOut.IsIn       = true;
                    BLL.PersonInOutService.AddPersonInOut(newPersonInOut);
                }

                if (newPerson.OutTime.HasValue)
                {
                    newPersonInOut.ChangeTime = person.OutTime;
                    newPersonInOut.IsIn       = false;
                    BLL.PersonInOutService.AddPersonInOut(newPersonInOut);
                }
            }
            ////增加一条编码记录
            BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.PersonListMenuId, person.ProjectId, person.UnitId, person.PersonId, person.InTime);
        }
Beispiel #13
0
        /// <summary>
        /// 生成安全资料计划总表 方法
        /// </summary>
        /// <param name="project"></param>
        /// <param name="safetyDataEnd"></param>
        public static void GetSafetyDataPlanMethod(Model.Base_Project project, List <Model.SafetyData_SafetyData> safetyDataEnd, DateTime?startTime, DateTime?endTime)
        {
            ////第一步 判断是否存在此项目的计划表
            ////第二步 不存在增加这个项目时间范围内的 存在取不存在时间段
            ////第三步 项目时间 是否为空? 现在默认都不能为空
            Model.SUBHSSEDB db         = Funs.DB;
            string          projectId  = project.ProjectId;
            DateTime        startDatep = project.StartDate.HasValue ? project.StartDate.Value : System.DateTime.Now;

            if (startTime.HasValue)
            {
                startDatep = startTime.Value;
            }
            DateTime startDate = startDatep;
            DateTime endDate   = project.EndDate.HasValue ? project.EndDate.Value : System.DateTime.Now.AddMonths(6);

            if (endTime.HasValue)
            {
                endDate = endTime.Value;
            }
            DeleteSafetyDataPlanByProjectDateId(projectId, endDate);   ///删除竣工后的考核计划
            foreach (var item in safetyDataEnd)
            {
                var safetyDataPlan = db.SafetyData_SafetyDataPlan.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.SafetyDataId == item.SafetyDataId && (x.IsManual == null || x.IsManual == false));
                if (safetyDataPlan != null)
                {
                    ///取结束时间 最大值作为开始时间
                    DateTime maxEndDate = Funs.DB.SafetyData_SafetyDataPlan.Where(x => x.ProjectId == projectId && x.RealEndDate.HasValue && x.SafetyDataId == item.SafetyDataId).Select(x => x.RealEndDate.Value).Max();
                    if (endDate > maxEndDate) ////如果计划单最大时间小于项目结束时间 则追加时间 否则删去
                    {
                        startDate = maxEndDate;
                    }
                    else
                    { ///项目提前结束 则删除计划时间
                        var delSafetyDataPlan = from x in db.SafetyData_SafetyDataPlan where x.RealEndDate > endDate && x.SafetyDataId == item.SafetyDataId select x;
                        if (delSafetyDataPlan.Count() > 0)
                        {
                            db.SafetyData_SafetyDataPlan.DeleteAllOnSubmit(delSafetyDataPlan);
                        }
                    }
                }
                ////算出 开始、结束时间跨度 然后循环增加一个月 并把在此时间段的 考核项写入计划表
                for (int i = 0; startDate.AddMonths(i) <= endDate; i++)
                {
                    Model.SafetyData_SafetyDataPlan newSafetyDataPlan = new Model.SafetyData_SafetyDataPlan
                    {
                        SafetyDataPlanId = SQLHelper.GetNewID(typeof(Model.SafetyData_SafetyDataPlan)),
                        ProjectId        = projectId,
                        SafetyDataId     = item.SafetyDataId,
                        Score            = item.Score,
                        ShouldScore      = item.Score,
                        Remark           = item.Remark,
                    };

                    int monthValue = 0;  ///设置月数
                    if (item.CheckTypeValue1.HasValue)
                    {
                        monthValue = item.CheckTypeValue1.Value;
                    }

                    int dateValue = 1;  ///设置天
                    if (item.CheckTypeValue2.HasValue)
                    {
                        dateValue = item.CheckTypeValue2.Value;
                        if (dateValue > 30)
                        {
                            dateValue = 30;
                        }
                    }

                    ////TODO:通过判断是月报、季报、定时报等情况 是否落在 当前时间范围内 写入到计划总表
                    if (item.CheckType == BLL.Const.SafetyDataCheckType_1) /// 月报
                    {
                        if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28)
                        {
                            dateValue = 28;
                        }
                        DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i + monthValue).Year + "-" + startDate.AddMonths(i + monthValue).Month + "-" + dateValue);
                        if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep)
                        {
                            newSafetyDataPlan.CheckDate     = checkDate;
                            newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-1); ///月报开始日期
                            newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1);
                            newSafetyDataPlan.RealEndDate   = newSafetyDataPlan.RealStartDate.Value.AddMonths(1).AddDays(-1);
                        }
                    }
                    else if (item.CheckType == BLL.Const.SafetyDataCheckType_2)                                                                                               /// 季报
                    {
                        int month = startDate.AddMonths(i).Month;                                                                                                             ///当前月份
                        if ((month == 3 + monthValue) || (month == 6 + monthValue) || (month == 9 + monthValue) || (month == monthValue) || (month == 12 && monthValue == 0)) ///考核季度时间
                        {
                            if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28)
                            {
                                dateValue = 28;
                            }
                            DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue);
                            if ((month == monthValue) && monthValue != 0)
                            {
                                checkDate = checkDate.Value.AddYears(1);
                            }

                            if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep)
                            {
                                newSafetyDataPlan.CheckDate     = checkDate;
                                newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-3); ///开始日期
                                newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1);
                                newSafetyDataPlan.RealEndDate   = newSafetyDataPlan.RealStartDate.Value.AddMonths(3).AddDays(-1);
                            }
                        }
                    }
                    else if (item.CheckType == BLL.Const.SafetyDataCheckType_3) /// 定时
                    {
                        if (startDate.AddMonths(i).Month == monthValue)         ///定时月份
                        {
                            if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28)
                            {
                                dateValue = 28;
                            }
                            DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue);
                            if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep)
                            {
                                newSafetyDataPlan.CheckDate     = checkDate;
                                newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-12); ///开始日期
                                newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1);
                                newSafetyDataPlan.RealEndDate   = checkDate.Value;
                            }
                        }
                    }
                    else if (item.CheckType == BLL.Const.SafetyDataCheckType_4) /// 开工后报
                    {
                        DateTime?checkDate = startDate.AddMonths(i);
                        if (checkDate.HasValue && checkDate <= endDate && BLL.Funs.CompareMonths(startDatep, checkDate.Value) == monthValue && checkDate >= startDatep)
                        {
                            newSafetyDataPlan.CheckDate     = checkDate;
                            newSafetyDataPlan.RealStartDate = startDate; ///开始日期
                            newSafetyDataPlan.RealEndDate   = checkDate.Value;
                        }
                    }
                    else if (item.CheckType == BLL.Const.SafetyDataCheckType_5) /// 半年报
                    {
                        if (startDate.AddMonths(i).Month == monthValue || startDate.AddMonths(i).Month == monthValue + 6)
                        {
                            if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28)
                            {
                                dateValue = 28;
                            }
                            DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue);
                            if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep)
                            {
                                newSafetyDataPlan.CheckDate     = checkDate;
                                newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-6); ///开始日期
                                newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1);
                                newSafetyDataPlan.RealEndDate   = newSafetyDataPlan.RealStartDate.Value.AddMonths(6).AddDays(-1);
                            }
                        }
                    }
                    else  /// 其他
                    {
                        if (monthValue > 0 && startDate.AddMonths(i).Year == System.DateTime.Now.Year && startDate.AddMonths(i).Month == monthValue)
                        {
                            if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28)
                            {
                                dateValue = 28;
                            }
                            DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue);
                            if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep)
                            {
                                newSafetyDataPlan.CheckDate     = checkDate;
                                newSafetyDataPlan.RealStartDate = startDate; ///开始日期
                                newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1);
                                newSafetyDataPlan.RealEndDate   = checkDate.Value;
                            }
                        }
                    }
                    if (newSafetyDataPlan.RealEndDate.HasValue)
                    {
                        newSafetyDataPlan.ReminderDate = newSafetyDataPlan.CheckDate.Value.AddDays(-7);
                        AddSafetyDataPlan(newSafetyDataPlan);
                    }
                }
            }
        }
Beispiel #14
0
        /// <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);
            }
        }
Beispiel #15
0
        /// <summary>
        /// 根据安全工作总结Id获取安全工作总结信息
        /// </summary>
        /// <param name="ManagerTotalId"></param>
        /// <returns></returns>
        public static List <Model.SpManagerTotalMonthSafetyDataDItem> GetManager_SafetyDataD(string date)
        {
            List <Model.SpManagerTotalMonthSafetyDataDItem> reportSafetyDataD = new List <Model.SpManagerTotalMonthSafetyDataDItem>();
            DateTime?monthTime   = Funs.GetNewDateTime(date);
            var      projectList = BLL.ProjectService.GetTotalMonthProjectWorkList(monthTime);
            int      sortIndex   = 1;

            Model.SpManagerTotalMonthSafetyDataDItem sunmPart = new Model.SpManagerTotalMonthSafetyDataDItem
            {
                ID                   = SQLHelper.GetNewID(typeof(Model.Manager_ManagerTotalMonth)),
                ProjectName          = "合计",
                ThisUnitPersonNum    = "0",
                ThisUnitHSEPersonNum = "0",
                SubUnitPersonNum     = "0",
                SubUnitHSEPersonNum  = "0",
                ManHours             = "0",
                HSEManHours          = "0"
            };

            foreach (var projectItem in projectList)
            {
                Model.SpManagerTotalMonthSafetyDataDItem part = new Model.SpManagerTotalMonthSafetyDataDItem
                {
                    ID                   = projectItem.ProjectId,
                    ProjectName          = projectItem.ProjectName,
                    SortIndex            = sortIndex,
                    ThisUnitPersonNum    = "/",
                    ThisUnitHSEPersonNum = "/",
                    SubUnitPersonNum     = "/",
                    SubUnitHSEPersonNum  = "/",
                    ManHours             = "/",
                    HSEManHours          = "/"
                };
                var projectMontReportD = Funs.DB.Manager_MonthReportD.FirstOrDefault(x => x.ProjectId == projectItem.ProjectId && (x.Months.Value.Year == monthTime.Value.Year && x.Months.Value.Month == monthTime.Value.Month));
                if (projectMontReportD != null)
                {
                    var safetyDataD = Funs.DB.Manager_SafetyDataD.FirstOrDefault(x => x.MonthReportId == projectMontReportD.MonthReportId);
                    if (safetyDataD != null)
                    {
                        part.ThisUnitPersonNum    = safetyDataD.ThisUnitPersonNum.ToString();
                        part.ThisUnitHSEPersonNum = safetyDataD.ThisUnitHSEPersonNum.ToString();
                        part.SubUnitPersonNum     = safetyDataD.SubUnitPersonNum.ToString();
                        part.SubUnitHSEPersonNum  = safetyDataD.SubUnitHSEPersonNum.ToString();
                        part.ManHours             = safetyDataD.ManHours.ToString();
                        part.HSEManHours          = safetyDataD.HSEManHours.ToString();

                        sunmPart.ThisUnitPersonNum    = (Funs.GetNewIntOrZero(sunmPart.ThisUnitPersonNum) + Funs.GetNewIntOrZero(part.ThisUnitPersonNum)).ToString();
                        sunmPart.ThisUnitHSEPersonNum = (Funs.GetNewIntOrZero(sunmPart.ThisUnitHSEPersonNum) + Funs.GetNewIntOrZero(part.ThisUnitHSEPersonNum)).ToString();
                        sunmPart.SubUnitPersonNum     = (Funs.GetNewIntOrZero(sunmPart.SubUnitPersonNum) + Funs.GetNewIntOrZero(part.SubUnitPersonNum)).ToString();
                        sunmPart.SubUnitHSEPersonNum  = (Funs.GetNewIntOrZero(sunmPart.SubUnitHSEPersonNum) + Funs.GetNewIntOrZero(part.SubUnitHSEPersonNum)).ToString();
                        sunmPart.ManHours             = (Funs.GetNewIntOrZero(sunmPart.ManHours) + Funs.GetNewIntOrZero(part.ManHours)).ToString();
                        sunmPart.HSEManHours          = (Funs.GetNewIntOrZero(sunmPart.HSEManHours) + Funs.GetNewIntOrZero(part.HSEManHours)).ToString();
                    }
                }
                reportSafetyDataD.Add(part);
                sortIndex++;
            }
            sunmPart.SortIndex = projectList.Count() + 1;

            reportSafetyDataD.Add(sunmPart);
            return(reportSafetyDataD);
        }
Beispiel #16
0
        /// <summary>
        /// 保存Meeting
        /// </summary>
        /// <param name="meeting">会议信息</param>
        /// <returns></returns>
        public static void SaveMeeting(Model.MeetingItem meeting)
        {
            Model.SUBHSSEDB db     = Funs.DB;
            string          menuId = string.Empty;

            if (meeting.MeetingType == "C")
            {
                Model.Meeting_ClassMeeting newClassMeeting = new Model.Meeting_ClassMeeting
                {
                    ClassMeetingId       = meeting.MeetingId,
                    ProjectId            = meeting.ProjectId,
                    UnitId               = meeting.UnitId == "" ? null : meeting.UnitId,
                    TeamGroupId          = meeting.TeamGroupId == "" ? null : meeting.TeamGroupId,
                    ClassMeetingCode     = meeting.MeetingCode,
                    ClassMeetingName     = meeting.MeetingName,
                    ClassMeetingDate     = Funs.GetNewDateTime(meeting.MeetingDate),
                    ClassMeetingContents = meeting.MeetingContents,
                    CompileMan           = meeting.CompileManId,
                    MeetingPlace         = meeting.MeetingPlace,
                    MeetingHours         = meeting.MeetingHours,
                    MeetingHostMan       = meeting.MeetingHostMan,
                    AttentPerson         = meeting.AttentPerson,
                    AttentPersonNum      = meeting.AttentPersonNum,
                    States               = Const.State_2,
                };

                if (meeting.States != "1")
                {
                    newClassMeeting.States = Const.State_0;
                }

                var updateMeet = Funs.DB.Meeting_ClassMeeting.FirstOrDefault(x => x.ClassMeetingId == meeting.MeetingId);
                if (updateMeet == null)
                {
                    newClassMeeting.CompileDate      = DateTime.Now;
                    meeting.MeetingId                = newClassMeeting.ClassMeetingId = SQLHelper.GetNewID();
                    newClassMeeting.ClassMeetingCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectClassMeetingMenuId, newClassMeeting.ProjectId, null);
                    ClassMeetingService.AddClassMeeting(newClassMeeting);
                }
                else
                {
                    ClassMeetingService.UpdateClassMeeting(newClassMeeting);
                }
                if (meeting.States == "1")
                {
                    CommonService.btnSaveData(meeting.ProjectId, Const.ProjectClassMeetingMenuId, newClassMeeting.ClassMeetingId, newClassMeeting.CompileMan, true, newClassMeeting.ClassMeetingName, "../Meeting/ClassMeetingView.aspx?ClassMeetingId={0}");
                }

                menuId = Const.ProjectClassMeetingMenuId;
            }
            else if (meeting.MeetingType == "W")
            {
                Model.Meeting_WeekMeeting newWeekMeeting = new Model.Meeting_WeekMeeting
                {
                    WeekMeetingId       = meeting.MeetingId,
                    ProjectId           = meeting.ProjectId,
                    UnitId              = meeting.UnitId == "" ? null : meeting.UnitId,
                    WeekMeetingCode     = meeting.MeetingCode,
                    WeekMeetingName     = meeting.MeetingName,
                    WeekMeetingDate     = Funs.GetNewDateTime(meeting.MeetingDate),
                    WeekMeetingContents = meeting.MeetingContents,
                    CompileMan          = meeting.CompileManId,
                    CompileDate         = Funs.GetNewDateTime(meeting.CompileDate),
                    MeetingPlace        = meeting.MeetingPlace,
                    MeetingHours        = meeting.MeetingHours,
                    MeetingHostMan      = meeting.MeetingHostMan,
                    AttentPerson        = meeting.AttentPerson,
                    AttentPersonNum     = meeting.AttentPersonNum,
                    States              = Const.State_2,

                    AttentPersonIds = meeting.AttentPersonIds,
                };

                if (meeting.States != "1")
                {
                    newWeekMeeting.States = Const.State_0;
                }
                if (!string.IsNullOrEmpty(meeting.MeetingHostManId))
                {
                    newWeekMeeting.MeetingHostManId = meeting.MeetingHostManId;
                }

                var updateMeet = Funs.DB.Meeting_WeekMeeting.FirstOrDefault(x => x.WeekMeetingId == meeting.MeetingId);
                if (updateMeet == null)
                {
                    newWeekMeeting.CompileDate     = DateTime.Now;
                    meeting.MeetingId              = newWeekMeeting.WeekMeetingId = SQLHelper.GetNewID();
                    newWeekMeeting.WeekMeetingCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectWeekMeetingMenuId, newWeekMeeting.ProjectId, null);
                    WeekMeetingService.AddWeekMeeting(newWeekMeeting);
                }
                else
                {
                    WeekMeetingService.UpdateWeekMeeting(newWeekMeeting);
                }
                if (meeting.States == "1")
                {
                    CommonService.btnSaveData(meeting.ProjectId, Const.ProjectWeekMeetingMenuId, newWeekMeeting.WeekMeetingId, newWeekMeeting.CompileMan, true, newWeekMeeting.WeekMeetingName, "../Meeting/WeekMeetingView.aspx?WeekMeetingId={0}");
                }
                menuId = Const.ProjectWeekMeetingMenuId;
            }
            else if (meeting.MeetingType == "M")
            {
                Model.Meeting_MonthMeeting newMonthMeeting = new Model.Meeting_MonthMeeting
                {
                    MonthMeetingId       = meeting.MeetingId,
                    ProjectId            = meeting.ProjectId,
                    UnitId               = meeting.UnitId == "" ? null : meeting.UnitId,
                    MonthMeetingCode     = meeting.MeetingCode,
                    MonthMeetingName     = meeting.MeetingName,
                    MonthMeetingDate     = Funs.GetNewDateTime(meeting.MeetingDate),
                    MonthMeetingContents = meeting.MeetingContents,
                    CompileMan           = meeting.CompileManId,
                    CompileDate          = Funs.GetNewDateTime(meeting.CompileDate),
                    MeetingPlace         = meeting.MeetingPlace,
                    MeetingHours         = meeting.MeetingHours,
                    MeetingHostMan       = meeting.MeetingHostMan,
                    AttentPerson         = meeting.AttentPerson,
                    AttentPersonNum      = meeting.AttentPersonNum,
                    States               = Const.State_2,
                    AttentPersonIds      = meeting.AttentPersonIds,
                };

                if (meeting.States != "1")
                {
                    newMonthMeeting.States = Const.State_0;
                }
                if (!string.IsNullOrEmpty(meeting.MeetingHostManId))
                {
                    newMonthMeeting.MeetingHostManId = meeting.MeetingHostManId;
                }

                var updateMeet = Funs.DB.Meeting_MonthMeeting.FirstOrDefault(x => x.MonthMeetingId == meeting.MeetingId);
                if (updateMeet == null)
                {
                    newMonthMeeting.CompileDate      = DateTime.Now;
                    meeting.MeetingId                = newMonthMeeting.MonthMeetingId = SQLHelper.GetNewID();
                    newMonthMeeting.MonthMeetingCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectMonthMeetingMenuId, newMonthMeeting.ProjectId, null);
                    MonthMeetingService.AddMonthMeeting(newMonthMeeting);
                }
                else
                {
                    MonthMeetingService.UpdateMonthMeeting(newMonthMeeting);
                }
                if (meeting.States == "1")
                {
                    CommonService.btnSaveData(meeting.ProjectId, Const.ProjectMonthMeetingMenuId, newMonthMeeting.MonthMeetingId, newMonthMeeting.CompileMan, true, newMonthMeeting.MonthMeetingName, "../Meeting/MonthMeetingView.aspx?MonthMeetingId={0}");
                }
                menuId = Const.ProjectMonthMeetingMenuId;
            }
            else if (meeting.MeetingType == "S")
            {
                Model.Meeting_SpecialMeeting newSpecialMeeting = new Model.Meeting_SpecialMeeting
                {
                    SpecialMeetingId       = meeting.MeetingId,
                    ProjectId              = meeting.ProjectId,
                    UnitId                 = meeting.UnitId == "" ? null : meeting.UnitId,
                    SpecialMeetingCode     = meeting.MeetingCode,
                    SpecialMeetingName     = meeting.MeetingName,
                    SpecialMeetingDate     = Funs.GetNewDateTime(meeting.MeetingDate),
                    SpecialMeetingContents = meeting.MeetingContents,
                    CompileMan             = meeting.CompileManId,
                    CompileDate            = Funs.GetNewDateTime(meeting.CompileDate),
                    MeetingPlace           = meeting.MeetingPlace,
                    MeetingHours           = meeting.MeetingHours,
                    MeetingHostMan         = meeting.MeetingHostMan,
                    AttentPerson           = meeting.AttentPerson,
                    AttentPersonNum        = meeting.AttentPersonNum,
                    States                 = Const.State_2,
                    //MeetingHostManId = meeting.MeetingHostManId,
                    AttentPersonIds = meeting.AttentPersonIds,
                };

                if (meeting.States != "1")
                {
                    newSpecialMeeting.States = Const.State_0;
                }
                if (!string.IsNullOrEmpty(meeting.MeetingHostManId))
                {
                    newSpecialMeeting.MeetingHostManId = meeting.MeetingHostManId;
                }

                var updateMeet = Funs.DB.Meeting_SpecialMeeting.FirstOrDefault(x => x.SpecialMeetingId == meeting.MeetingId);
                if (updateMeet == null)
                {
                    newSpecialMeeting.CompileDate        = DateTime.Now;
                    meeting.MeetingId                    = newSpecialMeeting.SpecialMeetingId = SQLHelper.GetNewID();
                    newSpecialMeeting.SpecialMeetingCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectSpecialMeetingMenuId, newSpecialMeeting.ProjectId, null);
                    SpecialMeetingService.AddSpecialMeeting(newSpecialMeeting);
                }
                else
                {
                    SpecialMeetingService.UpdateSpecialMeeting(newSpecialMeeting);
                }
                if (meeting.States == "1")
                {
                    CommonService.btnSaveData(meeting.ProjectId, Const.ProjectSpecialMeetingMenuId, newSpecialMeeting.SpecialMeetingId, newSpecialMeeting.CompileMan, true, newSpecialMeeting.SpecialMeetingName, "../Meeting/SpecialMeetingView.aspx?SpecialMeetingId={0}");
                }
                menuId = Const.ProjectSpecialMeetingMenuId;
            }
            else
            {
                Model.Meeting_AttendMeeting newAttendMeeting = new Model.Meeting_AttendMeeting
                {
                    AttendMeetingId       = meeting.MeetingId,
                    ProjectId             = meeting.ProjectId,
                    UnitId                = meeting.UnitId == "" ? null : meeting.UnitId,
                    AttendMeetingCode     = meeting.MeetingCode,
                    AttendMeetingName     = meeting.MeetingName,
                    AttendMeetingDate     = Funs.GetNewDateTime(meeting.MeetingDate),
                    AttendMeetingContents = meeting.MeetingContents,
                    CompileMan            = meeting.CompileManId,
                    CompileDate           = Funs.GetNewDateTime(meeting.CompileDate),
                    MeetingPlace          = meeting.MeetingPlace,
                    MeetingHours          = meeting.MeetingHours,
                    MeetingHostMan        = meeting.MeetingHostMan,
                    AttentPerson          = meeting.AttentPerson,
                    AttentPersonNum       = meeting.AttentPersonNum,
                    States                = Const.State_2,
                    //MeetingHostManId = meeting.MeetingHostManId,
                    AttentPersonIds = meeting.AttentPersonIds,
                };

                if (meeting.States != "1")
                {
                    newAttendMeeting.States = Const.State_0;
                }
                if (!string.IsNullOrEmpty(meeting.MeetingHostManId))
                {
                    newAttendMeeting.MeetingHostManId = meeting.MeetingHostManId;
                }

                var updateMeet = Funs.DB.Meeting_AttendMeeting.FirstOrDefault(x => x.AttendMeetingId == meeting.MeetingId);
                if (updateMeet == null)
                {
                    newAttendMeeting.CompileDate       = DateTime.Now;
                    meeting.MeetingId                  = newAttendMeeting.AttendMeetingId = SQLHelper.GetNewID();
                    newAttendMeeting.AttendMeetingCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectAttendMeetingMenuId, newAttendMeeting.ProjectId, null);
                    AttendMeetingService.AddAttendMeeting(newAttendMeeting);
                }
                else
                {
                    AttendMeetingService.UpdateAttendMeeting(newAttendMeeting);
                }
                if (meeting.States == "1")
                {
                    CommonService.btnSaveData(meeting.ProjectId, Const.ProjectAttendMeetingMenuId, newAttendMeeting.AttendMeetingId, newAttendMeeting.CompileMan, true, newAttendMeeting.AttendMeetingName, "../Meeting/AttendMeetingView.aspx?AttendMeetingId={0}");
                }
                menuId = Const.ProjectAttendMeetingMenuId;
            }
            if (!string.IsNullOrEmpty(menuId) && !string.IsNullOrEmpty(meeting.MeetingId))
            {
                SaveMeetUrl(meeting.MeetingId, menuId, meeting.AttachUrl, meeting.AttachUrl1, meeting.AttachUrl2);
            }
        }
Beispiel #17
0
        /// <summary>
        /// 保存Check_PauseNotice
        /// </summary>
        /// <param name="newItem">工程暂停令</param>
        /// <returns></returns>
        public static void SavePauseNotice(Model.PauseNoticeItem newItem)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                Model.Check_PauseNotice newPauseNotice = new Model.Check_PauseNotice
                {
                    PauseNoticeId   = newItem.PauseNoticeId,
                    PauseNoticeCode = newItem.PauseNoticeCode,
                    ProjectId       = newItem.ProjectId,
                    UnitId          = newItem.UnitId,
                    ProjectPlace    = newItem.ProjectPlace,
                    WrongContent    = newItem.WrongContent,
                    PauseTime       = Funs.GetNewDateTime(newItem.PauseTime),
                    PauseContent    = newItem.PauseContent,
                    OneContent      = newItem.OneContent,
                    SecondContent   = newItem.SecondContent,
                    ThirdContent    = newItem.ThirdContent,
                    States          = Const.State_0,
                    PauseStates     = newItem.PauseStates,
                };

                var getUpdate = db.Check_PauseNotice.FirstOrDefault(x => x.PauseNoticeId == newItem.PauseNoticeId);
                if (getUpdate == null)
                {
                    newPauseNotice.CompileDate     = DateTime.Now;
                    newPauseNotice.PauseNoticeId   = SQLHelper.GetNewID();
                    newPauseNotice.PauseNoticeCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectPauseNoticeMenuId, newPauseNotice.ProjectId, newPauseNotice.UnitId);
                    db.Check_PauseNotice.InsertOnSubmit(newPauseNotice);
                    db.SubmitChanges();

                    CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectPauseNoticeMenuId, newPauseNotice.ProjectId, newPauseNotice.UnitId, newPauseNotice.PauseNoticeId, newPauseNotice.CompileDate);
                    //// 回写巡检记录表
                    if (!string.IsNullOrEmpty(newItem.HazardRegisterId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(newItem.HazardRegisterId, ',');
                        foreach (var item in listIds)
                        {
                            var getHazardRegister = Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == item);
                            if (getHazardRegister != null)
                            {
                                getHazardRegister.States      = "3";
                                getHazardRegister.HandleIdea += "已下发工程暂停令:" + newPauseNotice.PauseNoticeCode;
                                getHazardRegister.ResultId    = newPauseNotice.PauseNoticeId;
                                getHazardRegister.ResultType  = "3";
                                Funs.SubmitChanges();
                            }
                        }
                    }
                    //// 回写专项检查明细表
                    if (!string.IsNullOrEmpty(newItem.CheckSpecialDetailId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(newItem.CheckSpecialDetailId, ',');
                        foreach (var item in listIds)
                        {
                            var getCheckSpecialDetail = db.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == item);
                            if (getCheckSpecialDetail != null)
                            {
                                getCheckSpecialDetail.DataType = "3";
                                getCheckSpecialDetail.DataId   = newPauseNotice.PauseNoticeId;
                                db.SubmitChanges();
                            }
                        }
                    }
                }
                else
                {
                    newPauseNotice.PauseNoticeId = getUpdate.PauseNoticeId;
                    getUpdate.PauseStates        = newItem.PauseStates;
                    if (newPauseNotice.PauseStates == "0" || newPauseNotice.PauseStates == "1")  ////编制人 修改或提交
                    {
                        getUpdate.UnitId        = newPauseNotice.UnitId;
                        getUpdate.ProjectPlace  = newPauseNotice.ProjectPlace;
                        getUpdate.WrongContent  = newPauseNotice.WrongContent;
                        getUpdate.PauseTime     = newPauseNotice.PauseTime;
                        getUpdate.PauseContent  = newPauseNotice.PauseContent;
                        getUpdate.OneContent    = newPauseNotice.OneContent;
                        getUpdate.SecondContent = newPauseNotice.SecondContent;
                        getUpdate.ThirdContent  = newPauseNotice.ThirdContent;
                        if (newPauseNotice.PauseStates == "1" && !string.IsNullOrEmpty(newItem.SignManId))
                        {
                            getUpdate.SignManId = newItem.SignManId;
                        }
                        else
                        {
                            newPauseNotice.PauseStates = getUpdate.PauseStates = "0";
                        }
                    }
                    else if (newPauseNotice.PauseStates == "2") ////【签发】总包安全经理
                    {
                        /// 不同意 打回 同意抄送专业工程师、施工经理、相关施工分包单位并提交【批准】总包项目经理
                        if (newItem.IsAgree == false)
                        {
                            newPauseNotice.PauseStates = getUpdate.PauseStates = "0";
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(newItem.ProfessionalEngineerId))
                            {
                                getUpdate.ProfessionalEngineerId = newItem.ProfessionalEngineerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.ConstructionManagerId))
                            {
                                getUpdate.ConstructionManagerId = newItem.ConstructionManagerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.UnitHeadManId))
                            {
                                getUpdate.UnitHeadManId = newItem.UnitHeadManId;
                            }
                            if (!string.IsNullOrEmpty(newItem.SupervisorManId))
                            {
                                getUpdate.SupervisorManId = newItem.SupervisorManId;
                            }
                            if (!string.IsNullOrEmpty(newItem.OwnerId))
                            {
                                getUpdate.OwnerId = newItem.OwnerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.ApproveManId))
                            {
                                getUpdate.ApproveManId = newItem.ApproveManId;
                                getUpdate.SignDate     = DateTime.Now;
                            }
                            else
                            {
                                newPauseNotice.PauseStates = getUpdate.States = "1";
                            }
                        }
                    }
                    else if (newPauseNotice.PauseStates == "3") ////【批准】总包项目经理
                    {
                        /// 不同意 打回 同意下发【回执】施工分包单位
                        if (newItem.IsAgree == false || string.IsNullOrEmpty(newItem.DutyPersonId))
                        {
                            newPauseNotice.PauseStates = getUpdate.PauseStates = "1";
                        }
                        else
                        {
                            getUpdate.DutyPersonId = newItem.DutyPersonId;
                            getUpdate.ApproveDate  = DateTime.Now;
                            getUpdate.IsConfirm    = true;
                        }
                    }
                    else if (newPauseNotice.PauseStates == "4") ////【批准】总包项目经理
                    {
                        getUpdate.DutyPersonDate = DateTime.Now;
                        getUpdate.States         = Const.State_2;
                    }

                    db.SubmitChanges();
                }

                if (newItem.PauseStates == Const.State_0 || newItem.PauseStates == Const.State_1)
                {     //// 通知单附件
                    UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newItem.PauseNoticeAttachUrl, 10, null), newItem.PauseNoticeAttachUrl, Const.ProjectPauseNoticeMenuId, newPauseNotice.PauseNoticeId);
                }
                if (getUpdate != null && getUpdate.States == Const.State_2)
                {
                    CommonService.btnSaveData(newPauseNotice.ProjectId, Const.ProjectPauseNoticeMenuId, newPauseNotice.PauseNoticeId, newPauseNotice.CompileManId, true, newPauseNotice.PauseContent, "../Check/PauseNoticeView.aspx?PauseNoticeId={0}");

                    var getcheck = from x in db.Check_CheckSpecialDetail where x.DataId == getUpdate.PauseNoticeId select x;
                    if (getcheck.Count() > 0)
                    {
                        foreach (var item in getcheck)
                        {
                            item.CompleteStatus = true;
                            item.CompletedDate  = DateTime.Now;
                            db.SubmitChanges();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 保存RectifyNotices
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public static void SaveRectifyNotices(Model.RectifyNoticesItem rectifyNotices)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                bool insertRectifyNoticesItemItem            = false;
                Model.Check_RectifyNotices newRectifyNotices = new Model.Check_RectifyNotices
                {
                    RectifyNoticesId   = rectifyNotices.RectifyNoticesId,
                    ProjectId          = rectifyNotices.ProjectId,
                    RectifyNoticesCode = rectifyNotices.RectifyNoticesCode,
                    UnitId             = rectifyNotices.UnitId,
                    CheckManNames      = rectifyNotices.CheckManNames,
                    CheckManIds        = rectifyNotices.CheckManIds,
                    CheckedDate        = Funs.GetNewDateTime(rectifyNotices.CheckedDate),
                    HiddenHazardType   = rectifyNotices.HiddenHazardType,
                    States             = rectifyNotices.States,
                };
                if (!string.IsNullOrEmpty(rectifyNotices.WorkAreaId))
                {
                    newRectifyNotices.WorkAreaId = rectifyNotices.WorkAreaId;
                }
                if (!string.IsNullOrEmpty(rectifyNotices.CompleteManId))
                {
                    newRectifyNotices.CompleteManId = rectifyNotices.CompleteManId;
                }
                if (newRectifyNotices.States == Const.State_1)
                {
                    newRectifyNotices.SignPerson = rectifyNotices.SignPersonId;
                }
                //// 新增整改单
                var isUpdate = db.Check_RectifyNotices.FirstOrDefault(x => x.RectifyNoticesId == newRectifyNotices.RectifyNoticesId);
                if (isUpdate == null)
                {
                    newRectifyNotices.RectifyNoticesId   = SQLHelper.GetNewID();
                    newRectifyNotices.Isprint            = "0";
                    newRectifyNotices.Isprintf           = "0";
                    newRectifyNotices.RectifyNoticesCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectRectifyNoticesMenuId, newRectifyNotices.ProjectId, newRectifyNotices.UnitId);
                    db.Check_RectifyNotices.InsertOnSubmit(newRectifyNotices);
                    db.SubmitChanges();
                    CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectRectifyNoticesMenuId, newRectifyNotices.ProjectId, newRectifyNotices.UnitId, newRectifyNotices.RectifyNoticesId, newRectifyNotices.CheckedDate);
                    //// 整改单附件
                    if (!string.IsNullOrEmpty(rectifyNotices.BeAttachUrl))
                    {
                        APIUpLoadFileService.SaveAttachUrl(Const.ProjectRectifyNoticesMenuId, newRectifyNotices.RectifyNoticesId + "#0", rectifyNotices.BeAttachUrl, "0");
                    }
                    //// 反馈单附件
                    if (!string.IsNullOrEmpty(rectifyNotices.AfAttachUrl))
                    {
                        APIUpLoadFileService.SaveAttachUrl(Const.ProjectRectifyNoticesMenuId, newRectifyNotices.RectifyNoticesId + "#1", rectifyNotices.AfAttachUrl, "0");
                    }
                    //// 整个单据附件
                    if (!string.IsNullOrEmpty(rectifyNotices.AttachUrl))
                    {
                        APIUpLoadFileService.SaveAttachUrl(Const.ProjectRectifyNoticesMenuId, newRectifyNotices.RectifyNoticesId, rectifyNotices.AttachUrl, "0");
                    }
                    insertRectifyNoticesItemItem = true;

                    //// 回写巡检记录表
                    if (!string.IsNullOrEmpty(rectifyNotices.HazardRegisterId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(rectifyNotices.HazardRegisterId, ',');
                        foreach (var item in listIds)
                        {
                            var getHazardRegister = db.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == item);
                            if (getHazardRegister != null)
                            {
                                getHazardRegister.States      = "3";
                                getHazardRegister.HandleIdea += "已升级为隐患整改单:" + newRectifyNotices.RectifyNoticesCode;
                                getHazardRegister.ResultId    = newRectifyNotices.RectifyNoticesId;
                                getHazardRegister.ResultType  = "1";
                                db.SubmitChanges();
                            }
                        }
                    }
                    //// 回写专项检查明细表
                    if (!string.IsNullOrEmpty(rectifyNotices.CheckSpecialDetailId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(rectifyNotices.CheckSpecialDetailId, ',');
                        foreach (var item in listIds)
                        {
                            var getCheckSpecialDetail = db.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == item);
                            if (getCheckSpecialDetail != null)
                            {
                                getCheckSpecialDetail.DataType = "1";
                                getCheckSpecialDetail.DataId   = newRectifyNotices.RectifyNoticesId;
                                db.SubmitChanges();
                            }
                        }
                    }
                }
                else
                {
                    newRectifyNotices.RectifyNoticesId = isUpdate.RectifyNoticesId;
                    isUpdate.States = rectifyNotices.States;
                    if (newRectifyNotices.States == "0" || newRectifyNotices.States == "1")  ////编制人 修改或提交
                    {
                        isUpdate.UnitId           = rectifyNotices.UnitId;
                        isUpdate.WorkAreaId       = rectifyNotices.WorkAreaId;
                        isUpdate.CheckManNames    = rectifyNotices.CheckManNames;
                        isUpdate.CheckManIds      = rectifyNotices.CheckManIds;
                        isUpdate.CheckedDate      = Funs.GetNewDateTime(rectifyNotices.CheckedDate);
                        isUpdate.HiddenHazardType = rectifyNotices.HiddenHazardType;
                        if (newRectifyNotices.States == "1" && !string.IsNullOrEmpty(rectifyNotices.SignPersonId))
                        {
                            isUpdate.SignPerson = rectifyNotices.SignPersonId;
                        }
                        else
                        {
                            newRectifyNotices.States = isUpdate.States = "0";
                        }
                        db.SubmitChanges();
                        //// 删除明细表
                        var deleteItem = from x in db.Check_RectifyNoticesItem where x.RectifyNoticesId == isUpdate.RectifyNoticesId select x;
                        if (deleteItem.Count() > 0)
                        {
                            foreach (var cdeleteItem in deleteItem)
                            {
                                CommonService.DeleteAttachFileById(cdeleteItem.RectifyNoticesItemId);
                            }
                            db.Check_RectifyNoticesItem.DeleteAllOnSubmit(deleteItem);
                        }

                        insertRectifyNoticesItemItem = true;
                    }
                    else if (newRectifyNotices.States == "2") ////总包单位项目安全经理 审核
                    {
                        /// 不同意 打回 同意抄送专业工程师、施工经理、项目经理 并下发分包接收人(也就是施工单位项目安全经理)
                        if (rectifyNotices.IsAgree == false)
                        {
                            newRectifyNotices.States = isUpdate.States = "0";
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(rectifyNotices.ProfessionalEngineerId))
                            {
                                isUpdate.ProfessionalEngineerId = rectifyNotices.ProfessionalEngineerId;
                            }
                            if (!string.IsNullOrEmpty(rectifyNotices.ConstructionManagerId))
                            {
                                isUpdate.ConstructionManagerId = rectifyNotices.ConstructionManagerId;
                            }
                            if (!string.IsNullOrEmpty(rectifyNotices.ProjectManagerId))
                            {
                                isUpdate.ProjectManagerId = rectifyNotices.ProjectManagerId;
                            }
                            if (!string.IsNullOrEmpty(rectifyNotices.DutyPersonId))
                            {
                                isUpdate.DutyPersonId = rectifyNotices.DutyPersonId;
                                isUpdate.SignDate     = DateTime.Now;
                            }
                            else
                            {
                                newRectifyNotices.States = isUpdate.States = "1";
                            }
                        }
                        db.SubmitChanges();
                    }
                    else if (newRectifyNotices.States == "3") /// 施工单位项目安全经理 整改 提交施工单位项目负责人
                    {
                        //// 整改明细反馈
                        if (rectifyNotices.RectifyNoticesItemItem != null && rectifyNotices.RectifyNoticesItemItem.Count() > 0)
                        {
                            foreach (var rItem in rectifyNotices.RectifyNoticesItemItem)
                            {
                                var getUpdateItem = db.Check_RectifyNoticesItem.FirstOrDefault(x => x.RectifyNoticesItemId == rItem.RectifyNoticesItemId);
                                if (getUpdateItem != null)
                                {
                                    getUpdateItem.RectifyResults = rItem.RectifyResults;
                                    if (getUpdateItem.IsRectify != true)
                                    {
                                        getUpdateItem.IsRectify = null;
                                    }
                                    db.SubmitChanges();
                                }
                                if (!string.IsNullOrEmpty(rItem.PhotoAfterUrl))
                                {
                                    APIUpLoadFileService.SaveAttachUrl(Const.ProjectRectifyNoticesMenuId, rItem.RectifyNoticesItemId + "#2", rItem.PhotoAfterUrl, "0");
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(rectifyNotices.UnitHeadManId))
                        {
                            isUpdate.UnitHeadManId = rectifyNotices.UnitHeadManId;
                            isUpdate.CompleteDate  = DateTime.Now;
                        }
                        else
                        {
                            newRectifyNotices.States = isUpdate.States = "2";
                        }
                        db.SubmitChanges();
                    }
                    else if (newRectifyNotices.States == "4")
                    { /// 施工单位项目负责人不同意 打回施工单位项目安全经理,同意提交安全经理/安全工程师复查
                        if (rectifyNotices.IsAgree == false)
                        {
                            newRectifyNotices.States = isUpdate.States = "2";
                            isUpdate.CompleteDate    = null;
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(rectifyNotices.CheckPersonId))
                            {
                                isUpdate.UnitHeadManDate = DateTime.Now;
                                isUpdate.CheckPerson     = rectifyNotices.CheckPersonId;
                            }
                            else
                            {
                                newRectifyNotices.States = isUpdate.States = "3";
                            }
                        }
                        db.SubmitChanges();
                    }
                    else if (newRectifyNotices.States == "5")
                    {
                        //// 整改明细反馈 复查 是否合格
                        if (rectifyNotices.RectifyNoticesItemItem != null && rectifyNotices.RectifyNoticesItemItem.Count() > 0)
                        {
                            foreach (var rItem in rectifyNotices.RectifyNoticesItemItem)
                            {
                                var getUpdateItem = db.Check_RectifyNoticesItem.FirstOrDefault(x => x.RectifyNoticesItemId == rItem.RectifyNoticesItemId);
                                if (getUpdateItem != null)
                                {
                                    getUpdateItem.IsRectify = rItem.IsRectify;
                                    db.SubmitChanges();
                                    //// 存在不合格  意见自动不同意
                                    if (!getUpdateItem.IsRectify.HasValue || getUpdateItem.IsRectify == false)
                                    {
                                        rectifyNotices.IsAgree = false;
                                    }
                                }
                            }
                        }

                        ////安全经理/安全工程师 同意关闭,不同意打回施工单位项目安全经理
                        isUpdate.ReCheckOpinion = rectifyNotices.ReCheckOpinion;
                        if (rectifyNotices.IsAgree == false)
                        {
                            newRectifyNotices.States           = isUpdate.States = "2";
                            isUpdate.UnitHeadManDate           = null;
                            isUpdate.CompleteDate              = null;
                            isUpdate.ProfessionalEngineerTime2 = null;
                            isUpdate.ConstructionManagerTime2  = null;
                            isUpdate.ProjectManagerTime2       = null;
                        }
                        else
                        {
                            isUpdate.ReCheckDate = DateTime.Now;
                            //// 回写专项检查明细表
                            var getcheck = from x in db.Check_CheckSpecialDetail where x.DataId == isUpdate.RectifyNoticesId select x;
                            if (getcheck.Count() > 0)
                            {
                                foreach (var item in getcheck)
                                {
                                    item.CompleteStatus = true;
                                    item.CompletedDate  = DateTime.Now;
                                    db.SubmitChanges();
                                }
                            }
                        }
                        db.SubmitChanges();
                    }
                }
                if (insertRectifyNoticesItemItem)
                {
                    //// 新增明细
                    if (rectifyNotices.RectifyNoticesItemItem != null && rectifyNotices.RectifyNoticesItemItem.Count() > 0)
                    {
                        foreach (var rItem in rectifyNotices.RectifyNoticesItemItem)
                        {
                            Model.Check_RectifyNoticesItem newItem = new Model.Check_RectifyNoticesItem
                            {
                                RectifyNoticesItemId = SQLHelper.GetNewID(),
                                RectifyNoticesId     = newRectifyNotices.RectifyNoticesId,
                                WrongContent         = rItem.WrongContent,
                                Requirement          = rItem.Requirement,
                                LimitTime            = Funs.GetNewDateTime(rItem.LimitTime),
                                RectifyResults       = null,
                                IsRectify            = null,
                            };
                            db.Check_RectifyNoticesItem.InsertOnSubmit(newItem);
                            db.SubmitChanges();

                            if (!string.IsNullOrEmpty(rItem.PhotoBeforeUrl))
                            {
                                APIUpLoadFileService.SaveAttachUrl(Const.ProjectRectifyNoticesMenuId, newItem.RectifyNoticesItemId + "#1", rItem.PhotoBeforeUrl, "0");
                            }
                        }
                    }
                }
                //// 增加审核记录
                if (rectifyNotices.RectifyNoticesFlowOperateItem != null && rectifyNotices.RectifyNoticesFlowOperateItem.Count() > 0)
                {
                    var getOperate = rectifyNotices.RectifyNoticesFlowOperateItem.FirstOrDefault();
                    if (getOperate != null && !string.IsNullOrEmpty(getOperate.OperateManId))
                    {
                        Model.Check_RectifyNoticesFlowOperate newOItem = new Model.Check_RectifyNoticesFlowOperate
                        {
                            FlowOperateId    = SQLHelper.GetNewID(),
                            RectifyNoticesId = newRectifyNotices.RectifyNoticesId,
                            OperateName      = getOperate.OperateName,
                            OperateManId     = getOperate.OperateManId,
                            OperateTime      = DateTime.Now,
                            IsAgree          = getOperate.IsAgree,
                            Opinion          = getOperate.Opinion,
                        };
                        db.Check_RectifyNoticesFlowOperate.InsertOnSubmit(newOItem);
                        db.SubmitChanges();
                    }
                }

                if (newRectifyNotices.States == Const.State_1)
                {
                    APICommonService.SendSubscribeMessage(newRectifyNotices.SignPerson, "隐患整改单" + newRectifyNotices.RectifyNoticesCode + "待您签发", rectifyNotices.CheckManNames, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
                }
                else if (newRectifyNotices.States == Const.State_2)
                {
                    APICommonService.SendSubscribeMessage(newRectifyNotices.DutyPersonId, "隐患整改单" + newRectifyNotices.RectifyNoticesCode + "待您整改", rectifyNotices.SignPersonName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
                }
                else if (newRectifyNotices.States == Const.State_3)
                {
                    APICommonService.SendSubscribeMessage(newRectifyNotices.UnitHeadManId, "隐患整改单" + newRectifyNotices.RectifyNoticesCode + "待您审核", rectifyNotices.DutyPersonName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
                }
                else if (newRectifyNotices.States == Const.State_4)
                {
                    APICommonService.SendSubscribeMessage(newRectifyNotices.CheckPerson, "隐患整改单" + newRectifyNotices.RectifyNoticesCode + "待您复查", rectifyNotices.UnitHeadManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// 保存emergencyInfo
        /// </summary>
        /// <param name="emergencyInfo">会议信息</param>
        /// <returns></returns>
        public static void SaveEmergency(Model.FileInfoItem emergencyInfo)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                string menuId = string.Empty;
                if (emergencyInfo.MenuType == "1")
                {
                    Model.Emergency_EmergencyList newEmergency = new Model.Emergency_EmergencyList
                    {
                        EmergencyListId   = emergencyInfo.FileId,
                        ProjectId         = emergencyInfo.ProjectId,
                        UnitId            = emergencyInfo.UnitId == "" ? null : emergencyInfo.UnitId,
                        EmergencyTypeId   = emergencyInfo.FileType == "" ? null : emergencyInfo.FileType,
                        EmergencyCode     = emergencyInfo.FileCode,
                        EmergencyName     = emergencyInfo.FileName,
                        EmergencyContents = emergencyInfo.FileContent,
                        CompileMan        = emergencyInfo.CompileManId,
                        CompileDate       = Funs.GetNewDateTime(emergencyInfo.CompileDate),
                        States            = Const.State_2,
                    };
                    if (!string.IsNullOrEmpty(emergencyInfo.AuditManId))
                    {
                        newEmergency.AuditMan = emergencyInfo.AuditManId;
                    }
                    if (!string.IsNullOrEmpty(emergencyInfo.ApproveManId))
                    {
                        newEmergency.ApproveMan = emergencyInfo.ApproveManId;
                    }
                    if (emergencyInfo.States != Const.State_1)
                    {
                        newEmergency.States = Const.State_0;
                    }
                    var updateEmergency = db.Emergency_EmergencyList.FirstOrDefault(x => x.EmergencyListId == emergencyInfo.FileId);
                    if (updateEmergency == null)
                    {
                        newEmergency.CompileDate   = DateTime.Now;
                        emergencyInfo.FileId       = newEmergency.EmergencyListId = SQLHelper.GetNewID();
                        newEmergency.EmergencyCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectClassMeetingMenuId, newEmergency.ProjectId, null);
                        db.Emergency_EmergencyList.InsertOnSubmit(newEmergency);
                        db.SubmitChanges();
                        ////增加一条编码记录
                        CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectEmergencyListMenuId, newEmergency.ProjectId, null, newEmergency.EmergencyListId, newEmergency.CompileDate);
                    }
                    else
                    {
                        updateEmergency.EmergencyName     = newEmergency.EmergencyName;
                        updateEmergency.UnitId            = newEmergency.UnitId;
                        updateEmergency.EmergencyTypeId   = newEmergency.EmergencyTypeId;
                        updateEmergency.EmergencyContents = newEmergency.EmergencyContents;
                        updateEmergency.AuditMan          = newEmergency.AuditMan;
                        updateEmergency.ApproveMan        = newEmergency.ApproveMan;
                        db.SubmitChanges();
                    }
                    if (emergencyInfo.States == Const.State_1)
                    {
                        CommonService.btnSaveData(newEmergency.ProjectId, Const.ProjectEmergencyListMenuId, newEmergency.EmergencyListId, newEmergency.CompileMan, true, newEmergency.EmergencyName, "../Emergency/EmergencyListView.aspx?EmergencyListId={0}");
                    }

                    menuId = Const.ProjectEmergencyListMenuId;
                }
                else if (emergencyInfo.MenuType == "2")
                {
                    Model.Emergency_EmergencySupply newEmergency = new Model.Emergency_EmergencySupply
                    {
                        FileId      = emergencyInfo.FileId,
                        ProjectId   = emergencyInfo.ProjectId,
                        UnitId      = emergencyInfo.UnitId == "" ? null : emergencyInfo.UnitId,
                        FileCode    = emergencyInfo.FileCode,
                        FileName    = emergencyInfo.FileName,
                        FileContent = emergencyInfo.FileContent,
                        CompileMan  = emergencyInfo.CompileManId,
                        CompileDate = Funs.GetNewDateTime(emergencyInfo.CompileDate),
                        States      = Const.State_2,
                    };

                    if (emergencyInfo.States != Const.State_1)
                    {
                        newEmergency.States = Const.State_0;
                    }
                    var updateEmergency = db.Emergency_EmergencySupply.FirstOrDefault(x => x.FileId == emergencyInfo.FileId);
                    if (updateEmergency == null)
                    {
                        newEmergency.CompileDate = DateTime.Now;
                        emergencyInfo.FileId     = newEmergency.FileId = SQLHelper.GetNewID();
                        newEmergency.FileCode    = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectEmergencySupplyMenuId, newEmergency.ProjectId, null);
                        db.Emergency_EmergencySupply.InsertOnSubmit(newEmergency);
                    }
                    else
                    {
                        updateEmergency.UnitId      = newEmergency.UnitId;
                        updateEmergency.FileCode    = newEmergency.FileCode;
                        updateEmergency.FileName    = newEmergency.FileName;
                        updateEmergency.FileContent = newEmergency.FileContent;
                        db.SubmitChanges();
                    }
                    if (emergencyInfo.States == Const.State_1)
                    {
                        CommonService.btnSaveData(newEmergency.ProjectId, Const.ProjectEmergencySupplyMenuId, newEmergency.FileId, newEmergency.CompileMan, true, newEmergency.FileName, "../Emergency/EmergencySupplyView.aspx?FileId={0}");
                    }
                    menuId = Const.ProjectEmergencySupplyMenuId;
                }
                else if (emergencyInfo.MenuType == "3")
                {
                    Model.Emergency_EmergencyTeamAndTrain newEmergency = new Model.Emergency_EmergencyTeamAndTrain
                    {
                        FileId      = emergencyInfo.FileId,
                        ProjectId   = emergencyInfo.ProjectId,
                        UnitId      = emergencyInfo.UnitId == "" ? null : emergencyInfo.UnitId,
                        FileCode    = emergencyInfo.FileCode,
                        FileName    = emergencyInfo.FileName,
                        FileContent = emergencyInfo.FileContent,
                        CompileMan  = emergencyInfo.CompileManId,
                        CompileDate = Funs.GetNewDateTime(emergencyInfo.CompileDate),
                        States      = Const.State_2,
                    };

                    if (emergencyInfo.States != Const.State_1)
                    {
                        newEmergency.States = Const.State_0;
                    }

                    var updateEmergency = db.Emergency_EmergencyTeamAndTrain.FirstOrDefault(x => x.FileId == emergencyInfo.FileId);
                    if (updateEmergency == null)
                    {
                        newEmergency.CompileDate = DateTime.Now;
                        emergencyInfo.FileId     = newEmergency.FileId = SQLHelper.GetNewID();
                        newEmergency.FileCode    = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectEmergencyTeamAndTrainMenuId, newEmergency.ProjectId, null);
                        db.Emergency_EmergencyTeamAndTrain.InsertOnSubmit(newEmergency);
                    }
                    else
                    {
                        updateEmergency.UnitId      = newEmergency.UnitId;
                        updateEmergency.FileCode    = newEmergency.FileCode;
                        updateEmergency.FileName    = newEmergency.FileName;
                        updateEmergency.FileContent = newEmergency.FileContent;
                        db.SubmitChanges();
                        var delItem = from x in db.Emergency_EmergencyTeamItem where x.FileId == updateEmergency.FileId select x;
                        if (delItem.Count() > 0)
                        {
                            db.Emergency_EmergencyTeamItem.DeleteAllOnSubmit(delItem);
                            db.SubmitChanges();
                        }
                    }
                    if (emergencyInfo.EmergencyTeamItem != null && emergencyInfo.EmergencyTeamItem.Count() > 0)
                    {
                        var getItems = from x in emergencyInfo.EmergencyTeamItem
                                       select new Model.Emergency_EmergencyTeamItem
                        {
                            EmergencyTeamItemId = x.EmergencyTeamItemId,
                            FileId   = x.FileId,
                            PersonId = x.PersonId,
                            Job      = x.Job,
                            Tel      = x.Tel,
                        };
                        if (getItems.Count() > 0)
                        {
                            Funs.DB.Emergency_EmergencyTeamItem.InsertAllOnSubmit(getItems);
                            Funs.DB.SubmitChanges();
                        }
                    }

                    if (emergencyInfo.States == Const.State_1)
                    {
                        CommonService.btnSaveData(newEmergency.ProjectId, Const.ProjectEmergencyTeamAndTrainMenuId, newEmergency.FileId, newEmergency.CompileMan, true, newEmergency.FileName, "../Emergency/EmergencyTeamAndTrainView.aspx?FileId={0}");
                    }
                    menuId = Const.ProjectEmergencyTeamAndTrainMenuId;
                }
                else
                {
                }
                ///// 附件保存
                if (!string.IsNullOrEmpty(menuId) && !string.IsNullOrEmpty(emergencyInfo.FileId))
                {
                    APIUpLoadFileService.SaveAttachUrl(menuId, emergencyInfo.FileId, emergencyInfo.AttachUrl, "0");
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// 根据安全工作总结Id获取安全工作总结信息
        /// </summary>
        /// <param name="ManagerTotalId"></param>
        /// <returns></returns>
        public static List <Model.SpManagerTotalMonthItem> GetManager_ManagerTotalMonthItem(string date)
        {
            DateTime?monthTime        = Funs.GetNewDateTime(date);
            var      managerTotalList = BLL.ManagerTotalMonthService.GetManagerTotalByDate(monthTime.Value);
            var      projectList      = BLL.ProjectService.GetTotalMonthProjectWorkList(monthTime);
            List <Model.SpManagerTotalMonthItem> reportItemPartList = new List <Model.SpManagerTotalMonthItem>();
            int projectCount = projectList.Count();
            int rows         = 1;
            int sortIndex    = 1;

            foreach (var projectItem in projectList)
            {
                var managerTotalProject = managerTotalList.FirstOrDefault(x => x.ProjectId == projectItem.ProjectId);
                if (managerTotalProject != null)
                {
                    var managerTotalItems = from x in Funs.DB.Manager_ManagerTotalMonthItem where x.ManagerTotalMonthId == managerTotalProject.ManagerTotalMonthId select x;
                    if (managerTotalItems.Count() > 0)
                    {
                        foreach (var item in managerTotalItems)
                        {
                            Model.SpManagerTotalMonthItem part = new Model.SpManagerTotalMonthItem
                            {
                                ID                    = SQLHelper.GetNewID(typeof(Model.Manager_ManagerTotalMonthItem)),
                                ProjectName           = projectItem.ProjectName,
                                ExistenceHiddenDanger = item.ExistenceHiddenDanger,
                                CorrectiveActions     = item.CorrectiveActions,
                                PlanCompletedDate     = string.Format("{0:yyyy-MM-dd}", item.PlanCompletedDate),
                                ResponsiMan           = item.ResponsiMan,
                                ActualCompledDate     = string.Format("{0:yyyy-MM-dd}", item.ActualCompledDate),
                                Remark                = item.Remark,
                                SortIndex             = sortIndex
                            };
                            reportItemPartList.Add(part);
                            sortIndex++;
                        }
                    }
                    else
                    {
                        Model.SpManagerTotalMonthItem part = new Model.SpManagerTotalMonthItem
                        {
                            ID                    = SQLHelper.GetNewID(typeof(Model.Manager_ManagerTotalMonthItem)),
                            ProjectName           = projectItem.ProjectName,
                            ExistenceHiddenDanger = "/",
                            CorrectiveActions     = "/",
                            PlanCompletedDate     = null,
                            ResponsiMan           = "/",
                            ActualCompledDate     = null,
                            Remark                = "/",
                            SortIndex             = sortIndex
                        };
                        reportItemPartList.Add(part);
                        sortIndex++;
                    }
                }
                else
                {
                    Model.SpManagerTotalMonthItem part = new Model.SpManagerTotalMonthItem
                    {
                        ID                    = SQLHelper.GetNewID(typeof(Model.Manager_ManagerTotalMonthItem)),
                        ProjectName           = projectItem.ProjectName,
                        ExistenceHiddenDanger = "/",
                        CorrectiveActions     = "/",
                        PlanCompletedDate     = "/",
                        ResponsiMan           = "/",
                        ActualCompledDate     = "/",
                        Remark                = "/",
                        SortIndex             = sortIndex
                    };
                    reportItemPartList.Add(part);
                    sortIndex++;
                }

                if (projectCount > rows)
                {
                    Model.SpManagerTotalMonthItem partNull = new Model.SpManagerTotalMonthItem
                    {
                        ID                    = SQLHelper.GetNewID(typeof(Model.Manager_ManagerTotalMonthItem)),
                        ProjectName           = "项目名称",
                        ExistenceHiddenDanger = "存在隐患",
                        CorrectiveActions     = "整改措施",
                        PlanCompletedDate     = "计划完成时间",
                        ResponsiMan           = "责任人",
                        ActualCompledDate     = "实际完成时间",
                        Remark                = "备注",
                        SortIndex             = sortIndex
                    };
                    reportItemPartList.Add(partNull);
                    sortIndex++;
                }

                rows++;
            }

            return(reportItemPartList);
        }
Beispiel #21
0
        /// <summary>
        /// 插入试卷 4
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="arr"></param>
        public static bool AddEduTrain_TrainTest(string projectId, JArray arr, Model.Sys_User user)
        {
            Model.SUBHSSEDB db   = Funs.DB;
            bool            isOk = true;

            try
            {
                foreach (var item in arr)
                {
                    string trainingId     = null; ////培训记录ID
                    var    getTrainRecord = db.EduTrain_TrainRecord.FirstOrDefault(x => x.FromRecordId == item["RecordId"].ToString());
                    if (getTrainRecord != null)
                    {
                        trainingId = getTrainRecord.TrainingId;
                    }

                    string trainTestId = item["ID"].ToString();
                    if (!string.IsNullOrEmpty(trainingId) && !string.IsNullOrEmpty(trainTestId))
                    {
                        Model.EduTrain_TrainTest newTrainTest = new Model.EduTrain_TrainTest
                        {
                            TrainTestId  = trainTestId,
                            TrainingId   = trainingId,
                            ExamNo       = item["ExamNo"].ToString(),
                            GroupNo      = item["GroupNo"].ToString(),
                            CourseID     = item["CourseID"].ToString(),
                            COrder       = Funs.GetNewInt(item["COrder"].ToString()),
                            QsnCode      = item["QsnCode"].ToString(),
                            QsnId        = item["QsnId"].ToString(),
                            QsnContent   = item["QsnContent"].ToString(),
                            QsnFileName  = item["QsnFileName"].ToString(),
                            QsnAnswer    = item["QsnAnswer"].ToString(),
                            QsnCategory  = item["QsnCategory"].ToString(),
                            QsnKind      = item["QsnKind"].ToString(),
                            Description  = item["Description"].ToString(),
                            QsnImportant = item["QsnImportant"].ToString(),
                            Analysis     = item["Analysis"].ToString(),
                            UploadTime   = Funs.GetNewDateTime(item["UploadTime"].ToString()),
                        };

                        var getTrainRecordDetail = db.EduTrain_TrainTest.FirstOrDefault(x => x.TrainTestId == trainTestId);
                        if (getTrainRecordDetail == null)
                        {
                            EduTrain_TrainTestService.AddTrainTest(newTrainTest);
                        }
                        else
                        {
                            newTrainTest.ExamNo       = newTrainTest.ExamNo;
                            newTrainTest.GroupNo      = newTrainTest.GroupNo;
                            newTrainTest.CourseID     = newTrainTest.CourseID;
                            newTrainTest.COrder       = newTrainTest.COrder;
                            newTrainTest.QsnCode      = newTrainTest.QsnCode;
                            newTrainTest.QsnId        = newTrainTest.QsnId;
                            newTrainTest.QsnContent   = newTrainTest.QsnContent;
                            newTrainTest.QsnFileName  = newTrainTest.QsnFileName;
                            newTrainTest.QsnAnswer    = newTrainTest.QsnAnswer;
                            newTrainTest.QsnCategory  = newTrainTest.QsnCategory;
                            newTrainTest.QsnKind      = newTrainTest.QsnKind;
                            newTrainTest.Description  = newTrainTest.Description;
                            newTrainTest.QsnImportant = newTrainTest.QsnImportant;
                            newTrainTest.Analysis     = newTrainTest.Analysis;
                            newTrainTest.UploadTime   = newTrainTest.UploadTime;
                            db.SubmitChanges();
                        }
                    }
                    else
                    {
                        isOk = false;
                    }
                }
            }
            catch (Exception ex)
            {
                isOk = false;
                ErrLogInfo.WriteLog(string.Empty, ex);
            }
            return(isOk);
        }
Beispiel #22
0
        /// <summary>
        ///  保存专项检查明细项
        /// </summary>
        /// <param name="newDetail"></param>
        public static void SaveCheckSpecialDetail(Model.CheckSpecialDetailItem newDetail)
        {
            if (!string.IsNullOrEmpty(newDetail.CheckSpecialId))
            {
                Model.Check_CheckSpecialDetail newCheckSpecialDetail = new Model.Check_CheckSpecialDetail
                {
                    CheckSpecialId  = newDetail.CheckSpecialId,
                    CheckItem       = newDetail.CheckItemSetId,
                    CheckItemType   = newDetail.CheckItemSetName,
                    Unqualified     = newDetail.Unqualified,
                    UnitId          = newDetail.UnitId,
                    HandleStep      = newDetail.HandleStep,
                    CompleteStatus  = newDetail.CompleteStatus,
                    RectifyNoticeId = newDetail.RectifyNoticeId,
                    LimitedDate     = Funs.GetNewDateTime(newDetail.LimitedDate),
                    CompletedDate   = Funs.GetNewDateTime(newDetail.CompletedDate),
                    Suggestions     = newDetail.Suggestions,
                    WorkArea        = newDetail.WorkArea,
                    CheckArea       = newDetail.WorkAreaId,
                    CheckContent    = newDetail.CheckContent,
                };
                var getUnit = UnitService.GetUnitByUnitId(newDetail.UnitId);
                if (getUnit != null)
                {
                    newCheckSpecialDetail.UnitId = newDetail.UnitId;
                }

                var updateDetail = Funs.DB.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == newDetail.CheckSpecialDetailId);
                if (updateDetail == null)
                {
                    newCheckSpecialDetail.CheckSpecialDetailId = SQLHelper.GetNewID();
                    Funs.DB.Check_CheckSpecialDetail.InsertOnSubmit(newCheckSpecialDetail);
                    Funs.DB.SubmitChanges();
                }
                else
                {
                    newCheckSpecialDetail.CheckSpecialDetailId = updateDetail.CheckSpecialDetailId;
                    updateDetail.CheckItem       = newCheckSpecialDetail.CheckItem;
                    updateDetail.CheckItemType   = newCheckSpecialDetail.CheckItemType;
                    updateDetail.Unqualified     = newCheckSpecialDetail.Unqualified;
                    updateDetail.UnitId          = newCheckSpecialDetail.UnitId;
                    updateDetail.HandleStep      = newCheckSpecialDetail.HandleStep;
                    updateDetail.CompleteStatus  = newCheckSpecialDetail.CompleteStatus;
                    updateDetail.RectifyNoticeId = newCheckSpecialDetail.RectifyNoticeId;
                    updateDetail.LimitedDate     = newCheckSpecialDetail.LimitedDate;
                    updateDetail.CompletedDate   = newCheckSpecialDetail.CompletedDate;
                    updateDetail.Suggestions     = newCheckSpecialDetail.Suggestions;
                    updateDetail.WorkArea        = newCheckSpecialDetail.WorkArea;
                    updateDetail.CheckContent    = newCheckSpecialDetail.CheckContent;
                    Funs.DB.SubmitChanges();
                }
                ////保存附件
                if (!string.IsNullOrEmpty(newDetail.AttachUrl1))
                {
                    UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newDetail.AttachUrl1, 10, null), newDetail.AttachUrl1, Const.ProjectCheckSpecialMenuId, newCheckSpecialDetail.CheckSpecialDetailId);
                }
                else
                {
                    CommonService.DeleteAttachFileById(Const.ProjectCheckSpecialMenuId, newCheckSpecialDetail.CheckSpecialDetailId);
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// 插入人员培训记录 5
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="arr"></param>
        public static bool AddPersonTrainRecord(string projectId, JArray arr, Model.Sys_User user)
        {
            Model.SUBHSSEDB db   = Funs.DB;
            bool            isOk = true;

            try
            {
                foreach (var item in arr)
                {
                    string id = item["ID"].ToString();
                    if (!string.IsNullOrEmpty(id))
                    {
                        bool isPass = false;
                        if (item["IsPass"].ToString() == "1")
                        {
                            isPass = true;
                        }

                        Model.EduTrain_TrainPersonRecord newTrainPersonRecord = new Model.EduTrain_TrainPersonRecord
                        {
                            ID             = id,
                            ProjectId      = projectId,
                            EmpName        = item["EmpName"].ToString(),
                            IdentifyId     = item["IdentifyId"].ToString(),
                            CategoryName   = item["CategoryName"].ToString(),
                            RecordId       = item["RecordId"].ToString(),
                            DepartId       = item["DepartId"].ToString(),
                            DepartName     = item["DepartName"].ToString(),
                            TrainPeriod    = item["TrainPeriod"].ToString(),
                            TotalScore     = item["TotalScore"].ToString(),
                            PassScore      = item["PassScore"].ToString(),
                            Score          = item["Score"].ToString(),
                            IsPass         = isPass,
                            GroupNo        = item["GroupNo"].ToString(),
                            ExamNo         = item["ExamNo"].ToString(),
                            ExamCount      = item["ExamCount"].ToString(),
                            DeviceNo       = item["DeviceNo"].ToString(),
                            OwnerDepartId  = item["OwnerDepartId"].ToString(),
                            Answers        = item["Answers"].ToString(),
                            RecordName     = item["RecordName"].ToString(),
                            TrainType      = item["TrainType"].ToString(),
                            PaperMode      = item["PaperMode"].ToString(),
                            TrainMode      = item["TrainMode"].ToString(),
                            TrainPrincipal = item["TrainPrincipal"].ToString(),
                            TrainStartDate = Funs.GetNewDateTime(item["TrainStartDate"].ToString()),
                            TrainEndDate   = Funs.GetNewDateTime(item["TrainEndDate"].ToString()),
                            TrainContent   = item["TrainContent"].ToString(),
                            TrainDescript  = item["TrainDescript"].ToString(),
                        };

                        var getnewTrainPersonRecord = db.EduTrain_TrainPersonRecord.FirstOrDefault(x => x.ID == id);
                        if (getnewTrainPersonRecord == null)
                        {
                            db.EduTrain_TrainPersonRecord.InsertOnSubmit(newTrainPersonRecord);
                            db.SubmitChanges();
                        }
                        else
                        {
                            db.SubmitChanges();
                        }
                    }
                    else
                    {
                        isOk = false;
                    }
                }
            }
            catch (Exception ex)
            {
                isOk = false;
                ErrLogInfo.WriteLog(string.Empty, ex);
            }
            return(isOk);
        }
Beispiel #24
0
        /// <summary>
        /// 保存TrainingPlan
        /// </summary>
        /// <param name="trainingPlan">培训计划记录</param>
        /// <param name="trainingTasks">培训人员list</param>
        /// <param name="trainingPlanItems">培训教材类型list</param>
        public static void SaveTrainingPlan(Model.TrainingPlanItem trainingPlan)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                Model.Training_Plan newTrainingPlan = new Model.Training_Plan
                {
                    PlanId         = trainingPlan.PlanId,
                    PlanCode       = trainingPlan.PlanCode,
                    ProjectId      = trainingPlan.ProjectId,
                    DesignerId     = trainingPlan.DesignerId,
                    PlanName       = trainingPlan.PlanName,
                    TrainContent   = trainingPlan.TrainContent,
                    TrainStartDate = Funs.GetNewDateTime(trainingPlan.TrainStartDate),
                    TeachHour      = trainingPlan.TeachHour,
                    TeachMan       = trainingPlan.TeachMan,
                    TeachAddress   = trainingPlan.TeachAddress,
                    TrainTypeId    = trainingPlan.TrainTypeId,
                    UnitIds        = trainingPlan.UnitIds,
                    WorkPostId     = trainingPlan.WorkPostId,
                    States         = trainingPlan.States,
                };

                if (!string.IsNullOrEmpty(trainingPlan.TrainLevelId))
                {
                    newTrainingPlan.TrainLevelId = trainingPlan.TrainLevelId;
                }

                if (newTrainingPlan.TrainStartDate.HasValue && newTrainingPlan.TeachHour.HasValue)
                {
                    double dd = (double)((decimal)newTrainingPlan.TeachHour.Value);
                    newTrainingPlan.TrainEndDate = newTrainingPlan.TrainStartDate.Value.AddHours(dd);
                }

                List <Model.TrainingTaskItem>     trainingTasks     = trainingPlan.TrainingTasks;
                List <Model.TrainingPlanItemItem> trainingPlanItems = trainingPlan.TrainingPlanItems;

                var isUpdate = db.Training_Plan.FirstOrDefault(x => x.PlanId == newTrainingPlan.PlanId);
                if (isUpdate == null)
                {
                    newTrainingPlan.DesignerDate = DateTime.Now;
                    string unitId = string.Empty;
                    var    user   = UserService.GetUserByUserId(newTrainingPlan.DesignerId);
                    if (user != null)
                    {
                        unitId = user.UnitId;
                    }
                    newTrainingPlan.PlanCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectTrainingPlanMenuId, newTrainingPlan.ProjectId, unitId);
                    if (string.IsNullOrEmpty(newTrainingPlan.PlanId))
                    {
                        newTrainingPlan.PlanId = SQLHelper.GetNewID();
                    }
                    db.Training_Plan.InsertOnSubmit(newTrainingPlan);
                    db.SubmitChanges();

                    CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTrainingPlanMenuId, newTrainingPlan.ProjectId, null, newTrainingPlan.PlanId, newTrainingPlan.DesignerDate);
                }
                else
                {
                    if (newTrainingPlan.States == "0" || newTrainingPlan.States == "1")
                    {
                        isUpdate.PlanName       = newTrainingPlan.PlanName;
                        isUpdate.TrainContent   = newTrainingPlan.TrainContent;
                        isUpdate.TrainStartDate = newTrainingPlan.TrainStartDate;
                        isUpdate.TeachHour      = newTrainingPlan.TeachHour;
                        isUpdate.TrainEndDate   = newTrainingPlan.TrainEndDate;
                        isUpdate.TeachMan       = newTrainingPlan.TeachMan;
                        isUpdate.TeachAddress   = newTrainingPlan.TeachAddress;
                        isUpdate.TrainTypeId    = newTrainingPlan.TrainTypeId;
                        isUpdate.TrainLevelId   = newTrainingPlan.TrainLevelId;
                        isUpdate.UnitIds        = newTrainingPlan.UnitIds;
                        isUpdate.WorkPostId     = newTrainingPlan.WorkPostId;
                        isUpdate.States         = newTrainingPlan.States;
                        db.SubmitChanges();
                    }
                    ////删除培训任务
                    var tasks = from x in db.Training_Task where x.PlanId == newTrainingPlan.PlanId select x;
                    if (tasks.Count() > 0)
                    {
                        var taskItems = from x in db.Training_TaskItem where x.PlanId == newTrainingPlan.PlanId select x;
                        if (tasks.Count() > 0)
                        {
                            db.Training_TaskItem.DeleteAllOnSubmit(taskItems);
                            db.SubmitChanges();
                        }
                        db.Training_Task.DeleteAllOnSubmit(tasks);
                        db.SubmitChanges();
                    }

                    ////删除培训教材类型
                    var planItem = (from x in db.Training_PlanItem where x.PlanId == newTrainingPlan.PlanId select x).ToList();
                    if (planItem.Count() > 0)
                    {
                        db.Training_PlanItem.DeleteAllOnSubmit(planItem);
                        db.SubmitChanges();
                    }
                }

                if (trainingTasks.Count() > 0)
                {
                    ////新增培训人员明细
                    foreach (var item in trainingTasks)
                    {
                        if (!string.IsNullOrEmpty(item.PersonId))
                        {
                            Model.Training_Task newTrainDetail = new Model.Training_Task
                            {
                                TaskId    = SQLHelper.GetNewID(),
                                ProjectId = newTrainingPlan.ProjectId,
                                PlanId    = newTrainingPlan.PlanId,
                                UserId    = item.PersonId,
                                TaskDate  = DateTime.Now,
                                States    = Const.State_0, ////未生成培训教材明细
                            };
                            db.Training_Task.InsertOnSubmit(newTrainDetail);
                            db.SubmitChanges();
                        }
                    }
                }
                if (trainingPlanItems.Count() > 0)
                {
                    ////新增培训教材类型明细
                    foreach (var item in trainingPlanItems)
                    {
                        if (!string.IsNullOrEmpty(item.CompanyTrainingId) || !string.IsNullOrEmpty(item.CompanyTrainingItemId))
                        {
                            Model.Training_PlanItem newPlanItem = new Model.Training_PlanItem
                            {
                                PlanItemId = SQLHelper.GetNewID(),
                                PlanId     = newTrainingPlan.PlanId,
                            };
                            if (!string.IsNullOrEmpty(item.CompanyTrainingId))
                            {
                                newPlanItem.CompanyTrainingId = item.CompanyTrainingId;
                            }
                            if (!string.IsNullOrEmpty(item.CompanyTrainingItemId))
                            {
                                newPlanItem.CompanyTrainingItemId = item.CompanyTrainingItemId;
                            }
                            db.Training_PlanItem.InsertOnSubmit(newPlanItem);
                            db.SubmitChanges();
                        }
                    }
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// 保存Check_PunishNotice
        /// </summary>
        /// <param name="newItem">处罚通知单</param>
        /// <returns></returns>
        public static void SavePunishNotice(Model.PunishNoticeItem newItem)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                Model.Check_PunishNotice newPunishNotice = new Model.Check_PunishNotice
                {
                    PunishNoticeId   = newItem.PunishNoticeId,
                    PunishNoticeCode = newItem.PunishNoticeCode,
                    ProjectId        = newItem.ProjectId,
                    PunishNoticeDate = Funs.GetNewDateTime(newItem.PunishNoticeDate),
                    UnitId           = newItem.UnitId,
                    ContractNum      = newItem.ContractNum,
                    IncentiveReason  = newItem.IncentiveReason,
                    BasicItem        = newItem.BasicItem,
                    PunishMoney      = newItem.PunishMoney,
                    Currency         = newItem.Currency,
                    FileContents     = System.Web.HttpUtility.HtmlEncode(newItem.FileContents),
                    States           = Const.State_0,
                    PunishStates     = newItem.PunishStates,
                };

                if (!string.IsNullOrEmpty(newItem.CompileManId))
                {
                    newPunishNotice.CompileMan = newItem.CompileManId;
                }
                if (newPunishNotice.PunishStates == Const.State_1)
                {
                    newPunishNotice.SignMan = newItem.SignManId;
                }

                var getUpdate = db.Check_PunishNotice.FirstOrDefault(x => x.PunishNoticeId == newItem.PunishNoticeId);
                if (getUpdate == null)
                {
                    newPunishNotice.CompileDate      = DateTime.Now;
                    newPunishNotice.PunishNoticeId   = SQLHelper.GetNewID();
                    newPunishNotice.PunishNoticeCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectPunishNoticeMenuId, newPunishNotice.ProjectId, newPunishNotice.UnitId);
                    db.Check_PunishNotice.InsertOnSubmit(newPunishNotice);
                    db.SubmitChanges();
                    CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectPunishNoticeMenuId, newPunishNotice.ProjectId, newPunishNotice.UnitId, newPunishNotice.PunishNoticeId, newPunishNotice.CompileDate);

                    //// 回写巡检记录表
                    if (!string.IsNullOrEmpty(newItem.HazardRegisterId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(newItem.HazardRegisterId, ',');
                        foreach (var item in listIds)
                        {
                            var getHazardRegister = db.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == item);
                            if (getHazardRegister != null)
                            {
                                getHazardRegister.States      = "3";
                                getHazardRegister.HandleIdea += "已下发处罚通知单:" + newPunishNotice.PunishNoticeCode;
                                getHazardRegister.ResultId    = newPunishNotice.PunishNoticeId;
                                getHazardRegister.ResultType  = "2";
                                db.SubmitChanges();
                            }
                        }
                    }

                    //// 回写专项检查明细表
                    if (!string.IsNullOrEmpty(newItem.CheckSpecialDetailId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(newItem.CheckSpecialDetailId, ',');
                        foreach (var item in listIds)
                        {
                            var getCheckSpecialDetail = db.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == item);
                            if (getCheckSpecialDetail != null)
                            {
                                getCheckSpecialDetail.DataType = "2";
                                getCheckSpecialDetail.DataId   = newPunishNotice.PunishNoticeId;
                                db.SubmitChanges();
                            }
                        }
                    }
                }
                else
                {
                    newPunishNotice.PunishNoticeId = getUpdate.PunishNoticeId;
                    getUpdate.PunishStates         = newItem.PunishStates;
                    if (newPunishNotice.PunishStates == "0" || newPunishNotice.PunishStates == "1")  ////编制人 修改或提交
                    {
                        getUpdate.PunishNoticeDate = newPunishNotice.PunishNoticeDate;
                        getUpdate.UnitId           = newPunishNotice.UnitId;
                        getUpdate.ContractNum      = newPunishNotice.ContractNum;
                        getUpdate.IncentiveReason  = newPunishNotice.IncentiveReason;
                        getUpdate.BasicItem        = newPunishNotice.BasicItem;
                        getUpdate.PunishMoney      = newPunishNotice.PunishMoney;
                        getUpdate.Currency         = newPunishNotice.Currency;
                        getUpdate.FileContents     = newPunishNotice.FileContents;
                        if (newPunishNotice.PunishStates == "1" && !string.IsNullOrEmpty(newItem.SignManId))
                        {
                            getUpdate.SignMan = newItem.SignManId;
                        }
                        else
                        {
                            newPunishNotice.PunishStates = getUpdate.PunishStates = "0";
                        }
                        db.SubmitChanges();
                    }
                    else if (newPunishNotice.PunishStates == "2") ////【签发】总包安全经理
                    {
                        /// 不同意 打回 同意抄送专业工程师、施工经理、相关施工分包单位并提交【批准】总包项目经理
                        if (newItem.IsAgree == false)
                        {
                            newPunishNotice.PunishStates = getUpdate.PunishStates = "0";
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(newItem.ProfessionalEngineerId))
                            {
                                getUpdate.ProfessionalEngineerId = newItem.ProfessionalEngineerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.ConstructionManagerId))
                            {
                                getUpdate.ConstructionManagerId = newItem.ConstructionManagerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.UnitHeadManId))
                            {
                                getUpdate.UnitHeadManId = newItem.UnitHeadManId;
                            }
                            if (!string.IsNullOrEmpty(newItem.ApproveManId))
                            {
                                getUpdate.ApproveMan = newItem.ApproveManId;
                                getUpdate.SignDate   = DateTime.Now;
                            }
                            else
                            {
                                newPunishNotice.PunishStates = getUpdate.States = "1";
                            }
                        }
                        db.SubmitChanges();
                    }
                    else if (newPunishNotice.PunishStates == "3") ////【批准】总包项目经理
                    {
                        /// 不同意 打回 同意下发【回执】施工分包单位
                        if (newItem.IsAgree == false || string.IsNullOrEmpty(newItem.DutyPersonId))
                        {
                            newPunishNotice.PunishStates = getUpdate.PunishStates = "1";
                        }
                        else
                        {
                            getUpdate.DutyPersonId = newItem.DutyPersonId;
                            getUpdate.ApproveDate  = DateTime.Now;
                        }
                        db.SubmitChanges();
                    }
                    else if (newPunishNotice.PunishStates == "4") ////【批准】总包项目经理
                    {
                        /// 不同意 打回 同意下发【回执】施工分包单位
                        if (string.IsNullOrEmpty(newItem.ReceiptUrl))
                        {
                            newPunishNotice.PunishStates = getUpdate.PunishStates = "3";
                        }
                        else
                        {
                            getUpdate.DutyPersonDate = DateTime.Now;
                            getUpdate.States         = Const.State_2;
                        }
                        db.SubmitChanges();
                    }
                }

                if (newItem.PunishStates == Const.State_0 || newItem.PunishStates == Const.State_1)
                {     //// 通知单附件
                    APIUpLoadFileService.SaveAttachUrl(Const.ProjectPunishNoticeStatisticsMenuId, newPunishNotice.PunishNoticeId, newItem.PunishUrl, "0");
                }
                if (newItem.PunishStates == Const.State_4)
                {     //// 回执单附件
                    APIUpLoadFileService.SaveAttachUrl(Const.ProjectPunishNoticeMenuId, newPunishNotice.PunishNoticeId, newItem.ReceiptUrl, "0");
                }
                if (getUpdate != null && getUpdate.States == Const.State_2)
                {
                    CommonService.btnSaveData(newPunishNotice.ProjectId, Const.ProjectPunishNoticeMenuId, newPunishNotice.PunishNoticeId, newPunishNotice.CompileMan, true, newPunishNotice.PunishNoticeCode, "../Check/PunishNoticeView.aspx?PunishNoticeId={0}");
                    var getcheck = from x in db.Check_CheckSpecialDetail where x.DataId == getUpdate.PunishNoticeId select x;
                    if (getcheck.Count() > 0)
                    {
                        foreach (var item in getcheck)
                        {
                            item.CompleteStatus = true;
                            item.CompletedDate  = DateTime.Now;
                            db.SubmitChanges();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 人员资质信息保存方法
        /// </summary>
        /// <param name="personQuality">人员信息</param>
        public static void SavePersonQuality(Model.PersonQualityItem personQuality)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                if (personQuality.QualityType == "1")
                {
                    Model.QualityAudit_PersonQuality newPersonQuality = new Model.QualityAudit_PersonQuality
                    {
                        PersonQualityId = personQuality.PersonQualityId,
                        PersonId        = personQuality.PersonId,
                        CertificateNo   = personQuality.CertificateNo,
                        CertificateName = personQuality.CertificateName,
                        Grade           = personQuality.Grade,
                        SendUnit        = personQuality.SendUnit,
                        SendDate        = Funs.GetNewDateTime(personQuality.SendDate),
                        LimitDate       = Funs.GetNewDateTime(personQuality.LimitDate),
                        LateCheckDate   = Funs.GetNewDateTime(personQuality.LateCheckDate),
                        ApprovalPerson  = personQuality.ApprovalPerson,
                        Remark          = personQuality.Remark,
                        CompileDate     = Funs.GetNewDateTime(personQuality.CompileDate),
                        AuditOpinion    = personQuality.AuditOpinion,
                        States          = personQuality.States,
                    };
                    if (newPersonQuality.States == Const.State_2 || newPersonQuality.States == Const.State_R)
                    {
                        newPersonQuality.AuditDate = DateTime.Now;
                    }
                    else
                    {
                        newPersonQuality.AuditDate = null;
                    }
                    if (!string.IsNullOrEmpty(personQuality.CertificateId))
                    {
                        newPersonQuality.CertificateId = personQuality.CertificateId;
                    }
                    if (!string.IsNullOrEmpty(personQuality.CompileMan))
                    {
                        newPersonQuality.CompileMan = personQuality.CompileMan;
                    }
                    if (!string.IsNullOrEmpty(personQuality.AuditorId))
                    {
                        newPersonQuality.AuditorId = personQuality.AuditorId;
                    }
                    var getPersonQuality = db.QualityAudit_PersonQuality.FirstOrDefault(x => x.PersonQualityId == newPersonQuality.PersonQualityId || x.PersonId == newPersonQuality.PersonId);
                    if (getPersonQuality == null)
                    {
                        newPersonQuality.PersonQualityId = SQLHelper.GetNewID();
                        newPersonQuality.CompileDate     = DateTime.Now;
                        db.QualityAudit_PersonQuality.InsertOnSubmit(newPersonQuality);
                        db.SubmitChanges();
                    }
                    else
                    {
                        newPersonQuality.PersonQualityId = getPersonQuality.PersonQualityId;
                        getPersonQuality.CertificateId   = newPersonQuality.CertificateId;
                        getPersonQuality.CertificateNo   = newPersonQuality.CertificateNo;
                        getPersonQuality.CertificateName = newPersonQuality.CertificateName;
                        getPersonQuality.Grade           = newPersonQuality.Grade;
                        getPersonQuality.SendUnit        = newPersonQuality.SendUnit;
                        getPersonQuality.SendDate        = newPersonQuality.SendDate;
                        getPersonQuality.LimitDate       = newPersonQuality.LimitDate;
                        getPersonQuality.LateCheckDate   = newPersonQuality.LateCheckDate;
                        getPersonQuality.Remark          = newPersonQuality.Remark;
                        getPersonQuality.AuditDate       = newPersonQuality.AuditDate;
                        getPersonQuality.AuditorId       = newPersonQuality.AuditorId;
                        getPersonQuality.States          = newPersonQuality.States;
                        db.SubmitChanges();
                    }
                    if (!string.IsNullOrEmpty(newPersonQuality.PersonQualityId))
                    {
                        APIUpLoadFileService.SaveAttachUrl(Const.PersonQualityMenuId, newPersonQuality.PersonQualityId, personQuality.AttachUrl, "0");
                    }
                }
                else if (personQuality.QualityType == "2")
                {
                    Model.QualityAudit_SafePersonQuality newSafeQuality = new Model.QualityAudit_SafePersonQuality
                    {
                        SafePersonQualityId = personQuality.PersonQualityId,
                        PersonId            = personQuality.PersonId,
                        CertificateNo       = personQuality.CertificateNo,
                        CertificateName     = personQuality.CertificateName,
                        Grade          = personQuality.Grade,
                        SendUnit       = personQuality.SendUnit,
                        SendDate       = Funs.GetNewDateTime(personQuality.SendDate),
                        LimitDate      = Funs.GetNewDateTime(personQuality.LimitDate),
                        LateCheckDate  = Funs.GetNewDateTime(personQuality.LateCheckDate),
                        ApprovalPerson = personQuality.ApprovalPerson,
                        Remark         = personQuality.Remark,
                        CompileDate    = Funs.GetNewDateTime(personQuality.CompileDate),
                        AuditDate      = Funs.GetNewDateTime(personQuality.AuditDate),
                        AuditOpinion   = personQuality.AuditOpinion,
                        States         = personQuality.States,
                    };
                    if (newSafeQuality.States == Const.State_2 || newSafeQuality.States == Const.State_R)
                    {
                        newSafeQuality.AuditDate = DateTime.Now;
                    }
                    else
                    {
                        newSafeQuality.AuditDate = null;
                    }
                    //if (!string.IsNullOrEmpty(personQuality.CertificateId))
                    //{
                    //    newSafeQuality.CertificateId = personQuality.CertificateId;
                    //}
                    if (!string.IsNullOrEmpty(personQuality.CompileMan))
                    {
                        newSafeQuality.CompileMan = personQuality.CompileMan;
                    }
                    if (!string.IsNullOrEmpty(personQuality.AuditorId))
                    {
                        newSafeQuality.AuditorId = personQuality.AuditorId;
                    }
                    var getSafePersonQuality = db.QualityAudit_SafePersonQuality.FirstOrDefault(x => x.SafePersonQualityId == newSafeQuality.SafePersonQualityId || x.PersonId == newSafeQuality.PersonId);
                    if (getSafePersonQuality == null)
                    {
                        newSafeQuality.SafePersonQualityId = SQLHelper.GetNewID();
                        newSafeQuality.CompileDate         = DateTime.Now;
                        db.QualityAudit_SafePersonQuality.InsertOnSubmit(newSafeQuality);
                        db.SubmitChanges();
                    }
                    else
                    {
                        newSafeQuality.SafePersonQualityId = getSafePersonQuality.SafePersonQualityId;
                        //getPersonQuality.CertificateId = newSafeQuality.CertificateId;
                        getSafePersonQuality.CertificateNo   = newSafeQuality.CertificateNo;
                        getSafePersonQuality.CertificateName = newSafeQuality.CertificateName;
                        getSafePersonQuality.Grade           = newSafeQuality.Grade;
                        getSafePersonQuality.SendUnit        = newSafeQuality.SendUnit;
                        getSafePersonQuality.SendDate        = newSafeQuality.SendDate;
                        getSafePersonQuality.LimitDate       = newSafeQuality.LimitDate;
                        getSafePersonQuality.LateCheckDate   = newSafeQuality.LateCheckDate;
                        getSafePersonQuality.Remark          = newSafeQuality.Remark;
                        getSafePersonQuality.AuditDate       = newSafeQuality.AuditDate;
                        getSafePersonQuality.AuditorId       = newSafeQuality.AuditorId;
                        getSafePersonQuality.States          = newSafeQuality.States;
                        db.SubmitChanges();
                    }
                    if (!string.IsNullOrEmpty(newSafeQuality.SafePersonQualityId))
                    {
                        APIUpLoadFileService.SaveAttachUrl(Const.SafePersonQualityMenuId, newSafeQuality.SafePersonQualityId, personQuality.AttachUrl, "0");
                    }
                }
                //// 特种设备作业人员
                if (personQuality.QualityType == "3")
                {
                    Model.QualityAudit_EquipmentPersonQuality newEquipmentPersonQuality = new Model.QualityAudit_EquipmentPersonQuality
                    {
                        EquipmentPersonQualityId = personQuality.PersonQualityId,
                        PersonId        = personQuality.PersonId,
                        CertificateNo   = personQuality.CertificateNo,
                        CertificateName = personQuality.CertificateName,
                        Grade           = personQuality.Grade,
                        SendUnit        = personQuality.SendUnit,
                        SendDate        = Funs.GetNewDateTime(personQuality.SendDate),
                        LimitDate       = Funs.GetNewDateTime(personQuality.LimitDate),
                        LateCheckDate   = Funs.GetNewDateTime(personQuality.LateCheckDate),
                        ApprovalPerson  = personQuality.ApprovalPerson,
                        Remark          = personQuality.Remark,
                        CompileDate     = Funs.GetNewDateTime(personQuality.CompileDate),
                        AuditDate       = Funs.GetNewDateTime(personQuality.AuditDate),
                        AuditOpinion    = personQuality.AuditOpinion,
                        States          = personQuality.States,
                    };
                    if (newEquipmentPersonQuality.States == Const.State_2 || newEquipmentPersonQuality.States == Const.State_R)
                    {
                        newEquipmentPersonQuality.AuditDate = DateTime.Now;
                    }
                    else
                    {
                        newEquipmentPersonQuality.AuditDate = null;
                    }
                    if (!string.IsNullOrEmpty(personQuality.CertificateId))
                    {
                        newEquipmentPersonQuality.CertificateId = personQuality.CertificateId;
                    }
                    if (!string.IsNullOrEmpty(personQuality.CompileMan))
                    {
                        newEquipmentPersonQuality.CompileMan = personQuality.CompileMan;
                    }
                    if (!string.IsNullOrEmpty(personQuality.AuditorId))
                    {
                        newEquipmentPersonQuality.AuditorId = personQuality.AuditorId;
                    }
                    var getEquipmentPersonQuality = db.QualityAudit_EquipmentPersonQuality.FirstOrDefault(x => x.EquipmentPersonQualityId == newEquipmentPersonQuality.EquipmentPersonQualityId || x.PersonId == newEquipmentPersonQuality.PersonId);
                    if (getEquipmentPersonQuality == null)
                    {
                        newEquipmentPersonQuality.EquipmentPersonQualityId = SQLHelper.GetNewID();
                        newEquipmentPersonQuality.CompileDate = DateTime.Now;
                        db.QualityAudit_EquipmentPersonQuality.InsertOnSubmit(newEquipmentPersonQuality);
                        db.SubmitChanges();
                    }
                    else
                    {
                        newEquipmentPersonQuality.EquipmentPersonQualityId = getEquipmentPersonQuality.EquipmentPersonQualityId;
                        getEquipmentPersonQuality.CertificateId            = newEquipmentPersonQuality.CertificateId;
                        getEquipmentPersonQuality.CertificateNo            = newEquipmentPersonQuality.CertificateNo;
                        getEquipmentPersonQuality.CertificateName          = newEquipmentPersonQuality.CertificateName;
                        getEquipmentPersonQuality.Grade         = newEquipmentPersonQuality.Grade;
                        getEquipmentPersonQuality.SendUnit      = newEquipmentPersonQuality.SendUnit;
                        getEquipmentPersonQuality.SendDate      = newEquipmentPersonQuality.SendDate;
                        getEquipmentPersonQuality.LimitDate     = newEquipmentPersonQuality.LimitDate;
                        getEquipmentPersonQuality.LateCheckDate = newEquipmentPersonQuality.LateCheckDate;
                        getEquipmentPersonQuality.Remark        = newEquipmentPersonQuality.Remark;
                        getEquipmentPersonQuality.AuditDate     = newEquipmentPersonQuality.AuditDate;
                        getEquipmentPersonQuality.AuditorId     = newEquipmentPersonQuality.AuditorId;
                        getEquipmentPersonQuality.States        = newEquipmentPersonQuality.States;
                        db.SubmitChanges();
                    }
                    if (!string.IsNullOrEmpty(newEquipmentPersonQuality.EquipmentPersonQualityId))
                    {
                        APIUpLoadFileService.SaveAttachUrl(Const.EquipmentPersonQualityMenuId, newEquipmentPersonQuality.EquipmentPersonQualityId, personQuality.AttachUrl, "0");
                    }
                }

                if (!string.IsNullOrEmpty(personQuality.AuditDate) && string.IsNullOrEmpty(personQuality.AuditorId))
                {
                    APICommonService.SendSubscribeMessage(personQuality.AuditorId, "人员资质" + personQuality.PersonName + "待您审核", personQuality.CompileManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
                }
            }
        }