抛光仓库功能

This commit is contained in:
赵正易 2024-07-26 17:34:01 +08:00
parent d3029ed1e4
commit 512231d555
5 changed files with 219 additions and 32 deletions

View File

@ -104,27 +104,6 @@ namespace ZR.Admin.WebApi.Controllers
return ToResponse(response);
}
/// <summary>
/// 抛光手动入库
/// </summary>
/// <returns></returns>
[HttpPost("doWmPolishWarehousing")]
[ActionPermissionFilter(Permission = "business:wmpolishinventory:add")]
[Log(Title = "抛光手动入库", BusinessType = BusinessType.INSERT)]
public IActionResult DoWmPolishWarehousing([FromBody] WmPolishInventoryDto parm)
{
try
{
var modal = parm.Adapt<WmPolishInventory>().ToCreate(HttpContext);
var response = _WmPolishInventoryService.DoWmPolishWarehousing(modal);
return ToResponse(new ApiResult(200, "手动入库成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "手动入库异常:" + e.Message, e.Message));
}
}
/// <summary>
/// 物料下拉菜单查看
/// </summary>
@ -142,5 +121,68 @@ namespace ZR.Admin.WebApi.Controllers
return ToResponse(new ApiResult(500, "获取物料下拉菜单数据失败:" + e.Message, null));
}
}
/// <summary>
/// 抛光手动入库
/// </summary>
/// <returns></returns>
[HttpPost("doWmPolishWarehousing")]
[ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")]
[Log(Title = "抛光手动入库", BusinessType = BusinessType.UPDATE)]
public IActionResult DoWmPolishWarehousing([FromBody] WmPolishInventoryDto parm)
{
try
{
var modal = parm.Adapt<WmPolishInventory>().ToCreate(HttpContext);
var response = _WmPolishInventoryService.DoWmPolishWarehousing(modal);
return ToResponse(new ApiResult(200, "手动入库成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "手动入库异常:" + e.Message, e.Message));
}
}
/// <summary>
/// 抛光手动出库
/// </summary>
/// <returns></returns>
[HttpPost("doWmPolishRetrieval")]
[ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")]
[Log(Title = "抛光手动出库", BusinessType = BusinessType.UPDATE)]
public IActionResult DoWmPolishRetrieval([FromBody] WmPolishInventoryDto parm)
{
try
{
var modal = parm.Adapt<WmPolishInventory>().ToCreate(HttpContext);
var response = _WmPolishInventoryService.DoWmPolishRetrieval(modal);
return ToResponse(new ApiResult(200, "手动出库成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "手动出库异常:" + e.Message, e.Message));
}
}
/// <summary>
/// 抛光仓库盘点
/// </summary>
/// <returns></returns>
[HttpPost("doWmPolishStocktaking")]
[ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")]
[Log(Title = "抛光仓库盘点", BusinessType = BusinessType.INSERT)]
public IActionResult DoWmPolishStocktaking([FromBody] WmPolishInventoryDto parm)
{
try
{
var modal = parm.Adapt<WmPolishInventory>().ToCreate(HttpContext);
var response = _WmPolishInventoryService.DoWmPolishStocktaking(modal);
return ToResponse(new ApiResult(200, "盘点成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "盘点异常:" + e.Message, e.Message));
}
}
}
}

View File

@ -5,8 +5,16 @@ namespace ZR.Model.MES.wms.Dto
/// <summary>
/// 工艺路线-抛光 库存变动表查询对象
/// </summary>
public class WmPolishRecordQueryDto : PagerInfo
public class WmPolishRecordQueryDto : PagerInfo
{
public string Id { get; set; }
public string FkInventoryId { get; set; }
public string Code { get; set; }
public string BlankNum { get; set; }
public string Partnumber { get; set; }
public int? ChangeType { get; set; }
public DateTime? StartActionTime { get; set; }
public DateTime? EndActionTime { get; set; }
}
/// <summary>
@ -43,8 +51,5 @@ namespace ZR.Model.MES.wms.Dto
public string UpdatedBy { get; set; }
public DateTime? UpdatedTime { get; set; }
}
}
}

View File

@ -30,6 +30,13 @@ namespace ZR.Service.mes.wms.IService
/// <returns></returns>
int DoWmPolishWarehousing(WmPolishInventory parm);
/// <summary>
/// 抛光零件出库
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
int DoWmPolishRetrieval(WmPolishInventory parm);
/// <summary>
/// 抛光零件盘点
/// </summary>

View File

@ -252,7 +252,7 @@ namespace ZR.Service.mes.wms
.Insertable(newWmPolishInventory)
.ExecuteReturnEntity();
string code = SnowFlakeSingle.Instance.NextId().ToString();
string remark = "初次创建仓库,新增手动入库数据";
string remark = "初次创建仓库,新增入库数据 " + parm.Remark;
int successNum = AddPolishRecord(
addWmPolishInventory.Id,
code,
@ -280,7 +280,6 @@ namespace ZR.Service.mes.wms
}
// 已有则新增记录
string code = SnowFlakeSingle.Instance.NextId().ToString();
string remark = "手动入库";
int successNum = AddPolishRecord(
polishInventory.Id,
code,
@ -288,13 +287,117 @@ namespace ZR.Service.mes.wms
1,
parm.Quantity,
parm.ActionTime,
parm.Remark,
parm.CreatedBy
);
if (successNum == 0)
{
Context.Ado.RollbackTran();
throw new Exception("入库日志添加失败");
}
}
Context.Ado.CommitTran();
return 1;
}
catch (Exception e)
{
Context.Ado.RollbackTran();
throw new Exception(e.Message);
}
}
public int DoWmPolishRetrieval(WmPolishInventory parm)
{
try
{
Context.Ado.BeginTran();
// 零件号检查
string partnumber = parm.Partnumber;
WmMaterial material = Context
.Queryable<WmMaterial>()
.Where(it => it.Partnumber == partnumber)
.Where(it => it.Type == 1)
.Where(it => it.Status == 1)
.First();
if (material == null)
{
Context.Ado.RollbackTran();
throw new Exception("零件号在物料清单未查到,请到物料清单新增零件号记录");
}
// 检查是否存在库中
WmPolishInventory polishInventory = Context
.Queryable<WmPolishInventory>()
.Where(it => it.Partnumber == partnumber)
.Where(it => it.Type == parm.Type)
.Where(it => it.Status == 1)
.First();
if (polishInventory == null)
{
// 为空则新增库
WmPolishInventory newWmPolishInventory =
new()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
BlankNum = "",
Partnumber = partnumber,
Type = parm.Type,
Quantity = parm.Quantity * -1,
MaxNum = 0,
MinNum = 0,
WarnNum = 0,
Status = 1,
Remark = "系统自动创建库",
CreatedBy = parm.CreatedBy,
CreatedTime = DateTime.Now.ToLocalTime(),
UpdatedBy = parm.CreatedBy,
UpdatedTime = DateTime.Now.ToLocalTime(),
};
WmPolishInventory addWmPolishInventory = Context
.Insertable(newWmPolishInventory)
.ExecuteReturnEntity();
string code = SnowFlakeSingle.Instance.NextId().ToString();
string remark = "初次创建仓库,新增手动出库数据" + parm.Remark;
int successNum = AddPolishRecord(
addWmPolishInventory.Id,
code,
partnumber,
2,
parm.Quantity,
parm.ActionTime,
remark,
parm.CreatedBy
);
if (successNum == 0)
{
Context.Ado.RollbackTran();
throw new Exception("入库日志添加失败");
throw new Exception("出库日志添加失败");
}
}
else
{
polishInventory.Quantity -= parm.Quantity;
int updateNum = Context.Updateable(polishInventory).ExecuteCommand();
if (updateNum == 0)
{
Context.Ado.RollbackTran();
throw new Exception("修改抛光仓库零件数失败");
}
// 已有则新增记录
string code = SnowFlakeSingle.Instance.NextId().ToString();
int successNum = AddPolishRecord(
polishInventory.Id,
code,
partnumber,
2,
parm.Quantity,
parm.ActionTime,
parm.Remark,
parm.CreatedBy
);
if (successNum == 0)
{
Context.Ado.RollbackTran();
throw new Exception("出库日志添加失败");
}
}
Context.Ado.CommitTran();
@ -326,7 +429,6 @@ namespace ZR.Service.mes.wms
Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
// 已有则新增记录
string code = SnowFlakeSingle.Instance.NextId().ToString();
string remark = "手动盘点";
int successNum = AddPolishRecord(
parm.Id,
code,
@ -334,7 +436,7 @@ namespace ZR.Service.mes.wms
3,
parm.Quantity,
parm.ActionTime,
remark,
parm.Remark,
parm.CreatedBy
);
if (successNum == 0)
@ -351,5 +453,7 @@ namespace ZR.Service.mes.wms
throw new Exception(e.Message);
}
}
}
}

