修复租户数据库差异问题及商品类型分类
parent
66c8d40696
commit
4b3e396f88
@ -0,0 +1,63 @@
|
||||
using DS.Module.Core;
|
||||
using DS.WMS.Core.Code.Dtos;
|
||||
using DS.WMS.Core.Code.Interface;
|
||||
using DS.WMS.Core.System.Dtos;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DS.WMS.AdminApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 商品类型服务
|
||||
/// </summary>
|
||||
public class CodeGoodsTypeController : ApiController
|
||||
{
|
||||
private readonly ICodeGoodsTypeService _invokeService;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="invokeService"></param>
|
||||
public CodeGoodsTypeController(ICodeGoodsTypeService invokeService)
|
||||
{
|
||||
_invokeService = invokeService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("GetCodeGoodsTypeList")]
|
||||
public DataResult<List<CodeGoodsTypeRes>> GetCodeGoodsTypeList([FromBody] PageRequest request)
|
||||
{
|
||||
var res = _invokeService.GetListByPage(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("EditCodeGoodsType")]
|
||||
public DataResult EditCodeGoodsType([FromBody] CodeGoodsTypeReq model)
|
||||
{
|
||||
var res = _invokeService.EditCodeGoodsType(model);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("GetCodeGoodsTypeInfo")]
|
||||
public DataResult<CodeGoodsTypeRes> GetCodeGoodsTypeInfo([FromQuery] string id)
|
||||
{
|
||||
var res = _invokeService.GetCodeGoodsTypeInfo(id);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
using DS.Module.Core;
|
||||
using FluentValidation;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 商品类型请求实体
|
||||
/// </summary>
|
||||
public class CodeGoodsTypeReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 商品类型代码
|
||||
/// </summary>
|
||||
public string GoodsTypeCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品类型名称
|
||||
/// </summary>
|
||||
public string GoodsTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 英文名称
|
||||
/// </summary>
|
||||
public string EnName { get; set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// 状态 0 启用 1 禁用
|
||||
/// </summary>
|
||||
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证
|
||||
/// </summary>
|
||||
public class CodeGoodsTypeValidator : AbstractValidator<CodeGoodsTypeReq>
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CodeGoodsTypeValidator()
|
||||
{
|
||||
this.RuleFor(o => o.GoodsTypeCode)
|
||||
.NotEmpty().WithName("商品类型代码");
|
||||
this.RuleFor(o => o.GoodsTypeName)
|
||||
.NotEmpty().WithName("商品类型名称");
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
using DS.Module.Core;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 商品类型返回
|
||||
/// </summary>
|
||||
public class CodeGoodsTypeRes
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 商品类型代码
|
||||
/// </summary>
|
||||
public string GoodsTypeCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品类型名称
|
||||
/// </summary>
|
||||
public string GoodsTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 英文名称
|
||||
/// </summary>
|
||||
public string EnName { get; set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// 状态 0 启用 1 禁用
|
||||
/// </summary>
|
||||
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using DS.Module.Core;
|
||||
using DS.Module.Core.Data;
|
||||
using SqlSugar;
|
||||
|
||||
namespace DS.WMS.Core.Code.Entity;
|
||||
/// <summary>
|
||||
/// 船名信息表
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("op_code_vessel","船名信息表")]
|
||||
public class CodeVessel: BaseModel<long>
|
||||
{
|
||||
/// <summary>
|
||||
/// 船名
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "船名", Length = 60)]
|
||||
public string VesselName { get; set; }
|
||||
/// <summary>
|
||||
/// 中文说明
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "中文说明", Length = 100)]
|
||||
public string CnName { get; set; }
|
||||
/// <summary>
|
||||
/// 船公司Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "船公司Id")]
|
||||
public long CarrierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 船运代理
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "船运代理",IsNullable = true, Length = 100)]
|
||||
public string ShipAgency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// EDI代码-船舶呼号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "EDI代码-船舶呼号", Length = 5)]
|
||||
public string EdiCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态 0启用 1禁用
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "状态",DefaultValue = "0")]
|
||||
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
using DS.Module.Core;
|
||||
using DS.Module.Core.Data;
|
||||
using DS.WMS.Core.Code.Dtos;
|
||||
|
||||
namespace DS.WMS.Core.Code.Interface;
|
||||
|
||||
public interface ICodeGoodsTypeService
|
||||
{
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<List<CodeGoodsTypeRes>> GetListByPage(PageRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
DataResult EditCodeGoodsType(CodeGoodsTypeReq req);
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<CodeGoodsTypeRes> GetCodeGoodsTypeInfo(string id);
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<List<CodeGoodsTypeRes>> GetClientListByPage(PageRequest request);
|
||||
/// <summary>
|
||||
/// 编辑-客户端
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
DataResult EditClientCodeGoodsType(CodeGoodsTypeReq req);
|
||||
/// <summary>
|
||||
/// 获取详情 -客户端
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<CodeGoodsTypeRes> GetClientCodeGoodsTypeInfo(string id);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品类型列表-基础库
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<List<CodeGoodsTypeRes>> GetCodeGoodsTypeList(PageRequest request);
|
||||
/// <summary>
|
||||
/// 导入商品类型列表
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
DataResult ImportCodeGoodsType(IdModel req);
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前租户已有的商品类型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DataResult<List<string>> GetExistCodeGoodsTypeList();
|
||||
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
using DS.Module.Core;
|
||||
using DS.Module.Core.Data;
|
||||
using DS.Module.Core.Extensions;
|
||||
using DS.Module.SqlSugar;
|
||||
using DS.Module.UserModule;
|
||||
using DS.WMS.Core.Code.Dtos;
|
||||
using DS.WMS.Core.Code.Entity;
|
||||
using DS.WMS.Core.Code.Interface;
|
||||
using Mapster;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
|
||||
namespace DS.WMS.Core.Code.Method;
|
||||
|
||||
public class CodeGoodsTypeService:ICodeGoodsTypeService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ISqlSugarClient db;
|
||||
private readonly IUser user;
|
||||
private readonly ISaasDbService saasService;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public CodeGoodsTypeService(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
||||
user = _serviceProvider.GetRequiredService<IUser>();
|
||||
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
||||
}
|
||||
|
||||
public DataResult<List<CodeGoodsTypeRes>> GetListByPage(PageRequest request)
|
||||
{
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = db.Queryable<CodeGoodsType>()
|
||||
.Where(whereList)
|
||||
.Select<CodeGoodsTypeRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
|
||||
public DataResult EditCodeGoodsType(CodeGoodsTypeReq req)
|
||||
{
|
||||
if (req.Id == 0)
|
||||
{
|
||||
|
||||
if (db.Queryable<CodeGoodsType>().Where(x=>x.GoodsTypeCode == req.GoodsTypeCode.Trim()).Any())
|
||||
{
|
||||
return DataResult.Failed("商品类型已存在!",MultiLanguageConst.CodeGoodsTypeExist);
|
||||
}
|
||||
|
||||
var data = req.Adapt<CodeGoodsType>();
|
||||
|
||||
var entity = db.Insertable(data).ExecuteReturnEntity();
|
||||
|
||||
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = db.Queryable<CodeGoodsType>().Where(x => x.Id == req.Id).First();
|
||||
|
||||
info = req.Adapt(info);
|
||||
|
||||
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
public DataResult<CodeGoodsTypeRes> GetCodeGoodsTypeInfo(string id)
|
||||
{
|
||||
var data = db.Queryable<CodeGoodsType>()
|
||||
.Where(a => a.Id == long.Parse(id))
|
||||
.Select<CodeGoodsTypeRes>()
|
||||
.First();
|
||||
return DataResult<CodeGoodsTypeRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
||||
}
|
||||
|
||||
public DataResult<List<CodeGoodsTypeRes>> GetClientListByPage(PageRequest request)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbById(user.TenantId);
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = tenantDb.Queryable<CodeGoodsType>()
|
||||
.Where(whereList)
|
||||
.Select<CodeGoodsTypeRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
|
||||
public DataResult EditClientCodeGoodsType(CodeGoodsTypeReq req)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbById(user.TenantId);
|
||||
if (req.Id == 0)
|
||||
{
|
||||
|
||||
if (tenantDb.Queryable<CodeGoodsType>().Where(x=>x.GoodsTypeCode == req.GoodsTypeCode.Trim()).Any())
|
||||
{
|
||||
return DataResult.Failed("商品类型已存在!",MultiLanguageConst.CodeGoodsTypeExist);
|
||||
}
|
||||
|
||||
var data = req.Adapt<CodeGoodsType>();
|
||||
|
||||
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
||||
|
||||
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = tenantDb.Queryable<CodeGoodsType>().Where(x => x.Id == req.Id).First();
|
||||
|
||||
info = req.Adapt(info);
|
||||
|
||||
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
public DataResult<CodeGoodsTypeRes> GetClientCodeGoodsTypeInfo(string id)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbById(user.TenantId);
|
||||
var data = tenantDb.Queryable<CodeGoodsType>()
|
||||
.Where(a => a.Id == long.Parse(id))
|
||||
.Select<CodeGoodsTypeRes>()
|
||||
.First();
|
||||
return DataResult<CodeGoodsTypeRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
||||
}
|
||||
|
||||
public DataResult<List<CodeGoodsTypeRes>> GetCodeGoodsTypeList(PageRequest request)
|
||||
{
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = db.Queryable<CodeGoodsType>().Where(x=>x.Status == StatusEnum.Enable)
|
||||
.Where(whereList)
|
||||
.Select<CodeGoodsTypeRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
|
||||
public DataResult ImportCodeGoodsType(IdModel req)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbById(user.TenantId);
|
||||
var list = db.Queryable<CodeGoodsType>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
|
||||
if (list.Count == 0)
|
||||
{
|
||||
return DataResult.Failed("商品类型导入无数据!",MultiLanguageConst.CodeGoodsTypeImportNoData);
|
||||
}
|
||||
|
||||
if (tenantDb.Queryable<CodeGoodsType>().Where(x =>req.Ids.Contains(x.Id) ).Any())
|
||||
{
|
||||
return DataResult.Failed("存在已导入的商品类型!",MultiLanguageConst.CodeGoodsTypeImportAlready);
|
||||
}
|
||||
|
||||
tenantDb.Insertable(list).ExecuteCommand();
|
||||
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前租户已有的商品类型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DataResult<List<string>> GetExistCodeGoodsTypeList()
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbById(user.TenantId);
|
||||
var data = tenantDb.Queryable<CodeGoodsType>()
|
||||
.Select(n=>n.Id.ToString())
|
||||
.ToList();
|
||||
return DataResult<List<string>>.Success(data);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using DS.Module.Core;
|
||||
using DS.Module.Core.Data;
|
||||
using DS.WMS.Core.Code.Dtos;
|
||||
using DS.WMS.Core.Code.Interface;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DS.WMS.MainApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 商品类型服务
|
||||
/// </summary>
|
||||
public class CodeGoodsTypeController : ApiController
|
||||
{
|
||||
private readonly ICodeGoodsTypeService _invokeService;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="invokeService"></param>
|
||||
public CodeGoodsTypeController(ICodeGoodsTypeService invokeService)
|
||||
{
|
||||
_invokeService = invokeService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("GetCodeGoodsTypeList")]
|
||||
public DataResult<List<CodeGoodsTypeRes>> GetCodeGoodsTypeList([FromBody] PageRequest request)
|
||||
{
|
||||
var res = _invokeService.GetClientListByPage(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("EditCodeGoodsType")]
|
||||
public DataResult EditCodeGoodsType([FromBody] CodeGoodsTypeReq model)
|
||||
{
|
||||
var res = _invokeService.EditClientCodeGoodsType(model);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("GetCodeGoodsTypeInfo")]
|
||||
public DataResult<CodeGoodsTypeRes> GetCodeGoodsTypeInfo([FromQuery] string id)
|
||||
{
|
||||
var res = _invokeService.GetClientCodeGoodsTypeInfo(id);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品类型列表-基础库
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("GetBasicsCodeGoodsTypeList")]
|
||||
public DataResult<List<CodeGoodsTypeRes>> GetBasicsCodeGoodsTypeList([FromBody] PageRequest request)
|
||||
{
|
||||
var res = _invokeService.GetCodeGoodsTypeList(request);
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// 导入商品类型列表-基础库
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("ImportCodeGoodsType")]
|
||||
public DataResult ImportCodeGoodsType([FromBody] IdModel req)
|
||||
{
|
||||
var res = _invokeService.ImportCodeGoodsType(req);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前租户已有的商品类型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("GetExistCodeGoodsTypeList")]
|
||||
public DataResult<List<string>> GetExistCodeGoodsTypeList()
|
||||
{
|
||||
var res = _invokeService.GetExistCodeGoodsTypeList();
|
||||
return res;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue