using System; using System.Collections; using BP.DA; using BP.En; using BP.Port; namespace BP.WF.Template { /// /// 选择接受人属性 /// public class SelectAccperAttr { /// /// 工作ID /// public const string WorkID = "WorkID"; /// /// 节点 /// public const string FK_Node = "FK_Node"; /// /// 到人员 /// public const string FK_Emp = "FK_Emp"; /// /// 操作员名称 /// public const string EmpName = "EmpName"; /// /// 部门编号 /// public const string FK_Dept = "FK_Dept"; /// /// 部门名称 /// public const string DeptName = "DeptName"; /// /// 记录人 /// public const string Rec = "Rec"; /// /// 办理意见 信息 /// public const string Info = "Info"; /// /// 以后发送是否按此计算 /// public const string IsRemember = "IsRemember"; /// /// 顺序号 /// public const string Idx = "Idx"; /// /// 类型(@0=接受人@1=抄送人) /// public const string AccType = "AccType"; /// /// 维度标记 /// public const string Tag = "Tag"; /// /// 时限天 /// public const string TimeLimit = "TimeLimit"; /// /// 时限小时 /// public const string TSpanHour = "TSpanHour"; /// /// 接受日期(计划) /// public const string PlanADT = "ADT"; /// /// 应完成日期(计划) /// public const string PlanSDT = "SDT"; } /// /// 选择接受人 /// 节点的到人员有两部分组成. /// 记录了从一个节点到其他的多个节点. /// 也记录了到这个节点的其他的节点. /// public class SelectAccper : EntityMyPK { #region 基本属性 /// /// UI界面上的访问控制 /// public override UAC HisUAC { get { UAC uac = new UAC(); uac.OpenAll(); return uac; } } /// ///工作ID /// public Int64 WorkID { get { return this.GetValInt64ByKey(SelectAccperAttr.WorkID); } set { this.SetValByKey(SelectAccperAttr.WorkID, value); } } /// ///节点 /// public int FK_Node { get { return this.GetValIntByKey(SelectAccperAttr.FK_Node); } set { this.SetValByKey(SelectAccperAttr.FK_Node, value); } } /// /// 到人员 /// public string FK_Emp { get { return this.GetValStringByKey(SelectAccperAttr.FK_Emp); } set { this.SetValByKey(SelectAccperAttr.FK_Emp, value); } } /// /// 标记 /// public string Tag { get { return this.GetValStringByKey(SelectAccperAttr.Tag); } set { this.SetValByKey(SelectAccperAttr.Tag, value); } } /// /// 人员名称 /// public string EmpName { get { string s= this.GetValStringByKey(SelectAccperAttr.EmpName); if (DataType.IsNullOrEmpty(s) == true) s = this.FK_Emp; return s; } set { this.SetValByKey(SelectAccperAttr.EmpName, value); } } /// /// 部门名称 /// public string DeptName { get { return this.GetValStringByKey(SelectAccperAttr.DeptName); } set { this.SetValByKey(SelectAccperAttr.DeptName, value); } } /// /// 接收人 /// public string Rec { get { return this.GetValStringByKey(SelectAccperAttr.Rec); } set { this.SetValByKey(SelectAccperAttr.Rec, value); } } /// /// 办理意见 信息 /// public string Info { get { return this.GetValStringByKey(SelectAccperAttr.Info); } set { this.SetValByKey(SelectAccperAttr.Info, value); } } /// /// 是否记忆 /// public bool IsRemember { get { return this.GetValBooleanByKey(SelectAccperAttr.IsRemember); } set { this.SetValByKey(SelectAccperAttr.IsRemember, value); } } /// /// 顺序号 /// public int Idx { get { return this.GetValIntByKey(SelectAccperAttr.Idx); } set { this.SetValByKey(SelectAccperAttr.Idx, value); } } /// /// 类型(@0=接受人@1=抄送人) /// public int AccType { get { return this.GetValIntByKey(SelectAccperAttr.AccType); } set { this.SetValByKey(SelectAccperAttr.AccType, value); } } /// /// 时限 /// public float TSpanHour { get { return this.GetValFloatByKey(SelectAccperAttr.TSpanHour); } set { this.SetValByKey(SelectAccperAttr.TSpanHour, value); } } /// /// 工作到达日期(计划) /// public string PlanADT { get { return this.GetValStringByKey(SelectAccperAttr.PlanADT); } set { this.SetValByKey(SelectAccperAttr.PlanADT, value); } } /// /// 工作应完成日期(计划) /// public string PlanSDT { get { return this.GetValStringByKey(SelectAccperAttr.PlanSDT); } set { this.SetValByKey(SelectAccperAttr.PlanSDT, value); } } /// /// 工作应完成日期(计划) /// public string FK_Dept { get { return this.GetValStringByKey(SelectAccperAttr.FK_Dept); } set { this.SetValByKey(SelectAccperAttr.FK_Dept, value); } } #endregion #region 构造方法 /// /// 选择接受人 /// public SelectAccper() { } public SelectAccper(string mypk) { this.setMyPK(mypk); this.Retrieve(); } /// /// 重写基类方法 /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("WF_SelectAccper", "选择接受/抄送人信息"); map.AddMyPK(); map.AddTBInt(SelectAccperAttr.FK_Node, 0, "接受人节点", true, false); map.AddTBInt(SelectAccperAttr.WorkID, 0, "WorkID", true, false); map.AddTBString(SelectAccperAttr.FK_Emp, null, "FK_Emp", true, false, 0, 100, 10); map.AddTBString(SelectAccperAttr.EmpName, null, "EmpName", true, false, 0, 60, 10); map.AddTBString(SelectAccperAttr.FK_Dept, null, "部门编号", true, false, 0, 400, 10); map.AddTBString(SelectAccperAttr.DeptName, null, "部门名称", true, false, 0, 400, 10); map.AddTBInt(SelectAccperAttr.AccType, 0, "类型(@0=接受人@1=抄送人)", true, false); map.AddTBString(SelectAccperAttr.Rec, null, "记录人", true, false, 0, 100, 10); map.AddTBString(SelectAccperAttr.Info, null, "办理意见信息", true, false, 0, 200, 10); map.AddTBInt(SelectAccperAttr.IsRemember, 0, "以后发送是否按本次计算", true, false); map.AddTBInt(SelectAccperAttr.Idx, 0, "顺序号(可以用于流程队列审核模式)", true, false); /* * add 2015-1-12. * 为了解决多维度的人员问题. * 在分流点向下发送时, 一个人可以分配两次任务,但是这个任务需要一个维度来区分。 * 这个维度,有可能是一个类别,批次。 */ map.AddTBString(SelectAccperAttr.Tag, null, "维度信息Tag", true, false, 0, 200, 10); map.AddTBInt(SelectAccperAttr.TimeLimit, 0, "时限-天", true, false); map.AddTBFloat(SelectAccperAttr.TSpanHour, 0, "时限-小时", true, false); //应该完成日期,为了自动计算未来的日期. map.AddTBDateTime(SelectAccperAttr.PlanADT, null, "到达日期(计划)", true, false); map.AddTBDateTime(SelectAccperAttr.PlanSDT, null, "应完成日期(计划)", true, false); this._enMap = map; return this._enMap; } } #endregion public string DoUp() { this.DoOrderUp(SelectAccperAttr.WorkID, this.WorkID, SelectAccperAttr.FK_Node, this.FK_Node, SelectAccperAttr.Idx); return ""; } public string DoDown() { this.DoOrderDown(SelectAccperAttr.WorkID, this.WorkID, SelectAccperAttr.FK_Node, this.FK_Node, SelectAccperAttr.Idx); return ""; } protected override bool beforeInsert() { this.ResetPK(); return base.beforeInsert(); } public void ResetPK() { //注释掉了. // this.setMyPK(this.FK_Node + "_" + this.WorkID + "_" + this.FK_Emp+"_"+this.Idx; this.setMyPK(this.FK_Node + "_" + this.WorkID + "_" + this.FK_Emp); this.Idx = DBAccess.RunSQLReturnValInt("SELECT Max(idx) +1 FROM WF_SelectAccper WHERE FK_Node=" + this.FK_Node + " AND WorkID=" + this.WorkID, 1); } protected override bool beforeUpdateInsertAction() { if (this.DeptName.Length == 0) { bool isHavePathName = DBAccess.IsExitsTableCol("Port_Dept", "NameOfpath"); if (isHavePathName == true) { this.DeptName = DBAccess.RunSQLReturnStringIsNull("select a.NameOfPath from port_dept a,Port_Emp b where a.No=b.fk_dept and b.no='" + this.FK_Emp + "'", "无"); if (this.DeptName == "无") this.DeptName = DBAccess.RunSQLReturnStringIsNull("select a.name from port_dept a,Port_Emp b where a.No=b.fk_dept and b.no='" + this.FK_Emp + "'", "无"); } else this.DeptName = DBAccess.RunSQLReturnStringIsNull("select a.name from port_dept a,Port_Emp b where a.No=b.fk_dept and b.no='" + this.FK_Emp + "'", "无"); } this.ResetPK(); this.Rec = BP.Web.WebUser.No; return base.beforeUpdateInsertAction(); } } /// /// 选择接受人 /// public class SelectAccpers : EntitiesMyPK { /// /// 是否记忆下次选择 /// public bool IsSetNextTime { get { if (this.Count == 0) return false; foreach (SelectAccper item in this) { if (item.IsRemember == true) return item.IsRemember; } return false; } } /// /// 查询接收人,如果没有设置就查询历史记录设置的接收人. /// /// /// /// public int QueryAccepter(int fk_node, string rec, Int64 workid) { //查询出来当前的数据. int i = this.Retrieve(SelectAccperAttr.FK_Node, fk_node, SelectAccperAttr.WorkID, workid); if (i != 0) return i; /*如果没有就找最大的workid.*/ //找出最近的工作ID int maxWorkID = DBAccess.RunSQLReturnValInt("SELECT Max(WorkID) FROM WF_SelectAccper WHERE Rec='" + rec + "' AND FK_Node=" + fk_node, 0); if (maxWorkID == 0) return 0; //查询出来该数据. this.Retrieve(SelectAccperAttr.FK_Node, fk_node, SelectAccperAttr.WorkID, maxWorkID); //返回查询结果. return this.Count; } /// /// 查询上次的设置 /// /// 节点编号 /// 当前人员 /// 工作ID /// public int QueryAccepterPriSetting(int fk_node) { //找出最近的工作ID. int maxWorkID = DBAccess.RunSQLReturnValInt("SELECT Max(WorkID) FROM WF_SelectAccper WHERE " + SelectAccperAttr.IsRemember + "=1 AND Rec='" + BP.Web.WebUser.No + "' AND FK_Node=" + fk_node, 0); if (maxWorkID == 0) return 0; //查询出来该数据. this.Retrieve(SelectAccperAttr.FK_Node, fk_node, SelectAccperAttr.WorkID, maxWorkID); //返回查询结果. return this.Count; } /// /// 他的到人员 /// public Emps HisEmps { get { Emps ens = new Emps(); foreach (SelectAccper ns in this) { ens.AddEntity(new Emp(ns.FK_Emp)); } return ens; } } /// /// 他的工作节点 /// public Nodes HisNodes { get { Nodes ens = new Nodes(); foreach (SelectAccper ns in this) { ens.AddEntity(new Node(ns.FK_Node)); } return ens; } } /// /// 选择接受人 /// public SelectAccpers() { } /// /// 查询出来选择的人员 /// /// /// public SelectAccpers(Int64 workid) { BP.En.QueryObject qo = new QueryObject(this); qo.AddWhere(SelectAccperAttr.WorkID, workid); qo.addOrderByDesc(SelectAccperAttr.FK_Node,SelectAccperAttr.Idx); qo.DoQuery(); } /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new SelectAccper(); } } #region 为了适应自动翻译成java的需要,把实体转换成List. /// /// 转化成 java list,C#不能调用. /// /// List public System.Collections.Generic.IList ToJavaList() { return (System.Collections.Generic.IList)this; } /// /// 转化成list /// /// List public System.Collections.Generic.List Tolist() { System.Collections.Generic.List list = new System.Collections.Generic.List(); for (int i = 0; i < this.Count; i++) { list.Add((SelectAccper)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }