This commit is contained in:
2024-10-25 19:01:06 +08:00
parent 0f3232d32b
commit 58994f4d7a
14 changed files with 414 additions and 10 deletions

View File

@@ -11,6 +11,13 @@ namespace ZR.Service.mes.wms.IService
{
PagedInfo<WmOneTimeInventoryDto> GetList(WmOneTimeInventoryQueryDto parm);
/// <summary>
/// 一次合格导出
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
List<WmOneTimeInventoryExportDto> GetExportList(WmOneTimeInventoryQueryDto parm);
WmOneTimeInventory GetInfo(string Id);
WmOneTimeInventory AddWmOneTimeInventory(WmOneTimeInventory parm);

View File

@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using ZR.Model;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
@@ -11,6 +12,13 @@ namespace ZR.Service.mes.wms.IService
{
PagedInfo<WmPolishInventoryDto> GetList(WmPolishInventoryQueryDto parm);
/// <summary>
/// 获取导出数据
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
List<WmPolishInventoryExportDto> GetExportList(WmPolishInventoryQueryDto parm);
WmPolishInventory GetInfo(string Id);
WmPolishInventory AddWmPolishInventory(WmPolishInventory parm);

View File

@@ -328,6 +328,7 @@ namespace ZR.Service.mes.wms
.First();
if (workOrderInfo == null)
{
Context.Ado.RollbackTran();
throw new Exception("工单记录不存在!" + workOrderId);
}
if (workOrderInfo.Remark1.Contains("返工"))
@@ -343,6 +344,7 @@ namespace ZR.Service.mes.wms
.First();
if (blankInventory == null)
{
Context.Ado.RollbackTran();
throw new Exception("毛坯记录不存在!请检查毛坯仓库,毛坯号:" + workOrderInfo.BlankNumber);
}
WmBlankInventory updateInfo =

View File

@@ -1,10 +1,12 @@
using System;
using System.Linq;
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.qc;
using ZR.Service.mes.wms.IService;
namespace ZR.Service.mes.wms
@@ -51,7 +53,7 @@ namespace ZR.Service.mes.wms
var response = Queryable()
.Where(predicate.ToExpression())
.OrderByDescending(it => it.UpdatedTime)
.OrderBy(it => it.Partnumber)
.ToPage<WmOneTimeInventory, WmOneTimeInventoryDto>(parm);
if (response.Result.Count > 0)
{
@@ -406,5 +408,95 @@ namespace ZR.Service.mes.wms
.Where(it => it.Status == 1)
.Sum(it => it.Quantity) ?? 0;
}
// Util 获取物料清单,不包含毛坯
public List<WmMaterial> GetWmMaterialList(string partnumber)
{
// 获取物料信息
return Context
.Queryable<WmMaterial>()
.WhereIF(
!string.IsNullOrEmpty(partnumber),
it => it.Partnumber.Contains(partnumber)
)
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
.Where(it => it.Type == 1)
.Where(it => it.Status == 1)
.Distinct()
.OrderBy(it => it.Description)
.ToList();
}
public List<WmOneTimeInventoryExportDto> GetExportList(WmOneTimeInventoryQueryDto parm)
{
try
{
List<WmMaterial> materials = GetWmMaterialList(parm.Partnumber);
// 获取所有partnumber列表
List<string> partnumbers = materials
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
.Select(it => it.Partnumber)
.Distinct()
.ToList();
// 批量获取盘点数和现有库存
Dictionary<string, object> stockNumbers = GetBatchOneTimeStockPartNum(partnumbers);
Dictionary<string, int> realNumbers = GetBatchOneTimeRealPartNum(partnumbers);
// 构建导出数据
List<WmOneTimeInventoryExportDto> exportDto = materials
.Select(it =>
{
bool found1 = stockNumbers.TryGetValue(it.Partnumber, out object value1);
int stockNumber = found1 && value1 != null ? Convert.ToInt32(value1) : 0;
bool found2 = realNumbers.TryGetValue(it.Partnumber, out int realNumber);
return new WmOneTimeInventoryExportDto
{
= it.Partnumber,
= it.Color,
= it.Specification,
= it.Description,
= stockNumber,
= found2 ? realNumber : 0,
};
})
.ToList();
return exportDto;
}
catch (Exception e)
{
throw;
}
}
// Util 获取指定抛光库零件盘点库存
public Dictionary<string, object> GetBatchOneTimeStockPartNum(List<string> partnumbers)
{
return Context
.Queryable<WmOneTimeInventory>()
.Where(it => partnumbers.Contains(it.Partnumber))
.GroupBy(it => it.Partnumber)
.ToDictionary(g => g.Partnumber, g => SqlFunc.AggregateSum(g.Quantity) ?? 0);
}
// Util 获取指定抛光库零件加报表后库存
public Dictionary<string, int> GetBatchOneTimeRealPartNum(List<string> partnumbers)
{
try
{
// 盘点时间
DateTime checkTime = new(2024, 10, 20, 0, 0, 0);
CommonFQCService commonFQCService = new();
// 获取报表数据
// 一次合格计算后库存 = 盘点库存 + 产线合格 + 抛光合格 - gp12投入 - 后道直接出库
return commonFQCService.GetBatchOneTimePartRealStock(partnumbers, checkTime);
}
catch (Exception e)
{
throw;
}
}
}
}

