using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using SqlSugar.Extensions;
|
using WIDESEA_Core;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_Model.Models;
|
|
|
|
namespace WIDESEA_TaskInfoService
|
{
|
public partial class TaskService
|
{
|
/// <summary>
|
/// 空托入库
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public WebResponseContent EmptyInTask(SaveModel saveModel)
|
{
|
lock (text)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
string stationcode = saveModel.MainData["stationcode"].ToString();
|
//string PalletCode = saveModel.MainData["PalletCode"].ToString();
|
//string toaddress = saveModel.MainData["toaddress"].ToString();
|
if (stationcode == "")//异常返回。。。。。。
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据不能为空"}");
|
}
|
Dt_CachePoint endCachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode.Contains("空托库HCK") && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
|
if (endCachePoint == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"未找到空托库出库位可用缓存架"}");
|
}
|
Dt_CachePoint point = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode);
|
if (point == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,未找到此缓存架或物料类型不匹配"}");
|
}
|
Dt_CachePoint points = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
|
if (points == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,此缓存点已被锁定"}");
|
}
|
Dt_Task taskcode = BaseDal.QueryFirst(x => x.SourceAddress == stationcode || x.TargetAddress == stationcode);
|
if (taskcode != null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:该站点已存在任务");
|
}
|
List<Dt_Task> tasks = new List<Dt_Task>();
|
Dt_Task task = new Dt_Task()
|
{
|
CurrentAddress = "",
|
Grade = 1,
|
NextAddress = "",
|
PalletCode = "",
|
Roadway = "",
|
SourceAddress = stationcode,
|
TargetAddress = endCachePoint.PointCode,
|
TaskStatus = AGVTaskStatusEnum.AGV_New.ObjToInt(),
|
TaskType = TaskTypeEnum.AGVCarry.ObjToInt(),
|
Depth = 1,
|
Materialtype = "",
|
TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
Creater = App.User.UserId > 0 ? App.User.UserName : "System",
|
};
|
tasks.Add(task);
|
Repository.AddData(tasks);
|
//修改已存在任务缓存架状态
|
HCJLock(task);
|
content = WebResponseContent.Instance.OK();
|
}
|
catch (Exception ex)
|
{
|
content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{ex.Message}");
|
}
|
return content;
|
}
|
|
}
|
/// <summary>
|
/// 空托出库
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public WebResponseContent EmptyOutTask(SaveModel saveModel)
|
{
|
lock (text)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
string stationcode = saveModel.MainData["stationcode"].ToString();
|
//string PalletCode = saveModel.MainData["PalletCode"].ToString();
|
//string toaddress = saveModel.MainData["toaddress"].ToString();
|
if (stationcode == "")//异常返回。。。。。。
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据不能为空"}");
|
}
|
Dt_CachePoint endCachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode.Contains("空托库HCK") && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
|
if (endCachePoint == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"未找到空托库入库位可用缓存架"}");
|
}
|
Dt_CachePoint point = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode);
|
if (point == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,未找到此缓存架或物料类型不匹配"}");
|
}
|
Dt_CachePoint points = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
|
if (points == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,此缓存点已被锁定"}");
|
}
|
Dt_Task taskcode = BaseDal.QueryFirst(x => x.SourceAddress == stationcode || x.TargetAddress == stationcode);
|
if (taskcode != null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:该站点已存在任务");
|
}
|
List<Dt_Task> tasks = new List<Dt_Task>();
|
Dt_Task task = new Dt_Task()
|
{
|
CurrentAddress = "",
|
Grade = 1,
|
NextAddress = "",
|
PalletCode = "",
|
Roadway = "",
|
SourceAddress = stationcode,
|
TargetAddress = endCachePoint.PointCode,
|
TaskStatus = AGVTaskStatusEnum.AGV_New.ObjToInt(),
|
TaskType = TaskTypeEnum.AGVCarry.ObjToInt(),
|
Depth = 1,
|
Materialtype = "",
|
TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
Creater = App.User.UserId > 0 ? App.User.UserName : "System",
|
};
|
tasks.Add(task);
|
Repository.AddData(tasks);
|
//修改已存在任务缓存架状态
|
HCJLock(task);
|
content = WebResponseContent.Instance.OK();
|
}
|
catch (Exception ex)
|
{
|
content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{ex.Message}");
|
}
|
return content;
|
}
|
}
|
/// <summary>
|
/// 半成品发货
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public WebResponseContent PartiallyTask(SaveModel saveModel)
|
{
|
lock (text)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
string stationcode = saveModel.MainData["stationcode"].ToString();
|
string PalletCode = saveModel.MainData["PalletCode"].ToString();
|
string toaddress = saveModel.MainData["toaddress"].ToString();
|
if (stationcode == "" || PalletCode == "" || toaddress == "")//异常返回。。。。。。
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据不能为空"}");
|
}
|
Dt_CachePoint endCachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.Materialtype == PalletCode && x.PointName == toaddress && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
|
if (endCachePoint == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"未找到终点区域可用缓存架"}");
|
}
|
Dt_CachePoint point = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode);// && x.Materialtype == PalletCode
|
if (point == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,未找到此缓存架或物料类型不匹配"}");
|
}
|
Dt_CachePoint points = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
|
if (points == null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,此缓存点已被锁定"}");
|
}
|
Dt_Task taskcode = BaseDal.QueryFirst(x => x.SourceAddress == stationcode || x.TargetAddress == stationcode);
|
if (taskcode != null)
|
{
|
return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:该站点已存在任务");
|
}
|
List<Dt_Task> tasks = new List<Dt_Task>();
|
Dt_Task task = new Dt_Task()
|
{
|
CurrentAddress = "",
|
Grade = 1,
|
NextAddress = "",
|
PalletCode = "",
|
Roadway = "",
|
SourceAddress = stationcode,
|
TargetAddress = endCachePoint.PointCode,
|
TaskStatus = AGVTaskStatusEnum.AGV_New.ObjToInt(),
|
TaskType = TaskTypeEnum.AGVCarry.ObjToInt(),
|
Depth = 1,
|
Materialtype = PalletCode,
|
TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
Creater = App.User.UserId > 0 ? App.User.UserName : "System",
|
};
|
tasks.Add(task);
|
Repository.AddData(tasks);
|
//修改已存在任务缓存架状态
|
HCJLock(task);
|
content = WebResponseContent.Instance.OK();
|
}
|
catch (Exception ex)
|
{
|
content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{ex.Message}");
|
}
|
return content;
|
}
|
}
|
/// <summary>
|
/// 确认收货
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public WebResponseContent ConfirmTask(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
string stationcode = saveModel.MainData["stationcode"].ToString();
|
//string PalletCode = saveModel.MainData["PalletCode"].ToString();
|
if (stationcode == "")//异常返回。。。。。。|| PalletCode == ""
|
{
|
return content = WebResponseContent.Instance.Error($"收货异常,错误信息:{"扫码数据不能为空"}");
|
}
|
Dt_CachePoint cachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && (x.PointStatus == LocationStatusEnum.Lock.ObjToInt() || x.PointStatus == LocationStatusEnum.InStock.ObjToInt()));//&& x.Materialtype == PalletCode
|
if (cachePoint == null)
|
{
|
return content = WebResponseContent.Instance.Error($"收货异常,错误信息:{"缓存位不是锁定状态"}");
|
}
|
Dt_CachePoint point = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode);// && x.Materialtype == PalletCode
|
if (point == null)
|
{
|
return content = WebResponseContent.Instance.Error($"收货异常,错误信息:{"扫码数据异常,未找到此缓存架或物料类型不匹配"}");
|
}
|
Dt_Task taskcode = BaseDal.QueryFirst(x => (x.SourceAddress == stationcode || x.TargetAddress == stationcode));
|
if (taskcode != null)
|
{
|
return content = WebResponseContent.Instance.Error($"收货异常,错误信息:该站点已存在任务");
|
}
|
cachePoint.PointStatus = LocationStatusEnum.Free.ObjToInt();
|
_basicService.CachePointService.Repository.UpdateData(cachePoint);
|
content = WebResponseContent.Instance.OK();
|
}
|
catch (Exception ex)
|
{
|
|
content = WebResponseContent.Instance.Error($"收货异常,错误信息:{ex.Message}");
|
}
|
return content;
|
}
|
}
|
}
|