feat 初始化表格管理
This commit is contained in:
parent
4468dda253
commit
025c0dd5c9
@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.TableDataManage.TableDatas;
|
||||
|
||||
namespace ARW.Model.Dto.Business.TableDataManage.TableDatas
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格数据输入对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
public class TableDataDto
|
||||
{
|
||||
|
||||
public int TableDataId { get; set; }
|
||||
|
||||
public long TableDataGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "采购内容不能为空")]
|
||||
public string TableDataProcurementContent { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "采购单位名称不能为空")]
|
||||
public string TableDataProcurementUnit { get; set; }
|
||||
|
||||
public string TableDataProcurementMethod { get; set; }
|
||||
|
||||
public string TableDataSupplierName { get; set; }
|
||||
|
||||
public decimal TableDataSupplierOffer { get; set; }
|
||||
|
||||
public string TableDataProjectPricingForm { get; set; }
|
||||
|
||||
public string TableDataLink { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "日期不能为空")]
|
||||
public DateTime? TableDataDate { get; set; }
|
||||
|
||||
public DateTime? TableDataDeadline { get; set; }
|
||||
|
||||
public string TableDataWinningBidde { get; set; }
|
||||
|
||||
public decimal TableDataBidWinningPrice { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "是否为中标公告不能为空")]
|
||||
public int TableDataIsBidAnnouncement { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "是否是人力资源池或框架协议不能为空")]
|
||||
public int TableDataIsHumanResourcePoolOrFrameworkAgreement { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "公告中是否包含多个包/标段/采购内容不能为空")]
|
||||
public int TableDataIsMultiple { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "是否仅有一个中标人不能为空")]
|
||||
public int TableDataIsOnlyBidder { get; set; }
|
||||
|
||||
public string TableDataSingleSource { get; set; }
|
||||
|
||||
public string TableDataDetails { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "排序不能为空")]
|
||||
public int TableDataSort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 表格数据查询对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
public class TableDataQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public string TableDataProcurementContent { get; set; }
|
||||
|
||||
public string TableDataProcurementUnit { get; set; }
|
||||
|
||||
public DateTime? BeginTime { get; set; }
|
||||
|
||||
public DateTime? EndTime { get; set; }
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ARW.Model.Models.Business.TableDataManage.TableDatas
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格数据,数据实体对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
[SugarTable("tb_table_data")]
|
||||
public class TableData : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "TableDataId")]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "table_data_id")]
|
||||
public int TableDataId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "TableDataGuid")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "table_data_guid")]
|
||||
public long TableDataGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :采购内容
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "采购内容")]
|
||||
[SugarColumn(ColumnName = "table_data_procurement_content")]
|
||||
public string TableDataProcurementContent { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :采购单位名称
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "采购单位名称")]
|
||||
[SugarColumn(ColumnName = "table_data_procurement_unit")]
|
||||
public string TableDataProcurementUnit { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :采购方式
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "采购方式")]
|
||||
[SugarColumn(ColumnName = "table_data_procurement_method")]
|
||||
public string TableDataProcurementMethod { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :供应商名称
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "供应商名称")]
|
||||
[SugarColumn(ColumnName = "table_data_supplier_name")]
|
||||
public string TableDataSupplierName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :供应商的对应报价
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "供应商的对应报价")]
|
||||
[SugarColumn(ColumnName = "table_data_supplier_offer")]
|
||||
public decimal TableDataSupplierOffer { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :项目计价形式
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "项目计价形式")]
|
||||
[SugarColumn(ColumnName = "table_data_project_pricing_form")]
|
||||
public string TableDataProjectPricingForm { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :链接
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "链接")]
|
||||
[SugarColumn(ColumnName = "table_data_link")]
|
||||
public string TableDataLink { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :日期
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "日期", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
|
||||
[SugarColumn(ColumnName = "table_data_date")]
|
||||
public DateTime? TableDataDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :截止日期
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "截止日期", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
|
||||
[SugarColumn(ColumnName = "table_data_deadline")]
|
||||
public DateTime? TableDataDeadline { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :中标人或候选人
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "中标人或候选人")]
|
||||
[SugarColumn(ColumnName = "table_data_winning_bidde")]
|
||||
public string TableDataWinningBidde { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :中标金额
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "中标金额")]
|
||||
[SugarColumn(ColumnName = "table_data_bid_winning_price")]
|
||||
public decimal TableDataBidWinningPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否为中标公告
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否为中标公告")]
|
||||
[SugarColumn(ColumnName = "table_data_is_bid_announcement")]
|
||||
public int TableDataIsBidAnnouncement { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否是人力资源池或框架协议
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否是人力资源池或框架协议")]
|
||||
[SugarColumn(ColumnName = "table_data_is_human_resource_pool_or_framework_agreement")]
|
||||
public int TableDataIsHumanResourcePoolOrFrameworkAgreement { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :公告中是否包含多个包/标段/采购内容
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "公告中是否包含多个包/标段/采购内容")]
|
||||
[SugarColumn(ColumnName = "table_data_is_multiple")]
|
||||
public int TableDataIsMultiple { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否仅有一个中标人
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否仅有一个中标人")]
|
||||
[SugarColumn(ColumnName = "table_data_is_only_bidder")]
|
||||
public int TableDataIsOnlyBidder { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :单一来源理由(如有)
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "单一来源理由(如有)")]
|
||||
[SugarColumn(ColumnName = "table_data_single_source")]
|
||||
public string TableDataSingleSource { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :详情
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "详情")]
|
||||
[SugarColumn(ColumnName = "table_data_details")]
|
||||
public string TableDataDetails { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
[SugarColumn(ColumnName = "table_data_sort")]
|
||||
public int TableDataSort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
159
ARW.Model/Vo/Business/TableDataManage/TableDatas/TableDataVo.cs
Normal file
159
ARW.Model/Vo/Business/TableDataManage/TableDatas/TableDataVo.cs
Normal file
@ -0,0 +1,159 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.TableDataManage.TableDatas
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格数据展示对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
public class TableDataVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int TableDataId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long TableDataGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :采购内容
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "采购内容")]
|
||||
public string TableDataProcurementContent { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :采购单位名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "采购单位名称")]
|
||||
public string TableDataProcurementUnit { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :采购方式
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string TableDataProcurementMethod { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :供应商名称
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string TableDataSupplierName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :供应商的对应报价
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public decimal TableDataSupplierOffer { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :项目计价形式
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string TableDataProjectPricingForm { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :链接
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string TableDataLink { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :日期
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "日期", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
|
||||
public DateTime? TableDataDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :截止日期
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public DateTime? TableDataDeadline { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :中标人或候选人
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string TableDataWinningBidde { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :中标金额
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public decimal TableDataBidWinningPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否为中标公告
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否为中标公告")]
|
||||
public int TableDataIsBidAnnouncement { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否是人力资源池或框架协议
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否是人力资源池或框架协议")]
|
||||
public int TableDataIsHumanResourcePoolOrFrameworkAgreement { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :公告中是否包含多个包/标段/采购内容
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "公告中是否包含多个包/标段/采购内容")]
|
||||
public int TableDataIsMultiple { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否仅有一个中标人
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否仅有一个中标人")]
|
||||
public int TableDataIsOnlyBidder { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :单一来源理由(如有)
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string TableDataSingleSource { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :详情
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string TableDataDetails { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
public int TableDataSort { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.TableDataManage.TableDatas;
|
||||
|
||||
namespace ARW.Repository.Business.TableDataManage.TableDatas
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格数据仓储
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class TableDataRepository : BaseRepository<TableData>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ namespace ARW.Service.Business.BusinessService.ProductsInvolveds
|
||||
var query = _ProductsInvolvedRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.ProductsInvolvedSort,OrderByType.Asc)
|
||||
.OrderBy(s => s.ProductsInvolvedSort, OrderByType.Asc)
|
||||
.Select(s => new ProductsInvolvedVo
|
||||
{
|
||||
ProductsInvolvedId = s.ProductsInvolvedId,
|
||||
@ -92,7 +92,7 @@ namespace ARW.Service.Business.BusinessService.ProductsInvolveds
|
||||
/// <summary>
|
||||
/// Excel导入
|
||||
/// </summary>
|
||||
public async Task<string> ImportExcel(ProductsInvolved ProductsInvolved,int index,bool isUpdateSupport,string user)
|
||||
public async Task<string> ImportExcel(ProductsInvolved ProductsInvolved, int index, bool isUpdateSupport, string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -131,7 +131,8 @@ namespace ARW.Service.Business.BusinessService.ProductsInvolveds
|
||||
return editStr;
|
||||
}
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
// 开启事务
|
||||
var res = await UseTranAsync(async () =>
|
||||
{
|
||||
@ -164,7 +165,7 @@ namespace ARW.Service.Business.BusinessService.ProductsInvolveds
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,189 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using ARW.Model;
|
||||
using ARW.Repository;
|
||||
using ARW.Repository.Business.TableDataManage.TableDatas;
|
||||
using ARW.Service.Business.IBusinessService.TableDataManage.TableDatas;
|
||||
using ARW.Model.Dto.Business.TableDataManage.TableDatas;
|
||||
using ARW.Model.Models.Business.TableDataManage.TableDatas;
|
||||
using ARW.Model.Vo.Business.TableDataManage.TableDatas;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.TableDataManage.TableDatas
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格数据接口实现类
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ITableDataService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class TableDataServiceImpl : BaseService<TableData>, ITableDataService
|
||||
{
|
||||
private readonly TableDataRepository _TableDataRepository;
|
||||
|
||||
public TableDataServiceImpl(TableDataRepository TableDataRepository)
|
||||
{
|
||||
this._TableDataRepository = TableDataRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询表格数据分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<TableDataVo>> GetTableDataList(TableDataQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<TableData>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.TableDataProcurementContent), s => s.TableDataProcurementContent.Contains(parm.TableDataProcurementContent));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.TableDataProcurementUnit), s => s.TableDataProcurementUnit.Contains(parm.TableDataProcurementUnit));
|
||||
predicate = predicate.AndIF(parm.BeginTime != null && parm.EndTime != null, it => it.TableDataDate >= parm.BeginTime && it.TableDataDate <= parm.EndTime);
|
||||
predicate = predicate.AndIF(parm.BeginTime != null && parm.EndTime != null, it => it.TableDataDeadline >= parm.BeginTime && it.TableDataDeadline <= parm.EndTime);
|
||||
var query = _TableDataRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.TableDataSort,OrderByType.Asc)
|
||||
.Select(s => new TableDataVo
|
||||
{
|
||||
TableDataId = s.TableDataId,
|
||||
TableDataGuid = s.TableDataGuid,
|
||||
TableDataProcurementContent = s.TableDataProcurementContent,
|
||||
TableDataProcurementUnit = s.TableDataProcurementUnit,
|
||||
TableDataProcurementMethod = s.TableDataProcurementMethod,
|
||||
TableDataSupplierName = s.TableDataSupplierName,
|
||||
TableDataSupplierOffer = s.TableDataSupplierOffer,
|
||||
TableDataProjectPricingForm = s.TableDataProjectPricingForm,
|
||||
TableDataLink = s.TableDataLink,
|
||||
TableDataDate = s.TableDataDate,
|
||||
TableDataDeadline = s.TableDataDeadline,
|
||||
TableDataWinningBidde = s.TableDataWinningBidde,
|
||||
TableDataBidWinningPrice = s.TableDataBidWinningPrice,
|
||||
TableDataIsBidAnnouncement = s.TableDataIsBidAnnouncement,
|
||||
TableDataIsHumanResourcePoolOrFrameworkAgreement = s.TableDataIsHumanResourcePoolOrFrameworkAgreement,
|
||||
TableDataIsMultiple = s.TableDataIsMultiple,
|
||||
TableDataIsOnlyBidder = s.TableDataIsOnlyBidder,
|
||||
TableDataSingleSource = s.TableDataSingleSource,
|
||||
TableDataDetails = s.TableDataDetails,
|
||||
TableDataSort = s.TableDataSort,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改表格数据
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateTableData(TableData model)
|
||||
{
|
||||
if (model.TableDataId != 0)
|
||||
{
|
||||
var response = await _TableDataRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var response = await _TableDataRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
/// <summary>
|
||||
/// 数据导入处理
|
||||
/// </summary>
|
||||
public async Task<TableDataVo> HandleImportData(TableDataVo TableData)
|
||||
{
|
||||
return TableData;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导入
|
||||
/// </summary>
|
||||
public async Task<string> ImportExcel(TableData TableData,int index,bool isUpdateSupport,string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 空值判断
|
||||
// if (TableData.TableDataId == null) throw new CustomException("表格数据不能为空");
|
||||
|
||||
if (isUpdateSupport)
|
||||
{
|
||||
// 判断唯一值
|
||||
var model = await GetFirstAsync(s => s.TableDataId == TableData.TableDataId);
|
||||
|
||||
// 如果为空就新增数据
|
||||
if (model == null)
|
||||
{
|
||||
// 开启事务
|
||||
var res = await UseTranAsync(async () =>
|
||||
{
|
||||
var addRes = await AddOrUpdateTableData(TableData);
|
||||
});
|
||||
var addStr = $"第 {index} 行 => 表格数据:【{TableData.TableDataId}】<span style='color:#27af49'>新增成功!</span><br>";
|
||||
return addStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果有数据就进行修改
|
||||
// 开启事务
|
||||
await UseTranAsync(async () =>
|
||||
{
|
||||
TableData.TableDataId = model.TableDataId;
|
||||
TableData.TableDataGuid = model.TableDataGuid;
|
||||
TableData.Update_by = user;
|
||||
TableData.Update_time = DateTime.Now;
|
||||
var editRes = await AddOrUpdateTableData(TableData);
|
||||
});
|
||||
var editStr = $"第 {index} 行 => 表格数据:【{TableData.TableDataId}】<span style='color:#e6a23c'>更新成功!</span><br>";
|
||||
return editStr;
|
||||
}
|
||||
}
|
||||
else{
|
||||
// 开启事务
|
||||
var res = await UseTranAsync(async () =>
|
||||
{
|
||||
var addRes = await AddOrUpdateTableData(TableData);
|
||||
});
|
||||
//Console.WriteLine(res.IsSuccess);
|
||||
var addStr = $"第 {index} 行 => 表格数据:【{TableData.TableDataId}】<span style='color:#27af49'>新增成功!</span><br>";
|
||||
return addStr;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorRes = $"第 {index} 行 => 表格数据:【{TableData.TableDataId}】<span style='color:red'>导入失败!{ex.Message}</span><br>";
|
||||
return errorRes;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel数据导出处理
|
||||
/// </summary>
|
||||
public async Task<List<TableDataVo>> HandleExportData(List<TableDataVo> data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Business.TableDataManage.TableDatas;
|
||||
using ARW.Model.Models.Business.TableDataManage.TableDatas;
|
||||
using ARW.Model.Vo.Business.TableDataManage.TableDatas;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.TableDataManage.TableDatas
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格数据接口类
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
public interface ITableDataService : IBaseService<TableData>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取表格数据分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<TableDataVo>> GetTableDataList(TableDataQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改表格数据
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateTableData(TableData parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数据导入处理
|
||||
/// </summary>
|
||||
/// <param name="shopVo"></param>
|
||||
/// <returns></returns>
|
||||
Task<TableDataVo> HandleImportData(TableDataVo TableDataVo);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导入
|
||||
/// </summary>
|
||||
/// <param name="TableData"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> ImportExcel(TableData TableData,int index,bool isUpdateSupport,string user);
|
||||
|
||||
/// <summary>
|
||||
/// Excel导出
|
||||
/// </summary>
|
||||
Task<List<TableDataVo>> HandleExportData(List<TableDataVo> data);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -98,7 +98,7 @@ namespace ARW.WebApi.Controllers.Business.ProductsInvolveds
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "涉及产品导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
||||
[ActionPermissionFilter(Permission = "business:productsinvolved:import")]
|
||||
public async Task<IActionResult> ImportExcel([FromForm(Name = "file")] IFormFile formFile,bool updateSupport)
|
||||
public async Task<IActionResult> ImportExcel([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
|
||||
{
|
||||
var isUpdateSupport = updateSupport;
|
||||
IEnumerable<ProductsInvolvedVo> parm = ExcelHelper<ProductsInvolvedVo>.ImportData(formFile.OpenReadStream());
|
||||
@ -111,7 +111,7 @@ namespace ARW.WebApi.Controllers.Business.ProductsInvolveds
|
||||
var ProductsInvolved = await _ProductsInvolvedService.HandleImportData(item);
|
||||
var modal = ProductsInvolved.Adapt<ProductsInvolved>().ToCreate(HttpContext);
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
|
||||
var msg = await _ProductsInvolvedService.ImportExcel(modal,i,isUpdateSupport,user);
|
||||
var msg = await _ProductsInvolvedService.ImportExcel(modal, i, isUpdateSupport, user);
|
||||
msgList.Add(msg);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,180 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ARW.Admin.WebApi.Extensions;
|
||||
using ARW.Admin.WebApi.Filters;
|
||||
using ARW.Common;
|
||||
using ARW.Model.Dto.Business.TableDataManage.TableDatas;
|
||||
using ARW.Service.Business.IBusinessService.TableDataManage.TableDatas;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Models.Business.TableDataManage.TableDatas;
|
||||
using ARW.Model.Vo.Business.TableDataManage.TableDatas;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
|
||||
|
||||
namespace ARW.WebApi.Controllers.Business.TableDataManage.TableDatas
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格数据控制器
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-11-22
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/[controller]")]
|
||||
public class TableDataController : BaseController
|
||||
{
|
||||
private readonly ITableDataService _TableDataService;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="TableDataService">表格数据服务</param>
|
||||
public TableDataController(ITableDataService TableDataService)
|
||||
{
|
||||
_TableDataService = TableDataService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取表格数据列表
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getTableDataList")]
|
||||
[ActionPermissionFilter(Permission = "business:tabledata:list")]
|
||||
public async Task<IActionResult> GetTableDataList([FromQuery] TableDataQueryDto parm)
|
||||
{
|
||||
var res = await _TableDataService.GetTableDataList(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改表格数据
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateTableData")]
|
||||
[ActionPermissionFilter(Permission = "business:tabledata:addOrUpdate")]
|
||||
[Log(Title = "添加或修改表格数据", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateTableData([FromBody] TableDataDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new TableData();
|
||||
if (parm.TableDataId != 0) modal = parm.Adapt<TableData>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<TableData>().ToCreate(HttpContext);
|
||||
|
||||
var res = await _TableDataService.AddOrUpdateTableData(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除表格数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:tabledata:delete")]
|
||||
[Log(Title = "表格数据删除", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult Delete(string ids)
|
||||
{
|
||||
long[] idsArr = Tools.SpitLongArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
var response = _TableDataService.Delete(idsArr);
|
||||
return SUCCESS("删除成功!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入表格数据
|
||||
/// </summary>
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
/// <param name="updateSupport">是否需要更新</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "表格数据导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
||||
[ActionPermissionFilter(Permission = "business:tabledata:import")]
|
||||
public async Task<IActionResult> ImportExcel([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
|
||||
{
|
||||
var isUpdateSupport = updateSupport;
|
||||
IEnumerable<TableDataVo> parm = ExcelHelper<TableDataVo>.ImportData(formFile.OpenReadStream());
|
||||
|
||||
var i = 0;
|
||||
var msgList = new List<string>();
|
||||
foreach (TableDataVo item in parm)
|
||||
{
|
||||
i++;
|
||||
var TableData = await _TableDataService.HandleImportData(item);
|
||||
var modal = TableData.Adapt<TableData>().ToCreate(HttpContext);
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
|
||||
var msg = await _TableDataService.ImportExcel(modal, i, isUpdateSupport, user);
|
||||
msgList.Add(msg);
|
||||
}
|
||||
|
||||
return SUCCESS(msgList.ToArray());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 表格数据导入模板下载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("importTemplate")]
|
||||
[Log(Title = "表格数据模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
List<TableDataVo> TableData = new List<TableDataVo>();
|
||||
MemoryStream stream = new MemoryStream();
|
||||
|
||||
// 示例数据
|
||||
var values = new List<string>() { "111", "222", "333" };
|
||||
string sFileName = DownloadImportTemplate(TableData, stream, "表格数据导入模板", values);
|
||||
|
||||
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出表格数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(Title = "表格数据导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||
[HttpGet("exportTableData")]
|
||||
[ActionPermissionFilter(Permission = "business:tabledata:export")]
|
||||
public async Task<IActionResult> ExportExcel([FromQuery] TableDataQueryDto parm)
|
||||
{
|
||||
parm.PageSize = 10000;
|
||||
var list = await _TableDataService.GetTableDataList(parm);
|
||||
var data = list.Result;
|
||||
|
||||
// 选中数据
|
||||
if (!string.IsNullOrEmpty(parm.ids))
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(parm.ids);
|
||||
var selectDataList = new List<TableDataVo>();
|
||||
foreach (var item in idsArr)
|
||||
{
|
||||
var select_data = data.Where(s => s.TableDataId == item).First();
|
||||
selectDataList.Add(select_data);
|
||||
}
|
||||
data = selectDataList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 导出数据处理
|
||||
var handleData = await _TableDataService.HandleExportData(data);
|
||||
|
||||
string sFileName = ExportExcel(handleData, "TableData", "表格数据列表");
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user