fix issue #I62YDO 保存拖拽表单默认增加InstanceId,方便取关卡的审批意见等信息

This commit is contained in:
yubaolee 2022-12-24 21:38:48 +08:00
parent eb77c29999
commit f55ceba171
3 changed files with 20 additions and 8 deletions

View File

@ -28,5 +28,7 @@
public const string DATAPRIVILEGE_LOGINORG = "{loginOrg}"; //数据权限配置中当前登录用户部门的key
public const string JOBMAPKEY = "OpenJob";
public const string DEFAULT_FORM_INSTANCE_ID_NAME = "InstanceId";
}
}

View File

@ -156,6 +156,14 @@ namespace OpenAuth.App
continue;
}
//讲流程实例ID赋值到表单数据表中实现表单记录与流程实例关联
if (column.ColumnName == Define.DEFAULT_FORM_INSTANCE_ID_NAME)
{
columnstr += $"{Define.DEFAULT_FORM_INSTANCE_ID_NAME},";
valstr += "'" + flowInstance.Id + "',";
continue;
}
var val = json[column.ColumnName];
if (val == null)
{

View File

@ -26,18 +26,19 @@ namespace OpenAuth.App
if (dbType == Define.DBTYPE_SQLSERVER) //Sql Server
{
// 获取字段并处理
var jsonArray = JsonHelper.Instance.Deserialize<JObject>(form.ContentData)["list"];
// 数据库名称
var jsonArray = JsonHelper.Instance.Deserialize<JObject>(form.ContentData)["widgetList"];
string tableName = form.DbName;
//如果数据库已经存在该表,则不用创建
var exist = _unitWork.FromSql<QueryStringObj>($"select '1' as value from sysobjects where name = '{tableName}' and type = 'U'").SingleOrDefault();
if (exist != null) return string.Empty;
// 创建数据
// 如果数据库没有指定的表,则创建表
StringBuilder sql = new StringBuilder($"CREATE TABLE {tableName} ( [Id] varchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL,"); //主键
sql.Append($"[{Define.DEFAULT_FORM_INSTANCE_ID_NAME}] varchar(50) COLLATE Chinese_PRC_CI_AS,"); //默认加上FlowinstanceId字段记录关联的流程实例ID
string sqlDefault = "";
foreach (var json in jsonArray)
{
string type = json["type"].ToString();
string name = json["model"].ToString();
string name = json["options"]["name"].ToString();
sql.Append("[" + name + "] " + field_type_sql(type)); //字段拼接
if ("checkboxs" == type)
sqlDefault += field_type_sql_default(tableName, name, "0");
@ -58,17 +59,18 @@ namespace OpenAuth.App
else
{
// 获取字段并处理
var jsonArray = JsonHelper.Instance.Deserialize<JObject>(form.ContentData)["list"];
// 数据库名称
var jsonArray = JsonHelper.Instance.Deserialize<JObject>(form.ContentData)["widgetList"];
string tableName = form.DbName;
//如果数据库已经存在该表,则不用创建
var exist = _unitWork.FromSql<QueryStringObj>($"select distinct table_name as value from information_schema.tables where table_name ='{tableName}'").SingleOrDefault();
if (exist != null) return string.Empty;
// 创建数据
// 如果数据库没有指定的表,则创建表
StringBuilder sql = new StringBuilder($"create table if not exists `{tableName}` ( Id varchar(50) not null primary key,"); //主键
sql.Append($"`{Define.DEFAULT_FORM_INSTANCE_ID_NAME}` varchar(50),"); //默认加上FlowinstanceId字段记录关联的流程实例ID
foreach (var json in jsonArray)
{
string type = json["type"].ToString();
string name = json["model"].ToString();
string name = json["options"]["name"].ToString();
sql.Append("`" + name + "` " + field_type_mysql(type)); //字段拼接
}