base
This commit is contained in:
1 parent
d1781f7326
commit
aa33eadcb6
1066 files changed
+68
-335722
No files matched your search
@@ -237,129 +237,5 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 任务取消
|
||||
[ActionDescription("TaskHeader.Cancel")]
|
||||
public ActionResult Cancel(string id)
|
||||
{
|
||||
var task = _unitwork.Find<TaskDetail>(x => x.ID == int.Parse(id))
|
||||
.Include(x => x.TaskHeader).FirstOrDefault();
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
var isSend = 0;
|
||||
// 判断任务 是否能取消
|
||||
if (task.Status < TaskStatusEnum.已下发)
|
||||
{
|
||||
isSend = 1;
|
||||
}
|
||||
else if (task.Status == TaskStatusEnum.完成)
|
||||
{
|
||||
return FFResult().Alert($"此任务已完成,无需取消!");
|
||||
}
|
||||
|
||||
var taskInfo = new TaskInfo
|
||||
{
|
||||
TaskId = $"{task.TaskHeader.TaskNo}-{task.FromLocation}",
|
||||
TaskType = 99,
|
||||
};
|
||||
try
|
||||
{
|
||||
if (isSend == 0)
|
||||
{
|
||||
var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, taskInfo).Result.Data;
|
||||
if ((bool)res?.Success)
|
||||
{
|
||||
isSend = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().Alert($"操作失败,{res.Msg}");
|
||||
}
|
||||
}
|
||||
if (isSend == 1)
|
||||
{
|
||||
// 盘料入库,删除子表任务,并且删除子表对应库存,
|
||||
if (task.TaskHeader.TaskType.Equals(TaskTypeEnum.盘料入库))
|
||||
{
|
||||
List<TaskDetail> taskDetails = _unitwork.Find<TaskDetail>(x => x.TaskHeaderId == task.TaskHeader.ID
|
||||
&& x.ID != task.ID).ToList();
|
||||
Inventory inventory = _unitwork.Find<Inventory>(n => n.UniqueCode == task.UniqueCode
|
||||
&& n.ContainerCode == task.TaskHeader.FromLocation
|
||||
&& n.TaskStatus == InventoryTaskStatus.任务中).FirstOrDefault();
|
||||
if (inventory != null)
|
||||
{
|
||||
_unitwork.Delete(inventory);
|
||||
}
|
||||
_unitwork.Delete(task);
|
||||
//子表已经被全部删除,创建盘料盒回库任务
|
||||
if (taskDetails.Count() == 0)
|
||||
{
|
||||
var newTask = new TaskHeader
|
||||
{
|
||||
TaskDetails = new List<TaskDetail>()
|
||||
};
|
||||
var station = _unitwork.Find<Location>(x => x.Code == task.FromLocation).FirstOrDefault();
|
||||
// 创建料盒入库任务
|
||||
// 查找回库的任务起点,
|
||||
var fromLocation = _unitwork.FindSingle<Location>(x => x.Code.Equals(task.ToLocation)).ContiguousCode;
|
||||
newTask.ZoneCode = ZoneCodeEnum.盘料库;
|
||||
newTask.TaskNo = _unitwork.GetSerialNumber("Deletein", 4);
|
||||
newTask.TaskType = TaskTypeEnum.盘料盒入库;
|
||||
newTask.ContainerCode = task.TaskHeader.ContainerCode;
|
||||
newTask.FromLocation = fromLocation;
|
||||
newTask.ToLocation = task.TaskHeader.ContainerCode;
|
||||
newTask.Status = TaskStatusEnum.待下发;
|
||||
newTask.CreateTime = DateTime.Now;
|
||||
_unitwork.Add(newTask);
|
||||
//更新料塔占用
|
||||
station.ContainerCode = "";
|
||||
_unitwork.Update(station);
|
||||
}
|
||||
|
||||
}
|
||||
//盘料出库,删除子表任务,并且恢复子表对应库存,子表全部删除后创建盘料盒回库任务
|
||||
else if (task.TaskHeader.TaskType.Equals(TaskTypeEnum.盘料出库))
|
||||
{
|
||||
List<TaskDetail> taskDetails = _unitwork.Find<TaskDetail>(x => x.TaskHeaderId == task.TaskHeader.ID
|
||||
&& x.ID != task.ID).ToList();
|
||||
Inventory inventory = _unitwork.Find<Inventory>(n => n.UniqueCode == task.UniqueCode
|
||||
&& n.ContainerCode == task.TaskHeader.FromLocation
|
||||
&& n.TaskStatus == InventoryTaskStatus.任务中).FirstOrDefault();
|
||||
if (inventory != null)
|
||||
{
|
||||
inventory.ContainerCode = task.TaskHeader.ContainerCode;
|
||||
inventory.LocationCode = task.TaskHeader.ContainerCode;
|
||||
_unitwork.Update(inventory);
|
||||
}
|
||||
if (taskDetails.Count() == 0)
|
||||
{
|
||||
// 查找回库的任务起点,
|
||||
var fromLocation = _unitwork.FindSingle<Location>(x => x.Code.Equals(task.FromLocation)).ContiguousCode;
|
||||
// 下发盘料盒回库任务,回原位
|
||||
var newTask = new TaskHeader
|
||||
{
|
||||
TaskDetails = new List<TaskDetail>()
|
||||
};
|
||||
newTask.ZoneCode = ZoneCodeEnum.盘料库;
|
||||
newTask.TaskNo = _unitwork.GetSerialNumber("Deletein", 4);
|
||||
newTask.TaskType = TaskTypeEnum.盘料盒入库;
|
||||
newTask.ContainerCode = task.ContainerCode;
|
||||
newTask.FromLocation = fromLocation;
|
||||
newTask.ToLocation = task.ContainerCode;
|
||||
newTask.Status = TaskStatusEnum.待下发;
|
||||
newTask.CreateTime = DateTime.Now;
|
||||
_unitwork.Add(newTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return FFResult().Alert($"操作失败,{ex.Message}");
|
||||
}
|
||||
}
|
||||
return FFResult().Message("任务取消成功").RefreshGrid();
|
||||
}
|
||||
#endregion 任务取消
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user