抛光管理,完成抛光仓库入库,盘点,生成日志 条件查询功能
This commit is contained in:
40
ZR.Service/mes/wms/IService/IWmPolishInventoryService.cs
Normal file
40
ZR.Service/mes/wms/IService/IWmPolishInventoryService.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
|
||||
namespace ZR.Service.mes.wms.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺路线-抛光 库存表service接口
|
||||
/// </summary>
|
||||
public interface IWmPolishInventoryService : IBaseService<WmPolishInventory>
|
||||
{
|
||||
PagedInfo<WmPolishInventoryDto> GetList(WmPolishInventoryQueryDto parm);
|
||||
|
||||
WmPolishInventory GetInfo(string Id);
|
||||
|
||||
WmPolishInventory AddWmPolishInventory(WmPolishInventory parm);
|
||||
|
||||
int UpdateWmPolishInventory(WmPolishInventory parm);
|
||||
|
||||
/// <summary>
|
||||
/// 抛光库,物料下拉菜单获取下拉选项
|
||||
/// </summary>
|
||||
/// <param name="partnumber"></param>
|
||||
/// <returns></returns>
|
||||
public List<WmMaterialSelectOptions> GetMaterialSelectOption(string partnumber);
|
||||
/// <summary>
|
||||
/// 抛光零件入库
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
int DoWmPolishWarehousing(WmPolishInventory parm);
|
||||
|
||||
/// <summary>
|
||||
/// 抛光零件盘点
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
int DoWmPolishStocktaking(WmPolishInventory parm);
|
||||
}
|
||||
}
|
||||
20
ZR.Service/mes/wms/IService/IWmPolishRecordService.cs
Normal file
20
ZR.Service/mes/wms/IService/IWmPolishRecordService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
|
||||
namespace ZR.Service.mes.wms.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺路线-抛光 库存变动表service接口
|
||||
/// </summary>
|
||||
public interface IWmPolishRecordService : IBaseService<WmPolishRecord>
|
||||
{
|
||||
PagedInfo<WmPolishRecordDto> GetList(WmPolishRecordQueryDto parm);
|
||||
|
||||
WmPolishRecord GetInfo(string Id);
|
||||
|
||||
WmPolishRecord AddWmPolishRecord(WmPolishRecord parm);
|
||||
|
||||
int UpdateWmPolishRecord(WmPolishRecord parm);
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ namespace ZR.Service.mes.wms
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.BlankNum == item.BlankNum)
|
||||
.Where(it => it.Type == 2)
|
||||
.Where(it => it.Status == 1)
|
||||
.First();
|
||||
if (material == null)
|
||||
{
|
||||
|
||||
355
ZR.Service/mes/wms/WmPolishInventoryService.cs
Normal file
355
ZR.Service/mes/wms/WmPolishInventoryService.cs
Normal file
@@ -0,0 +1,355 @@
|
||||
using System;
|
||||
using Aliyun.OSS;
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺路线-抛光 库存表Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(
|
||||
ServiceType = typeof(IWmPolishInventoryService),
|
||||
ServiceLifetime = LifeTime.Transient
|
||||
)]
|
||||
public class WmPolishInventoryService
|
||||
: BaseService<WmPolishInventory>,
|
||||
IWmPolishInventoryService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询工艺路线-抛光 库存表列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<WmPolishInventoryDto> GetList(WmPolishInventoryQueryDto parm)
|
||||
{
|
||||
List<string> partnumberByDescription = new();
|
||||
if (parm != null && !string.IsNullOrEmpty(parm.Description))
|
||||
{
|
||||
partnumberByDescription = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Description.Contains(parm.Description))
|
||||
.Select(it => it.Partnumber)
|
||||
.ToList();
|
||||
}
|
||||
var predicate = Expressionable
|
||||
.Create<WmPolishInventory>()
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(parm.Description),
|
||||
it => partnumberByDescription.Contains(it.Partnumber)
|
||||
)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(parm.Partnumber),
|
||||
it => it.Partnumber.Contains(parm.Partnumber)
|
||||
)
|
||||
.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<WmPolishInventory, WmPolishInventoryDto>(parm);
|
||||
if (response.Result.Count > 0)
|
||||
{
|
||||
foreach (WmPolishInventoryDto item in response.Result)
|
||||
{
|
||||
WmMaterial material = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Partnumber == item.Partnumber)
|
||||
.Where(it => it.Type == 1)
|
||||
.Where(it => it.Status == 1)
|
||||
.First();
|
||||
if (material == null)
|
||||
{
|
||||
item.Description = "此毛坯号不在物料清单内!";
|
||||
continue;
|
||||
}
|
||||
item.Color = material.Color;
|
||||
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 WmPolishInventory GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable().Where(x => x.Id == Id).First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加工艺路线-抛光 库存表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public WmPolishInventory AddWmPolishInventory(WmPolishInventory model)
|
||||
{
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改工艺路线-抛光 库存表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateWmPolishInventory(WmPolishInventory model)
|
||||
{
|
||||
//var response = Update(w => w.Id == model.Id, it => new WmPolishInventory()
|
||||
//{
|
||||
// BlankNum = model.BlankNum,
|
||||
// Partnumber = model.Partnumber,
|
||||
// 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 零件号下拉查询
|
||||
/// </summary>
|
||||
/// <param name="query">零件号或描述</param>
|
||||
/// <returns></returns>
|
||||
public List<WmMaterialSelectOptions> GetMaterialSelectOption(string query)
|
||||
{
|
||||
var predicate = Expressionable
|
||||
.Create<WmMaterial>()
|
||||
.Or(it => it.Partnumber.Contains(query))
|
||||
.Or(it => it.Description.Contains(query))
|
||||
.Or(it => it.ProductName.Contains(query))
|
||||
.And(it => it.Type == 1)
|
||||
.And(it => it.Status == 1);
|
||||
List<WmMaterialSelectOptions> options = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(predicate.ToExpression())
|
||||
.Select(
|
||||
(it) =>
|
||||
new WmMaterialSelectOptions
|
||||
{
|
||||
Key = it.Id,
|
||||
Label = "[ " + it.Partnumber + " ] " + it.Description,
|
||||
Value = it.Partnumber
|
||||
}
|
||||
)
|
||||
.ToList();
|
||||
return options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增抛光仓库操作记录
|
||||
/// </summary>
|
||||
/// <param name="fkInventoryId">抛光仓库主键</param>
|
||||
/// <param name="code">同批功能识别编号</param>
|
||||
/// <param name="partnumber">零件号</param>
|
||||
/// <param name="type">类别</param>
|
||||
/// <param name="changeQuantity">操作数字</param>
|
||||
/// <param name="remark">备注</param>
|
||||
/// <param name="createdBy">创建人</param>
|
||||
/// <returns></returns>
|
||||
public int AddPolishRecord(
|
||||
string fkInventoryId,
|
||||
string code,
|
||||
string partnumber,
|
||||
int type,
|
||||
int? changeQuantity,
|
||||
DateTime? actionTime,
|
||||
string remark,
|
||||
string createdBy
|
||||
)
|
||||
{
|
||||
WmPolishRecord newPolishRecord =
|
||||
new()
|
||||
{
|
||||
Id = SnowFlakeSingle.Instance.NextId().ToString(),
|
||||
FkInventoryId = fkInventoryId,
|
||||
Code = code,
|
||||
Partnumber = partnumber,
|
||||
BlankNum = "",
|
||||
ChangeType = type,
|
||||
ChangeQuantity = changeQuantity ?? 0,
|
||||
ActionTime = actionTime,
|
||||
Status = 1,
|
||||
Remark = remark,
|
||||
CreatedBy = createdBy,
|
||||
CreatedTime = DateTime.Now.ToLocalTime(),
|
||||
UpdatedBy = createdBy,
|
||||
UpdatedTime = DateTime.Now.ToLocalTime(),
|
||||
};
|
||||
|
||||
return Context.Insertable(newPolishRecord).ExecuteCommand();
|
||||
}
|
||||
|
||||
public int DoWmPolishWarehousing(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,
|
||||
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 = "初次创建仓库,新增手动入库数据";
|
||||
int successNum = AddPolishRecord(
|
||||
addWmPolishInventory.Id,
|
||||
code,
|
||||
partnumber,
|
||||
1,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
remark,
|
||||
parm.CreatedBy
|
||||
);
|
||||
if (successNum == 0)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
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();
|
||||
string remark = "手动入库";
|
||||
int successNum = AddPolishRecord(
|
||||
polishInventory.Id,
|
||||
code,
|
||||
partnumber,
|
||||
1,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
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 DoWmPolishStocktaking(WmPolishInventory parm)
|
||||
{
|
||||
if (parm.Quantity < 0)
|
||||
{
|
||||
throw new Exception("修改的零件数小于0");
|
||||
}
|
||||
try
|
||||
{
|
||||
Context.Ado.BeginTran();
|
||||
// 检查是否存在库中
|
||||
WmPolishInventory polishInventory = Context
|
||||
.Queryable<WmPolishInventory>()
|
||||
.Where(it => it.Id == parm.Id)
|
||||
.Where(it => it.Status == 1)
|
||||
.First();
|
||||
polishInventory.Quantity = parm.Quantity;
|
||||
Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
// 已有则新增记录
|
||||
string code = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
string remark = "手动盘点";
|
||||
int successNum = AddPolishRecord(
|
||||
parm.Id,
|
||||
code,
|
||||
parm.Partnumber,
|
||||
3,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
remark,
|
||||
parm.CreatedBy
|
||||
);
|
||||
if (successNum == 0)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("盘点日志添加失败");
|
||||
}
|
||||
Context.Ado.CommitTran();
|
||||
return successNum;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
ZR.Service/mes/wms/WmPolishRecordService.cs
Normal file
81
ZR.Service/mes/wms/WmPolishRecordService.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺路线-抛光 库存变动表Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IWmPolishRecordService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class WmPolishRecordService : BaseService<WmPolishRecord>, IWmPolishRecordService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询工艺路线-抛光 库存变动表列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<WmPolishRecordDto> GetList(WmPolishRecordQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<WmPolishRecord>();
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<WmPolishRecord, WmPolishRecordDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public WmPolishRecord GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable().Where(x => x.Id == Id).First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加工艺路线-抛光 库存变动表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public WmPolishRecord AddWmPolishRecord(WmPolishRecord model)
|
||||
{
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改工艺路线-抛光 库存变动表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateWmPolishRecord(WmPolishRecord model)
|
||||
{
|
||||
//var response = Update(w => w.Id == model.Id, it => new WmPolishRecord()
|
||||
//{
|
||||
// Code = model.Code,
|
||||
// Partnumber = model.Partnumber,
|
||||
// BlankNum = model.BlankNum,
|
||||
// ChangeType = model.ChangeType,
|
||||
// ChangeQuantity = model.ChangeQuantity,
|
||||
// ActionTime = model.ActionTime,
|
||||
// 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