Esempio n. 1
0
 /// <summary>
 /// 定时推送待办 订阅服务内容
 /// </summary>
 public static void SendSubscribeMessage()
 {
     try
     {
         string miniprogram_state = ConfigurationManager.AppSettings["miniprogram_state"];
         if (!string.IsNullOrEmpty(miniprogram_state) && miniprogram_state == "formal")
         {
             //// 获取所有待办事项
             var getToItems = from x in Funs.DB.View_APP_GetToDoItems select x;
             if (getToItems.Count() > 0)
             {
                 //// 获取施工中的项目
                 var getProjects = ProjectService.GetProjectWorkList();
                 foreach (var item in getProjects)
                 {
                     ////获取当前项目下的待办
                     var getPItems = getToItems.Where(x => x.ProjectId == item.ProjectId);
                     if (getPItems.Count() > 0)
                     {
                         foreach (var itemP in getPItems)
                         {
                             APICommonService.SendSubscribeMessage(itemP.UserId, "项目【" + item.ProjectCode + "】上有" + itemP.Counts.ToString() + "条待办事件,需要您处理!", "赛鼎施工管理系统", string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     { }
 }
Esempio n. 2
0
        /// <summary>
        /// 发送订阅消息
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="thing2"></param>
        /// <param name="name1"></param>
        /// <param name="date3"></param>
        public static string SendSubscribeMessage(string userId, string thing2, string name1, string date3)
        {
            string access_token = APICommonService.getaccess_token();
            var    getUser      = Funs.DB.Sys_User.FirstOrDefault(x => x.UserId == userId);

            if (getUser != null && !string.IsNullOrEmpty(getUser.OpenId))
            {
                string miniprogram_state = ConfigurationManager.AppSettings["miniprogram_state"];
                if (string.IsNullOrEmpty(miniprogram_state))
                {
                    miniprogram_state = "formal";
                }
                string contenttype = "application/json;charset=utf-8";
                string url         = $"https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={access_token}";
                var    tempData    = new
                {
                    access_token,
                    touser      = getUser.OpenId,
                    template_id = Const.WX_TemplateID,
                    page        = "pages/home/main",
                    data        = new
                    {
                        thing2 = new { value = thing2 },
                        name1  = new { value = name1 },
                        date3  = new { value = date3 }
                    },
                    miniprogram_state,
                    lang = "zh_CN",
                };
                string messages = APIGetHttpService.Http(url, "POST", contenttype, null, JsonConvert.SerializeObject(tempData));
                //// 记录
                SaveSysHttpLog(getUser.UserName, url, messages);
                return(messages);
            }
            else
            {
                return("openId is null");
            }
        }
Esempio n. 3
0
        /// <summary>
        ///  获取身份证信息
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string ReadIDCardInfo(string url)
        {
            string access_token = APICommonService.getaccess_token();

            return(APIGetHttpService.Http("https://api.weixin.qq.com/cv/ocr/idcard?type=photo&img_url=" + url + "&access_token=" + access_token, "POST"));
        }
Esempio n. 4
0
        /// <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));
                }
            }
        }
Esempio n. 5
0
        /// <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));
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 保存HazardRegister
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public static void SaveHazardRegister(Model.HazardRegisterItem hazardRegister)
        {
            Model.HSSE_Hazard_HazardRegister newHazardRegister = new Model.HSSE_Hazard_HazardRegister
            {
                HazardRegisterId      = hazardRegister.HazardRegisterId,
                HazardCode            = hazardRegister.HazardCode,
                RegisterDef           = hazardRegister.RegisterDef,
                Rectification         = hazardRegister.Rectification,
                Place                 = hazardRegister.Place,
                ResponsibleUnit       = hazardRegister.ResponsibleUnit,
                ProjectId             = hazardRegister.ProjectId,
                States                = hazardRegister.States,
                IsEffective           = "1",
                ResponsibleMan        = hazardRegister.ResponsibleMan,
                CheckManId            = hazardRegister.CheckManId,
                CheckTime             = hazardRegister.CheckTime,
                RectificationPeriod   = hazardRegister.RectificationPeriod,
                ImageUrl              = hazardRegister.ImageUrl,
                RectificationImageUrl = hazardRegister.RectificationImageUrl,
                RectificationTime     = hazardRegister.RectificationTime,
                ConfirmMan            = hazardRegister.ConfirmMan,
                ConfirmDate           = hazardRegister.ConfirmDate,
                HandleIdea            = hazardRegister.HandleIdea,
                CutPayment            = hazardRegister.CutPayment,
                ProblemTypes          = hazardRegister.ProblemTypes,
                RegisterTypesId       = hazardRegister.RegisterTypesId,
                CheckCycle            = hazardRegister.CheckCycle,
                SafeSupervisionIsOK   = hazardRegister.SafeSupervisionIsOK,
                IsWx         = "Y",
                CCManIds     = hazardRegister.CCManIds,
                Requirements = hazardRegister.Requirements,
            };
            var isUpdate = Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == newHazardRegister.HazardRegisterId);

            if (isUpdate == null)
            {
                newHazardRegister.RegisterDate = DateTime.Now;
                newHazardRegister.CheckTime    = DateTime.Now;
                if (string.IsNullOrEmpty(newHazardRegister.HazardRegisterId))
                {
                    newHazardRegister.HazardRegisterId = SQLHelper.GetNewID();
                }
                Funs.DB.HSSE_Hazard_HazardRegister.InsertOnSubmit(newHazardRegister);
            }
            else
            {
                if (newHazardRegister.States == "2")
                {
                    isUpdate.RectificationTime     = DateTime.Now;
                    isUpdate.Rectification         = newHazardRegister.Rectification;
                    isUpdate.RectificationImageUrl = newHazardRegister.RectificationImageUrl;
                }
                else
                {
                    isUpdate.ConfirmDate         = DateTime.Now;
                    isUpdate.ConfirmMan          = newHazardRegister.ConfirmMan;
                    isUpdate.HandleIdea          = newHazardRegister.HandleIdea;
                    isUpdate.SafeSupervisionIsOK = newHazardRegister.SafeSupervisionIsOK;
                }

                isUpdate.States = newHazardRegister.States;
            }
            Funs.SubmitChanges();

            if (hazardRegister.States == Const.State_1)
            {
                APICommonService.SendSubscribeMessage(hazardRegister.ResponsibleMan, "安全巡检问题待整改", hazardRegister.CheckManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", hazardRegister.CheckTime));
            }
            else if (hazardRegister.States == Const.State_2)
            {
                APICommonService.SendSubscribeMessage(hazardRegister.CheckManId, "安全巡检待复查验收", hazardRegister.ResponsibilityManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", hazardRegister.RectificationTime));
            }
        }