Compare commits
10
Commits
13d3a96f0c
...
59f2af943b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59f2af943b | ||
|
|
22bfe9d015 | ||
|
|
68419bf7de | ||
|
|
c3ec557c4d | ||
|
|
00119151c9 | ||
|
|
287453691b | ||
|
|
e3002cabf6 | ||
|
|
c38199268f | ||
|
|
0e5d0247bf | ||
|
|
713c3528ad |
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,15 +386,22 @@ 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;
|
||||
}
|
||||
|
||||
var invVM = Wtm.CreateVM<InventoryVM>();
|
||||
await invVM.ProcessErpFinishIn(inventory, task.TaskType);
|
||||
|
||||
if (task.TaskType != TaskTypeEnum.移库)
|
||||
{
|
||||
// 创建库存交易记录 放到任务完成,计算数量信息
|
||||
@@ -398,7 +409,7 @@ namespace HHWMS.Web
|
||||
invTran.Type = task.TaskType == TaskTypeEnum.入库
|
||||
? InventoryTranType.入库
|
||||
: InventoryTranType.出库;
|
||||
|
||||
invTran.CreateTime = DateTime.Now;
|
||||
invTrans.Add(invTran);
|
||||
}
|
||||
else
|
||||
@@ -406,16 +417,18 @@ namespace HHWMS.Web
|
||||
// 创建库存交易记录 放到任务完成,计算数量信息
|
||||
var invTran = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invTran.Type = InventoryTranType.入库;
|
||||
|
||||
invTran.CreateTime = DateTime.Now;
|
||||
|
||||
invTrans.Add(invTran);
|
||||
|
||||
|
||||
var invTran2 = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invTran2.Type = InventoryTranType.出库;
|
||||
|
||||
invTran2.CreateTime = DateTime.Now;
|
||||
|
||||
invTrans.Add(invTran2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inventory.TaskStatus = InventoryTaskStatusEnum.Idle;
|
||||
}
|
||||
|
||||
@@ -441,9 +454,9 @@ namespace HHWMS.Web
|
||||
container.LocationCode = task.TaskType == TaskTypeEnum.出库 ? "" : task.ToLocation;
|
||||
container.IsLock = ContainerLockEnum.未锁;
|
||||
container.UpdateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
_unitWork.Update(container);
|
||||
_unitWork.Update(container);
|
||||
}
|
||||
|
||||
// 更新库位状态(区分入库、出库、移库)
|
||||
switch (task.TaskType)
|
||||
@@ -480,14 +493,6 @@ namespace HHWMS.Web
|
||||
// 处理移库:同时更新源库位和目标库位
|
||||
// 1. 更新源库位(移出后变为空)
|
||||
var sourceLocation = _unitWork.FindSingle<Location>(x => x.Code == task.FromLocation);
|
||||
if (sourceLocation != null)
|
||||
{
|
||||
sourceLocation.ContainerCode = "";
|
||||
sourceLocation.Status = LocationStatusEnum.未锁;
|
||||
sourceLocation.ContainerStatus = LocationStatus.空仓位;
|
||||
sourceLocation.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(sourceLocation);
|
||||
}
|
||||
|
||||
// 2. 更新目标库位(移入后有容器)
|
||||
var targetLocation = _unitWork.FindSingle<Location>(x => x.Code == task.ToLocation);
|
||||
@@ -495,10 +500,20 @@ namespace HHWMS.Web
|
||||
{
|
||||
targetLocation.ContainerCode = task.ContainerCode;
|
||||
targetLocation.Status = LocationStatusEnum.未锁;
|
||||
targetLocation.ContainerStatus = sourceLocation.ContainerStatus;
|
||||
targetLocation.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(targetLocation);
|
||||
}
|
||||
|
||||
if (sourceLocation != null)
|
||||
{
|
||||
sourceLocation.ContainerCode = "";
|
||||
sourceLocation.Status = LocationStatusEnum.未锁;
|
||||
sourceLocation.ContainerStatus = LocationStatus.空仓位;
|
||||
sourceLocation.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(sourceLocation);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -528,8 +543,7 @@ namespace HHWMS.Web
|
||||
}
|
||||
|
||||
#region 暂时无用
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 请求入库(带防抖)
|
||||
/// </summary>
|
||||
@@ -557,7 +571,7 @@ namespace HHWMS.Web
|
||||
await Task.Delay(1000); // 模拟异步处理
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 请求空闲库位(带防抖)
|
||||
/// </summary>
|
||||
@@ -622,7 +636,7 @@ namespace HHWMS.Web
|
||||
|
||||
return ApiResult(new { LocationCode = location?.Code });
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,14 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search2(MaterialProcessListVM2 vm)
|
||||
{
|
||||
vm.Searcher.Page = vm.FC.GetValue<int>("Page");
|
||||
vm.Searcher.Limit = vm.FC.GetValue<int>("Limit");
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Create
|
||||
@@ -112,6 +120,15 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
var code = _unitWork.FindSingle<MaterialProcess>(x => x.ProcessName == vm.Entity.ProcessName)?.ProcessCode;
|
||||
vm.Entity.ProcessCode = code;
|
||||
// 判断是否重复
|
||||
if (_unitWork.IsExit<MaterialProcess>(x => x.ID != vm.Entity.ID && x.MaterialCode == vm.Entity.MaterialCode
|
||||
&& (x.ProcessOrder == vm.Entity.ProcessOrder
|
||||
|| x.ProcessName == vm.Entity.ProcessName)))
|
||||
{
|
||||
return FFResult().Alert("同一物料的工序或者顺序不能重复,请检查后重新编辑!");
|
||||
}
|
||||
vm.DoEdit();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
@@ -120,7 +137,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
|
||||
return FFResult().CloseDialog().RefreshGrid(vm.ParentWindowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace HHWMS.Web
|
||||
var moveloc = GetMoveLocation(outter);
|
||||
if (moveloc.Status)
|
||||
{
|
||||
string code = moveloc.Data.Code;
|
||||
string code = moveloc.Data.LocationCode;
|
||||
var movelocation = _unitWork.FindSingle<Location>(x => x.Code == code);
|
||||
|
||||
// 生成outter移库任务
|
||||
@@ -435,6 +435,7 @@ namespace HHWMS.Web
|
||||
ZoneId = outter.ZoneId,
|
||||
TaskNo = _unitWork.GetSerialNumber("Move"),
|
||||
TaskType = TaskTypeEnum.移库,
|
||||
RoadWay = 2,
|
||||
ContainerCode = outter.ContainerCode,
|
||||
FromLocation = outter.Code,
|
||||
ToLocation = movelocation.Code,
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace HHWMS.Web
|
||||
return new List<GridAction>
|
||||
{
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "configs", dialogWidth: 800,dialogHeight:800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "configs", dialogWidth: 800),
|
||||
@@ -64,7 +64,7 @@ namespace HHWMS.Web
|
||||
Description = x.Description,
|
||||
IsActive = x.IsActive,
|
||||
})
|
||||
.OrderBy(x => x.ID);
|
||||
.OrderBy(x => x.ProcessOrder);
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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 MaterialProcessListVM2 : BasePagedListVM<MaterialProcess_View, MaterialProcessSearcher>
|
||||
{
|
||||
protected override List<GridAction> InitGridAction()
|
||||
{
|
||||
return new List<GridAction>
|
||||
{
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "configs", dialogWidth: 800,dialogHeight:800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "configs", dialogWidth: 800),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected override IEnumerable<IGridColumn<MaterialProcess_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<MaterialProcess_View>>{
|
||||
this.MakeGridHeader(x => x.MaterialCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.ProcessOrder),
|
||||
this.MakeGridHeader(x => x.ProcessName),
|
||||
this.MakeGridHeader(x => x.ProcessCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.Weight),
|
||||
this.MakeGridHeader(x => x.Description),
|
||||
this.MakeGridHeader(x => x.IsActive).SetHide(),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<MaterialProcess_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<MaterialProcess>()
|
||||
.Where( x=>x.MaterialCode == Searcher.MaterialCode)
|
||||
.Select(x => new MaterialProcess_View
|
||||
{
|
||||
ID = x.ID,
|
||||
MaterialCode = x.MaterialCode,
|
||||
ProcessOrder = x.ProcessOrder,
|
||||
ProcessName = x.ProcessName,
|
||||
ProcessCode = x.ProcessCode,
|
||||
Weight = x.Weight,
|
||||
Description = x.Description,
|
||||
IsActive = x.IsActive,
|
||||
})
|
||||
.OrderBy(x => x.ProcessOrder);
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,20 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class MaterialProcessVM : BaseCRUDVM<MaterialProcess>
|
||||
{
|
||||
|
||||
public List<ComboSelectListItem> Processes { get; set; }
|
||||
public MaterialProcessVM()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
var CurrentCulture = Wtm.CurrentCulture;
|
||||
var processDatas = DC.Set<ProcessConfig>().ToList();
|
||||
Processes = processDatas.Select(x => new ComboSelectListItem
|
||||
{
|
||||
Text = x.Name,
|
||||
Value = x.Name
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public override void DoAdd()
|
||||
|
||||
@@ -12,13 +12,15 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class MaterialVM : BaseCRUDVM<Material>
|
||||
{
|
||||
|
||||
public MaterialProcessListVM2 materialProcesses = new MaterialProcessListVM2();
|
||||
public MaterialVM()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
materialProcesses.CopyContext(this);
|
||||
materialProcesses.Searcher.MaterialCode = Entity.MaterialCode;
|
||||
}
|
||||
|
||||
public override void DoAdd()
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
|
||||
// 根据库区加载排号
|
||||
function loadRows(area) {
|
||||
console.log(area);
|
||||
//console.log(area);
|
||||
if (!area) return;
|
||||
$.get('/configs/LocationMonitor/GetRows', { area: area }, function(data) {
|
||||
var rowSelect = $('#rowSelect');
|
||||
|
||||
@@ -2,21 +2,31 @@
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<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.Batch" />
|
||||
<wt:textbox field="Entity.Lot" />
|
||||
<wt:textbox field="Entity.CompanyCode" />
|
||||
<wt:textbox field="Entity.SupplierCode" />
|
||||
<wt:textbox field="Entity.Qty" />
|
||||
</wt:row>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="Entity.MaterialCode" disabled/>
|
||||
<wt:textbox field="Entity.MaterialType" disabled/>
|
||||
<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" disabled/>
|
||||
<wt:textbox field="Entity.Qty" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
<wt:submitbutton click="test2()" text="刷新"/>
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
<wt:grid vm="@Model.materialProcesses" id="materialProcesses" hidden-checkbox="true" hidden-panel="true" use-local-data="true" height="400" />
|
||||
|
||||
<script>
|
||||
function test2(){
|
||||
let code = $('[name="Entity.MaterialCode"]').val()
|
||||
console.log(1,code)
|
||||
layui.table.reload('materialProcesses', { where: { "Searcher.MaterialCode": code } });
|
||||
}
|
||||
</script>
|
||||
@@ -5,8 +5,8 @@
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="Entity.MaterialCode" disabled/>
|
||||
<wt:textbox field="Entity.ProcessOrder" />
|
||||
<wt:textbox field="Entity.ProcessName" />
|
||||
<wt:textbox field="Entity.ProcessCode" />
|
||||
<wt:combobox field="Entity.ProcessName" items="Processes" />
|
||||
<wt:hidden field="Entity.ProcessCode" />
|
||||
<wt:textbox field="Entity.Weight" />
|
||||
<wt:textbox field="Entity.Description" />
|
||||
<wt:switch field="Entity.IsActive" />
|
||||
@@ -17,3 +17,7 @@
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
<script>
|
||||
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录状态 Hub - 用于保活和异地登录检测
|
||||
/// </summary>
|
||||
public class LoginHub : Hub
|
||||
{
|
||||
// 存储用户连接信息:用户ID -> 连接ID
|
||||
private static readonly ConcurrentDictionary<string, string> _userConnections = new();
|
||||
|
||||
// 存储连接对应的用户:连接ID -> 用户ID
|
||||
private static readonly ConcurrentDictionary<string, string> _connectionUsers = new();
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录注册连接
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
public async Task Register(string userId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
return;
|
||||
|
||||
var connectionId = Context.ConnectionId;
|
||||
|
||||
// 检查该用户是否已有其他连接
|
||||
if (_userConnections.TryGetValue(userId, out var oldConnectionId))
|
||||
{
|
||||
if (oldConnectionId != connectionId)
|
||||
{
|
||||
// 通知旧连接被踢出
|
||||
await Clients.Client(oldConnectionId).SendAsync("ForceLogout", "您的账号已在其他设备登录");
|
||||
|
||||
// 移除旧连接记录
|
||||
_connectionUsers.TryRemove(oldConnectionId, out _);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新连接映射
|
||||
_userConnections[userId] = connectionId;
|
||||
_connectionUsers[connectionId] = userId;
|
||||
|
||||
// 通知当前客户端注册成功
|
||||
await Clients.Caller.SendAsync("RegisterSuccess", "连接成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 心跳保活
|
||||
/// </summary>
|
||||
public async Task Heartbeat(string userId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
return;
|
||||
|
||||
var connectionId = Context.ConnectionId;
|
||||
|
||||
// 检查是否是当前有效连接
|
||||
if (_userConnections.TryGetValue(userId, out var currentConnectionId))
|
||||
{
|
||||
if (currentConnectionId != connectionId)
|
||||
{
|
||||
// 当前连接不是最新的,通知被踢出
|
||||
await Clients.Caller.SendAsync("ForceLogout", "您的账号已在其他设备登录");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 回复心跳
|
||||
await Clients.Caller.SendAsync("HeartbeatResponse", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接断开时清理
|
||||
/// </summary>
|
||||
public override Task OnDisconnectedAsync(Exception exception)
|
||||
{
|
||||
var connectionId = Context.ConnectionId;
|
||||
|
||||
// 移除连接记录
|
||||
if (_connectionUsers.TryRemove(connectionId, out var userId))
|
||||
{
|
||||
// 只有当前连接是该用户的有效连接时才移除用户映射
|
||||
if (_userConnections.TryGetValue(userId, out var currentConnectionId) && currentConnectionId == connectionId)
|
||||
{
|
||||
_userConnections.TryRemove(userId, out _);
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取在线用户数量
|
||||
/// </summary>
|
||||
public int GetOnlineCount()
|
||||
{
|
||||
return _userConnections.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
@@ -359,7 +363,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region InvOut 成品出库
|
||||
#region InvOut 成品出库
|
||||
[ActionDescription("TaskType.Out")]
|
||||
public ActionResult InvOut2(string id)
|
||||
{
|
||||
@@ -380,134 +384,227 @@ namespace HHWMS.Web.Controllers
|
||||
[ActionDescription("TaskType.Out")]
|
||||
public ActionResult InvOut2(InventoryVM vm)
|
||||
{
|
||||
var id = vm.Entity.ID;
|
||||
// 校验参数
|
||||
if (string.IsNullOrWhiteSpace(vm.OutPort))
|
||||
try
|
||||
{
|
||||
return FFResult().Alert("出口必选,请选择后重试!");
|
||||
}
|
||||
// 校验库存
|
||||
var inv = _unitWork.FindSingle<Inventory>(x => x.ID == id);
|
||||
if (inv == null)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存不存在,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
if (inv.TaskStatus == InventoryTaskStatusEnum.Locked)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存已被锁定!,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
// 校验容器
|
||||
var container = _unitWork.FindSingle<Container>(x => x.Code == inv.ContainerCode);
|
||||
if (container == null)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存的容器不存在,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
var id = vm.Entity.ID;
|
||||
// 校验参数
|
||||
if (string.IsNullOrWhiteSpace(vm.OutPort))
|
||||
{
|
||||
return FFResult().Alert("出口必选,请选择后重试!");
|
||||
}
|
||||
|
||||
if (container.IsLock == ContainerLockEnum.任务锁)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("库存所在容器已被锁定!,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
// 校验库位
|
||||
var location = _unitWork.FindSingle<Location>(x => x.Code == inv.LocationCode);
|
||||
if (location == null)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存不在库内,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
// 校验库存
|
||||
var inv = _unitWork.FindSingle<Inventory>(x => x.ID == id);
|
||||
if (inv == null)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存不存在,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
if (location.Status == LocationStatusEnum.锁定)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("库存所在仓位已被锁定!,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
// 创建任务
|
||||
var task = new TaskHeader()
|
||||
{
|
||||
TaskNo = _unitWork.GetSerialNumber("Out", 6),
|
||||
ZoneId = inv.ZoneId,
|
||||
TaskType = TaskTypeEnum.出库,
|
||||
FromLocation = inv.LocationCode,
|
||||
ToLocation = vm.OutPort,
|
||||
ContainerCode = inv.ContainerCode,
|
||||
RoadWay = 2,
|
||||
Status = TaskStatusEnum.新建,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
|
||||
var locationVm = Wtm.CreateVM<LocationVM>();
|
||||
var result = locationVm.SendWcsTask(task);
|
||||
if (result.Status)
|
||||
{
|
||||
// 更新库存
|
||||
inv.TaskStatus = InventoryTaskStatusEnum.Locked;
|
||||
inv.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(inv);
|
||||
|
||||
// 更新容器
|
||||
container.IsLock = ContainerLockEnum.任务锁;
|
||||
container.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(container);
|
||||
|
||||
// 更新库位
|
||||
location.Status = LocationStatusEnum.锁定;
|
||||
location.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(location);
|
||||
return FFResult().CloseDialog().Message("出库任务创建成功").RefreshGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().Message(result.Message?? "WCS任务下发失败").RefreshGrid();
|
||||
}
|
||||
// 6. 调用WCS接口下发任务
|
||||
|
||||
/*
|
||||
var wcsTaskModel = new WCSTaskModel
|
||||
{
|
||||
TaskNo = task.TaskNo,
|
||||
PalletNo = task.ContainerCode,
|
||||
FromLocation = task.FromLocation, // 入库任务起始位置为空
|
||||
ToLocation = task.ToLocation,
|
||||
};
|
||||
if (inv.TaskStatus == InventoryTaskStatusEnum.Locked)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存已被锁定!,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
//调用WCS任务下发接口
|
||||
var wcsResult = Wtm.CallAPI<WCSTaskResponse>("WCSCP", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
|
||||
|
||||
if (wcsResult != null && wcsResult.Success)
|
||||
// 校验容器
|
||||
var container = _unitWork.FindSingle<Container>(x => x.Code == inv.ContainerCode);
|
||||
if (container == null)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存的容器不存在,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
if (container.IsLock == ContainerLockEnum.任务锁)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("库存所在容器已被锁定!,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
// 校验库位
|
||||
var location = _unitWork.FindSingle<Location>(x => x.Code == inv.LocationCode);
|
||||
if (location == null)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("所选库存不在库内,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
if (location.Status == LocationStatusEnum.锁定)
|
||||
{
|
||||
return FFResult().CloseDialog().Alert("库存所在仓位已被锁定!,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
|
||||
// 创建任务
|
||||
var task = new TaskHeader()
|
||||
{
|
||||
TaskNo = _unitWork.GetSerialNumber("Out", 6),
|
||||
ZoneId = inv.ZoneId,
|
||||
TaskType = TaskTypeEnum.出库,
|
||||
FromLocation = inv.LocationCode,
|
||||
ToLocation = vm.OutPort,
|
||||
ContainerCode = inv.ContainerCode,
|
||||
RoadWay = 2,
|
||||
Status = TaskStatusEnum.新建,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
|
||||
var locationVm = Wtm.CreateVM<LocationVM>();
|
||||
var result = locationVm.SendWcsTask(task);
|
||||
if (result.Status)
|
||||
{
|
||||
// 更新库存
|
||||
inv.TaskStatus = InventoryTaskStatusEnum.Locked;
|
||||
inv.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(inv);
|
||||
|
||||
// 更新容器
|
||||
container.IsLock = ContainerLockEnum.任务锁;
|
||||
container.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(container);
|
||||
|
||||
// 更新库位
|
||||
location.Status = LocationStatusEnum.锁定;
|
||||
location.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(location);
|
||||
return FFResult().CloseDialog().Message("出库任务创建成功").RefreshGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().Message(result.Message ?? "WCS任务下发失败").RefreshGrid();
|
||||
}
|
||||
// 6. 调用WCS接口下发任务
|
||||
|
||||
/*
|
||||
var wcsTaskModel = new WCSTaskModel
|
||||
{
|
||||
TaskNo = task.TaskNo,
|
||||
PalletNo = task.ContainerCode,
|
||||
FromLocation = task.FromLocation, // 入库任务起始位置为空
|
||||
ToLocation = task.ToLocation,
|
||||
};
|
||||
|
||||
//调用WCS任务下发接口
|
||||
var wcsResult = Wtm.CallAPI<WCSTaskResponse>("WCSCP", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
|
||||
|
||||
if (wcsResult != null && wcsResult.Success)
|
||||
{
|
||||
// WCS任务下发成功
|
||||
task.Status = TaskStatusEnum.已下发;
|
||||
_unitWork.Add(task);
|
||||
|
||||
// 更新库存
|
||||
inv.TaskStatus = InventoryTaskStatusEnum.Locked;
|
||||
inv.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(inv);
|
||||
|
||||
// 更新容器
|
||||
// _unitWork.BatchUpdate<Container>(x => x.Code == task.ContainerCode, x => new Container()
|
||||
// {
|
||||
// IsLock = ContainerLockEnum.任务锁,
|
||||
// UpdateTime = DateTime.Now
|
||||
// });
|
||||
container.IsLock = ContainerLockEnum.任务锁;
|
||||
container.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(container);
|
||||
|
||||
// 更新库位
|
||||
location.Status = LocationStatusEnum.锁定;
|
||||
location.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(location);
|
||||
|
||||
return FFResult().CloseDialog().Message("出库任务创建成功").RefreshGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
// WCS任务下发失败
|
||||
return FFResult().CloseDialog().Message(wcsResult?.Msg ?? "WCS任务下发失败").RefreshGrid();
|
||||
}*/
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// WCS任务下发成功
|
||||
task.Status = TaskStatusEnum.已下发;
|
||||
_unitWork.Add(task);
|
||||
|
||||
// 更新库存
|
||||
inv.TaskStatus = InventoryTaskStatusEnum.Locked;
|
||||
inv.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(inv);
|
||||
|
||||
// 更新容器
|
||||
// _unitWork.BatchUpdate<Container>(x => x.Code == task.ContainerCode, x => new Container()
|
||||
return FFResult().CloseDialog().Alert(ex.Message).RefreshGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region FinishIn 回传ERP入库信息
|
||||
/// <summary>
|
||||
/// 回传ERP入库信息
|
||||
/// </summary>
|
||||
/// <param name="ids">库存ID数组</param>
|
||||
/// <returns></returns>
|
||||
[ActionDescription("回传ERP入库")]
|
||||
public async Task<ActionResult> FinishIn(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 参数校验
|
||||
// 校验库存
|
||||
var inv = _unitWork.FindSingle<Inventory>(x => x.ID == int.Parse(id));
|
||||
if (inv == null)
|
||||
{
|
||||
return FFResult().Alert("所选库存不存在,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
if (inv.TaskStatus == InventoryTaskStatusEnum.Locked)
|
||||
{
|
||||
return FFResult().Alert("所选库存存在任务,请检查后重试!").RefreshGrid();
|
||||
}
|
||||
// if (string.IsNullOrEmpty(inv.ReceiptDetailId))
|
||||
// {
|
||||
// IsLock = ContainerLockEnum.任务锁,
|
||||
// UpdateTime = DateTime.Now
|
||||
// });
|
||||
container.IsLock = ContainerLockEnum.任务锁;
|
||||
container.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(container);
|
||||
// return FFResult().Alert("所选库存没关联订单,无需回传!").RefreshGrid();
|
||||
// }
|
||||
if (inv.UploadErpFlag is 1)
|
||||
{
|
||||
return FFResult().Alert("所选库存已报工回传,无需再次回传!").RefreshGrid();
|
||||
}
|
||||
|
||||
// 更新库位
|
||||
location.Status = LocationStatusEnum.锁定;
|
||||
location.UpdateTime = DateTime.Now;
|
||||
_unitWork.Update(location);
|
||||
// 构建ERP请求
|
||||
// 字段映射参照 ReceiptInController:
|
||||
// SourceCode = 单号 -> InCode
|
||||
// ReceiptDetailId = erpdetailid -> MoDetailId
|
||||
// BatchCode = 工序编码 -> StepCode
|
||||
// CreateBy = 操作员 -> WorkerCode
|
||||
// ReceiptCode = 校验员 -> Maker
|
||||
// CompanyCode = 公司 -> ErpCode
|
||||
var request = new FinishInRequest
|
||||
{
|
||||
Main = new FinishInMain
|
||||
{
|
||||
ErpCode = "003", // 账套号
|
||||
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);
|
||||
|
||||
return FFResult().CloseDialog().Message("出库任务创建成功").RefreshGrid();
|
||||
if (apiResult.Data is { Result: true })
|
||||
{
|
||||
inv.UploadErpFlag = 1;
|
||||
_unitWork.Update(inv);
|
||||
return FFResult().Alert("回传ERP成功").RefreshGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
inv.UploadErpFlag = 0;
|
||||
_unitWork.Update(inv);
|
||||
return FFResult().Alert($"调用ERP接口失败 {(apiResult.Data != null ? apiResult.Data.Message : apiResult.ErrorMsg)}")
|
||||
.RefreshGrid();
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
// WCS任务下发失败
|
||||
return FFResult().CloseDialog().Message(wcsResult?.Msg ?? "WCS任务下发失败").RefreshGrid();
|
||||
}*/
|
||||
|
||||
return FFResult().Alert($"回传ERP失败:{ex.Message}" ).RefreshGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
+49
-17
@@ -8,6 +8,23 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class InventoryTransactionListVM : BasePagedListVM<InventoryTransaction_View, InventoryTransactionSearcher>
|
||||
{
|
||||
public List<ComboSelectListItem> ZoneCodeList { get; set; }
|
||||
public List<ComboSelectListItem> BillTypeList { get; set; }
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
ZoneCodeList = new List<ComboSelectListItem>
|
||||
{
|
||||
new ComboSelectListItem { Text = "成品", Value = "1028" },
|
||||
new ComboSelectListItem { Text = "线边", Value = "1027" },
|
||||
new ComboSelectListItem { Text = "模具", Value = "1025" }
|
||||
};
|
||||
BillTypeList = new List<ComboSelectListItem>
|
||||
{
|
||||
new ComboSelectListItem { Text = "入库", Value = "in" },
|
||||
new ComboSelectListItem { Text = "出库", Value = "out" }
|
||||
};
|
||||
}
|
||||
protected override List<GridAction> InitGridAction()
|
||||
{
|
||||
return new List<GridAction>
|
||||
@@ -25,28 +42,41 @@ namespace HHWMS.Web
|
||||
|
||||
protected override IEnumerable<IGridColumn<InventoryTransaction_View>> InitGridHeader()
|
||||
{
|
||||
InitVM();
|
||||
return new List<GridColumn<InventoryTransaction_View>>{
|
||||
this.MakeGridHeader(x => x.ZoneCode),
|
||||
this.MakeGridHeader(x => x.Type),
|
||||
this.MakeGridHeader(x => x.ZoneCode)
|
||||
.SetFormat((a, b) =>
|
||||
{
|
||||
var data = ZoneCodeList.FirstOrDefault(x => x.Value.ToString() == a.ZoneCode);
|
||||
return data?.Text ?? a.ZoneCode;
|
||||
}),
|
||||
this.MakeGridHeader(x => x.Type)
|
||||
.SetFormat((a, b) =>
|
||||
{
|
||||
var data = BillTypeList.FirstOrDefault(x => x.Value.ToString() == a.Type);
|
||||
return data?.Text ?? a.Type;
|
||||
}),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.MaterialType).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.MaterialName),
|
||||
this.MakeGridHeader(x => x.Qty)
|
||||
.SetFormat((a, b) => { return (int?)a.Qty ?? 0; }),
|
||||
this.MakeGridHeader(x => x.CreateTime),
|
||||
this.MakeGridHeader(x => x.ContainerCode),
|
||||
this.MakeGridHeader(x => x.LocationCode),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.MaterialType),
|
||||
this.MakeGridHeader(x => x.MaterialName),
|
||||
this.MakeGridHeader(x => x.MaterialSpec),
|
||||
this.MakeGridHeader(x => x.MaterialUnit),
|
||||
this.MakeGridHeader(x => x.MaterialSpec).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialUnit).SetHide(),
|
||||
this.MakeGridHeader(x => x.Batch),
|
||||
this.MakeGridHeader(x => x.Lot),
|
||||
this.MakeGridHeader(x => x.ManufactureDate),
|
||||
this.MakeGridHeader(x => x.ExpirationDate),
|
||||
this.MakeGridHeader(x => x.ManufactureDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.ExpirationDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.CompanyCode),
|
||||
this.MakeGridHeader(x => x.SupplierCode),
|
||||
this.MakeGridHeader(x => x.Qty),
|
||||
this.MakeGridHeader(x => x.BillType),
|
||||
this.MakeGridHeader(x => x.SourceCode),
|
||||
this.MakeGridHeader(x => x.BillCode),
|
||||
this.MakeGridHeader(x => x.BillDetailId),
|
||||
this.MakeGridHeader(x => x.Status),
|
||||
this.MakeGridHeader(x => x.BillType).SetHide(),
|
||||
this.MakeGridHeader(x => x.SourceCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.BillCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.BillDetailId).SetHide(),
|
||||
this.MakeGridHeader(x => x.Status).SetHide(),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
}
|
||||
@@ -56,11 +86,11 @@ namespace HHWMS.Web
|
||||
var query = DC.Set<InventoryTransaction>()
|
||||
.CheckContain(Searcher.ZoneCode, x => x.ZoneCode)
|
||||
.CheckContain(Searcher.Type, x => x.Type)
|
||||
.CheckContain(Searcher.ContainerCode, x => x.ContainerCode)
|
||||
.CheckContain(Searcher.LocationCode, x => x.LocationCode)
|
||||
.CheckContain(Searcher.MaterialCode, x => x.MaterialCode)
|
||||
.CheckContain(Searcher.MaterialType, x => x.MaterialType)
|
||||
.CheckContain(Searcher.MaterialName, x => x.MaterialName)
|
||||
.CheckContain(Searcher.ContainerCode, x => x.ContainerCode)
|
||||
.CheckContain(Searcher.LocationCode, x => x.LocationCode)
|
||||
.CheckContain(Searcher.MaterialSpec, x => x.MaterialSpec)
|
||||
.CheckContain(Searcher.MaterialUnit, x => x.MaterialUnit)
|
||||
.CheckContain(Searcher.Batch, x => x.Batch)
|
||||
@@ -69,6 +99,7 @@ namespace HHWMS.Web
|
||||
.CheckContain(Searcher.SourceCode, x => x.SourceCode)
|
||||
.CheckContain(Searcher.BillCode, x => x.BillCode)
|
||||
.CheckContain(Searcher.Status, x => x.Status)
|
||||
.CheckBetween(Searcher.CreateTime?.GetStartTime(), Searcher.CreateTime?.GetEndTime(), x => x.CreateTime, includeMax: false)
|
||||
.Select(x => new InventoryTransaction_View
|
||||
{
|
||||
ID = x.ID,
|
||||
@@ -93,6 +124,7 @@ namespace HHWMS.Web
|
||||
BillCode = x.BillCode,
|
||||
BillDetailId = x.BillDetailId,
|
||||
Status = x.Status,
|
||||
CreateTime = x.CreateTime,
|
||||
})
|
||||
.OrderBy(x => x.ID);
|
||||
return query;
|
||||
|
||||
+3
@@ -42,6 +42,9 @@ namespace HHWMS.Web
|
||||
public String BillCode { get; set; }
|
||||
[Display(Name = "Inventory.Status")]
|
||||
public String Status { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.CreateTime")]
|
||||
public DateRange CreateTime { get; set; }
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -54,47 +54,95 @@ namespace HHWMS.Web
|
||||
.SetShowDialog(false),
|
||||
this.MakeAction("Inventory","InvOut2",Localizer["TaskType.Out1"],"",GridActionParameterTypesEnum.SingleId,"inventory")
|
||||
.SetSize(500,400),
|
||||
this.MakeAction("Inventory","FinishIn",Localizer["FinishIn"],"",GridActionParameterTypesEnum.SingleId,"inventory")
|
||||
.SetShowDialog(false).SetShowInRow(true),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected override IEnumerable<IGridColumn<Inventory_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<Inventory_View>>{
|
||||
this.MakeGridHeader(x => x.Name_view).SetWidth(80),
|
||||
this.MakeGridHeader(x => x.ContainerCode).SetWidth(90),
|
||||
this.MakeGridHeader(x => x.LocationCode).SetWidth(130),
|
||||
this.MakeGridHeader(x => x.MaterialCode).SetWidth(90),
|
||||
this.MakeGridHeader(x => x.MaterialType).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.Qty).SetWidth(100)
|
||||
.SetFormat((a, b) =>
|
||||
{
|
||||
return (int?)a.Qty ?? 0;
|
||||
}),
|
||||
this.MakeGridHeader(x => x.SupplierCode).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.Batch).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.Lot).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.TaskStatus).SetWidth(100)
|
||||
.SetBackGroundFunc((a)=>{
|
||||
if(a.TaskStatus == InventoryTaskStatusEnum.Locked )
|
||||
if (Wtm.LoginUserInfo.Groups.Any(x => x.GroupCode == "001"))
|
||||
{
|
||||
// 线边
|
||||
return new List<GridColumn<Inventory_View>>
|
||||
{
|
||||
this.MakeGridHeader(x => x.Name_view).SetWidth(80).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialCode).SetWidth(90).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialType).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.Qty).SetWidth(100)
|
||||
.SetFormat((a, b) => { return (int?)a.Qty ?? 0; })
|
||||
.SetShowTotal(true),
|
||||
this.MakeGridHeader(x => x.Batch).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.Lot).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.TaskStatus).SetWidth(100)
|
||||
.SetBackGroundFunc((a) =>
|
||||
{
|
||||
return "#FF0000";
|
||||
}
|
||||
return "";
|
||||
}),
|
||||
this.MakeGridHeader(x => x.MaterialName).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.CompanyCode).SetWidth(150),
|
||||
this.MakeGridHeader(x => x.SourceCode).SetWidth(150),
|
||||
this.MakeGridHeader(x => x.MaterialSpec).SetHide().SetWidth(150),
|
||||
this.MakeGridHeader(x => x.MaterialUnit).SetHide(),
|
||||
this.MakeGridHeader(x => x.TaskQty).SetHide(),
|
||||
this.MakeGridHeader(x => x.ManufactureDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.ExpirationDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.ReceiptCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.ReceiptDetailId).SetHide(),
|
||||
this.MakeGridHeader(x => x.Status).SetWidth(100),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
if (a.TaskStatus == InventoryTaskStatusEnum.Locked)
|
||||
{
|
||||
return "#FF0000";
|
||||
}
|
||||
|
||||
return "";
|
||||
}),
|
||||
this.MakeGridHeader(x => x.CreateTime).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.MaterialName).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.ContainerCode).SetWidth(90),
|
||||
this.MakeGridHeader(x => x.LocationCode).SetWidth(130),
|
||||
this.MakeGridHeader(x => x.SupplierCode).SetWidth(100).SetHide(),
|
||||
this.MakeGridHeader(x => x.CompanyCode).SetWidth(150),
|
||||
this.MakeGridHeader(x => x.SourceCode).SetWidth(150),
|
||||
this.MakeGridHeader(x => x.MaterialSpec).SetHide().SetWidth(150),
|
||||
this.MakeGridHeader(x => x.MaterialUnit).SetHide(),
|
||||
this.MakeGridHeader(x => x.TaskQty).SetHide(),
|
||||
this.MakeGridHeader(x => x.ManufactureDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.ExpirationDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.ReceiptCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.ReceiptDetailId).SetHide(),
|
||||
this.MakeGridHeader(x => x.Status).SetWidth(100),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<GridColumn<Inventory_View>>
|
||||
{
|
||||
this.MakeGridHeader(x => x.Name_view).SetWidth(80).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialCode).SetWidth(90).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialType).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.Qty).SetWidth(100)
|
||||
.SetFormat((a, b) => { return (int?)a.Qty ?? 0; })
|
||||
.SetShowTotal(true),
|
||||
this.MakeGridHeader(x => x.CompanyCode).SetWidth(150),
|
||||
this.MakeGridHeader(x => x.SourceCode).SetWidth(150),
|
||||
this.MakeGridHeader(x => x.Batch).SetWidth(100).SetHide(),
|
||||
this.MakeGridHeader(x => x.Lot).SetWidth(100).SetHide(),
|
||||
this.MakeGridHeader(x => x.TaskStatus).SetWidth(100)
|
||||
.SetBackGroundFunc((a) =>
|
||||
{
|
||||
if (a.TaskStatus == InventoryTaskStatusEnum.Locked)
|
||||
{
|
||||
return "#FF0000";
|
||||
}
|
||||
|
||||
return "";
|
||||
}),
|
||||
this.MakeGridHeader(x => x.CreateTime).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.MaterialName).SetWidth(100),
|
||||
this.MakeGridHeader(x => x.ContainerCode).SetWidth(90),
|
||||
this.MakeGridHeader(x => x.LocationCode).SetWidth(130),
|
||||
this.MakeGridHeader(x => x.SupplierCode).SetWidth(100).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialSpec).SetHide().SetWidth(150),
|
||||
this.MakeGridHeader(x => x.MaterialUnit).SetHide(),
|
||||
this.MakeGridHeader(x => x.TaskQty).SetHide(),
|
||||
this.MakeGridHeader(x => x.ManufactureDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.ExpirationDate).SetHide(),
|
||||
this.MakeGridHeader(x => x.ReceiptCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.ReceiptDetailId).SetHide(),
|
||||
this.MakeGridHeader(x => x.Status).SetWidth(100),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<Inventory_View> GetSearchQuery()
|
||||
@@ -109,6 +157,7 @@ namespace HHWMS.Web
|
||||
.CheckContain(Searcher.SourceCode, x=>x.SourceCode)
|
||||
.CheckContain(Searcher.CompanyCode, x=>x.CompanyCode)
|
||||
.CheckContain(Searcher.Batch, x=>x.Batch)
|
||||
.CheckContain(Searcher.Lot, x=>x.Lot)
|
||||
.CheckContain(Searcher.Status, x=>x.Status)
|
||||
.CheckEqual(Searcher.TaskStatus, x=>x.TaskStatus)
|
||||
.DPWhere(Wtm,x => x.ZoneId)
|
||||
@@ -137,6 +186,7 @@ namespace HHWMS.Web
|
||||
Status = x.Status,
|
||||
TaskStatus = x.TaskStatus,
|
||||
Flag = x.Flag,
|
||||
CreateTime = x.CreateTime
|
||||
})
|
||||
.OrderBy(x => x.ID);
|
||||
return query;
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
@@ -18,6 +18,7 @@ namespace HHWMS.Web
|
||||
|
||||
[Display(Name = "Location.OutPort", Description = "拣货口")]
|
||||
public string OutPort { get; set; }
|
||||
private IUnitWork unitWork;
|
||||
|
||||
public InventoryVM()
|
||||
{
|
||||
@@ -26,6 +27,7 @@ namespace HHWMS.Web
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
unitWork = new UnitWork(Wtm);
|
||||
AllZones = DC.Set<LocationZone>().GetSelectListItems(Wtm, y => y.Name);
|
||||
|
||||
AllOutPorts = new List<ComboSelectListItem>
|
||||
@@ -63,5 +65,95 @@ namespace HHWMS.Web
|
||||
{
|
||||
base.DoDelete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ERP报工处理
|
||||
/// </summary>
|
||||
/// <param name="inventory">库存实体</param>
|
||||
/// <param name="taskType">任务类型(入库/出库)</param>
|
||||
/// <returns>返回处理结果,true表示成功,false表示失败</returns>
|
||||
public async Task<bool> ProcessErpFinishIn(Inventory inventory, TaskTypeEnum? taskType)
|
||||
{
|
||||
if (inventory == null
|
||||
//|| string.IsNullOrEmpty(inventory.ReceiptDetailId)
|
||||
|| inventory.ZoneId == 1025 ) //模具库不报工
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// ERP相关 入库报工
|
||||
var finishInRequest = new FinishInRequest
|
||||
{
|
||||
Main = new FinishInMain
|
||||
{
|
||||
ErpCode = "003", // 账套号
|
||||
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, // 制单人(校验员)
|
||||
Type = inventory.ZoneId == 1027 ? 1: 2,
|
||||
WhCode = inventory.ZoneId == 1027 ? "xb": "cp",
|
||||
},
|
||||
Details = new List<FinishInDetail>()
|
||||
};
|
||||
|
||||
if (taskType == TaskTypeEnum.入库)
|
||||
{
|
||||
// 根据库存构建明细
|
||||
finishInRequest.Details.Add(new FinishInDetail
|
||||
{
|
||||
MoDetailId = inventory.ZoneId == 1027 ? "" : inventory.ReceiptDetailId, // 生产订单明细(ERP明细ID)
|
||||
InvCode = inventory.MaterialCode, // 物料号
|
||||
Qty = inventory.Qty ?? 0 // 完工数量
|
||||
});
|
||||
}
|
||||
else if (taskType == TaskTypeEnum.出库)
|
||||
{
|
||||
finishInRequest.Details.Add(new FinishInDetail
|
||||
{
|
||||
MaterialDetails = new List<MaterialDetail>
|
||||
{
|
||||
new MaterialDetail
|
||||
{
|
||||
MoDetailId = inventory.ZoneId == 1027 ? "" : inventory.ReceiptDetailId, // 生产订单明细ID
|
||||
InvCode = inventory.MaterialCode, // 物料号
|
||||
Qty = (decimal)inventory.Qty // 完工数量(空值兜底为0)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 调用ERP接口
|
||||
var apiResult = await Wtm.CallAPI<FinishInResponse>("ERP", "FinishIn",
|
||||
HttpMethodEnum.POST,
|
||||
finishInRequest);
|
||||
|
||||
if (apiResult.Data != null && apiResult.Data.Result)
|
||||
{
|
||||
inventory.UploadErpFlag = 1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory.UploadErpFlag = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 异常情况下设置标志为失败
|
||||
inventory.UploadErpFlag = 0;
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
unitWork.Update(inventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
<wt:searchpanel vm="@Model" reset-btn="true">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Three">
|
||||
<wt:textbox field="Searcher.ZoneCode" />
|
||||
<wt:textbox field="Searcher.Type" />
|
||||
<wt:combobox field="Searcher.ZoneCode" items="ZoneCodeList" />
|
||||
<wt:combobox field="Searcher.Type" items="BillTypeList"/>
|
||||
<wt:textbox field="Searcher.ContainerCode" />
|
||||
<wt:textbox field="Searcher.LocationCode" />
|
||||
<wt:textbox field="Searcher.MaterialCode" />
|
||||
@@ -16,8 +16,8 @@
|
||||
<wt:textbox field="Searcher.Lot" />
|
||||
<wt:textbox field="Searcher.BillType" />
|
||||
<wt:textbox field="Searcher.SourceCode" />
|
||||
<wt:textbox field="Searcher.BillCode" />
|
||||
<wt:textbox field="Searcher.Status" />
|
||||
<wt:datetime field="Searcher.CreateTime" range="true" />
|
||||
</wt:row>
|
||||
</wt:searchpanel>
|
||||
<wt:grid vm="@Model" url="/inventory/InventoryTransaction/Search"/>
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Public]
|
||||
[Area("receipt")]
|
||||
[ActionDescription("CP入库单明细")]
|
||||
[ApiController]
|
||||
[Route("api/Detail")]
|
||||
[FixConnection(DBOperationEnum.Read,"cp")]
|
||||
public partial class CPReceiptDetailController : BaseApiController
|
||||
{
|
||||
private readonly IUnitWork _unitwork;
|
||||
public CPReceiptDetailController(IUnitWork unitwork)
|
||||
{
|
||||
_unitwork = unitwork;
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost("Search")]
|
||||
[Public]
|
||||
public List<ReceiptDetail> Search()
|
||||
{
|
||||
var data = _unitwork.Find<ReceiptDetail>(x => x.Batch == "1").ToList();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
@@ -67,7 +70,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_unitwork.IsExit<ReceiptHeader>(x => x.Code == vm.Entity.Code))
|
||||
if (_unitwork.IsExit<ReceiptHeader>(x => x.Code == vm.Entity.Code))
|
||||
{
|
||||
return FFResult().Alert($"入库单号 {vm.Entity.Code} 重复!");
|
||||
}
|
||||
@@ -234,5 +237,29 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
[ActionDescription("GetReceiptDetails")]
|
||||
public ActionResult GetReceiptDetails()
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptDetailVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据入库单单号获取ERP生产订单数据并更新
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[ActionDescription("GetReceiptDetails")]
|
||||
public async Task<IActionResult> GetReceiptDetails(ReceiptDetailVM vm)
|
||||
{
|
||||
var receiptHeaderVM = Wtm.CreateVM<ReceiptHeaderVM>();
|
||||
var result = await receiptHeaderVM.GetReceiptDetailsFromERP(vm);
|
||||
if (result.Success)
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert("拉取成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert($"拉取失败!{result.Msg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,37 +42,179 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
#region API Methods
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult GetOperators()
|
||||
{
|
||||
var users = _unitWork.Find<FrameworkUser>(x => x.ITCode != "Admin")
|
||||
.Select(x => new {x.ITCode,x.Name})
|
||||
.ToList();
|
||||
return Json(new { Code = 200, Data = users});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult GetProcesses()
|
||||
/// <summary>
|
||||
/// 搜索物料
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> SearchMaterials(string keyword)
|
||||
{
|
||||
try
|
||||
{
|
||||
var processes = _unitWork.Find<MaterialProcess>(x => x.IsActive)
|
||||
.OrderBy(x => x.ProcessOrder)
|
||||
.Select(x => new {
|
||||
value = x.ID.ToString(),
|
||||
label = x.ProcessName,
|
||||
processCode = x.ProcessCode,
|
||||
processName = x.ProcessName
|
||||
if (string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
return Json(new { Code = 200, Data = new object[] { } });
|
||||
}
|
||||
|
||||
// 尝试调用接口获取物料
|
||||
try
|
||||
{
|
||||
var request = new LoadInventoryRequest
|
||||
{
|
||||
ErpCode = "003",
|
||||
InvDefine1 = keyword,
|
||||
Size = 15,
|
||||
Page = 1
|
||||
};
|
||||
|
||||
var apiResult =
|
||||
await Wtm.CallAPI<LoadInventoryResponse>("ERP", "LoadInventory", HttpMethodEnum.POST, request,3);
|
||||
|
||||
if (apiResult?.Data != null && apiResult.Data.Code == 0)
|
||||
{
|
||||
var materialsList = new List<object>();
|
||||
var oldMaterials = new List<object>();
|
||||
var newMaterials = new List<Material>();
|
||||
|
||||
// 获取接口返回的所有物料编码
|
||||
var invCodes = apiResult.Data.Data
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.InvCode))
|
||||
.Select(x => x.InvCode)
|
||||
.ToList();
|
||||
|
||||
// 一次性查询本地数据库中已存在的物料(优化性能,避免循环中多次查询)
|
||||
var existingMaterials = _unitWork.Find<Material>(m => invCodes.Contains(m.MaterialCode))
|
||||
.ToList();
|
||||
|
||||
// 遍历接口返回的物料数据
|
||||
foreach (var item in apiResult.Data.Data)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item.InvCode))
|
||||
continue;
|
||||
|
||||
// 在已查询的列表中查找物料是否存在
|
||||
var existingMaterial =
|
||||
existingMaterials.FirstOrDefault(m => m.MaterialCode == item.InvCode);
|
||||
|
||||
if (existingMaterial == null)
|
||||
{
|
||||
// 物料不存在,新增到数据库
|
||||
var newMaterial = new Material
|
||||
{
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialName = item.InvName,
|
||||
MaterialSpec = item.InvStd,
|
||||
MaterialUnit = item.UnitName,
|
||||
MaterialType = item.InvDefine1, // 永丰图号
|
||||
SupplierCode = item.InvDefine4, // 客户图号
|
||||
Qty = 0, // 默认数量为0
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "System"
|
||||
};
|
||||
|
||||
newMaterials.Add(newMaterial);
|
||||
|
||||
// 添加到返回列表
|
||||
materialsList.Add(new
|
||||
{
|
||||
MaterialCode = newMaterial.MaterialCode,
|
||||
MaterialName = newMaterial.MaterialName,
|
||||
MaterialSpec = newMaterial.MaterialSpec,
|
||||
MaterialUnit = newMaterial.MaterialUnit,
|
||||
MaterialType = newMaterial.MaterialType,
|
||||
SupplierCode = newMaterial.SupplierCode
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existingMaterial.MaterialName != item.InvName
|
||||
|| existingMaterial.MaterialType != item.InvDefine1)
|
||||
{
|
||||
existingMaterial.MaterialName = item.InvName;
|
||||
existingMaterial.MaterialSpec = item.InvStd;
|
||||
existingMaterial.MaterialUnit = item.UnitName;
|
||||
existingMaterial.MaterialType = item.InvDefine1;
|
||||
existingMaterial.SupplierCode = item.InvDefine4;
|
||||
existingMaterial.UpdateTime = DateTime.Now;
|
||||
existingMaterial.UpdateBy = "System";
|
||||
oldMaterials.Add(existingMaterial);
|
||||
}
|
||||
// 物料已存在,添加到返回列表
|
||||
materialsList.Add(new
|
||||
{
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialName = item.InvName,
|
||||
MaterialSpec = item.InvStd,
|
||||
MaterialUnit = item.UnitName,
|
||||
MaterialType = item.InvDefine1, // 永丰图号
|
||||
SupplierCode = item.InvDefine4, // 客户图号
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 保存新增的物料
|
||||
_unitWork.BatchAdd(newMaterials);
|
||||
_unitWork.BatchUpdate(oldMaterials);
|
||||
|
||||
// 返回物料列表到前端
|
||||
return Json(new { Code = 200, Data = materialsList });
|
||||
}
|
||||
}
|
||||
catch (System.Exception apiEx)
|
||||
{
|
||||
// 接口调用失败,记录日志
|
||||
Wtm.DoLog("获取ERP物料数据", ActionLogTypesEnum.Normal, "SearchMaterials",
|
||||
request: $"接口调用失败,改用本地数据库查询:{apiEx.Message}",
|
||||
result: "接口调用失败,改用本地数据库查询");
|
||||
}
|
||||
|
||||
// 接口连接失败或返回错误,从本地数据库查询
|
||||
var localMaterials = _unitWork.Find<Material>
|
||||
(m => m.MaterialCode.Contains(keyword)
|
||||
|| m.MaterialName.Contains(keyword)
|
||||
|| m.MaterialType.Contains(keyword))
|
||||
.Select(m => new
|
||||
{
|
||||
MaterialCode = m.MaterialCode,
|
||||
MaterialName = m.MaterialName,
|
||||
MaterialSpec = m.MaterialSpec,
|
||||
MaterialUnit = m.MaterialUnit,
|
||||
MaterialType = m.MaterialType,
|
||||
SupplierCode = m.SupplierCode
|
||||
})
|
||||
.Take(15)
|
||||
.ToList();
|
||||
return Json(new { Code = 200, Data = processes });
|
||||
|
||||
return Json(new { Code = 200, Data = localMaterials });
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Json(new { Code = 500, Msg = $"获取工序列表失败:{ex.Message}" });
|
||||
return Json(new { Code = 500, Msg = $"搜索物料失败:{ex.Message}" });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult GetOperators()
|
||||
{
|
||||
var users = _unitWork.Find<FrameworkUser>(x => x.ITCode != "Admin"
|
||||
&& x.ITCode.Length > 5)
|
||||
.Select(x => new
|
||||
{
|
||||
value = x.ITCode,
|
||||
label = x.Name
|
||||
})
|
||||
.ToList();
|
||||
return Json(new { Code = 200, Data = users });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的工序列表
|
||||
/// </summary>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult GetProcessesByMaterial(string materialCode)
|
||||
{
|
||||
@@ -85,8 +227,9 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
var processes = _unitWork.Find<MaterialProcess>(x => x.MaterialCode == materialCode && x.IsActive)
|
||||
.OrderBy(x => x.ProcessOrder)
|
||||
.Select(x => new {
|
||||
value = x.ID.ToString(),
|
||||
.Select(x => new
|
||||
{
|
||||
value = x.ID.ToString(),
|
||||
label = x.ProcessName,
|
||||
processCode = x.ProcessCode,
|
||||
processName = x.ProcessName
|
||||
@@ -100,33 +243,50 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的单据信息
|
||||
/// </summary>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult GetOperatorInfo()
|
||||
public async Task<IActionResult> GetOrdersByMaterial(string materialCode,string batch)
|
||||
{
|
||||
var users = _unitWork.Find<FrameworkUser>(x => x.ITCode != "Admin")
|
||||
.Select(x => new {x.ITCode,x.Name})
|
||||
.ToList();
|
||||
return Json(new { Code = 200, Data = users});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult GetOrdersByMaterial(string materialCode)
|
||||
{
|
||||
// TODO: 根据物料码查询相关生产订单
|
||||
var orders = new List<object>
|
||||
var receiptHeaderVM = Wtm.CreateVM<ReceiptHeaderVM>();
|
||||
var vm = new ReceiptDetailVM()
|
||||
{
|
||||
new { value = "1", label = "生产订单1" },
|
||||
new { value = "2", label = "生产订单2" }
|
||||
Entity = new ReceiptDetail()
|
||||
{
|
||||
MaterialCode = materialCode,
|
||||
Batch = batch ?? "32"
|
||||
}
|
||||
};
|
||||
return Json(new { Code = 200, Data = orders });
|
||||
}
|
||||
var result = await receiptHeaderVM.GetReceiptDetailsFromERP(vm);
|
||||
if (result.Data != null)
|
||||
{
|
||||
var orders = result.Data.Select(x => new
|
||||
{
|
||||
value = x.MoDetailId,
|
||||
label = x.MoCode,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
return Json(new { Code = 200, Data = orders });
|
||||
}
|
||||
return Json(new { Code = 200, Data = new List<MoDetailItem>() });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取托盘类型信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Public]
|
||||
[HttpGet]
|
||||
public IActionResult GetTrayTypes()
|
||||
{
|
||||
var containerconfig = _unitWork.Find<SysDictData>(x => x.DictType == "ContainerConfig"
|
||||
&& x.DictLabelUs.ToLower() != "container")
|
||||
&& x.DictLabelUs.ToLower() != "container")
|
||||
.Select(x => new
|
||||
{
|
||||
value = x.ID,
|
||||
@@ -136,26 +296,43 @@ namespace HHWMS.Web.Controllers
|
||||
return Json(new { Code = 200, Data = containerconfig });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上架入库
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult SubmitReceipt([FromBody] ReceiptInModel model)
|
||||
{
|
||||
if (_unitWork.IsExit<TaskHeader>(x => x.ContainerCode == model.PalletCode))
|
||||
{
|
||||
return JsonMore(null, 500, $"库内已存在托盘编码为 {model.PalletCode} 的任务!");
|
||||
}
|
||||
|
||||
// 获取物料信息
|
||||
var material = _unitWork.FindSingle<Material>(m => m.MaterialCode == model.MaterialCode);
|
||||
if (material == null)
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "物料不存在" });
|
||||
}
|
||||
|
||||
if (material.Qty == null || material.Qty <= 0)
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "物料毛重没有设置,请设置后再执行入库" });
|
||||
}
|
||||
|
||||
|
||||
// 获取容器信息
|
||||
var container = _unitWork.FindSingle<Container>(c => c.Code == model.PalletCode);
|
||||
if (container == null)
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "容器不存在" });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(container.LocationCode))
|
||||
{
|
||||
return Json(new { Code = 400, Msg = $"{container.Code} 容器状态不正确!已存在任务或者已在库内" });
|
||||
}
|
||||
|
||||
var materialProcessList = _unitWork.Find<MaterialProcess>(m => m.MaterialCode == material.MaterialCode);
|
||||
|
||||
var materialProcess = _unitWork.FindSingle<MaterialProcess>(m => m.ID == model.ProcessId);
|
||||
@@ -163,7 +340,7 @@ namespace HHWMS.Web.Controllers
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "未找到此物料工序配置" });
|
||||
}
|
||||
|
||||
|
||||
// 下一道工序
|
||||
var nextProcess = materialProcessList
|
||||
// 筛选同一物料
|
||||
@@ -174,25 +351,34 @@ namespace HHWMS.Web.Controllers
|
||||
.OrderBy(p => p.ProcessOrder)
|
||||
// 取第一个(下一道工序)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (nextProcess == null)
|
||||
{
|
||||
// 没有下一道工序的话,默认下一道工序为99
|
||||
nextProcess = new MaterialProcess()
|
||||
{
|
||||
ProcessCode = "99"
|
||||
};
|
||||
}
|
||||
// 从字典查询工序对应的区域
|
||||
var zoneName = _unitWork.FindSingle<ProcessConfig>(x =>
|
||||
x.Code == nextProcess.ProcessCode)?.Zone;
|
||||
var nextProcessConfig = _unitWork.FindSingle<ProcessConfig>(x =>
|
||||
x.Code == nextProcess.ProcessCode);
|
||||
var zoneName = nextProcessConfig?.Zone;
|
||||
|
||||
if (string.IsNullOrEmpty(zoneName))
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "未找到此工序对应区域配置" });
|
||||
}
|
||||
|
||||
|
||||
// 1. 查找可用库位信息
|
||||
var locationVm = Wtm.CreateVM<LocationVM>();
|
||||
var locationCode = locationVm.GetEmptyLocationFromXb(_materialZones[zoneName].BeginLine, _materialZones[zoneName].EndLine);
|
||||
|
||||
var locationCode =
|
||||
locationVm.GetEmptyLocationFromXb(_materialZones[zoneName].BeginLine, _materialZones[zoneName].EndLine);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(locationCode))
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "未找到可用的空仓位" });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 使用事务
|
||||
using (var tran = DC.BeginTransaction())
|
||||
{
|
||||
@@ -229,13 +415,16 @@ namespace HHWMS.Web.Controllers
|
||||
MaterialSpec = material.MaterialSpec,
|
||||
MaterialUnit = material.MaterialUnit,
|
||||
SupplierCode = material.SupplierCode,
|
||||
SourceCode = model.SourceCode,
|
||||
SourceCode = model.BillCode,//客户订单号
|
||||
ProduceCode = model.OrderId, // 单号
|
||||
ReceiptDetailId = model.SourceCode, // erpdetailid 回传使用
|
||||
BatchCode = materialProcess.ProcessCode, //erp回传使用 批次编码
|
||||
Batch = materialProcess.ProcessName,
|
||||
Lot = nextProcess?.ProcessName,
|
||||
Lot = nextProcessConfig?.Name,
|
||||
Status = model.IsQualified ? "合格" : "不合格",
|
||||
TaskStatus = InventoryTaskStatusEnum.Locked,
|
||||
TaskQty = model.Qty,//小托盘数量
|
||||
Flag = model.Type,//小托盘类型
|
||||
TaskQty = model.Qty, //小托盘数量
|
||||
Flag = model.Type, //小托盘类型
|
||||
CreateBy = model.OperatorId,
|
||||
ReceiptCode = model.OperatorInfo, //校验员
|
||||
CreateTime = DateTime.Now
|
||||
@@ -251,8 +440,9 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
// 从数据库中重新获取库位实体,避免实体跟踪冲突
|
||||
var locationToUpdate = _unitWork.FindSingle<Location>(l => l.Code == locationCode);
|
||||
|
||||
var resultNum = _unitWork.BatchUpdate<Location>(x => x.Code == locationCode && x.Version == locationToUpdate.Version,
|
||||
|
||||
var resultNum = _unitWork.BatchUpdate<Location>(
|
||||
x => x.Code == locationCode && x.Version == locationToUpdate.Version,
|
||||
x => new Location()
|
||||
{
|
||||
Status = LocationStatusEnum.锁定,
|
||||
@@ -262,12 +452,12 @@ namespace HHWMS.Web.Controllers
|
||||
UpdateBy = "WMS",
|
||||
Version = Guid.NewGuid()
|
||||
});
|
||||
|
||||
|
||||
if (resultNum == 0)
|
||||
{
|
||||
//失败 回滚
|
||||
tran.Rollback();
|
||||
return Json(new { Code = 500, Msg = "更新仓位失败!请重新提交!"});
|
||||
return Json(new { Code = 500, Msg = "更新仓位失败!请重新提交!" });
|
||||
}
|
||||
|
||||
// 6. 调用WCS接口下发任务
|
||||
@@ -282,14 +472,19 @@ 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 = Wtm
|
||||
.CallAPI<WCSTaskResponse>("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
|
||||
// var wcsResult = new WCSTaskResponse()
|
||||
// {
|
||||
// Success = true,
|
||||
// Msg = "Success"
|
||||
// };
|
||||
if (wcsResult != null && wcsResult.Success)
|
||||
{
|
||||
// WCS任务下发成功,提交事务
|
||||
taskHeader.Status = TaskStatusEnum.已下发;
|
||||
_unitWork.Update(taskHeader);
|
||||
|
||||
|
||||
tran.Commit();
|
||||
return Json(new { Code = 200, Msg = "入库成功", Data = new { TaskNo = taskNo } });
|
||||
}
|
||||
@@ -323,16 +518,17 @@ namespace HHWMS.Web.Controllers
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "容器不存在" });
|
||||
}
|
||||
|
||||
|
||||
// 1. 查找可用库位信息
|
||||
var locationVm = Wtm.CreateVM<LocationVM>();
|
||||
var locationCode = locationVm.GetEmptyLocationFromXb(_materialZones["Zone1"].BeginLine, _materialZones["Zone1"].EndLine);
|
||||
|
||||
var locationCode =
|
||||
locationVm.GetEmptyLocationFromXb(_materialZones["Zone1"].BeginLine, _materialZones["Zone1"].EndLine);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(locationCode))
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "未找到可用的空仓位" });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 使用事务
|
||||
using (var tran = DC.BeginTransaction())
|
||||
{
|
||||
@@ -357,7 +553,7 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
_unitWork.Add(taskHeader);
|
||||
|
||||
|
||||
|
||||
// 5. 锁定容器和库位
|
||||
container.IsLock = ContainerLockEnum.任务锁;
|
||||
container.LocationCode = locationCode;
|
||||
@@ -366,8 +562,9 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
// 从数据库中重新获取库位实体,避免实体跟踪冲突
|
||||
var locationToUpdate = _unitWork.FindSingle<Location>(l => l.Code == locationCode);
|
||||
|
||||
var resultNum = _unitWork.BatchUpdate<Location>(x => x.Code == locationCode && x.Version == locationToUpdate.Version,
|
||||
|
||||
var resultNum = _unitWork.BatchUpdate<Location>(
|
||||
x => x.Code == locationCode && x.Version == locationToUpdate.Version,
|
||||
x => new Location()
|
||||
{
|
||||
Status = LocationStatusEnum.锁定,
|
||||
@@ -377,12 +574,12 @@ namespace HHWMS.Web.Controllers
|
||||
UpdateBy = "WMS",
|
||||
Version = Guid.NewGuid()
|
||||
});
|
||||
|
||||
|
||||
if (resultNum == 0)
|
||||
{
|
||||
//失败 回滚
|
||||
tran.Rollback();
|
||||
return Json(new { Code = 500, Msg = "更新仓位失败!请重新提交!"});
|
||||
return Json(new { Code = 500, Msg = "更新仓位失败!请重新提交!" });
|
||||
}
|
||||
|
||||
// 6. 调用WCS接口下发任务
|
||||
@@ -395,7 +592,8 @@ namespace HHWMS.Web.Controllers
|
||||
};
|
||||
|
||||
// 调用WCS任务下发接口
|
||||
var wcsResult = Wtm.CallAPI<WCSTaskResponse>("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
|
||||
var wcsResult = Wtm
|
||||
.CallAPI<WCSTaskResponse>("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
|
||||
|
||||
if (wcsResult != null && wcsResult.Success)
|
||||
{
|
||||
@@ -416,7 +614,8 @@ namespace HHWMS.Web.Controllers
|
||||
tran.Rollback();
|
||||
return Json(new { Code = 500, Msg = ex.Message });
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 空托盘出库
|
||||
@@ -430,18 +629,18 @@ namespace HHWMS.Web.Controllers
|
||||
&& !string.IsNullOrEmpty(x.LocationCode));
|
||||
if (container == null)
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "库内不存在可用空容器!"} );
|
||||
return Json(new { Code = 500, Msg = "库内不存在可用空容器!" });
|
||||
}
|
||||
|
||||
|
||||
//创建出库任务
|
||||
var location = _unitWork.FindSingle<Location>(x => x.Code == container.LocationCode);
|
||||
|
||||
var outPort = _unitWork.FindSingle<ProcessConfig>(x => x.Code == "00")?.Port;
|
||||
if (string.IsNullOrEmpty(outPort))
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "未配置空托盘出库口,请配置后重新呼叫出库任务!"} );
|
||||
return Json(new { Code = 500, Msg = "未配置空托盘出库口,请配置后重新呼叫出库任务!" });
|
||||
}
|
||||
|
||||
|
||||
var task = new TaskHeader()
|
||||
{
|
||||
ZoneId = location.ZoneId,
|
||||
@@ -452,12 +651,12 @@ namespace HHWMS.Web.Controllers
|
||||
ToLocation = outPort,
|
||||
Status = TaskStatusEnum.新建
|
||||
};
|
||||
|
||||
|
||||
var vm = Wtm.CreateVM<LocationVM>();
|
||||
var result = vm.SendWcsTask(task);
|
||||
if (!result.Status)
|
||||
{
|
||||
return Json(new { Code = 500, Msg =result.Message});
|
||||
return Json(new { Code = 500, Msg = result.Message });
|
||||
}
|
||||
|
||||
location.Status = LocationStatusEnum.锁定;
|
||||
@@ -469,38 +668,6 @@ namespace HHWMS.Web.Controllers
|
||||
_unitWork.Update(container);
|
||||
return Json(new { Code = 200, Msg = "提交成功" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索物料
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public IActionResult SearchMaterials(string keyword)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
return Json(new { Code = 200, Data = new object[] { } });
|
||||
}
|
||||
|
||||
var materials = _unitWork.Find<Material>
|
||||
(m => m.MaterialCode.Contains(keyword) || m.MaterialName.Contains(keyword))
|
||||
.Select(m => new
|
||||
{
|
||||
MaterialCode = m.MaterialCode,
|
||||
m.MaterialType,
|
||||
MaterialName = m.MaterialName
|
||||
})
|
||||
.Take(10)
|
||||
.ToList();
|
||||
|
||||
return Json(new { Code = 200, Data = materials });
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Json(new { Code = 500, Msg = $"搜索物料失败:{ex.Message}" });
|
||||
}
|
||||
}
|
||||
|
||||
#endregion API Methods
|
||||
}
|
||||
@@ -518,11 +685,13 @@ namespace HHWMS.Web.Controllers
|
||||
public int Qty { get; set; }
|
||||
public bool IsQualified { get; set; }
|
||||
public string OperatorInfo { get; set; }
|
||||
|
||||
public string BillCode { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class LineRange
|
||||
{
|
||||
public int BeginLine { get; set; }
|
||||
public int EndLine { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -71,6 +72,7 @@ namespace HHWMS.Web.Controllers
|
||||
MaterialName = x.MaterialType,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
CompanyCode = x.CompanyCode,
|
||||
x.SourceCode,
|
||||
Batch = x.Batch,
|
||||
Qty = (int)x.Qty
|
||||
})
|
||||
@@ -133,39 +135,43 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult AddInventory(string containerCode, string materialCode, string company, string sourceCode, decimal qty, string batch)
|
||||
public async Task<ActionResult> AddInventory([FromBody] SimpleReceiptInModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(containerCode))
|
||||
if (string.IsNullOrEmpty(model.ContainerCode))
|
||||
{
|
||||
return JsonMore(null, 500, "容器编码为空!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(materialCode))
|
||||
if (string.IsNullOrEmpty(model.MaterialCode))
|
||||
{
|
||||
return JsonMore(null, 500, "物料编码为空!");
|
||||
}
|
||||
|
||||
if (qty <= 0)
|
||||
if (model.Qty <= 0)
|
||||
{
|
||||
return JsonMore(null, 500, "数量必须大于0!");
|
||||
}
|
||||
|
||||
// 查询容器
|
||||
var container = _unitWork.FindSingle<Container>(u => u.Code == containerCode);
|
||||
var container = _unitWork.FindSingle<Container>(u => u.Code == model.ContainerCode);
|
||||
if (container == null)
|
||||
{
|
||||
return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
|
||||
return JsonMore(null, 500, $"库内没有编码为 {model.ContainerCode} 的容器!");
|
||||
}
|
||||
|
||||
// 查询物料信息
|
||||
var material = _unitWork.FindSingle<Material>(x => x.MaterialCode == materialCode);
|
||||
var material = _unitWork.FindSingle<Material>(x => x.MaterialCode == model.MaterialCode);
|
||||
if (material == null)
|
||||
{
|
||||
return JsonMore(null, 500, $"未找到物料编码为 {materialCode} 的物料信息!");
|
||||
return JsonMore(null, 500, $"未找到物料编码为 {model.MaterialCode} 的物料信息!");
|
||||
}
|
||||
|
||||
var batchCode = _unitWork.Find<MaterialProcess>(x => x.MaterialCode == material.MaterialCode)
|
||||
.OrderByDescending(x => x.ProcessOrder)
|
||||
.FirstOrDefault()
|
||||
?.ProcessCode;
|
||||
var zone = _unitWork.FindSingle<LocationZone>(x => x.ZoneCode == container.Type);
|
||||
// 创建库存记录
|
||||
var inventory = new Inventory()
|
||||
@@ -177,21 +183,30 @@ namespace HHWMS.Web.Controllers
|
||||
MaterialType = material.MaterialType,
|
||||
MaterialSpec = material.MaterialSpec,
|
||||
MaterialUnit = material.MaterialUnit,
|
||||
CompanyCode = company,
|
||||
SourceCode = sourceCode,
|
||||
CompanyCode = model.CompanyCode,
|
||||
SourceCode = model.BillCode,// 客户订单
|
||||
ProduceCode = model.OrderId,// 生产订单
|
||||
ReceiptDetailId = model.SourceCode, // 优先使用 OrderId
|
||||
SupplierCode = material.SupplierCode,
|
||||
Batch = batch,
|
||||
Qty = qty,
|
||||
Batch = model.Batch,
|
||||
Qty = model.Qty,
|
||||
BatchCode = batchCode,
|
||||
TaskStatus = InventoryTaskStatusEnum.Locked,
|
||||
CreateTime = DateTime.Now
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode,
|
||||
UploadErpFlag = 0
|
||||
};
|
||||
_unitWork.Add(inventory);
|
||||
|
||||
// 创建入库交易记录
|
||||
var invTran = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invTran.BillCode = inventory.ID.ToString();
|
||||
invTran.Type = InventoryTranType.入库;
|
||||
|
||||
_unitWork.Add(invTran);
|
||||
|
||||
var invVM = Wtm.CreateVM<InventoryVM>();
|
||||
await invVM.ProcessErpFinishIn(inventory, TaskTypeEnum.入库);
|
||||
|
||||
return JsonMore(new { Id = inventory.ID });
|
||||
}
|
||||
@@ -215,12 +230,21 @@ namespace HHWMS.Web.Controllers
|
||||
return JsonMore(null, 500, "容器编码为空!");
|
||||
}
|
||||
|
||||
if (_unitWork.IsExit<TaskHeader>(x => x.ContainerCode == containerCode))
|
||||
{
|
||||
return JsonMore(null, 500, $"库内已存在托盘编码为 {containerCode} 的任务!");
|
||||
}
|
||||
// 查询容器
|
||||
var container = _unitWork.FindSingle<Container>(u => u.Code == containerCode);
|
||||
if (container == null)
|
||||
{
|
||||
return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(container.LocationCode))
|
||||
{
|
||||
return JsonMore(null,500, $"{container.Code} 容器状态不正确!已存在任务或者已在库内" );
|
||||
}
|
||||
|
||||
// 查询容器的库存
|
||||
var inventories = _unitWork.Find<Inventory>(x => x.ContainerCode == containerCode).ToList();
|
||||
@@ -302,7 +326,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult DeleteInventory(int id)
|
||||
public async Task<ActionResult> DeleteInventory(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -316,13 +340,17 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
// 创建出库交易记录
|
||||
var invTran = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invTran.BillCode = inventory.ID.ToString();
|
||||
invTran.Type = InventoryTranType.出库;
|
||||
|
||||
_unitWork.Add(invTran);
|
||||
|
||||
// var invVM = Wtm.CreateVM<InventoryVM>();
|
||||
// await invVM.ProcessErpFinishIn(inventory, TaskTypeEnum.出库);
|
||||
|
||||
// 删除库存记录
|
||||
_unitWork.Delete(inventory);
|
||||
|
||||
|
||||
return JsonMore(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -332,7 +360,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult UpdateInventory(int id, decimal qty)
|
||||
public async Task<ActionResult> UpdateInventory(int id, decimal qty)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -352,21 +380,32 @@ namespace HHWMS.Web.Controllers
|
||||
// 创建出库交易记录(原数量)
|
||||
var invOutTran = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invOutTran.Type = InventoryTranType.出库;
|
||||
invOutTran.Qty -= qty;
|
||||
invOutTran.BillCode = inventory.ID.ToString();
|
||||
invOutTran.CreateTime = DateTime.Now;
|
||||
|
||||
_unitWork.Add(invOutTran);
|
||||
|
||||
// 创建入库交易记录(新数量)
|
||||
var invInTran = _mapper.Map<InventoryTransaction>(inventory);
|
||||
invInTran.Qty = qty;
|
||||
invInTran.Type = InventoryTranType.入库;
|
||||
|
||||
_unitWork.Add(invInTran);
|
||||
// var invInTran = _mapper.Map<InventoryTransaction>(inventory);
|
||||
// invInTran.Qty = qty;
|
||||
// invInTran.BillCode = inventory.ID.ToString();
|
||||
// invInTran.Type = InventoryTranType.入库;
|
||||
// invInTran.CreateTime = DateTime.Now;
|
||||
//
|
||||
// _unitWork.Add(invInTran);
|
||||
|
||||
// 出库数量
|
||||
// inventory.Qty -= qty;
|
||||
// var invVM = Wtm.CreateVM<InventoryVM>();
|
||||
// await invVM.ProcessErpFinishIn(inventory, TaskTypeEnum.出库);
|
||||
|
||||
// 更新库存数量
|
||||
inventory.Qty = qty;
|
||||
inventory.UpdateTime = DateTime.Now;
|
||||
inventory.UpdateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS";
|
||||
_unitWork.Update(inventory);
|
||||
|
||||
|
||||
return JsonMore(null);
|
||||
}
|
||||
@@ -533,4 +572,57 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成品入库请求模型
|
||||
/// </summary>
|
||||
public class SimpleReceiptInModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 托盘编码
|
||||
/// </summary>
|
||||
public string ContainerCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string MaterialCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称(图号)
|
||||
/// </summary>
|
||||
public string MaterialName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料规格
|
||||
/// </summary>
|
||||
public string MaterialSpec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部件名称(批次)
|
||||
/// </summary>
|
||||
public string Batch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号(上游单号)
|
||||
/// </summary>
|
||||
public string SourceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产订单号
|
||||
/// </summary>
|
||||
public string BillCode { get; set; }
|
||||
|
||||
public string OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 公司
|
||||
/// </summary>
|
||||
public string CompanyCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace HHWMS.Web
|
||||
this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "receipt", dialogWidth: 800),
|
||||
this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "receipt", dialogWidth: 800),
|
||||
this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "receipt"),
|
||||
|
||||
this.MakeAction("ReceiptHeader","GetReceiptDetails",Localizer["GetReceiptDetails"],"",GridActionParameterTypesEnum.NoId,"receipt")
|
||||
.SetSize(500,400),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,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) =>
|
||||
{
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Models;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
@@ -9,12 +14,17 @@ namespace HHWMS.Web
|
||||
{
|
||||
public ReceiptDetailListVM2 Details = new ReceiptDetailListVM2();
|
||||
public List<ComboSelectListItem> ReceiptTypes { get; set; }
|
||||
|
||||
private IUnitWork _unitwork;
|
||||
|
||||
public ReceiptHeaderVM()
|
||||
{
|
||||
// 默认构造函数,用于框架创建实例
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
_unitwork = new UnitWork(Wtm);
|
||||
Details.CopyContext(this);
|
||||
Details.Searcher.HeaderId = Entity.ID;
|
||||
|
||||
@@ -41,5 +51,390 @@ namespace HHWMS.Web
|
||||
{
|
||||
base.DoDelete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据入库单单号获取ERP生产订单数据并更新
|
||||
/// </summary>
|
||||
public async Task<ApiJsonResult<List<MoDetailItem>>> GetReceiptDetailsFromERP(ReceiptDetailVM vm)
|
||||
{
|
||||
string receiptCode = vm.Entity.SourceCode;
|
||||
try
|
||||
{
|
||||
// 调用 ERP 接口获取该订单的最新数据
|
||||
var request = new LoadMoDetailListRequest
|
||||
{
|
||||
ErpCode = "003",
|
||||
MoCode = receiptCode, // 使用生产订单号查询
|
||||
InvCode = vm.Entity?.MaterialCode,
|
||||
InvDefine1 = vm.Entity?.MaterialType,
|
||||
StepCode = vm.Entity?.Batch,
|
||||
Size = 100,
|
||||
Page = 1
|
||||
};
|
||||
|
||||
var apiResult = await Wtm.CallAPI<LoadMoDetailListResponse>("ERP", "MOWorkAPI", HttpMethodEnum.POST, request);
|
||||
|
||||
if (apiResult?.Data != null && apiResult.Data.Code == 0 && apiResult.Data.Data?.Count > 0)
|
||||
{
|
||||
Wtm.DoLog("获取ERP订单数据", ActionLogTypesEnum.Normal, "GetReceiptDetails",
|
||||
request: $"订单号:{receiptCode},获取到 {apiResult.Data.Data.Count} 条明细",
|
||||
result: "开始处理订单数据");
|
||||
|
||||
// 使用相同的逻辑处理订单数据
|
||||
await ProcessOrderData(_unitwork, apiResult.Data.Data);
|
||||
|
||||
Wtm.DoLog("获取ERP订单数据", ActionLogTypesEnum.Normal, "GetReceiptDetails",
|
||||
request: $"订单号:{receiptCode}",
|
||||
result: "订单数据处理完成");
|
||||
|
||||
return new ApiJsonResult<List<MoDetailItem>>()
|
||||
{
|
||||
Success = true,
|
||||
Data = apiResult.Data.Data
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ApiJsonResult<List<MoDetailItem>>()
|
||||
{
|
||||
Success = false,
|
||||
Msg = apiResult?.Data?.Msg ?? apiResult?.ErrorMsg ?? "未获取到订单数据"
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Wtm.DoLog("获取ERP订单数据", ActionLogTypesEnum.Normal, "GetReceiptDetails",
|
||||
request: $"入库单号:{receiptCode}",
|
||||
result: $"错误:{ex.Message}");
|
||||
return new ApiJsonResult<List<MoDetailItem>>()
|
||||
{
|
||||
Success = false,
|
||||
Msg = $"获取订单数据失败:{ex.Message}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理订单数据并保存到本地数据库(照搬 LoadErpOrderJob)
|
||||
/// </summary>
|
||||
private async Task ProcessOrderData(IUnitWork unitWork, List<MoDetailItem> orderList)
|
||||
{
|
||||
// 按订单号分组
|
||||
var orderGroups = orderList.GroupBy(x => x.MoCode);
|
||||
|
||||
foreach (var group in orderGroups)
|
||||
{
|
||||
var moCode = group.Key;
|
||||
var orderDetails = group.ToList();
|
||||
|
||||
// 检查订单是否已存在
|
||||
var existingHeader = unitWork.FindSingle<ReceiptHeader>(h => h.SourceCode == moCode);
|
||||
|
||||
if (existingHeader == null)
|
||||
{
|
||||
// 创建新的入库单头
|
||||
var header = new ReceiptHeader
|
||||
{
|
||||
SourceCode = moCode, // 生产订单号
|
||||
Code = unitWork.GetSerialNumber("REC", 8), // 生成入库单号
|
||||
BillType = "生产订单",
|
||||
TotalQty = orderDetails.Sum(x => x.Qty),
|
||||
TotalLines = orderDetails.Count,
|
||||
FirstStatus = ReceiptStatusEnum.新建,
|
||||
LastStatus = ReceiptStatusEnum.新建,
|
||||
Remark = orderDetails.First().Memo,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "系统",
|
||||
UpdateVersion = 1
|
||||
};
|
||||
|
||||
unitWork.Add(header); // 保存以获取 HeaderId
|
||||
|
||||
// 获取订单明细中的所有物料编码
|
||||
var invCodes = orderDetails
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.InvCode))
|
||||
.Select(x => x.InvCode)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
// 一次性查询本地数据库中已存在的物料(优化性能)
|
||||
var existingMaterials = unitWork.Find<Material>(m => invCodes.Contains(m.MaterialCode))
|
||||
.ToList();
|
||||
|
||||
// 待新增的物料列表
|
||||
var newMaterials = new List<Material>();
|
||||
|
||||
// 创建入库单明细
|
||||
var details = new List<ReceiptDetail>();
|
||||
foreach (var item in orderDetails)
|
||||
{
|
||||
// 判断物料是否存在,不存在则创建
|
||||
if (!string.IsNullOrWhiteSpace(item.InvCode))
|
||||
{
|
||||
var existingMaterial = existingMaterials.FirstOrDefault(m => m.MaterialCode == item.InvCode);
|
||||
if (existingMaterial == null)
|
||||
{
|
||||
// 检查是否已在待新增列表中
|
||||
if (!newMaterials.Any(m => m.MaterialCode == item.InvCode))
|
||||
{
|
||||
// 物料不存在,创建新物料
|
||||
var newMaterial = new Material
|
||||
{
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialName = item.InvName,
|
||||
MaterialSpec = item.InvStd,
|
||||
MaterialType = item.InvDefine1, // 图号
|
||||
Qty = 0,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "系统"
|
||||
};
|
||||
newMaterials.Add(newMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var detail = new ReceiptDetail
|
||||
{
|
||||
HeaderId = header.ID,
|
||||
SourceCode = header.SourceCode,
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialType = item.InvDefine1, // 图号
|
||||
MaterialName = item.InvName,
|
||||
Lot = item.MoDetailId, // 明细id
|
||||
MaterialSpec = item.InvStd,
|
||||
Qty = item.Qty,
|
||||
CompletedQty = 0,
|
||||
Status = ReceiptStatusEnum.新建,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "系统",
|
||||
UpdateVersion = 1
|
||||
};
|
||||
|
||||
details.Add(detail);
|
||||
|
||||
|
||||
// 保存工序路线到 MaterialProcess 表
|
||||
if (item.ProcessRoute != null && item.ProcessRoute.Count > 0)
|
||||
{
|
||||
await SaveProcessRoute(unitWork, item.InvCode, item.ProcessRoute);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量新增物料
|
||||
if (newMaterials.Count > 0)
|
||||
{
|
||||
unitWork.BatchAdd(newMaterials);
|
||||
}
|
||||
|
||||
unitWork.BatchAdd(details);
|
||||
|
||||
Wtm.DoLog("保存订单数据", ActionLogTypesEnum.Normal, "ProcessOrderData",
|
||||
request: $"订单号:{moCode}",
|
||||
result: $"成功创建入库单 {header.Code},明细 {details.Count} 条");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 订单已存在,更新数据
|
||||
existingHeader.TotalQty = orderDetails.Sum(x => x.Qty);
|
||||
existingHeader.TotalLines = orderDetails.Count;
|
||||
existingHeader.Remark = orderDetails.First().Memo;
|
||||
existingHeader.UpdateVersion++;
|
||||
existingHeader.UpdateTime = DateTime.Now;
|
||||
existingHeader.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "系统";
|
||||
unitWork.Update(existingHeader);
|
||||
|
||||
// 更新明细
|
||||
var oldDetails = unitWork.Find<ReceiptDetail>(d => d.HeaderId == existingHeader.ID).ToList();
|
||||
|
||||
// 获取订单明细中的所有物料编码
|
||||
var invCodes = orderDetails
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.InvCode))
|
||||
.Select(x => x.InvCode)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
// 一次性查询本地数据库中已存在的物料(优化性能)
|
||||
var existingMaterials = unitWork.Find<Material>(m => invCodes.Contains(m.MaterialCode))
|
||||
.ToList();
|
||||
|
||||
// 待新增的物料列表
|
||||
var newMaterials = new List<Material>();
|
||||
|
||||
var newDetails = new List<ReceiptDetail>();
|
||||
foreach (var item in orderDetails)
|
||||
{
|
||||
// 判断明细是否存在 用MoDetailId 判断
|
||||
if (!oldDetails.Any(x => x.Lot == item.MoDetailId))
|
||||
{
|
||||
// 判断物料是否存在,不存在则创建
|
||||
if (!string.IsNullOrWhiteSpace(item.InvCode))
|
||||
{
|
||||
var existingMaterial = existingMaterials.FirstOrDefault(m => m.MaterialCode == item.InvCode);
|
||||
if (existingMaterial == null)
|
||||
{
|
||||
// 检查是否已在待新增列表中
|
||||
if (!newMaterials.Any(m => m.MaterialCode == item.InvCode))
|
||||
{
|
||||
// 物料不存在,创建新物料
|
||||
var newMaterial = new Material
|
||||
{
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialName = item.InvName,
|
||||
MaterialSpec = item.InvStd,
|
||||
MaterialType = item.InvDefine1, // 图号
|
||||
Qty = 0,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "系统"
|
||||
};
|
||||
newMaterials.Add(newMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var detail = new ReceiptDetail
|
||||
{
|
||||
HeaderId = existingHeader.ID,
|
||||
SourceCode = existingHeader.SourceCode,
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialType = item.InvDefine1, // 图号
|
||||
MaterialName = item.InvName,
|
||||
Lot = item.MoDetailId, // 明细id
|
||||
MaterialSpec = item.InvStd,
|
||||
Qty = item.Qty,
|
||||
CompletedQty = 0,
|
||||
Status = ReceiptStatusEnum.新建,
|
||||
Batch = item.Version,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "系统",
|
||||
UpdateVersion = 1
|
||||
};
|
||||
|
||||
newDetails.Add(detail);
|
||||
|
||||
// 更新工序路线
|
||||
if (item.ProcessRoute != null && item.ProcessRoute.Count > 0)
|
||||
{
|
||||
await SaveProcessRoute(unitWork, item.InvCode, item.ProcessRoute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量新增物料
|
||||
if (newMaterials.Count > 0)
|
||||
{
|
||||
unitWork.BatchAdd(newMaterials);
|
||||
}
|
||||
|
||||
unitWork.BatchAdd(newDetails);
|
||||
|
||||
Wtm.DoLog("更新订单数据", ActionLogTypesEnum.Normal, "ProcessOrderData",
|
||||
request: $"订单号:{moCode}",
|
||||
result: $"成功更新入库单 {existingHeader.Code},新增明细 {newDetails.Count} 条");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存工序路线到 MaterialProcess 表
|
||||
/// </summary>
|
||||
private async Task SaveProcessRoute(IUnitWork unitWork, string materialCode, List<ProcessRouteItem> processRoute)
|
||||
{
|
||||
// 查询已存在的工序路线
|
||||
var existingProcesses = unitWork.Find<MaterialProcess>(p => p.MaterialCode == materialCode).ToList();
|
||||
|
||||
// 待新增的工序
|
||||
var processesToAdd = new List<MaterialProcess>();
|
||||
// 待更新的工序
|
||||
var processesToUpdate = new List<MaterialProcess>();
|
||||
|
||||
var processConfigs = unitWork.Find<ProcessConfig>(x => x.Code != "").ToList();
|
||||
// 遍历新的工序路线
|
||||
foreach (var route in processRoute)
|
||||
{
|
||||
// 检查工艺是否存在于ProcessConfig中,不存在则添加
|
||||
var processConfig = processConfigs.Any(p => p.Code == route.ProcessCode);
|
||||
if (!processConfig)
|
||||
{
|
||||
unitWork.Add(new ProcessConfig
|
||||
{
|
||||
Code = route.ProcessCode,
|
||||
Name = route.ProcessName,
|
||||
Zone = "Zone2",
|
||||
Port = "EnterExit_P2005"
|
||||
});
|
||||
}
|
||||
|
||||
// 查找是否存在相同工序名称的记录
|
||||
var existing = existingProcesses.FirstOrDefault(p =>
|
||||
p.ProcessName == route.ProcessName);
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
// 已存在,检查是否需要更新
|
||||
bool needUpdate = false;
|
||||
|
||||
if (existing.ProcessCode != route.ProcessCode || existing.ProcessOrder != route.Sort)
|
||||
{
|
||||
existing.ProcessCode = route.ProcessCode;
|
||||
existing.ProcessOrder = route.Sort;
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
if (!existing.IsActive)
|
||||
{
|
||||
existing.IsActive = true;
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
if (needUpdate)
|
||||
{
|
||||
existing.UpdateTime = DateTime.Now;
|
||||
existing.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "系统";
|
||||
processesToUpdate.Add(existing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 不存在,新增
|
||||
var newProcess = new MaterialProcess
|
||||
{
|
||||
MaterialCode = materialCode,
|
||||
ProcessCode = route.ProcessCode,
|
||||
ProcessName = route.ProcessName,
|
||||
ProcessOrder = route.Sort,
|
||||
Weight = 0,
|
||||
IsActive = true,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "系统"
|
||||
};
|
||||
processesToAdd.Add(newProcess);
|
||||
}
|
||||
}
|
||||
|
||||
// 查找需要删除的工序(旧的多余的)
|
||||
var processesToDelete = existingProcesses.Where(existing =>
|
||||
!processRoute.Any(route =>
|
||||
route.ProcessName == existing.ProcessName)
|
||||
).ToList();
|
||||
|
||||
// 执行数据库操作
|
||||
if (processesToAdd.Count > 0)
|
||||
{
|
||||
unitWork.BatchAdd(processesToAdd);
|
||||
}
|
||||
|
||||
if (processesToUpdate.Count > 0)
|
||||
{
|
||||
unitWork.BatchUpdate(processesToUpdate);
|
||||
}
|
||||
|
||||
if (processesToDelete.Count > 0)
|
||||
{
|
||||
unitWork.BatchDelete(processesToDelete);
|
||||
}
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
@model HHWMS.Web.ReceiptDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.One">
|
||||
<wt:textbox field="Entity.SourceCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -5,8 +5,8 @@
|
||||
<a-form :model="form" :rules="rules" ref="formRef" auto-label-width>
|
||||
<a-form-item label="托盘码" field="palletCode">
|
||||
<a-input v-model="form.palletCode" ref="palletCodeRef" placeholder="请扫描托盘码"
|
||||
|
||||
@@keyup.enter="validateContainer" />
|
||||
@@keyup.enter="validateContainer"
|
||||
@@blur="validateContainer" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="物料码" field="materialCode">
|
||||
@@ -22,7 +22,7 @@
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="图号" field="name">
|
||||
<a-input v-model="form.name" />
|
||||
<a-input v-model="form.name"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="当前工序" field="processId">
|
||||
@@ -39,10 +39,18 @@
|
||||
<a-input v-model="form.processName" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item field="sourceCode" label="单号">
|
||||
<a-input v-model="form.sourceCode" style="width: 100%" ref="sourceCodeRef" @@keydown.enter="focusNext('numInput')"/>
|
||||
<a-form-item field="sourceCode" label="生产单号">
|
||||
<a-select v-model="form.sourceCode" placeholder="请选择生产单号" allow-search ref="sourceCodeRef" @@change="orderSelect">
|
||||
<a-option v-for="item in orderOptions"
|
||||
:key="item.value"
|
||||
:value="item.value">
|
||||
{{ item.label }}
|
||||
</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="客户单号" field="billCode">
|
||||
<a-input v-model="form.billCode" ref="billCodeRef" placeholder="请输入客户单号"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item field="type" label="小托盘类型" >
|
||||
<a-radio-group v-model="form.type" type="button">
|
||||
<a-radio
|
||||
@@ -63,11 +71,19 @@
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="操作员工" field="operatorId">
|
||||
<a-input v-model="form.operatorId" ref="operatorIdRef" placeholder="请扫描员工码" @@keydown.enter="focusNext('operatorInfoRef')" />
|
||||
<a-select v-model="form.operatorId" ref="operatorIdRef" placeholder="请选择或搜索操作员工" allow-search @@change="focusNext('operatorInfoRef')">
|
||||
<a-option v-for="item in operatorOptions" :key="item.value" :value="item.value">
|
||||
{{ item.value }}:{{ item.label }}
|
||||
</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="检验员信息" field="operatorInfo">
|
||||
<a-input v-model="form.operatorInfo" ref="operatorInfoRef" placeholder="请扫描检验员信息" @@keydown.enter="submitForm" />
|
||||
<a-select v-model="form.operatorInfo" ref="operatorInfoRef" placeholder="请选择或搜索检验员" allow-search>
|
||||
<a-option v-for="item in operatorOptions" :key="item.value" :value="item.value">
|
||||
{{ item.value }}:{{ item.label }}
|
||||
</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
@@ -96,6 +112,7 @@
|
||||
const palletCodeRef = ref(null);
|
||||
const materialCodeRef = ref(null);
|
||||
const sourceCodeRef = ref(null);
|
||||
const billCodeRef = ref(null);
|
||||
const numInput = ref(null);
|
||||
const operatorIdRef = ref(null);
|
||||
const operatorInfoRef = ref(null);
|
||||
@@ -105,6 +122,7 @@
|
||||
palletCodeRef,
|
||||
materialCodeRef,
|
||||
sourceCodeRef,
|
||||
billCodeRef,
|
||||
numInput,
|
||||
operatorIdRef,
|
||||
operatorInfoRef
|
||||
@@ -125,6 +143,7 @@
|
||||
operatorId: '',
|
||||
processId: '',
|
||||
processName:'',
|
||||
processCode:'',
|
||||
name:'',
|
||||
type:'',
|
||||
qty:null,
|
||||
@@ -132,6 +151,7 @@
|
||||
operatorInfo: ''
|
||||
});
|
||||
const processOptions = ref([]);
|
||||
const orderOptions = ref([]);
|
||||
const materialOptions = ref([]);
|
||||
let searchTimer = null;
|
||||
|
||||
@@ -145,6 +165,15 @@
|
||||
qty: [
|
||||
{ required: true, message: '请输入数量', trigger: ['change', 'blur'] }
|
||||
],
|
||||
type: [
|
||||
{ required: true, message: '请选择托盘类型', trigger: ['change', 'blur'] }
|
||||
],
|
||||
//sourceCode: [
|
||||
//{ required: true, message: '请选择生产单据', trigger: ['change', 'blur'] }
|
||||
//],
|
||||
//billCode: [
|
||||
//{ required: true, message: '请输入客户单据', trigger: ['change', 'blur'] }
|
||||
//],
|
||||
processId: [
|
||||
{ required: true, message: '请选择工序', trigger: ['change', 'blur'] }
|
||||
],
|
||||
@@ -178,27 +207,44 @@
|
||||
|
||||
const processSelect = (value) => {
|
||||
form.processName = processOptions.value.find(item => item.value === value).processName;
|
||||
form.processCode = processOptions.value.find(item => item.value === value).processCode;
|
||||
// 选择工序后,加载订单列表
|
||||
loadOrdersByMaterial(form.materialCode,form.processCode);
|
||||
focusNext('sourceCodeRef');
|
||||
}
|
||||
|
||||
// 加载工序列表
|
||||
const loadProcesses = () => {
|
||||
|
||||
const orderSelect = (value) => {
|
||||
form.orderId = orderOptions.value.find(item => item.value === value).label;
|
||||
focusNext('numInput');
|
||||
}
|
||||
|
||||
// 根据物料加载订单列表
|
||||
const loadOrdersByMaterial = (materialCode,batch) => {
|
||||
form.sourceCode = '';
|
||||
form.orderId = '';
|
||||
orderOptions.value = [];
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
url: "/receipt/ReceiptIn/GetProcesses",
|
||||
data: { materialCode: materialCode,batch: batch},
|
||||
url: "/receipt/ReceiptIn/GetOrdersByMaterial",
|
||||
success: (json) => {
|
||||
if (json.Code == 200) {
|
||||
processOptions.value = json.Data;
|
||||
orderOptions.value = json.Data || [];
|
||||
if (orderOptions.value.length === 0) {
|
||||
Message.warning('该物料暂无关联订单');
|
||||
}
|
||||
//console.log(orderOptions.value);
|
||||
} else {
|
||||
Message.error(json.Msg || '加载工序列表失败');
|
||||
Message.error(json.Msg || "获取订单列表失败");
|
||||
}
|
||||
},
|
||||
error: (xhr, status, error) => {
|
||||
Message.error('加载工序列表失败:' + error);
|
||||
error: (error) => {
|
||||
console.error("获取订单列表失败", error);
|
||||
Message.error("获取订单列表失败");
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// 根据物料加载工序列表
|
||||
const loadProcessesByMaterial = (materialCode) => {
|
||||
@@ -236,12 +282,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 扫描托盘码
|
||||
const scanPallet = () => {
|
||||
if (!form.palletCode) return;
|
||||
// TODO: 实现托盘码验证逻辑
|
||||
};
|
||||
|
||||
// 处理物料搜索
|
||||
const handleMaterialSearch = (value) => {
|
||||
if (searchTimer) {
|
||||
@@ -253,13 +293,13 @@
|
||||
} else {
|
||||
materialOptions.value = [];
|
||||
}
|
||||
}, 300);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
// 搜索物料
|
||||
|
||||
const searchMaterials = (keyword) => {
|
||||
axios.get(`/receipt/SimpleReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||
axios.get(`/receipt/ReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||
.then(function (json) {
|
||||
if (json.data.Code == 200) {
|
||||
materialOptions.value = json.data.Data.map(item => ({
|
||||
@@ -288,10 +328,13 @@
|
||||
// 先清空当前工序选择,避免显示旧数据
|
||||
form.processId = '';
|
||||
form.processName = '';
|
||||
form.sourceCode = '';
|
||||
form.orderId = '';
|
||||
|
||||
// 清除现有工序选项,触发重新渲染
|
||||
processOptions.value = [];
|
||||
|
||||
orderOptions.value = [];
|
||||
|
||||
// 延迟加载新工序,确保先清空再加载
|
||||
nextTick(() => {
|
||||
loadProcessesByMaterial(selectedMaterial.MaterialCode);
|
||||
@@ -412,6 +455,7 @@
|
||||
const resetForm = () => {
|
||||
formRef.value.resetFields();
|
||||
processOptions.value = [];
|
||||
orderOptions.value = [];
|
||||
setTimeout(() => {
|
||||
if (palletCodeRef.value) {
|
||||
palletCodeRef.value.focus();
|
||||
@@ -453,15 +497,35 @@
|
||||
}, 100);
|
||||
|
||||
loadTrayTypes();
|
||||
loadOperators();
|
||||
});
|
||||
|
||||
const operatorOptions = ref([]);
|
||||
|
||||
const loadOperators = () => {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/receipt/ReceiptIn/GetOperators",
|
||||
success: (json) => {
|
||||
if (json.Code == 200) {
|
||||
operatorOptions.value = json.Data;
|
||||
} else {
|
||||
Message.error(json.Msg || "获取员工列表失败");
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
Message.error("获取员工列表失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
formRef,
|
||||
form,
|
||||
loading,
|
||||
processOptions,
|
||||
orderOptions,
|
||||
rules,
|
||||
scanPallet,
|
||||
validateContainer,
|
||||
scanMaterial,
|
||||
submitForm,
|
||||
@@ -474,18 +538,20 @@
|
||||
palletCodeRef,
|
||||
materialCodeRef,
|
||||
sourceCodeRef,
|
||||
billCodeRef,
|
||||
numInput,
|
||||
operatorIdRef,
|
||||
operatorInfoRef,
|
||||
focusNext,
|
||||
loadProcesses,
|
||||
loadProcessesByMaterial,
|
||||
processSelect,
|
||||
trayTypeOptions
|
||||
orderSelect,
|
||||
trayTypeOptions,
|
||||
operatorOptions
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
app.use(ArcoVue);
|
||||
app.mount('#plapp');
|
||||
</script>
|
||||
</script>
|
||||
@@ -7,6 +7,7 @@
|
||||
placeholder="扫描托盘号"
|
||||
allow-clear
|
||||
@@keyup.enter="validateContainer"
|
||||
@@blur="validateContainer"
|
||||
ref="containerInput"/>
|
||||
</a-form-item>
|
||||
<a-form-item field="materialCode" label="物料信息">
|
||||
@@ -29,18 +30,24 @@
|
||||
placeholder="输入部件名称"
|
||||
allow-clear
|
||||
@@keydown.enter="$nextTick(() => {
|
||||
$refs.sourceCodeInput.focus();
|
||||
$refs.sourceCodeSelect.focus();
|
||||
})"/>/>
|
||||
</a-form-item>
|
||||
<a-form-item field="sourceCode" label="订单号">
|
||||
<a-input
|
||||
<a-form-item field="sourceCode" label="生产订单">
|
||||
<a-select
|
||||
v-model="formData.sourceCode"
|
||||
placeholder="输入订单号"
|
||||
ref="sourceCodeInput"
|
||||
@@keydown.enter="$nextTick(() => {
|
||||
$refs.companyCodeInput.focus();
|
||||
})"/>
|
||||
:options="orderOptions"
|
||||
placeholder="请选择生产订单"
|
||||
allow-search
|
||||
ref="sourceCodeSelect"
|
||||
@@change="handleOrderSelect">
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="客户单号" field="billCode">
|
||||
<a-input v-model="formData.billCode" placeholder="请输入客户单号"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item field="companyCode" label="公司">
|
||||
<a-auto-complete
|
||||
v-model="formData.companyCode"
|
||||
@@ -73,7 +80,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>
|
||||
@@ -125,6 +132,7 @@
|
||||
return {
|
||||
loading1: false,
|
||||
materialOptions: [],
|
||||
orderOptions: [],
|
||||
searchTimer: null,
|
||||
bindList: [],
|
||||
editModalVisible: false,
|
||||
@@ -181,7 +189,7 @@
|
||||
dataIndex: 'Batch',
|
||||
},
|
||||
{
|
||||
title: '订单号',
|
||||
title: '客户订单',
|
||||
dataIndex: 'SourceCode',
|
||||
},
|
||||
{
|
||||
@@ -206,6 +214,8 @@
|
||||
materialSpec: '',
|
||||
batch: '',
|
||||
sourceCode: '',
|
||||
billCode:'',
|
||||
orderId: '',
|
||||
companyCode: '',
|
||||
qty: null
|
||||
},
|
||||
@@ -293,7 +303,7 @@
|
||||
},
|
||||
|
||||
searchMaterials(keyword) {
|
||||
axios.get(`/receipt/SimpleReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||
axios.get(`/receipt/ReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||
.then((response) => {
|
||||
const json = response.data;
|
||||
if (json.Code == 200) {
|
||||
@@ -320,6 +330,9 @@
|
||||
this.formData.materialCode = selectedMaterial.MaterialCode;
|
||||
this.formData.materialName = selectedMaterial.MaterialType;
|
||||
this.formData.materialSpec = selectedMaterial.MaterialSpec;
|
||||
|
||||
// 选择物料后加载订单列表
|
||||
this.loadOrdersByMaterial(selectedMaterial.MaterialCode);
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
@@ -327,6 +340,45 @@
|
||||
});
|
||||
},
|
||||
|
||||
// 根据物料加载订单列表
|
||||
loadOrdersByMaterial(materialCode) {
|
||||
|
||||
this.formData.sourceCode = '';
|
||||
this.formData.orderId = '';
|
||||
this.orderOptions = [];
|
||||
const postData = new URLSearchParams();
|
||||
postData.append('materialCode', materialCode);
|
||||
|
||||
axios.post('/receipt/ReceiptIn/GetOrdersByMaterial', postData)
|
||||
.then((response) => {
|
||||
const json = response.data;
|
||||
if (json.Code == 200) {
|
||||
this.orderOptions = json.Data || [];
|
||||
|
||||
if (this.orderOptions.length === 0) {
|
||||
this.$message.warning('该物料暂无关联订单');
|
||||
}
|
||||
} else {
|
||||
this.$message.error(json.Msg || '获取订单列表失败');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('获取订单列表失败:', error);
|
||||
this.$message.error('获取订单列表失败: ' + (error.message || '网络错误'));
|
||||
});
|
||||
},
|
||||
|
||||
// 处理订单选择
|
||||
handleOrderSelect(value) {
|
||||
const selectedOrder = this.orderOptions.find(item => item.value === value);
|
||||
if (selectedOrder) {
|
||||
this.formData.orderId = selectedOrder.label; // 设置 OrderId 为订单号
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs.companyCodeInput?.focus();
|
||||
});
|
||||
},
|
||||
|
||||
handleBind() {
|
||||
// 表单验证
|
||||
if (!this.formData.containerCode) {
|
||||
@@ -351,34 +403,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 添加到绑定列表
|
||||
const bindItem = {
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
ContainerCode: this.formData.containerCode,
|
||||
MaterialCode: this.formData.materialCode,
|
||||
MaterialName: this.formData.materialName,
|
||||
MaterialSpec: this.formData.materialSpec,
|
||||
Batch: this.formData.batch,
|
||||
SourceCode: this.formData.sourceCode,
|
||||
BillCode: this.formData.billCode,
|
||||
OrderId: this.formData.orderId,
|
||||
CompanyCode: this.formData.companyCode,
|
||||
Qty: this.formData.qty
|
||||
};
|
||||
|
||||
// 调用后端添加库存
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('containerCode', this.formData.containerCode);
|
||||
postData.append('materialCode', this.formData.materialCode);
|
||||
postData.append('company', this.formData.companyCode);
|
||||
postData.append('sourceCode', this.formData.sourceCode);
|
||||
postData.append('qty', this.formData.qty);
|
||||
postData.append('batch', this.formData.batch);
|
||||
|
||||
axios.post("/receipt/SimpleReceiptIn/AddInventory", postData)
|
||||
axios.post("/receipt/SimpleReceiptIn/AddInventory", requestData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
const json = response.data;
|
||||
if (json.Code == 200) {
|
||||
// 添加ID到绑定项
|
||||
bindItem.Id = json.Data.Id;
|
||||
this.bindList.unshift(bindItem);
|
||||
|
||||
this.$message.success("物料绑定成功");
|
||||
this.saveToHistory('batch', this.formData.batch);
|
||||
// 清空表单
|
||||
@@ -404,8 +452,11 @@
|
||||
this.formData.materialSpec = '';
|
||||
this.formData.batch = '';
|
||||
this.formData.sourceCode = '';
|
||||
this.formData.billCode = '';
|
||||
this.formData.orderId = '';
|
||||
this.formData.companyCode = '';
|
||||
this.formData.qty = null;
|
||||
this.orderOptions = [];
|
||||
|
||||
// 页面加载完成后,将焦点设置到容器编码输入框
|
||||
this.$nextTick(() => {
|
||||
|
||||
@@ -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 = "003", // 账套号
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
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 LoadErpOrderJob : WtmJob
|
||||
{
|
||||
public override async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
var _unitwork = new UnitWork(Wtm);
|
||||
|
||||
// 调用接口获取ERP订单数据
|
||||
var request = new LoadMoDetailListRequest
|
||||
{
|
||||
ErpCode = "003",
|
||||
Size = 100,
|
||||
Page = 1
|
||||
};
|
||||
|
||||
var apiResult = await Wtm.CallAPI<LoadMoDetailListResponse>("ERP", "LoadMoDetailList", HttpMethodEnum.POST, request);
|
||||
|
||||
if (apiResult?.Data != null && apiResult.Data.Code == 0 && apiResult.Data.Data?.Count > 0)
|
||||
{
|
||||
Wtm.DoLog("获取ERP订单数据", ActionLogTypesEnum.Job, "LoadERPOrderJob",
|
||||
request: $"获取到 {apiResult.Data.Count} 条订单",
|
||||
result: "开始处理订单数据");
|
||||
|
||||
await ProcessOrderData(_unitwork, apiResult.Data.Data);
|
||||
|
||||
Wtm.DoLog("获取ERP订单数据", ActionLogTypesEnum.Job, "LoadERPOrderJob",
|
||||
request: $"成功处理 {apiResult.Data.Data.Count} 条订单",
|
||||
result: "订单数据处理完成");
|
||||
}
|
||||
else
|
||||
{
|
||||
Wtm.DoLog("获取ERP订单数据", ActionLogTypesEnum.Job, "LoadERPOrderJob",
|
||||
request: "调用接口",
|
||||
result: apiResult?.Data?.Msg ?? "未获取到订单数据");
|
||||
}
|
||||
#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, "LoadERPOrderJob", request:"error", result:ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理订单数据并保存到本地数据库
|
||||
/// </summary>
|
||||
private async Task ProcessOrderData(IUnitWork unitWork, List<MoDetailItem> orderList)
|
||||
{
|
||||
// 按订单号分组
|
||||
var orderGroups = orderList.GroupBy(x => x.MoCode);
|
||||
|
||||
foreach (var group in orderGroups)
|
||||
{
|
||||
var moCode = group.Key;
|
||||
var orderDetails = group.ToList();
|
||||
|
||||
// 检查订单是否已存在
|
||||
var existingHeader = unitWork.FindSingle<ReceiptHeader>(h => h.SourceCode == moCode);
|
||||
|
||||
if (existingHeader == null)
|
||||
{
|
||||
// 创建新的入库单头
|
||||
var header = new ReceiptHeader
|
||||
{
|
||||
SourceCode = moCode, // 生产订单号
|
||||
Code = unitWork.GetSerialNumber("REC", 8), // 生成入库单号
|
||||
BillType = "生产订单",
|
||||
TotalQty = orderDetails.Sum(x => x.Qty),
|
||||
TotalLines = orderDetails.Count,
|
||||
FirstStatus = ReceiptStatusEnum.新建,
|
||||
LastStatus = ReceiptStatusEnum.新建,
|
||||
Remark = orderDetails.First().Memo,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "系统",
|
||||
UpdateVersion = 1
|
||||
};
|
||||
|
||||
unitWork.Add(header); // 保存以获取 HeaderId
|
||||
|
||||
// 创建入库单明细
|
||||
var details = new List<ReceiptDetail>();
|
||||
foreach (var item in orderDetails)
|
||||
{
|
||||
var detail = new ReceiptDetail
|
||||
{
|
||||
HeaderId = header.ID,
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialName = item.InvName,
|
||||
MaterialSpec = item.InvStd,
|
||||
Qty = item.Qty,
|
||||
CompletedQty = 0,
|
||||
Status = ReceiptStatusEnum.新建,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "系统",
|
||||
UpdateVersion = 1
|
||||
};
|
||||
|
||||
details.Add(detail);
|
||||
|
||||
// 保存工序路线到 MaterialProcess 表
|
||||
if (item.ProcessRoute != null && item.ProcessRoute.Count > 0)
|
||||
{
|
||||
await SaveProcessRoute(unitWork, item.InvCode, item.ProcessRoute);
|
||||
}
|
||||
}
|
||||
|
||||
unitWork.BatchAdd(details);
|
||||
|
||||
Wtm.DoLog("保存订单数据", ActionLogTypesEnum.Job, "LoadERPOrderJob",
|
||||
request: $"订单号:{moCode}",
|
||||
result: $"成功创建入库单 {header.Code},明细 {details.Count} 条");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 订单已存在,更新数据
|
||||
existingHeader.TotalQty = orderDetails.Sum(x => x.Qty);
|
||||
existingHeader.TotalLines = orderDetails.Count;
|
||||
existingHeader.Remark = orderDetails.First().Memo;
|
||||
existingHeader.UpdateVersion++;
|
||||
unitWork.Update(existingHeader);
|
||||
|
||||
// 更新明细(简化处理:删除旧明细,重新插入)
|
||||
var oldDetails = unitWork.Find<ReceiptDetail>(d => d.HeaderId == existingHeader.ID).ToList();
|
||||
unitWork.BatchDelete(oldDetails);
|
||||
|
||||
var newDetails = new List<ReceiptDetail>();
|
||||
foreach (var item in orderDetails)
|
||||
{
|
||||
// 判断明细是否存在 用MoDetailId 判断
|
||||
if (!oldDetails.Any(x => x.Lot == item.MoDetailId))
|
||||
{
|
||||
var detail = new ReceiptDetail
|
||||
{
|
||||
HeaderId = existingHeader.ID,
|
||||
MaterialCode = item.InvCode,
|
||||
MaterialName = item.InvName,
|
||||
Lot = item.MoDetailId,//明细id
|
||||
MaterialSpec = item.InvStd,
|
||||
Qty = item.Qty,
|
||||
CompletedQty = 0,
|
||||
Status = ReceiptStatusEnum.新建,
|
||||
Batch = item.Version,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "系统",
|
||||
UpdateVersion = 1
|
||||
};
|
||||
|
||||
newDetails.Add(detail);
|
||||
|
||||
// 更新工序路线
|
||||
if (item.ProcessRoute != null && item.ProcessRoute.Count > 0)
|
||||
{
|
||||
await SaveProcessRoute(unitWork, item.InvCode, item.ProcessRoute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unitWork.BatchAdd(newDetails);
|
||||
|
||||
Wtm.DoLog("更新订单数据", ActionLogTypesEnum.Job, "LoadERPOrderJob",
|
||||
request: $"订单号:{moCode}",
|
||||
result: $"成功更新入库单 {existingHeader.Code},明细 {newDetails.Count} 条");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存工序路线到 MaterialProcess 表(智能比较更新)
|
||||
/// </summary>
|
||||
private async Task SaveProcessRoute(IUnitWork unitWork, string materialCode, List<ProcessRouteItem> processRoute)
|
||||
{
|
||||
// 查询已存在的工序路线
|
||||
var existingProcesses = unitWork.Find<MaterialProcess>(p => p.MaterialCode == materialCode).ToList();
|
||||
|
||||
// 待新增的工序
|
||||
var processesToAdd = new List<MaterialProcess>();
|
||||
// 待更新的工序
|
||||
var processesToUpdate = new List<MaterialProcess>();
|
||||
|
||||
// 遍历新的工序路线
|
||||
foreach (var route in processRoute)
|
||||
{
|
||||
// 查找是否存在相同工序编码和序号的记录
|
||||
var existing = existingProcesses.FirstOrDefault(p =>
|
||||
p.ProcessName == route.ProcessName);
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
// 已存在,检查是否需要更新
|
||||
bool needUpdate = false;
|
||||
|
||||
if (existing.ProcessCode != route.ProcessCode || existing.ProcessOrder != route.Sort)
|
||||
{
|
||||
existing.ProcessCode = route.ProcessCode;
|
||||
existing.ProcessOrder = route.Sort;
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
if (!existing.IsActive)
|
||||
{
|
||||
existing.IsActive = true;
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
if (needUpdate)
|
||||
{
|
||||
existing.UpdateTime = DateTime.Now;
|
||||
existing.UpdateBy = "系统";
|
||||
processesToUpdate.Add(existing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 不存在,新增
|
||||
var newProcess = new MaterialProcess
|
||||
{
|
||||
MaterialCode = materialCode,
|
||||
ProcessCode = route.ProcessCode,
|
||||
ProcessName = route.ProcessName,
|
||||
ProcessOrder = route.Sort,
|
||||
IsActive = true,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "系统"
|
||||
};
|
||||
processesToAdd.Add(newProcess);
|
||||
}
|
||||
}
|
||||
|
||||
// 查找需要删除的工序(旧的多余的)
|
||||
var processesToDelete = existingProcesses.Where(existing =>
|
||||
!processRoute.Any(route =>
|
||||
route.ProcessCode == existing.ProcessCode && route.Sort == existing.ProcessOrder)
|
||||
).ToList();
|
||||
|
||||
// 执行数据库操作
|
||||
if (processesToAdd.Count > 0)
|
||||
{
|
||||
unitWork.BatchAdd(processesToAdd);
|
||||
}
|
||||
|
||||
if (processesToUpdate.Count > 0)
|
||||
{
|
||||
unitWork.BatchUpdate(processesToUpdate);
|
||||
}
|
||||
|
||||
if (processesToDelete.Count > 0)
|
||||
{
|
||||
unitWork.BatchDelete(processesToDelete);
|
||||
}
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
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 LoadErpUserJob : WtmJob
|
||||
{
|
||||
public override async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
var _unitwork = new UnitWork(Wtm);
|
||||
|
||||
// 调用接口获取ERP用户数据
|
||||
var request = new LoadPersonRequest
|
||||
{
|
||||
ErpCode = "003",
|
||||
Size = 1000,
|
||||
Page = 1
|
||||
};
|
||||
|
||||
var apiResult = await Wtm.CallAPI<LoadPersonResponse>("ERP", "LoadPerson", HttpMethodEnum.POST, request,5);
|
||||
|
||||
if (apiResult?.Data != null && apiResult.Data.Code == 0 && apiResult.Data.Data?.Count > 0)
|
||||
{
|
||||
Wtm.DoLog("获取ERP用户数据", ActionLogTypesEnum.Job, "LoadErpUserJob",
|
||||
request: $"获取到 {apiResult.Data.Count} 条用户",
|
||||
result: "开始处理用户数据");
|
||||
|
||||
await ProcessUserData(_unitwork, apiResult.Data.Data);
|
||||
|
||||
Wtm.DoLog("获取ERP用户数据", ActionLogTypesEnum.Job, "LoadErpUserJob",
|
||||
request: $"成功处理 {apiResult.Data.Data.Count} 条用户",
|
||||
result: "用户数据处理完成");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 记录失败或无数据日志
|
||||
string msg = apiResult?.Data?.Msg ?? "未获取到用户数据";
|
||||
if (apiResult?.ErrorMsg != null) msg += $" Error: {apiResult.ErrorMsg}";
|
||||
|
||||
Wtm.DoLog("获取ERP用户数据", ActionLogTypesEnum.Job, "LoadErpUserJob",
|
||||
request: "调用接口",
|
||||
result: msg);
|
||||
}
|
||||
#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, "LoadErpUserJob", request:"error", result:ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理用户数据并保存到本地数据库
|
||||
/// </summary>
|
||||
private async Task ProcessUserData(IUnitWork unitWork, List<PersonItem> userList)
|
||||
{
|
||||
// 获取本次涉及的所有 MemCode
|
||||
var codes = userList.Select(x => x.MemCode).Distinct().ToList();
|
||||
|
||||
// 查询已存在的用户
|
||||
var existingUsers = unitWork.Find<FrameworkUser>(x => codes.Contains(x.ITCode)).ToList();
|
||||
|
||||
var usersToAdd = new List<FrameworkUser>();
|
||||
var usersToUpdate = new List<FrameworkUser>();
|
||||
|
||||
foreach (var item in userList)
|
||||
{
|
||||
// 查找本地是否已存在
|
||||
var existing = existingUsers.FirstOrDefault(x => x.ITCode == item.MemCode);
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
// 检查待添加列表中是否已包含(防止接口返回重复数据)
|
||||
if (!usersToAdd.Any(x => x.ITCode == item.MemCode))
|
||||
{
|
||||
var newUser = new FrameworkUser
|
||||
{
|
||||
ITCode = item.MemCode,
|
||||
Name = item.MemRealName,
|
||||
Password = Utils.GetMD5String("123456"), // 默认密码
|
||||
IsValid = true,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "System"
|
||||
};
|
||||
usersToAdd.Add(newUser);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 检查是否需要更新 (仅当姓名变更时)
|
||||
if (existing.Name != item.MemRealName)
|
||||
{
|
||||
existing.Name = item.MemRealName;
|
||||
existing.UpdateTime = DateTime.Now;
|
||||
existing.UpdateBy = "System";
|
||||
|
||||
// 确保不重复加入更新列表
|
||||
if(!usersToUpdate.Contains(existing))
|
||||
{
|
||||
usersToUpdate.Add(existing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (usersToAdd.Count > 0)
|
||||
{
|
||||
unitWork.BatchAdd(usersToAdd);
|
||||
}
|
||||
|
||||
if (usersToUpdate.Count > 0)
|
||||
{
|
||||
unitWork.BatchUpdate(usersToUpdate);
|
||||
}
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public class LoadPersonRequest
|
||||
{
|
||||
public string ErpCode { get; set; }
|
||||
public string MemRealName { get; set; }
|
||||
public string MemCode { get; set; }
|
||||
public int Size { get; set; }
|
||||
public int Page { get; set; }
|
||||
}
|
||||
|
||||
public class LoadPersonResponse
|
||||
{
|
||||
public int Code { get; set; }
|
||||
public string Msg { get; set; }
|
||||
public int Count { get; set; }
|
||||
public List<PersonItem> Data { get; set; }
|
||||
}
|
||||
|
||||
public class PersonItem
|
||||
{
|
||||
public string MemCode { get; set; }
|
||||
public string MemRealName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Controllers;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Quartz;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Core.Support.Quartz;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public class SyncReceiptJob : WtmJob
|
||||
{
|
||||
|
||||
public override Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var unitwork = new UnitWork(Wtm);
|
||||
var cp = new CPReceiptDetailController(unitwork);
|
||||
|
||||
// 获取所有已成品库已完成的明细,更新线边库数据库,限制用户入库的时候选择已入库的订单
|
||||
// 或者 建立线边库的库存,完成成品库的入库后,同步更新线边库的订单明细 todo
|
||||
var data = cp.Search();
|
||||
var t = "";
|
||||
/*var _unitwork = new UnitWork(Wtm);
|
||||
var sql = $"DELETE FROM {this.Wtm.DC.GetTableName<PersistedGrant>()} WHERE Expiration<'{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}'";
|
||||
this.Wtm.DC.RunSQL(sql);
|
||||
Wtm.DoLog("清理过期的refreshToken", ActionLogTypesEnum.Job, "JwtRefreshJob");
|
||||
|
||||
#region 更新时间
|
||||
var job = _unitwork.FindSingle<SysJob>(x => x.JobName == context.JobDetail.Key.Name);
|
||||
job.LastFireTime = TimeZoneInfo.ConvertTimeFromUtc(context.FireTimeUtc.DateTime, TimeZoneInfo.Local);
|
||||
job.NextFireTime = TimeZoneInfo.ConvertTimeFromUtc(context.NextFireTimeUtc.Value.DateTime, TimeZoneInfo.Local);
|
||||
_unitwork.Update<SysJob>(job);
|
||||
#endregion*/
|
||||
}
|
||||
catch { }
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ namespace HHWMS.Web.Controllers
|
||||
public IActionResult Index(string redirect)
|
||||
{
|
||||
ViewData["title"] = "WMS";
|
||||
ViewData["ITCode"] = Wtm.LoginUserInfo?.ITCode; // 传递用户ID用于SignalR连接
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,11 +56,11 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
var signined = UserSessionManager.IsUserSignined(user.Name);
|
||||
var signined = UserSessionManager.IsUserSignined(user.ITCode);
|
||||
if (signined)
|
||||
{
|
||||
// 踢人下线
|
||||
await KickUser(user.Name);
|
||||
await KickUser(user.ITCode);
|
||||
}
|
||||
//其他属性可以通过user.Attributes["aaa"] = "bbb"方式赋值
|
||||
Wtm.LoginUserInfo = user;
|
||||
@@ -85,8 +85,15 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
var principal = user.CreatePrincipal();
|
||||
|
||||
// 确保Principal包含ITCode claim,用于会话验证
|
||||
var identity = principal.Identity as System.Security.Claims.ClaimsIdentity;
|
||||
if (identity != null && !identity.HasClaim(c => c.Type == "ITCode"))
|
||||
{
|
||||
identity.AddClaim(new System.Security.Claims.Claim("ITCode", user.ITCode));
|
||||
}
|
||||
|
||||
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, properties);
|
||||
UserSessionManager.AddUserSession(user.Name,principal.Claims.First(c => c.Type == "SessionId").Value);
|
||||
UserSessionManager.AddUserSession(user.ITCode,principal.Claims.First(c => c.Type == "SessionId").Value);
|
||||
return Redirect(HttpUtility.UrlDecode(url));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ namespace HHWMS.Web.Models
|
||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string MaterialUnit { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.Batch", Description = "批次")]
|
||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string BatchCode { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.Batch", Description = "批次")]
|
||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string Batch { get; set; }
|
||||
@@ -65,7 +69,12 @@ namespace HHWMS.Web.Models
|
||||
[Display(Name = "Inventory.SupplierCode", Description = "供应商")]
|
||||
[StringLength(100, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string SupplierCode { get; set; }
|
||||
|
||||
|
||||
|
||||
[Display(Name = "Inventory.ProduceCode", Description = "生产订单号")]
|
||||
[StringLength(100, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string ProduceCode { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.TaskQty", Description = "任务数量")]
|
||||
[Column(TypeName = "decimal(12,4)")]
|
||||
public decimal? TaskQty { get; set; }
|
||||
@@ -83,7 +92,8 @@ namespace HHWMS.Web.Models
|
||||
public string ReceiptCode { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.ReceiptDetailId", Description = "明细ID")]
|
||||
public int? ReceiptDetailId { get; set; }
|
||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string ReceiptDetailId { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.Status", Description = "物料状态")]
|
||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
@@ -95,6 +105,8 @@ namespace HHWMS.Web.Models
|
||||
[Display(Name = "Inventory.Flag", Description = "格数")]
|
||||
public int Flag { get; set; }
|
||||
|
||||
public int? UploadErpFlag { get; set; }
|
||||
|
||||
public int UpdateVersion { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ namespace HHWMS.Web.Models
|
||||
[Display(Name = "Inventory.ReceiptCode")]
|
||||
public int HeaderId { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.SourceCode", Description = "上游单号")]
|
||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string SourceCode { get; set; }
|
||||
|
||||
[Display(Name = "Task.ZoneCode", Description = "库区")]
|
||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||
public string ZoneCode { get; set; }
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HHWMS.Web.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 入库回传ERP请求模型
|
||||
/// </summary>
|
||||
public class FinishInRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 报工单主表
|
||||
/// </summary>
|
||||
public FinishInMain Main { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报工单明细
|
||||
/// </summary>
|
||||
public List<FinishInDetail> Details { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报工单主表
|
||||
/// </summary>
|
||||
public class FinishInMain
|
||||
{
|
||||
/// <summary>
|
||||
/// 账套号,必填
|
||||
/// </summary>
|
||||
public string ErpCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报工单号,必填
|
||||
/// </summary>
|
||||
public string InCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报工日期,必填
|
||||
/// </summary>
|
||||
public string InDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序,必填
|
||||
/// </summary>
|
||||
public string StepCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工人编码,必填
|
||||
/// </summary>
|
||||
public string WorkerCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制单人,必填
|
||||
/// </summary>
|
||||
public string Maker { get; set; }
|
||||
|
||||
public int Type { get; set; }
|
||||
public string WhCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报工单明细
|
||||
/// </summary>
|
||||
public class FinishInDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产订单明细,必填
|
||||
/// </summary>
|
||||
public string MoDetailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料号,必填
|
||||
/// </summary>
|
||||
public string InvCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完工数量,必填
|
||||
/// </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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
namespace HHWMS.Web.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载物料请求模型
|
||||
/// </summary>
|
||||
public class LoadInventoryRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 账套号,必填
|
||||
/// </summary>
|
||||
public string ErpCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存货名称,非必填
|
||||
/// </summary>
|
||||
public string InvName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存货编码,非必填
|
||||
/// </summary>
|
||||
public string InvCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 永丰图号,非必填
|
||||
/// </summary>
|
||||
public string InvDefine1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户图号,非必填
|
||||
/// </summary>
|
||||
public string InvDefine4 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格,非必填
|
||||
/// </summary>
|
||||
public string InvStd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每页大小,必填
|
||||
/// </summary>
|
||||
public int Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码,必填
|
||||
/// </summary>
|
||||
public int Page { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace HHWMS.Web.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载生产订单请求模型
|
||||
/// </summary>
|
||||
public class LoadMoDetailListRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 账套号,必填
|
||||
/// </summary>
|
||||
public string ErpCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产订单号,非必填
|
||||
/// </summary>
|
||||
public string MoCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图号
|
||||
/// </summary>
|
||||
public string InvDefine1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存货编码,非必填
|
||||
/// </summary>
|
||||
public string InvCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每页大小,必填
|
||||
/// </summary>
|
||||
public int Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码,必填
|
||||
/// </summary>
|
||||
public int Page { get; set; }
|
||||
|
||||
public string StepCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace HHWMS.Web.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 入库回传ERP响应模型
|
||||
/// </summary>
|
||||
public class FinishInResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// true表示成功,false表示失败
|
||||
/// </summary>
|
||||
public bool Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回信息描述
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HHWMS.Web.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载物料返回模型
|
||||
/// </summary>
|
||||
public class LoadInventoryResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料列表
|
||||
/// </summary>
|
||||
public List<InventoryItem> Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总记录数
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态码,正确返回0
|
||||
/// </summary>
|
||||
public int Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误消息
|
||||
/// </summary>
|
||||
public string Msg { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料项
|
||||
/// </summary>
|
||||
public class InventoryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string InvCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string InvName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图号
|
||||
/// </summary>
|
||||
public string InvDefine1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户图号
|
||||
/// </summary>
|
||||
public string InvDefine4 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public string InvStd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计量单位编码
|
||||
/// </summary>
|
||||
public string ComUnitCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计量单位名称
|
||||
/// </summary>
|
||||
public string UnitName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HHWMS.Web.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载生产订单返回模型
|
||||
/// </summary>
|
||||
public class LoadMoDetailListResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单列表
|
||||
/// </summary>
|
||||
public List<MoDetailItem> Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总记录数
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态码,正确返回0
|
||||
/// </summary>
|
||||
public int Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误消息
|
||||
/// </summary>
|
||||
public string Msg { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产订单明细项
|
||||
/// </summary>
|
||||
public class MoDetailItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 单据号
|
||||
/// </summary>
|
||||
public string MoCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产订单明细id
|
||||
/// </summary>
|
||||
public string MoDetailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存货编码
|
||||
/// </summary>
|
||||
public string InvCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string InvName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图号
|
||||
/// </summary>
|
||||
public string InvDefine1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public string InvStd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产数量
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 成品完工数量
|
||||
/// </summary>
|
||||
public decimal FinishQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Memo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序路线
|
||||
/// </summary>
|
||||
public List<ProcessRouteItem> ProcessRoute { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工序路线项
|
||||
/// </summary>
|
||||
public class ProcessRouteItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
public string ProcessCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
public string ProcessName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序序号
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ app.UseEndpoints(endpoints =>
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
endpoints.MapHub<StockTickerHub>("/stocks");
|
||||
endpoints.MapHub<LoginHub>("/loginHub");
|
||||
});
|
||||
// 添加以下代码以确保响应是UTF-8编码
|
||||
app.Use(async (context, next) =>
|
||||
|
||||
@@ -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>
|
||||
@@ -1240,7 +1246,7 @@
|
||||
<value>数量</value>
|
||||
</data>
|
||||
<data name="Inventory.SourceCode" xml:space="preserve">
|
||||
<value>单号</value>
|
||||
<value>客户单号</value>
|
||||
</data>
|
||||
<data name="Inventory.UniqueCode" xml:space="preserve">
|
||||
<value>唯一码</value>
|
||||
@@ -1263,6 +1269,9 @@
|
||||
<data name="Inventory.Status" xml:space="preserve">
|
||||
<value>物料状态</value>
|
||||
</data>
|
||||
<data name="Inventory.CreateTime" xml:space="preserve">
|
||||
<value>创建时间</value>
|
||||
</data>
|
||||
<data name="Inventory.TaskStatus" xml:space="preserve">
|
||||
<value>任务状态</value>
|
||||
</data>
|
||||
|
||||
@@ -21,7 +21,9 @@ public class SessionValidationMiddleware
|
||||
{
|
||||
if (context.User.Identity.IsAuthenticated)
|
||||
{
|
||||
var userId = context.User.Identity.Name;
|
||||
// 优先使用ITCode claim,如果不存在则使用Name
|
||||
var userId = context.User.Claims.FirstOrDefault(c => c.Type == "ITCode")?.Value
|
||||
?? context.User.Identity.Name;
|
||||
var sessionId = context.User.Claims.FirstOrDefault(c => c.Type == "SessionId")?.Value;
|
||||
|
||||
if (!UserSessionManager.IsUserSessionValid(userId, sessionId))
|
||||
@@ -35,4 +37,4 @@ public class SessionValidationMiddleware
|
||||
|
||||
await _next(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@
|
||||
initLocationChart();
|
||||
initCurrentTaskChart();
|
||||
});
|
||||
console.log(echarts);
|
||||
//console.log(echarts);
|
||||
// 一周内出入库任务统计柱状图
|
||||
function initTaskHistoryChart() {
|
||||
var taskHistoryChart = echarts.init(document.getElementById('taskHistoryChart'));
|
||||
|
||||
@@ -1,58 +1 @@
|
||||
<script>layui.use('index')</script>
|
||||
<script>
|
||||
// 检查登录状态的函数
|
||||
function checkLoginStatus() {
|
||||
$.ajax({
|
||||
url: '/Home/CheckLogin',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
// 如果返回的数据包含Login,说明已被重定向到登录页
|
||||
if (data && data.indexOf('Login') !== -1) {
|
||||
// 清除定时器
|
||||
if (window.loginCheckTimer) {
|
||||
clearInterval(window.loginCheckTimer);
|
||||
}
|
||||
|
||||
// 使用layer弹窗提示
|
||||
layer.alert("您的账号已在其他设备登录,请重新登录", {
|
||||
icon: 0,
|
||||
title: "登录提示",
|
||||
closeBtn: 0,
|
||||
btn: ['确定'],
|
||||
yes: function(index) {
|
||||
layer.close(index);
|
||||
// 重定向到登录页
|
||||
window.location.href = '/Login/Login';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
// 如果返回401或其他错误,直接跳转到登录页
|
||||
window.location.href = '/Login/Login';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 页面加载完成后开始检查
|
||||
$(document).ready(function() {
|
||||
// 存储定时器ID
|
||||
window.loginCheckTimer = setInterval(function() {
|
||||
checkLoginStatus();
|
||||
}, 10000); // 每10秒检查一次
|
||||
|
||||
// 页面关闭时清除定时器
|
||||
$(window).on('unload', function() {
|
||||
if (window.loginCheckTimer) {
|
||||
clearInterval(window.loginCheckTimer);
|
||||
}
|
||||
});
|
||||
|
||||
// 页面从隐藏状态变为可见时,立即检查一次
|
||||
$(document).on('visibilitychange', function() {
|
||||
if (document.visibilityState === 'visible') {
|
||||
checkLoginStatus();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -75,7 +75,7 @@
|
||||
margin-bottom: 1%;
|
||||
">© 2022 华恒工程技术中心有限公司</p>*@
|
||||
</div>
|
||||
<script>
|
||||
@* <script>
|
||||
var loginData = [];
|
||||
$.post('/Home/BeforeLogin/',{},function (data){
|
||||
loginData = data.Data;
|
||||
@@ -101,7 +101,7 @@
|
||||
})
|
||||
|
||||
return issigned;
|
||||
}
|
||||
} *@
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
"Key": "default",
|
||||
"Value": "Server=127.0.0.1;Port=3306;Database=WMS2;Uid=root;Password=abc123*;Character Set=utf8mb4;",
|
||||
"DBType": "mysql"
|
||||
},
|
||||
{
|
||||
"Key": "cp",
|
||||
"Value": "Server=127.0.0.1;Port=3306;Database=wms3;Uid=root;Password=abc123*;Character Set=utf8mb4;",
|
||||
"DBType": "mysql"
|
||||
}
|
||||
],
|
||||
"CookiePre": "HHWMS", //cookie前缀
|
||||
@@ -94,6 +99,9 @@
|
||||
"Domains": {
|
||||
"WCS": {
|
||||
"Address": "http://192.168.30.220:65533/api/WCS/"
|
||||
},
|
||||
"ERP": {
|
||||
"Address": "http://127.0.0.1:4523/m1/1364541-1434451-default/"
|
||||
}
|
||||
},
|
||||
"AppSettings": {
|
||||
|
||||
Reference in new issue
Block a user