feat 添加物流公司管理
This commit is contained in:
parent
9ffb9fe07a
commit
e76d63b2d6
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.LogisticsManage.LogisticsCompanys;
|
||||
|
||||
namespace ARW.Model.Dto.Business.LogisticsManage.LogisticsCompanys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司输入对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public class LogisticsCompanyDto
|
||||
{
|
||||
|
||||
public int LogisticsCompanyId { get; set; }
|
||||
|
||||
public long LogisticsCompanyGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "物流公司名称不能为空")]
|
||||
public string LogisticsCompanyName { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "物流公司编码不能为空")]
|
||||
public string LogisticsCompanyCode { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "排序不能为空")]
|
||||
public int LogisticsCompanySort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物流公司查询对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public class LogisticsCompanyQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public string LogisticsCompanyName { get; set; }
|
||||
|
||||
public string LogisticsCompanyCode { get; set; }
|
||||
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ARW.Model.Models.Business.LogisticsManage.LogisticsCompanys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司,数据实体对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[SugarTable("tb_logistics_company")]
|
||||
public class LogisticsCompany : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "LogisticsCompanyId")]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "logistics_company_id")]
|
||||
public int LogisticsCompanyId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "LogisticsCompanyGuid")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "logistics_company_guid")]
|
||||
public long LogisticsCompanyGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :物流公司名称
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "物流公司名称")]
|
||||
[SugarColumn(ColumnName = "logistics_company_name")]
|
||||
public string LogisticsCompanyName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :物流公司编码
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "物流公司编码")]
|
||||
[SugarColumn(ColumnName = "logistics_company_code")]
|
||||
public string LogisticsCompanyCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
[SugarColumn(ColumnName = "logistics_company_sort")]
|
||||
public int LogisticsCompanySort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.LogisticsManage.LogisticsCompanys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司展示对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public class LogisticsCompanyVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int LogisticsCompanyId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long LogisticsCompanyGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :物流公司名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "物流公司名称")]
|
||||
public string LogisticsCompanyName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :物流公司编码
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "物流公司编码")]
|
||||
public string LogisticsCompanyCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
public int LogisticsCompanySort { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :添加时间
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "添加时间")]
|
||||
[EpplusIgnore]
|
||||
public string CreateTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.LogisticsManage.LogisticsCompanys;
|
||||
|
||||
namespace ARW.Repository.Business.LogisticsManage.LogisticsCompanys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司仓储
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class LogisticsCompanyRepository : BaseRepository<LogisticsCompany>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
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.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Service.Business.IBusinessService.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Model.Dto.Business.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Model.Models.Business.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Model.Vo.Business.LogisticsManage.LogisticsCompanys;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.LogisticsManage.LogisticsCompanys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司接口实现类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ILogisticsCompanyService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class LogisticsCompanyServiceImpl : BaseService<LogisticsCompany>, ILogisticsCompanyService
|
||||
{
|
||||
private readonly LogisticsCompanyRepository _LogisticsCompanyRepository;
|
||||
|
||||
public LogisticsCompanyServiceImpl(LogisticsCompanyRepository LogisticsCompanyRepository)
|
||||
{
|
||||
this._LogisticsCompanyRepository = LogisticsCompanyRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询物流公司分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<LogisticsCompanyVo>> GetLogisticsCompanyList(LogisticsCompanyQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<LogisticsCompany>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LogisticsCompanyName), s => s.LogisticsCompanyName.Contains(parm.LogisticsCompanyName));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LogisticsCompanyCode), s => s.LogisticsCompanyCode.Contains(parm.LogisticsCompanyCode));
|
||||
var query = _LogisticsCompanyRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.LogisticsCompanySort, OrderByType.Asc)
|
||||
.Select(s => new LogisticsCompanyVo
|
||||
{
|
||||
LogisticsCompanyId = s.LogisticsCompanyId,
|
||||
LogisticsCompanyGuid = s.LogisticsCompanyGuid,
|
||||
LogisticsCompanyName = s.LogisticsCompanyName,
|
||||
LogisticsCompanyCode = s.LogisticsCompanyCode,
|
||||
LogisticsCompanySort = s.LogisticsCompanySort,
|
||||
CreateTime = s.Create_time.ToString("yyyy-MM-dd HH:mm")
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改物流公司
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateLogisticsCompany(LogisticsCompany model)
|
||||
{
|
||||
if (model.LogisticsCompanyId != 0)
|
||||
{
|
||||
var response = await _LogisticsCompanyRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var response = await _LogisticsCompanyRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
/// <summary>
|
||||
/// 数据导入处理
|
||||
/// </summary>
|
||||
public async Task<LogisticsCompanyVo> HandleImportData(LogisticsCompanyVo LogisticsCompany)
|
||||
{
|
||||
return LogisticsCompany;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导入
|
||||
/// </summary>
|
||||
public async Task<string> ImportExcel(LogisticsCompany LogisticsCompany, int index, bool isUpdateSupport, string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 空值判断
|
||||
// if (LogisticsCompany.LogisticsCompanyId == null) throw new CustomException("物流公司不能为空");
|
||||
var company = await GetFirstAsync(s => s.LogisticsCompanyName == LogisticsCompany.LogisticsCompanyName);
|
||||
if (company != null) throw new CustomException("已存在!");
|
||||
|
||||
if (isUpdateSupport)
|
||||
{
|
||||
// 判断唯一值
|
||||
var model = await GetFirstAsync(s => s.LogisticsCompanyId == LogisticsCompany.LogisticsCompanyId);
|
||||
|
||||
// 如果为空就新增数据
|
||||
if (model == null)
|
||||
{
|
||||
// 开启事务
|
||||
var res = await UseTranAsync(async () =>
|
||||
{
|
||||
var addRes = await AddOrUpdateLogisticsCompany(LogisticsCompany);
|
||||
});
|
||||
var addStr = $"第 {index} 行 => 物流公司:【{LogisticsCompany.LogisticsCompanyName}】<span style='color:#27af49'>新增成功!</span><br>";
|
||||
return addStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果有数据就进行修改
|
||||
// 开启事务
|
||||
await UseTranAsync(async () =>
|
||||
{
|
||||
LogisticsCompany.LogisticsCompanyId = model.LogisticsCompanyId;
|
||||
LogisticsCompany.LogisticsCompanyGuid = model.LogisticsCompanyGuid;
|
||||
LogisticsCompany.Update_by = user;
|
||||
LogisticsCompany.Update_time = DateTime.Now;
|
||||
var editRes = await AddOrUpdateLogisticsCompany(LogisticsCompany);
|
||||
});
|
||||
var editStr = $"第 {index} 行 => 物流公司:【{LogisticsCompany.LogisticsCompanyName}】<span style='color:#e6a23c'>更新成功!</span><br>";
|
||||
return editStr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 开启事务
|
||||
var res = await UseTranAsync(async () =>
|
||||
{
|
||||
var addRes = await AddOrUpdateLogisticsCompany(LogisticsCompany);
|
||||
});
|
||||
//Console.WriteLine(res.IsSuccess);
|
||||
var addStr = $"第 {index} 行 => 物流公司:【{LogisticsCompany.LogisticsCompanyName}】<span style='color:#27af49'>新增成功!</span><br>";
|
||||
return addStr;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorRes = $"第 {index} 行 => 物流公司:【{LogisticsCompany.LogisticsCompanyName}】<span style='color:red'>导入失败!{ex.Message}</span><br>";
|
||||
return errorRes;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel数据导出处理
|
||||
/// </summary>
|
||||
public async Task<List<LogisticsCompanyVo>> HandleExportData(List<LogisticsCompanyVo> 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.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Model.Models.Business.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Model.Vo.Business.LogisticsManage.LogisticsCompanys;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.LogisticsManage.LogisticsCompanys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司接口类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public interface ILogisticsCompanyService : IBaseService<LogisticsCompany>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取物流公司分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<LogisticsCompanyVo>> GetLogisticsCompanyList(LogisticsCompanyQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改物流公司
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateLogisticsCompany(LogisticsCompany parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数据导入处理
|
||||
/// </summary>
|
||||
/// <param name="shopVo"></param>
|
||||
/// <returns></returns>
|
||||
Task<LogisticsCompanyVo> HandleImportData(LogisticsCompanyVo LogisticsCompanyVo);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导入
|
||||
/// </summary>
|
||||
/// <param name="shopVo"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> ImportExcel(LogisticsCompany LogisticsCompany,int index,bool isUpdateSupport,string user);
|
||||
|
||||
/// <summary>
|
||||
/// Excel导出
|
||||
/// </summary>
|
||||
Task<List<LogisticsCompanyVo>> HandleExportData(List<LogisticsCompanyVo> data);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Service.Business.IBusinessService.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Models.Business.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Model.Vo.Business.LogisticsManage.LogisticsCompanys;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
|
||||
|
||||
namespace ARW.WebApi.Controllers.Business.LogisticsManage.LogisticsCompanys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司控制器
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/[controller]")]
|
||||
public class LogisticsCompanyController : BaseController
|
||||
{
|
||||
private readonly ILogisticsCompanyService _LogisticsCompanyService;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="LogisticsCompanyService">物流公司服务</param>
|
||||
public LogisticsCompanyController(ILogisticsCompanyService LogisticsCompanyService)
|
||||
{
|
||||
_LogisticsCompanyService = LogisticsCompanyService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取物流公司列表
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getLogisticsCompanyList")]
|
||||
[ActionPermissionFilter(Permission = "business:logisticscompany:list")]
|
||||
public async Task<IActionResult> GetLogisticsCompanyList([FromQuery] LogisticsCompanyQueryDto parm)
|
||||
{
|
||||
var res = await _LogisticsCompanyService.GetLogisticsCompanyList(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改物流公司
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateLogisticsCompany")]
|
||||
[ActionPermissionFilter(Permission = "business:logisticscompany:addOrUpdate")]
|
||||
[Log(Title = "添加或修改物流公司", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateLogisticsCompany([FromBody] LogisticsCompanyDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new LogisticsCompany();
|
||||
if (parm.LogisticsCompanyId != 0) modal = parm.Adapt<LogisticsCompany>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<LogisticsCompany>().ToCreate(HttpContext);
|
||||
|
||||
var res = await _LogisticsCompanyService.AddOrUpdateLogisticsCompany(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除物流公司
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:logisticscompany: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 = _LogisticsCompanyService.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:logisticscompany:import")]
|
||||
public async Task<IActionResult> ImportExcel([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
|
||||
{
|
||||
var isUpdateSupport = updateSupport;
|
||||
IEnumerable<LogisticsCompanyVo> parm = ExcelHelper<LogisticsCompanyVo>.ImportData(formFile.OpenReadStream());
|
||||
|
||||
var i = 0;
|
||||
var msgList = new List<string>();
|
||||
foreach (LogisticsCompanyVo item in parm)
|
||||
{
|
||||
i++;
|
||||
var LogisticsCompany = await _LogisticsCompanyService.HandleImportData(item);
|
||||
var modal = LogisticsCompany.Adapt<LogisticsCompany>().ToCreate(HttpContext);
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
|
||||
var msg = await _LogisticsCompanyService.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<LogisticsCompanyVo> LogisticsCompany = new List<LogisticsCompanyVo>();
|
||||
MemoryStream stream = new MemoryStream();
|
||||
|
||||
// 示例数据
|
||||
var values = new List<string>() { "顺丰速运", "shunfeng", "100" };
|
||||
string sFileName = DownloadImportTemplate(LogisticsCompany, 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("exportLogisticsCompany")]
|
||||
[ActionPermissionFilter(Permission = "business:logisticscompany:export")]
|
||||
public async Task<IActionResult> ExportExcel([FromQuery] LogisticsCompanyQueryDto parm)
|
||||
{
|
||||
parm.PageSize = 10000;
|
||||
var list = await _LogisticsCompanyService.GetLogisticsCompanyList(parm);
|
||||
var data = list.Result;
|
||||
|
||||
// 选中数据
|
||||
if (!string.IsNullOrEmpty(parm.ids))
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(parm.ids);
|
||||
var selectDataList = new List<LogisticsCompanyVo>();
|
||||
foreach (var item in idsArr)
|
||||
{
|
||||
var select_data = data.Where(s => s.LogisticsCompanyId == item).First();
|
||||
selectDataList.Add(select_data);
|
||||
}
|
||||
data = selectDataList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 导出数据处理
|
||||
var handleData = await _LogisticsCompanyService.HandleExportData(data);
|
||||
|
||||
string sFileName = ExportExcel(handleData, "LogisticsCompany", "物流公司列表");
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user