仓库模块_出库货物记录:init

This commit is contained in:
qianhao.xu
2024-03-22 08:54:11 +08:00
parent 2074ea2e84
commit dac58ddb77
20 changed files with 800 additions and 20 deletions

View File

@@ -1398,12 +1398,12 @@ namespace ZR.Service.mes.qc
QcQualityStatisticsFirst first = new QcQualityStatisticsFirst();
first.Id = SnowFlakeSingle.Instance.NextId().ToString();
first.WorkorderId = workorderID;
ProWorkorder_v2 workorder= Context.Queryable<ProWorkorder_v2>().Where(it => it.Id == first.WorkorderId).First();
first.Color = workorder?.Colour;
ProWorkorder_v2 workorder_item = Context.Queryable<ProWorkorder_v2>().Where(it => it.ClientWorkorder == workorderID).First();
if (workorder_item != null)
{
first.Color = workorder_item?.Colour;
first.FinishedPartNumber = workorder_item.FinishedPartNumber;
first.ProductDescription = workorder_item.ProductDescription;
first.RequireNumber = workorder_item.PreviousNumber;
@@ -1615,13 +1615,12 @@ namespace ZR.Service.mes.qc
QcQualityStatisticsFirst first2 = new QcQualityStatisticsFirst();
first2.Id = SnowFlakeSingle.Instance.NextId().ToString();
first2.WorkorderId = workorderID;
ProWorkorder_v2 workorder2 = Context.Queryable<ProWorkorder_v2>().Where(it => it.Id == first.WorkorderId).First();
first2.Color = workorder2?.Colour;
ProWorkorder_v2 workorder_item2 = Context.Queryable<ProWorkorder_v2>().Where(it => it.ClientWorkorder == workorderID).First();
if (workorder_item2 != null)
{
first2.Color = workorder_item2?.Colour;
first2.FinishedPartNumber = workorder_item2.FinishedPartNumber;
first2.ProductDescription = workorder_item2.ProductDescription;
first2.RequireNumber = workorder_item2.PreviousNumber;
@@ -1839,12 +1838,13 @@ namespace ZR.Service.mes.qc
first3.WorkorderId = workorderID;
ProWorkorder_v2 workorder3 = Context.Queryable<ProWorkorder_v2>().Where(it => it.Id == first.WorkorderId).First();
first3.Color = workorder3?.Colour;
ProWorkorder_v2 workorder_item3 = Context.Queryable<ProWorkorder_v2>().Where(it => it.ClientWorkorder == workorderID).First();
if (workorder_item3 != null)
{
first3.Color = workorder_item3?.Colour;
first3.FinishedPartNumber = workorder_item3.FinishedPartNumber;
first3.ProductDescription = workorder_item3.ProductDescription;
first3.RequireNumber = workorder_item3.PreviousNumber;

View File

@@ -22,5 +22,7 @@ namespace ZR.Service.mes.qc.IService
//获取 总检
(List<QcQualityStatisticsTotal>,int) GetQualityStatisticsTable_total(DateTime starttime, DateTime endTime, string workorderid, string partnumber, string product_description, string team, int pageNum, int pageSize);
#endregion
public int DeleteStatisticsTable(string workorderid);
}
}

View File

@@ -13,9 +13,19 @@ using ZR.Service.mes.qc.IService;
namespace ZR.Service.mes.qc
{
/// <summary>
/// 查询报表
/// </summary>
[AppService(ServiceType = typeof(IQCStatisticsService), ServiceLifetime = LifeTime.Transient)]
public class QCStatisticsService : BaseService<QcQualityStatisticsFirst>, IQCStatisticsService
{
/// <summary>
/// 获取质量统计表 首检
/// </summary>
@@ -153,5 +163,30 @@ namespace ZR.Service.mes.qc
return (data, totalNum);
}
/// <summary>
/// 删除首检,二检,三检报表
/// </summary>
/// <param name="workorderid"></param>
/// <returns></returns>
public int DeleteStatisticsTable(string workorderid)
{
int num = 0;
num = num + Context.Deleteable<QcQualityStatisticsFirst>()
.Where(it => it.WorkorderId == workorderid).ExecuteCommand();
num = num + Context.Deleteable<QcQualityStatisticsAgain>().Where(it => it.WorkorderId == workorderid).ExecuteCommand();
num = num + Context.Deleteable<QcQualityStatisticsFinal>().Where(it => it.WorkorderId == workorderid).ExecuteCommand();
num = num + Context.Deleteable<QcQualityStatisticsTotal>().Where(it => it.WorkorderId == workorderid).ExecuteCommand();
return num;
}
}
}

