/// <summary> /// 修改审批流程 /// </summary> /// <param name="approvalTypeId">审批类型id</param> /// <param name="bType">单据类型</param> /// <param name="proc_code">审批流程编码</param> /// <param name="orgids">组织id集合</param> /// <param name="procModels">新增集合</param> /// <param name="uCode">用户账号</param> /// <returns></returns> public SavedResult <Int64> PostUpdateProc(long approvalTypeId, string bType, string proc_code, List <long> orgids, List <GAppvalProcModel> procModels, string uCode) { SavedResult <Int64> savedResult = null; //获取审批流程 List <GAppvalProcModel> existProcModels = GAppvalProcFacade.GetAppvalProc(orgids, bType, approvalTypeId); if (existProcModels == null || existProcModels.Count == 0) { throw new Exception("审批流程为空!"); } else { existProcModels = existProcModels.FindAll(t => t.FCode == proc_code); } //判断审批流程是否被引用 foreach (GAppvalProcModel model in existProcModels) { IList <GAppvalRecordModel> models = GAppvalRecordFacade.Find(t => t.ProcPhid == model.PhId).Data; if (models != null && models.Count > 0) { foreach (var mo in models) { throw new Exception("修改失败,流程为'" + model.FName + "'的审批流存在审批中的单据,无法修改!请审批完成后再来修改!!"); //if (mo.FApproval == (byte)Approval.Wait) //{ // throw new Exception("修改失败,流程为'" + model.FName + "'的审批流存在审批中的单据,无法修改!请审批完成后再来修改!!"); //} } } if (uCode != "Admin" && model.IsSystem == (byte)1) { throw new Exception("修改失败,流程为'" + model.FName + "'为内置流程,不允许普通操作员进行修改!"); } } //如果审批流程没有被引用,更新操作为:删除审批流程,重新保存 //批量删除审批流程 GAppvalProcFacade.DeleteAppvalProc(existProcModels); foreach (GAppvalProcModel procModel in procModels) { if (uCode == "Admin") { procModel.IsSystem = (byte)1; } //保存审批流程 savedResult = GAppvalProcFacade.SaveAppvalProc(procModel); } return(savedResult); }
/// <summary> /// 删除审批类型 /// </summary> /// <param name="proc_phid">审批类型id</param> /// <returns></returns> public DeletedResult PostDeleteProcType(long proc_phid) { if (proc_phid == 0) { return(null); } IList <GAppvalProcModel> procModels = GAppvalProcFacade.Find(t => t.SPLXPhid == proc_phid).Data; //批量删除审批流程 GAppvalProcFacade.DeleteAppvalProc(procModels); DeletedResult deletedResult = QTSysSetFacade.Delete(proc_phid); return(deletedResult); }
/// <summary> /// 批量删除审批流程 /// </summary> /// <param name="procModels"></param> public void PostDeleteProc(List <GAppvalProcModel> procModels) { if (procModels == null || procModels.Count == 0) { throw new Exception("审批流程为空!"); } foreach (GAppvalProcModel model in procModels) { List <long> orgids = model.Organizes.Select(t => t.OrgId).ToList(); //获取审批流程 List <GAppvalProcModel> existProcModels = GAppvalProcFacade.GetAppvalProc(orgids, model.FBilltype, model.SPLXPhid); if (existProcModels != null) { existProcModels = existProcModels.FindAll(t => t.FCode == model.FCode); } else { throw new Exception("审批流程为空!"); } if (existProcModels.Count == 0) { throw new Exception("审批流程为空!"); } //判断审批流程是否被引用 foreach (GAppvalProcModel proc in existProcModels) { IList <GAppvalRecordModel> models = GAppvalRecordFacade.Find(t => t.ProcPhid == proc.PhId).Data; if (models != null && models.Count > 0) { throw new Exception("修改失败,流程为'" + proc.FName + "'已经被引用!"); } } //批量删除审批流程 GAppvalProcFacade.DeleteAppvalProc(existProcModels); } }
/// <summary> /// 批量删除审批类型 /// </summary> /// <param name="ids">审批类型id集合</param> /// <returns></returns> public DeletedResult PostDeleteProcTypes(List <long> ids) { if (ids == null || ids.Count == 0) { return(null); } foreach (long proc_phid in ids) { IList <GAppvalProcModel> procModels = GAppvalProcFacade.Find(t => t.SPLXPhid == proc_phid).Data; //批量删除审批流程 GAppvalProcFacade.DeleteAppvalProc(procModels); } Dictionary <string, object> dicWhere = new Dictionary <string, object>(); new CreateCriteria(dicWhere) .Add(ORMRestrictions <List <long> > .In("PhId", ids)); DeletedResult deletedResult = QTSysSetFacade.Delete(dicWhere); return(deletedResult); }
/// <summary> /// 删除审批流程 /// </summary> /// <param name="approvalTypeId">审批类型id</param> /// <param name="bType">单据类型</param> /// <param name="proc_code">审批流程编码</param> /// <param name="orgids">组织id集合</param> /// <param name="uCode">用户账号</param> public void PostDeleteProc(long approvalTypeId, string bType, string proc_code, List <long> orgids, string uCode) { //获取审批流程 List <GAppvalProcModel> existProcModels = GAppvalProcFacade.GetAppvalProc(orgids, bType, approvalTypeId); if (existProcModels != null) { existProcModels = existProcModels.FindAll(t => t.FCode == proc_code); } else { throw new Exception("审批流程为空!"); } if (existProcModels.Count == 0) { throw new Exception("审批流程为空!"); } //判断审批流程是否被引用 foreach (GAppvalProcModel model in existProcModels) { IList <GAppvalRecordModel> models = GAppvalRecordFacade.Find(t => t.ProcPhid == model.PhId).Data; if (models != null && models.Count > 0) { throw new Exception("删除失败,流程为'" + model.FName + "'已经被引用!"); } if (uCode != "Admin" && model.IsSystem == (byte)1) { throw new Exception("删除失败,流程为'" + model.FName + "'为内置流程,不允许普通操作员进行删除!"); } } //批量删除审批流程 GAppvalProcFacade.DeleteAppvalProc(existProcModels); }
/// <summary> /// 更新启用组织 /// </summary> /// <param name="procModel"></param> /// <returns></returns> public int PostUpdateProcOrganize(GAppvalProcModel procModel) { int result = 0; List <long> orgids = procModel.Organizes.Select(t => t.OrgId).ToList(); //获取审批流程 List <GAppvalProcModel> existProcModels = GAppvalProcFacade.GetAppvalProc(orgids, procModel.FBilltype, procModel.SPLXPhid); if (existProcModels != null) { existProcModels = existProcModels.FindAll(t => t.FCode == procModel.FCode); } else { throw new Exception("审批流程为空!"); } List <long> deleteOrgs = new List <long>(); List <Organize> addOrgs = new List <Organize>(); foreach (Organize model in procModel.NewOrganizes) { if (!procModel.Organizes.Exists(t => t.OrgId == model.OrgId)) { addOrgs.Add(model); } } foreach (Organize model in procModel.Organizes) { if (!procModel.NewOrganizes.Exists(t => t.OrgId == model.OrgId)) { deleteOrgs.Add(model.OrgId); } } //获取审批流程和审批岗位的对应关系 List <GAppvalProc4PostModel> proc4PostModels = GAppvalProc4PostFacade.Find(t => t.ProcPhid == procModel.PhId).Data.ToList(); //获取审批流程的启用条件 List <GAppvalProcCondsModel> procCondsModels = null; FindedResults <GAppvalProcCondsModel> findedResults = GAppvalProcCondsFacade.Find(t => t.ProcPhid == procModel.PhId); if (findedResults != null && findedResults.Data != null && findedResults.Data.Count > 0) { procCondsModels = findedResults.Data.ToList(); } else { procCondsModels = new List <GAppvalProcCondsModel>(); } //新增审批流程 foreach (Organize model in addOrgs) { /* * 这里审批流程添加启用组织,虽然审批流程,审批流程和岗位的对应关系,审批流程条件这些数据都是一样的 * 但是也不能直接将查询得到的数据赋值给审批流程对象去保存 * 因为循环过程中,每一个保存的审批流程对象,审批流程和岗位的对应关系对象,审批流程条件对象实际指向的都是内存中同一个内存地址,也就是同一个对象 * 又因为事务没有提交,循环保存的时候,同一个对象被多次保存,生成不同的主键,会导致报错, * 所有要通过工具类复制一个对象 */ GAppvalProcModel existProcModel = existProcModels[0]; GAppvalProcModel gAppval = CommonUtils.TransReflection <GAppvalProcModel, GAppvalProcModel>(existProcModel); gAppval.OrgPhid = model.OrgId; gAppval.OrgCode = model.OrgCode; List <GAppvalProc4PostModel> proc4Posts = new List <GAppvalProc4PostModel>(); foreach (GAppvalProc4PostModel proc4Post in proc4PostModels) { GAppvalProc4PostModel gAppvalProc = CommonUtils.TransReflection <GAppvalProc4PostModel, GAppvalProc4PostModel>(proc4Post); proc4Posts.Add(gAppvalProc); } List <GAppvalProcCondsModel> condsModels = new List <GAppvalProcCondsModel>(); foreach (GAppvalProcCondsModel conds in procCondsModels) { GAppvalProcCondsModel procCondsModel = CommonUtils.TransReflection <GAppvalProcCondsModel, GAppvalProcCondsModel>(conds); condsModels.Add(procCondsModel); } gAppval.Proc4PostModels = proc4Posts; gAppval.CondsModels = condsModels; //保存审批流程 SavedResult <Int64> savedResult = GAppvalProcFacade.SaveAppvalProc(gAppval); result += savedResult.SaveRows; } //删除审批流程 List <GAppvalProcModel> deleteProcs = existProcModels.FindAll(t => deleteOrgs.Contains(t.OrgPhid)); result += GAppvalProcFacade.DeleteAppvalProc(deleteProcs); return(result); }