出入库回退增加备注

This commit is contained in:
18942506660
2024-07-27 10:31:57 +08:00
parent a28c882307
commit 16d067fa94
11 changed files with 150 additions and 11 deletions

View File

@@ -110,6 +110,19 @@ namespace WMS.Web.Api.Controllers
return Result.ReFailure(ResultCodes.Token_Invalid_Error); return Result.ReFailure(ResultCodes.Token_Invalid_Error);
return await _backRecordService.BackShelf(dto, BackRecordType.InstockOff, loginInfo); return await _backRecordService.BackShelf(dto, BackRecordType.InstockOff, loginInfo);
} }
/// <summary>
/// 修改备注
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost]
[Route("UpdateRemark")]
public async Task<Result> UpdateRemark([FromBody] UpdateRemarkRequest 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 _backRecordService.UpdateRemark(dto, loginInfo);
}
} }
} }

View File

@@ -90,6 +90,10 @@ namespace WMS.Web.Core.Dto
/// </summary> /// </summary>
[Ignore] [Ignore]
public string Stock { get; set; } public string Stock { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
} }

View File

@@ -39,5 +39,9 @@ namespace WMS.Web.Core.Dto.BackRecord
/// </summary> /// </summary>
[Required(ErrorMessage = "序列号不能为空")] [Required(ErrorMessage = "序列号不能为空")]
public List<string> SerialNumbers { get; set; } = new List<string>(); public List<string> SerialNumbers { get; set; } = new List<string>();
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
} }
} }

View File

@@ -0,0 +1,27 @@
using Npoi.Mapper.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
namespace WMS.Web.Core.Dto.BackRecord
{
/// <summary>
/// 修改备注
/// </summary>
public class UpdateRemarkRequest
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 明细ID
/// </summary>
public int DetailsId { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

View File

@@ -1,7 +1,10 @@
using System; 
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text; using System.Text;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Values; using WMS.Web.Domain.Values;
namespace WMS.Web.Domain.Entitys namespace WMS.Web.Domain.Entitys
@@ -89,5 +92,18 @@ namespace WMS.Web.Domain.Entitys
} }
this.BillNo = "CR" + idStr; this.BillNo = "CR" + idStr;
} }
/// <summary>
/// 修改备注
/// </summary>
/// <param name="detailId"></param>
/// <param name="remark"></param>
/// <returns></returns>
public Result UpdateRemark(int detailId, string remark)
{
var detail = this.Details.Where(w => w.Id == detailId).FirstOrDefault();
if (detail == null) return Result.ReFailure(ResultCodes.NoDateError);
detail.Remark = remark;
return Result.ReSuccess();
}
} }
} }

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text; using System.Text;
using WMS.Web.Core;
namespace WMS.Web.Domain.Entitys namespace WMS.Web.Domain.Entitys
{ {
@@ -10,12 +11,12 @@ namespace WMS.Web.Domain.Entitys
/// </summary> /// </summary>
[Serializable] [Serializable]
[Table("t_wms_back_record_details")] [Table("t_wms_back_record_details")]
public class BackRecordDetails public class BackRecordDetails : EntityBase
{ {
/// <summary> /// <summary>
/// ID /// 编号
/// </summary> /// </summary>
public int Id { get; set; } public override int Id { get; set; }
/// <summary> /// <summary>
/// 回退记录表ID /// 回退记录表ID
/// </summary> /// </summary>
@@ -39,5 +40,9 @@ namespace WMS.Web.Domain.Entitys
/// 序列号集 /// 序列号集
/// </summary> /// </summary>
public List<string> SerialNumbers { get; set; } = new List<string>(); public List<string> SerialNumbers { get; set; } = new List<string>();
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
} }
} }

View File

@@ -22,5 +22,13 @@ namespace WMS.Web.Domain.IService
/// <param name="loginInfo"></param> /// <param name="loginInfo"></param>
/// <returns></returns> /// <returns></returns>
Task<Result> BackShelf(BackRecordOnOffRequest dto, BackRecordType type, LoginInDto loginInfo); Task<Result> BackShelf(BackRecordOnOffRequest dto, BackRecordType type, LoginInDto loginInfo);
/// <summary>
/// 修改备注
/// </summary>
/// <param name="dto"></param>
/// <param name="loginInfo"></param>
/// <returns></returns>
Task<Result> UpdateRemark(UpdateRemarkRequest dto, LoginInDto loginInfo);
} }
} }

View File

@@ -28,5 +28,9 @@ namespace WMS.Web.Domain.Infrastructure
/// <param name="isTransaction"></param> /// <param name="isTransaction"></param>
/// <returns></returns> /// <returns></returns>
Task<BackRecord> Add(BackRecord entity, bool isTransaction = true); Task<BackRecord> Add(BackRecord entity, bool isTransaction = true);
//修改
Task<BackRecord> Edit(BackRecord entity, bool isTransaction = true);
//获取
Task<BackRecord> GetEntity(int id);
} }
} }