View File

@@ -32,8 +32,6 @@ namespace ZR.Service.mes.qc
.AndIF(!string.IsNullOrEmpty(inspectionType), it => it.InspectionType == inspectionType)
.ToExpression();
return Queryable().Where(predicate).OrderBy(x => x.Order).ToList();
}
}

View File

@@ -0,0 +1,24 @@
using System;
using ZR.Model;
using ZR.Model.Dto;
using System.Collections.Generic;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
namespace ZR.Service.mes.wms.IService
{
/// <summary>
/// 出库货物记录表service接口
/// </summary>
public interface IWmGoodsOutProductionService : IBaseService<WmGoodsOutProduction>
{
PagedInfo<WmGoodsOutProductionDto> GetList(WmGoodsOutProductionQueryDto parm);
WmGoodsOutProduction GetInfo(string Id);
WmGoodsOutProduction AddWmGoodsOutProduction(WmGoodsOutProduction parm);
int UpdateWmGoodsOutProduction(WmGoodsOutProduction parm);
}
}

View File

@@ -26,5 +26,10 @@ namespace ZR.Service.mes.wms.IService
(List<WmMaterialQuery_stockQuantityDto>, int) GetmaterialList(WmMaterialQueryDto parm);
List<WmMaterialQuery_print> Queryoutoder_matrials(string shipment_num);
List<WmOutOrderPlan> Generate_outorderplan(string shipment_num);
}
}

View File

@@ -215,7 +215,7 @@ namespace ZR.Service.mes.wms
//todo 解析工单号
string workoderidid = splitstr[2].Substring(7);
resultionPackageCode.WorkoderID = workoderidid;
//todo 生产描述
//todo 生产时间
resultionPackageCode.ProductionTime="20"+ workoderidid.Substring(0,6);
//todo 解析箱子中产品数量
string product_num = splitstr[3].Substring(4);

View File

