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

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
@ -51,7 +49,7 @@ namespace ZR.Admin.WebApi.Controllers
public IActionResult GetMmIngredientTask(int Id)
{
var response = _MmIngredientTaskService.GetInfo(Id);
var info = response.Adapt<MmIngredientTask>();
return SUCCESS(info);
}

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

@ -5,12 +5,12 @@ namespace ZR.Model.MES.mm.Dto
/// <summary>
/// 配料任务清单查询对象
/// </summary>
public class MmIngredientTaskQueryDto : PagerInfo
public class MmIngredientTaskQueryDto : PagerInfo
{
public string Workorder { get; set; }
public string Workorder { get; set; }
public DateTime Starttime { get; set; }
public DateTime Endtime { get; set; }
public DateTime Starttime { get; set; }
public DateTime Endtime { get; set; }
}

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,37 +90,45 @@ 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>
public object Value { get; set; }
}
}
}

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
{
@ -26,12 +23,12 @@ namespace ZR.Service.mes.mm
public PagedInfo<MmIngredientTaskDto> GetList(MmIngredientTaskQueryDto parm)
{
var predicate = Expressionable.Create<MmIngredientTask>()
.AndIF(parm.Starttime!=null&&parm.Starttime>new DateTime(1899,1,1),it=>it.CreatedTime>=parm.Starttime)
.AndIF(parm.Endtime!=null&&parm.Starttime>new DateTime(1899,1,1),it=>it.CreatedTime<=parm.Endtime)
.AndIF(!string.IsNullOrEmpty(parm.Workorder),it=>it.Workorder.Contains(parm.Workorder));
.AndIF(parm.Starttime != null && parm.Starttime > new DateTime(1899, 1, 1), it => it.CreatedTime >= parm.Starttime)
.AndIF(parm.Endtime != null && parm.Starttime > new DateTime(1899, 1, 1), it => it.CreatedTime <= parm.Endtime)
.AndIF(!string.IsNullOrEmpty(parm.Workorder), it => it.Workorder.Contains(parm.Workorder));
var response = Queryable()
.OrderByDescending(it=>it.CreatedTime)
.OrderByDescending(it => it.CreatedTime)
.Where(predicate.ToExpression())
.ToPage<MmIngredientTask, MmIngredientTaskDto>(parm);

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;
@ -11,7 +7,7 @@ namespace ZR.Service.mes.ql.IService
public interface IPLBatchService
{
public (List<PLBatch>, int) GetPLBatchTable(DateTime starttime, DateTime endTime, string code,int pageNum, int pageSize);
public (List<PLBatch>, int) GetPLBatchTable(DateTime starttime, DateTime endTime, string code, int pageNum, int pageSize);
public int AddPLBatchRecords(int num, int size);

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;
@ -12,9 +7,9 @@ namespace ZR.Service.mes.ql.IService
public interface IPLRawMaterialService
{
public (List<PLRawMaterial>, int) GetRawMaterialTable(DateTime starttime, DateTime endTime,string pci, string colorCode,int pageNum, int pageSize);
public (List<PLRawMaterial>, int) GetRawMaterialTable(DateTime starttime, DateTime endTime, string pci, string colorCode, int pageNum, int pageSize);
public int AddRawMaterialRecords(int num,int size);
public int AddRawMaterialRecords(int num, int size);
public int DelRawMaterialRecords(string idGroup);

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;
@ -11,7 +7,7 @@ namespace ZR.Service.mes.ql.IService
public interface IPLTestService
{
public (List<PLTest>, int) GetPLTestTable(DateTime starttime, DateTime endTime, string code,int pageNum, int pageSize);
public (List<PLTest>, int) GetPLTestTable(DateTime starttime, DateTime endTime, string code, int pageNum, int pageSize);
public int AddPLTestRecords(int num, int size);

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;
@ -75,7 +66,7 @@ namespace ZR.Service.mes.ql
/// <param name="pageSize"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public (List<PLBatch>, int) GetPLBatchTable(DateTime starttime, DateTime endTime,string code, int pageNum, int pageSize)
public (List<PLBatch>, int) GetPLBatchTable(DateTime starttime, DateTime endTime, string code, int pageNum, int pageSize)
{
starttime = starttime.ToLocalTime();
endTime = endTime.ToLocalTime();
@ -89,7 +80,7 @@ namespace ZR.Service.mes.ql
//int totalNum = 0;
List<PLBatch> data = Context.Queryable<PLBatch>()
.Where(predicate)
.OrderByDescending(it=>it.IdGroup)
.OrderByDescending(it => it.IdGroup)
.OrderBy(it => it.Id)
.ToPageList(pageNum, pageSize, ref totalNum);
return (data, totalNum);

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;
@ -122,10 +112,10 @@ namespace ZR.Service.mes.ql
return new PLRawMaterial()
{
Id = 0,
IdGroup=DateTime.Now.ToString("yyyyMMddHHmmssfff"),
Code="",
Pci="",
Value01="",
IdGroup = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
Code = "",
Pci = "",
Value01 = "",
Value02 = "",
Value03 = "",
Value04 = "",
@ -136,10 +126,10 @@ namespace ZR.Service.mes.ql
Value09 = "",
Value10 = "",
Value11 = "",
CreatedBy="user",
CreatedTime=DateTime.Now,
UpdatedBy="user",
UpdatedTime=DateTime.Now,
CreatedBy = "user",
CreatedTime = DateTime.Now,
UpdatedBy = "user",
UpdatedTime = DateTime.Now,
};
}
}

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;
@ -75,7 +66,7 @@ namespace ZR.Service.mes.ql
/// <param name="pageSize"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public (List<PLTest>, int) GetPLTestTable(DateTime starttime, DateTime endTime, string code,int pageNum, int pageSize)
public (List<PLTest>, int) GetPLTestTable(DateTime starttime, DateTime endTime, string code, int pageNum, int pageSize)
{
starttime = starttime.ToLocalTime();
endTime = endTime.ToLocalTime();

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,33 +28,69 @@ 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>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
WmMaterial material = Context
.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
if (material == null)
{
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,52 +101,63 @@ 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()
{
Id = p.Id,
PackageCode = p.PackageCode,
PackageCodeClient_short_parent = p.PackageCodeClient.Split("_")[0],
PackageCodeClient_son = p.PackageCodeClient,
PackageCodeOriginal = p.PackageCodeClient,
LocationCode = p.LocationCode,
Partnumber = p.Partnumber,
Pack_num = 1,
GoodsNumLogic = p.GoodsNumLogic,
GoodsNumAction = p.GoodsNumAction,
EntryWarehouseTime = p.EntryWarehouseTime,
Remark = p.Remark,
}).ToList();
List<WmGoods_nodeDto> WmGoods_nodeDto_list = rawdatas
.Select(p => new WmGoods_nodeDto()
{
Id = p.Id,
PackageCode = p.PackageCode,
PackageCodeClient_short_parent = p.PackageCodeClient.Split("_")[0],
PackageCodeClient_son = p.PackageCodeClient,
PackageCodeOriginal = p.PackageCodeClient,
LocationCode = p.LocationCode,
Partnumber = p.Partnumber,
Pack_num = 1,
GoodsNumLogic = p.GoodsNumLogic,
GoodsNumAction = p.GoodsNumAction,
EntryWarehouseTime = p.EntryWarehouseTime,
Remark = p.Remark,
})
.ToList();
//todo 分组 聚合 生成父节点
List<WmGoods_nodeDto> WmGoods_nodeDto_list_parent = WmGoods_nodeDto_list.GroupBy(p => p.PackageCodeClient_short_parent)
.Select(group => new WmGoods_nodeDto()
{
PackageCodeClient_short_parent = "",
PackageCodeClient_son = group.Key,
GoodsNumLogic = group.Sum(group => group.GoodsNumLogic),
GoodsNumAction = group.Sum(group => group.GoodsNumAction),
Partnumber = group.Max(group => group.Partnumber),
Pack_num = group.Count()
}).ToList();
List<WmGoods_nodeDto> WmGoods_nodeDto_list_parent = WmGoods_nodeDto_list
.GroupBy(p => p.PackageCodeClient_short_parent)
.Select(group => new WmGoods_nodeDto()
{
PackageCodeClient_short_parent = "",
PackageCodeClient_son = group.Key,
GoodsNumLogic = group.Sum(group => group.GoodsNumLogic),
GoodsNumAction = group.Sum(group => group.GoodsNumAction),
Partnumber = group.Max(group => group.Partnumber),
Pack_num = group.Count()
})
.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>()
.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>()
.Where(predicate.ToExpression())
.OrderByDescending(it => it.PackageCodeClient)
.ToList();
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>()
.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;
@ -141,7 +200,7 @@ namespace ZR.Service.mes.wms
int page = parm.PageNum;
//每一页开始下标
int startIndex = (page - 1) * rows;
//数据总数
//数据总数
int sum = resultList.Count;
if (startIndex + rows > sum)
{
@ -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,21 +242,22 @@ namespace ZR.Service.mes.wms
.ToList();
foreach (WmGoodsNowProductionDto item in response)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
WmMaterial material = Context
.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
if (material == null)
{
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;
}
@ -216,7 +279,7 @@ namespace ZR.Service.mes.wms
{
if (string.IsNullOrEmpty(model.Id))
{
model.Id = SnowFlakeSingle.Instance.NextId().ToString();//也可以在程序中直接获取ID
model.Id = SnowFlakeSingle.Instance.NextId().ToString(); //也可以在程序中直接获取ID
}
if (string.IsNullOrEmpty(model.PackageCode))
{
@ -226,9 +289,10 @@ namespace ZR.Service.mes.wms
{
model.PackageCodeOriginal = model.PackageCodeClient;
}
bool hasRecord = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient == model.PackageCodeClient)
.Any();
bool hasRecord = Context
.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient == model.PackageCodeClient)
.Any();
if (hasRecord)
{
throw new Exception("成品仓库已有相同批次号记录");
@ -271,18 +335,21 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public int ModifyInventoryQuantity(string id, int stack_num)
{
return Context.Updateable<WmGoodsNowProduction>()
.SetColumns(it => it.GoodsNumAction == stack_num)
.Where(it => it.Id == id).ExecuteCommand();
return Context
.Updateable<WmGoodsNowProduction>()
.SetColumns(it => it.GoodsNumAction == stack_num)
.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))
;
// .Or(it => it.LocationCode.Contains(parm.Query))
;
var response = Queryable()
.Where(predicate.ToExpression())
@ -301,18 +368,27 @@ namespace ZR.Service.mes.wms
foreach (WmGoodsNowProductionDictDto item in response.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
WmMaterial material = Context
.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
}
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("请检查该箱是否已完全出库,或已添加出库记录!");
@ -73,7 +109,7 @@ namespace ZR.Service.mes.wms
}
if (string.IsNullOrEmpty(model.Id))
{
model.Id = SnowFlakeSingle.Instance.NextId().ToString();//也可以在程序中直接获取ID
model.Id = SnowFlakeSingle.Instance.NextId().ToString(); //也可以在程序中直接获取ID
}
//2. 根据成品仓库id修改记录
@ -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,32 +174,38 @@ 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()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
FkNowProductionId = nowProduction.Id,
FkOutOrderId = parm.FkOutOrderId,
PackageCode = nowProduction.PackageCode,
PackageCodeClient = nowProduction.PackageCodeClient,
PackageCodeOriginal = nowProduction.PackageCodeOriginal,
LocationCode = nowProduction.LocationCode,
Partnumber = nowProduction.Partnumber,
GoodsNumAction = nowProduction.GoodsNumAction,
GoodsNumLogic = nowProduction.GoodsNumAction,
EntryWarehouseTime = nowProduction.EntryWarehouseTime,
OutTime = time,
Remark = "批量出库",
CreatedBy = parm.CreatedBy ?? "batch",
CreatedTime = time,
};
WmGoodsOutRecord outRecord =
new()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
FkNowProductionId = nowProduction.Id,
FkOutOrderId = parm.FkOutOrderId,
PackageCode = nowProduction.PackageCode,
PackageCodeClient = nowProduction.PackageCodeClient,
PackageCodeOriginal = nowProduction.PackageCodeOriginal,
LocationCode = nowProduction.LocationCode,
Partnumber = nowProduction.Partnumber,
GoodsNumAction = nowProduction.GoodsNumAction,
GoodsNumLogic = nowProduction.GoodsNumAction,
EntryWarehouseTime = nowProduction.EntryWarehouseTime,
OutTime = time,
Remark = "批量出库",
CreatedBy = parm.CreatedBy ?? "batch",
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,39 +220,47 @@ 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()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
FkNowProductionId = nowProduction.Id,
FkOutOrderId = parm.FkOutOrderId,
PackageCode = nowProduction.PackageCode,
PackageCodeClient = nowProduction.PackageCodeClient,
PackageCodeOriginal = nowProduction.PackageCodeOriginal,
LocationCode = nowProduction.LocationCode,
Partnumber = nowProduction.Partnumber,
GoodsNumAction = nowProduction.GoodsNumAction,
GoodsNumLogic = nowProduction.GoodsNumAction,
EntryWarehouseTime = nowProduction.EntryWarehouseTime,
OutTime = time,
Remark = "批量出库",
CreatedBy = parm.CreatedBy ?? "batch",
CreatedTime = time,
};
WmGoodsOutRecord outRecord =
new()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
FkNowProductionId = nowProduction.Id,
FkOutOrderId = parm.FkOutOrderId,
PackageCode = nowProduction.PackageCode,
PackageCodeClient = nowProduction.PackageCodeClient,
PackageCodeOriginal = nowProduction.PackageCodeOriginal,
LocationCode = nowProduction.LocationCode,
Partnumber = nowProduction.Partnumber,
GoodsNumAction = nowProduction.GoodsNumAction,
GoodsNumLogic = nowProduction.GoodsNumAction,
EntryWarehouseTime = nowProduction.EntryWarehouseTime,
OutTime = time,
Remark = "批量出库",
CreatedBy = parm.CreatedBy ?? "batch",
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";
}
}
}
}