signalr 取消,长时间会有问题,打开浏览器会白屏
对接erp,接口 线边任务完成根据detailid,分入库 出库报工 todo 成品的报工(定时器回传 or 入库/拣货的时候回传)
This commit is contained in:
parent
00119151c9
commit
c3ec557c4d
@ -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
|
||||
}
|
||||
}
|
||||
@ -5,13 +5,13 @@
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="Entity.MaterialCode" disabled/>
|
||||
<wt:textbox field="Entity.MaterialType" disabled/>
|
||||
<wt:textbox field="Entity.MaterialName" />
|
||||
<wt:textbox field="Entity.MaterialSpec" />
|
||||
<wt:textbox field="Entity.MaterialUnit" />
|
||||
<wt:textbox field="Entity.MaterialName" disabled/>
|
||||
<wt:textbox field="Entity.MaterialSpec" disabled/>
|
||||
<wt:textbox field="Entity.MaterialUnit" disabled/>
|
||||
<wt:textbox field="Entity.Batch" />
|
||||
<wt:textbox field="Entity.Lot" />
|
||||
<wt:textbox field="Entity.CompanyCode" />
|
||||
<wt:textbox field="Entity.SupplierCode" />
|
||||
<wt:textbox field="Entity.SupplierCode" disabled/>
|
||||
<wt:textbox field="Entity.Qty" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using HHWMS.Web;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Area("inventory")]
|
||||
[Public]
|
||||
[ActionDescription("库存管理")]
|
||||
[ApiController]
|
||||
[Route("api/Inventory")]
|
||||
public partial class InventoryApiController : BaseApiController
|
||||
{
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost("Search")]
|
||||
[Public]
|
||||
public IActionResult Search(InventoryApiSearcher searcher)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var vm = Wtm.CreateVM<InventoryApiListVM>(passInit: true);
|
||||
searcher.SortInfo = new SortInfo()
|
||||
{
|
||||
Property = "MaterialCode",
|
||||
Direction = SortDir.Asc
|
||||
};
|
||||
searcher.IsPlainText = false;
|
||||
searcher.IsEnumToString = true;
|
||||
vm.Searcher = searcher;
|
||||
|
||||
if (searcher.WareHouse.ToLower() == "mj")
|
||||
vm.Searcher.ZoneId = 1025;
|
||||
else if (searcher.WareHouse.ToLower() == "xb")
|
||||
vm.Searcher.ZoneId = 1027;
|
||||
else if (searcher.WareHouse.ToLower() == "cp")
|
||||
vm.Searcher.ZoneId = 1028;
|
||||
|
||||
var data = vm.GetJson();
|
||||
return Content(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorJson());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -549,6 +549,10 @@ namespace HHWMS.Web.Controllers
|
||||
{
|
||||
return FFResult().Alert("所选库存没关联订单,无需回传!").RefreshGrid();
|
||||
}
|
||||
if (inv.UploadErpFlag == 0)
|
||||
{
|
||||
return FFResult().Alert("所选库存已报工回传,无需再次回传!").RefreshGrid();
|
||||
}
|
||||
|
||||
// 构建ERP请求
|
||||
// 字段映射参照 ReceiptInController:
|
||||
@ -562,8 +566,8 @@ namespace HHWMS.Web.Controllers
|
||||
{
|
||||
Main = new FinishInMain
|
||||
{
|
||||
ErpCode = "999", // 账套号
|
||||
InCode = $"{inv.SourceCode}-{DateTime.Now.Ticks}", // 报工单号(上游单号)
|
||||
ErpCode = "002", // 账套号
|
||||
InCode = _unitWork.GetSerialNumber("RW"), // 报工单号(上游单号)
|
||||
InDate = (inv.CreateTime ?? DateTime.Now).ToString("yyyy-MM-dd"), // 报工日期
|
||||
StepCode = inv.BatchCode, // 工序(批次编码)
|
||||
WorkerCode = inv.CreateBy, // 工人编码(创建人)
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class InventoryApiListVM : BasePagedListVM<InventoryApi_View, InventoryApiSearcher>
|
||||
{
|
||||
|
||||
protected override IEnumerable<IGridColumn<InventoryApi_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<InventoryApi_View>>{
|
||||
this.MakeGridHeader(x => x.WareHouse),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.FigureNo),
|
||||
this.MakeGridHeader(x => x.MaterialName),
|
||||
this.MakeGridHeader(x => x.MaterialSpec),
|
||||
this.MakeGridHeader(x => x.BatchCode),
|
||||
this.MakeGridHeader(x => x.SuFigureNo),
|
||||
this.MakeGridHeader(x => x.Qty),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<InventoryApi_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<Inventory>()
|
||||
.Where(x => x.ZoneId == Searcher.ZoneId)
|
||||
.CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
|
||||
.CheckContain(Searcher.FigureNo, x=>x.MaterialType)
|
||||
.CheckContain(Searcher.MaterialName, x=>x.MaterialName)
|
||||
.CheckContain(Searcher.MaterialSpec, x=>x.MaterialSpec)
|
||||
.CheckContain(Searcher.BatchCode, x=>x.BatchCode)
|
||||
.CheckContain(Searcher.SuFigureNo, x=>x.SupplierCode)
|
||||
.Select(x => new InventoryApi_View
|
||||
{
|
||||
WareHouse = x.ZoneId == 1027 ? "xb" : x.ZoneId == 1028 ? "cp" : "mj" ,
|
||||
MaterialCode = x.MaterialCode,
|
||||
FigureNo = x.MaterialType,
|
||||
MaterialName = x.MaterialName,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
BatchCode = x.BatchCode,
|
||||
SuFigureNo = x.SupplierCode,
|
||||
LocationCode = x.LocationCode,
|
||||
Qty = x.Qty,
|
||||
}).OrderBy(x => x.MaterialCode);
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class InventoryApi_View : TopBasePoco {
|
||||
public String WareHouse { get; set; }
|
||||
public string MaterialCode { get; set; }
|
||||
public string MaterialName { get; set; }
|
||||
public string MaterialSpec { get; set; }
|
||||
public string BatchCode { get; set; }
|
||||
public string SuFigureNo { get; set; }
|
||||
public string FigureNo { get; set; }
|
||||
public string LocationCode { get; set; }
|
||||
public decimal? Qty { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class InventoryApiSearcher : BaseSearcher
|
||||
{
|
||||
public int ZoneId { get; set; }
|
||||
[Display(Name = "Inventory.MaterialCode")]
|
||||
public String MaterialCode { get; set; }
|
||||
[Display(Name = "Inventory.MaterialType")]
|
||||
public String FigureNo { get; set; }
|
||||
[Display(Name = "Inventory.MaterialName")]
|
||||
public String MaterialName { get; set; }
|
||||
[Display(Name = "Inventory.MaterialSpec")]
|
||||
public String MaterialSpec { get; set; }
|
||||
[Display(Name = "Inventory.Batch")]
|
||||
public String BatchCode { get; set; }
|
||||
[Display(Name = "Inventory.SupplierCode")]
|
||||
public String SuFigureNo { get; set; }
|
||||
public String WareHouse { get; set; }
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -39,6 +39,10 @@ namespace HHWMS.Web
|
||||
public String Status { get; set; }
|
||||
[Display(Name = "Inventory.TaskStatus")]
|
||||
public InventoryTaskStatusEnum? TaskStatus { get; set; }
|
||||
|
||||
public string SupplierCode { get; set; }
|
||||
public string BatchCode { get; set; }
|
||||
public string MaterialSpec { get; set; }
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
|
||||
@ -267,7 +267,7 @@ namespace HHWMS.Web.Controllers
|
||||
// 调用 ERP 接口获取该订单的最新数据
|
||||
var request = new LoadMoDetailListRequest
|
||||
{
|
||||
ErpCode = "999",
|
||||
ErpCode = "002",
|
||||
MoCode = receiptCode, // 使用生产订单号查询
|
||||
Size = 100,
|
||||
Page = 1
|
||||
|
||||
@ -60,7 +60,7 @@ namespace HHWMS.Web.Controllers
|
||||
{
|
||||
var request = new LoadInventoryRequest
|
||||
{
|
||||
ErpCode = "999",
|
||||
ErpCode = "002",
|
||||
InvDefine1 = keyword,
|
||||
Size = 15,
|
||||
Page = 1
|
||||
@ -185,7 +185,8 @@ namespace HHWMS.Web.Controllers
|
||||
[HttpPost]
|
||||
public IActionResult GetOperators()
|
||||
{
|
||||
var users = _unitWork.Find<FrameworkUser>(x => x.ITCode != "Admin")
|
||||
var users = _unitWork.Find<FrameworkUser>(x => x.ITCode != "Admin"
|
||||
&& x.ITCode.Length > 5)
|
||||
.Select(x => new
|
||||
{
|
||||
value = x.ITCode,
|
||||
@ -443,13 +444,13 @@ namespace HHWMS.Web.Controllers
|
||||
// 调用WCS任务下发接口
|
||||
// tran.Commit();
|
||||
// return Json(new { Code = 200, Msg = "入库成功", Data = new { TaskNo = taskNo } });
|
||||
// var wcsResult = Wtm
|
||||
// .CallAPI<WCSTaskResponse>("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
|
||||
var wcsResult = new WCSTaskResponse()
|
||||
{
|
||||
Success = true,
|
||||
Msg = "Success"
|
||||
};
|
||||
var wcsResult = Wtm
|
||||
.CallAPI<WCSTaskResponse>("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
|
||||
// var wcsResult = new WCSTaskResponse()
|
||||
// {
|
||||
// Success = true,
|
||||
// Msg = "Success"
|
||||
// };
|
||||
if (wcsResult != null && wcsResult.Success)
|
||||
{
|
||||
// WCS任务下发成功,提交事务
|
||||
|
||||
@ -191,7 +191,8 @@ namespace HHWMS.Web.Controllers
|
||||
BatchCode = batchCode,
|
||||
TaskStatus = InventoryTaskStatusEnum.Locked,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode,
|
||||
UploadErpFlag = 0
|
||||
};
|
||||
_unitWork.Add(inventory);
|
||||
|
||||
|
||||
@ -33,17 +33,17 @@ namespace HHWMS.Web
|
||||
//this.MakeGridHeader(x => x.Code_view),
|
||||
//this.MakeGridHeader(x => x.ZoneCode),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
//this.MakeGridHeader(x => x.MaterialType),
|
||||
this.MakeGridHeader(x => x.MaterialType),
|
||||
// this.MakeGridHeader(x => x.Batch),
|
||||
this.MakeGridHeader(x => x.MaterialName),
|
||||
//this.MakeGridHeader(x => x.MaterialSpec),
|
||||
this.MakeGridHeader(x => x.MaterialUnit),
|
||||
this.MakeGridHeader(x => x.Batch),
|
||||
//this.MakeGridHeader(x => x.Lot).SetHide(),
|
||||
//this.MakeGridHeader(x => x.ManufactureDate),
|
||||
//this.MakeGridHeader(x => x.ExpirationDate),
|
||||
//this.MakeGridHeader(x => x.CompanyCode),
|
||||
this.MakeGridHeader(x => x.SupplierCode),
|
||||
this.MakeGridHeader(x => x.CompletedQty),
|
||||
// this.MakeGridHeader(x => x.CompletedQty),
|
||||
this.MakeGridHeader(x => x.Qty),
|
||||
//this.MakeGridHeader(x => x.InventoryStatus),
|
||||
this.MakeGridHeader(x => x.Status)
|
||||
|
||||
@ -38,12 +38,12 @@ namespace HHWMS.Web
|
||||
{
|
||||
InitVM();
|
||||
return new List<GridColumn<ReceiptHeader_View>>{
|
||||
//this.MakeGridHeader(x => x.SourceCode),
|
||||
this.MakeGridHeader(x => x.Code).SetFormat((a,b) =>
|
||||
{
|
||||
string rv = UIService.MakeScriptButton(ButtonTypesEnum.Link,a.Code,$"details('{a.ID}')");
|
||||
return rv;
|
||||
}),
|
||||
this.MakeGridHeader(x => x.SourceCode),
|
||||
this.MakeGridHeader(x => x.BillType)
|
||||
.SetFormat((a, b) =>
|
||||
{
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
<template #operations="{ record }">
|
||||
<a-space>
|
||||
<a-button type="text" status="danger" @@click="handleDelete(record)">删除</a-button>
|
||||
<a-button type="text" @@click="handleEdit(record)">修改</a-button>
|
||||
@* <a-button type="text" @@click="handleEdit(record)">修改</a-button> *@
|
||||
<a-button type="text" @@click="handleDeduct(record)">扣料</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
92
HHWMS.Web/Areas/System/Controllers/jobs/FinishInJob.cs
Normal file
92
HHWMS.Web/Areas/System/Controllers/jobs/FinishInJob.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Models;
|
||||
using Quartz;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Support.Quartz;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
//[QuartzRepeat(10,10, true, 30)]
|
||||
[PersistJobDataAfterExecution]
|
||||
[DisallowConcurrentExecution]
|
||||
public class FinishInJob : WtmJob
|
||||
{
|
||||
public override async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
var _unitwork = new UnitWork(Wtm);
|
||||
|
||||
var inv = _unitwork.FindSingle<Inventory>(x => x.UploadErpFlag == 0
|
||||
&& x.TaskStatus != InventoryTaskStatusEnum.Locked
|
||||
&& !string.IsNullOrEmpty(x.SourceCode)
|
||||
);
|
||||
|
||||
var request = new FinishInRequest
|
||||
{
|
||||
Main = new FinishInMain
|
||||
{
|
||||
ErpCode = "002", // 账套号
|
||||
InCode = _unitwork.GetSerialNumber("RW"), // 报工单号(上游单号)
|
||||
InDate = (inv.CreateTime ?? DateTime.Now).ToString("yyyy-MM-dd"), // 报工日期
|
||||
StepCode = inv.BatchCode, // 工序(批次编码)
|
||||
WorkerCode = inv.CreateBy, // 工人编码(创建人)
|
||||
Maker = _unitwork.FindSingle<FrameworkUser>(x =>
|
||||
x.ITCode == inv.CreateBy).Name // 制单人(校验员)
|
||||
},
|
||||
Details = new List<FinishInDetail>()
|
||||
};
|
||||
|
||||
// 根据库存构建明细
|
||||
request.Details.Add(new FinishInDetail
|
||||
{
|
||||
MoDetailId = inv.ReceiptDetailId, // 生产订单明细(ERP明细ID)
|
||||
InvCode = inv.MaterialCode, // 物料号
|
||||
Qty = inv.Qty ?? 0 // 完工数量
|
||||
});
|
||||
// 调用ERP接口
|
||||
var apiResult = await Wtm.CallAPI<FinishInResponse>("ERP", "FinishIn", HttpMethodEnum.POST, request);
|
||||
|
||||
if (apiResult.Data != null && apiResult.Data.Result)
|
||||
{
|
||||
inv.UploadErpFlag = 1;
|
||||
_unitwork.Update(inv);
|
||||
}
|
||||
else
|
||||
{
|
||||
inv.UploadErpFlag = 0;
|
||||
_unitwork.Update(inv);
|
||||
}
|
||||
#region 更新时间
|
||||
var job = _unitwork.FindSingle<SysJob>(x =>
|
||||
x.JobName == context.JobDetail.Key.Name
|
||||
);
|
||||
if (job != null)
|
||||
{
|
||||
job.LastFireTime = TimeZoneInfo.ConvertTimeFromUtc(
|
||||
context.FireTimeUtc.DateTime,
|
||||
TimeZoneInfo.Local
|
||||
);
|
||||
// 只执行一次 没有下次执行时间
|
||||
if (context.NextFireTimeUtc != null)
|
||||
{
|
||||
job.NextFireTime = TimeZoneInfo.ConvertTimeFromUtc(
|
||||
context.NextFireTimeUtc.Value.DateTime,
|
||||
TimeZoneInfo.Local
|
||||
);
|
||||
}
|
||||
_unitwork.Update<SysJob>(job);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch(Exception ex) {
|
||||
Wtm.DoLog("ERP报工失败", ActionLogTypesEnum.Job, "FinishInJob", request:"error", result:ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ namespace HHWMS.Web
|
||||
// 调用接口获取ERP订单数据
|
||||
var request = new LoadMoDetailListRequest
|
||||
{
|
||||
ErpCode = "999",
|
||||
ErpCode = "002",
|
||||
Size = 100,
|
||||
Page = 1
|
||||
};
|
||||
|
||||
@ -23,7 +23,7 @@ namespace HHWMS.Web
|
||||
// 调用接口获取ERP用户数据
|
||||
var request = new LoadPersonRequest
|
||||
{
|
||||
ErpCode = "999",
|
||||
ErpCode = "002",
|
||||
Size = 1000,
|
||||
Page = 1
|
||||
};
|
||||
|
||||
@ -73,5 +73,32 @@ namespace HHWMS.Web.Models
|
||||
/// 完工数量,必填
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库明细
|
||||
/// </summary>
|
||||
|
||||
public List<MaterialDetail> MaterialDetails { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库明细
|
||||
/// </summary>
|
||||
public class MaterialDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产订单明细,必填
|
||||
/// </summary>
|
||||
public string MoDetailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料号,必填
|
||||
/// </summary>
|
||||
public string InvCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完工数量,必填
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1023,6 +1023,12 @@
|
||||
<data name="TaskType.Out" xml:space="preserve">
|
||||
<value>出库</value>
|
||||
</data>
|
||||
<data name="FinishIn" xml:space="preserve">
|
||||
<value>报工回传</value>
|
||||
</data>
|
||||
<data name="GetReceiptDetails" xml:space="preserve">
|
||||
<value>获取ERP订单</value>
|
||||
</data>
|
||||
<data name="TaskType.Out1" xml:space="preserve">
|
||||
<value>出 库</value>
|
||||
</data>
|
||||
|
||||
@ -1,285 +1 @@
|
||||
<script>layui.use('index')</script>
|
||||
<script src="/front/signalr.min.js"></script>
|
||||
<script>
|
||||
// SignalR 登录状态管理
|
||||
var loginConnection = null;
|
||||
var heartbeatTimer = null;
|
||||
var userId = '@ViewData["ITCode"]'; // 从后端获取当前用户ID
|
||||
var isForceLogout = false;
|
||||
|
||||
// 服务异常检测
|
||||
var reconnectAttempts = 0; // 重连尝试次数
|
||||
var maxReconnectAttempts = 5; // 最大重连次数
|
||||
var isServerDown = false; // 服务是否宕机
|
||||
var serverDownAlertIndex = null; // 服务宕机弹窗索引
|
||||
var reconnectTimer = null; // 重连定时器
|
||||
|
||||
// 初始化 SignalR 连接
|
||||
function initLoginHub() {
|
||||
loginConnection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("/loginHub")
|
||||
.withAutomaticReconnect({
|
||||
nextRetryDelayInMilliseconds: function(retryContext) {
|
||||
// 自定义重连策略
|
||||
if (retryContext.previousRetryCount < maxReconnectAttempts) {
|
||||
return Math.min(1000 * Math.pow(2, retryContext.previousRetryCount), 30000);
|
||||
}
|
||||
return null; // 停止自动重连
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
// 监听强制登出事件
|
||||
loginConnection.on("ForceLogout", function(message) {
|
||||
isForceLogout = true;
|
||||
stopHeartbeat();
|
||||
stopReconnect();
|
||||
|
||||
// 使用layer弹窗提示
|
||||
layer.alert(message || "您的账号已在其他设备登录,请重新登录", {
|
||||
icon: 0,
|
||||
title: "登录提示",
|
||||
closeBtn: 0,
|
||||
btn: ['确定'],
|
||||
yes: function(index) {
|
||||
layer.close(index);
|
||||
// 重定向到登录页
|
||||
window.location.href = '/Login/Login';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 监听注册成功
|
||||
loginConnection.on("RegisterSuccess", function(message) {
|
||||
console.log("SignalR 登录连接成功:", message);
|
||||
onConnectionRestored();
|
||||
startHeartbeat();
|
||||
});
|
||||
|
||||
// 监听心跳响应
|
||||
loginConnection.on("HeartbeatResponse", function(serverTime) {
|
||||
//console.log("心跳响应:", serverTime);
|
||||
});
|
||||
|
||||
// 连接关闭事件
|
||||
loginConnection.onclose(function(error) {
|
||||
console.log("SignalR 连接已关闭", error);
|
||||
stopHeartbeat();
|
||||
|
||||
if (!isForceLogout) {
|
||||
onConnectionLost();
|
||||
}
|
||||
});
|
||||
|
||||
// 正在重连事件
|
||||
loginConnection.onreconnecting(function(error) {
|
||||
console.log("SignalR 正在重连...", error);
|
||||
reconnectAttempts++;
|
||||
showReconnectingStatus();
|
||||
});
|
||||
|
||||
// 重连成功事件
|
||||
loginConnection.onreconnected(function(connectionId) {
|
||||
console.log("SignalR 重连成功:", connectionId);
|
||||
onConnectionRestored();
|
||||
// 重新注册
|
||||
if (userId) {
|
||||
loginConnection.invoke("Register", userId).catch(function(err) {
|
||||
console.error("重新注册失败:", err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 开始连接
|
||||
startConnection();
|
||||
}
|
||||
|
||||
// 启动连接
|
||||
function startConnection() {
|
||||
if (isForceLogout) return;
|
||||
|
||||
loginConnection.start()
|
||||
.then(function() {
|
||||
console.log("SignalR 连接已建立");
|
||||
onConnectionRestored();
|
||||
// 注册当前用户
|
||||
if (userId) {
|
||||
loginConnection.invoke("Register", userId).catch(function(err) {
|
||||
console.error("注册失败:", err);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.error("SignalR 连接失败:", err);
|
||||
reconnectAttempts++;
|
||||
|
||||
if (reconnectAttempts >= maxReconnectAttempts) {
|
||||
// 达到最大重连次数,显示服务不可用
|
||||
showServerDownAlert();
|
||||
} else {
|
||||
// 继续重连
|
||||
showReconnectingStatus();
|
||||
var delay = Math.min(1000 * Math.pow(2, reconnectAttempts), 30000);
|
||||
reconnectTimer = setTimeout(function() {
|
||||
startConnection();
|
||||
}, delay);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 连接丢失处理
|
||||
function onConnectionLost() {
|
||||
reconnectAttempts = 0;
|
||||
showReconnectingStatus();
|
||||
|
||||
// 手动启动重连
|
||||
reconnectTimer = setTimeout(function() {
|
||||
startConnection();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// 连接恢复处理
|
||||
function onConnectionRestored() {
|
||||
reconnectAttempts = 0;
|
||||
isServerDown = false;
|
||||
hideReconnectingStatus();
|
||||
hideServerDownAlert();
|
||||
}
|
||||
|
||||
// 显示重连中状态
|
||||
function showReconnectingStatus() {
|
||||
if ($('#reconnecting-status').length === 0) {
|
||||
$('body').append(
|
||||
'<div id="reconnecting-status" style="position:fixed;top:0;left:0;right:0;background:#ff9800;color:#fff;text-align:center;padding:8px;z-index:99999;font-size:14px;">' +
|
||||
'<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i> ' +
|
||||
'正在连接服务器... (尝试 ' + reconnectAttempts + '/' + maxReconnectAttempts + ')' +
|
||||
'</div>'
|
||||
);
|
||||
} else {
|
||||
$('#reconnecting-status').html(
|
||||
'<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i> ' +
|
||||
'正在连接服务器... (尝试 ' + reconnectAttempts + '/' + maxReconnectAttempts + ')'
|
||||
).show();
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏重连中状态
|
||||
function hideReconnectingStatus() {
|
||||
$('#reconnecting-status').hide();
|
||||
}
|
||||
|
||||
// 显示服务不可用弹窗
|
||||
function showServerDownAlert() {
|
||||
if (isServerDown) return;
|
||||
isServerDown = true;
|
||||
hideReconnectingStatus();
|
||||
|
||||
// 显示服务不可用状态栏
|
||||
if ($('#server-down-status').length === 0) {
|
||||
$('body').append(
|
||||
'<div id="server-down-status" style="position:fixed;top:0;left:0;right:0;background:#f44336;color:#fff;text-align:center;padding:8px;z-index:99999;font-size:14px;">' +
|
||||
'<i class="layui-icon layui-icon-close-fill"></i> ' +
|
||||
'服务器连接已断开,请检查网络或联系管理员 ' +
|
||||
'<button onclick="manualReconnect()" style="margin-left:10px;padding:2px 10px;cursor:pointer;background:#fff;color:#f44336;border:none;border-radius:3px;">重新连接</button>' +
|
||||
'</div>'
|
||||
);
|
||||
} else {
|
||||
$('#server-down-status').show();
|
||||
}
|
||||
|
||||
// 弹窗提示
|
||||
if (!serverDownAlertIndex) {
|
||||
serverDownAlertIndex = layer.confirm('服务器连接已断开,可能是网络问题或服务器维护中。<br/>是否重新连接?', {
|
||||
icon: 2,
|
||||
title: "连接异常",
|
||||
btn: ['重新连接', '稍后再试'],
|
||||
closeBtn: 0
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
serverDownAlertIndex = null;
|
||||
manualReconnect();
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
serverDownAlertIndex = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏服务不可用弹窗
|
||||
function hideServerDownAlert() {
|
||||
$('#server-down-status').hide();
|
||||
if (serverDownAlertIndex) {
|
||||
layer.close(serverDownAlertIndex);
|
||||
serverDownAlertIndex = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 手动重连
|
||||
function manualReconnect() {
|
||||
reconnectAttempts = 0;
|
||||
isServerDown = false;
|
||||
hideServerDownAlert();
|
||||
showReconnectingStatus();
|
||||
startConnection();
|
||||
}
|
||||
|
||||
// 停止重连
|
||||
function stopReconnect() {
|
||||
if (reconnectTimer) {
|
||||
clearTimeout(reconnectTimer);
|
||||
reconnectTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 开始心跳
|
||||
function startHeartbeat() {
|
||||
stopHeartbeat();
|
||||
heartbeatTimer = setInterval(function() {
|
||||
if (loginConnection && loginConnection.state === signalR.HubConnectionState.Connected) {
|
||||
loginConnection.invoke("Heartbeat", userId).catch(function(err) {
|
||||
console.error("心跳发送失败:", err);
|
||||
});
|
||||
}
|
||||
}, 30000); // 每30秒发送一次心跳
|
||||
}
|
||||
|
||||
// 停止心跳
|
||||
function stopHeartbeat() {
|
||||
if (heartbeatTimer) {
|
||||
clearInterval(heartbeatTimer);
|
||||
heartbeatTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载完成后初始化
|
||||
$(document).ready(function() {
|
||||
if (userId) {
|
||||
initLoginHub();
|
||||
}
|
||||
|
||||
// 页面关闭时断开连接
|
||||
$(window).on('beforeunload', function() {
|
||||
stopReconnect();
|
||||
stopHeartbeat();
|
||||
if (loginConnection) {
|
||||
loginConnection.stop();
|
||||
}
|
||||
});
|
||||
|
||||
// 页面从隐藏状态变为可见时,检查连接状态
|
||||
$(document).on('visibilitychange', function() {
|
||||
if (document.visibilityState === 'visible' && !isForceLogout) {
|
||||
if (loginConnection && loginConnection.state !== signalR.HubConnectionState.Connected) {
|
||||
if (!isServerDown) {
|
||||
manualReconnect();
|
||||
}
|
||||
} else if (loginConnection && userId) {
|
||||
// 页面可见时发送一次心跳
|
||||
loginConnection.invoke("Heartbeat", userId).catch(function(err) {
|
||||
console.error("心跳发送失败:", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user