View File

@ -1,4 +1,6 @@
using System;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using SqlSugar;
using ZR.Model;
using ZR.Model.MES.wms;
@ -21,10 +23,37 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public PagedInfo<WmPolishRecordDto> GetList(WmPolishRecordQueryDto parm)
{
var predicate = Expressionable.Create<WmPolishRecord>();
DateTime startTime = parm.StartActionTime ?? DateTime.MinValue;
DateTime endTime = parm.EndActionTime ?? DateTime.MinValue;
var predicate = Expressionable
.Create<WmPolishRecord>()
.AndIF(
!string.IsNullOrEmpty(parm.Partnumber),
it => it.Partnumber.Contains(parm.Partnumber)
)
.AndIF(
!string.IsNullOrEmpty(parm.BlankNum),
it => it.BlankNum.Contains(parm.BlankNum)
)
.AndIF(!string.IsNullOrEmpty(parm.Code), it => it.Code.Contains(parm.Code))
.AndIF(
!string.IsNullOrEmpty(parm.FkInventoryId),
it => it.FkInventoryId == parm.FkInventoryId
)
.AndIF(!string.IsNullOrEmpty(parm.Id), it => it.Id == parm.Id)
.AndIF(parm.ChangeType > -1, it => it.ChangeType == parm.ChangeType)
.AndIF(
startTime > DateTime.MinValue,
it => startTime <= it.ActionTime
)
.AndIF(
endTime > DateTime.MinValue,
it => endTime >= it.ActionTime
);
var response = Queryable()
.Where(predicate.ToExpression())
.OrderByDescending(it => it.ActionTime)
.ToPage<WmPolishRecord, WmPolishRecordDto>(parm);
return response;