线边操作添加ERP关联
This commit is contained in:
parent
713c3528ad
commit
0e5d0247bf
@ -389,6 +389,41 @@ namespace HHWMS.Web
|
||||
_unitWork.FindSingle<Material>(x => x.MaterialCode == inventory.MaterialCode);
|
||||
inventory.Qty = (int)((request.Weight * 100 - ContainerWeight - inventory.TaskQty * SmallContainerWeight) / (material.Qty ?? 1));
|
||||
inventory.Qty = inventory.Qty > 0 ? inventory.Qty : 0;
|
||||
|
||||
// ERP相关
|
||||
var finishInRequest = new FinishInRequest
|
||||
{
|
||||
Main = new FinishInMain
|
||||
{
|
||||
ErpCode = "001", // 账套号
|
||||
InCode = inventory.SourceCode, // 报工单号(上游单号)
|
||||
InDate = (inventory.CreateTime ?? DateTime.Now).ToString("yyyy-MM-dd"), // 报工日期
|
||||
StepCode = inventory.BatchCode, // 工序(批次编码)
|
||||
WorkerCode = inventory.CreateBy, // 工人编码(创建人)
|
||||
Maker = inventory.ReceiptCode // 制单人(校验员)
|
||||
},
|
||||
Details = new List<FinishInDetail>()
|
||||
};
|
||||
|
||||
// 根据库存构建明细
|
||||
finishInRequest.Details.Add(new FinishInDetail
|
||||
{
|
||||
MoDetailId = inventory.ReceiptDetailId, // 生产订单明细(ERP明细ID)
|
||||
InvCode = inventory.MaterialCode, // 物料号
|
||||
Qty = inventory.Qty ?? 0 // 完工数量
|
||||
});
|
||||
|
||||
// 调用ERP接口
|
||||
var apiResult = await Wtm.CallAPI<FinishInResponse>("ERP", "Api/FinishIn", HttpMethodEnum.POST, finishInRequest);
|
||||
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
inventory.UploadErpFlag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory.UploadErpFlag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (task.TaskType != TaskTypeEnum.移库)
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
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;
|
||||
@ -359,7 +362,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region InvOut 成品出库
|
||||
#region InvOut 成品出库
|
||||
[ActionDescription("TaskType.Out")]
|
||||
public ActionResult InvOut2(string id)
|
||||
{
|
||||
@ -518,5 +521,81 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
}
|
||||
#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();
|
||||
}
|
||||
|
||||
// 构建ERP请求
|
||||
// 字段映射参照 ReceiptInController:
|
||||
// SourceCode = 单号 -> InCode
|
||||
// ReceiptDetailId = erpdetailid -> MoDetailId
|
||||
// BatchCode = 工序编码 -> StepCode
|
||||
// CreateBy = 操作员 -> WorkerCode
|
||||
// ReceiptCode = 校验员 -> Maker
|
||||
// CompanyCode = 公司 -> ErpCode
|
||||
var request = new FinishInRequest
|
||||
{
|
||||
Main = new FinishInMain
|
||||
{
|
||||
ErpCode = "001", // 账套号
|
||||
InCode = inv.SourceCode, // 报工单号(上游单号)
|
||||
InDate = (inv.CreateTime ?? DateTime.Now).ToString("yyyy-MM-dd"), // 报工日期
|
||||
StepCode = inv.BatchCode, // 工序(批次编码)
|
||||
WorkerCode = inv.CreateBy, // 工人编码(创建人)
|
||||
Maker = inv.ReceiptCode // 制单人(校验员)
|
||||
},
|
||||
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", "Api/FinishIn", HttpMethodEnum.POST, request);
|
||||
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
inv.UploadErpFlag = 1;
|
||||
_unitWork.Update(inv);
|
||||
return FFResult().Alert("回传ERP成功").RefreshGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
inv.UploadErpFlag = 0;
|
||||
_unitWork.Update(inv);
|
||||
return FFResult().Alert(apiResult.ErrorMsg?? "调用ERP接口失败").RefreshGrid();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return FFResult().Alert($"回传ERP失败:{ex.Message}" ).RefreshGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +54,8 @@ 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),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
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.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
@ -67,7 +69,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 +236,393 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
[ActionDescription("GetReceiptDetails")]
|
||||
public ActionResult GetReceiptDetails()
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptHeaderVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据入库单单号获取ERP生产订单数据并更新
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[ActionDescription("GetReceiptDetails")]
|
||||
public async Task<IActionResult> GetReceiptDetails(ReceiptHeaderVM vm)
|
||||
{
|
||||
string receiptCode = vm.Entity.SourceCode;
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(receiptCode))
|
||||
{
|
||||
return FFResult().Alert($"入库单单号不能为空");
|
||||
}
|
||||
|
||||
// 根据入库单单号查找对应的 SourceCode(生产订单号)
|
||||
var header = _unitwork.FindSingle<ReceiptHeader>(h => h.SourceCode == receiptCode);
|
||||
if (header != null)
|
||||
{
|
||||
return FFResult().Alert($"已存在此入库单,单号:{receiptCode}");
|
||||
}
|
||||
|
||||
// 调用 ERP 接口获取该订单的最新数据
|
||||
var request = new LoadMoDetailListRequest
|
||||
{
|
||||
ErpCode = "001",
|
||||
MoCode = receiptCode, // 使用生产订单号查询
|
||||
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.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 FFResult().CloseDialog().RefreshGrid().Message("订单数据获取成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().Alert(apiResult?.Data?.Msg ?? apiResult?.ErrorMsg ?? "未获取到订单数据");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Wtm.DoLog("获取ERP订单数据", ActionLogTypesEnum.Normal, "GetReceiptDetails",
|
||||
request: $"入库单号:{receiptCode}",
|
||||
result: $"错误:{ex.Message}");
|
||||
return FFResult().Alert($"获取订单数据失败:{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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,37 +42,164 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
#region API Methods
|
||||
|
||||
/// <summary>
|
||||
/// 搜索物料
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> SearchMaterials(string keyword)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
return Json(new { Code = 200, Data = new object[] { } });
|
||||
}
|
||||
|
||||
// 尝试调用接口获取物料
|
||||
try
|
||||
{
|
||||
var request = new LoadInventoryRequest
|
||||
{
|
||||
ErpCode = "001",
|
||||
InvDefine1 = keyword,
|
||||
Size = 15,
|
||||
Page = 1
|
||||
};
|
||||
|
||||
var apiResult =
|
||||
await Wtm.CallAPI<LoadInventoryResponse>("ERP", "LoadInventory", HttpMethodEnum.POST, request);
|
||||
|
||||
if (apiResult?.Data != null && apiResult.Data.Code == 0)
|
||||
{
|
||||
var materialsList = 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
|
||||
{
|
||||
// 物料已存在,添加到返回列表
|
||||
materialsList.Add(new
|
||||
{
|
||||
MaterialCode = existingMaterial.MaterialCode,
|
||||
MaterialName = existingMaterial.MaterialName,
|
||||
MaterialSpec = existingMaterial.MaterialSpec,
|
||||
MaterialUnit = existingMaterial.MaterialUnit,
|
||||
MaterialType = existingMaterial.MaterialType,
|
||||
SupplierCode = existingMaterial.SupplierCode
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 保存新增的物料
|
||||
_unitWork.BatchAdd(newMaterials);
|
||||
|
||||
// 返回物料列表到前端
|
||||
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 = localMaterials });
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
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")
|
||||
.Select(x => new {x.ITCode,x.Name})
|
||||
.Select(x => new
|
||||
{
|
||||
value = x.ITCode,
|
||||
label = x.Name
|
||||
})
|
||||
.ToList();
|
||||
return Json(new { Code = 200, Data = users});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult GetProcesses()
|
||||
{
|
||||
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
|
||||
})
|
||||
.ToList();
|
||||
return Json(new { Code = 200, Data = processes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(new { Code = 500, Msg = $"获取工序列表失败:{ex.Message}" });
|
||||
}
|
||||
return Json(new { Code = 200, Data = users });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的工序列表
|
||||
/// </summary>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult GetProcessesByMaterial(string materialCode)
|
||||
{
|
||||
@ -85,8 +212,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 +228,37 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult GetOperatorInfo()
|
||||
{
|
||||
var users = _unitWork.Find<FrameworkUser>(x => x.ITCode != "Admin")
|
||||
.Select(x => new {x.ITCode,x.Name})
|
||||
.ToList();
|
||||
return Json(new { Code = 200, Data = users});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的单据信息
|
||||
/// </summary>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult GetOrdersByMaterial(string materialCode)
|
||||
{
|
||||
// TODO: 根据物料码查询相关生产订单
|
||||
var orders = new List<object>
|
||||
{
|
||||
new { value = "1", label = "生产订单1" },
|
||||
new { value = "2", label = "生产订单2" }
|
||||
};
|
||||
// 查询包含这个物料的入库单单号
|
||||
|
||||
var orders = _unitWork.Find<ReceiptDetail>(x => x.MaterialCode == materialCode)
|
||||
.Select(x => new
|
||||
{
|
||||
value = x.Lot,
|
||||
label = x.SourceCode,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return Json(new { Code = 200, Data = orders });
|
||||
}
|
||||
|
||||
/// <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,32 +268,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);
|
||||
@ -169,7 +312,7 @@ namespace HHWMS.Web.Controllers
|
||||
{
|
||||
return Json(new { Code = 500, Msg = "未找到此物料工序配置" });
|
||||
}
|
||||
|
||||
|
||||
// 下一道工序
|
||||
var nextProcess = materialProcessList
|
||||
// 筛选同一物料
|
||||
@ -180,25 +323,26 @@ namespace HHWMS.Web.Controllers
|
||||
.OrderBy(p => p.ProcessOrder)
|
||||
// 取第一个(下一道工序)
|
||||
.FirstOrDefault();
|
||||
|
||||
|
||||
// 从字典查询工序对应的区域
|
||||
var zoneName = _unitWork.FindSingle<ProcessConfig>(x =>
|
||||
var zoneName = _unitWork.FindSingle<ProcessConfig>(x =>
|
||||
x.Code == nextProcess.ProcessCode)?.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())
|
||||
{
|
||||
@ -235,13 +379,15 @@ namespace HHWMS.Web.Controllers
|
||||
MaterialSpec = material.MaterialSpec,
|
||||
MaterialUnit = material.MaterialUnit,
|
||||
SupplierCode = material.SupplierCode,
|
||||
SourceCode = model.SourceCode,
|
||||
SourceCode = model.OrderId, // 单号
|
||||
ReceiptDetailId = model.SourceCode, // erpdetailid 回传使用
|
||||
BatchCode = materialProcess.ProcessCode, //erp回传使用 批次编码
|
||||
Batch = materialProcess.ProcessName,
|
||||
Lot = nextProcess?.ProcessName,
|
||||
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
|
||||
@ -257,8 +403,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.锁定,
|
||||
@ -268,12 +415,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接口下发任务
|
||||
@ -288,14 +435,15 @@ 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;
|
||||
|
||||
if (wcsResult != null && wcsResult.Success)
|
||||
{
|
||||
// WCS任务下发成功,提交事务
|
||||
taskHeader.Status = TaskStatusEnum.已下发;
|
||||
_unitWork.Update(taskHeader);
|
||||
|
||||
|
||||
tran.Commit();
|
||||
return Json(new { Code = 200, Msg = "入库成功", Data = new { TaskNo = taskNo } });
|
||||
}
|
||||
@ -329,16 +477,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())
|
||||
{
|
||||
@ -363,7 +512,7 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
_unitWork.Add(taskHeader);
|
||||
|
||||
|
||||
|
||||
// 5. 锁定容器和库位
|
||||
container.IsLock = ContainerLockEnum.任务锁;
|
||||
container.LocationCode = locationCode;
|
||||
@ -372,8 +521,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.锁定,
|
||||
@ -383,12 +533,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接口下发任务
|
||||
@ -401,7 +551,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)
|
||||
{
|
||||
@ -422,7 +573,8 @@ namespace HHWMS.Web.Controllers
|
||||
tran.Rollback();
|
||||
return Json(new { Code = 500, Msg = ex.Message });
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 空托盘出库
|
||||
@ -436,18 +588,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,
|
||||
@ -458,12 +610,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.锁定;
|
||||
@ -475,38 +627,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
|
||||
}
|
||||
@ -525,7 +645,7 @@ namespace HHWMS.Web.Controllers
|
||||
public bool IsQualified { get; set; }
|
||||
public string OperatorInfo { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class LineRange
|
||||
{
|
||||
public int BeginLine { get; set; }
|
||||
|
||||
@ -215,6 +215,10 @@ 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)
|
||||
|
||||
@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
@model HHWMS.Web.ReceiptHeaderVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.One">
|
||||
<wt:textbox field="Entity.SourceCode" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -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" disabled="true"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="当前工序" field="processId">
|
||||
@ -40,7 +40,13 @@
|
||||
</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-select v-model="form.sourceCode" placeholder="请选择单号" 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 field="type" label="小托盘类型" >
|
||||
@ -132,6 +138,7 @@
|
||||
operatorInfo: ''
|
||||
});
|
||||
const processOptions = ref([]);
|
||||
const orderOptions = ref([]);
|
||||
const materialOptions = ref([]);
|
||||
let searchTimer = null;
|
||||
|
||||
@ -178,27 +185,46 @@
|
||||
|
||||
const processSelect = (value) => {
|
||||
form.processName = processOptions.value.find(item => item.value === value).processName;
|
||||
// 选择工序后,加载订单列表
|
||||
loadOrdersByMaterial(form.materialCode);
|
||||
focusNext('sourceCodeRef');
|
||||
}
|
||||
|
||||
// 加载工序列表
|
||||
const loadProcesses = () => {
|
||||
|
||||
const orderSelect = (value) => {
|
||||
form.orderId = orderOptions.value.find(item => item.value === value).label;
|
||||
focusNext('numInput');
|
||||
}
|
||||
|
||||
// 根据物料加载订单列表
|
||||
const loadOrdersByMaterial = (materialCode) => {
|
||||
if (!materialCode) {
|
||||
form.sourceCode = '';
|
||||
orderOptions.value = [];
|
||||
return;
|
||||
}
|
||||
orderOptions.value = [];
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
url: "/receipt/ReceiptIn/GetProcesses",
|
||||
data: { materialCode: materialCode },
|
||||
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 +262,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 扫描托盘码
|
||||
const scanPallet = () => {
|
||||
if (!form.palletCode) return;
|
||||
// TODO: 实现托盘码验证逻辑
|
||||
};
|
||||
|
||||
// 处理物料搜索
|
||||
const handleMaterialSearch = (value) => {
|
||||
if (searchTimer) {
|
||||
@ -253,13 +273,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 => ({
|
||||
@ -412,6 +432,7 @@
|
||||
const resetForm = () => {
|
||||
formRef.value.resetFields();
|
||||
processOptions.value = [];
|
||||
orderOptions.value = [];
|
||||
setTimeout(() => {
|
||||
if (palletCodeRef.value) {
|
||||
palletCodeRef.value.focus();
|
||||
@ -460,8 +481,8 @@
|
||||
form,
|
||||
loading,
|
||||
processOptions,
|
||||
orderOptions,
|
||||
rules,
|
||||
scanPallet,
|
||||
validateContainer,
|
||||
scanMaterial,
|
||||
submitForm,
|
||||
@ -478,9 +499,9 @@
|
||||
operatorIdRef,
|
||||
operatorInfoRef,
|
||||
focusNext,
|
||||
loadProcesses,
|
||||
loadProcessesByMaterial,
|
||||
processSelect,
|
||||
orderSelect,
|
||||
trayTypeOptions
|
||||
};
|
||||
}
|
||||
|
||||
288
HHWMS.Web/Areas/System/Controllers/jobs/LoadErpOrderJob.cs
Normal file
288
HHWMS.Web/Areas/System/Controllers/jobs/LoadErpOrderJob.cs
Normal file
@ -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 = "001",
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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; }
|
||||
@ -83,7 +87,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 +100,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; }
|
||||
|
||||
77
HHWMS.Web/Models/Request/Request/FinishInRequest.cs
Normal file
77
HHWMS.Web/Models/Request/Request/FinishInRequest.cs
Normal file
@ -0,0 +1,77 @@
|
||||
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; }
|
||||
}
|
||||
|
||||
/// <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; }
|
||||
}
|
||||
}
|
||||
48
HHWMS.Web/Models/Request/Request/LoadInventoryRequest.cs
Normal file
48
HHWMS.Web/Models/Request/Request/LoadInventoryRequest.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
34
HHWMS.Web/Models/Request/Request/LoadMoDetailListRequest.cs
Normal file
34
HHWMS.Web/Models/Request/Request/LoadMoDetailListRequest.cs
Normal file
@ -0,0 +1,34 @@
|
||||
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 InvCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每页大小,必填
|
||||
/// </summary>
|
||||
public int Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码,必填
|
||||
/// </summary>
|
||||
public int Page { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
18
HHWMS.Web/Models/Request/Response/FinishInResponse.cs
Normal file
18
HHWMS.Web/Models/Request/Response/FinishInResponse.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
71
HHWMS.Web/Models/Request/Response/LoadInventoryResponse.cs
Normal file
71
HHWMS.Web/Models/Request/Response/LoadInventoryResponse.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
113
HHWMS.Web/Models/Request/Response/LoadMoDetailListResponse.cs
Normal file
113
HHWMS.Web/Models/Request/Response/LoadMoDetailListResponse.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,6 +94,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": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user