change - 组装计划、货道信息设置

collectionStore
wenjy 6 months ago
parent 69484298b1
commit c66668b66a

@ -104,11 +104,11 @@ namespace Aucma.Scada.Business
{
productPlanInfos = _productPlanInfoService.GetProductPlanInfosByProductLineCode(appConfig.stationCode);
if(productPlanInfos.Count>0 )
if (productPlanInfos.Count > 0)
{
if(!string.IsNullOrEmpty(orderCode))
if (!string.IsNullOrEmpty(orderCode))
{
productPlanInfos = productPlanInfos.Where(x=>x.orderCode.Contains(orderCode)).ToList();
productPlanInfos = productPlanInfos.Where(x => x.orderCode.Contains(orderCode)).ToList();
}
}
}
@ -155,7 +155,7 @@ namespace Aucma.Scada.Business
/// <param name="materialType">BOM类型</param>
/// <param name="storeCode"></param>
/// <returns></returns>
public bool JudgmentStock(ProductPlanInfo planInfo,int transmitAmount, string materialType,string storeCode)
public bool JudgmentStock(ProductPlanInfo planInfo, int transmitAmount, string materialType, string storeCode)
{
bool result = false;
try
@ -176,16 +176,16 @@ namespace Aucma.Scada.Business
materialType = baseBomInfo.materialCode;
var planInfos = _executePlanInfoService.GetExecutePlanInfosByProductLineCode(appConfig.stationCode);
var spaceInfo = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode,materialType);
if(spaceInfo != null)
var spaceInfo = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType);
if (spaceInfo != null)
{
int sumStock = spaceInfo.Sum(x=>x.spaceStock);
int sumStock = spaceInfo.Sum(x => x.spaceStock);
if(planInfos != null)
if (planInfos != null)
{
int sumPlanAmount = planInfos.Sum(x => x.planAmount - x.completeAmount);
if(sumStock - sumPlanAmount > transmitAmount)
if (sumStock - sumPlanAmount > transmitAmount)
{
result = true;
}
@ -413,16 +413,20 @@ namespace Aucma.Scada.Business
break;
}
var taksInfos =_realTaskInfoService.GetTaskInfosByTaskStatus(new string[] { appConfig.shellStoreCode, appConfig.linerStoreCode }, 2,2);
var taksInfos = _realTaskInfoService.GetTaskInfosByStoreCode(new string[] { appConfig.shellStoreCode, appConfig.linerStoreCode }, 2);
if (taksInfos != null)
{
taksInfos = taksInfos.Where(x => x.taskStatus != 3).ToList();
if (taksInfos.Count == 0)
{
var prodPlanInfo = _productPlanInfoService.GetProductPlanByPlanCode(planInfo.productPlanCode);
if(prodPlanInfo!= null)
if (prodPlanInfo != null)
{
if(prodPlanInfo.planAmount > prodPlanInfo.completeAmount)
if (prodPlanInfo.planAmount > prodPlanInfo.completeAmount)
{
if((prodPlanInfo.planAmount - prodPlanInfo.completeAmount) >= planInfo.planAmount)
if ((prodPlanInfo.planAmount - prodPlanInfo.completeAmount) >= planInfo.planAmount)
{
//创建新计划
PlanTransmitByProductPlan(planInfo.productPlanCode, planInfo.planAmount);
@ -436,9 +440,9 @@ namespace Aucma.Scada.Business
else
{
var prodPlanInfos = _productPlanInfoService.GetProductPlanInfosByProductLineCode(appConfig.stationCode);
if(prodPlanInfos != null)
if (prodPlanInfos != null)
{
prodPlanInfos = prodPlanInfos.Where(x=>x.materialCode == planInfo.materialCode && x.planAmount > x.completeAmount).ToList();
prodPlanInfos = prodPlanInfos.Where(x => x.materialCode == planInfo.materialCode && x.planAmount > x.completeAmount).ToList();
prodPlanInfo = prodPlanInfos.First();
if ((prodPlanInfo.planAmount - prodPlanInfo.completeAmount) >= planInfo.planAmount)
@ -458,12 +462,16 @@ namespace Aucma.Scada.Business
isFlase = false;
}
}
Task.Delay(2000).Wait();
} while (isFlase);
}
}
Task.Delay(5000).Wait();
}catch(Exception ex)
}
catch (Exception ex)
{
Console.WriteLine($"组装计划自动执行异常:{ex.Message}");
}

@ -246,7 +246,7 @@ namespace Aucma.Scada.Business
if (spaceList != null)
{
spaceList = spaceList.Where(x => x.spaceStatus == 4).ToList();
spaceList = spaceList.Where(x => x.unusualFlag == 2).ToList();
BaseSpaceInfo spaceInfo = GetSpaceInfosByPlc(spaceList, false);

@ -70,7 +70,7 @@ namespace Aucma.Scada.Business
List<BaseSpaceInfo> spaceInfos = null;
try
{
spaceInfos = _spaceInfoService.GetSpaceInfosByStoreCode(storeCode).OrderBy(x=>x.objId).ToList();
spaceInfos = _spaceInfoService.GetSpaceInfosByStoreCode(storeCode).OrderBy(x => x.objId).ToList();
}
catch (Exception ex)
@ -149,6 +149,7 @@ namespace Aucma.Scada.Business
if (spaceInfo != null)
{
spaceInfo.unusualFlag = spaceInfo.unusualFlag == 1 ? 2 : 1;
result = _spaceInfoService.UpdateSpaceInfo(spaceInfo);
logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};异常标识:{spaceInfo.unusualFlag};修改{(result == true ? "" : "")}");
}
@ -175,7 +176,7 @@ namespace Aucma.Scada.Business
BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode);
if (spaceInfo != null)
{
spaceInfo.spaceStatus = spaceInfo.spaceStatus == 1 ? 2 : 1;
spaceInfo.spaceStatus = spaceInfo.spaceStatus == 1 ? 3 : 1;
result = _spaceInfoService.UpdateSpaceInfo(spaceInfo);
logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};货道状态:{spaceInfo.unusualFlag};修改{(result == true ? "" : "")}");
}