View File

@@ -392,7 +392,8 @@ namespace ZR.Service.mes.wms
int accumulation_num = 0;
foreach (var witem in wmGoodsNowsList)
{
if (require_num >= accumulation_num)
//TODO 修改>= 为 > 查看情况
if (require_num > accumulation_num)
{
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;

View File

@@ -1,12 +1,20 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Aliyun.OSS;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Newtonsoft.Json.Linq;
using SqlSugar;
using ZR.Model;
using ZR.Model.MES.qc.DTO;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Repository;
using ZR.Service.mes.qc;
using ZR.Service.mes.wms.IService;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ZR.Service.mes.wms
{
@@ -52,12 +60,13 @@ namespace ZR.Service.mes.wms
var response = Queryable()
.Where(predicate.ToExpression())
.OrderByDescending(it => it.UpdatedTime)
.OrderBy(it => it.Partnumber)
.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)
@@ -472,5 +481,96 @@ namespace ZR.Service.mes.wms
.Where(it => it.Status == 1)
.Sum(it => it.Quantity) ?? 0;
}
// Util 获取物料清单,不包含毛坯
public List<WmMaterial> GetWmMaterialList(string partnumber)
{
// 获取物料信息
return Context
.Queryable<WmMaterial>()
.WhereIF(
!string.IsNullOrEmpty(partnumber),
it => it.Partnumber.Contains(partnumber)
)
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
.Where(it => it.Type == 1)
.Where(it => it.Status == 1)
.Distinct()
.OrderBy(it => it.Description)
.ToList();
}
// 获取Excel导出数据
public List<WmPolishInventoryExportDto> GetExportList(WmPolishInventoryQueryDto parm)
{
try
{
List<WmMaterial> materials = GetWmMaterialList(parm.Partnumber);
// 获取所有partnumber列表
List<string> partnumbers = materials
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
.Select(it => it.Partnumber)
.Distinct()
.ToList();
// 批量获取盘点数和现有库存
Dictionary<string, object> stockNumbers = GetBatchPolishStockPartNum(partnumbers);
Dictionary<string, int> realNumbers = GetBatchPolishRealPartNum(partnumbers);
// 构建导出数据
List<WmPolishInventoryExportDto> exportDto = materials
.Select(it =>
{
bool found1 = stockNumbers.TryGetValue(it.Partnumber, out object value1);
int stockNumber = found1 && value1 != null ? Convert.ToInt32(value1) : 0;
bool found2 = realNumbers.TryGetValue(it.Partnumber, out int realNumber);
return new WmPolishInventoryExportDto
{
= it.Partnumber,
= it.Color,
= it.Specification,
= it.Description,
= stockNumber,
= found2 ? realNumber : 0,
};
})
.ToList();
return exportDto;
}
catch (Exception e)
{
throw;
}
}
// Util 获取指定抛光库零件盘点库存
public Dictionary<string, object> GetBatchPolishStockPartNum(List<string> partnumbers)
{
return Context
.Queryable<WmPolishInventory>()
.Where(it => partnumbers.Contains(it.Partnumber))
.GroupBy(it => it.Partnumber)
.ToDictionary(g => g.Partnumber, g => SqlFunc.AggregateSum(g.Quantity) ?? 0);
}
// Util 获取指定抛光库零件加报表后库存
public Dictionary<string, int> GetBatchPolishRealPartNum(List<string> partnumbers)
{
try
{
// 盘点时间
DateTime checkTime = new(2024, 10, 20, 0, 0, 0);
CommonFQCService commonFQCService = new();
// 获取报表数据
// 抛光计算后库存 = 盘点库存 + 产线抛光 + 后道反抛 + GP12反抛 - 抛光投入
return commonFQCService.GetBatchPolishPartRealStock(partnumbers, checkTime);
}
catch (Exception e)
{
throw;
}
}
}
}

View File

@@ -122,7 +122,7 @@ namespace ZR.Service.mes.wms
if(model.IsOutbound)
{
model.Type = 1;
model.Remark += "[直接出库]";
model.Remark += "[跳过后道]";
}
else
{
@@ -263,6 +263,7 @@ namespace ZR.Service.mes.wms
if (model.IsOutbound)
{
model.Type = 1;
model.Remark = "[跳过后道]";
}
else
{