仓库货物,出库记录查询调整

This commit is contained in:
赵正易 2024-06-28 15:21:25 +08:00
parent 9b63150b66
commit c7cd6ba42c
23 changed files with 335 additions and 317 deletions

View File

@ -1,11 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using ZR.Model.Dto;
using ZR.Service.mes.mm.IService;
using ZR.Service.mes.mm;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model.MES.mm.Dto;
using ZR.Model.MES.mm;
using ZR.Model.MES.mm.Dto;
using ZR.Service.mes.mm.IService;
//创建时间2024-06-05
namespace ZR.Admin.WebApi.Controllers

View File

@ -1,21 +1,7 @@
using Infrastructure.Extensions;
using JinianNet.JNTemplate;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text.Json;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.mes.pro;
using ZR.Model.MES.qc.DTO;
using Microsoft.AspNetCore.Mvc;
using ZR.Model.MES.ql;
using ZR.Model.MES.ql.DTO;
using ZR.Service.mes.pro;
using ZR.Service.mes.pro.IService;
using ZR.Service.mes.ql;
using ZR.Service.mes.ql.IService;
using ZR.Service.mes.qu.IService;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ZR.Admin.WebApi.Controllers.mes.ql
{

View File

@ -1,21 +1,7 @@
using Infrastructure.Extensions;
using JinianNet.JNTemplate;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text.Json;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.mes.pro;
using ZR.Model.MES.qc.DTO;
using Microsoft.AspNetCore.Mvc;
using ZR.Model.MES.ql;
using ZR.Model.MES.ql.DTO;
using ZR.Service.mes.pro;
using ZR.Service.mes.pro.IService;
using ZR.Service.mes.ql;
using ZR.Service.mes.ql.IService;
using ZR.Service.mes.qu.IService;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ZR.Admin.WebApi.Controllers.mes.ql
{

View File

@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.ql.DTO
namespace ZR.Model.MES.ql.DTO
{
/// <summary>
/// 当前工单

View File

@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.ql.DTO
namespace ZR.Model.MES.ql.DTO
{
/// <summary>
/// 当前工单

View File

@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.ql.DTO
namespace ZR.Model.MES.ql.DTO
{
/// <summary>
/// 当前工单

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.ql
namespace ZR.Model.MES.ql
{
/// <summary>

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.ql
namespace ZR.Model.MES.ql
{
/// <summary>

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.ql
namespace ZR.Model.MES.ql
{
/// <summary>

View File

@ -7,24 +7,25 @@ namespace ZR.Model.MES.wms.Dto
{
public string Id { get; set; }
public string PackageCode { get; set; }
public string PackageCodeClient { get; set; }
public string PackageCodeOriginal { get; set; }
public string LocationCode { get; set; }
public string Partnumber { get; set; }
public string Description { get; set; }
public int? GoodsNumLogic { get; set; }
public int? GoodsNumAction { get; set; }
public DateTime? EntryWarehouseTime { get; set; }
public DateTime? EntryWarehouseTimeStart { get; set; }
public DateTime? EntryWarehouseTimeEnd { get; set; }
public string Remark { get; set; }
@ -42,21 +43,18 @@ namespace ZR.Model.MES.wms.Dto
/// </summary>
public class WmGoodsNowProductionDto
{
public string Id { get; set; }
public string PackageCode { get; set; }
public string PackageCodeClient { get; set; }
public string PackageCodeOriginal { get; set; }
public string LocationCode { get; set; }
public string Partnumber { get; set; }
public string Description { get; set; }
public int? GoodsNumLogic { get; set; }
@ -76,7 +74,6 @@ namespace ZR.Model.MES.wms.Dto
public DateTime? CreatedTime { get; set; }
}
/// <summary>
/// 成品库当前货物表查询对象(下拉菜单)
/// </summary>
@ -93,34 +90,42 @@ namespace ZR.Model.MES.wms.Dto
/// 成品库货物id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 批次号(MES中)
/// </summary>
public string PackageCodeClient { get; set; } = string.Empty;
/// <summary>
/// 库位号
/// </summary>
public string LocationCode { get; set; } = string.Empty;
/// <summary>
/// 零件号
/// </summary>
public string Partnumber { get; set; } = string.Empty;
/// <summary>
/// 详细描述
/// </summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// 入库时库存
/// </summary>
public int? GoodsNumLogic { get; set; } = 0;
/// <summary>
/// 当前实际库存!
/// </summary>
public int? GoodsNumAction { get; set; } = 0;
/// <summary>
/// 下拉显示值
/// </summary>
public string Label { get; set; } = string.Empty;
/// <summary>
/// 下拉实际值
/// </summary>

View File

@ -32,6 +32,8 @@ namespace ZR.Model.MES.wms.Dto
public DateTime? EntryWarehouseTime { get; set; }
public DateTime? OutTime { get; set; }
public DateTime? OutTimeStart { get; set; }
public DateTime? OutTimeEnd { get; set; }
public string Remark { get; set; }

View File

@ -1,9 +1,6 @@
using System;
using ZR.Model;
using ZR.Model.Dto;
using ZR.Model.MES.mm;
using ZR.Model.MES.mm.Dto;
using System.Collections.Generic;
namespace ZR.Service.mes.mm.IService
{

View File

@ -1,14 +1,11 @@
using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using SqlSugar;
using System;
using ZR.Model;
using ZR.Repository;
using ZR.Model.MES.mm;
using ZR.Service.mes.mm.IService;
using System.Linq;
using ZR.Model.MES.mm.Dto;
using ZR.Repository;
using ZR.Service.mes.mm.IService;
namespace ZR.Service.mes.mm
{

View File

@ -5,7 +5,6 @@ using ZR.Model.MES.op.DTO;
using ZR.Model.MES.op.ZR.Model.mes.md;
using ZR.Model.MES.pro;
using ZR.Model.MES.qc;
using ZR.Model.MES.qc.DTO;
using ZR.Model.MES.qu;
using ZR.Service.MES.op.IService;

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.ql;

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.qc;
using ZR.Model.MES.ql;

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.ql;

View File

@ -1,15 +1,6 @@
using Infrastructure.Attribute;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.ql;
using ZR.Service.mes.ql.IService;

View File

@ -1,16 +1,6 @@
using Infrastructure.Attribute;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.qc;
using ZR.Model.MES.ql;
using ZR.Service.mes.ql.IService;

View File

@ -1,15 +1,6 @@
using Infrastructure.Attribute;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.ql;
using ZR.Service.mes.ql.IService;

View File

@ -1,7 +1,7 @@
using Infrastructure.Attribute;
using SqlSugar;
using System;
using System.Linq;
using Infrastructure.Attribute;
using SqlSugar;
using ZR.Model;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
@ -13,8 +13,13 @@ namespace ZR.Service.mes.wms
/// <summary>
/// 成品库当前货物表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmGoodsNowProductionService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsNowProductionService : BaseService<WmGoodsNowProduction>, IWmGoodsNowProductionService
[AppService(
ServiceType = typeof(IWmGoodsNowProductionService),
ServiceLifetime = LifeTime.Transient
)]
public class WmGoodsNowProductionService
: BaseService<WmGoodsNowProduction>,
IWmGoodsNowProductionService
{
/// <summary>
/// 查询成品库当前货物表列表
@ -23,20 +28,55 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public PagedInfo<WmGoodsNowProductionDto> GetList(WmGoodsNowProductionQueryDto parm)
{
var predicate = Expressionable.Create<WmGoodsNowProduction>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
.AndIF(!string.IsNullOrEmpty(parm.PackageCodeClient), it => it.PackageCodeClient.Contains(parm.PackageCodeClient))
.AndIF(!string.IsNullOrEmpty(parm.LocationCode), it => it.LocationCode.Contains(parm.LocationCode))
;
var response = Queryable()
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<WmGoodsNowProduction>()
.AndIF(
partnumberByDescription.Count > 0,
it => partnumberByDescription.Contains(it.Partnumber)
)
.AndIF(
!string.IsNullOrEmpty(parm.Partnumber),
it => it.Partnumber.Contains(parm.Partnumber)
)
.AndIF(
!string.IsNullOrEmpty(parm.PackageCodeClient),
it => it.PackageCodeClient.Contains(parm.PackageCodeClient)
)
.AndIF(
parm.EntryWarehouseTimeStart != null,
it => it.EntryWarehouseTime > parm.EntryWarehouseTimeStart
)
.AndIF(
parm.EntryWarehouseTimeEnd != null,
it => it.EntryWarehouseTime < parm.EntryWarehouseTimeEnd
)
.AndIF(
!string.IsNullOrEmpty(parm.PackageCodeClient),
it => it.PackageCodeClient.Contains(parm.PackageCodeClient)
)
.AndIF(
!string.IsNullOrEmpty(parm.LocationCode),
it => it.LocationCode.Contains(parm.LocationCode)
);
var response = Context
.Queryable<WmGoodsNowProduction>()
.Where(predicate.ToExpression())
.OrderByDescending(x => x.EntryWarehouseTime)
.ToPage<WmGoodsNowProduction, WmGoodsNowProductionDto>(parm);
foreach (WmGoodsNowProductionDto item in response.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
WmMaterial material = Context
.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
if (material == null)
@ -44,12 +84,13 @@ namespace ZR.Service.mes.wms
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
item.Description = !string.IsNullOrEmpty(material.Description)
? material.Description
: material.ProductName;
}
return response;
}
/// <summary>
/// 批量查看
/// </summary>
@ -60,16 +101,26 @@ namespace ZR.Service.mes.wms
{
List<WmGoods_nodeDto> list = null;
int total = 0;
var predicate = Expressionable.Create<WmGoodsNowProduction>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
.AndIF(!string.IsNullOrEmpty(parm.PackageCodeClient), it => it.PackageCodeClient.Contains(parm.PackageCodeClient));
var predicate = Expressionable
.Create<WmGoodsNowProduction>()
.AndIF(
!string.IsNullOrEmpty(parm.Partnumber),
it => it.Partnumber.Contains(parm.Partnumber)
)
.AndIF(
!string.IsNullOrEmpty(parm.PackageCodeClient),
it => it.PackageCodeClient.Contains(parm.PackageCodeClient)
);
List<WmGoodsNowProduction> rawdatas = Queryable().Where(predicate.ToExpression()).ToPageList(parm.PageNum, parm.PageSize, ref total);
List<WmGoodsNowProduction> rawdatas = Queryable()
.Where(predicate.ToExpression())
.ToPageList(parm.PageNum, parm.PageSize, ref total);
if (rawdatas != null && rawdatas.Count > 0)
{
//todo 对字段进行拆分
List<WmGoods_nodeDto> WmGoods_nodeDto_list = rawdatas.Select(p => new WmGoods_nodeDto()
List<WmGoods_nodeDto> WmGoods_nodeDto_list = rawdatas
.Select(p => new WmGoods_nodeDto()
{
Id = p.Id,
PackageCode = p.PackageCode,
@ -83,11 +134,12 @@ namespace ZR.Service.mes.wms
GoodsNumAction = p.GoodsNumAction,
EntryWarehouseTime = p.EntryWarehouseTime,
Remark = p.Remark,
}).ToList();
})
.ToList();
//todo 分组 聚合 生成父节点
List<WmGoods_nodeDto> WmGoods_nodeDto_list_parent = WmGoods_nodeDto_list.GroupBy(p => p.PackageCodeClient_short_parent)
List<WmGoods_nodeDto> WmGoods_nodeDto_list_parent = WmGoods_nodeDto_list
.GroupBy(p => p.PackageCodeClient_short_parent)
.Select(group => new WmGoods_nodeDto()
{
PackageCodeClient_short_parent = "",
@ -96,16 +148,16 @@ namespace ZR.Service.mes.wms
GoodsNumAction = group.Sum(group => group.GoodsNumAction),
Partnumber = group.Max(group => group.Partnumber),
Pack_num = group.Count()
}).ToList();
})
.ToList();
//todo 合并
list = WmGoods_nodeDto_list.Concat(WmGoods_nodeDto_list_parent).ToList();
}
return (list, total);
}
/// <summary>
/// 移动端 货物查看 根据Query零件号与批次号查看信息
/// </summary>
@ -116,16 +168,22 @@ namespace ZR.Service.mes.wms
// 结果集
List<WmGoodShortPackageCodeDto> resultList = new();
// 全数据处理
var predicate = Expressionable.Create<WmGoodsNowProduction>()
var predicate = Expressionable
.Create<WmGoodsNowProduction>()
.OrIF(!string.IsNullOrEmpty(parm.Query), it => it.Partnumber.Contains(parm.Query))
.OrIF(!string.IsNullOrEmpty(parm.Query), it => it.PackageCodeClient.Contains(parm.Query));
List<WmGoodsNowProduction> wmGoodsNowsList = Context.Queryable<WmGoodsNowProduction>()
.OrIF(
!string.IsNullOrEmpty(parm.Query),
it => it.PackageCodeClient.Contains(parm.Query)
);
List<WmGoodsNowProduction> wmGoodsNowsList = Context
.Queryable<WmGoodsNowProduction>()
.Where(predicate.ToExpression())
.OrderByDescending(it => it.PackageCodeClient)
.ToList();
// 聚合数据
resultList = wmGoodsNowsList.GroupBy(it => it.PackageCodeClient.Split('_')[0])
resultList = wmGoodsNowsList
.GroupBy(it => it.PackageCodeClient.Split('_')[0])
.Select(group => new WmGoodShortPackageCodeDto
{
ShortPackageCode = group.Key,
@ -133,7 +191,8 @@ namespace ZR.Service.mes.wms
EntryWarehouseTime = group.Max(item => item.EntryWarehouseTime),
PackageNumber = group.Count(),
PartnumberNumber = group.Sum(item => item.GoodsNumAction)
}).ToList();
})
.ToList();
// 结果数据处理
//每页多少条
int rows = parm.PageSize;
@ -153,6 +212,7 @@ namespace ZR.Service.mes.wms
}
return resultList;
}
/// <summary>
/// 移动端 短批次号详情
/// </summary>
@ -160,8 +220,12 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public List<WmGoodsNowProductionDto> Patchsearchdetail(WmGoodsNowProductionQueryDto parm)
{
var predicate = Expressionable.Create<WmGoodsNowProduction>()
.AndIF(!string.IsNullOrEmpty(parm.PackageCodeClient), it => it.PackageCodeClient.Contains(parm.PackageCodeClient));
var predicate = Expressionable
.Create<WmGoodsNowProduction>()
.AndIF(
!string.IsNullOrEmpty(parm.PackageCodeClient),
it => it.PackageCodeClient.Contains(parm.PackageCodeClient)
);
var response = Queryable()
.Where(predicate.ToExpression())
@ -178,7 +242,8 @@ namespace ZR.Service.mes.wms
.ToList();
foreach (WmGoodsNowProductionDto item in response)
{
WmMaterial material = Context.Queryable<WmMaterial>()
WmMaterial material = Context
.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
if (material == null)
@ -186,13 +251,13 @@ namespace ZR.Service.mes.wms
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
item.Description = !string.IsNullOrEmpty(material.Description)
? material.Description
: material.ProductName;
}
return response;
}
/// <summary>
/// 获取详情
/// </summary>
@ -200,9 +265,7 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public WmGoodsNowProduction GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
var response = Queryable().Where(x => x.Id == Id).First();
return response;
}
@ -226,7 +289,8 @@ namespace ZR.Service.mes.wms
{
model.PackageCodeOriginal = model.PackageCodeClient;
}
bool hasRecord = Context.Queryable<WmGoodsNowProduction>()
bool hasRecord = Context
.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient == model.PackageCodeClient)
.Any();
if (hasRecord)
@ -271,14 +335,17 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public int ModifyInventoryQuantity(string id, int stack_num)
{
return Context.Updateable<WmGoodsNowProduction>()
return Context
.Updateable<WmGoodsNowProduction>()
.SetColumns(it => it.GoodsNumAction == stack_num)
.Where(it => it.Id == id).ExecuteCommand();
.Where(it => it.Id == id)
.ExecuteCommand();
}
public PagedInfo<WmGoodsNowProductionDictDto> GetDictData(WmGoodsNowProductionDictDto parm)
{
var predicate = Expressionable.Create<WmGoodsNowProduction>()
var predicate = Expressionable
.Create<WmGoodsNowProduction>()
.AndIF(!string.IsNullOrEmpty(parm.Query), it => it.Partnumber.Contains(parm.Query))
.Or(it => it.PackageCodeClient.Contains(parm.Query))
// .Or(it => it.LocationCode.Contains(parm.Query))
@ -301,7 +368,8 @@ namespace ZR.Service.mes.wms
foreach (WmGoodsNowProductionDictDto item in response.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
WmMaterial material = Context
.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
if (material == null)
@ -310,9 +378,17 @@ namespace ZR.Service.mes.wms
}
else
{
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
item.Description = !string.IsNullOrEmpty(material.Description)
? material.Description
: material.ProductName;
}
string label = "批次号:" + item.PackageCodeClient + " 零件号:" + item.Partnumber + " 描述:" + item.Description;
string label =
"批次号:"
+ item.PackageCodeClient
+ " 零件号:"
+ item.Partnumber
+ " 描述:"
+ item.Description;
var value = new
{
Id = item.Id,
@ -325,12 +401,8 @@ namespace ZR.Service.mes.wms
};
item.Value = value;
item.Label = label;
}
return response;
}
}
}

