仓库-毛坯仓库添加,毛坯仓库日志添加
This commit is contained in:
121
ZR.Service/mes/wms/WmBlankInventoryService.cs
Normal file
121
ZR.Service/mes/wms/WmBlankInventoryService.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Repository;
|
||||
using System.Linq;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
{
|
||||
/// <summary>
|
||||
/// 毛坯库存表Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IWmBlankInventoryService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class WmBlankInventoryService : BaseService<WmBlankInventory>, IWmBlankInventoryService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询毛坯库存表列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<WmBlankInventoryDto> GetList(WmBlankInventoryQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<WmBlankInventory>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.BlankNum), it => it.BlankNum.Contains(parm.BlankNum))
|
||||
.AndIF(parm.Status > -1, it => it.Status == parm.Status)
|
||||
.AndIF(parm.Type > 0, it => it.Type == parm.Type)
|
||||
;
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderByDescending(it=>it.UpdatedTime)
|
||||
.ToPage<WmBlankInventory, WmBlankInventoryDto>(parm);
|
||||
if (response.Result.Count > 0)
|
||||
{
|
||||
foreach (WmBlankInventoryDto item in response.Result)
|
||||
{
|
||||
WmMaterial material = Context.Queryable<WmMaterial>()
|
||||
.Where(it => it.BlankNum == item.BlankNum)
|
||||
.Where(it => it.Remarks == "毛坯")
|
||||
.First();
|
||||
if (material == null)
|
||||
{
|
||||
item.Description = "此毛坯号不在物料清单内!";
|
||||
continue;
|
||||
}
|
||||
item.Color = material.Color;
|
||||
item.Unit = material.Unit;
|
||||
item.Version = material.Version;
|
||||
item.Specification = material.Specification;
|
||||
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public WmBlankInventory GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加毛坯库存表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public WmBlankInventory AddWmBlankInventory(WmBlankInventory model)
|
||||
{
|
||||
bool hasRecord = Context.Queryable<WmBlankInventory>()
|
||||
.Where(it => it.BlankNum == model.BlankNum)
|
||||
.Any();
|
||||
if(hasRecord)
|
||||
{
|
||||
throw new Exception("毛坯仓库已有相同毛坯号记录");
|
||||
}
|
||||
model.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改毛坯库存表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateWmBlankInventory(WmBlankInventory model)
|
||||
{
|
||||
//var response = Update(w => w.Id == model.Id, it => new WmBlankInventory()
|
||||
//{
|
||||
// BlankNum = model.BlankNum,
|
||||
// Quantity = model.Quantity,
|
||||
// MaxNum = model.MaxNum,
|
||||
// MinNum = model.MinNum,
|
||||
// WarnNum = model.WarnNum,
|
||||
// Type = model.Type,
|
||||
// Status = model.Status,
|
||||
// Remark = model.Remark,
|
||||
// CreatedBy = model.CreatedBy,
|
||||
// CreatedTime = model.CreatedTime,
|
||||
// UpdatedBy = model.UpdatedBy,
|
||||
// UpdatedTime = model.UpdatedTime,
|
||||
//});
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user