jianghaiqing 4 months ago
commit eab290907e

@ -23,6 +23,11 @@ namespace DS.WMS.Core.Sys.Dtos
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 助记码
/// </summary>
public string PinYinCode { get; set; }
/// <summary>
/// 揽货人所属公司
/// </summary>

@ -92,6 +92,19 @@ namespace DS.WMS.Core.Sys.Dtos
/// 备注
/// </summary>
public string Note { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
public string CarrierCode { get; set; }
/// <summary>
/// 船公司名称
/// </summary>
public string CarrierName { get; set; }
/// <summary>
/// 船公司Id
/// </summary>
public long? CarrierId { get; set; }
}
/// <summary>

@ -103,5 +103,18 @@ namespace DS.WMS.Core.Sys.Dtos
/// </summary>
[Description("创建人名称")]
public string CreateUserName { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
public string CarrierCode { get; set; }
/// <summary>
/// 船公司名称
/// </summary>
public string CarrierName { get; set; }
/// <summary>
/// 船公司Id
/// </summary>
public long? CarrierId { get; set; }
}
}

@ -0,0 +1,129 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using DS.Module.Core.Extensions;
using FluentValidation;
namespace DS.WMS.Core.Sys.Dtos;
/// <summary>
/// 用户编辑Excel导入实体
/// </summary>
public class UserExcelImportReq
{
/// <summary>
/// <summary>
/// 登陆账号
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 员工代码
/// </summary>
public string UserNumber { get; set; }
public string Password { get; set; }
/// <summary>
/// 中文名称
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 性别 1-男 2-女 3 -未知
/// </summary>
public string Sex { get; set; }
/// <summary>
///
/// </summary>
public DateTime? Birthday { get; set; } = DateTime.MinValue;
/// <summary>
/// 手机号码
/// </summary>
public string Phone { get; set; } = "";
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; } = "";
/// <summary>
/// 电话
/// </summary>
public string Tel { get; set; }
/// <summary>
/// 办公电话
/// </summary>
public string OfficePhone { get; set; }
/// <summary>
/// 传真
/// </summary>
public string Fax { get; set; }
/// <summary>
/// 财务软件代码
/// </summary>
public string FinanceSoftCode { get; set; }
/// <summary>
/// 职位
/// </summary>
public string Duty { get; set; } = "";
/// <summary>
/// 用户类型 1-管理员 2-普通用户
/// </summary>
public int UserType { get; set; } = 1;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 是否操作
/// </summary>
public int IsOperator { get; set; }
/// <summary>
/// 是否单证
/// </summary>
public int IsVouchingClerk { get; set; }
/// <summary>
/// 是否销售
/// </summary>
public int IsSale { get; set; }
/// <summary>
/// 是否报关员
/// </summary>
public int IsCustom { get; set; }
/// <summary>
/// 是否财务
/// </summary>
public int IsFinancialStaff { get; set; }
/// <summary>
/// 是否客服
/// </summary>
public int IsCustomerService { get; set; }
/// <summary>
/// 是否司机
/// </summary>
public int IsDriver { get; set; }
/// <summary>
/// 是否派车调度人员
/// </summary>
public int IsDispatcher { get; set; }
/// <summary>
/// 英文名称
/// </summary>
public string UserEnName { get; set; }
}

@ -20,7 +20,11 @@ public class UserReq
/// 登陆账号
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 员工代码
/// </summary>
[Description("员工代码")]
public string UserNumber { get; set; }
/// <summary>
/// 密码
/// </summary>

@ -13,7 +13,11 @@ public class UserViewModel
/// 登陆账号
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 员工代码
/// </summary>
[Description("员工代码")]
public string UserNumber { get; set; }
/// <summary>
/// 密码
/// </summary>

@ -91,4 +91,21 @@ public class SysPrintTemplate : BaseTenantModel<long>
[Description("是否可用")]
[SqlSugar.SugarColumn(ColumnDescription = "是否可用", IsNullable = true, DefaultValue = "0")]
public bool Disable { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
[SugarColumn(ColumnDescription = "船公司代码", Length = 40, IsNullable = true)]
public string CarrierCode { get; set; }
/// <summary>
/// 船公司名称
/// </summary>
[SugarColumn(ColumnDescription = "船公司名称", Length = 100, IsNullable = true)]
public string CarrierName { get; set; }
/// <summary>
/// 船公司Id
/// </summary>
[SugarColumn(ColumnDescription = "船公司Id", DefaultValue = "0", IsNullable = true)]
public long? CarrierId { get; set; }
}

@ -14,7 +14,11 @@ public class SysUser : UserTenantModel<long>
/// </summary>
[Description("登陆账号")]
public string UserCode { get; set; }
/// <summary>
/// 员工代码
/// </summary>
[Description("员工代码")]
public string UserNumber { get; set; }
/// <summary>
/// 密码
/// </summary>

@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Sys.Dtos;
using Microsoft.AspNetCore.Http;
namespace DS.WMS.Core.Sys.Interface;
@ -41,4 +42,12 @@ public interface IUserService
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult> BatchDelUser(IdModel req);
/// <summary>
/// 按Excel导入用户信息
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public Task<DataResult<string>> ImportUserByExcel(IFormFile file);
}

