冲突解决
commit
20570d64c7
|
|
@ -190,10 +190,10 @@ namespace OpenAuth.App.FormScheme.FormHelpers
|
|||
{
|
||||
//girdTableMap[component.ComponentProps.DataTable].children.AddRange(column.children);
|
||||
}
|
||||
else
|
||||
{
|
||||
girdTableMap.Add(component.ComponentProps.DataTable, component);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// girdTableMap.Add(component.ComponentProps.DataTable, component);
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -217,7 +217,8 @@ namespace OpenAuth.App.FormScheme.FormHelpers
|
|||
{
|
||||
if (tableMap.ContainsKey(childTable.Name))
|
||||
{
|
||||
var rComponent = tableMap[childTable.RelationName].Find(t => t.ComponentProps.FieldName == childTable.RelationField);
|
||||
//var rComponent = tableMap[childTable.RelationName].Find(t => t.ComponentProps.FieldName == childTable.RelationField);
|
||||
var rComponent = tableMap[childTable.Name].Find(t => t.ComponentProps.FieldName == childTable.RelationField);
|
||||
if (girdTableMap.ContainsKey(childTable.Name))
|
||||
{
|
||||
list.Add(GetDeleteSqlNew(childTable, dataJson, rComponent));
|
||||
|
|
@ -250,7 +251,8 @@ namespace OpenAuth.App.FormScheme.FormHelpers
|
|||
}
|
||||
else
|
||||
{
|
||||
list.Add(GetUpDateSqlNew(childTable, tableMap, dataJson, childTable.Field, dataJson[rComponent.Field].ToString()));
|
||||
//list.Add(GetUpDateSqlNew(childTable, tableMap, dataJson, childTable.Field, dataJson[rComponent.Field].ToString()));
|
||||
list.Add(GetUpDateSqlNew(childTable, tableMap, dataJson, childTable.RelationField, dataJson[rComponent.Field].ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,6 +264,7 @@ namespace OpenAuth.App.FormScheme.FormHelpers
|
|||
foreach (var childTable in childrenTables)
|
||||
{
|
||||
var rComponent = tableMap[childTable.RelationName].Find(t => t.ComponentProps.FieldName == childTable.RelationField);
|
||||
//var rComponent = tableMap[childTable.Name].Find(t => t.ComponentProps.FieldName == childTable.RelationField);
|
||||
FormComponentNewModel newComponent = new FormComponentNewModel() { };
|
||||
newComponent.Field = rComponent.Field;
|
||||
newComponent.ComponentProps = new ComponentPropsModel();
|
||||
|
|
@ -659,8 +662,7 @@ namespace OpenAuth.App.FormScheme.FormHelpers
|
|||
return res;
|
||||
}
|
||||
private static FormDbTable GetUpDateSqlNew(FormDbTableInfo table, Dictionary<string, List<FormComponentNewModel>> tableMap, JObject dataJson, string pkey, string pkeyValue)
|
||||
{
|
||||
string[] noNull = { "_input_39", "_input_51b5805f379942debe4224511f3e5ebe" };
|
||||
{
|
||||
FormDbTable res = new FormDbTable();
|
||||
res.DbParameter = new List<SugarParameter>();
|
||||
res.TableName = table.Name;
|
||||
|
|
@ -689,18 +691,22 @@ namespace OpenAuth.App.FormScheme.FormHelpers
|
|||
//if (dataJson[component.Field] != null && dataJson[component.Field].ToString() == "" && component.CsType == "string" && component.itemProps.required == true)
|
||||
//{
|
||||
// throw new Exception("必填数据不能为空");
|
||||
////}
|
||||
//if (dataJson[component.Field] != null && noNull.Contains(component.Field) && dataJson[component.Field].ToString() == "")
|
||||
//{
|
||||
// throw new Exception("请在数据加载完再进行操作");
|
||||
//}
|
||||
if (dataJson[component.Field] != null && noNull.Contains(component.Field) && dataJson[component.Field].ToString() == "")
|
||||
{
|
||||
throw new Exception("请在数据加载完再进行操作");
|
||||
}
|
||||
//如果传过来的值为"",需要判断下字符类型
|
||||
if (dataJson[component.Field] != null && dataJson[component.Field].ToString() == "" && component.CsType == "string")
|
||||
{
|
||||
res.DbParameter.Add(GetMyDbParameter(component.ComponentProps.FieldName, dataJson[component.Field].ToString(), component.CsType));
|
||||
}
|
||||
//只更新上传的数据,表单其他的不更新
|
||||
//res.DbParameter.Add(new SugarParameter(component.ComponentProps.FieldName, null));
|
||||
else
|
||||
{
|
||||
//只更新上传的数据,表单其他的不更新
|
||||
//res.DbParameter.Add(new SugarParameter(component.ComponentProps.FieldName, null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (component.ComponentProps.FieldName == pkey)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ using OpenAuth.App.FormModule;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using OpenAuth.App.BaseApp.Base;
|
||||
using Castle.Core.Internal;
|
||||
using OpenAuth.App.BaseApp.FormScheme.Request;
|
||||
using OpenAuth.App.BaseApp.FormScheme.Response;
|
||||
using System.Dynamic;
|
||||
using System.Security.Cryptography.Xml;
|
||||
|
||||
namespace OpenAuth.App.FormScheme
|
||||
{
|
||||
|
|
@ -51,7 +55,7 @@ namespace OpenAuth.App.FormScheme
|
|||
ISqlSugarClient sqlSugarClient,
|
||||
ILogger<FormSchemeApp> logger,
|
||||
CommonDataManager dataManager,
|
||||
ISimpleClient<Repository.Domain.FormSchemeInfo> repository,
|
||||
ISimpleClient<Repository.Domain.FormSchemeInfo> repository,
|
||||
BaseDataAuthorizeApp dataAuthorizeApp)
|
||||
: base(unitWork, repository, null)
|
||||
{
|
||||
|
|
@ -1788,5 +1792,116 @@ namespace OpenAuth.App.FormScheme
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取历史数据
|
||||
//public (List<string> Headers, List<dynamic> Data) GetFormDataHistory(FormDataHistoryReq req)
|
||||
//{
|
||||
// // 获取字段说明
|
||||
// var tableDec = GetTableColumnsWithDescriptions(req.table);
|
||||
// //获取表单信息
|
||||
// // 表单
|
||||
// Repository.Domain.FormScheme schemeEntity = GetScheme(req.schemeId).Result;
|
||||
// FormSchemeNewModel formSchemeModel = schemeEntity.Scheme.ToObject<FormSchemeNewModel>();
|
||||
// var chilTable = formSchemeModel.Db.Find(t => t.Type == "chlid");
|
||||
// var reqkey = chilTable.Field;
|
||||
// // 构建字段 SQL
|
||||
// string fieldSql = string.Join(",", req.field);
|
||||
|
||||
// // 构建 SQL 查询语句(参数化,防注入)
|
||||
// var sql = $"SELECT {fieldSql} FROM {req.table} WHERE {reqkey} = @p0";
|
||||
|
||||
// DataTable dt;
|
||||
// using (var db = UnitWork.CreateContext())
|
||||
// {
|
||||
// dt = db.Db.Ado.GetDataTable(sql, new List<SugarParameter>{
|
||||
// new SugarParameter("@p0", req.pkeyValue)
|
||||
// });
|
||||
// }
|
||||
// // 字段中文表头
|
||||
// var headers = req.field.Select(f =>
|
||||
// {
|
||||
// var desc = tableDec.FirstOrDefault(t => t.FieldName == f).Description;
|
||||
// return string.IsNullOrEmpty(desc) ? f : desc;
|
||||
// }).ToList();
|
||||
|
||||
// // 转换 DataTable 为 List<dynamic>
|
||||
// var data = dt.AsEnumerable()
|
||||
// .Select(row =>
|
||||
// {
|
||||
// dynamic obj = new ExpandoObject();
|
||||
// var dict = (IDictionary<string, object>)obj;
|
||||
// foreach (DataColumn col in dt.Columns)
|
||||
// {
|
||||
// dict[col.ColumnName] = row[col];
|
||||
// }
|
||||
// return obj;
|
||||
// }).ToList();
|
||||
|
||||
// return (headers, data);
|
||||
//}
|
||||
public (List<object> Headers, List<dynamic> Data) GetFormDataHistory(
|
||||
FormDataHistoryReq req)
|
||||
{
|
||||
// ① 取到整张表的列名+中文描述
|
||||
var allColumns = GetTableColumnsWithDescriptions(req.table); // [(FieldName,Description)]
|
||||
// 表单
|
||||
Repository.Domain.FormScheme schemeEntity = GetScheme(req.schemeId).Result;
|
||||
FormSchemeNewModel formSchemeModel = schemeEntity.Scheme.ToObject<FormSchemeNewModel>();
|
||||
var chilTable = formSchemeModel.Db.Find(t => t.Type == "chlid");
|
||||
var reqkey = chilTable.Field;
|
||||
|
||||
// ② 先执行查询,拿到数据
|
||||
string fieldSql = string.Join(",", req.field.Select(f => $"\"{f}\""));
|
||||
string sql = $"SELECT {fieldSql} FROM \"{req.table}\" WHERE \"{reqkey}\" = @p0";
|
||||
|
||||
DataTable dt;
|
||||
using (var db = UnitWork.CreateContext())
|
||||
{
|
||||
dt = db.Db.Ado.GetDataTable(sql, new List<SugarParameter>
|
||||
{
|
||||
new SugarParameter("@p0",req.pkeyValue)
|
||||
});
|
||||
}
|
||||
|
||||
// ③ 生成 item1:{title , dataIndex}
|
||||
var item1 = req.field
|
||||
.Select(f =>
|
||||
{
|
||||
var desc = allColumns.FirstOrDefault(c => c.FieldName == f).Description ?? f;
|
||||
// 返回匿名对象,也可以建 DTO
|
||||
return new { title = desc, dataIndex = f };
|
||||
})
|
||||
.ToList<object>();
|
||||
|
||||
// ④ 把 DataTable → List<dynamic> (item2)
|
||||
var item2 = dt.AsEnumerable()
|
||||
.Select(r =>
|
||||
{
|
||||
dynamic obj = new ExpandoObject();
|
||||
var dict = (IDictionary<string, object>)obj;
|
||||
foreach (DataColumn col in dt.Columns)
|
||||
{
|
||||
dict[col.ColumnName] = r[col];
|
||||
}
|
||||
return obj;
|
||||
})
|
||||
.ToList<dynamic>();
|
||||
|
||||
return (item1, item2);
|
||||
}
|
||||
public List<(string FieldName, string Description)> GetTableColumnsWithDescriptions(string tableName)
|
||||
{
|
||||
var list = new List<(string FieldName, string Description)>();
|
||||
using (var db = UnitWork.CreateContext())
|
||||
{
|
||||
var columns = db.Db.DbMaintenance.GetColumnInfosByTableName(tableName, false);
|
||||
foreach (var col in columns)
|
||||
{
|
||||
list.Add((col.DbColumnName, col.ColumnDescription));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.App.BaseApp.FormScheme.Request
|
||||
{
|
||||
public class FormDataHistoryReq
|
||||
{
|
||||
public string table { get; set; }
|
||||
public List<string> field { get; set; }
|
||||
public string pkey { get; set; }
|
||||
public string pkeyValue { get; set; }
|
||||
public string schemeId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.App.BaseApp.FormScheme.Response
|
||||
{
|
||||
public class ColumnHeader
|
||||
{
|
||||
public string FieldName { get; set; } // 列名
|
||||
public string Description { get; set; } // 中文描述
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.App.BaseApp.FormScheme.Response
|
||||
{
|
||||
public class FormDataHistoryRes
|
||||
{
|
||||
public List<ColumnHeader> Headers { get; set; } // 表头(含中文)
|
||||
public List<dynamic> Rows { get; set; } // 数据行
|
||||
}
|
||||
}
|
||||
|
|
@ -52,7 +52,6 @@
|
|||
<Folder Include="BaseApp\Permission\" />
|
||||
<Folder Include="BaseApp\WFTask\Response\新文件夹\" />
|
||||
<Folder Include="ServiceApp\DroneCaseInfoTaskManage\Response\" />
|
||||
<Folder Include="ServiceApp\DroneSsnydManage\Request\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.ServiceApp.DroneSsnydManage.Request;
|
||||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using SqlSugar;
|
||||
using Infrastructure;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
|
@ -16,13 +13,13 @@ namespace OpenAuth.App.ServiceApp.DroneSsnydManage
|
|||
{
|
||||
public class DroneSsnyApp : SqlSugarBaseApp<DroneSsnyd, SugarDbContext>
|
||||
{
|
||||
public DroneSsnyApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<DroneSsnyd> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
public DroneSsnyApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<DroneSsnyd> repository, IAuth auth)
|
||||
: base(unitWork, repository, auth)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 超期预警
|
||||
/// 到期预警
|
||||
/// </summary>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
|
|
@ -72,5 +69,48 @@ namespace OpenAuth.App.ServiceApp.DroneSsnydManage
|
|||
Total = totalCount
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 历史项目
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public PageInfo<List<DroneSsnyd>> HistoryProject(DroneSnnyAppPageReq req)
|
||||
{
|
||||
var totalCount = 0;
|
||||
var list = Repository.AsQueryable()
|
||||
.Where(a => a.handle_status_id == 99)
|
||||
.WhereIF(!string.IsNullOrEmpty(req.xiangmu_no), a => a.xiangmu_no.Contains(req.xiangmu_no))
|
||||
.WhereIF(!string.IsNullOrEmpty(req.xiangmumc), a => a.xiangmumc.Contains(req.xiangmumc))
|
||||
.OrderBy(a => a.end_time, OrderByType.Desc)
|
||||
.ToPageList(req.page, req.limit, ref totalCount);
|
||||
return new PageInfo<List<DroneSsnyd>>
|
||||
{
|
||||
Items = list,
|
||||
Total = totalCount
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 项目变更
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public PageInfo<List<DroneSsnyd>> ProjectChange(DroneSnnyAppPageReq req)
|
||||
{
|
||||
var totalCount = 0;
|
||||
var list = Repository.AsQueryable()
|
||||
.Where(a => a.handle_status_id != 99)
|
||||
.WhereIF(!string.IsNullOrEmpty(req.xiangmu_no), a => a.xiangmu_no.Contains(req.xiangmu_no))
|
||||
.WhereIF(!string.IsNullOrEmpty(req.xiangmumc), a => a.xiangmumc.Contains(req.xiangmumc))
|
||||
.OrderBy(a => a.end_time, OrderByType.Desc)
|
||||
.ToPageList(req.page, req.limit, ref totalCount);
|
||||
return new PageInfo<List<DroneSsnyd>>
|
||||
{
|
||||
Items = list,
|
||||
Total = totalCount
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using OpenAuth.App.Request;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.DroneSsnydManage.Request;
|
||||
|
||||
public class DroneSnnyAppPageReq : PageReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目名称
|
||||
/// </summary>
|
||||
public string xiangmumc { get; set; }
|
||||
/// <summary>
|
||||
/// 项目编号
|
||||
/// </summary>
|
||||
public string xiangmu_no { get; set; }
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ using Infrastructure.Helpers.Excel.Model;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenAuth.App.BaseApp.FormScheme.Request;
|
||||
using OpenAuth.App.FormScheme;
|
||||
using OpenAuth.App.FormScheme.Request;
|
||||
using OpenAuth.App.FormScheme.Response;
|
||||
|
|
@ -449,7 +450,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||
result.Result = data;
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Result = false;
|
||||
result.Message = ex.Message.ToString();
|
||||
|
|
@ -509,5 +510,27 @@ namespace OpenAuth.WebApi.Controllers
|
|||
return File(ExcelHelper.ExportMemoryStream(dt, excelconfig), "application/ms-excel", excelconfig.FileName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取历史数据
|
||||
/// <summary>
|
||||
/// 获取子表历史数据
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
[HttpPost]
|
||||
public (List<object> Headers, List<dynamic> Data) GetFormDataHistory(FormDataHistoryReq req)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _app.GetFormDataHistory(req);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("获取数据失败");
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.ServiceApp.DroneSsnydManage;
|
||||
using OpenAuth.App.ServiceApp.DroneSsnydManage.Request;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||
|
|
@ -15,13 +14,14 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
public class DroneSsnyController : ControllerBase
|
||||
{
|
||||
DroneSsnyApp droneSsnyApp;
|
||||
|
||||
public DroneSsnyController(DroneSsnyApp droneSsnyApp)
|
||||
{
|
||||
this.droneSsnyApp = droneSsnyApp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 超期预警
|
||||
/// 到期预警
|
||||
/// </summary>
|
||||
/// <param name="xiangmumc">项目名称</param>
|
||||
/// <param name="countyid">县</param>
|
||||
|
|
@ -42,6 +42,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +68,52 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 历史项目
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Response<PageInfo<List<DroneSsnyd>>> HistoryProject(DroneSnnyAppPageReq req)
|
||||
{
|
||||
var response = new Response<PageInfo<List<DroneSsnyd>>>();
|
||||
try
|
||||
{
|
||||
response.Result = droneSsnyApp.HistoryProject(req);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 项目变更列表
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Response<PageInfo<List<DroneSsnyd>>> ProjectChange(DroneSnnyAppPageReq req)
|
||||
{
|
||||
var response = new Response<PageInfo<List<DroneSsnyd>>>();
|
||||
try
|
||||
{
|
||||
response.Result = droneSsnyApp.ProjectChange(req);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue