Exemple #1
0
        /// <summary>
        /// 获取评价流程图
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public Flow GetEvaluateFlow(string keyValue)
        {
            List <nodes> nlist     = new List <nodes>();
            List <lines> llist     = new List <lines>();
            var          isendflow = false;//流程结束标记
            string       flowid    = string.Empty;
            Flow         flow      = new Flow();

            flow.title   = "";
            flow.initNum = 22;
            Operator currUser       = ERCHTMS.Code.OperatorProvider.Provider.Current();
            var      EvaluateEntity = this.BaseRepository().FindEntity(keyValue);

            flowid = EvaluateEntity.NodeId;
            if (EvaluateEntity.IsOverEvaluate == 1)
            {
                isendflow = true;
            }
            string moduleName = string.Empty;

            if (EvaluateEntity != null)
            {
                switch (EvaluateEntity.DrillLevel)
                {
                case "厂级":
                    moduleName = "厂级演练记录评价";
                    break;

                case "部门级":
                    moduleName = "部门级演练记录评价";
                    break;

                case "班组级":
                    moduleName = "班组级演练记录评价";
                    break;

                default:
                    break;
                }
            }
            string    flowSql = string.Format(@"select t.flowname,t.id,t.serialnum,t.checkrolename,
                                            t.checkroleid,t.checkdeptid,t.checkdeptcode,
                                            d.evaluateperson,d.evaluatetime,d.evaluatedept,
                                            d.evaluateopinion,t.checkdeptname
                                        from  bis_manypowercheck t 
                                             left join mae_drillrecordevaluate d on d.nodeid=t.id and d.drillrecordid='{2}'
                                        where t.createuserorgcode='{0}' and t.modulename='{1}' 
                                              order by t.serialnum asc", currUser.OrganizeCode, moduleName, keyValue);
            DataTable dt      = this.BaseRepository().FindTable(flowSql);

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr    = dt.Rows[i];
                    nodes   nodes = new nodes();
                    nodes.alt     = true;
                    nodes.isclick = false;
                    nodes.css     = "";
                    nodes.id      = dr["id"].ToString(); //主键
                    nodes.img     = "";
                    nodes.name    = dr["flowname"].ToString();
                    nodes.type    = "stepnode";
                    //位置
                    int m = i % 4;
                    int n = i / 4;
                    if (m == 0)
                    {
                        nodes.left = 120;
                    }
                    else
                    {
                        nodes.left = 120 + ((150 + 60) * m);
                    }
                    if (n == 0)
                    {
                        nodes.top = 54;
                    }
                    else
                    {
                        nodes.top = (n * 100) + 54;
                    }
                    setInfo sinfo = new setInfo();
                    sinfo.NodeName = nodes.name;

                    //审核记录
                    if (dr["evaluateperson"] != null && !string.IsNullOrEmpty(dr["evaluateperson"].ToString()))
                    {
                        sinfo.Taged = 1;
                        List <NodeDesignateData> nodelist          = new List <NodeDesignateData>();
                        NodeDesignateData        nodedesignatedata = new NodeDesignateData();
                        DateTime auditdate;
                        DateTime.TryParse(dr["evaluatetime"].ToString(), out auditdate);
                        nodedesignatedata.createdate = auditdate.ToString("yyyy-MM-dd HH:mm");
                        nodedesignatedata.creatdept  = dr["evaluatedept"].ToString();
                        nodedesignatedata.createuser = dr["evaluateperson"].ToString();
                        nodedesignatedata.status     = dr["evaluateopinion"].ToString();
                        if (i == 0)
                        {
                            nodedesignatedata.prevnode = "无";
                        }
                        else
                        {
                            nodedesignatedata.prevnode = dt.Rows[i - 1]["flowname"].ToString();
                        }

                        nodelist.Add(nodedesignatedata);
                        sinfo.NodeDesignateData = nodelist;
                        nodes.setInfo           = sinfo;
                    }
                    else
                    {
                        if (dr["id"].ToString() == flowid)
                        {
                            sinfo.Taged = 0;
                        }
                        List <NodeDesignateData> nodelist          = new List <NodeDesignateData>();
                        NodeDesignateData        nodedesignatedata = new NodeDesignateData();
                        nodedesignatedata.createdate = "无";
                        var checkDeptId = dr["checkdeptid"].ToString();
                        if (checkDeptId == "-1")//审核流程标记 -1 为执行单位=外包工程的发包单位
                        {
                            var deptentity = new DepartmentService().GetEntityByCode(EvaluateEntity.CREATEUSERDEPTCODE);
                            if (deptentity != null)
                            {
                                if (deptentity.Nature == "班组")
                                {
                                    var parentDept = new DepartmentService().GetParentDeptBySpecialArgs(deptentity.ParentId, "部门");
                                    if (parentDept != null)
                                    {
                                        checkDeptId = parentDept.DepartmentId;
                                        nodedesignatedata.creatdept = parentDept.FullName;
                                    }
                                }
                            }
                            else
                            {
                                nodedesignatedata.creatdept = "无";
                            }
                        }
                        else if (checkDeptId == "-3")
                        {
                            var deptentity = new DepartmentService().GetEntityByCode(EvaluateEntity.CREATEUSERDEPTCODE);
                            if (deptentity != null)
                            {
                                checkDeptId = deptentity.DepartmentId;
                                nodedesignatedata.creatdept = deptentity.FullName;
                            }
                            else
                            {
                                nodedesignatedata.creatdept = "无";
                            }
                        }
                        else
                        {
                            nodedesignatedata.creatdept = dr["checkdeptname"].ToString();
                        }
                        string userNames = new ScaffoldService().GetUserName(checkDeptId, dr["checkrolename"].ToString(), "0").Split('|')[0];
                        nodedesignatedata.createuser = !string.IsNullOrEmpty(userNames) ? userNames : "无";

                        nodedesignatedata.status = "无";
                        if (i == 0)
                        {
                            nodedesignatedata.prevnode = "无";
                        }
                        else
                        {
                            nodedesignatedata.prevnode = dt.Rows[i - 1]["flowname"].ToString();
                        }

                        nodelist.Add(nodedesignatedata);
                        sinfo.NodeDesignateData = nodelist;
                        nodes.setInfo           = sinfo;
                    }
                    nlist.Add(nodes);
                }
                //流程结束节点
                nodes nodes_end = new nodes();
                nodes_end.alt     = true;
                nodes_end.isclick = false;
                nodes_end.css     = "";
                nodes_end.id      = Guid.NewGuid().ToString();
                nodes_end.img     = "";
                nodes_end.name    = "流程结束";
                nodes_end.type    = "endround";
                nodes_end.width   = 150;
                nodes_end.height  = 60;
                //取最后一流程的位置,相对排位
                nodes_end.left = nlist[nlist.Count - 1].left;
                nodes_end.top  = nlist[nlist.Count - 1].top + 100;
                nlist.Add(nodes_end);

                //如果状态为审核通过或不通过,流程结束进行标识
                if (isendflow)
                {
                    setInfo sinfo = new setInfo();
                    sinfo.NodeName = nodes_end.name;
                    sinfo.Taged    = 1;
                    List <NodeDesignateData> nodelist          = new List <NodeDesignateData>();
                    NodeDesignateData        nodedesignatedata = new NodeDesignateData();

                    //取流程结束时的节点信息
                    if (!string.IsNullOrWhiteSpace(flowid))
                    {
                        DataRow[] end_rows = dt.Select("id = '" + flowid + "'");
                        DataRow   end_row  = end_rows[0];
                        DateTime  auditdate;
                        DateTime.TryParse(end_row["evaluatetime"].ToString(), out auditdate);
                        nodedesignatedata.createdate = auditdate.ToString("yyyy-MM-dd HH:mm");
                        nodedesignatedata.creatdept  = end_row["evaluatedept"].ToString();
                        nodedesignatedata.createuser = end_row["evaluateperson"].ToString();
                        nodedesignatedata.status     = end_row["evaluateopinion"].ToString();
                        nodedesignatedata.prevnode   = end_row["flowname"].ToString();
                    }
                    else
                    {
                        //历史数据无Flowid
                        nodedesignatedata.createdate = "";
                        nodedesignatedata.creatdept  = "";
                        nodedesignatedata.createuser = "";
                        nodedesignatedata.status     = "";
                        nodedesignatedata.prevnode   = "";
                    }
                    nodelist.Add(nodedesignatedata);
                    sinfo.NodeDesignateData = nodelist;
                    nodes_end.setInfo       = sinfo;
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    lines lines = new lines();
                    lines.alt  = true;
                    lines.id   = Guid.NewGuid().ToString();
                    lines.from = dt.Rows[i]["id"].ToString();
                    if (i < dt.Rows.Count - 1)
                    {
                        lines.to = dt.Rows[i + 1]["id"].ToString();
                    }
                    lines.name = "";
                    lines.type = "sl";
                    llist.Add(lines);
                }

                lines lines_end = new lines();
                lines_end.alt  = true;
                lines_end.id   = Guid.NewGuid().ToString();
                lines_end.from = dt.Rows[dt.Rows.Count - 1]["id"].ToString();
                lines_end.to   = nodes_end.id;
                llist.Add(lines_end);

                flow.nodes = nlist;
                flow.lines = llist;
            }
            return(flow);
        }
Exemple #2
0
 // dependency injection is used to initialise ScaffoldService
 // See Startup.cs file to see how it was registered
 public ScaffoldController(ScaffoldService scaffoldService)
 {
     _scaffoldedService = scaffoldService;
 }