@ -100,7 +100,7 @@ namespace DS.WMS.Core.Sys.Method
{
if (req.Id == 0)
{
var isExist = db.Queryable<SysPrintTemplate>().Where(x => x.TemplateCode == req.TemplateCode).First();
var isExist = db.Queryable<SysPrintTemplate>().Where(x => x.TemplateCode == req.TemplateCode).WhereIF(req.CarrierId != 0, x => x.CarrierId == req.CarrierId).First();
if (isExist != null)
{
return DataResult.Failed("打印模板唯一编码已存在!");

@ -4,11 +4,16 @@ using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using DS.WMS.Core.TaskPlat.Dtos;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using MiniExcelLibs;
using Org.BouncyCastle.Ocsp;
using SqlSugar;
namespace DS.WMS.Core.Sys.Method;
@ -122,7 +127,7 @@ public class UserService : IUserService
#endregion
var data = model.MapTo<UserReq, SysUser>();
data.PinYinCode = PinYinUtil.GetFristLetter(data.UserName);
data.PinYinCode = data.UserName + "(" + PinYinUtil.GetFristLetter(data.UserName) + ")";
data.MD5Password = MD5Helper.MD5Encrypt(data.Password);
var entity = db.Insertable(data).ExecuteReturnEntity();
@ -172,7 +177,7 @@ public class UserService : IUserService
var info = db.Queryable<SysUser>().Where(x => x.Id == userId).First();
info = model.MapTo<UserReq, SysUser>();
info.PinYinCode = PinYinUtil.GetFristLetter(info.UserName);
info.PinYinCode = info.UserName + "(" + PinYinUtil.GetFristLetter(info.UserName) + ")";
db.Updateable(info).IgnoreColumns(it => new { it.TenantId,it.TenantName, it.Password,it.MD5Password }).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
@ -302,4 +307,78 @@ public class UserService : IUserService
return await Task.FromResult(DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess));
}
/// <summary>
/// 按Excel导入用户信息
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public async Task<DataResult<string>> ImportUserByExcel(IFormFile file)
{
//未上传文件
if (file == null || file.Length == 0)
{
return await Task.FromResult(DataResult<string>.Failed("请上传Excel!"));
}
var formFile = file;
//DataResult<string> api_Result = new Api_Result<string>();
//获取文件名
var fileName = formFile.FileName;
// 获取文件后缀
var fileExtension = Path.GetExtension(fileName);
// 判断后缀是否是xlsx或者xls
if (fileExtension != ".xlsx" && fileExtension != ".xls")
{
return DataResult<string>.Failed("文件格式错误");
}
var length = formFile.Length;
if (length > 1024 * 1024 * 10)
{
return DataResult<string>.Failed("文件大小不能超过10M");
}
// MemoryStream 内存流 在内存当中创建一个流(开辟空间)
using (var stream = new MemoryStream())
{
//将文件写入内存流
formFile.CopyTo(stream);
//将流的位置归零
stream.Position = 0;
//将内存流转成List集合
var list = await stream.QueryAsync<UserExcelImportReq>();
var users = new List<SysUser>();
foreach (var item in list)
{
var sysUser = new SysUser()
{
UserCode = item.UserCode,
UserName = item.UserName,
PinYinCode = item.UserName + "("+ PinYinUtil.GetFristLetter(item.UserName)+")",
UserNumber = item.UserNumber,
Password = "123456ABC",
MD5Password = MD5Helper.MD5Encrypt("123456ABC"),
UserEnName = item.UserEnName,
Sex = item.Sex == "女"? 2:1,
Duty = item.Duty,
OfficePhone = item.OfficePhone,
Email = item.Email,
Phone = item.Phone,
IsOperator = item.IsOperator == 1? true : false,
IsVouchingClerk = item.IsVouchingClerk == 1 ? true : false,
IsSale = item.IsSale == 1 ? true : false,
IsCustom = item.IsCustom == 1 ? true : false,
IsFinancialStaff = item.IsFinancialStaff == 1 ? true : false,
IsCustomerService = item.IsCustomerService == 1 ? true : false,
IsDriver = item.IsDriver == 1 ? true : false,
IsDispatcher = item.IsDispatcher == 1 ? true : false,
UserType = 2
};
users.Add(sysUser);
}
await db.Insertable(users).ExecuteCommandAsync();
return await Task.FromResult(DataResult<string>.Failed("导入成功!", MultiLanguageConst.DataImportSuccess));
}
}
}

@ -86,4 +86,18 @@ public class UserController : ApiController
var res =await _invokeService.BatchDelUser(req);
return res;
}
/// <summary>
/// 按Excel导入用户信息
/// </summary>
/// <param name="file">Excel文件</param>
/// <returns></returns>
[HttpPost]
[Route("ImportUserByExcel")]
public async Task<DataResult<string>> ImportUserByExcel(IFormFile file)
{
var res = await _invokeService.ImportUserByExcel(file);
return res;
}
}
Loading…
Cancel
Save