@ -97,7 +97,7 @@ namespace Aucma.Scada.Business
public delegate void RefreshLogMessage(string message);
public event RefreshLogMessage RefreshLogMessageEvent;
public delegate void RefreshAssemblyPlanInit();
public delegate void RefreshAssemblyPlanInit(int isFlag = 0);
public event RefreshAssemblyPlanInit RefreshAssemblyPlanInitEvent;
public delegate void RefreshStoreStock();
@ -122,7 +122,8 @@ namespace Aucma.Scada.Business
taskHandleBusiness.OutStoreFinsihEvent += OutStoreFinish;
taskHandleBusiness.UpdateMesPlanCompleteEvent += UpdatePlanInfo;
StartPassDown();
}catch (Exception ex)
}
catch (Exception ex)
{
Console.WriteLine($"OutStoreBusiness异常{ex.Message}");
PrintLogErrorMessage($"OutStoreBusiness异常{ex.Message}");
@ -146,18 +147,63 @@ namespace Aucma.Scada.Business
var shellBomInfo = _bomInfoService.GetBomInfoByMaterialCode(planInfo.materialCode);
var linerBomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, appConfig.linerMaterialType);
if(shellBomInfo != null && linerBomInfo != null)
if (shellBomInfo != null && linerBomInfo != null)
{
for (int i = 0; i < planInfo.planAmount - planInfo.completeAmount; i++)
{
string taskCode = System.Guid.NewGuid().ToString("N").Substring(0,10);
RealTaskInfo shellTask = OutStore(appConfig.shellStoreCode, shellBomInfo, planInfo.executePlanCode, taskCode);
Thread.Sleep(500);
RealTaskInfo linerTask = OutStore(appConfig.linerStoreCode, linerBomInfo, planInfo.executePlanCode, taskCode);
string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 10);
//RealTaskInfo shellTask = OutStore(appConfig.shellStoreCode, shellBomInfo, planInfo.executePlanCode, taskCode);
//Thread.Sleep(500);
//RealTaskInfo linerTask = OutStore(appConfig.linerStoreCode, linerBomInfo, planInfo.executePlanCode, taskCode);
//Thread.Sleep(500);
var shellSpaceInfo = GetSpaceInfoByMaterialType(appConfig.shellStoreCode, shellBomInfo.materialCode);
Thread.Sleep(100);
var linerSpaceInfo = GetSpaceInfoByMaterialType(appConfig.linerStoreCode, linerBomInfo.materialCode);
Thread.Sleep(100);
//判断库存
if (shellSpaceInfo != null && linerSpaceInfo != null)
{
RealTaskInfo shell_task = CreateOutStoreTask(shellSpaceInfo, planInfo.executePlanCode, taskCode); //创建出库任务
if (shell_task != null)
{
PrintLogInfoMessage("箱壳出库计划创建成功");
}
else
{
PrintLogInfoMessage("箱壳出库计划创建失败");
assemblyPlanBusiness.autoFlag = false;
RefreshAssemblyPlanInitEvent?.Invoke(2);
}
Thread.Sleep(100);
RealTaskInfo liner_task = CreateOutStoreTask(shellSpaceInfo, planInfo.executePlanCode, taskCode); //创建出库任务
if (shell_task != null)
{
PrintLogInfoMessage("箱壳出库计划创建成功");
}
else
{
PrintLogInfoMessage("箱壳出库计划创建失败");
assemblyPlanBusiness.autoFlag = false;
RefreshAssemblyPlanInitEvent?.Invoke(2);
}
}
else
{
PrintLogInfoMessage($"组装计划:{planInfo.executePlanCode};出库失败,货道不匹配,未匹配到相同型号物料");
assemblyPlanBusiness.autoFlag = false;
}
Thread.Sleep(1000 * 2);
Thread.Sleep(500);
}
}
else
{
@ -187,7 +233,7 @@ namespace Aucma.Scada.Business
{
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
RealTaskInfo task = CreateOutStoreTask(spaceInfo, planCode, taskCode); //创建出库任务
if (task!=null)
if (task != null)
{
PrintLogInfoMessage("出库任务创建成功");
return task;
@ -217,7 +263,7 @@ namespace Aucma.Scada.Business
/// 创建出库任务
/// </summary>
/// <param name="spaceInfo"></param>
private RealTaskInfo CreateOutStoreTask(BaseSpaceInfo spaceInfo, string planCode, string taksCode, int taskModel = 0,int emptyDetailFlag=0)
private RealTaskInfo CreateOutStoreTask(BaseSpaceInfo spaceInfo, string planCode, string taksCode, int taskModel = 0, int emptyDetailFlag = 0)
{
bool result = false;
try
@ -291,7 +337,7 @@ namespace Aucma.Scada.Business
/// </summary>
/// <param name="spaceInfo"></param>
/// <returns></returns>
private BaseSpaceDetail GetSpaceDetailFirstOrderByCreatTime(BaseSpaceInfo spaceInfo,string type)
private BaseSpaceDetail GetSpaceDetailFirstOrderByCreatTime(BaseSpaceInfo spaceInfo, string type)
{
BaseSpaceDetail spaceDetail = null;
try
@ -299,7 +345,7 @@ namespace Aucma.Scada.Business
List<BaseSpaceDetail> spaceDetails = _spaceDetailService.GetSpaceDetailsBySpaceCode(spaceInfo.storeCode, spaceInfo.spaceCode);
if (spaceDetails.Count > 0)
{
spaceDetails = spaceDetails.Where(x => x.isFlag != 1 && x.materialType==type).ToList();
spaceDetails = spaceDetails.Where(x => x.isFlag != 1 && x.materialType == type).ToList();
if (spaceDetails.Count > 0)
{
spaceDetail = spaceDetails.OrderBy(x => x.createTime).First();
@ -356,11 +402,11 @@ namespace Aucma.Scada.Business
//获取箱壳出库任务
RealTaskInfo taskInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.shellStoreCode, appConfig.outstoreTaskType);
if(taskInfo != null)
if (taskInfo != null)
{
PrintLogInfoMessage($"下发箱壳出库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
int result = taskHandleBusiness.SendShellTask_OutStore(taskInfo);
if (result==1)
if (result == 1)
{
PrintLogInfoMessage($"箱壳出库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈");
@ -387,7 +433,8 @@ namespace Aucma.Scada.Business
{
// PrintLogInfoMessage("未获取到需要下发的箱壳出库任务");
}
}catch(Exception ex)
}
catch (Exception ex)
{
PrintLogErrorMessage("下传箱壳出库任务逻辑处理异常", ex);
}
@ -405,7 +452,7 @@ namespace Aucma.Scada.Business
{
PrintLogInfoMessage($"下发内胆出库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
int result = taskHandleBusiness.SendLinerTask_OutStore(taskInfo);
if (result==1)
if (result == 1)
{
PrintLogInfoMessage($"内胆出库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈");
@ -586,7 +633,7 @@ namespace Aucma.Scada.Business
_executePlanInfoService.UpdateExecutePlanInfo(executeInfo);
var productInfo = _productPlanInfoService.GetProductPlanByPlanCode(executeInfo.productPlanCode);
if(productInfo != null)
if (productInfo != null)
{
productInfo.completeAmount += 1;
if (productInfo.completeAmount == productInfo.planAmount)
@ -611,7 +658,7 @@ namespace Aucma.Scada.Business
RefreshAssemblyPlanInitEvent?.Invoke();
}
catch(Exception ex)
catch (Exception ex)
{
PrintLogErrorMessage("计划信息更新异常", ex);
}
@ -635,11 +682,11 @@ namespace Aucma.Scada.Business
/// </summary>
/// <param name="taskCode"></param>
/// <returns></returns>
public bool DeleteTaskInfoByTaskCode(string taskCode,bool isFlag)
public bool DeleteTaskInfoByTaskCode(string taskCode, bool isFlag)
{
bool result = false;
var info = _taskInfoService.GetTaskInfosByTaskCode(taskCode);
if(info != null && info.Count>0)
if (info != null && info.Count > 0)
{
RealTaskInfo taskInfo = info[0];
//foreach(var taskInfo in info)
@ -653,8 +700,8 @@ namespace Aucma.Scada.Business
result = _taskInfoService.DeleteTaskInfoById(taskInfo.objId);
if (result)
{
var spaceDetailInfo =_spaceDetailService.GetSpaceDetailByMaterialCode(taskInfo.spaceCode,taskInfo.materialCode,taskInfo.detailCode);
if(spaceDetailInfo != null)
var spaceDetailInfo = _spaceDetailService.GetSpaceDetailByMaterialCode(taskInfo.spaceCode, taskInfo.materialCode, taskInfo.detailCode);
if (spaceDetailInfo != null)
{
if (!isFlag)
{
@ -663,7 +710,7 @@ namespace Aucma.Scada.Business
}
else
{
_spaceDetailService.DeleteSpaceDetailByMaterialCode(spaceDetailInfo.spaceCode,spaceDetailInfo.materialCode,spaceDetailInfo.detailCode);
_spaceDetailService.DeleteSpaceDetailByMaterialCode(spaceDetailInfo.spaceCode, spaceDetailInfo.materialCode, spaceDetailInfo.detailCode);
}
}
@ -760,11 +807,11 @@ namespace Aucma.Scada.Business
PrintLogInfoMessage($"通过PLC读取货道信息货道{spaceInfo.spaceName};在库数量:{item.spaceStock};货道状态:{item.spaceStatus}");
}
var list = info.Where(x=>x.spaceStatus == 1 && x.spaceStock > 0 && (x.spaceStock - x.outRouteAmount) > 0).ToList();
var list = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0).ToList(); // && (x.spaceStock - x.outRouteAmount) > 0
if (list.Count > 0)
{
result = info.OrderBy(x => x.spaceStock - x.outRouteAmount).First();
result = info.OrderBy(x => x.spaceStock).First();
}
else
{

@ -124,7 +124,7 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
set { beginTime = value; RaisePropertyChanged(nameof(BeginTime)); }
}
private string autoSendContent =string.Empty;
private string autoSendContent = string.Empty;
//
public string AutoSendContent
@ -255,7 +255,7 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
public RelayCommand MaterialStatisticsCommand { get; set; }
public RelayCommand AutoSendCommand { get;set; }
public RelayCommand AutoSendCommand { get; set; }
#endregion
@ -348,8 +348,22 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
/// <summary>
/// 出库完成刷新计划列表
/// </summary>
private void RefreshPlanInfoDataGrid()
private void RefreshPlanInfoDataGrid(int isFlag = 0)
{
if (isFlag == 1)
{
AutoSendContent = "关闭";
}
else if (isFlag == 2)
{
AutoSendContent = "自动下发";
}
else
{
//
}
RefreshExecutePlan();
App.Current.Dispatcher.Invoke((Action)(() =>
@ -424,7 +438,7 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
/// <param name="planInfos"></param>
private void RefreshStatisticsGauge(List<ExecutePlanInfo> planInfos)
{
if(planInfos != null)
if (planInfos != null)
{
if (planInfos.Count > 0)
{

Loading…
Cancel
Save