View File

@@ -71,7 +71,7 @@ namespace WMS.Web.Domain.Services
else else
_logger.LogInformation($"回退上架:{JsonConvert.SerializeObject(dto)} 操作人:{loginInfo.UserInfo.StaffId + loginInfo.UserInfo.Nickname}"); _logger.LogInformation($"回退上架:{JsonConvert.SerializeObject(dto)} 操作人:{loginInfo.UserInfo.StaffId + loginInfo.UserInfo.Nickname}");
//回退上下架:不能扫同样的箱,按箱入库时候 //回退上下架:不能扫同样的箱,按箱入库时候
if (dto.Details != null && dto.Details.Count != 0 && dto.Method== (int)InventoryInOutMethod.Box) if (dto.Details != null && dto.Details.Count != 0 && dto.Method == (int)InventoryInOutMethod.Box)
{ {
var mIds = dto.Details.GroupBy(g => g.MaterialNumber).Select(s => s.Key).ToList(); var mIds = dto.Details.GroupBy(g => g.MaterialNumber).Select(s => s.Key).ToList();
foreach (var m in mIds) foreach (var m in mIds)
@@ -116,8 +116,8 @@ namespace WMS.Web.Domain.Services
if (entity.Type == BackRecordType.InstockOff) if (entity.Type == BackRecordType.InstockOff)
{ {
_logger.LogInformation("入库回退下架:" + entity.BillNo); _logger.LogInformation("入库回退下架:" + entity.BillNo);
var boxIds= entity.Details.GroupBy(x => x.BoxId).Select(x => x.Key).ToList(); var boxIds = entity.Details.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
var unBindResult= await _inStockTaskBoxService.UnBind(boxIds, isTransaction); var unBindResult = await _inStockTaskBoxService.UnBind(boxIds, isTransaction);
_logger.LogInformation("入库回退下架-BOXID" + JsonConvert.SerializeObject(boxIds)); _logger.LogInformation("入库回退下架-BOXID" + JsonConvert.SerializeObject(boxIds));
if (!unBindResult.IsSuccess) if (!unBindResult.IsSuccess)
return unBindResult; return unBindResult;
@@ -132,5 +132,24 @@ namespace WMS.Web.Domain.Services
return Result.ReSuccess(); return Result.ReSuccess();
} }
/// <summary>
/// 修改备注
/// </summary>
/// <param name="dto"></param>
/// <param name="loginInfo"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<Result> UpdateRemark(UpdateRemarkRequest dto, LoginInDto loginInfo)
{
var entity = await _backRecordRepositories.GetEntity(dto.Id);
if (entity == null) return Result.ReFailure(ResultCodes.NoDateError);
var res = entity.UpdateRemark(dto.DetailsId, dto.Remark);
if (!res.IsSuccess) return res;
entity = await _backRecordRepositories.Edit(entity, true);
if (entity == null) return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
} }
} }

View File

@@ -15,6 +15,7 @@ using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure; using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService.Public; using WMS.Web.Domain.IService.Public;
using WMS.Web.Domain.Mappers;
using WMS.Web.Domain.Values.Single; using WMS.Web.Domain.Values.Single;
using WMS.Web.Repositories.Configuration; using WMS.Web.Repositories.Configuration;
@@ -122,6 +123,7 @@ namespace WMS.Web.Repositories
Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, companyId, s.order.StockCode + s.order.OrgCode), Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, companyId, s.order.StockCode + s.order.OrgCode),
SubStock = _singleDataService.GetSingleData(SingleAction.SubStocksJoinOrgCode, companyId, s.order.SubStockCode + s.order.StockCode + s.order.OrgCode), SubStock = _singleDataService.GetSingleData(SingleAction.SubStocksJoinOrgCode, companyId, s.order.SubStockCode + s.order.StockCode + s.order.OrgCode),
SerialNumbers = (string.Join(",", s.detail.SerialNumbers)).TrimEnd(','), SerialNumbers = (string.Join(",", s.detail.SerialNumbers)).TrimEnd(','),
Remark=s.detail.Remark
}).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); }).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
return (list,total); return (list,total);
@@ -171,5 +173,42 @@ namespace WMS.Web.Repositories
{ {
return await GetPagedList(dto,companyId); return await GetPagedList(dto,companyId);
} }
public async Task<BackRecord> Edit(BackRecord entity, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
var res = await _context.BackRecord
.Include(s => s.Details)
.FirstOrDefaultAsync(f => f.Id == entity.Id);
if (res == null) return null;
_mapper.Map(entity, res);
_mapper.ToMapList(entity.Details, res.Details);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
return res;
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return null;
}
}
public async Task<BackRecord> GetEntity(int id)
{
return await _context.BackRecord.AsNoTracking()
.Include(s => s.Details)
.Where(f => id == f.Id).FirstOrDefaultAsync();
}
} }
} }