@@ -0,0 +1,92 @@
using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.Model;
using ZR.Model.Dto;
using ZR.Repository;
using System.Linq;
using ZR.Service.mes.wms.IService;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
namespace ZR.Service.Business
{
/// <summary>
/// 出库货物记录表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmGoodsOutProductionService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsOutProductionService : BaseService<WmGoodsOutProduction>, IWmGoodsOutProductionService
{
/// <summary>
/// 查询出库货物记录表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<WmGoodsOutProductionDto> GetList(WmGoodsOutProductionQueryDto parm)
{
var predicate = Expressionable.Create<WmGoodsOutProduction>();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<WmGoodsOutProduction, WmGoodsOutProductionDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public WmGoodsOutProduction GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public WmGoodsOutProduction AddWmGoodsOutProduction(WmGoodsOutProduction model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateWmGoodsOutProduction(WmGoodsOutProduction model)
{
//var response = Update(w => w.Id == model.Id, it => new WmGoodsOutProduction()
//{
// PackageCode = model.PackageCode,
// PackageCodeClient = model.PackageCodeClient,
// PackageCodeOriginal = model.PackageCodeOriginal,
// LocationCode = model.LocationCode,
// Partnumber = model.Partnumber,
// GoodsNumLogic = model.GoodsNumLogic,
// GoodsNumAction = model.GoodsNumAction,
// EntryWarehouseTime = model.EntryWarehouseTime,
// OutTime = model.OutTime,
// Remark = model.Remark,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
//});
//return response;
return Update(model, true);
}
}
}

View File

@@ -8,6 +8,8 @@ using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using Mapster;
using System.Collections.Generic;
using System.Data;
using JinianNet.JNTemplate.Dynamic;
namespace ZR.Service.mes.wms
{
@@ -220,5 +222,188 @@ namespace ZR.Service.mes.wms
return (material_stockQuantity_list, total);
}
/// <summary>
/// 查询出货单的物料信息
/// </summary>
/// <param name="shipment_num"></param>
/// <returns></returns>
public List<WmMaterialQuery_print> Queryoutoder_matrials(string shipment_num)
{
List<WmMaterialQuery_print> stockList = Context.Queryable<WmMaterialOutorder>()
.LeftJoin<WmMaterial>((mo, m) => mo.FkMaterialId == m.Id)
.Where(mo => mo.FkOutorderId == shipment_num)
.Select((mo, m) => new WmMaterialQuery_print()
{
//物料号
Partnumber = m.Partnumber,
// 描述
ProductName = m.ProductName,
//需求零件数
RequireOutNum = mo.OuthouseNum
}).ToList();
if (stockList != null && stockList.Count > 0)
{
foreach (var stock in stockList)
{
//现有箱数
stock.PackageNum = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == shipment_num).Count();
//现有零件数
int? num = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == shipment_num).Sum(it => it.GoodsNumLogic);
stock.PackageNum = num ?? 0;
}
}
return stockList;
}
/// <summary>
/// 生成出货单的出货计划
/// </summary>
/// <param name="shipment_num">出货单号</param>
/// <returns></returns>
public List<WmOutOrderPlan> Generate_outorderplan(string shipment_num)
{
List<WmOutOrderPlan> wmOutOrderPlans = new List<WmOutOrderPlan>();
// 获取当前出货单下的物料信息
List<WmMaterialQuery_print> materialQuery_Prints = this.Queryoutoder_matrials(shipment_num);
if (materialQuery_Prints != null && materialQuery_Prints.Count > 0)
{
foreach (var material in materialQuery_Prints)
{
//todo 判断要出多少货 按照最早工单和批次号 进行出货(重要算法)
//1. 这个物料要出多少货
int require_num = material.RequireOutNum;
// 物料号
string partnumber = material.Partnumber;
/*此物料下的最早列表
List<WmGoodsNowProduction> wmGoodsNows = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == partnumber)
.OrderByDescending(it => it.EntryWarehouseTime).ToList();
if (wmGoodsNows != null && wmGoodsNows.Count > 0)
{
foreach (var witem in wmGoodsNows)
{
if (require_num >= witem.GoodsNumLogic)
{ // 取出同一批次下列表
string patchcode = witem.PackageCodeClient.Split("_")[0];
List<WmGoodsNowProduction> Samebatch_wmGoodsNows = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Partnumber == partnumber)
.Where(it => it.PackageCodeClient.StartsWith(patchcode)).ToList();
出货计划
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum = 1;
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
wmOutOrderPlans.Add(orderPlan);
}
else
{
一个箱子就可以做一个出货计划
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum = 1;
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
}
}
}*/
List<WmGoodsNowProduction> wmGoodsNowsList = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == partnumber)
.OrderByDescending(it => it.PackageCodeClient).ToList();
foreach(var witem in wmGoodsNowsList)
{
int accumulation_num = 0;
if (require_num>= accumulation_num)
{
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum =int.Parse( witem.PackageCodeClient.Split("_")[1] );
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
wmOutOrderPlans.Add(orderPlan);
accumulation_num = accumulation_num+ witem.GoodsNumLogic??0;
}
else
{ //超了
break;
}
}
}
}
foreach (var witem in wmOutOrderPlans)
{
witem.Outorder = wmOutOrderPlans.IndexOf(witem);
}
return wmOutOrderPlans;
}
/// <summary>
/// 传入批次号 解析出时间 BNW240318007_105
/// </summary>
/// <param name="bath_code"></param>
/// <returns></returns>
private string Resolution_bath(string bath_code)
{
if (string.IsNullOrEmpty(bath_code))
{
return "";
}
string temp = bath_code.Split("_")[0];
return "20" + temp.Substring(2, 6);
}
}
}