|
|
using iWareCommon.Common.Globle;
|
using iWareCommon.Utils;
|
using iWareModel;
|
using iWareModel.EnumType.AoSinPublicCommon;
|
using iWareSql;
|
using iWareSql.DbOrm;
|
using iWareSql.Entity.ViewMode;
|
using iWareSql.Orm;
|
using System;
|
using System.Collections.Generic;
|
using System.Data.Entity.Infrastructure;
|
using System.Linq;
|
using System.Net;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using XiGang.Core.Model;
|
|
namespace iWareSql.DataAccess
|
{
|
/// <summary>
|
/// 设备任务处理类
|
/// </summary>
|
public class PartTaskHandler
|
{
|
/// <summary>
|
/// 创建一个子任务
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="deviceType"></param>
|
/// <param name="userName"></param>
|
/// <param name="taskSequence"></param>
|
/// <param name="_DeviceTaskTypeEnum"></param>
|
/// <param name="mainTask"></param>
|
/// <param name="salver"></param>
|
/// <param name="sourcePlace"></param>
|
/// <param name="toPlace"></param>
|
/// <param name="description"></param>
|
/// <returns></returns>
|
public static FunRetEntity CreateSubTask(DateTime createTime, string plcTaskNo, iWareSql.DbOrm.DbOrm edm,
|
EDeviceType deviceType,
|
long? usersID,
|
string userName,
|
int taskSequence,
|
TaskCategoryEnum _TaskCategoryEnum,
|
ware_task mainTask, string midPlace, string description, int containerType, string midPlace2 = "")
|
{
|
var validate_deviceByPlace = "";
|
var sourcePlace = "";
|
var toPlace = "";
|
string containerCode = mainTask.ContainerCode;
|
switch (_TaskCategoryEnum)
|
{
|
case TaskCategoryEnum.OutStock:
|
validate_deviceByPlace = mainTask.FromLocationCode;
|
switch (deviceType)
|
{
|
case EDeviceType.堆垛机:
|
sourcePlace = mainTask.FromLocationCode;
|
toPlace = midPlace;
|
break;
|
case EDeviceType.输送线:
|
sourcePlace = midPlace;
|
toPlace = midPlace2;
|
break;
|
case EDeviceType.AGV:
|
sourcePlace = midPlace2;
|
toPlace = mainTask.ToLocationCode;
|
break;
|
}
|
break;
|
case TaskCategoryEnum.InStock:
|
validate_deviceByPlace = mainTask.ToLocationCode;
|
switch (deviceType)
|
{
|
case EDeviceType.AGV:
|
sourcePlace = mainTask.FromLocationCode;
|
toPlace = midPlace;
|
break;
|
case EDeviceType.输送线:
|
sourcePlace = midPlace;
|
toPlace = midPlace2;
|
break;
|
case EDeviceType.堆垛机:
|
sourcePlace = midPlace2;
|
toPlace = mainTask.ToLocationCode;
|
break;
|
}
|
break;
|
case TaskCategoryEnum.MoveStock:
|
if (description == "堆垛机出库移库任务")
|
{
|
validate_deviceByPlace = mainTask.FromLocationCode;
|
sourcePlace = mainTask.MoveFromLocation;
|
toPlace = mainTask.MoveToLocation;
|
containerCode = mainTask.MoveContainerCode;
|
}
|
else if(description == "堆垛机出库移库任务2")
|
{
|
validate_deviceByPlace = mainTask.FromLocationCode;
|
sourcePlace = mainTask.MoveToLocation;
|
toPlace = midPlace;
|
containerCode = mainTask.MoveContainerCode;
|
}
|
else
|
{
|
validate_deviceByPlace = mainTask.FromLocationCode;
|
sourcePlace = mainTask.FromLocationCode;
|
toPlace = mainTask.ToLocationCode;
|
containerCode = mainTask.ContainerCode;
|
}
|
break;
|
case TaskCategoryEnum.Front:
|
validate_deviceByPlace = mainTask.FromLocationCode;
|
switch (deviceType)
|
{
|
case EDeviceType.AGV:
|
sourcePlace = mainTask.FromLocationCode;
|
toPlace = midPlace;
|
break;
|
case EDeviceType.输送线:
|
sourcePlace = midPlace;
|
toPlace = mainTask.ToLocationCode;
|
break;
|
}
|
break;
|
}
|
EDevice device = BusinessHelper.GetDeviceByPlaceNo(deviceType);
|
|
FunRetEntity fre = new FunRetEntity();
|
fre.result = true;
|
|
//var isEquipmentBreakdown1 = Wms_EquipmentSituationHandler.IsEquipmentBreakdown((int)device);
|
//if (isEquipmentBreakdown1.result)
|
//{//如果设备已经设定为 故障状态,不允许下发任务!!! [EditBy shaocx,2020-12-07]
|
// fre.result = false;
|
// fre.resMsg = isEquipmentBreakdown1.resMsg;
|
// return fre;
|
//}
|
ware_task_sub tsk = new ware_task_sub()
|
{
|
OrderNo = mainTask.OrderNo,
|
TaskId = mainTask.Id,
|
TaskNo = plcTaskNo,
|
TaskSequence = taskSequence,
|
TaskDescribe = description,
|
TaskState = _TaskCategoryEnum == TaskCategoryEnum.InStock && device == EDevice.堆垛机 ? (int)SubTaskStateEnum.等待下发 : (int)SubTaskStateEnum.未开始,
|
//TaskState = (int)SubTaskStateEnum.未开始,
|
DeviceType = device.ToString(),
|
DeviceId = (int)device,
|
ContainerCode = containerCode,
|
TaskType = (int)_TaskCategoryEnum,
|
SourcePlace = sourcePlace,
|
ToPlace = toPlace,
|
UpdatedUserName = userName,
|
UpdatedTime = createTime,
|
CreatedUserName = userName,
|
CreatedTime = createTime,
|
ContainerType = containerType,
|
OperationRemark = "初始创建",
|
};
|
|
DoCreateSubTask(edm, tsk);
|
return fre;
|
}
|
|
private static bool DoCreateSubTask(DbOrm.DbOrm edm, ware_task_sub tsk)
|
{
|
edm.ware_task_sub.Add(tsk);
|
return true;
|
}
|
}
|
}
|