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