101 lines
3.8 KiB
C#
101 lines
3.8 KiB
C#
using DOAN.Repository;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices.JavaScript;
|
|
using DOAN.Model;
|
|
using DOAN.Model.MES.mm;
|
|
using DOAN.Model.MES.mm.Dto;
|
|
using DOAN.Service.MES.mm.IService;
|
|
using Infrastructure.Attribute;
|
|
using Mapster;
|
|
|
|
namespace DOAN.Service.MES.mm
|
|
{
|
|
/// <summary>
|
|
/// 线边库出入库日志Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IMmLinesidebarInventoryCheckService), ServiceLifetime = LifeTime.Transient)]
|
|
public class MmLinesidebarInventoryCheckServcie : BaseService<MmInventoryCheckLog>,
|
|
IMmLinesidebarInventoryCheckService
|
|
{
|
|
/// <summary>
|
|
/// 查询线边库库存列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<MmInventoryCheckLogDto> GetList(MmInventoryCheckLogQueryDto parm)
|
|
{
|
|
DateTime SearchDate = DateTime.Today;
|
|
// 1 查询这个日期 是否存在盘点记录 ,存在直接查询 ,不存在 ,先生成 再查询
|
|
|
|
bool isExist = Context.Queryable<MmInventoryCheckLog>()
|
|
.Where(it => it.CreatedTime > SearchDate && it.CreatedTime <= SearchDate.AddDays(1)).Any();
|
|
if (!isExist)
|
|
{
|
|
List<MmInventoryCheckLog> newMmInventoryCheckLogList = Context.Queryable<MmLinesidebarInventory>()
|
|
.Where(it => it.CreatedTime >= SearchDate)
|
|
.Where(it => it.CreatedTime <= SearchDate.AddDays(1)).ToList()
|
|
.Adapt<List<MmInventoryCheckLog>>();
|
|
|
|
if (newMmInventoryCheckLogList.Count() > 0)
|
|
{
|
|
foreach (var item in newMmInventoryCheckLogList)
|
|
{
|
|
item.Id = XueHua;
|
|
item.CreatedTime = DateTime.Now;
|
|
item.IsCorrecting = 0;
|
|
}
|
|
}
|
|
|
|
Context.Insertable(newMmInventoryCheckLogList).ExecuteCommand();
|
|
}
|
|
|
|
|
|
var predicate = Expressionable.Create<MmInventoryCheckLog>()
|
|
.AndIF(!string.IsNullOrEmpty(parm.LineCode), it => it.LineCode == parm.LineCode)
|
|
.AndIF(SearchDate > DateTime.MinValue,
|
|
it => it.CreatedTime >= SearchDate && it.CreatedTime <= SearchDate.AddDays(1))
|
|
;
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<MmInventoryCheckLog, MmInventoryCheckLogDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 校正
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool Correcting(string id)
|
|
{
|
|
bool result = false;
|
|
UseTran2(() =>
|
|
{
|
|
Context.Updateable<MmInventoryCheckLogDto>().Where(it => it.LineCode == id)
|
|
.SetColumns(it => it.IsCorrecting == 1)
|
|
.ExecuteCommand();
|
|
|
|
|
|
result = Context.Updateable<MmLinesidebarInventory>().Where(it =>
|
|
it.LineCode == SqlFunc.Subqueryable<MmInventoryCheckLogDto>().Where(it => it.Id == id)
|
|
.Select(it => it.LineCode))
|
|
.Where(it => it.MaterialCode == SqlFunc.Subqueryable<MmInventoryCheckLogDto>()
|
|
.Where(it => it.Id == id)
|
|
.Select(it => it.MaterialCode))
|
|
.SetColumns(it => it.LogicQuantity == SqlFunc.Subqueryable<MmInventoryCheckLogDto>()
|
|
.Where(it => it.Id == id).Select(it => it.ActualQuantity))
|
|
.ExecuteCommandHasChange();
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
public int UpdateMmInventoryCheckLog(MmInventoryCheckLog model)
|
|
{
|
|
return Update(model, true);
|
|
}
|
|
}
|
|
} |