/******************************* * 说明:基础档案审批接口 * 创建人:龚宇超 * 创建日期:2017-12-19 * 修改人: * 修改日期: * 修改备注: * 版本:1.0.0.0 ********************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Lskj.Core; using System.Data.SqlClient; using Lskj.Model; using Lskj.Util; namespace Lskj.Business.Impl { /// /// 基础档案审批相关接口实现 /// public class BaseAuditImpl : BaseModuleImpl { /// /// 说明:设置确认信息 /// 创建人:龚宇超 /// 创建日期:2017-12-19 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 确认权限Id /// 用户Id /// 确认意见. /// System.Int32. public static int SetBaseFlowComfirm(string UserId, string ModuleCode, string PrimaryValue, string comfirmAdvice) { int result = 0; if (BaseImpl.HasExistsTable("p_baseflowComfirm")) { string sqlValue = string.Format("Update p_baseflowComfirm set comfirmFlag=1,comfirmOper='{0}',comfirmDate='{1}',comfirmAdvice='{2}' where modid='{3}' and keyvalue='{4}' and operatorid='{5}'", UserId, DateTime.Now.ToString(), comfirmAdvice, ModuleCode, PrimaryValue, ERPInfo.Instance.UserId); result = ExecSqlValue(sqlValue); } return result; } /// /// 说明:判断存储过程参数方法 /// 创建人:王一帆 /// 创建日期:2020-11-18 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 确认权限Id /// 用户Id /// 确认意见. /// System.Int32. public static bool isParamComplete(string storedName, string[] Param) { string whereConfig = string.Empty; for (int i = 0; i < Param.Length; i++) { whereConfig += string.Format(" LOWER(PARAMETER_NAME)=LOWER('{0}') or", Param[i]); } string sql = string.Format("SELECT PARAMETER_NAME AS [参数名称] FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME='{1}' and ({0})", whereConfig.Substring(0, whereConfig.Length - 2), storedName); return SqlHelper.ExecuteDataTable(sql).Rows.Count == Param.Length; } /// /// 说明:返回审批结果(通用多种审批处理结果) /// 创建人:龚宇超 /// 创建日期:2017-12-11 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 基础模型 /// 步骤编号 /// 单据编号. /// 特定消息 /// 存储过程名. /// 审批方向'F'=审批,'R'反审批 'Q' 关闭. /// 提醒 /// 意见文本. /// 提醒人 /// 确认人 /// 是否为返退处理true [ret]. /// 返退参数 /// System.String. public static string Audit(out string nextSelectStepCode, out string nextSelectStepOper, DynamicModel sysModel, string stepCode, string billDocumentId, string message, string storedName, string accractFlag, string remindSelect, string remarkText = "", string remindOpers = "", string confirmOpers = "", bool ret = false, int returnd = 0, int selectConfirmFlag = 0, bool IsStepOver = false) { bool newAudit = true; int i = 8; string[] newParameter = new string[] { "@nextSelectStepCode", "@nextSelectStepOper", "@selectConfirmFlag" }; if (!isParamComplete(storedName, newParameter)) newAudit = false; SqlParameter msg = ERPInfo.Instance.ChangeParameterType ? new SqlParameter("@msg", SqlDbType.NVarChar, 6000) : new SqlParameter("@msg", SqlDbType.VarChar, 3000); msg.Direction = ParameterDirection.Output; SqlParameter NextSelectStepCode = new SqlParameter("@nextSelectStepCode", SqlDbType.VarChar, 3000); NextSelectStepCode.Direction = ParameterDirection.Output; SqlParameter NextSelectStepOper = new SqlParameter("@nextSelectStepOper", SqlDbType.VarChar, 3000); NextSelectStepOper.Direction = ParameterDirection.Output; List list = new List { new SqlParameter("@typeCode",SqlDbType.VarChar,10), new SqlParameter("@stepCode",SqlDbType.Int,4), new SqlParameter("@billDocumentId",SqlDbType.VarChar,200), new SqlParameter("@operatorId",SqlDbType.Int,4), ERPInfo.Instance.ChangeParameterType ?new SqlParameter("@operatorName",SqlDbType.NVarChar,40):new SqlParameter("@operatorName",SqlDbType.VarChar,20), new SqlParameter("@auditAdvice",SqlDbType.VarChar,500), new SqlParameter("@Direction",SqlDbType.Char,1), msg, }; if (newAudit) { list.Add(new SqlParameter("@selectConfirmFlag", SqlDbType.Int, 4)); list.Add(NextSelectStepCode); list.Add(NextSelectStepOper); } if (remindSelect == "1") { list.Add(new SqlParameter("@hint_opers", SqlDbType.VarChar, 8000)); list.Add(new SqlParameter("@comfirm_opers", SqlDbType.VarChar, 8000)); } if (ret) list.Add(new SqlParameter("@backStepCode", SqlDbType.Int, 4)); SqlParameter[] param = list.ToArray(); param[0].Value = sysModel.ModuleCode; param[1].Value = string.IsNullOrEmpty(stepCode) ? 0 : Convert.ToInt32(stepCode); param[2].Value = billDocumentId; param[3].Value = sysModel.UserId; param[4].Value = sysModel.UserName; param[5].Value = accractFlag == "F" ? remarkText : IsStepOver ? "由[" + sysModel.UserName + "]强制退回,意见:" + remarkText : remarkText; param[6].Value = accractFlag; param[7].Value = ""; if (newAudit) { param[8].Value = selectConfirmFlag; param[9].Value = ""; param[10].Value = ""; i += 3; } if (remindSelect == "1") { param[i].Value = remindOpers; param[i + 1].Value = confirmOpers; i += 2; } if (ret) { param[i].Value = returnd; } SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, storedName, "bill", param); nextSelectStepCode = NextSelectStepCode.Value + ""; nextSelectStepOper = NextSelectStepOper.Value + ""; return msg.Value + ""; } /// /// 说明:返回审批结果(Return 值用于逻辑判断;@msg 用于提示展示) /// 创建人:龚宇超 /// 创建日期:2017-12-11 /// 修改日期:2025-09-10(新增重载:返回 SP Return 值;@msg 通过 out) /// /// 步骤编号 /// 单据编号. /// 特定消息 /// 存储过程名. /// 审批方向'F'=审批,'R'反审批 'Q' 关闭. /// 提醒 /// 意见文本. /// 提醒人 /// 确认人 /// 是否为返退处理true [ret]. /// 返退参数 /// 确认标识:默认传0 public static string Audit( out string nextSelectStepCode, out string nextSelectStepOper, out string msgText, // 新增:@msg 输出 DynamicModel sysModel, string stepCode, string billDocumentId, string message, // 兼容保留 string storedName, string accractFlag, string remindSelect, string remarkText = "", string remindOpers = "", string confirmOpers = "", bool ret = false, int returnd = 0, int selectConfirmFlag = 0, bool IsStepOver = false, int comfirm = 0) { bool newAudit = true; int i = 8; string[] newParameter = new string[] { "@nextSelectStepCode", "@nextSelectStepOper", "@selectConfirmFlag" }; if (!isParamComplete(storedName, newParameter)) newAudit = false; // 输出参数 SqlParameter pMsg = ERPInfo.Instance.ChangeParameterType ? new SqlParameter("@msg", SqlDbType.NVarChar, 6000) : new SqlParameter("@msg", SqlDbType.VarChar, 3000); pMsg.Direction = ParameterDirection.Output; SqlParameter pNextSelectStepCode = new SqlParameter("@nextSelectStepCode", SqlDbType.VarChar, 3000); pNextSelectStepCode.Direction = ParameterDirection.Output; SqlParameter pNextSelectStepOper = new SqlParameter("@nextSelectStepOper", SqlDbType.VarChar, 3000); pNextSelectStepOper.Direction = ParameterDirection.Output; // Return 值参数 SqlParameter pReturn = new SqlParameter("@RETURN_VALUE", SqlDbType.Int) { Direction = ParameterDirection.ReturnValue }; // 入参 List list = new List { new SqlParameter("@typeCode", SqlDbType.VarChar, 10), new SqlParameter("@stepCode", SqlDbType.Int, 4), new SqlParameter("@billDocumentId", SqlDbType.VarChar, 200), new SqlParameter("@operatorId", SqlDbType.Int, 4), ERPInfo.Instance.ChangeParameterType ? new SqlParameter("@operatorName", SqlDbType.NVarChar, 40) : new SqlParameter("@operatorName", SqlDbType.VarChar, 20), new SqlParameter("@auditAdvice", SqlDbType.VarChar, 500), new SqlParameter("@Direction", SqlDbType.Char, 1), pMsg }; if (newAudit) { list.Add(new SqlParameter("@selectConfirmFlag", SqlDbType.Int, 4)); list.Add(pNextSelectStepCode); list.Add(pNextSelectStepOper); } if (remindSelect == "1") { list.Add(new SqlParameter("@hint_opers", SqlDbType.VarChar, 8000)); list.Add(new SqlParameter("@comfirm_opers", SqlDbType.VarChar, 8000)); } if (ret) { list.Add(new SqlParameter("@backStepCode", SqlDbType.Int, 4)); } //判断是否存在confirmFlag参数 DataTable dt = GetDataTableResult(string.Format("select * from syscolumns where id =object_id('{0}') and name='@confirmFlag'", storedName)); if (dt != null && dt.Rows.Count > 0) { SqlParameter Flag = new SqlParameter("@confirmFlag", SqlDbType.Int, 4); Flag.Value = comfirm; list.Add(Flag); } // 追加 Return 参数 list.Add(pReturn); SqlParameter[] param = list.ToArray(); // 赋值 param[0].Value = sysModel.ModuleCode; param[1].Value = string.IsNullOrEmpty(stepCode) ? 0 : Convert.ToInt32(stepCode); param[2].Value = billDocumentId; param[3].Value = sysModel.UserId; param[4].Value = sysModel.UserName; param[5].Value = (accractFlag == "F") ? remarkText : (IsStepOver ? $"由[{sysModel.UserName}]强制退回,意见:{remarkText}" : remarkText); param[6].Value = accractFlag; param[7].Value = ""; // @msg 初始 if (newAudit) { param[8].Value = selectConfirmFlag; param[9].Value = ""; // @nextSelectStepCode 初始 param[10].Value = ""; // @nextSelectStepOper 初始 i += 3; } if (remindSelect == "1") { param[i].Value = remindOpers; param[i + 1].Value = confirmOpers; i += 2; } if (ret) { param[i].Value = returnd; } // 执行 SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, storedName, "bill", param); // 输出赋值 nextSelectStepCode = pNextSelectStepCode.Value + ""; nextSelectStepOper = pNextSelectStepOper.Value + ""; msgText = pMsg.Value + ""; // 返回存储过程 Return 值(以字符串返回,便于 "1".Equals(...) 判断) string retCode = (pReturn.Value == null || pReturn.Value == DBNull.Value) ? "0" : Convert.ToInt32(pReturn.Value).ToString(); if (retCode.Equals("-1")) { if (SqlHelper.ConnectionType == ConnectionType.SqlServer) { SqlStoredProcedurepPrompt.GenerateAuditExecutionScript(sysModel, stepCode, billDocumentId, storedName, accractFlag, remindSelect, remarkText, remindOpers, confirmOpers, ret, returnd, selectConfirmFlag, IsStepOver, comfirm); } if (SqlHelper.ConnectionType == ConnectionType.DmServer) { SqlStoredProcedurepPrompt.GenerateBillSaveScript_DM(SqlHelper.LastFailureSql); } } return retCode; } /// /// 说明:获取审批流程第一个tab /// 创建人:龚宇超 /// 创建日期:2017-12-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号. /// 角色名 /// 表名 /// DataTable. public static DataRow GetDefaultStepTab(string menuCode, string operatorName, string table) { string sqlValue = string.Format(@"select top 1 stepGroup,stepCode from {0} where typecode=@menuCode " + " and CHARINDEX(',@OperatorName,', ','+operuser+',')>0 " + " and typekey is not null " + "order by stepCode", table); DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@menuCode", menuCode), new SqlParameter("@OperatorName", operatorName) }); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取模块操作人 /// 创建人:龚宇超 /// 创建日期:2017-12-11 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 单据编号 /// 流程进度. /// 单据和基础标记 /// DataTable. public static DataRow GetSystemOperators(string billDocumentId, string stepCode, string flag) { string sqlValue = flag == "bill" ? "select operators,typeName menuname,'2'+CAST(b.id as varchar(10)) id from wms_billflowOper a,p_systembilltype b where a.modid=b.typeCode and keyvalue=@billdocumentId and stepcode=@stepCode and a.stepover=0" : "select operators,ToolsName menuname,'1'+CAST(b.dllid as varchar(10)) id from P_baseflowOper a,P_systemdlltab b where a.modid=b.DllCoid and keyvalue=@billdocumentId and stepcode=@stepCode and a.stepover=0"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@billdocumentId", billDocumentId), new SqlParameter("@stepCode", stepCode) }); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取流转操作人员(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号 /// 主键值 /// DataRow. public static DataRow GetFlowOperators(string menuCode, string paramaryValue, string stepcode) { DataTable dtTable = new DataTable(); if (SqlHelper.ExecuteDataTable("select object_id('p_baseflowoperex')").Rows.Count > 0 && int.Parse(SqlHelper.ExecuteScalar("select count(*) from sysobjects where id = object_id('p_baseflowoperex')") + "") > 0) { string sqlValue = @"select browsers,operators from p_baseflowoperex where modid=@MenuCode and keyvalue=@ObjectId and stepcode=@stepcode"; dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@MenuCode", menuCode), new SqlParameter("@ObjectId", paramaryValue), new SqlParameter("@stepcode", stepcode) }); } return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取审批流程步骤进度值 /// 创建人:龚宇超 /// 创建日期:2017-12-11 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号 /// DataTable. public static DataRow GetFlowStepCode(string menuCode) { string sqlValue = "select top 1 stepCode from p_systembillflow where typeCode=@MenuCode order by stepCode desc"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter("@MenuCode", menuCode)); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取弹出模块流转数据 /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 表名 /// 主键名称. /// 主键值. /// DataRow. public static DataRow GetCurrentFlowRowData(string tableName, string paramaryKey, string paramaryValue) { DataTable dtTable = SqlHelper.ExecuteDataTable(string.Format("select * from {0} where {1} = '{2}'", tableName, paramaryKey, paramaryValue)); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取当前弹出的审批进度跟踪内容 /// 创建人:龚宇超 /// 创建日期:2017-12-14 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号 /// 步骤编号 /// public static DataRow GetCurrentStepFlow(string menuCode, string stepCode) { string sqlValue = "select * from P_systemdlltabflow where typeCode=@menuCode and stepCode=@stepCode"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@menuCode", menuCode), new SqlParameter("@stepCode", stepCode) }); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取当前流转步骤(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号. /// 单据类别 /// 步骤编号. /// DataRow. public static DataRow GetCurrentFlowStep(string menuCode, string billType, string stepCode) { string sqlValue = @"select * from p_systemdlltabflowtypestep where typecode=@MenuCode and billtype=@BillType and stepcode=@StepCode"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@MenuCode", menuCode), new SqlParameter("@BillType", billType), new SqlParameter("@StepCode", stepCode) }); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取当前控件数据(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 配置SQl /// 主键名称 /// 当前数据主键. /// DataRow. public static DataRow GetCurrentControlData(string sql, string primaryKey, string paramaryValue) { string sqlValue = sql + string.Format(" and {0}='{1}'", primaryKey, paramaryValue); DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 得到确认人和提醒人(弹出提醒模块) /// 创建人:龚宇超 /// 创建日期:2017-12-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号 /// 主键值 /// DataRow. public static DataRow GetConfirmAndRemindOpers(string menuCode, string paramaryValue) { string sqlValue = @"select comfirmOpers,remindOpers from p_baseflowOper where modid =@modid and keyvalue=@keyvalue"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@modid", menuCode), new SqlParameter("@keyvalue", paramaryValue) }); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 获取本次推送人员(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 主键值. /// 步骤编码 /// DataRow. public static DataRow GetPushedOpers(string paramaryValue, string stepCode) { string sqlValue = "select operators,ToolsName menuname,'1'+CAST(b.dllid as varchar(10)) id from P_baseflowOper a,P_systemdlltab b where a.modid=b.DllCoid and keyvalue=@keyvalue and stepcode=@stepcode and a.stepover=0"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@keyvalue", paramaryValue), new SqlParameter("@stepcode", stepCode) }); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取新版审批的设置规则 /// 创建人:王一帆 /// 创建日期:2020-11-13 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 当前模块编号. /// 当前审批数据的单据类别 /// 当前审批数据的步骤 /// DataTable. public static DataRow SetUpNextStep(string typecode, string billtype, string stepcode) { string sqlValue = string.Format(@"select nextStepSelect, --步骤选择标记 nextOperSelect, multiAudit from p_systemdlltabflowtypestep where typecode='{0}' and billtype={1} and stepcode={2} ", typecode, billtype, stepcode); DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:获取新版审核用户确认后的数据源 /// 创建人:王一帆 /// 创建日期:2020--11-13 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 当前模块编号. /// 步骤的返回值 /// DataTable. public static DataTable GetUpNextStepGrid(string typecode, string nextSelectStepCode) { string sqlValue = string.Format(@"select stepcode,stepname from p_systemdlltabflow where typecode='{0}' and charindex(';'+cast(stepcode as varchar)+';',';{1};')>0 ", typecode, nextSelectStepCode); return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:获取选项卡 /// 创建人:龚宇超 /// 创建日期:2017-12-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号. /// 菜单条件 /// 表名. /// DataTable. public static DataTable GetTabPages(string menuCode, string mMenuCond, string table) { string sqlstr = string.IsNullOrEmpty(mMenuCond) ? "" : "and stepCode in (@mMenuCond)"; SqlParameter[] parms = string.IsNullOrEmpty(sqlstr) ? new SqlParameter[] { new SqlParameter("@menuCode", menuCode) } : new SqlParameter[] { new SqlParameter("@menuCode", menuCode), new SqlParameter("@mMenuCond", mMenuCond) }; string sqlValue = string.Format("select stepGroup,MAX(id) as id,MAX(stepCode) stepCode from {1} where typeCode=@menuCode {0} group by stepGroup order by stepCode", sqlstr, table); return SqlHelper.ExecuteDataTable(sqlValue, parms); } /// /// 说明:加载默认审批flow表格列 /// 创建人:龚宇超 /// 创建日期:2017-12-13 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetFlowGridColomns() { string sqlValue = @" select '1' id , 'stepCode' fieldName, 65 width, '' sysname , '步骤代码' username, '' dataFormat ,'' fieldsqltag union select '2' , 'stepName' ,148 , '' , '步骤名称' , '','' union select '3' , 'happenTime' ,120 , '' , '发生时间' , '' ,'444' union select '4' , 'operTime' ,120 , '' , '操作时间' , '','444' union select '5' , 'operatorName' ,120 ,'' , '操作人员' ,'' ,'' union select '6' , 'operDirectionName' ,58 , '' , '操作方向' ,'','' union select '7' , 'operAdvice' ,273 , '' , '操作建议' , '','' union select '8' , 'autoStep' ,63 , '' , '自动审核' , '' ,'' "; return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:获取审批流程跟踪信息 /// 创建人:龚宇超 /// 创建日期:2017-12-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 表名. /// 模块编号. /// 审批流程组 /// DataTable. public static DataTable GetFlowStepTab(string table, string menuCode, string stepGroup) { string sqlValue = string.Format("select * from {0} where typeCode=@menuCode and stepGroup=@stepGroup order by stepCode asc", table); return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@menuCode", menuCode), new SqlParameter("@stepGroup", stepGroup) }); } /// /// 说明:获取审批表格列配置 /// 创建人:龚宇超 /// 创建日期:2017-12-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 表格名 /// 模块编号. /// 进度编号 /// 角色名 /// DataTable. public static DataTable GetGridColumns(string table, string menuCode, string stepCode, string operatorName,bool TotalExistsTask=false) { string text= TotalExistsTask? ",isSum" : ""; string sqlValue = string.Format(@"select isnull(CASE WHEN ISNULL(b.userList,'')='' AND ISNULL(a.PrivilegeView,'')<>'' THEN 0 ELSE width END,0) width,a.id, a.typeCode,a.stepCode,a.fieldName,a.sysName,a.userName,a.orderid,a.isVisible,a.privilegeView,a.MobileWidth,a.DataFormat {1} from {0} a left join ( SELECT userList,privTypeId from p_systemPrivilege b where modId =@menuCode and ISNULL(userList,'')<>'' AND CHARINDEX(@username + ',', userList + ',') > 0 ) b on CHARINDEX(CAST(b.privTypeId AS VARCHAR(5)) + ',',a.PrivilegeView + ',') > 0 where isnull(a.isVisible,0)=0 and typeCode=@menuCode and stepCode=@stepCode order by orderid", table, text); return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@menuCode", menuCode), new SqlParameter("@stepCode", stepCode), new SqlParameter("@username", operatorName) }); } /// /// 说明:获取终审表格数据 /// 创建人:龚宇超 /// 创建日期:2017-12-11 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 基础档案审批模型. /// 取消标记 true [cancel flag]. /// 搜索条件 /// DataTable. public static DataTable GetGridFinishData(BaseAccraditationModel model, bool cancelFlag, string cond) { string tmpsql = string.Empty; if (!string.IsNullOrEmpty(model.MenuCond)) { cond += string.Format(" and ({0}stepCode > {1} OR ({0}stepCode >= {1} and isnull({0}stepover,0)=1))", model.ColumnPrefix, model.MenuCond.Split(',').Last()); tmpsql = string.Format(@"select " + model.KeyField + @" as Billdocument_Id,convert(varchar(25),{0}Operatedate,120) as OperateDate, dbo.P_GetOperator({0}operatorid) as OperatorName,{0}stepCode as stepCode, convert(varchar(25),{0}AffirmDate,120) as AffirmDate,dbo.P_GetOperator({0}affirmer) as AffirmerName, case when ISNULL(a.{0}StepOverName,'')='' then (select top 1 operatorName from p_baseflowstep b where a.{0}Billdocument_Id=b.flowSourceKey and a.{0}stepCode-100 = b.stepCode order by b.endTime desc) else a.{0}StepOverName end StepOverName, convert(varchar(25),case when ISNULL(a.{0}StepOverTime,'')='' then (select top 1 endTime from p_baseflowstep b where a.{0}Billdocument_Id=b.flowSourceKey and a.{0}stepCode-100 = b.stepCode order by b.endTime desc) else a.{0}StepOverTime end,120) StepOverTime," + (cancelFlag == true ? "case when isnull({0}cancelFlag,0)=1 then '关闭' else '正常' end " : "'正常'") + " as stepClosed " + "from " + model.BillTable + @" a where 1=1 ", model.ColumnPrefix) + cond; } else { cond += string.Format(" and isnull({0}stepover,0)=1 ", model.ColumnPrefix); tmpsql = string.Format("select " + model.KeyField + @" as Billdocument_Id,convert(varchar(25),{0}Operatedate,120) as OperateDate, dbo.P_GetOperator({0}operatorid) as OperatorName,{0}stepCode as stepCode, convert(varchar(25),{0}AffirmDate,120) as AffirmDate,dbo.P_GetOperator({0}affirmer) as AffirmerName, {0}StepOverName as StepOverName,convert(varchar(25),{0}StepOverTime,120) as StepOverTime," + (cancelFlag == true ? "case when isnull({0}cancelFlag,0)=1 then '关闭' else '正常' end " : "'正常'") + " as stepClosed " + "from " + model.BillTable + " a " + "where 1=1", model.ColumnPrefix) + cond; } if (!string.IsNullOrWhiteSpace(model.OverBackCond)) tmpsql = tmpsql + " and (" + ReplaceHelper.ReplaceUserInfo(model.OverBackCond) + ")"; if (!string.IsNullOrWhiteSpace(model.OverBackOper)) tmpsql = tmpsql + " and charindex('" + ERPInfo.Instance.UserName + ",','" + model.OverBackOper + ",')>0"; return SqlHelper.ExecuteDataTable(tmpsql); } /// /// 说明:填充GridFlow数据 /// 创建人:龚宇超 /// 创建日期:2017-12-11 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 单据编号. /// 表名. /// 菜单条件 /// DataTable. public static DataTable GetGridFlowData(string billCode, string table, string mMenuCond) { // 假如为分段,则取最大步骤作为终审数据 string cond = !string.IsNullOrEmpty(mMenuCond) ? "and stepcode<=" + mMenuCond.Split(',').Last() : ""; if (SystemInfo.Instance.AutomaticStepHidie) { cond += " and autoStep !=1 "; } string sqlValue = string.Format(@"select stepCode,stepName,happenTime,operatorName,operTime, case when operDirection='F' then '审核' when operDirection='Q' then '关闭' else '返退' end as operDirectionName, applyTime,operAdvice, case when autoStep=1 then '自动' else '' end as autoStep from {0} a where a.flowSourceKey=@BillCode {1} order by operTime", table, cond); return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@BillCode", billCode) }); } /// /// 说明:加载流转记录的列(基础审批弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetFlowRecordColumn() { string sqlValue = @" select '1' id ,'sh' fieldName,58 width,'' sysname ,'状态' username , '' dataFormat,'9' fieldsqltag union select '2' ,'stepName',150 ,'' ,'环节名称' ,'','9' union select '3' ,'operAdvice',120 ,'' ,'审核意见' ,'','9' union select '4' , 'operTime',67 ,'' ,'审核时间' ,'','9' union select '5' ,'operatorName' ,120 ,'' ,'审核人' ,'','9'"; return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:会签记录默认列 (基础审批弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-21 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetSignRecordCoulumn() { string sqlValue = @" select'1' id ,'operateName' fieldName,70 width,'' sysname, '操作员' username ,'' dataFormat union select'2' ,'operateDate',120 ,'' , '操作时间' , '' union select'3' ,'comfirmName',70 ,'' , '确认人' ,'' union select'4' , 'comfirmDate',150 ,'' , '确认时间' , '' union select'5' , 'comfirmAdvice',200 ,'' , '确认意见' , '' union select '6' , 'Remark',200 ,'' , '备注' , '' "; return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:提醒记录默认列 (基础审批弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-21 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetRemindColumn() { string sqlValue = @" select'1' id ,'needComfirm' fieldName,50 width,'' sysname , '需确认' username ,'' dataFormat union select'2' ,'remind_stepName' ,75 ,'' , '步骤名' username ,'' union select'3' ,'operateName' ,70 ,'' , '操作员' username ,'' union select'4' , 'operateDate',120 ,'' , '操作时间' username ,'' union select'5' , 'comfirmName',70 ,'' , '确认人' username ,'' union select '6' ,'comfirmDate' ,120 ,'' , '确认时间' username ,'' union select '7' , 'comfirmAdvice' ,200 ,'', '确认意见' username ,'' union select '8' , 'Remark' ,400 ,'' , '备注' username ,'' "; return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:获取提醒记录(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-20 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 单据表. /// 确认表. /// 主键值 /// 模块编号 /// DataTable. public static DataTable GetRemindinRecord(string billTable, string confirmTable, string paramaryValue, string menuCode) { string sqlValue = string.Format(@"select b.stepName remind_stepName,CAST(a.needComfirm as bit) needComfirm,dbo.P_GetOperator(a.operatorid) operateName,a.operateDate,dbo.P_GetOperator(a.comfirmOper) comfirmName,a.comfirmDate,a.comfirmAdvice,a.Remark from {1} a left join {0} b on a.billtype=b.billType and a.stepcode=b.stepCode where a.signFlag=0 and a.keyvalue=@keyvalue and a.modid=@modid ", billTable, confirmTable); return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@keyvalue", paramaryValue), new SqlParameter("@modid", menuCode) }); } /// /// 说明:获取会签记录(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-20 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 表名. /// 主键值. /// 模块编号. /// DataTable. public static DataTable GetSignRecord(string table, string paramaryValue, string menuCode) { string sqlValue = string.Format(@"select dbo.P_GetOperator(operatorid) operateName,operateDate,dbo.P_GetOperator(comfirmOper) comfirmName,comfirmDate,comfirmAdvice,Remark from {0} where signFlag=1 and keyvalue=@keyvalue and modid=@modid", table); return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@keyvalue", paramaryValue), new SqlParameter("@modid", menuCode) }); } /// /// 说明:获取选项卡数据(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-20 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 模块编号/param> /// 步骤编号 /// DataTable. public static DataTable GetAttachTabs(string menuCode, string stepCode, string whereCond = "") { string columnStr = ""; string DetailIsSave = ""; string unionCond = ""; string fields = ""; if (string.IsNullOrEmpty(whereCond)) whereCond = " and orderid > 0 "; DataTable dataTable = GetTableColumns("p_systembillauditAttach"); if (dataTable.Columns.Contains("rightVisible")) { columnStr = ",rightVisible"; } if (dataTable.Columns.Contains("DetailIsSave")) { DetailIsSave = ",DetailIsSave"; } if (dataTable.Columns.Contains("unionmodule") && dataTable.Columns.Contains("unionValue") && dataTable.Columns.Contains("unionParentField") && dataTable.Columns.Contains("unionCond")) { unionCond = ",unionmodule unionModule,unionValue,unionParentField,unionCond"; } if (dataTable.Columns.Contains("privilegeoper")) { fields += ",privilegeoper"; } if (dataTable.Columns.Contains("enablecond")) { fields += " ,enablecond"; } if (dataTable.Columns.Contains("DBClickEvent")) { fields += " ,DBClickEvent"; } if (dataTable.Columns.Contains("LoadFilter")) { fields += " ,LoadFilter"; } if (dataTable.Columns.Contains("IsUnioDetail")) { fields += " ,IsUnioDetail"; } if (dataTable.Columns.Contains("gridDetailCheck")) { fields += " ,gridDetailCheck"; } if (dataTable.Columns.Contains("DetailSearch")) { fields += " ,DetailSearch"; } if (dataTable.Columns.Contains("DragExecuteSql")) { fields += " ,DragExecuteSql"; } string sqlCond = string.Empty; List parames = new List { new SqlParameter("@typeCode",menuCode), new SqlParameter("@stepcode",stepCode) }; SqlParameter[] parameters = parames.ToArray(); string sqlValue = string.Format(@"select id,attachName detailName,orderid,attachSql detailSql,attachType detailType,formKey,'' autoRefresh{3} {1} {2} {4} from p_systembillauditAttach where typeCode=@typeCode {0} and isnull(stepcode,0)=@stepCode and isnull(isVisible,0)=0 order by orderid", whereCond, columnStr, DetailIsSave, unionCond, fields); return SqlHelper.ExecuteDataTable(sqlValue, parameters); } /// /// 说明:获取下面基本信息选项卡(弹出模块) /// 创建人:龚宇超 /// 创建日期:2017-12-20 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 键值. /// DataTable. public static DataTable GetBottomBasicInformation(string formKey) { string sqlValue = "select * from P_systembillauditAttachDetail where attachKey=@attachKey and isnull(isvisible,0)=0 order by orderid"; return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@attachKey", formKey) }); } /// /// 说明:获取下面附加信息明细(弹出模块) /// 创建人:王一帆 /// 创建日期:2021-01-21 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 键值. /// DataTable. public static DataRow GetBottomDetailModel(string formKey) { string sqlValue = "select * from p_systemDlltabDetail where formKey=@formKey"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@formKey", formKey) }); return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null; } /// /// 说明:加载流转记录的数据(弹出基础审批模块) /// 创建人:龚宇超 /// 创建日期:2017-12-21 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 表名. /// 主键值 /// DataTable. public static DataTable GetFlowRecordData(string tableName, string paramaryValue, string modeCode) { string fields = string.Empty; if (HasExistsColumn(tableName, "flowSource")) { fields = " and flowSource=@flowSource "; } if (SystemInfo.Instance.CancelFlowSource && tableName.Equals("wms_billflowstep", StringComparison.OrdinalIgnoreCase)) fields = ""; if (SystemInfo.Instance.AutomaticStepHidie) { fields += " and autoStep !=1 "; } //string sqlValue = string.Format("select case when stepcode=0 then stepName else REPLACE(REPLACE(REPLACE(operDirection,'R','退'),'F','审'),'Q','关闭') end as sh,* from {0} where flowSourceKey=@flowSourceKey {1} order by id asc", tableName, fields); string sqlValue = string.Format("select case when stepcode=0 then stepName else REPLACE(REPLACE(REPLACE(REPLACE(operDirection,'R','退'),'F','审'),'Q','关闭'),'J','转交') end as sh,* from {0} where flowSourceKey=@flowSourceKey {1} order by id asc", tableName, fields); if (Business.Impl.LanguageTranslation.Translatable) { string retreat = Business.Impl.LanguageTranslation.GetTranslatedText("退"); string review = Business.Impl.LanguageTranslation.GetTranslatedText("审"); string close = Business.Impl.LanguageTranslation.GetTranslatedText("关闭"); string forward = Business.Impl.LanguageTranslation.GetTranslatedText("转交"); string first = Business.Impl.LanguageTranslation.GetTranslatedText("首次提交"); sqlValue = string.Format(@"SELECT REPLACE( CASE WHEN stepcode=0 THEN stepName ELSE REPLACE(REPLACE(REPLACE(REPLACE(operDirection,'R','{2}'),'F','{3}'),'Q','{4}'),'J','{5}') END, '首次提交', '{6}' ) AS sh, * from {0} where flowSourceKey=@flowSourceKey {1} order by id asc", tableName, fields, retreat, review, close, forward, first); } return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@flowSourceKey", paramaryValue), new SqlParameter("@flowSource", modeCode) }); } /// /// 说明:设置提醒主表列(弹出提醒模块) /// 创建人:龚宇超 /// 创建日期:2017-12-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetRemindSelectColumn() { string sqlValue = @" select '1' id ,'UserId' fieldName,85 width,'编号' username,''sysname,''dataFormat union select'2', 'UserCode' ,85 ,'工号','',''union select '3','UserName' ,350 ,'操作员','',''"; return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:设置提醒和确认人列表列(弹出提醒模块) /// 创建人:龚宇超 /// 创建日期:2017-12-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetPersonColumn() { string sqlValue = @"select '1'id, 'UserCode' fieldName,125 width,'工号' username,'' sysname,'' dataFormat union select '2', 'UserName' ,125 ,'姓名','','' "; return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 绑定提醒选择树(弹出提醒模块) /// 创建人:龚宇超 /// 创建日期:2017-12-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable BindRemindSelectTree() { string sqlValue = string.Format("select SpeciesNo,SpeciesName from {0}", SystemInfo.Instance.HrSpecTab); return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 反退步骤数据集(弹出反退) /// 创建人:龚宇超 /// 创建日期:2017-12-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 流转表名 /// 主表名 /// 流转类别表名 /// 当前步骤编号. /// 主键名 /// 主键值 /// 列前缀 /// DataTable. public static DataTable GetBackSelect(string flowStepTable, string masterTable, string flowTypeStepTable, int currStepCode, string parmaryKey, string paramaryValue, string columnPrefix) { string sqlValue = string.Format(@"select * from (select distinct a.stepCode,c.stepName from {5} a inner join {0} b on a.flowsourcekey=b.{1} inner join {6} c on a.stepCode=c.stepCode and c.billType=b.{2}billtype where a.flowSourceKey='{3}' and isnull(a.autoStep,0)=0 and ISNULL(a.operDirection,'F')='F' and a.stepCode<{4} union all select 0,'退回至提交人') x order by stepcode desc", masterTable, parmaryKey, columnPrefix, paramaryValue, currStepCode, flowStepTable, flowTypeStepTable); if (SystemInfo.Instance.SpecialReverseStep) { sqlValue = string.Format(@"select * from (select distinct a.stepCode,c.stepName from {5} a inner join {0} b on a.flowsourcekey=b.{1} inner join {6} c on a.stepCode=c.stepCode and c.billType=b.{2}billtype where a.flowSourceKey='{3}' and isnull(a.autoStep,0)=0 and ISNULL(a.operDirection,'F')='F' and a.stepCode<{4} and a.operAdvice<>'自动亩核' and a.operAdvice<>'不同意' union all select 0,'退回至提交人') x order by stepcode desc", masterTable, parmaryKey, columnPrefix, paramaryValue, currStepCode, flowStepTable, flowTypeStepTable); } return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 反退步骤数据集(弹出反退) /// 创建人:龚宇超 /// 创建日期:2017-12-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetBackSelect() { string sqlValue = @" select 0 as stepCode,'退回至提交人' as stepName"; return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 反退步骤数据集(弹出反退) /// 创建人:龚宇超 /// 创建日期:2017-12-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The form key. /// DataTable. public static DataTable GetControlLocation(string formKey) { string sqlValue = "select * from v_systemcontrolLocation where formKey=@formKey order by orderid asc"; return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@formKey", formKey) }); } /// /// 说明:执行SQL语句返回结果集 /// 创建人:龚宇超 /// 创建日期:2017-12-28 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 审批表格名称 /// 模块编号 /// DataTable. public static DataTable GetAuditMainGridCoulmns(string tableName, string menuCode) { string sqlValue = string.Format("select *,0 as fieldTypeId,0 as ifMerge from {0} a where typecode='{1}' and stepcode=999 and isnull(isvisible,0)=0 order by orderid", tableName, menuCode); return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:获取审批默认主表格列 /// 创建人:龚宇超 /// 创建日期:2017-12-28 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 区分单据和基础档案 /// DataTable. public static DataTable GetDefaultGridMainColumns(string flag) { string billSysname = flag == "bill" ? "单据号" : "数据标识号"; string sqlValue = string.Format(@" select '1' id ,'stepClosed' fieldName,57 width,'' sysname, '状态' username , '' dataFormat union select '2' ,'Billdocument_Id' ,97 , '' , '{0}' username ,'' union select '3' ,'OperateDate' ,120 ,'' , '制单时间' username, '' union select '4' , 'OperatorName',67 ,'' , '制单人' username, '' union select '5' ,'AffirmDate' ,120 ,'' , '提交时间' username, '' union select '6' ,'AffirmerName' ,70 , '' , '提交人' username , '' union select '7' ,'StepOverTime' ,120 , '' , '终审时间' username, '' union select '8' ,'StepOverName' ,78 ,'' , '终审人' username, '' ", billSysname); return SqlHelper.ExecuteDataTable(sqlValue); } /// /// 说明:获取提醒用户 /// 创建人:龚宇超 /// 创建日期:2017-12-28 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 区分单据和基础档案 /// DataTable. public static DataTable GetRemindSelectOpers(string speciesNo) { string SqlValue = string.Format("select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName from P_employeeTab where sign=0 and SpeciesNo like '{0}%'", speciesNo); return SqlHelper.ExecuteDataTable(SqlValue); } /// /// 说明:获取有代理权限的人员 /// 创建人: /// 创建日期:2023-05-12 /// 修改人: ///