change - 计划下达时添加库存判断

foamRearStore
wenjy 1 year ago
parent ad40d223ba
commit cd400a85d8

Binary file not shown.

@ -43,6 +43,16 @@ namespace Aucma.Scada.Business
/// 执行计划
/// </summary>
private IExecutePlanInfoService _executePlanInfoService;
/// <summary>
/// BOM信息
/// </summary>
private IBaseBomInfoService _bomInfoService;
/// <summary>
/// 货道明细
/// </summary>
private IBaseSpaceDetailService _spaceDetailService;
#endregion
#region 委托事件
@ -65,6 +75,8 @@ namespace Aucma.Scada.Business
{
_productPlanInfoService = registerServices.GetService<IProductPlanInfoService>();
_executePlanInfoService = registerServices.GetService<IExecutePlanInfoService>();
_bomInfoService = registerServices.GetService<IBaseBomInfoService>();
_spaceDetailService = registerServices.GetService<IBaseSpaceDetailService>();
}
@ -115,6 +127,39 @@ namespace Aucma.Scada.Business
return planInfos;
}
/// <summary>
/// 判断库存
/// </summary>
/// <param name="planInfo">生产计划</param>
/// <param name="transmitAmount">下达数量</param>
/// <param name="materialType">BOM类型</param>
/// <param name="storeCode"></param>
/// <returns></returns>
public bool JudgmentStock(ProductPlanInfo planInfo, int transmitAmount, string materialType, string storeCode)
{
bool result = false;
try
{
var bomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, materialType);
if (bomInfo != null)
{
materialType = bomInfo.materialCode;
List<BaseSpaceDetail> spaceDetails = _spaceDetailService.GetSpaceDetailsByMaterialType(storeCode, materialType);
if (spaceDetails.Count > transmitAmount)
{
result = true;
}
}
}
catch (Exception ex)
{
logHelper.Error("计划下达判断库存异常", ex);
}
return result;
}
/// <summary>
/// 根据生产计划下达执行计划
/// </summary>

@ -2,6 +2,7 @@
using Aucma.Scada.Model.domain;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HighWayIot.Config;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -16,6 +17,7 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
public class QuantityIssuedViewModel : ViewModelBase
{
private AssemblyPlanBusiness assemblyPlanBusiness = AssemblyPlanBusiness.Instance;
private AppConfig appConfig = AppConfig.Instance;
public QuantityIssuedViewModel(ProductPlanInfo productPlanInfo)
{
@ -56,6 +58,25 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
private void PlanInfoTransmit()
{
var productPlanInfo = _PlanInfo;
if (productPlanInfo != null)
{
var materialType = productPlanInfo.materialCode;
bool shellResult = assemblyPlanBusiness.JudgmentStock(productPlanInfo, Convert.ToInt32(_TransmitAmount), appConfig.foamMaterialType, appConfig.foamStoreCode);
if (!shellResult)
{
MessageBox.Show("计划下达失败,箱体物料库存不足");
return;
}
}
else
{
MessageBox.Show("生产计划获取失败,加载为空");
return;
}
bool result = assemblyPlanBusiness.PlanTransmitByProductPlan(_PlanInfo.planCode, Convert.ToInt32(_TransmitAmount));
if (result)
{

@ -13,6 +13,14 @@ namespace HighWayIot.Repository.service
/// <returns></returns>
List<BaseSpaceDetail> GetSpaceDetailsBySpaceCode(string storeCode, string spaceCode);
/// <summary>
/// 根据物料类型获取可用的货道明细
/// </summary>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <returns></returns>
List<BaseSpaceDetail> GetSpaceDetailsByMaterialType(string storeCode, string materialType);
/// <summary>
/// 通过物料编号获取货道明细
/// </summary>

@ -86,6 +86,31 @@ namespace HighWayIot.Repository.service.Impl
return spaceDetails;
}
/// <summary>
/// 根据物料类型获取可用的货道明细
/// </summary>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <returns></returns>
public List<BaseSpaceDetail> GetSpaceDetailsByMaterialType(string storeCode, string materialType)
{
List<BaseSpaceDetail> spaceDetails = null;
try
{
Expression<Func<BaseSpaceDetail, bool>> exp = s1 => true;
exp = exp.And(x => x.storeCode == storeCode && x.materialType == materialType && x.isFlag != 1);
spaceDetails = _mesRepository.GetList(exp);
logHelper.Info($"根据仓库编号:{storeCode};物料类型:{materialType};获取到的货道明细:{jsonChange.ModeToJson(spaceDetails)}");
}
catch (Exception ex)
{
logHelper.Error("通过物料类型获取货道明细异常", ex);
}
return spaceDetails;
}
/// <summary>
/// 添加货道明细
/// </summary>

Loading…
Cancel
Save