View File

@ -1,6 +1,6 @@
using System;
using Infrastructure.Attribute;
using SqlSugar;
using System;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms.IService;
@ -10,8 +10,13 @@ namespace ZR.Service.mes.wms
/// <summary>
/// 出库货物记录表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmGoodsOutProductionService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsOutProductionService : BaseService<WmGoodsOutRecord>, IWmGoodsOutProductionService
[AppService(
ServiceType = typeof(IWmGoodsOutProductionService),
ServiceLifetime = LifeTime.Transient
)]
public class WmGoodsOutProductionService
: BaseService<WmGoodsOutRecord>,
IWmGoodsOutProductionService
{
/// <summary>
/// 查询出库货物记录表列表
@ -21,24 +26,55 @@ namespace ZR.Service.mes.wms
public (List<WmGoodsOutProductionDto>, int) GetList(WmGoodsOutProductionQueryDto parm)
{
int total = 0;
var predicate = Expressionable.Create<WmGoodsOutRecord>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), wgo => wgo.Partnumber.Contains(parm.Partnumber))
.AndIF(!string.IsNullOrEmpty(parm.PackageCodeClient), wgo => wgo.PackageCodeClient.Contains(parm.PackageCodeClient))
.AndIF(!string.IsNullOrEmpty(parm.LocationCode), wgo => wgo.LocationCode.Contains(parm.LocationCode))
.AndIF(!string.IsNullOrEmpty(parm.FkOutOrderId), wgo => wgo.FkOutOrderId.Contains(parm.FkOutOrderId))
;
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<WmGoodsOutRecord>()
.AndIF(
!string.IsNullOrEmpty(parm.Partnumber),
wgo => wgo.Partnumber.Contains(parm.Partnumber)
)
.AndIF(
partnumberByDescription.Count > 0,
wgo => partnumberByDescription.Contains(wgo.Partnumber)
)
.AndIF(
!string.IsNullOrEmpty(parm.PackageCodeClient),
wgo => wgo.PackageCodeClient.Contains(parm.PackageCodeClient)
)
.AndIF(
!string.IsNullOrEmpty(parm.LocationCode),
wgo => wgo.LocationCode.Contains(parm.LocationCode)
)
.AndIF(parm.OutTimeStart != null, wgo => wgo.OutTime > parm.OutTimeStart)
.AndIF(parm.OutTimeEnd != null, wgo => wgo.OutTime < parm.OutTimeEnd)
.AndIF(
!string.IsNullOrEmpty(parm.FkOutOrderId),
wgo => wgo.FkOutOrderId.Contains(parm.FkOutOrderId)
);
//TODO 添加了Distinct去重
var response = Queryable()
.LeftJoin<WmMaterial>((wgo, wml) => wgo.Partnumber == wml.Partnumber)
.Where(predicate.ToExpression())
.Select((wgo, wml) => new WmGoodsOutProductionDto { Description = wml.Description }, true)
.Select(
(wgo, wml) => new WmGoodsOutProductionDto { Description = wml.Description },
true
)
.MergeTable()
.Distinct()
.OrderBy(wml => wml.OutTime, OrderByType.Desc)
.ToPageList(parm.PageNum, parm.PageSize, ref total);
return (response, total);
}
/// <summary>
/// 获取详情
/// </summary>
@ -46,9 +82,7 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public WmGoodsOutRecord GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
var response = Queryable().Where(x => x.Id == Id).First();
return response;
}
@ -61,8 +95,10 @@ namespace ZR.Service.mes.wms
public WmGoodsOutRecord AddWmGoodsOutProduction(WmGoodsOutRecord model)
{
// 检查成品库数据是否存在
bool hasRecord = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Id == model.FkNowProductionId).Any();
bool hasRecord = Context
.Queryable<WmGoodsNowProduction>()
.Where(it => it.Id == model.FkNowProductionId)
.Any();
if (!hasRecord)
{
throw new Exception("请检查该箱是否已完全出库,或已添加出库记录!");
@ -86,11 +122,17 @@ namespace ZR.Service.mes.wms
}
if (updateModel.GoodsNumAction == 0)
{
Context.Deleteable<WmGoodsNowProduction>().Where(it => it.Id == updateModel.Id).ExecuteCommand();
Context
.Deleteable<WmGoodsNowProduction>()
.Where(it => it.Id == updateModel.Id)
.ExecuteCommand();
}
else
{
Context.Updateable(updateModel).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
Context
.Updateable(updateModel)
.IgnoreColumns(ignoreAllNullColumns: true)
.ExecuteCommand();
}
return Context.Insertable(model).ExecuteReturnEntity();
}
@ -132,13 +174,16 @@ namespace ZR.Service.mes.wms
var list = parm.Ids;
for (int i = 0; i < list.Count; i++)
{
WmGoodsNowProduction nowProduction = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Id == list[i]).First();
WmGoodsNowProduction nowProduction = Context
.Queryable<WmGoodsNowProduction>()
.Where(it => it.Id == list[i])
.First();
if (nowProduction == null)
{
continue;
}
WmGoodsOutRecord outRecord = new()
WmGoodsOutRecord outRecord =
new()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
FkNowProductionId = nowProduction.Id,
@ -157,7 +202,10 @@ namespace ZR.Service.mes.wms
CreatedTime = time,
};
Context.Insertable(outRecord).ExecuteCommand();
Context.Deleteable<WmGoodsNowProduction>().Where(it => it.Id == nowProduction.Id).ExecuteCommand();
Context
.Deleteable<WmGoodsNowProduction>()
.Where(it => it.Id == nowProduction.Id)
.ExecuteCommand();
}
}
else if (type == 2)
@ -172,17 +220,22 @@ namespace ZR.Service.mes.wms
{
return "请输入至少8位批次号编码以保证正确批次出库";
}
List<WmGoodsNowProduction> nowProductionList = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient.Contains(shortPackageCode)).ToList();
List<WmGoodsNowProduction> nowProductionList = Context
.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient.Contains(shortPackageCode))
.ToList();
for (int i = 0; i < nowProductionList.Count; i++)
{
WmGoodsNowProduction nowProduction = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Id == nowProductionList[i].Id).First();
WmGoodsNowProduction nowProduction = Context
.Queryable<WmGoodsNowProduction>()
.Where(it => it.Id == nowProductionList[i].Id)
.First();
if (nowProduction == null)
{
continue;
}
WmGoodsOutRecord outRecord = new()
WmGoodsOutRecord outRecord =
new()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
FkNowProductionId = nowProduction.Id,
@ -201,7 +254,10 @@ namespace ZR.Service.mes.wms
CreatedTime = time,
};
Context.Insertable(outRecord).ExecuteCommand();
Context.Deleteable<WmGoodsNowProduction>().Where(it => it.Id == nowProduction.Id).ExecuteCommand();
Context
.Deleteable<WmGoodsNowProduction>()
.Where(it => it.Id == nowProduction.Id)
.ExecuteCommand();
}
}
return "ok";