Esempio n. 1
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, JobApprovalFormEntity entity, List <ManyPowerCheckEntity> data, string arr)
        {
            try
            {
                service.SaveForm(keyValue, entity, data, arr);
                if (entity.IsSubmit == 1)
                {
                    UserBLL userbll = new UserBLL();
                    DangerousJobFlowDetailEntity flow = DangerousJobFlowDetailIService.GetList().Where(t => t.BusinessId == entity.Id && t.Status == 0).FirstOrDefault();
                    string    userids = DangerousJobFlowDetailIService.GetCurrentStepUser(entity.Id, flow.Id);
                    DataTable dt      = userbll.GetUserTable(userids.Split(','));
                    entity = service.GetEntity(entity.Id);
                    entity.JobLevelName = dataitemdetailbll.GetItemName("DangerousJobCheck", entity.JobLevel);

                    JPushApi.PushMessage(string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("account")).ToArray()), string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("realname")).ToArray()), "WXZY001", entity.JobLevelName + "审批单(" + entity.JobTypeName + ")申请待您审批,请您及时处理。", entity.CreateUserName + "于" + entity.CreateDate.Value.ToString("yyyy年MM月dd日") + "申请的" + entity.JobLevelName + "审批单(" + entity.JobTypeName + ")需要您进行审批,请您及时处理。", entity.Id);
                }
                //if (entity.FlowState == "1")
                //{
                //    UserBLL userbll = new UserBLL();
                //    UserEntity userEntity = userbll.GetEntity(entity.DutyPersonId);//获取责任人用户信息
                //    JPushApi.PushMessage(userEntity.Account, entity.DutyPerson, "GZDB001", "例行安全工作", entity.Id);
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, JobApprovalFormEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult SaveCancelReason(string keyValue, JobApprovalFormEntity entity)
 {
     try
     {
         Operator user    = OperatorProvider.Provider.Current();
         var      entity1 = JobApprovalFormbll.GetEntity(keyValue);
         if (entity1 != null)
         {
             entity1.CancelReason   = entity.CancelReason;
             entity1.CancelTime     = DateTime.Now;
             entity1.CancelUserId   = user.UserId;
             entity1.CancelUserName = user.UserName;
             entity1.JobState       = 3;//更改状态(作废)
             JobApprovalFormbll.SaveForm(keyValue, entity1);
         }
         return(Success("操作成功。"));
     }
     catch (Exception ex)
     {
         return(Error("操作失败。"));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 开始作业
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="ledgerType"></param>
        /// <param name="type"></param>
        /// <param name="worktime"></param>
        /// <param name="issendmessage"></param>
        /// <param name="conditioncontent"></param>
        /// <param name="conditionid"></param>
        /// <param name="iscomplete"></param>
        public void LedgerOp(string keyValue, string ledgerType, string type, string worktime, string issendmessage, string conditioncontent, string conditionid = "", string iscomplete = "")
        {
            string title   = string.Empty;
            string message = string.Empty;
            var    time    = Convert.ToDateTime(worktime);

            Operator curUser             = OperatorProvider.Provider.Current();
            JobApprovalFormEntity entity = service.GetEntity(keyValue);

            string sql = "";

            if (type == "HeightWorking" || type == "Lifting" || type == "Digging" || type == "OpenCircuit" || type == "WhenHot" || type == "BlindPlateWall" || type == "LimitedSpace" || type == "EquOverhaulClean")
            {
                if (ledgerType == "0")
                {
                    sql = string.Format(@"update bis_jobsafetycardapply set realityjobstarttime=to_date('{1}','yyyy-mm-dd hh24:mi:ss')," +
                                        "jobstate=10,RealityJobEndTime='' where id='{0}'", keyValue, time.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                else if (ledgerType == "1")
                {
                    int jobstate = 9;
                    if (iscomplete == "0")
                    {
                        jobstate = 9;//状态为作业暂停
                    }
                    else
                    {
                        UserBLL userbll = new UserBLL();
                        JobSafetyCardApplyBLL    JobSafetyCardApplyBLL = new JobSafetyCardApplyBLL();
                        JobSafetyCardApplyEntity data = JobSafetyCardApplyBLL.GetEntity(keyValue);
                        if (type == "OpenCircuit")
                        {
                            jobstate = 6; //断路作业 结束作业后下一步流程为验收   状态值改为验收中:6
                            DataTable dt = userbll.GetUserTable(data.CheckPersonId.Split(','));
                            JPushApi.PushMessage(string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("account")).ToArray()), data.CheckPerson, "ZYAQZ004", data.JobTypeName + "安全证待您进行作业后验收,请您及时处理。", data.CreateUserName + "于" + data.CreateDate.Value.ToString("yyyy年MM月dd日") + "申请的" + data.JobTypeName + "安全证需要您进行作业后验收,请您及时处理。", data.Id);
                        }
                        else if (type == "EquOverhaulClean")
                        {
                            jobstate = 7; //设备检修清理作业 结束作业后下一步流程为送电  状态值改为送电中:7
                            DataTable dt = userbll.GetUserTable(data.PowerGivePersonId.Split(','));
                            JPushApi.PushMessage(string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("account")).ToArray()), data.PowerGivePerson, "ZYAQZ010", data.JobTypeName + "已结束,待您进行送电,请您及时处理。", data.CreateUserName + "于" + data.CreateDate.Value.ToString("yyyy年MM月dd日") + "申请的" + data.JobTypeName + "已结束,需要您进行送电操作,请您及时处理。", data.Id);
                        }
                        else
                        {
                            jobstate = 11; //其他作业  作业结束即为整个流程结束  状态值为11
                        }
                    }
                    sql = string.Format("update bis_jobsafetycardapply set jobstate={2},realityjobendtime=to_date('{1}','yyyy-mm-dd hh24:mi:ss') where id='{0}'",
                                        keyValue, time.ToString("yyyy-MM-dd HH:mm:ss"), jobstate);
                }
            }
            else
            {
                if (ledgerType == "0")
                {
                    entity.RealityJobStartTime = time;

                    sql = string.Format(@"update BIS_JobApprovalForm set RealityJobStartTime=to_date('{1}','yyyy-mm-dd hh24:mi:ss')," +
                                        "WorkOperate='0',RealityJobEndTime='' where id='{0}'", keyValue, time.ToString("yyyy-MM-dd HH:mm:ss"));
                    entity.WorkOperate       = "0";
                    entity.RealityJobEndTime = null;
                }
                if (ledgerType == "1")
                {
                    entity.RealityJobEndTime = time;
                    if (iscomplete == "0")
                    {
                        entity.WorkOperate = "1";
                    }
                    sql = string.Format("update BIS_JobApprovalForm set WorkOperate='{2}',RealityJobEndTime=to_date('{1}','yyyy-mm-dd hh24:mi:ss') where id='{0}'",
                                        keyValue, time.ToString("yyyy-MM-dd HH:mm:ss"), entity.WorkOperate);
                }
                //更新作业安全证状态
                UpdateGerOp(keyValue, ledgerType, type, worktime, issendmessage, conditioncontent, conditionid, iscomplete);
            }
            service.UpdateData(sql);
            #region 添加执行情况信息
            FireWaterCondition Conditionentity = new FireWaterCondition();
            Conditionentity.Id                = !string.IsNullOrEmpty(conditionid) ? conditionid : "";
            Conditionentity.LedgerType        = ledgerType;
            Conditionentity.ConditionTime     = time;
            Conditionentity.ConditionContent  = conditioncontent;
            Conditionentity.ConditionDept     = curUser.DeptName;
            Conditionentity.ConditionDeptCode = curUser.DeptCode;
            Conditionentity.ConditionDeptId   = curUser.DeptId;
            Conditionentity.ConditionPerson   = curUser.UserName;
            Conditionentity.ConditionPersonId = curUser.UserId;
            Conditionentity.FireWaterId       = keyValue;
            firewaterbll.SubmitCondition(conditionid, Conditionentity);

            #endregion
        }
        public ActionResult SaveForm(string keyValue, JobApprovalFormEntity entity, [System.Web.Http.FromBody] string arr)
        {
            try
            {
                var str = 0;
                var msg = "";
                if (entity.IsSubmit == 1)
                {
                    var list            = JobApprovalFormbll.GetList("").Where(x => x.IsSubmit == 1).Where(x => x.Id != keyValue).ToList();
                    var JobSafetyCardId = string.Join(",", list.Select(x => x.JobSafetyCardId).ToArray()).Replace(",", "','");
                    if (!string.IsNullOrEmpty(entity.JobSafetyCardId))
                    {
                        var cardId = entity.JobSafetyCardId.TrimEnd(',').Split(',');
                        foreach (var item in cardId)
                        {
                            if (JobSafetyCardId.Contains(item))
                            {
                                str = 1;
                                var Applyentity = jobSafetyCardApplybll.GetEntity(item);
                                msg += Applyentity.JobTypeName + "(" + Applyentity.ApplyNo + "),";
                            }
                        }
                        if (str == 1)
                        {
                            return(Error(msg.TrimEnd(',') + "作业安全证已被关联,请重新选择。"));
                        }
                        else
                        {
                            //获取业务数据关联的逐级审核流程步骤信息
                            Operator user = OperatorProvider.Provider.Current();
                            var      data = manyPowerCheckbll.GetListByModuleNo(user.OrganizeCode, entity.ModuleName);

                            JobApprovalFormbll.SaveForm(keyValue, entity, data, arr);
                            return(Success("操作成功。"));
                        }
                    }
                    else
                    {
                        //获取业务数据关联的逐级审核流程步骤信息
                        Operator user = OperatorProvider.Provider.Current();
                        var      data = manyPowerCheckbll.GetListByModuleNo(user.OrganizeCode, entity.ModuleName);

                        JobApprovalFormbll.SaveForm(keyValue, entity, data, arr);
                        return(Success("操作成功。"));
                    }
                }
                else
                {
                    //获取业务数据关联的逐级审核流程步骤信息
                    Operator user = OperatorProvider.Provider.Current();
                    var      data = manyPowerCheckbll.GetListByModuleNo(user.OrganizeCode, entity.ModuleName);

                    JobApprovalFormbll.SaveForm(keyValue, entity, data, arr);
                    return(Success("操作成功。"));
                }
            }
            catch (Exception ex)
            {
                return(Error("操作失败。" + ex.Message));
            }
        }
        public void ExportDetails(string KeyValue)
        {
            string fileName = Str.Empty;
            JobApprovalFormEntity jobapprovalformentity = JobApprovalFormbll.GetEntity(KeyValue);

            if (jobapprovalformentity == null)
            {
                return;
            }
            else
            {
                if (jobapprovalformentity.JobLevel == "0")
                {
                    fileName = Server.MapPath("~/Resource/ExcelTemplate/一级危险作业审批单.docx");
                }
                if (jobapprovalformentity.JobLevel == "1")
                {
                    fileName = Server.MapPath("~/Resource/ExcelTemplate/二级危险作业审批单.docx");
                }
                if (jobapprovalformentity.JobLevel == "2")
                {
                    fileName = Server.MapPath("~/Resource/ExcelTemplate/三级危险作业审批单.docx");
                }

                Document        doc     = new Document(fileName);
                DocumentBuilder builder = new DocumentBuilder(doc);
                DataSet         ds      = new DataSet();
                DataTable       dt      = new DataTable("");
                dt.Columns.Add("JobDeptName");       //作业单位
                dt.Columns.Add("JobContent");        //作业内容
                dt.Columns.Add("JobStartTime");      //作业开始时间
                dt.Columns.Add("JobEndTime");        //作业结束时间
                dt.Columns.Add("JobPlace");          //作业地点
                dt.Columns.Add("JobNum");            //作业人数
                dt.Columns.Add("JobType");           //危险作业类型
                dt.Columns.Add("DangerousDecipher"); //主要危险、危害因素
                dt.Columns.Add("SafetyMeasures");    //安全措施(可另附)
                dt.Columns.Add("AuditRemark1");      //中心(部门)安全管理人员:
                dt.Columns.Add("AuditRemark2");      //现场安全负责人
                dt.Columns.Add("AuditRemark3");      //作业单位主管意见
                dt.Columns.Add("AuditRemark4");      //工序确认意见
                dt.Columns.Add("AuditRemark5");      //中心(部门)安全管理人员意见
                dt.Columns.Add("AuditRemark6");      //中心(部门)负责人意见
                dt.Columns.Add("AuditRemark7");      //作业单位负责人意见
                dt.Columns.Add("AuditRemark8");      //公司安全环保健康部意见
                dt.Columns.Add("AuditRemark9");      //公司分管负责人意见

                dt.Columns.Add("AuditUserName1");    //中心(部门)安全管理人员:
                dt.Columns.Add("AuditUserName2");    //现场安全负责人
                dt.Columns.Add("AuditUserName3");    //作业单位主管意见
                dt.Columns.Add("AuditUserName4");    //工序确认意见
                dt.Columns.Add("AuditUserName5");    //中心(部门)安全管理人员意见
                dt.Columns.Add("AuditUserName6");    //中心(部门)负责人意见
                dt.Columns.Add("AuditUserName7");    //作业单位负责人意见
                dt.Columns.Add("AuditUserName8");    //公司安全环保健康部意见
                dt.Columns.Add("AuditUserName9");    //公司分管负责人意见

                dt.Columns.Add("Tel1");              //中心(部门)安全管理人员:
                dt.Columns.Add("Tel2");              //现场安全负责人

                dt.Columns.Add("AuditDate3");        //作业单位主管意见
                dt.Columns.Add("AuditDate4");        //工序确认意见
                dt.Columns.Add("AuditDate5");        //中心(部门)安全管理人员意见
                dt.Columns.Add("AuditDate6");        //中心(部门)负责人意见
                dt.Columns.Add("AuditDate7");        //作业单位负责人意见
                dt.Columns.Add("AuditDate8");        //公司安全环保健康部意见
                dt.Columns.Add("AuditDate9");        //公司分管负责人意见
                dt.Columns.Add("SignUrl");           //编制人
                dt.Columns.Add("SignUrl1");          //审批人
                DataRow row1       = dt.NewRow();
                string  auditdate3 = "年   月   日",    //作业单位主管意见
                        auditdate4 = "年   月   日",    //工序确认意见
                        auditdate5 = "年   月   日",    //中心(部门)安全管理人员意见
                        auditdate6 = "年   月   日",    //中心(部门)负责人意见
                        auditdate7 = "年   月   日",    //作业单位负责人意见
                        auditdate8 = "年   月   日",    //公司安全环保健康部意见
                        auditdate9 = "年   月   日";    //公司分管负责人意见
                string defaultstr  = "yyyy年MM月dd日";
                var    table       = JobApprovalFormbll.GetCheckInfo(jobapprovalformentity.Id);

                row1["JobDeptName"]  = jobapprovalformentity.JobDeptName;
                row1["JobContent"]   = jobapprovalformentity.JobContent;
                row1["JobStartTime"] = jobapprovalformentity.JobStartTime.HasValue ? jobapprovalformentity.JobStartTime.Value.ToString("yyyy-MM-dd HH:mm") : "";
                row1["JobEndTime"]   = jobapprovalformentity.JobEndTime.HasValue ? jobapprovalformentity.JobEndTime.Value.ToString("yyyy-MM-dd HH:mm") : "";
                row1["JobPlace"]     = jobapprovalformentity.JobPlace;
                row1["JobNum"]       = jobapprovalformentity.JobNum;

                //row1["JobType"] = jobapprovalformentity.JobTypeName;
                var JobLevelList = dataItemCache.GetDataItemList("DangerousJobType");
                foreach (var item in JobLevelList)
                {
                    if (jobapprovalformentity.JobType.Contains(item.ItemValue))
                    {
                        row1["JobType"] += " ☑" + item.ItemName;
                    }
                    else
                    {
                        row1["JobType"] += "  □" + item.ItemName;
                    }
                }
                //row1["JobType"]+=""
                Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                var      data = classstandardconfigbll.GetList("").Where(t => t.WorkType == "DangerousJobCheck" && t.DeptCode == user.OrganizeCode).FirstOrDefault();
                if (data != null)
                {
                    var newdata = data.Whbs.Split('$');
                    foreach (var item in newdata)
                    {
                        if (jobapprovalformentity.DangerousDecipher.Contains(item))
                        {
                            row1["DangerousDecipher"] += " ☑" + item;
                        }
                        else
                        {
                            row1["DangerousDecipher"] += "  □" + item;
                        }
                    }
                }
                row1["SafetyMeasures"] = jobapprovalformentity.SafetyMeasures;
                string  pic     = Server.MapPath("~/content/Images/no_1.png");//默认图片
                UserBLL userbll = new UserBLL();
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i + 1 < 3)
                    {
                        var users = userbll.GetEntity(table.Rows[i]["approvepersonid"].ToString());
                        row1["Tel" + (i + 1)] = users != null ? users.Mobile : "";
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(table.Rows[i]["approvetime"].ToString()))
                        {
                            var stime = Convert.ToDateTime(table.Rows[i]["approvetime"]);
                            row1["AuditDate" + (i + 1)] = stime.ToString(defaultstr);
                        }
                    }
                    var filepath = table.Rows[i]["SignUrl"] == null ? "" : (Server.MapPath("~/") + table.Rows[i]["SignUrl"].ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString();

                    row1["AuditRemark" + (i + 1)]   = table.Rows[i]["approveopinion"];
                    row1["AuditUserName" + (i + 1)] = builder.MoveToMergeField("AuditUserName" + (i + 1));; //中心(部门)安全管理人员:
                                                                                                            //builder.InsertImage(row["Person1"].ToString(), 80, 35);
                    if (!System.IO.File.Exists(filepath))
                    {
                        filepath = pic;
                    }
                    builder.InsertImage(filepath, 80, 35);
                }
                var signurl = string.IsNullOrEmpty(jobapprovalformentity.SignUrl) ? "" : (Server.MapPath("~/") + jobapprovalformentity.SignUrl.Replace("../../", "").ToString()).Replace(@"\/", "/").ToString();
                row1["SignUrl"] = builder.MoveToMergeField("SignUrl");
                //row1["SignUrl1"] = builder.MoveToMergeField("SignUrl1");
                if (!System.IO.File.Exists(signurl))
                {
                    signurl = pic;
                }
                builder.InsertImage(signurl, 80, 35);
                row1["SignUrl1"] = builder.MoveToMergeField("SignUrl1");
                if (!System.IO.File.Exists(signurl))
                {
                    signurl = pic;
                }
                builder.InsertImage(signurl, 80, 35);
                dt.Rows.Add(row1);
                doc.MailMerge.Execute(dt);
                doc.MailMerge.ExecuteWithRegions(dt);
                var docStream = new MemoryStream();
                doc.Save(docStream, SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Doc));
                Response.ContentType = "application/msword";
                if (jobapprovalformentity.JobLevel == "0")
                {
                    Response.AddHeader("content-disposition", "attachment;filename=一级危险作业审批单.doc");
                }
                if (jobapprovalformentity.JobLevel == "1")
                {
                    Response.AddHeader("content-disposition", "attachment;filename=二级危险作业审批单.doc");
                }
                if (jobapprovalformentity.JobLevel == "2")
                {
                    Response.AddHeader("content-disposition", "attachment;filename=三级危险作业审批单.doc");
                }
                Response.BinaryWrite(docStream.ToArray());
                Response.End();
            }
        }