Merge branch 'master' of https://codeup.aliyun.com/62ce7bca487c500c27f70a79/OPS/WMS-Api
This commit is contained in:
66
src/WMS.Web.Api/Controllers/TakeStockController.cs
Normal file
66
src/WMS.Web.Api/Controllers/TakeStockController.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto.TakeStock;
|
||||||
|
using WMS.Web.Core.Internal.Results;
|
||||||
|
using WMS.Web.Domain.Infrastructure;
|
||||||
|
using WMS.Web.Domain.IService.Public;
|
||||||
|
using WMS.Web.Domain.Values;
|
||||||
|
|
||||||
|
namespace WMS.Web.Api.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点单
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class TakeStockController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
private readonly ILoginService _loginService;
|
||||||
|
private readonly ITakeStockRepositories _repositories;
|
||||||
|
public TakeStockController(IMapper mapper, ILoginService loginService, ITakeStockRepositories repositories)
|
||||||
|
{
|
||||||
|
_mapper = mapper;
|
||||||
|
_loginService = loginService;
|
||||||
|
_repositories = repositories;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("GetList")]
|
||||||
|
public async Task<ResultPagedList<TakeStockQueryInfoResponse>> GetPagedList([FromBody] TakeStockQueryRequest dto)
|
||||||
|
{
|
||||||
|
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
|
||||||
|
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||||
|
return ResultPagedList<TakeStockQueryInfoResponse>.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||||
|
|
||||||
|
var (list, count) = await _repositories.GetListAsync(dto);
|
||||||
|
var result = ResultPagedList<TakeStockQueryInfoResponse>.ReSuccess(list, count);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("Save")]
|
||||||
|
public async Task<Result> Save(List<SaveTakeStockRequest> dto)
|
||||||
|
{
|
||||||
|
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
|
||||||
|
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||||
|
return Result.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||||
|
|
||||||
|
return await _changeMoveBoxService.MoveBoxSave(dto, loginInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/WMS.Web.Core/Dto/TakeStock/SaveTakeStockRequest.cs
Normal file
13
src/WMS.Web.Core/Dto/TakeStock/SaveTakeStockRequest.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WMS.Web.Core.Dto.TakeStock
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点单明细
|
||||||
|
/// </summary>
|
||||||
|
public class SaveTakeStockRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
65
src/WMS.Web.Core/Dto/TakeStock/TakeStockQueryInfoResponse.cs
Normal file
65
src/WMS.Web.Core/Dto/TakeStock/TakeStockQueryInfoResponse.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WMS.Web.Core.Dto.TakeStock
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点单列表
|
||||||
|
/// </summary>
|
||||||
|
public class TakeStockQueryInfoResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 明细编号
|
||||||
|
/// </summary>
|
||||||
|
public int DetailId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 单据编号
|
||||||
|
/// </summary>
|
||||||
|
public string BillNo { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点日期
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点人员
|
||||||
|
/// </summary>
|
||||||
|
public string Creator { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 金蝶同步成功或者失败 null 就是未同步
|
||||||
|
/// </summary>
|
||||||
|
public bool? SuccessSync { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 单位
|
||||||
|
/// </summary>
|
||||||
|
public string Unit { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库
|
||||||
|
/// </summary>
|
||||||
|
public string Stock { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 仓位
|
||||||
|
/// </summary>
|
||||||
|
public string SubStock { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点前数量(wms系统数量)
|
||||||
|
/// </summary>
|
||||||
|
public decimal BeforeQty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点实际数量(实际仓库数量)
|
||||||
|
/// </summary>
|
||||||
|
public decimal AfterQty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点后数量
|
||||||
|
/// </summary>
|
||||||
|
public decimal FinalQty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点结果类型:1为盘盈,2位盘亏
|
||||||
|
/// </summary>
|
||||||
|
public string ResultType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string Remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/WMS.Web.Core/Dto/TakeStock/TakeStockQueryRequest.cs
Normal file
33
src/WMS.Web.Core/Dto/TakeStock/TakeStockQueryRequest.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WMS.Web.Core.Dto.TakeStock
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点单列表请求
|
||||||
|
/// </summary>
|
||||||
|
public class TakeStockQueryRequest : PaginationBaseRequestDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点结果类型:1为盘盈,2位盘亏
|
||||||
|
/// </summary>
|
||||||
|
public int? ResultType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库ID
|
||||||
|
/// </summary>
|
||||||
|
public int? StockId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 单据编号
|
||||||
|
/// </summary>
|
||||||
|
public string BillNo { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点日期-开始
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? DateBeginDate { get; set; } = null;
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点日期-结束
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? DateEndDate { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,11 +35,6 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
[Column("CreatorId")]
|
[Column("CreatorId")]
|
||||||
public int CreatorId { get; set; }
|
public int CreatorId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 公司ID
|
|
||||||
/// </summary>
|
|
||||||
[Column("CompanyId")]
|
|
||||||
public int CompanyId { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 同步成功或者失败 null 就是未同步
|
/// 同步成功或者失败 null 就是未同步
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column("SuccessSync")]
|
[Column("SuccessSync")]
|
||||||
@@ -48,5 +43,14 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
/// 明细
|
/// 明细
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<TakeStockDetails> Details = new List<TakeStockDetails>();
|
public List<TakeStockDetails> Details = new List<TakeStockDetails>();
|
||||||
|
/// <summary>
|
||||||
|
/// 创建
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="creatorId"></param>
|
||||||
|
public void Create(int creatorId)
|
||||||
|
{
|
||||||
|
this.CreatorId = creatorId;
|
||||||
|
this.Date = DateTime.Now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
[Column("Fid")]
|
[Column("Fid")]
|
||||||
public int Fid { get; set; }
|
public int Fid { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单据头Id
|
/// 箱Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column("BoxId")]
|
[Column("BoxId")]
|
||||||
public int BoxId { get; set; }
|
public int BoxId { get; set; }
|
||||||
|
|||||||
19
src/WMS.Web.Domain/IService/ITakeStockService.cs
Normal file
19
src/WMS.Web.Domain/IService/ITakeStockService.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto.Login;
|
||||||
|
using WMS.Web.Core.Dto.TakeStock;
|
||||||
|
using WMS.Web.Core.Internal.Results;
|
||||||
|
|
||||||
|
namespace WMS.Web.Domain.IService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点单服务
|
||||||
|
/// </summary>
|
||||||
|
public interface ITakeStockService
|
||||||
|
{
|
||||||
|
//保存
|
||||||
|
Task<Result> Save(List<SaveTakeStockRequest> dto, LoginInDto loginInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace WMS.Web.Domain.Infrastructure
|
|||||||
// 新增
|
// 新增
|
||||||
Task<ChangeBoxRecord> Add(ChangeBoxRecord entity, bool isTransaction = true);
|
Task<ChangeBoxRecord> Add(ChangeBoxRecord entity, bool isTransaction = true);
|
||||||
|
|
||||||
// 获取销售列表
|
// 获取列表
|
||||||
Task<(List<ChangeBoxRecordQueryInfoResponse> list,int total)> GetListAsync(ChangeBoxRecordQueryRequest dto);
|
Task<(List<ChangeBoxRecordQueryInfoResponse> list,int total)> GetListAsync(ChangeBoxRecordQueryRequest dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace WMS.Web.Domain.Infrastructure
|
|||||||
{
|
{
|
||||||
// 新增
|
// 新增
|
||||||
Task<MoveBoxRecord> Add(MoveBoxRecord entity, bool isTransaction = true);
|
Task<MoveBoxRecord> Add(MoveBoxRecord entity, bool isTransaction = true);
|
||||||
// 获取销售列表
|
// 获取列表
|
||||||
Task<(List<MoveBoxRecordQueryInfoResponse> list, int total)> GetListAsync(MoveBoxRecordQueryRequest dto);
|
Task<(List<MoveBoxRecordQueryInfoResponse> list, int total)> GetListAsync(MoveBoxRecordQueryRequest dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto.TakeStock;
|
||||||
using WMS.Web.Domain.Entitys;
|
using WMS.Web.Domain.Entitys;
|
||||||
|
|
||||||
namespace WMS.Web.Domain.Infrastructure
|
namespace WMS.Web.Domain.Infrastructure
|
||||||
@@ -10,5 +11,7 @@ namespace WMS.Web.Domain.Infrastructure
|
|||||||
{
|
{
|
||||||
// 新增
|
// 新增
|
||||||
Task<TakeStock> Add(TakeStock entity, bool isTransaction = true);
|
Task<TakeStock> Add(TakeStock entity, bool isTransaction = true);
|
||||||
|
// 获取列表
|
||||||
|
Task<(List<TakeStockQueryInfoResponse> list, int total)> GetListAsync(TakeStockQueryRequest dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/WMS.Web.Domain/Mappers/MoveBoxRecordMapper.cs
Normal file
18
src/WMS.Web.Domain/Mappers/MoveBoxRecordMapper.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using WMS.Web.Core.Dto.ChangeBoxRecord;
|
||||||
|
using WMS.Web.Core.Dto.MoveBoxRecord;
|
||||||
|
using WMS.Web.Domain.Entitys;
|
||||||
|
|
||||||
|
namespace WMS.Web.Domain.Mappers
|
||||||
|
{
|
||||||
|
public class MoveBoxRecordMapper : Profile
|
||||||
|
{
|
||||||
|
public MoveBoxRecordMapper()
|
||||||
|
{
|
||||||
|
CreateMap<SaveMoveBoxRecordRequest, MoveBoxRecord>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/WMS.Web.Domain/Mappers/TakeStockMapper.cs
Normal file
17
src/WMS.Web.Domain/Mappers/TakeStockMapper.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using WMS.Web.Core.Dto.TakeStock;
|
||||||
|
using WMS.Web.Domain.Entitys;
|
||||||
|
|
||||||
|
namespace WMS.Web.Domain.Mappers
|
||||||
|
{
|
||||||
|
public class TakeStockMapper:Profile
|
||||||
|
{
|
||||||
|
public TakeStockMapper()
|
||||||
|
{
|
||||||
|
CreateMap<SaveTakeStockRequest, TakeStockDetails>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
65
src/WMS.Web.Domain/Services/TakeStockService.cs
Normal file
65
src/WMS.Web.Domain/Services/TakeStockService.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto.Login;
|
||||||
|
using WMS.Web.Core.Dto.TakeStock;
|
||||||
|
using WMS.Web.Core.Internal.Results;
|
||||||
|
using WMS.Web.Domain.Entitys;
|
||||||
|
using WMS.Web.Domain.Infrastructure;
|
||||||
|
using WMS.Web.Domain.IService;
|
||||||
|
using WMS.Web.Domain.IService.Public;
|
||||||
|
using WMS.Web.Domain.Values;
|
||||||
|
|
||||||
|
namespace WMS.Web.Domain.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点单服务
|
||||||
|
/// </summary>
|
||||||
|
public class TakeStockService : ITakeStockService
|
||||||
|
{
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
private readonly ILoginService _loginService;
|
||||||
|
public readonly ITransactionRepositories _transactionRepositories;
|
||||||
|
private readonly ITakeStockRepositories _takeStockRepositories;
|
||||||
|
public TakeStockService(IMapper mapper, ILoginService loginService,
|
||||||
|
ITransactionRepositories transactionRepositories,
|
||||||
|
ITakeStockRepositories takeStockRepositories)
|
||||||
|
{
|
||||||
|
_mapper = mapper;
|
||||||
|
_loginService = loginService;
|
||||||
|
_transactionRepositories = transactionRepositories;
|
||||||
|
_takeStockRepositories = takeStockRepositories;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <param name="loginInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<Result> Save(List<SaveTakeStockRequest> dto, LoginInDto loginInfo)
|
||||||
|
{
|
||||||
|
TakeStock entity = new TakeStock();
|
||||||
|
entity.Details = _mapper.Map<List<TakeStockDetails>>(dto);
|
||||||
|
entity.Create(loginInfo.UserInfo.StaffId);
|
||||||
|
|
||||||
|
//需要填写序列号
|
||||||
|
//需要修改库存
|
||||||
|
|
||||||
|
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||||
|
bool isRollback = false;
|
||||||
|
bool isSuccess = true;
|
||||||
|
entity = await _takeStockRepositories.Add(entity, true);
|
||||||
|
if (entity == null) isRollback = true;
|
||||||
|
|
||||||
|
//提交事务
|
||||||
|
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||||
|
if (!isSuccess)
|
||||||
|
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
|
||||||
|
return Result.ReSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -235,7 +235,7 @@ namespace WMS.Web.Repositories.DependencyInjection
|
|||||||
Services.AddTransient<IErpService, ErpService>();
|
Services.AddTransient<IErpService, ErpService>();
|
||||||
|
|
||||||
Services.AddTransient<IChangeMoveBoxService, ChangeMoveBoxService>();
|
Services.AddTransient<IChangeMoveBoxService, ChangeMoveBoxService>();
|
||||||
|
Services.AddTransient<ITakeStockService, TakeStockService>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto.TakeStock;
|
||||||
using WMS.Web.Domain.Entitys;
|
using WMS.Web.Domain.Entitys;
|
||||||
using WMS.Web.Domain.Infrastructure;
|
using WMS.Web.Domain.Infrastructure;
|
||||||
using WMS.Web.Repositories.Configuration;
|
using WMS.Web.Repositories.Configuration;
|
||||||
@@ -57,5 +60,43 @@ namespace WMS.Web.Repositories
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点单列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<(List<TakeStockQueryInfoResponse> list, int total)> GetListAsync(TakeStockQueryRequest dto)
|
||||||
|
{
|
||||||
|
var query = _context.TakeStock
|
||||||
|
.OrderByDescending(o => o.Id)
|
||||||
|
.Where(adv => 1 == 1);
|
||||||
|
|
||||||
|
if (dto.DateBeginDate != null)
|
||||||
|
query = query.Where(w => w.Date >= dto.DateBeginDate);
|
||||||
|
if (dto.DateEndDate != null)
|
||||||
|
query = query.Where(w => w.Date <= dto.DateEndDate);
|
||||||
|
//组装
|
||||||
|
int total = await query.CountAsync();
|
||||||
|
var list = await query.Select(s => new TakeStockQueryInfoResponse()
|
||||||
|
{
|
||||||
|
#region dto组装
|
||||||
|
DetailId = 0,
|
||||||
|
BillNo = "",
|
||||||
|
Unit = "",
|
||||||
|
Stock = "",
|
||||||
|
SubStock = "",
|
||||||
|
BeforeQty = 0,
|
||||||
|
AfterQty = 0,
|
||||||
|
FinalQty = 0,
|
||||||
|
ResultType="",
|
||||||
|
Remark="",
|
||||||
|
Creator = "",
|
||||||
|
Date = s.Date,
|
||||||
|
SuccessSync=s.SuccessSync
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||||
|
return (list, total);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user