signalr 取消,长时间会有问题,打开浏览器会白屏
对接erp,接口 线边任务完成根据detailid,分入库 出库报工 todo 成品的报工(定时器回传 or 入库/拣货的时候回传)
This commit is contained in:
1 parent
00119151c9
commit
c3ec557c4d
19 files changed
+403
-362
No files matched your search
@@ -84,8 +84,8 @@ namespace HHWMS.Web
|
||||
return ApiResultError($"处理请求时发生错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 满入处理
|
||||
/// </summary>
|
||||
@@ -100,14 +100,14 @@ namespace HHWMS.Web
|
||||
{
|
||||
return ApiResultError(msg: "未找到任务!");
|
||||
}
|
||||
|
||||
|
||||
// 更新旧仓位
|
||||
var oldLoc = _unitWork.FindSingle<Location>(x => x.Code == task.ToLocation);
|
||||
oldLoc.ContainerCode = "FullIn";
|
||||
oldLoc.UpdateBy = "FullIn";
|
||||
oldLoc.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(oldLoc);
|
||||
|
||||
|
||||
//查找新仓位
|
||||
var locationVm = Wtm.CreateVM<LocationVM>();
|
||||
var res = locationVm.GetMoveLocation(oldLoc);
|
||||
@@ -131,11 +131,11 @@ namespace HHWMS.Web
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApiResultError(msg:res.Message);
|
||||
return ApiResultError(msg: res.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 空出处理
|
||||
/// </summary>
|
||||
@@ -149,31 +149,32 @@ namespace HHWMS.Web
|
||||
{
|
||||
return ApiResultError(msg: "未找到任务!");
|
||||
}
|
||||
|
||||
//1. 更新容器
|
||||
var container = _unitWork.FindSingle<Container>(x => x.Code == task.ContainerCode);
|
||||
container.UpdateBy = "EmptyOut";
|
||||
container.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(container);
|
||||
|
||||
|
||||
//2. 更新库位
|
||||
var location = _unitWork.FindSingle<Location>(x => x.Code == task.FromLocation);
|
||||
location.UpdateBy = "EmptyOut";
|
||||
location.UpdateTime = DateTime.Now;
|
||||
location.ContainerStatus = LocationStatus.空仓位;
|
||||
_unitWork.Update(location);
|
||||
|
||||
|
||||
//3. 更新任务
|
||||
task.UpdateBy = "EmptyOut";
|
||||
task.UpdateTime = DateTime.Now;
|
||||
task.ErrorMsg = "空出";
|
||||
|
||||
|
||||
|
||||
|
||||
var taskHistory = _mapper.Map<TaskHeaderHistory>(task);
|
||||
_unitWork.Add(taskHistory);
|
||||
_unitWork.Delete(task);
|
||||
|
||||
//4. 更新库存
|
||||
_unitWork.BatchUpdate<Inventory>(x => x.ContainerCode == task.ContainerCode,x => new Inventory()
|
||||
_unitWork.BatchUpdate<Inventory>(x => x.ContainerCode == task.ContainerCode, x => new Inventory()
|
||||
{
|
||||
LocationCode = "空出",
|
||||
UpdateBy = "EmptyOut",
|
||||
@@ -181,8 +182,8 @@ namespace HHWMS.Web
|
||||
});
|
||||
return ApiResult();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取货错处理
|
||||
/// </summary>
|
||||
@@ -196,13 +197,14 @@ namespace HHWMS.Web
|
||||
{
|
||||
return ApiResultError(msg: "未找到任务!");
|
||||
}
|
||||
|
||||
var outLoc = _unitWork.FindSingle<Location>(x => x.Code == task.FromLocation);
|
||||
var outTask = _unitWork.FindSingle<TaskHeader>(x => x.FromLocation == outLoc.ContiguousCode);
|
||||
if (outTask != null)
|
||||
{
|
||||
return ApiResultError(msg: $"外侧仓位 {outLoc.Code} 已有出库任务!");
|
||||
}
|
||||
|
||||
|
||||
// 生成外侧仓位的移库任务
|
||||
var locationVm = Wtm.CreateVM<LocationVM>();
|
||||
var moveLocRes = locationVm.GetMoveLocation(outLoc);
|
||||
@@ -221,7 +223,7 @@ namespace HHWMS.Web
|
||||
CreateBy = "PickError",
|
||||
CreateTime = DateTime.Now,
|
||||
};
|
||||
|
||||
|
||||
var sendTaskRes = locationVm.SendWcsTask(taskHeader);
|
||||
if (sendTaskRes.Status)
|
||||
{
|
||||
@@ -241,9 +243,10 @@ namespace HHWMS.Web
|
||||
{
|
||||
return ApiResultError(msg: moveLocRes.Message);
|
||||
}
|
||||
|
||||
|
||||
return ApiResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 状态返回(带防抖)
|
||||
/// </summary>
|
||||
@@ -303,17 +306,17 @@ namespace HHWMS.Web
|
||||
|
||||
// 根据请求的高度,分配仓位
|
||||
var locationVm = Wtm.CreateVM<LocationVM>();
|
||||
|
||||
|
||||
request.RoadWay = 2;
|
||||
|
||||
|
||||
// 默认1 模具2 低仓位3 高仓位4 成品大于4 超限 模具大于2 超限
|
||||
if(request.Height == 2)
|
||||
if (request.Height == 2)
|
||||
request.Height = 999;
|
||||
else if (request.Height == 3)
|
||||
request.Height = 1100;
|
||||
else
|
||||
request.Height = 0;
|
||||
|
||||
|
||||
var container = _unitWork.FindSingle<Container>(x => x.Code == task.ContainerCode);
|
||||
if (container != null)
|
||||
{
|
||||
@@ -331,6 +334,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
return ApiResultError(msg: "模具超高,未找到合适的仓位");
|
||||
}
|
||||
|
||||
var location = locationVm.GetLocation(request).Data;
|
||||
if (location != null)
|
||||
{
|
||||
@@ -382,40 +386,67 @@ namespace HHWMS.Web
|
||||
{
|
||||
var containerconfig = _unitWork.Find<SysDictData>(x => x.DictType == "ContainerConfig")
|
||||
.ToList();
|
||||
int ContainerWeight = int.Parse(containerconfig.FirstOrDefault(x => x.DictLabelUs.ToLower() == "container")?.DictValue);
|
||||
int SmallContainerWeight = int.Parse(containerconfig.FirstOrDefault(x => x.ID == inventory.Flag)?.DictValue);
|
||||
int ContainerWeight = int.Parse(containerconfig
|
||||
.FirstOrDefault(x => x.DictLabelUs.ToLower() == "container")?.DictValue);
|
||||
int SmallContainerWeight =
|
||||
int.Parse(containerconfig.FirstOrDefault(x => x.ID == inventory.Flag)?.DictValue);
|
||||
|
||||
var material =
|
||||
_unitWork.FindSingle<Material>(x => x.MaterialCode == inventory.MaterialCode);
|
||||
inventory.Qty = (int)((request.Weight * 100 - ContainerWeight - inventory.TaskQty * SmallContainerWeight) / (material.Qty ?? 1));
|
||||
inventory.Qty =
|
||||
(int)((request.Weight * 100 - ContainerWeight -
|
||||
inventory.TaskQty * SmallContainerWeight) / (material.Qty ?? 1));
|
||||
inventory.Qty = inventory.Qty > 0 ? inventory.Qty : 0;
|
||||
|
||||
// ERP相关
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(inventory.ReceiptDetailId))
|
||||
{
|
||||
// ERP相关 入库报工
|
||||
var finishInRequest = new FinishInRequest
|
||||
{
|
||||
Main = new FinishInMain
|
||||
{
|
||||
ErpCode = "999", // 账套号
|
||||
InCode = _unitWork.GetSerialNumber(inventory.SourceCode), // 报工单号(上游单号)
|
||||
InDate = (inventory.CreateTime ?? DateTime.Now).ToString("yyyy-MM-dd"), // 报工日期
|
||||
StepCode = inventory.BatchCode, // 工序(批次编码)
|
||||
WorkerCode = inventory.CreateBy, // 工人编码(创建人)
|
||||
Maker = _unitWork.FindSingle<FrameworkUser>(x =>
|
||||
x.ITCode == inventory.CreateBy).Name // 制单人(校验员)
|
||||
ErpCode = "002", // 账套号
|
||||
InCode = _unitWork.GetSerialNumber("RW"), // 报工单号(上游单号)
|
||||
InDate = (inventory.CreateTime ?? DateTime.Now)
|
||||
.ToString("yyyy-MM-dd"), // 报工日期
|
||||
StepCode = inventory.BatchCode, // 工序(批次编码)
|
||||
WorkerCode = inventory.CreateBy, // 工人编码(创建人)
|
||||
Maker = _unitWork.FindSingle<FrameworkUser>(x =>
|
||||
x.ITCode == inventory.CreateBy).Name // 制单人(校验员)
|
||||
},
|
||||
Details = new List<FinishInDetail>()
|
||||
};
|
||||
|
||||
// 根据库存构建明细
|
||||
finishInRequest.Details.Add(new FinishInDetail
|
||||
if (task.TaskType == TaskTypeEnum.入库)
|
||||
{
|
||||
MoDetailId = inventory.ReceiptDetailId, // 生产订单明细(ERP明细ID)
|
||||
InvCode = inventory.MaterialCode, // 物料号
|
||||
Qty = inventory.Qty ?? 0 // 完工数量
|
||||
});
|
||||
|
||||
// 根据库存构建明细
|
||||
finishInRequest.Details.Add(new FinishInDetail
|
||||
{
|
||||
MoDetailId = inventory.ReceiptDetailId, // 生产订单明细(ERP明细ID)
|
||||
InvCode = inventory.MaterialCode, // 物料号
|
||||
Qty = inventory.Qty ?? 0 // 完工数量
|
||||
});
|
||||
}
|
||||
else if (task.TaskType == TaskTypeEnum.出库)
|
||||
{
|
||||
finishInRequest.Details.Add(new FinishInDetail
|
||||
{
|
||||
MaterialDetails = new List<MaterialDetail>
|
||||
{
|
||||
new MaterialDetail
|
||||
{
|
||||
MoDetailId = inventory.ReceiptDetailId, // 生产订单明细ID
|
||||
InvCode = inventory.MaterialCode, // 物料号
|
||||
Qty = (decimal)inventory.Qty // 完工数量(空值兜底为0)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 调用ERP接口
|
||||
var apiResult = await Wtm.CallAPI<FinishInResponse>("ERP", "FinishIn", HttpMethodEnum.POST, finishInRequest);
|
||||
var apiResult = await Wtm.CallAPI<FinishInResponse>("ERP", "FinishIn",
|
||||
HttpMethodEnum.POST,
|
||||
finishInRequest);
|
||||
|
||||
if (apiResult.Data != null && apiResult.Data.Result)
|
||||
{
|
||||
@@ -426,6 +457,7 @@ namespace HHWMS.Web
|
||||
inventory.UploadErpFlag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (task.TaskType != TaskTypeEnum.移库)
|
||||
{
|
||||
@@ -434,7 +466,7 @@ namespace HHWMS.Web
|
||||
invTran.Type = task.TaskType == TaskTypeEnum.入库
|
||||
? InventoryTranType.入库
|
||||
: InventoryTranType.出库;
|
||||
|
||||
|
||||
invTrans.Add(invTran);
|
||||
}
|
||||
else
|
||||
@@ -442,16 +474,16 @@ namespace HHWMS.Web
|
||||
// 创建库存交易记录 放到任务完成,计算数量信息
|
||||
var invTran = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invTran.Type = InventoryTranType.入库;
|
||||
|
||||
|
||||
invTrans.Add(invTran);
|
||||
|
||||
|
||||
var invTran2 = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invTran2.Type = InventoryTranType.出库;
|
||||
|
||||
|
||||
invTrans.Add(invTran2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inventory.TaskStatus = InventoryTaskStatusEnum.Idle;
|
||||
}
|
||||
|
||||
@@ -477,7 +509,7 @@ namespace HHWMS.Web
|
||||
container.LocationCode = task.TaskType == TaskTypeEnum.出库 ? "" : task.ToLocation;
|
||||
container.IsLock = ContainerLockEnum.未锁;
|
||||
container.UpdateTime = DateTime.Now;
|
||||
|
||||
|
||||
_unitWork.Update(container);
|
||||
}
|
||||
|
||||
@@ -516,7 +548,7 @@ namespace HHWMS.Web
|
||||
// 处理移库:同时更新源库位和目标库位
|
||||
// 1. 更新源库位(移出后变为空)
|
||||
var sourceLocation = _unitWork.FindSingle<Location>(x => x.Code == task.FromLocation);
|
||||
|
||||
|
||||
// 2. 更新目标库位(移入后有容器)
|
||||
var targetLocation = _unitWork.FindSingle<Location>(x => x.Code == task.ToLocation);
|
||||
if (targetLocation != null)
|
||||
@@ -527,7 +559,7 @@ namespace HHWMS.Web
|
||||
targetLocation.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(targetLocation);
|
||||
}
|
||||
|
||||
|
||||
if (sourceLocation != null)
|
||||
{
|
||||
sourceLocation.ContainerCode = "";
|
||||
@@ -566,8 +598,7 @@ namespace HHWMS.Web
|
||||
}
|
||||
|
||||
#region 暂时无用
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 请求入库(带防抖)
|
||||
/// </summary>
|
||||
@@ -595,7 +626,7 @@ namespace HHWMS.Web
|
||||
await Task.Delay(1000); // 模拟异步处理
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 请求空闲库位(带防抖)
|
||||
/// </summary>
|
||||
@@ -660,7 +691,7 @@ namespace HHWMS.Web
|
||||
|
||||
return ApiResult(new { LocationCode = location?.Code });
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user