Compare commits
No commits in common. "master" and "iot" have entirely different histories.
6
.gitignore
vendored
6
.gitignore
vendored
@ -41,8 +41,6 @@ bld/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
.rider/
|
||||
.idea/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
@ -281,7 +279,3 @@ __pycache__/
|
||||
/nuget.exe
|
||||
/demo/WalkingTec.Mvvm.VueDemo/ClientApp/yarn.lock
|
||||
*.lock
|
||||
.DS_Store
|
||||
|
||||
[core]
|
||||
autocrlf = input
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "6.0.11",
|
||||
"version": "5.0.2",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
|
||||
@ -6,12 +6,12 @@ namespace HHWMS.Web
|
||||
{
|
||||
public abstract class ApiController : BaseApiController
|
||||
{
|
||||
protected JsonResult ApiResult(object data = null, string msg = "操作成功!")
|
||||
protected JsonResult ApiResult(object data = null, string msg = "success")
|
||||
{
|
||||
return new JsonResult(new ApiJsonResult<object> { Data = data, Success = true, Status = true, Msg = msg });
|
||||
}
|
||||
|
||||
protected JsonResult ApiResultError(object data = null, string msg = "操作失败!")
|
||||
protected JsonResult ApiResultError(object data = null, string msg = "faield")
|
||||
{
|
||||
return new JsonResult(new ApiJsonResult<object> { Data = data, Success = false, Status = false, Msg = msg });
|
||||
}
|
||||
|
||||
@ -1,23 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using HHWMS.Web.Models;
|
||||
using HHWMS.Web.Support;
|
||||
using HHWMS.Web.Support.PLC;
|
||||
using HslCommunication;
|
||||
using HslCommunication.Profinet.Siemens;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using HslCommunication.Core;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// 提供给WCS调用接口
|
||||
/// WCS接口
|
||||
/// 调用方向 WCS --> WMS
|
||||
/// </summary>
|
||||
[Public]
|
||||
@ -26,264 +16,43 @@ namespace HHWMS.Web
|
||||
[Route("api/[controller]/[action]"), ApiExplorerSettings(GroupName = "User")]
|
||||
public class IWCSController : ApiController
|
||||
{
|
||||
private readonly IUnitWork _unitWork;
|
||||
private readonly IUnitWork _unitwork;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IMemoryCache _cache;
|
||||
private const int DEBOUNCE_INTERVAL_MS = 1000; // 防抖间隔1秒
|
||||
private readonly PLCHelper _plcHelper;
|
||||
|
||||
public IWCSController(IUnitWork unitWork, IMapper mapper, IMemoryCache cache, PLCHelper plcHelper)
|
||||
public IWCSController(IUnitWork unitwork, IMapper mapper)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
_unitwork = unitwork;
|
||||
_mapper = mapper;
|
||||
_cache = cache;
|
||||
_plcHelper = plcHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 防抖处理装饰器
|
||||
/// </summary>
|
||||
private async Task<IActionResult> WithDebounce(string key, Func<Task<IActionResult>> action)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 使用key作为请求标识
|
||||
string requestKey = $"Debounce_{key}";
|
||||
|
||||
// 检查是否存在处理中的相同请求
|
||||
if (_cache.TryGetValue(requestKey, out DateTime lastRequestTime))
|
||||
{
|
||||
var timeSinceLastRequest = DateTime.Now - lastRequestTime;
|
||||
if (timeSinceLastRequest.TotalMilliseconds < DEBOUNCE_INTERVAL_MS)
|
||||
{
|
||||
var remainingSeconds = Math.Ceiling((DEBOUNCE_INTERVAL_MS - timeSinceLastRequest.TotalMilliseconds) / 1000);
|
||||
return ApiResultError($"请求过于频繁,请等待{remainingSeconds}秒后重试");
|
||||
}
|
||||
}
|
||||
|
||||
// 添加或更新缓存(设置防抖间隔时间)
|
||||
var cacheEntryOptions = new MemoryCacheEntryOptions()
|
||||
.SetAbsoluteExpiration(TimeSpan.FromMilliseconds(DEBOUNCE_INTERVAL_MS));
|
||||
_cache.Set(requestKey, DateTime.Now, cacheEntryOptions);
|
||||
|
||||
try
|
||||
{
|
||||
// 执行实际的业务逻辑
|
||||
return await action();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 处理失败时移除缓存,允许重试
|
||||
_cache.Remove(requestKey);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResultError($"处理请求时发生错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求入库(带防抖)
|
||||
/// 请求入库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Task<IActionResult> RequestIn(WcsRequest request)
|
||||
public IActionResult RequestIn(WcsRequest request)
|
||||
{
|
||||
if (request == null || string.IsNullOrEmpty(request.PalletNo))
|
||||
{
|
||||
return Task.FromResult<IActionResult>(ApiResultError("请求参数无效"));
|
||||
}
|
||||
|
||||
return WithDebounce($"RequestIn_{request.PalletNo}", async () =>
|
||||
{
|
||||
await ProcessRequestIn(request);
|
||||
return ApiResult(new { Message = "入库请求处理成功" });
|
||||
});
|
||||
var inv = new List<Inventory>();
|
||||
for (int i = 0; i < 10; i++)
|
||||
inv.Add(new Inventory
|
||||
{
|
||||
ContainerCode = "test" + i
|
||||
});
|
||||
//_unitwork.BatchAdd<Inventory>(inv);
|
||||
_unitwork.DeleteById<Inventory>(1441);
|
||||
//_unitwork.BatchUpdate<Inventory>(x => x.ID > 1030, x=>new Inventory { Batch = "test"});
|
||||
return ApiResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理入库请求的具体业务逻辑
|
||||
/// </summary>
|
||||
private async Task ProcessRequestIn(WcsRequest request)
|
||||
{
|
||||
// TODO: 实现具体的入库处理逻辑
|
||||
var t = 0;
|
||||
var plc = new SiemensS7Net( SiemensPLCS.S1200, "10.211.55.4" );
|
||||
var read = await plc.ReadInt32Async( "V2634" );
|
||||
if (read.IsSuccess)
|
||||
{
|
||||
t = read.Content;
|
||||
}
|
||||
var write = await plc.WriteAsync( "V2634", t + 1 );
|
||||
await Task.Delay(1000); // 模拟异步处理
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 状态返回(带防抖)
|
||||
/// 状态返回
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Task<IActionResult> TaskStatusResult(WcsRequest request)
|
||||
public IActionResult TaskStatusResult(WcsRequest request)
|
||||
{
|
||||
if (request == null || string.IsNullOrEmpty(request.PalletNo))
|
||||
{
|
||||
return Task.FromResult<IActionResult>(ApiResultError("请求参数无效"));
|
||||
}
|
||||
|
||||
return WithDebounce($"TaskStatus_{request.PalletNo}", () => Task.FromResult<IActionResult>(ApiResult()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求空闲库位(带防抖)
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public Task<IActionResult> RequestLocation(WcsRequest request)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request?.PalletNo))
|
||||
{
|
||||
return Task.FromResult<IActionResult>(ApiResultError("容器编码不能为空"));
|
||||
}
|
||||
|
||||
return WithDebounce($"RequestLocation_{request.PalletNo}", () =>
|
||||
{
|
||||
var vm = Wtm.CreateVM<LocationVM>();
|
||||
var code = vm.GetLocation(request);
|
||||
if (code.Status)
|
||||
{
|
||||
UpdateLocationAndContainer(code.Data.LocationCode, request.PalletNo);
|
||||
return Task.FromResult<IActionResult>(ApiResult(code.Data));
|
||||
}
|
||||
return Task.FromResult<IActionResult>(ApiResultError("没有符合条件的可用库位"));
|
||||
});
|
||||
}
|
||||
|
||||
private IActionResult UpdateLocationAndContainer(string locationCode, string palletNo)
|
||||
{
|
||||
var location = _unitWork.Find<Location>(x => x.Code == locationCode).FirstOrDefault();
|
||||
location.ContainerCode = palletNo;
|
||||
location.Status = LocationStatus.任务锁;
|
||||
_unitWork.Update(location);
|
||||
|
||||
var container = _unitWork.Find<Container>(x => x.Code == palletNo).FirstOrDefault();
|
||||
if (container != null)
|
||||
{
|
||||
container.LocationCode = location.Code;
|
||||
_unitWork.Update(container);
|
||||
}
|
||||
|
||||
return ApiResult(new { LocationCode = location.Code });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PLC通信测试接口
|
||||
/// </summary>
|
||||
/// <param name="request">通信参数</param>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CommunicateWithPLC(PlcCommunicationRequest request)
|
||||
{
|
||||
if (request == null)
|
||||
{
|
||||
return ApiResultError("请求参数不能为空");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 连接PLC
|
||||
if (!_plcHelper.Connect(PlcType.Siemens, request.IpAddress))
|
||||
{
|
||||
return ApiResultError(msg:"PLC连接失败");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 根据操作类型执行不同的读写操作
|
||||
switch (request.OperationType)
|
||||
{
|
||||
case "ReadInt32":
|
||||
var value = _plcHelper.ReadInt32(request.Address);
|
||||
return ApiResult(new { Value = value });
|
||||
|
||||
case "WriteInt16":
|
||||
if (!short.TryParse(request.Value, out short shortValue))
|
||||
{
|
||||
return ApiResultError(msg: "无效的数值");
|
||||
}
|
||||
var writeResult = _plcHelper.WriteInt16(request.Address, shortValue);
|
||||
return ApiResult(new { Success = writeResult });
|
||||
|
||||
case "ReadBool":
|
||||
var boolValue = _plcHelper.ReadBool(request.Address);
|
||||
return ApiResult(new { Value = boolValue });
|
||||
|
||||
case "WriteBool":
|
||||
if (!bool.TryParse(request.Value, out bool boolWriteValue))
|
||||
{
|
||||
return ApiResultError("无效的布尔值");
|
||||
}
|
||||
var boolWriteResult = _plcHelper.WriteBool(request.Address, boolWriteValue);
|
||||
return ApiResult(new { Success = boolWriteResult });
|
||||
|
||||
case "ReadString":
|
||||
if (!ushort.TryParse(request.StringLength, out ushort length))
|
||||
{
|
||||
return ApiResultError("无效的字符串长度");
|
||||
}
|
||||
var stringValue = _plcHelper.ReadString(request.Address, length);
|
||||
return ApiResult(new { Value = stringValue });
|
||||
|
||||
case "WriteString":
|
||||
if (!ushort.TryParse(request.StringLength, out ushort writeLength))
|
||||
{
|
||||
return ApiResultError("无效的字符串长度");
|
||||
}
|
||||
var stringWriteResult = _plcHelper.WriteString(request.Address, request.Value, writeLength);
|
||||
return ApiResult(new { Success = stringWriteResult });
|
||||
|
||||
default:
|
||||
return ApiResultError("不支持的操作类型");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 确保操作完成后断开连接
|
||||
_plcHelper.Disconnect();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResultError($"PLC操作失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PLC通信请求参数类
|
||||
/// </summary>
|
||||
public class PlcCommunicationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// PLC的IP地址
|
||||
/// </summary>
|
||||
public string IpAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型(ReadInt16, WriteInt16, ReadBool, WriteBool, ReadString, WriteString)
|
||||
/// </summary>
|
||||
public string OperationType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PLC地址(例如"DB1.0")
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 要写入的值(用于写操作)
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字符串长度(用于字符串操作)
|
||||
/// </summary>
|
||||
public string StringLength { get; set; }
|
||||
return ApiResult();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ namespace HHWMS.Web.Controllers
|
||||
Row = row,
|
||||
Line = line,
|
||||
Layer = layer,
|
||||
RowFlag = (short?)(vm.RoadwayType == 1 || vm.RoadwayType == 2 ? 0 : (row == 1 || row == 4 ? 1 : 0)),
|
||||
RowFlag = (short?)(row == 1 || row == 4 ? 1 : 0),
|
||||
ContiguousCode = vm.RoadwayType == 4 ? $"{vm.Entity.Type}{vm.Entity.RoadWay.ToString().PadLeft(2, '0')}-{(row % 2 == 0?row-1:row+1) .ToString().PadLeft(2, '0')}-{line.ToString().PadLeft(2, '0')}-{layer.ToString().PadLeft(2, '0')}" : null,
|
||||
IsStop = false,
|
||||
Status = LocationStatus.空仓位,
|
||||
|
||||
@ -1,240 +0,0 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web;
|
||||
using System.DirectoryServices.Protocols;
|
||||
using System.Web;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Area("configs")]
|
||||
[ActionDescription("打印模板配置")]
|
||||
public partial class PrintConfigController : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitWork;
|
||||
|
||||
public PrintConfigController(IUnitWork unitWork)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
#region Search
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(PrintConfigSearcher searcher)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Create
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(PrintConfigVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoAdd();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[HttpPost]
|
||||
[ValidateFormItemOnly]
|
||||
public ActionResult Edit(PrintConfigVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
//替换 "
|
||||
vm.Entity.Template = HttpUtility.HtmlDecode(vm.Entity.Template);
|
||||
|
||||
vm.DoEdit();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Delete
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public ActionResult Delete(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
[HttpPost]
|
||||
public ActionResult Delete(string id, IFormCollection nouse)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
vm.DoDelete();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Details
|
||||
[ActionDescription("Sys.Details")]
|
||||
public ActionResult Details(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BatchEdit
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult BatchEdit(string[] IDs)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult DoBatchEdit(PrintConfigBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (!ModelState.IsValid || !vm.DoBatchEdit())
|
||||
{
|
||||
return PartialView("BatchEdit",vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchEditSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BatchDelete
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(string[] IDs)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult DoBatchDelete(PrintConfigBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete",vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Import
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import()
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigImportVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import(PrintConfigImportVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData())
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(PrintConfigListVM vm)
|
||||
{
|
||||
return vm.GetExportData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
[ActionDescription("Sys.Print")]
|
||||
public ActionResult Design(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HHWMS.Web.Models;
|
||||
using IoTClient.Clients.PLC;
|
||||
using IoTClient.Common.Enums;
|
||||
using IoTClient.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Query.Expressions.Internal;
|
||||
using NPOI.XSSF.Streaming.Values;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
|
||||
@ -11,10 +11,6 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class LocationVM : BaseCRUDVM<Location>
|
||||
{
|
||||
public LocationVM()
|
||||
{
|
||||
}
|
||||
|
||||
public InventoryListVM Inventorys { get; set; } = new InventoryListVM();
|
||||
|
||||
[Display(Name = "Location.BeginLine", Description = "起始列")]
|
||||
@ -36,6 +32,10 @@ namespace HHWMS.Web
|
||||
public List<ComboSelectListItem> Types { get; set; }
|
||||
public List<ComboSelectListItem> LocationStatus { get; set; }
|
||||
|
||||
public LocationVM()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
Inventorys.CopyContext(this);
|
||||
@ -88,250 +88,123 @@ namespace HHWMS.Web
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找单伸位巷道的空仓位
|
||||
/// </summary>
|
||||
private string GetEmptyLocationBySingle(int? roadway)
|
||||
{
|
||||
var locations = DC.Set<Location>()
|
||||
.Where(l => l.RoadWay == roadway
|
||||
&& l.Status == "empty"
|
||||
&& l.RowFlag == 0) // 单伸位只查找外仓位
|
||||
.OrderBy(l => l.Layer)
|
||||
.ThenBy(l => l.Line)
|
||||
.FirstOrDefault();
|
||||
|
||||
return locations?.Code;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找双伸位巷道的空仓位
|
||||
/// </summary>
|
||||
private string GetEmptyLocationByDouble(int roadway)
|
||||
{
|
||||
// 一次性获取所需的所有数据,避免多次查询数据库
|
||||
var locationPairs = DC.Set<Location>()
|
||||
.Where(l => l.RoadWay == roadway)
|
||||
.Select(l => new
|
||||
{
|
||||
l.Code,
|
||||
l.ContiguousCode,
|
||||
l.Status,
|
||||
l.RowFlag,
|
||||
l.Layer,
|
||||
l.Line
|
||||
})
|
||||
.ToDictionary(l => l.Code);
|
||||
|
||||
// 1. 优先查找里外仓位都为空的里仓位
|
||||
var emptyInnerLocation = locationPairs.Values
|
||||
.Where(l => l.RowFlag == 1
|
||||
&& l.Status == "empty"
|
||||
&& locationPairs.TryGetValue(l.ContiguousCode, out var outer)
|
||||
&& outer.Status == "empty")
|
||||
.OrderBy(l => l.Layer)
|
||||
.ThenBy(l => l.Line)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (emptyInnerLocation != null)
|
||||
{
|
||||
return emptyInnerLocation.Code;
|
||||
}
|
||||
|
||||
// 2. 查找里仓位有货,外仓位为空的外仓位
|
||||
var availableOuterLocation = locationPairs.Values
|
||||
.Where(l => l.RowFlag == 0
|
||||
&& l.Status == "empty"
|
||||
&& locationPairs.TryGetValue(l.ContiguousCode, out var inner)
|
||||
&& inner.Status == "some")
|
||||
.OrderBy(l => l.Layer)
|
||||
.ThenBy(l => l.Line)
|
||||
.FirstOrDefault();
|
||||
|
||||
return availableOuterLocation?.Code;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据巷道类型查找可用仓位
|
||||
/// 查找库位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ResponseResult<dynamic> GetLocation(WcsRequest request)
|
||||
{
|
||||
if (!request.RoadWay.HasValue)
|
||||
var res = ResponseResult<dynamic>.Success(new {LocationCode = "test"});
|
||||
return res;
|
||||
//return GetOutEmptyLocation(request);
|
||||
/*if (request.RoadWay == null)
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("巷道号不能为空");
|
||||
// 根据条件查询巷道 (巷道均分,根据托盘类型分)
|
||||
request.RoadWay = SelectRoadWay(request);
|
||||
if(SelectRoadWay(request) == 0)
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("未找到可用巷道!");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取巷道类型
|
||||
var roadwayType = GetRoadwayType(request.RoadWay);
|
||||
if (roadwayType == null)
|
||||
else
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("未找到对应的巷道类型");
|
||||
// 查询该巷道类型 调用不同的方法
|
||||
return GetLocationByOne(request);
|
||||
}
|
||||
|
||||
string locationCode;
|
||||
switch (roadwayType)
|
||||
{
|
||||
case 1: // 单边位
|
||||
case 2: // 单伸位
|
||||
locationCode = GetEmptyLocationBySingle(request.RoadWay.Value);
|
||||
break;
|
||||
case 4: // 双伸位
|
||||
locationCode = GetEmptyLocationByDouble(request.RoadWay.Value);
|
||||
break;
|
||||
default:
|
||||
return ResponseResult<dynamic>.Error("未知的巷道类型");
|
||||
}
|
||||
|
||||
if (locationCode == null)
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("未找到可用的空仓位");
|
||||
}
|
||||
|
||||
return ResponseResult<dynamic>.Success(new { LocationCode = locationCode });
|
||||
return "";*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据巷道名称获取巷道类型
|
||||
/// 单伸位 查找仓位
|
||||
/// </summary>
|
||||
/// <param name="roadwayName">巷道名称</param>
|
||||
/// <returns>巷道类型(2代表单伸位,4代表双伸位)</returns>
|
||||
private int? GetRoadwayType(int? roadwayName)
|
||||
/// <returns></returns>
|
||||
public string GetLocationByOne(WcsRequest request)
|
||||
{
|
||||
var dictData = DC.Set<SysDictData>()
|
||||
.FirstOrDefault(x => x.DictType == "RoadwayConfig" && x.DictLabel == roadwayName.ToString());
|
||||
|
||||
if (dictData != null)
|
||||
{
|
||||
if (int.TryParse(dictData.DictValue, out int roadwayType))
|
||||
{
|
||||
return roadwayType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
// 根据托盘类型/传入的长宽高 查找库位
|
||||
var locationList = _unitWork.Find<Location>(x => x.RoadWay == request.RoadWay);
|
||||
locationList = locationList.WhereIf(request.Length > 0, x => x.Length == request.Length)
|
||||
.WhereIf(request.Width > 0, x => x.Width == request.Width)
|
||||
.WhereIf(request.Height > 0, x => x.Height >= request.Height)
|
||||
.OrderBy(x => x.Height);
|
||||
var location = locationList.OrderBy(x => x.Layer)
|
||||
.ThenBy(x => x.Line)
|
||||
.FirstOrDefault();
|
||||
return location?.Code;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有巷道的可用仓位
|
||||
/// 双伸位 查找仓位
|
||||
/// </summary>
|
||||
public ResponseResult<dynamic> GetAllAvailableLocations()
|
||||
/// <returns></returns>
|
||||
public string GetLocationByTwo(WcsRequest request)
|
||||
{
|
||||
// 获取所有巷道配置
|
||||
var roadwayConfigs = DC.Set<SysDictData>()
|
||||
.Where(x => x.DictType == "RoadwayConfig")
|
||||
.Select(x => new
|
||||
{
|
||||
Roadway = x.DictLabel,
|
||||
Type = x.DictValue
|
||||
})
|
||||
.ToDictionary(x => x.Roadway, x => x.Type);
|
||||
// 根据托盘类型 查找库位 todo
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!roadwayConfigs.Any())
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("未找到巷道配置");
|
||||
}
|
||||
|
||||
// 一次性获取所有库位数据
|
||||
var allLocations = DC.Set<Location>()
|
||||
.Select(l => new
|
||||
/// <summary>
|
||||
/// 双伸位,获取里仓位有货,外仓位无货的仓位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetOutEmptyLocation(WcsRequest request)
|
||||
{
|
||||
int roadWay = (int)request.RoadWay;
|
||||
var locationList = _unitWork.Find<Location>(x => x.RoadWay == roadWay)
|
||||
.Join(_unitWork.Find<Location>(x => x.RoadWay == roadWay),
|
||||
a => a.ContiguousCode, g => g.Code,
|
||||
(a, g) => new
|
||||
{
|
||||
l.Code,
|
||||
l.ContiguousCode,
|
||||
l.Status,
|
||||
l.RowFlag,
|
||||
l.Layer,
|
||||
l.Line,
|
||||
l.RoadWay,
|
||||
l.ZoneCode
|
||||
})
|
||||
.ToDictionary(l => l.Code);
|
||||
a.Code,
|
||||
a.Status,
|
||||
a.RowFlag,
|
||||
a.Layer,
|
||||
a.Line,
|
||||
ContiguousCode = g.Code,
|
||||
Status1 = g.Status
|
||||
}).ToList();
|
||||
var location = locationList.Where(x => x.RowFlag == 0 && x.Status == "empty" && x.Status1 == "some")
|
||||
.OrderBy(x => x.Layer)
|
||||
.ThenBy(x => x.Line)
|
||||
.FirstOrDefault()?.Code;
|
||||
return location;
|
||||
}
|
||||
|
||||
var availableLocations = new List<object>();
|
||||
|
||||
// 按巷道类型分组处理
|
||||
foreach (var config in roadwayConfigs)
|
||||
{
|
||||
var roadway = int.Parse(config.Key);
|
||||
var locationType = config.Value;
|
||||
|
||||
// 获取当前巷道的所有仓位
|
||||
var roadwayLocations = allLocations.Values
|
||||
.Where(l => l.RoadWay == roadway)
|
||||
.ToList();
|
||||
|
||||
if (!roadwayLocations.Any()) continue;
|
||||
|
||||
// 根据巷道类型处理
|
||||
switch (locationType)
|
||||
/// <summary>
|
||||
/// 双伸位,获取里外仓位都为空的仓位
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="rowFlag">0 返回外仓位,1返回里仓位</param>
|
||||
/// <returns></returns>
|
||||
public string GetAllEmptyLocation(WcsRequest request, int rowFlag)
|
||||
{
|
||||
int roadWay = (int)request.RoadWay;
|
||||
var locationList = _unitWork.Find<Location>(x => x.RoadWay == roadWay)
|
||||
.Join(_unitWork.Find<Location>(x => x.RoadWay == roadWay),
|
||||
a => a.ContiguousCode, g => g.Code,
|
||||
(a, g) => new
|
||||
{
|
||||
case "2": // 单伸位
|
||||
var singleLocations = roadwayLocations
|
||||
.Where(l => l.RowFlag == 0 && l.Status == "empty")
|
||||
.OrderBy(l => l.Layer)
|
||||
.ThenBy(l => l.Line)
|
||||
.Select(l => new
|
||||
{
|
||||
LocationCode = l.Code,
|
||||
l.ZoneCode,
|
||||
l.RoadWay,
|
||||
l.Layer,
|
||||
l.Line,
|
||||
Type = "单伸位"
|
||||
});
|
||||
availableLocations.AddRange(singleLocations);
|
||||
break;
|
||||
a.Code,
|
||||
a.Status,
|
||||
a.RowFlag,
|
||||
a.Layer,
|
||||
a.Line,
|
||||
ContiguousCode = g.Code,
|
||||
Status1 = g.Status
|
||||
}).ToList();
|
||||
var location = locationList.Where(x => x.RowFlag == rowFlag && x.Status == "empty" && x.Status1 == "empty")
|
||||
.OrderBy(x => x.Layer)
|
||||
.ThenBy(x => x.Line)
|
||||
.FirstOrDefault()?.Code;
|
||||
return location;
|
||||
}
|
||||
|
||||
case "4": // 双伸位
|
||||
// 1. 查找里外都为空的里仓位
|
||||
var emptyInnerLocations = roadwayLocations
|
||||
.Where(l => l.RowFlag == 1
|
||||
&& l.Status == "empty"
|
||||
&& allLocations.TryGetValue(l.ContiguousCode, out var outer)
|
||||
&& outer.Status == "empty")
|
||||
.OrderBy(l => l.Layer)
|
||||
.ThenBy(l => l.Line)
|
||||
.Select(l => new
|
||||
{
|
||||
LocationCode = l.Code,
|
||||
l.ZoneCode,
|
||||
l.RoadWay,
|
||||
l.Layer,
|
||||
l.Line,
|
||||
Type = "双伸位-里仓位"
|
||||
});
|
||||
availableLocations.AddRange(emptyInnerLocations);
|
||||
|
||||
// 2. 查找里仓位有货,外仓位为空的外仓位
|
||||
var availableOuterLocations = roadwayLocations
|
||||
.Where(l => l.RowFlag == 0
|
||||
&& l.Status == "empty"
|
||||
&& allLocations.TryGetValue(l.ContiguousCode, out var inner)
|
||||
&& inner.Status == "some")
|
||||
.OrderBy(l => l.Layer)
|
||||
.ThenBy(l => l.Line)
|
||||
.Select(l => new
|
||||
{
|
||||
LocationCode = l.Code,
|
||||
l.ZoneCode,
|
||||
l.RoadWay,
|
||||
l.Layer,
|
||||
l.Line,
|
||||
Type = "双伸位-外仓位"
|
||||
});
|
||||
availableLocations.AddRange(availableOuterLocations);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!availableLocations.Any())
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("未找到可用的空仓位");
|
||||
}
|
||||
|
||||
return ResponseResult<dynamic>.Success(new
|
||||
{
|
||||
Locations = availableLocations,
|
||||
Total = availableLocations.Count
|
||||
});
|
||||
/// <summary>
|
||||
/// 根据传入条件,查找可利用巷道
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public int SelectRoadWay(WcsRequest request)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
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 PrintConfigBatchVM : BaseBatchVM<PrintConfig, PrintConfig_BatchEdit>
|
||||
{
|
||||
public PrintConfigBatchVM()
|
||||
{
|
||||
ListVM = new PrintConfigListVM();
|
||||
LinkedVM = new PrintConfig_BatchEdit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class to define batch edit fields
|
||||
/// </summary>
|
||||
public class PrintConfig_BatchEdit : BaseVM
|
||||
{
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
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 PrintConfigTemplateVM : BaseTemplateVM
|
||||
{
|
||||
[Display(Name = "PrintConfig.Name")]
|
||||
public ExcelPropety Name_Excel = ExcelPropety.CreateProperty<PrintConfig>(x => x.Name);
|
||||
[Display(Name = "PrintConfig.Template")]
|
||||
public ExcelPropety Template_Excel = ExcelPropety.CreateProperty<PrintConfig>(x => x.Template);
|
||||
[Display(Name = "PrintConfig.TestData")]
|
||||
public ExcelPropety TestData_Excel = ExcelPropety.CreateProperty<PrintConfig>(x => x.TestData);
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PrintConfigImportVM : BaseImportVM<PrintConfigTemplateVM, PrintConfig>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
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 PrintConfigListVM : BasePagedListVM<PrintConfig_View, PrintConfigSearcher>
|
||||
{
|
||||
protected override List<GridAction> InitGridAction()
|
||||
{
|
||||
return new List<GridAction>
|
||||
{
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"),
|
||||
// 打印模板设计
|
||||
this.MakeAction("PrintConfig","Design",Localizer["Sys.Design"],Localizer["Sys.Design"],GridActionParameterTypesEnum.SingleId,"configs")
|
||||
.SetShowDialog(true)
|
||||
.SetMax(),
|
||||
// 打印预览
|
||||
this.MakeAction("PrintConfig","PrintPreview",Localizer["Sys.Print"],Localizer["Sys.Print"],GridActionParameterTypesEnum.SingleId,"configs")
|
||||
.SetShowDialog(false)
|
||||
.SetOnClickScript("print"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected override IEnumerable<IGridColumn<PrintConfig_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<PrintConfig_View>>{
|
||||
this.MakeGridHeader(x => x.Name),
|
||||
this.MakeGridHeader(x => x.Template),
|
||||
this.MakeGridHeader(x => x.TestData),
|
||||
this.MakeGridHeaderAction(width: 300)
|
||||
};
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<PrintConfig_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<PrintConfig>()
|
||||
.CheckContain(Searcher.Name, x=>x.Name)
|
||||
.Select(x => new PrintConfig_View
|
||||
{
|
||||
ID = x.ID,
|
||||
Name = x.Name,
|
||||
Template = x.Template,
|
||||
TestData = x.TestData,
|
||||
})
|
||||
.OrderBy(x => x.ID);
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PrintConfig_View : PrintConfig{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
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 PrintConfigSearcher : BaseSearcher
|
||||
{
|
||||
[Display(Name = "PrintConfig.Name")]
|
||||
public String Name { get; set; }
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class PrintConfigVM : BaseCRUDVM<PrintConfig>
|
||||
{
|
||||
|
||||
public PrintConfigVM()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DoAdd()
|
||||
{
|
||||
base.DoAdd();
|
||||
}
|
||||
|
||||
public override void DoEdit(bool updateAllFields = false)
|
||||
{
|
||||
base.DoEdit(updateAllFields);
|
||||
}
|
||||
|
||||
public override void DoDelete()
|
||||
{
|
||||
base.DoDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,200 +1,99 @@
|
||||
<script src="/Area/Configs/Print.js"></script>
|
||||
|
||||
<link href="/hiprint/content/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<wt:row>
|
||||
<!-- 列表 -->
|
||||
<div class="layui-col-xs1 layui-col-md1" style="padding-right:0px;">
|
||||
<div class="rect-printElement-types hiprintEpContainer">
|
||||
<ul class="hiprint-printElement-type">
|
||||
<li>
|
||||
<span class="title"><code>拖拽列表</code></span>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.text" style="">
|
||||
<span class="glyphicon glyphicon-text-width"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">文本</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.image" style="">
|
||||
<span class="glyphicon glyphicon-picture"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">图片</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.longText">
|
||||
<span class="glyphicon glyphicon-subscript"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">长文</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.tableCustom" style="">
|
||||
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">表格</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.html">
|
||||
<span class="glyphicon glyphicon-header"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">html</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">辅助</span>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.hline" style="">
|
||||
<span class="glyphicon glyphicon-resize-horizontal"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">横线</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.vline" style="">
|
||||
<span class="glyphicon glyphicon-resize-vertical"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">竖线</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.rect">
|
||||
<span class="glyphicon glyphicon-unchecked"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">矩形</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.oval">
|
||||
<span class="glyphicon glyphicon-record"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">椭圆</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容 -->
|
||||
<div class="layui-col-xs8 layui-col-md8">
|
||||
<div class="hiprint-toolbar" style="margin-top:15px;">
|
||||
<ul>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A3')">A3</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A4')">A4</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A5')">A5</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B3')">B3</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B4')">B4</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B5')">B5</a></li>
|
||||
|
||||
<li><a class="hiprint-toolbar-item"><input type="text" id="customWidth"
|
||||
style="width: 50px;height: 19px;border: 0px;"
|
||||
placeholder="宽/mm" /></a></li>
|
||||
<li><a class="hiprint-toolbar-item"><input type="text" id="customHeight"
|
||||
style="width: 50px;height: 19px;border: 0px;"
|
||||
placeholder="高/mm" /></a></li>
|
||||
|
||||
<li><a class="hiprint-toolbar-item"
|
||||
onclick="setPaper($('#customWidth').val(),$('#customHeight').val())">自定义</a>
|
||||
</li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="rotatePaper()">旋转</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="clearTemplate()">清空</a></li>
|
||||
|
||||
<li>
|
||||
<a id="A4_directPrint" class="btn hiprint-toolbar-item " style="color: #fff;
|
||||
background-color: #d9534f;
|
||||
border-color: #d43f3a;">
|
||||
打印
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
|
||||
<div id="hiprint-printTemplate" class="hiprint-printTemplate" style="margin-top:20px;">
|
||||
|
||||
</div>
|
||||
<div style="padding-top:15px;">
|
||||
<button type="button" class="btn btn-primary"
|
||||
id="A4_getJson_toTextarea">生成json到textarea</button>
|
||||
</div>
|
||||
<textarea class="layui-textarea" id="A4_textarea_json"></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 属性 -->
|
||||
<div class="layui-col-xs3 layui-col-md3">
|
||||
<div id="PrintElementOptionSetting" style="margin-top:10px;"></div>
|
||||
</div>
|
||||
</wt:row>
|
||||
|
||||
|
||||
|
||||
<!-- 单独使用无需引入 -->
|
||||
<script src="/hiprint/custom/custom-etype-provider.js"></script>
|
||||
|
||||
<div id="app">
|
||||
<a-button @@click="handleClick">
|
||||
@* <template #icon>
|
||||
<icon-plus />
|
||||
</template> *@
|
||||
{{ message }}
|
||||
</a-button>
|
||||
{{ result }}
|
||||
|
||||
<a-table :columns="columns" :data="datat" />
|
||||
</div>
|
||||
<script src="/front/signalr.min.js"></script>
|
||||
<script>
|
||||
var hiprintTemplate;
|
||||
$(document).ready(function () {
|
||||
const { createApp, reactive } = Vue
|
||||
|
||||
// 默认值
|
||||
var customPrintJson = {
|
||||
"panels": [{
|
||||
"index": 0,
|
||||
"height": 60,
|
||||
"width": 100,
|
||||
"printElements": [],
|
||||
"paperNumberDisabled": true
|
||||
}]
|
||||
const app = createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello Vue!',
|
||||
result: 'Hello Vue!',
|
||||
columns: [
|
||||
{
|
||||
title: '地址',
|
||||
dataIndex: 'Key',
|
||||
},
|
||||
{
|
||||
title: '值',
|
||||
dataIndex: 'Value',
|
||||
}
|
||||
],
|
||||
datat: reactive([])
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
var _this = this;
|
||||
_this.connection = new signalR.HubConnectionBuilder()
|
||||
.withAutomaticReconnect()
|
||||
.withUrl("/stocks")
|
||||
.build();
|
||||
_this.connection.start().then(function () {
|
||||
_this.connection.invoke("GetAllStocks").then(function (stocks) {
|
||||
for (let i = 0; i < stocks.length; i++) {
|
||||
_this.datat.push({
|
||||
Key: stocks[i].dbName,
|
||||
Value: stocks[i].dbValue
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_this.connection.invoke("OpenMarket").then(() => {
|
||||
_this.startStreaming();
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
var _this = this;
|
||||
axios.post("/configs/Print/Test", {})
|
||||
.then(function (json) {
|
||||
_this.result = json.data.Data;
|
||||
_this.datat = [];
|
||||
_this.result.forEach((item) => {
|
||||
_this.datat.push(item);
|
||||
})
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
|
||||
handleSubmit(data) {
|
||||
console.log(data);
|
||||
this.$message.info('This is an info message')
|
||||
},
|
||||
|
||||
startStreaming() {
|
||||
this.connection.stream("StreamStocks").subscribe({
|
||||
close: false,
|
||||
next: this.displayStock,
|
||||
error: function (err) {
|
||||
logger.log(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
displayStock(stock) {
|
||||
this.datat.forEach((item, index) => {
|
||||
if (item.Key == stock.dbName) {
|
||||
this.datat[index].Value = stock.dbValue;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var printData = {}
|
||||
|
||||
//初始化打印插件
|
||||
hiprint.init({
|
||||
providers: [new customElementTypeProvider()]
|
||||
});
|
||||
|
||||
//hiprint.PrintElementTypeManager.build('.hiprintEpContainer', 'testModule');
|
||||
//设置左侧拖拽事件
|
||||
hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
|
||||
|
||||
hiprintTemplate = new hiprint.PrintTemplate({
|
||||
template: customPrintJson,
|
||||
settingContainer: '#PrintElementOptionSetting',
|
||||
paginationContainer: '.hiprint-printPagination'
|
||||
});
|
||||
//打印设计
|
||||
hiprintTemplate.design('#hiprint-printTemplate');
|
||||
|
||||
$('#A4_directPrint').click(function () {
|
||||
hiprintTemplate.print(printData);
|
||||
});
|
||||
|
||||
$('#A4_getJson_toTextarea').click(function () {
|
||||
$('#A4_textarea_json').html(JSON.stringify(hiprintTemplate.getJson()))
|
||||
})
|
||||
});
|
||||
app.use(ArcoVue)
|
||||
.use(ArcoVueIcon)
|
||||
.mount('#app');
|
||||
|
||||
//调整纸张
|
||||
var setPaper = function (paperTypeOrWidth, height) {
|
||||
hiprintTemplate.setPaper(paperTypeOrWidth, height);
|
||||
}
|
||||
|
||||
//旋转
|
||||
var rotatePaper = function () {
|
||||
hiprintTemplate.rotatePaper();
|
||||
}
|
||||
var clearTemplate = function () {
|
||||
hiprintTemplate.clear();
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@ -1,99 +0,0 @@
|
||||
<div id="app">
|
||||
<a-button @@click="handleClick">
|
||||
@* <template #icon>
|
||||
<icon-plus />
|
||||
</template> *@
|
||||
{{ message }}
|
||||
</a-button>
|
||||
{{ result }}
|
||||
|
||||
<a-table :columns="columns" :data="datat" />
|
||||
</div>
|
||||
<script src="/front/signalr.min.js"></script>
|
||||
<script>
|
||||
const { createApp, reactive } = Vue
|
||||
|
||||
const app = createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello Vue!',
|
||||
result: 'Hello Vue!',
|
||||
columns: [
|
||||
{
|
||||
title: '地址',
|
||||
dataIndex: 'Key',
|
||||
},
|
||||
{
|
||||
title: '值',
|
||||
dataIndex: 'Value',
|
||||
}
|
||||
],
|
||||
datat: reactive([])
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
var _this = this;
|
||||
_this.connection = new signalR.HubConnectionBuilder()
|
||||
.withAutomaticReconnect()
|
||||
.withUrl("/stocks")
|
||||
.build();
|
||||
_this.connection.start().then(function () {
|
||||
_this.connection.invoke("GetAllStocks").then(function (stocks) {
|
||||
for (let i = 0; i < stocks.length; i++) {
|
||||
_this.datat.push({
|
||||
Key: stocks[i].dbName,
|
||||
Value: stocks[i].dbValue
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_this.connection.invoke("OpenMarket").then(() => {
|
||||
_this.startStreaming();
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
var _this = this;
|
||||
axios.post("/configs/Print/Test", {})
|
||||
.then(function (json) {
|
||||
_this.result = json.data.Data;
|
||||
_this.datat = [];
|
||||
_this.result.forEach((item) => {
|
||||
_this.datat.push(item);
|
||||
})
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
|
||||
handleSubmit(data) {
|
||||
console.log(data);
|
||||
this.$message.info('This is an info message')
|
||||
},
|
||||
|
||||
startStreaming() {
|
||||
this.connection.stream("StreamStocks").subscribe({
|
||||
close: false,
|
||||
next: this.displayStock,
|
||||
error: function (err) {
|
||||
logger.log(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
displayStock(stock) {
|
||||
this.datat.forEach((item, index) => {
|
||||
if (item.Key == stock.dbName) {
|
||||
this.datat[index].Value = stock.dbValue;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
app.use(ArcoVue)
|
||||
.use(ArcoVueIcon)
|
||||
.mount('#app');
|
||||
|
||||
</script>
|
||||
@ -1,12 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigBatchVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.BatchDeleteConfirm"]</wt:quote>
|
||||
<wt:hidden field="Ids" />
|
||||
<wt:grid vm="ListVM" use-local-data="true" height="300" hidden-checkbox="true" hidden-panel="true"/>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton theme=" ButtonThemeEnum.Warm" text="@Localizer["Sys.Delete"]"/>
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -1,14 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigBatchVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<div style="margin-bottom:10px">@Localizer["Sys.BatchEditConfirm"] </div>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
</wt:row>
|
||||
<wt:hidden field="Ids" />
|
||||
<wt:grid vm="ListVM" use-local-data="true" height="300" hidden-checkbox="true" hidden-panel="true"/>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -1,14 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="Entity.Name" />
|
||||
<wt:textbox field="Entity.Template" />
|
||||
<wt:textbox field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -1,16 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.Name" />
|
||||
<wt:display field="Entity.Template" />
|
||||
<wt:display field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton theme=" ButtonThemeEnum.Warm" text="@Localizer["Sys.Delete"]"/>
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -1,202 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:textbox field="Entity.Template" />
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton submit-url="/configs/PrintConfig/Edit"/>
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
|
||||
|
||||
<link href="/hiprint/content/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- 单独使用无需引入 -->
|
||||
<script src="/hiprint/custom/custom-etype-provider.js"></script>
|
||||
|
||||
<wt:row>
|
||||
<!-- 列表 -->
|
||||
<div class="layui-col-xs1 layui-col-md1" style="padding-right:0px;">
|
||||
<div class="rect-printElement-types hiprintEpContainer">
|
||||
<ul class="hiprint-printElement-type">
|
||||
<li>
|
||||
<span class="title"><code>拖拽列表</code></span>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.text" style="">
|
||||
<span class="glyphicon glyphicon-text-width"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">文本</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.image" style="">
|
||||
<span class="glyphicon glyphicon-picture"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">图片</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.longText">
|
||||
<span class="glyphicon glyphicon-subscript"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">长文</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.tableCustom" style="">
|
||||
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">表格</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.html">
|
||||
<span class="glyphicon glyphicon-header"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">html</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">辅助</span>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.hline" style="">
|
||||
<span class="glyphicon glyphicon-resize-horizontal"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">横线</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.vline" style="">
|
||||
<span class="glyphicon glyphicon-resize-vertical"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">竖线</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.rect">
|
||||
<span class="glyphicon glyphicon-unchecked"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">矩形</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.oval">
|
||||
<span class="glyphicon glyphicon-record"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">椭圆</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容 -->
|
||||
<div class="layui-col-xs8 layui-col-md8">
|
||||
<div class="hiprint-toolbar" style="margin-top:15px;">
|
||||
<ul>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A3')">A3</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A4')">A4</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A5')">A5</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B3')">B3</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B4')">B4</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B5')">B5</a></li>
|
||||
|
||||
<li><a class="hiprint-toolbar-item"><input type="text" id="customWidth"
|
||||
style="width: 50px;height: 19px;border: 0px;"
|
||||
placeholder="宽/mm" /></a></li>
|
||||
<li><a class="hiprint-toolbar-item"><input type="text" id="customHeight"
|
||||
style="width: 50px;height: 19px;border: 0px;"
|
||||
placeholder="高/mm" /></a></li>
|
||||
|
||||
<li><a class="hiprint-toolbar-item"
|
||||
onclick="setPaper($('#customWidth').val(),$('#customHeight').val())">自定义</a>
|
||||
</li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="rotatePaper()">旋转</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="clearTemplate()">清空</a></li>
|
||||
|
||||
<li>
|
||||
<a id="A4_directPrint" class="btn hiprint-toolbar-item " style="color: #fff;
|
||||
background-color: #d9534f;
|
||||
border-color: #d43f3a;">
|
||||
打印
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
|
||||
<div id="hiprint-printTemplate" class="hiprint-printTemplate" style="margin-top:20px;">
|
||||
|
||||
</div>
|
||||
<div style="padding-top:15px;">
|
||||
<button type="button" class="btn btn-primary"
|
||||
id="A4_getJson_toTextarea">生成json到textarea</button>
|
||||
</div>
|
||||
<textarea class="layui-textarea" id="A4_textarea_json"></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 属性 -->
|
||||
<div class="layui-col-xs3 layui-col-md3">
|
||||
<div id="PrintElementOptionSetting" style="margin-top:10px;"></div>
|
||||
</div>
|
||||
</wt:row>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
var l = $('[name="Entity.Template"]').val();
|
||||
|
||||
var hiprintTemplate;
|
||||
$(document).ready(function () {
|
||||
|
||||
// 默认值
|
||||
var customPrintJson = JSON.parse(l);
|
||||
|
||||
var printData = {}
|
||||
|
||||
//初始化打印插件
|
||||
hiprint.init({
|
||||
providers: [new customElementTypeProvider()]
|
||||
});
|
||||
|
||||
//设置左侧拖拽事件
|
||||
hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
|
||||
|
||||
hiprintTemplate = new hiprint.PrintTemplate({
|
||||
template: customPrintJson,
|
||||
settingContainer: '#PrintElementOptionSetting',
|
||||
paginationContainer: '.hiprint-printPagination'
|
||||
});
|
||||
//打印设计
|
||||
hiprintTemplate.design('#hiprint-printTemplate');
|
||||
|
||||
$('#A4_directPrint').click(function () {
|
||||
hiprintTemplate.print(printData);
|
||||
});
|
||||
|
||||
$('#A4_getJson_toTextarea').click(function () {
|
||||
$('#A4_textarea_json').html(JSON.stringify(hiprintTemplate.getJson()));
|
||||
$('[name="Entity.Template"]').val(JSON.stringify(hiprintTemplate.getJson()));
|
||||
})
|
||||
});
|
||||
|
||||
//调整纸张
|
||||
var setPaper = function (paperTypeOrWidth, height) {
|
||||
hiprintTemplate.setPaper(paperTypeOrWidth, height);
|
||||
}
|
||||
|
||||
//旋转
|
||||
var rotatePaper = function () {
|
||||
hiprintTemplate.rotatePaper();
|
||||
}
|
||||
var clearTemplate = function () {
|
||||
hiprintTemplate.clear();
|
||||
}
|
||||
</script>
|
||||
@ -1,13 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.Name" />
|
||||
<wt:display field="Entity.Template" />
|
||||
<wt:display field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -1,15 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="Entity.Name" />
|
||||
<wt:textbox field="Entity.Template" />
|
||||
<wt:textbox field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -1,14 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigImportVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:downloadTemplateButton vm="@Model" />
|
||||
</wt:row>
|
||||
<wt:upload field="UploadFileId" label-text="@Model.Localizer["Sys.UploadTemplate"]" upload-type="ExcelFile" />
|
||||
<wt:grid vm="ErrorListVM" use-local-data="true" hidden-checkbox="true" hidden-grid-index="true" hidden-panel="true" height="300"/>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@ -1,29 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigListVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:searchpanel vm="@Model" reset-btn="true">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Three">
|
||||
<wt:textbox field="Searcher.Name" />
|
||||
</wt:row>
|
||||
</wt:searchpanel>
|
||||
<wt:grid vm="@Model" url="/configs/PrintConfig/Search" height="400"/>
|
||||
|
||||
<script>
|
||||
|
||||
// 打印模板,打印预览
|
||||
|
||||
function print(id, data) {
|
||||
|
||||
var printData = eval('(' + data[0].TestData.replace(/"/g, '"') + ')')
|
||||
|
||||
hiprint.init();
|
||||
var hiprintTemplate = new hiprint.PrintTemplate({
|
||||
template: JSON.parse(data[0].Template.replace(/"/g, '"'))
|
||||
|
||||
});
|
||||
|
||||
hiprintTemplate.print([printData]);
|
||||
printData = {};
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -55,6 +55,7 @@ namespace HHWMS.Web
|
||||
var data = ZoneCodes.FirstOrDefault(x => x.Value.ToString() == a.ZoneCode);
|
||||
return data?.Text ?? a.ZoneCode;
|
||||
}),
|
||||
this.MakeGridHeader(x => x.UniqueCode).SetWidth(230),
|
||||
this.MakeGridHeader(x => x.ContainerCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.LocationCode),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
@ -87,6 +88,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
return new List<GridColumn<Inventory_View>>{
|
||||
//this.MakeGridHeader(x => x.ZoneCode),
|
||||
this.MakeGridHeader(x => x.UniqueCode).SetWidth(230),
|
||||
//this.MakeGridHeader(x => x.ContainerCode),
|
||||
//this.MakeGridHeader(x => x.LocationCode),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
@ -109,6 +111,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
var query = DC.Set<Inventory>()
|
||||
.CheckContain(Searcher.ZoneCode, x => x.ZoneCode)
|
||||
.CheckContain(Searcher.UniqueCode, x => x.UniqueCode)
|
||||
.CheckContain(Searcher.LocationCode, x => x.LocationCode)
|
||||
.CheckContain(Searcher.MaterialCode, x => x.MaterialCode)
|
||||
.CheckContain(Searcher.MaterialType, x => x.MaterialType)
|
||||
@ -124,6 +127,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
ID = x.ID,
|
||||
ZoneCode = x.ZoneCode,
|
||||
UniqueCode = x.UniqueCode,
|
||||
ContainerCode = x.ContainerCode,
|
||||
LocationCode = x.LocationCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
|
||||
@ -89,7 +89,8 @@ namespace HHWMS.Web.Controllers
|
||||
public ActionResult Create2(int id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptDetailVM>(passInit: true);
|
||||
vm.Entity.HeaderId = id;
|
||||
vm.Entity.ReceiptHeaderId = id;
|
||||
vm.Entity.ReceiptHeader = new ReceiptHeader();
|
||||
//vm.Entity.ReceiptHeader.Code = vm.DC.Set<ReceiptHeader>().Find(id).Code;
|
||||
return PartialView(vm);
|
||||
}
|
||||
@ -117,6 +118,114 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult CreateDetails(int id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptDetailVM>(passInit: true);
|
||||
vm.Entity.ReceiptHeaderId = id;
|
||||
vm.Entity.ReceiptHeader = new ReceiptHeader();
|
||||
//vm.Entity.ReceiptHeader.Code = vm.DC.Set<ReceiptHeader>().Find(id).Code;
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult CreateDetails(ReceiptDetailVM vm)
|
||||
{
|
||||
var header = _unitwork.FindSingle<ReceiptHeader>(x => x.ID == vm.Entity.ReceiptHeaderId);
|
||||
if(header.FirstStatus != ReceiptStatusEnum.新建)
|
||||
{
|
||||
return FFResult().Alert("主单据不是新建状态,不能新建明细!");
|
||||
}
|
||||
var plList = vm.Entity.MaterialCode.Split("\n");
|
||||
var slList = vm.Entity.Lot.Split("\n");
|
||||
var detailList = new List<ReceiptDetail>();
|
||||
foreach(var item in plList)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
detailList.Add(new ReceiptDetail
|
||||
{
|
||||
UniqueCode = item,
|
||||
Status = 0,
|
||||
ZoneCode = ZoneCodeEnum.盘料库,
|
||||
ReceiptHeaderId = vm.Entity.ReceiptHeaderId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in slList)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
detailList.Add(new ReceiptDetail
|
||||
{
|
||||
UniqueCode = item,
|
||||
ZoneCode = ZoneCodeEnum.散料库,
|
||||
Status = 0,
|
||||
ReceiptHeaderId = vm.Entity.ReceiptHeaderId
|
||||
});
|
||||
}
|
||||
}
|
||||
var uniqueGroup = detailList.GroupBy(x => x.UniqueCode);
|
||||
|
||||
if (uniqueGroup.Any(x => x.Count() > 1))
|
||||
{
|
||||
var codeList = uniqueGroup.Where(x => x.Count() > 1)
|
||||
.Select(x => x.Key)
|
||||
.ToList();
|
||||
return FFResult().Alert($"新增明细中,存在重复的唯一码!{String.Join(", ", codeList.ToArray())}");
|
||||
}
|
||||
|
||||
// 判断唯一码是否已在库内
|
||||
var reDetailList = _unitwork.Find<ReceiptDetail>(x => x.Status == ReceiptStatusEnum.新建)
|
||||
.Select(x => new { x.UniqueCode, x.ReceiptHeader.Code })
|
||||
.ToList();
|
||||
var reDel = reDetailList.Select(x => x.UniqueCode)
|
||||
.Intersect(detailList.Select(x => x.UniqueCode));
|
||||
if (reDel.Count() > 0)
|
||||
{
|
||||
var tt= reDetailList.Where(x => reDel.Contains(x.UniqueCode))
|
||||
.ToList();
|
||||
var returnStr = "";
|
||||
foreach (var item in tt)
|
||||
{
|
||||
returnStr += $"单号:{item.Code};唯一码:{item.UniqueCode};";
|
||||
}
|
||||
return FFResult().Alert($"新增明细中,存在已添加的唯一码!{returnStr}");
|
||||
}
|
||||
|
||||
// 判断唯一码是否已在库内
|
||||
var invList = _unitwork.Find<Inventory>(x => 1 == 1)
|
||||
.Select(x => x.UniqueCode)
|
||||
.ToList();
|
||||
if(invList.Intersect(detailList.Select(x => x.UniqueCode)).Count() > 0)
|
||||
{
|
||||
return FFResult().Alert("新增明细中,存在已在库内的唯一码!");
|
||||
}
|
||||
// 补充物料明细
|
||||
foreach (var item in detailList)
|
||||
{
|
||||
var materialqr = _unitwork.FindSingle<MaterialQr>(x => x.UniqueCode.Equals(item.UniqueCode));
|
||||
if(materialqr == null)
|
||||
{
|
||||
return FFResult().Alert("新增明细中,存在不是WMS生成的唯一码!");
|
||||
}
|
||||
var material = _unitwork.FindSingle<Material>(x => x.QRCode.Equals(materialqr.QRCode));
|
||||
item.MaterialCode = material.MaterialCode;
|
||||
item.MaterialName = material.MaterialName;
|
||||
item.MaterialSpec = material.MaterialSpec;
|
||||
item.MaterialType = material.MaterialType;
|
||||
item.MaterialUnit = material.MaterialUnit;
|
||||
item.Batch = material.Batch;
|
||||
item.Qty = material.Qty;
|
||||
item.SupplierCode = material.SupplierCode;
|
||||
item.CreateBy = Wtm.LoginUserInfo.ITCode;
|
||||
item.CreateTime = DateTime.Now;
|
||||
}
|
||||
_unitwork.BatchAdd(detailList.ToArray());
|
||||
return FFResult().CloseDialog().RefreshGrid(index: 1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
|
||||
@ -234,5 +234,47 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 点数
|
||||
[ActionDescription("ReceiptHeader.Count")]
|
||||
public ActionResult Count(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptHeaderVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查所有新建的明细,已开始收货明细不允许点数
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public ActionResult SelectReceiptDetailsByCode(int id)
|
||||
{
|
||||
var data = _unitwork.Find<ReceiptHeader>(x => x.ID == id)
|
||||
.Include(x => x.ReceiptDetails).ToList();
|
||||
return JsonMore(data.FirstOrDefault().ReceiptDetails.Where(x => x.Status == ReceiptStatusEnum.新建));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改明细的数量
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="uniqueCode"></param>
|
||||
/// <param name="qty"></param>
|
||||
/// <returns></returns>
|
||||
public ActionResult CountCommit(string code, string uniqueCode, int qty)
|
||||
{
|
||||
var receiptDetail = _unitwork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode));
|
||||
if (receiptDetail != null)
|
||||
{
|
||||
receiptDetail.Qty = qty;
|
||||
receiptDetail.UpdateTime = DateTime.Now;
|
||||
receiptDetail.UpdateBy = Wtm.LoginUserInfo.ITCode;
|
||||
_unitwork.Update(receiptDetail);
|
||||
return JsonMore(null);
|
||||
}
|
||||
return JsonMore(null, 500, $"未找到唯一码{uniqueCode}的单据!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
@ -12,7 +12,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class ReceiptDetailHistoryTemplateVM : BaseTemplateVM
|
||||
{
|
||||
public ExcelPropety ReceiptHeaderHistory_Excel = ExcelPropety.CreateProperty<ReceiptDetailHistory>(x => x.HeaderId);
|
||||
public ExcelPropety ReceiptHeaderHistory_Excel = ExcelPropety.CreateProperty<ReceiptDetailHistory>(x => x.ReceiptHeaderHistoryId);
|
||||
[Display(Name = "Task.ZoneCode")]
|
||||
public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty<ReceiptDetailHistory>(x => x.ZoneCode);
|
||||
[Display(Name = "Inventory.MaterialCode")]
|
||||
|
||||
@ -56,7 +56,7 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<ReceiptDetailHistory_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<ReceiptDetailHistory>()
|
||||
.CheckEqual(Searcher.HeaderId, x=>x.HeaderId)
|
||||
.CheckEqual(Searcher.ReceiptHeaderHistoryId, x=>x.ReceiptHeaderHistoryId)
|
||||
.CheckContain(Searcher.ZoneCode, x=>x.ZoneCode)
|
||||
.CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
|
||||
.CheckContain(Searcher.MaterialType, x=>x.MaterialType)
|
||||
@ -71,7 +71,7 @@ namespace HHWMS.Web
|
||||
.Select(x => new ReceiptDetailHistory_View
|
||||
{
|
||||
ID = x.ID,
|
||||
HeaderId = x.HeaderId,
|
||||
Code_view = x.ReceiptHeaderHistory.Code,
|
||||
ZoneCode = x.ZoneCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialType = x.MaterialType,
|
||||
|
||||
@ -14,7 +14,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
public List<ComboSelectListItem> AllReceiptHeaderHistorys { get; set; }
|
||||
[Display(Name = "Inventory.ReceiptCode")]
|
||||
public int? HeaderId { get; set; }
|
||||
public int? ReceiptHeaderHistoryId { get; set; }
|
||||
[Display(Name = "Task.ZoneCode")]
|
||||
public String ZoneCode { get; set; }
|
||||
[Display(Name = "Inventory.MaterialCode")]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -16,6 +16,7 @@ namespace HHWMS.Web
|
||||
|
||||
public ReceiptDetailHistoryVM()
|
||||
{
|
||||
SetInclude(x => x.ReceiptHeaderHistory);
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
|
||||
@ -7,7 +7,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class ReceiptDetailTemplateVM : BaseTemplateVM
|
||||
{
|
||||
public ExcelPropety ReceiptHeader_Excel = ExcelPropety.CreateProperty<ReceiptDetail>(x => x.HeaderId);
|
||||
public ExcelPropety ReceiptHeader_Excel = ExcelPropety.CreateProperty<ReceiptDetail>(x => x.ReceiptHeaderId);
|
||||
|
||||
[Display(Name = "Task.ZoneCode")]
|
||||
public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty<ReceiptDetail>(x => x.ZoneCode);
|
||||
|
||||
@ -52,8 +52,9 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<ReceiptDetail_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<ReceiptDetail>()
|
||||
.CheckEqual(Searcher.HeaderId, x => x.HeaderId)
|
||||
.CheckEqual(Searcher.ReceiptHeaderId, x => x.ReceiptHeaderId)
|
||||
.CheckContain(Searcher.ZoneCode, x => x.ZoneCode)
|
||||
.CheckContain(Searcher.UniqueCode, x => x.UniqueCode)
|
||||
.CheckContain(Searcher.MaterialCode, x => x.MaterialCode)
|
||||
.CheckContain(Searcher.MaterialType, x => x.MaterialType)
|
||||
.CheckContain(Searcher.MaterialName, x => x.MaterialName)
|
||||
@ -66,8 +67,9 @@ namespace HHWMS.Web
|
||||
.Select(x => new ReceiptDetail_View
|
||||
{
|
||||
ID = x.ID,
|
||||
Code_view = x.HeaderId.ToString(),
|
||||
Code_view = x.ReceiptHeader.Code,
|
||||
ZoneCode = x.ZoneCode,
|
||||
UniqueCode = x.UniqueCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialType = x.MaterialType,
|
||||
MaterialName = x.MaterialName,
|
||||
|
||||
@ -32,6 +32,7 @@ namespace HHWMS.Web
|
||||
var result = new List<GridColumn<ReceiptDetail_View>>{
|
||||
//this.MakeGridHeader(x => x.Code_view),
|
||||
//this.MakeGridHeader(x => x.ZoneCode),
|
||||
this.MakeGridHeader(x => x.UniqueCode).SetWidth(230),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
//this.MakeGridHeader(x => x.MaterialType),
|
||||
this.MakeGridHeader(x => x.MaterialName),
|
||||
@ -59,12 +60,13 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<ReceiptDetail_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<ReceiptDetail>()
|
||||
.Where(x => x.HeaderId == Searcher.HeaderId)
|
||||
.Where(x => x.ReceiptHeaderId == Searcher.ReceiptHeaderId)
|
||||
.Select(x => new ReceiptDetail_View
|
||||
{
|
||||
ID = x.ID,
|
||||
Code_view = x.HeaderId.ToString(),
|
||||
Code_view = x.ReceiptHeader.Code,
|
||||
ZoneCode = x.ZoneCode,
|
||||
UniqueCode = x.UniqueCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialType = x.MaterialType,
|
||||
MaterialName = x.MaterialName,
|
||||
|
||||
@ -11,11 +11,14 @@ namespace HHWMS.Web
|
||||
{
|
||||
public List<ComboSelectListItem> AllReceiptHeaders { get; set; }
|
||||
[Display(Name = "Inventory.ReceiptCode")]
|
||||
public int? HeaderId { get; set; }
|
||||
public int? ReceiptHeaderId { get; set; }
|
||||
|
||||
[Display(Name = "Task.ZoneCode")]
|
||||
public String ZoneCode { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.UniqueCode")]
|
||||
public String UniqueCode { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.MaterialCode")]
|
||||
public String MaterialCode { get; set; }
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ namespace HHWMS.Web
|
||||
|
||||
public ReceiptDetailVM()
|
||||
{
|
||||
SetInclude(x => x.ReceiptHeader);
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
|
||||
@ -16,7 +16,7 @@ namespace HHWMS.Web
|
||||
protected override void InitVM()
|
||||
{
|
||||
Details.CopyContext(this);
|
||||
Details.Searcher.HeaderId = Entity.ID;
|
||||
Details.Searcher.ReceiptHeaderId = Entity.ID;
|
||||
|
||||
var CurrentCulture = Wtm.CurrentCulture;
|
||||
var dictDatas = DC.Set<SysDictData>().ToList();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ReceiptDetailVM
|
||||
@model HHWMS.Web.ReceiptDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllReceiptHeaders" />
|
||||
<wt:combobox field="Entity.ReceiptHeaderId" items="AllReceiptHeaders"/>
|
||||
<wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<wt:textbox field="Entity.InventoryStatus" />
|
||||
<wt:combobox field="Entity.Status" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.HeaderId" />
|
||||
<wt:hidden field="Entity.ReceiptHeaderId" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<wt:textarea field="Entity.MaterialCode" label-text="盘料"/>
|
||||
<wt:textarea field="Entity.Lot" label-text="散料" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.HeaderId" />
|
||||
<wt:hidden field="Entity.ReceiptHeaderId" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.ReceiptHeader.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.ReceiptHeader.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ReceiptDetailVM
|
||||
@model HHWMS.Web.ReceiptDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllReceiptHeaders" />
|
||||
<wt:combobox field="Entity.ReceiptHeaderId" items="AllReceiptHeaders"/>
|
||||
<wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ReceiptDetailListVM
|
||||
@model HHWMS.Web.ReceiptDetailListVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:searchpanel vm="@Model" reset-btn="true">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Three">
|
||||
<wt:combobox field="Searcher.HeaderId" items="Searcher.AllReceiptHeaders" empty-text="@Localizer["Sys.All"]" />
|
||||
<wt:combobox field="Searcher.ReceiptHeaderId" items="Searcher.AllReceiptHeaders" empty-text="@Localizer["Sys.All"]" />
|
||||
<wt:textbox field="Searcher.ZoneCode" />
|
||||
<wt:textbox field="Searcher.MaterialCode" />
|
||||
<wt:textbox field="Searcher.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllReceiptHeaderHistorys"/>
|
||||
<wt:combobox field="Entity.ReceiptHeaderHistoryId" items="AllReceiptHeaderHistorys"/>
|
||||
<wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.ID" />
|
||||
<wt:display field="Entity.ReceiptHeaderHistory.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.ReceiptHeaderHistory.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@model HHWMS.Web.ReceiptDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllReceiptHeaderHistorys" />
|
||||
<wt:combobox field="Entity.ReceiptHeaderHistoryId" items="AllReceiptHeaderHistorys"/>
|
||||
<wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ReceiptDetailHistoryListVM
|
||||
@model HHWMS.Web.ReceiptDetailHistoryListVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:searchpanel vm="@Model" reset-btn="true">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Three">
|
||||
<wt:combobox field="Searcher.HeaderId" items="Searcher.AllReceiptHeaderHistorys" empty-text="@Localizer["Sys.All"]" />
|
||||
<wt:combobox field="Searcher.ReceiptHeaderHistoryId" items="Searcher.AllReceiptHeaderHistorys" empty-text="@Localizer["Sys.All"]" />
|
||||
<wt:textbox field="Searcher.ZoneCode" />
|
||||
<wt:textbox field="Searcher.MaterialCode" />
|
||||
<wt:textbox field="Searcher.MaterialType" />
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<script>
|
||||
import {hiprint, defaultElementTypeProvider} from 'vue-plugin-hiprint'
|
||||
|
||||
hiprint.init({
|
||||
providers: [new defaultElementTypeProvider()]
|
||||
})
|
||||
</script>
|
||||
@ -17,7 +17,7 @@
|
||||
var headerId = 0;
|
||||
function details(id) {
|
||||
headerId = id;
|
||||
layui.table.reload('ReceiptDetail', { where: { "Searcher.HeaderId": id } });
|
||||
layui.table.reload('ReceiptDetail', { where: { "Searcher.ReceiptHeaderId": id } });
|
||||
}
|
||||
|
||||
function CreateDetail() {
|
||||
|
||||
@ -66,6 +66,32 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(vm.Entity.UniqueCode))
|
||||
{
|
||||
return FFResult().Alert($"唯一码不能为空!");
|
||||
}
|
||||
var header = _unitwork.FindSingle<ShipmentHeader>(x => x.ID == vm.Entity.ShipmentHeaderId);
|
||||
if (header != null && header.FirstStatus != ShipStatusEnum.新建)
|
||||
{
|
||||
return FFResult().Alert($"非新建状态的出库单,无法新建明细!");
|
||||
}
|
||||
var inv = _unitwork.FindSingle<Inventory>(x => x.UniqueCode == vm.Entity.UniqueCode
|
||||
&& x.TaskStatus != InventoryTaskStatus.任务中);
|
||||
if(inv == null)
|
||||
{
|
||||
return FFResult().Alert($"{vm.Entity.UniqueCode}不存在或已有任务,检查后重新添加!");
|
||||
}
|
||||
if(_unitwork.IsExit<ShipmentDetail>(x => x.UniqueCode == vm.Entity.UniqueCode))
|
||||
{
|
||||
return FFResult().Alert($"{vm.Entity.UniqueCode}已在出库单内,请勿重复添加!");
|
||||
}
|
||||
vm.Entity.MaterialCode = inv.MaterialCode;
|
||||
vm.Entity.MaterialName = inv.MaterialName;
|
||||
vm.Entity.MaterialSpec = inv.MaterialSpec;
|
||||
vm.Entity.MaterialUnit = inv.MaterialUnit;
|
||||
vm.Entity.MaterialType = inv.MaterialType;
|
||||
vm.Entity.Batch = inv.Batch;
|
||||
vm.Entity.Qty = inv.Qty;
|
||||
vm.Entity.Status = ShipStatusEnum.新建;
|
||||
vm.DoAdd();
|
||||
if (!ModelState.IsValid)
|
||||
|
||||
@ -231,7 +231,82 @@ namespace HHWMS.Web.Controllers
|
||||
return vm.GetExportData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 库位分析
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[ActionDescription("ShipmentHeader.Analyse")]
|
||||
public ActionResult Analyse(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ShipmentHeaderVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回分析数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[ActionDescription("ShipmentHeader.Analyse")]
|
||||
[HttpPost]
|
||||
public ActionResult AnalyseData(int id)
|
||||
{
|
||||
var data = _unitwork.Find<ShipmentHeader>(x => x.ID == id)
|
||||
.Include(x => x.ShipmentDetails).ToList();
|
||||
var details = data.FirstOrDefault().ShipmentDetails.Where(x => x.Status < ShipStatusEnum.分配完成);
|
||||
foreach (var item in details)
|
||||
{
|
||||
var invQty = _unitwork.FindSingle<Inventory>(x =>
|
||||
x.UniqueCode.Equals(item.UniqueCode)
|
||||
&& x.TaskStatus == InventoryTaskStatus.无任务);
|
||||
item.InventoryStatus = invQty != null ? "满足" : "不足";
|
||||
}
|
||||
return JsonMore(details);
|
||||
}
|
||||
|
||||
[ActionDescription("ShipmentHeader.ShelfInv")]
|
||||
public ActionResult ShelfInv(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ShipmentHeaderVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 货架库存
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[ActionDescription("ShipmentHeader.ShelfInv")]
|
||||
public ActionResult ShelfInvData(int id)
|
||||
{
|
||||
var data = _unitwork.Find<ShipmentHeader>(x => x.ID == id)
|
||||
.Include(x => x.ShipmentDetails)
|
||||
.FirstOrDefault();
|
||||
var details = data.ShipmentDetails.Where(x => x.Status < ShipStatusEnum.分配完成)
|
||||
.Select(x => x.UniqueCode)
|
||||
.ToList();
|
||||
|
||||
var invList = _unitwork.Find<Inventory>(x => x.ZoneCode.Equals(ZoneCodeEnum.货架库)
|
||||
&& x.TaskStatus.Equals(InventoryTaskStatus.无任务)
|
||||
&& details.Contains(x.UniqueCode))
|
||||
.ToList();
|
||||
//var details = data.ShipmentDetails.Where(x => invList.Contains(x.UniqueCode));
|
||||
return JsonMore(invList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取库存数据
|
||||
/// </summary>
|
||||
/// <param name="uniqueCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult GetInvData(string uniqueCode)
|
||||
{
|
||||
var data = _unitwork.Find<Inventory>(x => x.UniqueCode == uniqueCode).ToList();
|
||||
return JsonMore(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动出库
|
||||
@ -248,17 +323,5 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
return FFResult().RefreshGrid().Message("启动成功!");
|
||||
}
|
||||
|
||||
public ActionResult Analyse(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ShipmentHeaderVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
public ActionResult PickRoute(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ShipmentHeaderVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
@ -12,7 +12,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class ShipmentDetailHistoryTemplateVM : BaseTemplateVM
|
||||
{
|
||||
public ExcelPropety ShipmentHeaderHistory_Excel = ExcelPropety.CreateProperty<ShipmentDetailHistory>(x => x.HeaderId);
|
||||
public ExcelPropety ShipmentHeaderHistory_Excel = ExcelPropety.CreateProperty<ShipmentDetailHistory>(x => x.ShipmentHeaderHistoryId);
|
||||
[Display(Name = "Task.ZoneCode")]
|
||||
public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty<ShipmentDetailHistory>(x => x.ZoneCode);
|
||||
[Display(Name = "Inventory.MaterialCode")]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -32,7 +32,7 @@ namespace HHWMS.Web
|
||||
protected override IEnumerable<IGridColumn<ShipmentDetailHistory_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<ShipmentDetailHistory_View>>{
|
||||
this.MakeGridHeader(x => x.HeaderId),
|
||||
this.MakeGridHeader(x => x.Code_view),
|
||||
this.MakeGridHeader(x => x.ZoneCode),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.MaterialType),
|
||||
@ -57,7 +57,7 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<ShipmentDetailHistory_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<ShipmentDetailHistory>()
|
||||
.CheckEqual(Searcher.ShipmentHeaderHistoryId, x=>x.HeaderId)
|
||||
.CheckEqual(Searcher.ShipmentHeaderHistoryId, x=>x.ShipmentHeaderHistoryId)
|
||||
.CheckContain(Searcher.ZoneCode, x=>x.ZoneCode)
|
||||
.CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
|
||||
.CheckContain(Searcher.MaterialType, x=>x.MaterialType)
|
||||
@ -72,7 +72,7 @@ namespace HHWMS.Web
|
||||
.Select(x => new ShipmentDetailHistory_View
|
||||
{
|
||||
ID = x.ID,
|
||||
HeaderId = x.HeaderId,
|
||||
Code_view = x.ShipmentHeaderHistory.Code,
|
||||
ZoneCode = x.ZoneCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialType = x.MaterialType,
|
||||
@ -98,6 +98,8 @@ namespace HHWMS.Web
|
||||
}
|
||||
|
||||
public class ShipmentDetailHistory_View : ShipmentDetailHistory{
|
||||
[Display(Name = "Inventory.ShipCode")]
|
||||
public String Code_view { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -16,6 +16,7 @@ namespace HHWMS.Web
|
||||
|
||||
public ShipmentDetailHistoryVM()
|
||||
{
|
||||
SetInclude(x => x.ShipmentHeaderHistory);
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
|
||||
@ -7,7 +7,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class ShipmentDetailTemplateVM : BaseTemplateVM
|
||||
{
|
||||
public ExcelPropety ShipmentHeader_Excel = ExcelPropety.CreateProperty<ShipmentDetail>(x => x.HeaderId);
|
||||
public ExcelPropety ShipmentHeader_Excel = ExcelPropety.CreateProperty<ShipmentDetail>(x => x.ShipmentHeaderId);
|
||||
|
||||
[Display(Name = "Task.ZoneCode")]
|
||||
public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty<ShipmentDetail>(x => x.ZoneCode);
|
||||
|
||||
@ -41,6 +41,7 @@ namespace HHWMS.Web
|
||||
if (SearcherMode == ListVMSearchModeEnum.MasterDetail)
|
||||
{
|
||||
return new List<GridColumn<ShipmentDetail_View>>{
|
||||
this.MakeGridHeader(x => x.UniqueCode).SetWidth(220),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.Batch),
|
||||
this.MakeGridHeader(x => x.Qty),
|
||||
@ -50,6 +51,7 @@ namespace HHWMS.Web
|
||||
else if (SearcherMode == ListVMSearchModeEnum.Custom1)
|
||||
{
|
||||
return new List<GridColumn<ShipmentDetail_View>>{
|
||||
this.MakeGridHeader(x => x.UniqueCode).SetWidth(220),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.Batch),
|
||||
this.MakeGridHeader(x => x.Qty),
|
||||
@ -85,24 +87,31 @@ namespace HHWMS.Web
|
||||
InitVM();
|
||||
if (SearcherMode == ListVMSearchModeEnum.Custom1) {
|
||||
var tt = DC.Set<ShipmentDetail>()
|
||||
.CheckEqual(Searcher.HeaderId, x => x.HeaderId)
|
||||
.CheckEqual(Searcher.ShipmentHeaderId, x => x.ShipmentHeaderId)
|
||||
.Select(x => new ShipmentDetail_View
|
||||
{
|
||||
ID = x.ID,
|
||||
UniqueCode = x.UniqueCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
Batch = x.Batch,
|
||||
Qty = x.Qty,
|
||||
InventoryStatus = x.InventoryStatus,
|
||||
Status = x.Status
|
||||
}).ToList();
|
||||
|
||||
foreach(var item in tt.Where(x => x.Status < ShipStatusEnum.分配完成))
|
||||
{
|
||||
var invQty = _unitWork.Find<Inventory>(x => x.UniqueCode.Equals(item.UniqueCode))
|
||||
.Sum(x => x.Qty);
|
||||
item.InventoryStatus = invQty >= (item.Qty - item.DividedQty) ? "true" : "false";
|
||||
}
|
||||
return (IOrderedQueryable<ShipmentDetail_View>)tt.OrderBy(x => x.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
var query = DC.Set<ShipmentDetail>()
|
||||
.CheckEqual(Searcher.HeaderId, x => x.HeaderId)
|
||||
.CheckEqual(Searcher.ShipmentHeaderId, x => x.ShipmentHeaderId)
|
||||
.CheckContain(Searcher.ZoneCode, x => x.ZoneCode)
|
||||
.CheckContain(Searcher.UniqueCode, x => x.UniqueCode)
|
||||
.CheckContain(Searcher.MaterialCode, x => x.MaterialCode)
|
||||
.CheckContain(Searcher.MaterialType, x => x.MaterialType)
|
||||
.CheckContain(Searcher.MaterialName, x => x.MaterialName)
|
||||
@ -115,7 +124,8 @@ namespace HHWMS.Web
|
||||
.Select(x => new ShipmentDetail_View
|
||||
{
|
||||
ID = x.ID,
|
||||
Code_view = x.HeaderId.ToString(),
|
||||
Code_view = x.ShipmentHeader.Code,
|
||||
UniqueCode = x.UniqueCode,
|
||||
ZoneCode = x.ZoneCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialType = x.MaterialType,
|
||||
|
||||
@ -12,7 +12,7 @@ namespace HHWMS.Web
|
||||
public List<ComboSelectListItem> AllShipmentHeaders { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.ShipCode")]
|
||||
public int? HeaderId { get; set; }
|
||||
public int? ShipmentHeaderId { get; set; }
|
||||
|
||||
[Display(Name = "Task.ZoneCode")]
|
||||
public String ZoneCode { get; set; }
|
||||
|
||||
@ -11,6 +11,7 @@ namespace HHWMS.Web
|
||||
|
||||
public ShipmentDetailVM()
|
||||
{
|
||||
SetInclude(x => x.ShipmentHeader);
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
|
||||
@ -20,10 +20,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
this.MakeAction("ShipmentHeader","StartOut",Localizer["ShipmentHeader.StartOut"],"",GridActionParameterTypesEnum.SingleId,"shipment"),
|
||||
this.MakeAction("ShipmentHeader","Analyse",Localizer["ShipmentHeader.Analyse"],Localizer["ShipmentHeader.Analyse"],GridActionParameterTypesEnum.SingleId,"shipment")
|
||||
.SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-Warm").SetMax(),
|
||||
this.MakeAction("ShipmentHeader","PickRoute",Localizer["ShipmentHeader.PickRoute"],Localizer["ShipmentHeader.PickRoute"],GridActionParameterTypesEnum.SingleId,"shipment")
|
||||
.SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-Warm").SetMax(),
|
||||
|
||||
.SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-Warm").SetSize(1200,800),
|
||||
this.MakeAction("ShipmentHeader","ShelfInv",Localizer["ShipmentHeader.ShelfInv"],Localizer["ShipmentHeader.ShelfInv"],GridActionParameterTypesEnum.SingleId,"shipment")
|
||||
.SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-Warm").SetSize(1200,800),
|
||||
|
||||
|
||||
@ -7,8 +7,6 @@ using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Z.EntityFramework.Plus;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
@ -16,7 +14,6 @@ namespace HHWMS.Web
|
||||
{
|
||||
public ShipmentDetailListVM Details = new ShipmentDetailListVM();
|
||||
public List<ComboSelectListItem> ShipTypes { get; set; }
|
||||
|
||||
public ShipmentHeaderVM()
|
||||
{
|
||||
}
|
||||
@ -24,7 +21,7 @@ namespace HHWMS.Web
|
||||
protected override void InitVM()
|
||||
{
|
||||
Details.CopyContext(this);
|
||||
Details.Searcher.HeaderId = Entity.ID;
|
||||
Details.Searcher.ShipmentHeaderId = Entity.ID;
|
||||
|
||||
var CurrentCulture = Wtm.CurrentCulture;
|
||||
var dictDatas = DC.Set<SysDictData>().ToList();
|
||||
@ -35,148 +32,6 @@ namespace HHWMS.Web
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分解出库单
|
||||
/// </summary>
|
||||
/// <returns>处理结果</returns>
|
||||
public ResponseResult<dynamic> DecomposeShipment()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var transaction = DC.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var details = DC.Set<ShipmentDetail>()
|
||||
.Where(x => x.HeaderId == Entity.ID && x.Status != ShipStatusEnum.分配完成)
|
||||
.ToList();
|
||||
|
||||
if (!details.Any())
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("没有需要分配的出库单明细");
|
||||
}
|
||||
|
||||
foreach (var detail in details)
|
||||
{
|
||||
var availableInventories = DC.Set<Inventory>()
|
||||
.Where(x => x.MaterialCode == detail.MaterialCode
|
||||
&& x.TaskStatus == InventoryTaskStatus.无任务
|
||||
&& x.Qty > x.TaskQty
|
||||
)
|
||||
.OrderBy(x => x.CreateTime)
|
||||
.ToList();
|
||||
|
||||
decimal remainingQty = (decimal)(detail.Qty - (detail.DividedQty ?? 0));
|
||||
decimal dividedQty = 0;
|
||||
|
||||
foreach (var inventory in availableInventories)
|
||||
{
|
||||
if (remainingQty <= 0) break;
|
||||
|
||||
var currentInventory = DC.Set<Inventory>()
|
||||
.FirstOrDefault(x => x.ID == inventory.ID);
|
||||
|
||||
if (currentInventory == null || currentInventory.UpdateVersion != inventory.UpdateVersion)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
decimal availableQty = (decimal)(currentInventory.Qty - (currentInventory.TaskQty ?? 0));
|
||||
if (availableQty <= 0) continue;
|
||||
|
||||
decimal qtyToDivide = Math.Min(remainingQty, availableQty);
|
||||
|
||||
// 更新库存分配数量
|
||||
currentInventory.TaskQty = (currentInventory.TaskQty ?? 0) + qtyToDivide;
|
||||
currentInventory.Status = InventoryTaskStatus.任务中;
|
||||
currentInventory.UpdateVersion++;
|
||||
DC.UpdateEntity(currentInventory);
|
||||
|
||||
remainingQty -= qtyToDivide;
|
||||
dividedQty += qtyToDivide;
|
||||
|
||||
/*var allocation = new InventoryAllocation
|
||||
{
|
||||
InventoryId = currentInventory.ID,
|
||||
ShipmentDetailId = detail.ID,
|
||||
DividedQty = qtyToDivide,
|
||||
Status = ShipStatusEnum.分配完成.ToString()
|
||||
};
|
||||
DC.AddEntity(allocation);*/
|
||||
}
|
||||
|
||||
if (dividedQty > 0)
|
||||
{
|
||||
var currentDetail = DC.Set<ShipmentDetail>()
|
||||
.FirstOrDefault(x => x.ID == detail.ID);
|
||||
|
||||
if (currentDetail != null && currentDetail.UpdateVersion == detail.UpdateVersion)
|
||||
{
|
||||
currentDetail.DividedQty = (currentDetail.DividedQty ?? 0) + dividedQty;
|
||||
currentDetail.Status = currentDetail.DividedQty >= currentDetail.Qty ?
|
||||
ShipStatusEnum.分配完成 :
|
||||
ShipStatusEnum.分配中;
|
||||
currentDetail.UpdateVersion++;
|
||||
DC.UpdateEntity(currentDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var currentHeader = DC.Set<ShipmentHeader>()
|
||||
.FirstOrDefault(x => x.ID == Entity.ID);
|
||||
|
||||
if (currentHeader != null && currentHeader.UpdateVersion == Entity.UpdateVersion)
|
||||
{
|
||||
var allDetails = DC.Set<ShipmentDetail>()
|
||||
.Where(x => x.HeaderId == Entity.ID)
|
||||
.ToList();
|
||||
|
||||
bool allDivided = allDetails.All(x => x.Status == ShipStatusEnum.分配完成);
|
||||
|
||||
currentHeader.FirstStatus = allDivided ?
|
||||
ShipStatusEnum.分配完成 :
|
||||
ShipStatusEnum.分配中;
|
||||
currentHeader.UpdateVersion++;
|
||||
DC.UpdateEntity(currentHeader);
|
||||
}
|
||||
|
||||
DC.SaveChanges();
|
||||
transaction.Commit();
|
||||
|
||||
var unallocatedDetails = details.Where(x => x.Status != ShipStatusEnum.分配完成).ToList();
|
||||
if (unallocatedDetails.Any())
|
||||
{
|
||||
var errorMsg = string.Join("\n", unallocatedDetails.Select(x =>
|
||||
$"物料{x.MaterialCode}缺少{x.Qty - (x.DividedQty ?? 0)}个"));
|
||||
return ResponseResult<dynamic>.Error($"部分物料库存不足,请检查:\n{errorMsg}");
|
||||
}
|
||||
|
||||
return ResponseResult<dynamic>.Success(new
|
||||
{
|
||||
message = "出库单分解完成",
|
||||
headerId = Entity.ID,
|
||||
status = Entity.FirstStatus,
|
||||
allocatedDetails = details.Select(x => new
|
||||
{
|
||||
x.ID,
|
||||
x.MaterialCode,
|
||||
x.Qty,
|
||||
DividedQty = x.DividedQty,
|
||||
x.Status
|
||||
}).ToList()
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw new Exception($"处理出库单时发生错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ResponseResult<dynamic>.Error($"分解出库单失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoAdd()
|
||||
{
|
||||
base.DoAdd();
|
||||
@ -191,151 +46,5 @@ namespace HHWMS.Web
|
||||
{
|
||||
base.DoDelete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分配库存对应的货架列表
|
||||
/// </summary>
|
||||
/// <returns>货架列表</returns>
|
||||
public ResponseResult<List<string>> GetAllocatedLocations()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取已分配的出库单明细
|
||||
var details = DC.Set<ShipmentDetail>()
|
||||
.Where(x => x.HeaderId == Entity.ID
|
||||
&& (x.Status == ShipStatusEnum.分配完成 || x.Status == ShipStatusEnum.分配中))
|
||||
.ToList();
|
||||
|
||||
if (!details.Any())
|
||||
{
|
||||
return ResponseResult<List<string>>.Error("没有已分配的出库单明细");
|
||||
}
|
||||
|
||||
// 获取明细对应的所有库存记录
|
||||
var allocatedInventories = DC.Set<Inventory>()
|
||||
.Where(x => x.TaskStatus == InventoryTaskStatus.任务中
|
||||
&& details.Select(d => d.MaterialCode).Contains(x.MaterialCode))
|
||||
.ToList();
|
||||
|
||||
// 获取去重后的货架编码列表
|
||||
var locations = allocatedInventories
|
||||
.Where(x => !string.IsNullOrEmpty(x.LocationCode))
|
||||
.Select(x => x.LocationCode)
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
|
||||
if (!locations.Any())
|
||||
{
|
||||
return ResponseResult<List<string>>.Error("未找到相关库存的货架信息");
|
||||
}
|
||||
|
||||
// 返回货架列表,并包含统计信息
|
||||
return ResponseResult<List<string>>.Success(locations);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ResponseResult<List<string>>.Error($"获取货架列表失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分配库存的详细信息
|
||||
/// </summary>
|
||||
/// <returns>库存详细信息</returns>
|
||||
public ResponseResult<List<InventoryLocationInfo>> GetAllocatedInventoryDetails()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取已分配的出库单明细
|
||||
var details = DC.Set<ShipmentDetail>()
|
||||
.Where(x => x.HeaderId == Entity.ID
|
||||
&& (x.Status == ShipStatusEnum.分配完成 || x.Status == ShipStatusEnum.分配中))
|
||||
.ToList();
|
||||
|
||||
if (!details.Any())
|
||||
{
|
||||
return ResponseResult<List<InventoryLocationInfo>>.Error("没有已分配的出库单明细");
|
||||
}
|
||||
|
||||
// 获取明细对应的所有库存记录,并按货架分组
|
||||
var inventoryGroups = DC.Set<Inventory>()
|
||||
.Where(x => x.TaskStatus == InventoryTaskStatus.任务中
|
||||
&& details.Select(d => d.MaterialCode).Contains(x.MaterialCode))
|
||||
.GroupBy(x => x.LocationCode)
|
||||
.Select(g => new InventoryLocationInfo
|
||||
{
|
||||
LocationCode = g.Key,
|
||||
Inventories = g.Select(inv => new InventoryInfo
|
||||
{
|
||||
MaterialCode = inv.MaterialCode,
|
||||
MaterialName = inv.MaterialName,
|
||||
Qty = (decimal)inv.Qty,
|
||||
TaskQty = inv.TaskQty ?? 0,
|
||||
BatchCode = inv.Batch
|
||||
}).ToList()
|
||||
})
|
||||
.OrderBy(x => x.LocationCode)
|
||||
.ToList();
|
||||
|
||||
if (!inventoryGroups.Any())
|
||||
{
|
||||
return ResponseResult<List<InventoryLocationInfo>>.Error("未找到相关库存信息");
|
||||
}
|
||||
|
||||
return ResponseResult<List<InventoryLocationInfo>>.Success(inventoryGroups);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ResponseResult<List<InventoryLocationInfo>>.Error($"获取库存详细信息失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 库存位置信息
|
||||
/// </summary>
|
||||
public class InventoryLocationInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架编码
|
||||
/// </summary>
|
||||
public string LocationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 该货架上的库存列表
|
||||
/// </summary>
|
||||
public List<InventoryInfo> Inventories { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 库存信息
|
||||
/// </summary>
|
||||
public class InventoryInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string MaterialCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string MaterialName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总数量
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务数量
|
||||
/// </summary>
|
||||
public decimal TaskQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批次号
|
||||
/// </summary>
|
||||
public string BatchCode { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllShipmentHeaders" />
|
||||
<wt:combobox field="Entity.ShipmentHeaderId" items="AllShipmentHeaders"/>
|
||||
<wt:textbox field="Entity.UniqueCode" />
|
||||
@* <wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.ShipmentHeader.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.ShipmentHeader.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ShipmentDetailVM
|
||||
@model HHWMS.Web.ShipmentDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllShipmentHeaders" />
|
||||
<wt:combobox field="Entity.ShipmentHeaderId" items="AllShipmentHeaders"/>
|
||||
<wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
<wt:searchpanel vm="@Model" reset-btn="true">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Three">
|
||||
<wt:combobox field="Searcher.HeaderId" items="Searcher.AllShipmentHeaders" empty-text="@Localizer["Sys.All"]" />
|
||||
<wt:combobox field="Searcher.ShipmentHeaderId" items="Searcher.AllShipmentHeaders" empty-text="@Localizer["Sys.All"]" />
|
||||
<wt:textbox field="Searcher.ZoneCode" />
|
||||
<wt:textbox field="Searcher.MaterialCode" />
|
||||
<wt:textbox field="Searcher.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllShipmentHeaderHistorys" />
|
||||
<wt:combobox field="Entity.ShipmentHeaderHistoryId" items="AllShipmentHeaderHistorys"/>
|
||||
<wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.ShipmentHeaderHistory.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.ShipmentHeaderHistory.Code" />
|
||||
<wt:display field="Entity.ZoneCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialType" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@model HHWMS.Web.ShipmentDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllShipmentHeaderHistorys" />
|
||||
<wt:combobox field="Entity.ShipmentHeaderHistoryId" items="AllShipmentHeaderHistorys"/>
|
||||
<wt:textbox field="Entity.ZoneCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialType" />
|
||||
|
||||
@ -1,899 +0,0 @@
|
||||
@model HHWMS.Web.ShipmentHeaderVM
|
||||
|
||||
<input type="hidden" id="shipmentId" value="@Model.Entity.ID" />
|
||||
|
||||
<div id="pickRoute">
|
||||
<div class="picking-route">
|
||||
<div class="route-info">
|
||||
<h3>最优拣货路径</h3>
|
||||
<div class="route-summary">
|
||||
<span class="total-distance">总距离:{{state.totalDistance}} 格</span>
|
||||
<span class="total-points">拣货点数:{{state.pickingPoints}} 个</span>
|
||||
</div>
|
||||
<div class="route-steps">
|
||||
<span v-for="(loc, index) in state.route" :key="index"
|
||||
:class="['route-step',
|
||||
index === 0 ? 'start' :
|
||||
(index === state.route.length - 1 ? 'end' : 'point')]">
|
||||
{{index + 1}}. {{loc}}
|
||||
<template v-if="index < state.route.length - 1">→</template>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="route-visual">
|
||||
<canvas id="routeCanvas" width="800" height="800"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 定义货架之间的距离关系(邻接矩阵)
|
||||
const INFINITY = Number.MAX_SAFE_INTEGER;
|
||||
|
||||
// 计算两个货架之间的曼哈顿距离
|
||||
function calculateDistance(loc1, loc2) {
|
||||
// 解析位置编码
|
||||
const [area1, row1Str, col1Str] = loc1.split('-');
|
||||
const [area2, row2Str, col2Str] = loc2.split('-');
|
||||
|
||||
// 转换为实际的网格位置
|
||||
const row1 = parseInt(row1Str) * 2 - 1;
|
||||
const row2 = parseInt(row2Str) * 2 - 1;
|
||||
const col1 = parseInt(col1Str);
|
||||
const col2 = parseInt(col2Str);
|
||||
|
||||
// 如果不在同一区域,增加额外距离
|
||||
const areaPenalty = area1 !== area2 ? 100 : 0;
|
||||
|
||||
// 计算曼哈顿距离,考虑通道
|
||||
const rowDist = Math.abs(row1 - row2) +
|
||||
(row1 !== row2 ? 2 : 0); // 如果跨行,需要额外通过通道
|
||||
const colDist = Math.abs(col1 - col2);
|
||||
|
||||
return rowDist + colDist + areaPenalty;
|
||||
}
|
||||
|
||||
// 计算路径距离
|
||||
function calculatePathDistance(points) {
|
||||
let distance = 0;
|
||||
for (let i = 0; i < points.length - 1; i++) {
|
||||
const [row1, col1] = points[i];
|
||||
const [row2, col2] = points[i + 1];
|
||||
// 计算两点间的曼哈顿距离
|
||||
distance += Math.abs(row2 - row1) + Math.abs(col2 - col1);
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
// 构建邻接矩阵
|
||||
function buildAdjacencyMatrix(locations) {
|
||||
const n = locations.length;
|
||||
const matrix = Array(n).fill().map(() => Array(n).fill(INFINITY));
|
||||
|
||||
// 填充距离
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let j = 0; j < n; j++) {
|
||||
if (i === j) {
|
||||
matrix[i][i] = 0;
|
||||
continue;
|
||||
}
|
||||
matrix[i][j] = calculateDistance(locations[i], locations[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
// Dijkstra算法实现
|
||||
function dijkstra(graph, start, locations) {
|
||||
const n = graph.length;
|
||||
const dist = Array(n).fill(INFINITY);
|
||||
const visited = Array(n).fill(false);
|
||||
const prev = Array(n).fill(-1);
|
||||
|
||||
dist[start] = 0;
|
||||
|
||||
for (let count = 0; count < n - 1; count++) {
|
||||
let minDist = INFINITY;
|
||||
let minIndex = -1;
|
||||
|
||||
for (let v = 0; v < n; v++) {
|
||||
if (!visited[v] && dist[v] < minDist) {
|
||||
minDist = dist[v];
|
||||
minIndex = v;
|
||||
}
|
||||
}
|
||||
|
||||
if (minIndex === -1) break;
|
||||
|
||||
visited[minIndex] = true;
|
||||
|
||||
for (let v = 0; v < n; v++) {
|
||||
if (!visited[v] &&
|
||||
graph[minIndex][v] !== INFINITY &&
|
||||
dist[minIndex] + graph[minIndex][v] < dist[v]) {
|
||||
dist[v] = dist[minIndex] + graph[minIndex][v];
|
||||
prev[v] = minIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { dist, prev };
|
||||
}
|
||||
|
||||
// 获取最短路径
|
||||
function getShortestPath(prev, end, locations) {
|
||||
const path = [];
|
||||
let current = end;
|
||||
|
||||
while (current !== -1) {
|
||||
path.unshift(locations[current]);
|
||||
current = prev[current];
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
// 绘制路径
|
||||
function drawRoute(route, totalRows, totalCols) {
|
||||
const canvas = document.getElementById('routeCanvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
const padding = 50;
|
||||
|
||||
// 清空画布
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// 计算网格大小
|
||||
totalRows = totalRows * 2;
|
||||
totalCols = totalCols + 2;
|
||||
const gridSize = Math.min(
|
||||
(canvas.width - padding * 2) / totalCols,
|
||||
(canvas.height - padding * 2) / totalRows
|
||||
);
|
||||
|
||||
// 修改路径颜色方案
|
||||
const pathColors = [
|
||||
'#2196F3', // 蓝色
|
||||
'#FF5722', // 橙色
|
||||
'#9C27B0', // 紫色
|
||||
'#009688', // 青色
|
||||
'#E91E63', // 粉色
|
||||
'#673AB7', // 深紫色
|
||||
'#4CAF50', // 绿色
|
||||
'#FFC107' // 琥珀色
|
||||
];
|
||||
|
||||
// 绘制网格函数
|
||||
function drawGrid() {
|
||||
ctx.strokeStyle = '#ddd';
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
// 绘制所有格子
|
||||
for (let row = 0; row < totalRows; row++) {
|
||||
for (let col = 0; col < totalCols; col++) {
|
||||
const x = padding + col * gridSize;
|
||||
const y = padding + row * gridSize;
|
||||
|
||||
// 判断是否是通道
|
||||
const isAisle = row === 0 || row === totalRows - 1 || // 顶部和底部通道
|
||||
col === 0 || col === totalCols - 1 || // 左右通道
|
||||
row % 2 === 0; // 货架间通道
|
||||
|
||||
if (!isAisle) {
|
||||
// 绘制货架背景
|
||||
ctx.fillStyle = '#f0f0f0';
|
||||
ctx.fillRect(x, y, gridSize, gridSize);
|
||||
|
||||
// 绘制货架外框
|
||||
ctx.strokeStyle = '#999';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeRect(x, y, gridSize, gridSize);
|
||||
|
||||
// 绘制货架内部结构
|
||||
const innerPadding = 4;
|
||||
const shelfWidth = (gridSize - innerPadding * 2) / 3;
|
||||
|
||||
ctx.fillStyle = '#e0e0e0';
|
||||
ctx.strokeStyle = '#bbb';
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
// 绘制三层货架
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const shelfX = x + innerPadding + i * shelfWidth;
|
||||
const shelfY = y + innerPadding;
|
||||
const shelfHeight = gridSize - innerPadding * 2;
|
||||
|
||||
ctx.fillRect(shelfX, shelfY, shelfWidth - 1, shelfHeight);
|
||||
ctx.strokeRect(shelfX, shelfY, shelfWidth - 1, shelfHeight);
|
||||
}
|
||||
|
||||
// 修改货架编号显示
|
||||
const shelfRow = Math.ceil(row/2);
|
||||
const shelfCode = `A-${shelfRow.toString().padStart(2, '0')}-${col.toString().padStart(2, '0')}`;
|
||||
|
||||
// 使用更小的字体
|
||||
ctx.font = '10px Arial';
|
||||
const textWidth = ctx.measureText(shelfCode).width + 6;
|
||||
const textHeight = 16;
|
||||
|
||||
// 调整位置到货架底部中间
|
||||
const textX = x + (gridSize - textWidth) / 2;
|
||||
const textY = y + gridSize - textHeight - 2;
|
||||
|
||||
// 绘制半透明背景
|
||||
ctx.fillStyle = 'rgba(255, 255, 255, 0.9)';
|
||||
ctx.fillRect(textX, textY, textWidth, textHeight);
|
||||
|
||||
// 绘制编号文字
|
||||
ctx.fillStyle = '#666';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillText(shelfCode, x + gridSize/2, y + gridSize - textHeight/2 - 2);
|
||||
} else {
|
||||
// 绘制通道
|
||||
ctx.fillStyle = '#f8f9fa';
|
||||
ctx.fillRect(x, y, gridSize, gridSize);
|
||||
|
||||
// 添加通道标记
|
||||
if (row % 2 === 0 && col > 0 && col < totalCols - 1) {
|
||||
// 水平通道标记
|
||||
ctx.strokeStyle = '#e9ecef';
|
||||
ctx.setLineDash([5, 5]);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y + gridSize/2);
|
||||
ctx.lineTo(x + gridSize, y + gridSize/2);
|
||||
ctx.stroke();
|
||||
ctx.setLineDash([]);
|
||||
}
|
||||
if ((col === 0 || col === totalCols - 1) && row > 0 && row < totalRows - 1) {
|
||||
// 垂直通道标记
|
||||
ctx.strokeStyle = '#e9ecef';
|
||||
ctx.setLineDash([5, 5]);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + gridSize/2, y);
|
||||
ctx.lineTo(x + gridSize/2, y + gridSize);
|
||||
ctx.stroke();
|
||||
ctx.setLineDash([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制路径函数
|
||||
function drawPath() {
|
||||
ctx.lineWidth = 3;
|
||||
let lastEndPoint = null;
|
||||
|
||||
// 绘制路径线和方向
|
||||
for (let i = 0; i < route.length - 1; i++) {
|
||||
const pathPoints = getPathPoints(route[i], route[i + 1], lastEndPoint);
|
||||
|
||||
// 使用预定义的颜色,循环使用
|
||||
const pathColor = pathColors[i % pathColors.length];
|
||||
ctx.strokeStyle = pathColor;
|
||||
|
||||
// 绘制路径线
|
||||
ctx.beginPath();
|
||||
pathPoints.forEach((point, index) => {
|
||||
const [row, col] = point;
|
||||
const x = padding + col * gridSize + gridSize / 2;
|
||||
const y = padding + row * gridSize + gridSize / 2;
|
||||
|
||||
if (index === 0) {
|
||||
if (lastEndPoint && i > 0) {
|
||||
const [lastRow, lastCol] = lastEndPoint;
|
||||
const lastX = padding + lastCol * gridSize + gridSize / 2;
|
||||
const lastY = padding + lastRow * gridSize + gridSize / 2;
|
||||
ctx.moveTo(lastX, lastY);
|
||||
} else {
|
||||
ctx.moveTo(x, y);
|
||||
}
|
||||
}
|
||||
ctx.lineTo(x, y);
|
||||
|
||||
// 在路径段中间绘制箭头
|
||||
if (index > 0) {
|
||||
const prevPoint = pathPoints[index - 1];
|
||||
const [prevRow, prevCol] = prevPoint;
|
||||
const prevX = padding + prevCol * gridSize + gridSize / 2;
|
||||
const prevY = padding + prevRow * gridSize + gridSize / 2;
|
||||
|
||||
// 只在直线段的中间绘制箭头
|
||||
const dx = x - prevX;
|
||||
const dy = y - prevY;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
// 如果路径段足够长,才绘制箭头
|
||||
if (distance > gridSize * 1.5) {
|
||||
// 计算箭头位置(在路径段中间)
|
||||
const midX = (x + prevX) / 2;
|
||||
const midY = (y + prevY) / 2;
|
||||
|
||||
// 计算方向角度
|
||||
const angle = Math.atan2(dy, dx);
|
||||
|
||||
// 绘制箭头
|
||||
drawArrow(midX, midY, angle, pathColor);
|
||||
}
|
||||
}
|
||||
});
|
||||
ctx.stroke();
|
||||
|
||||
lastEndPoint = pathPoints[pathPoints.length - 1];
|
||||
}
|
||||
|
||||
// 绘制节点和序号
|
||||
route.forEach((loc, index) => {
|
||||
const [_, rowStr, colStr] = loc.split('-');
|
||||
const row = parseInt(rowStr) * 2 - 1; // 修正行号计算
|
||||
const col = parseInt(colStr);
|
||||
const x = padding + col * gridSize + gridSize / 2;
|
||||
const y = padding + row * gridSize + gridSize / 2;
|
||||
|
||||
// 修改节点样式
|
||||
ctx.fillStyle = index === 0 ? '#4CAF50' :
|
||||
(index === route.length - 1 ? '#f44336' : '#1976D2');
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, 10, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
// 添加白色边框
|
||||
ctx.strokeStyle = '#fff';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.stroke();
|
||||
|
||||
// 绘制序号
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.font = 'bold 11px Arial';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillText(index + 1, x, y);
|
||||
});
|
||||
}
|
||||
|
||||
// 绘制箭头函数
|
||||
function drawArrow(x, y, angle, color) {
|
||||
const arrowLength = 15; // 增加箭头长度
|
||||
const arrowWidth = 10; // 增加箭头宽度
|
||||
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.rotate(angle);
|
||||
|
||||
// 绘制箭头
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.lineTo(-arrowLength, arrowWidth/2);
|
||||
ctx.lineTo(-arrowLength, -arrowWidth/2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
|
||||
// 添加白色边框
|
||||
ctx.strokeStyle = '#fff';
|
||||
ctx.lineWidth = 1;
|
||||
ctx.stroke();
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// 绘制图例函数
|
||||
function drawLegend() {
|
||||
const legendX = padding;
|
||||
const legendY = canvas.height - padding/2;
|
||||
|
||||
ctx.font = 'bold 14px Arial';
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
// 起点
|
||||
ctx.fillStyle = '#4CAF50';
|
||||
ctx.beginPath();
|
||||
ctx.arc(legendX, legendY, 10, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = '#fff';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = '#333';
|
||||
ctx.fillText('起点', legendX + 20, legendY);
|
||||
|
||||
// 拣货点
|
||||
ctx.fillStyle = '#1976D2';
|
||||
ctx.beginPath();
|
||||
ctx.arc(legendX + 100, legendY, 10, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = '#333';
|
||||
ctx.fillText('拣货点', legendX + 120, legendY);
|
||||
|
||||
// 终点
|
||||
ctx.fillStyle = '#f44336';
|
||||
ctx.beginPath();
|
||||
ctx.arc(legendX + 200, legendY, 10, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = '#333';
|
||||
ctx.fillText('终点', legendX + 220, legendY);
|
||||
|
||||
// 通道
|
||||
ctx.fillStyle = '#f8f9fa';
|
||||
ctx.fillRect(legendX + 300, legendY - 10, 20, 20);
|
||||
ctx.strokeStyle = '#ddd';
|
||||
ctx.strokeRect(legendX + 300, legendY - 10, 20, 20);
|
||||
ctx.fillStyle = '#333';
|
||||
ctx.fillText('通道', legendX + 330, legendY);
|
||||
|
||||
// 路径示例
|
||||
const arrowX = legendX + 400;
|
||||
const arrowY = legendY;
|
||||
|
||||
ctx.strokeStyle = '#1976D2';
|
||||
ctx.lineWidth = 3;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(arrowX, arrowY);
|
||||
ctx.lineTo(arrowX + 40, arrowY);
|
||||
ctx.stroke();
|
||||
|
||||
drawArrow(arrowX + 20, arrowY, 0, '#1976D2');
|
||||
ctx.fillStyle = '#333';
|
||||
ctx.fillText('移动方向', arrowX + 60, arrowY);
|
||||
}
|
||||
|
||||
// 执行绘制
|
||||
drawGrid();
|
||||
drawPath();
|
||||
drawLegend();
|
||||
}
|
||||
|
||||
// 计算最优拣货路径
|
||||
function calculateOptimalPickingRoute(locations) {
|
||||
if (!locations || locations.length === 0) {
|
||||
return { route: [], totalDistance: 0 };
|
||||
}
|
||||
|
||||
const startLocation = 'A-01-01';
|
||||
|
||||
// 按行分组并排序货架位置
|
||||
const groupedLocations = {};
|
||||
locations.forEach(loc => {
|
||||
const [area, rowStr, colStr] = loc.split('-');
|
||||
const row = parseInt(rowStr);
|
||||
const col = parseInt(colStr);
|
||||
if (!groupedLocations[row]) {
|
||||
groupedLocations[row] = [];
|
||||
}
|
||||
groupedLocations[row].push({ loc, col });
|
||||
});
|
||||
|
||||
// 按行号排序
|
||||
const sortedRows = Object.keys(groupedLocations).map(Number).sort((a, b) => a - b);
|
||||
|
||||
// 构建最终路径
|
||||
const route = [startLocation];
|
||||
let totalDistance = 0;
|
||||
let currentLoc = startLocation;
|
||||
let lastEndPoint = null;
|
||||
let currentSide = 'left'; // 记录当前在左侧还是右侧
|
||||
|
||||
// 处理每一行
|
||||
for (let i = 0; i < sortedRows.length; i++) {
|
||||
const row = sortedRows[i];
|
||||
let locations = groupedLocations[row];
|
||||
|
||||
// 对每一行的位置按列号排序
|
||||
locations.sort((a, b) => a.col - b.col);
|
||||
|
||||
// 确定这一行的访问顺序
|
||||
const leftmostCol = locations[0].col;
|
||||
const rightmostCol = locations[locations.length - 1].col;
|
||||
const midpoint = 7;
|
||||
|
||||
// 判断这一行的位置主要分布在左侧还是右侧
|
||||
const avgCol = locations.reduce((sum, loc) => sum + loc.col, 0) / locations.length;
|
||||
const isMainlyLeft = avgCol < midpoint;
|
||||
|
||||
// 根据当前位置和主要分布确定访问顺序
|
||||
let orderedLocations;
|
||||
if (currentSide === 'left') {
|
||||
// 当前在左侧,优先处理左侧的货架
|
||||
orderedLocations = isMainlyLeft ? locations : [...locations].reverse();
|
||||
currentSide = isMainlyLeft ? 'right' : 'left';
|
||||
} else {
|
||||
// 当前在右侧,优先处理右侧的货架
|
||||
orderedLocations = isMainlyLeft ? locations : [...locations].reverse();
|
||||
currentSide = isMainlyLeft ? 'right' : 'left';
|
||||
}
|
||||
|
||||
// 添加路径点
|
||||
orderedLocations.forEach(({ loc }) => {
|
||||
route.push(loc);
|
||||
const points = getPathPoints(currentLoc, loc, lastEndPoint);
|
||||
totalDistance += calculatePathDistance(points);
|
||||
lastEndPoint = points[points.length - 1];
|
||||
currentLoc = loc;
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
route,
|
||||
totalDistance: Math.round(totalDistance * 10) / 10
|
||||
};
|
||||
}
|
||||
|
||||
// 最近邻策略
|
||||
function nearestNeighbor(graph, locations) {
|
||||
const n = locations.length;
|
||||
const visited = new Set([0]);
|
||||
const route = [locations[0]];
|
||||
let currentNode = 0;
|
||||
|
||||
while (visited.size < n) {
|
||||
let minDist = INFINITY;
|
||||
let nextNode = -1;
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (!visited.has(i) && graph[currentNode][i] < minDist) {
|
||||
minDist = graph[currentNode][i];
|
||||
nextNode = i;
|
||||
}
|
||||
}
|
||||
|
||||
visited.add(nextNode);
|
||||
route.push(locations[nextNode]);
|
||||
currentNode = nextNode;
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
|
||||
// 最远插入策略
|
||||
function farthestInsertion(graph, locations) {
|
||||
const n = locations.length;
|
||||
const route = [locations[0]];
|
||||
const unused = new Set(locations.slice(1));
|
||||
|
||||
while (unused.size > 0) {
|
||||
let maxDist = -1;
|
||||
let bestLoc = null;
|
||||
let bestPos = -1;
|
||||
|
||||
// 找到距离当前路径最远的点
|
||||
for (const loc of unused) {
|
||||
for (let i = 0; i < route.length; i++) {
|
||||
const dist = calculateDistance(route[i], loc);
|
||||
if (dist > maxDist) {
|
||||
maxDist = dist;
|
||||
bestLoc = loc;
|
||||
bestPos = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 插入到最优位置
|
||||
route.splice(bestPos, 0, bestLoc);
|
||||
unused.delete(bestLoc);
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
|
||||
// 最近插入策略
|
||||
function nearestInsertion(graph, locations) {
|
||||
const n = locations.length;
|
||||
const route = [locations[0]];
|
||||
const unused = new Set(locations.slice(1));
|
||||
|
||||
while (unused.size > 0) {
|
||||
let minDist = INFINITY;
|
||||
let bestLoc = null;
|
||||
let bestPos = -1;
|
||||
|
||||
// 找到距离当前路径最近的点
|
||||
for (const loc of unused) {
|
||||
for (let i = 0; i < route.length; i++) {
|
||||
const dist = calculateDistance(route[i], loc);
|
||||
if (dist < minDist) {
|
||||
minDist = dist;
|
||||
bestLoc = loc;
|
||||
bestPos = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 插入到最优位置
|
||||
route.splice(bestPos, 0, bestLoc);
|
||||
unused.delete(bestLoc);
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
|
||||
// 2-opt优化
|
||||
function twoOptImprovement(route, graph) {
|
||||
let improved = true;
|
||||
while (improved) {
|
||||
improved = false;
|
||||
for (let i = 0; i < route.length - 2; i++) {
|
||||
for (let j = i + 2; j < route.length - 1; j++) {
|
||||
const delta = calculateDelta(route, i, j, graph);
|
||||
if (delta < 0) {
|
||||
// 如果交换能减少距离,则进行交换
|
||||
reverse(route, i + 1, j);
|
||||
improved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return route;
|
||||
}
|
||||
|
||||
// 计算2-opt交换的距离变化
|
||||
function calculateDelta(route, i, j, graph) {
|
||||
const a = route[i];
|
||||
const b = route[i + 1];
|
||||
const c = route[j];
|
||||
const d = route[j + 1];
|
||||
|
||||
const d1 = calculateDistance(a, b) + calculateDistance(c, d);
|
||||
const d2 = calculateDistance(a, c) + calculateDistance(b, d);
|
||||
|
||||
return d2 - d1;
|
||||
}
|
||||
|
||||
// 反转子路径
|
||||
function reverse(route, start, end) {
|
||||
while (start < end) {
|
||||
[route[start], route[end]] = [route[end], route[start]];
|
||||
start++;
|
||||
end--;
|
||||
}
|
||||
}
|
||||
|
||||
// 计算路径总距离
|
||||
function calculateTotalDistance(route, graph) {
|
||||
let distance = 0;
|
||||
for (let i = 0; i < route.length - 1; i++) {
|
||||
distance += calculateDistance(route[i], route[i + 1]);
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
// 添加getPathPoints函数
|
||||
function getPathPoints(fromLoc, toLoc, lastEndPoint = null) {
|
||||
const [_, fromRowStr, fromColStr] = fromLoc.split('-');
|
||||
const [__, toRowStr, toColStr] = toLoc.split('-');
|
||||
|
||||
const fromRow = parseInt(fromRowStr);
|
||||
const toRow = parseInt(toRowStr);
|
||||
const fromCol = parseInt(fromColStr);
|
||||
const toCol = parseInt(toColStr);
|
||||
|
||||
const points = [];
|
||||
const midpoint = 7;
|
||||
|
||||
// 如果有上一段路径的终点,从那里开始
|
||||
if (lastEndPoint) {
|
||||
points.push(lastEndPoint);
|
||||
} else {
|
||||
points.push([fromRow * 2 - 1, fromCol]);
|
||||
}
|
||||
|
||||
const currentPoint = lastEndPoint || [fromRow * 2 - 1, fromCol];
|
||||
const [currentRow, currentCol] = currentPoint;
|
||||
|
||||
// 首先移动到最近的通道
|
||||
points.push([fromRow * 2 - 2, currentCol]);
|
||||
|
||||
if (fromRow !== toRow) {
|
||||
// 跨行移动时,根据起点和终点的位置选择最优通道
|
||||
const fromSide = fromCol <= midpoint ? 'left' : 'right';
|
||||
const toSide = toCol <= midpoint ? 'left' : 'right';
|
||||
|
||||
// 计算使用左右通道的总距离
|
||||
const leftPathDist = Math.abs(currentCol - 0) + Math.abs(toCol - 0); // 使用左通道的距离
|
||||
const rightPathDist = Math.abs(currentCol - 14) + Math.abs(toCol - 14); // 使用右通道的距离
|
||||
|
||||
// 选择最短路径的通道
|
||||
let useLeftAisle = leftPathDist <= rightPathDist;
|
||||
|
||||
// 如果起点和终点都在同一侧,优先使用该侧通道
|
||||
if (fromSide === toSide) {
|
||||
useLeftAisle = fromSide === 'left';
|
||||
}
|
||||
|
||||
// 如果目标点在最左侧(列号小于3),强制使用左通道
|
||||
if (toCol <= 3) {
|
||||
useLeftAisle = true;
|
||||
}
|
||||
// 如果目标点在最右侧(列号大于11),强制使用右通道
|
||||
else if (toCol >= 11) {
|
||||
useLeftAisle = false;
|
||||
}
|
||||
|
||||
const aisleCol = useLeftAisle ? 0 : 14;
|
||||
|
||||
// 移动到选定的通道
|
||||
points.push([fromRow * 2 - 2, aisleCol]);
|
||||
|
||||
// 在通道中移动到目标行
|
||||
points.push([toRow * 2 - 2, aisleCol]);
|
||||
|
||||
// 移动到目标列
|
||||
points.push([toRow * 2 - 2, toCol]);
|
||||
} else if (currentCol !== toCol) {
|
||||
// 同行移动时,在通道内移动到目标列
|
||||
points.push([fromRow * 2 - 2, toCol]);
|
||||
}
|
||||
|
||||
// 最后移动到目标货架
|
||||
points.push([toRow * 2 - 1, toCol]);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
const { createApp, reactive, onMounted, nextTick } = Vue;
|
||||
|
||||
const app = createApp({
|
||||
setup() {
|
||||
// 响应式状态
|
||||
const state = reactive({
|
||||
route: [], // 拣货路径
|
||||
totalDistance: 0, // 总距离
|
||||
pickingPoints: 0, // 拣货点数
|
||||
maxRow: 7, // 最大行数
|
||||
maxCol: 13 // 最大列数
|
||||
});
|
||||
|
||||
// 计算网格大小
|
||||
const calculateGridSize = (locations) => {
|
||||
state.maxRow = Math.max(...locations.map(loc => parseInt(loc.split('-')[1]))) + 1;
|
||||
state.maxCol = Math.max(...locations.map(loc => parseInt(loc.split('-')[2])));
|
||||
};
|
||||
|
||||
// 获取货架位置并计算路径
|
||||
const getLocationsAndCalculateRoute = () => {
|
||||
const shipmentId = document.getElementById('shipmentId').value;
|
||||
|
||||
$.ajax({
|
||||
url: '/Shipment/ShipmentHeader/GetAllocatedLocations',
|
||||
type: 'POST',
|
||||
data: { id: shipmentId },
|
||||
success: (response) => {
|
||||
if (response.code === 200) {
|
||||
// 计算最优拣货路径
|
||||
const result = calculateOptimalPickingRoute(response.data);
|
||||
|
||||
// 更新状态
|
||||
state.route = result.route;
|
||||
state.totalDistance = result.totalDistance;
|
||||
state.pickingPoints = result.route.length - 1;
|
||||
|
||||
// 计算最大行列数
|
||||
calculateGridSize(response.data);
|
||||
|
||||
// 绘制路径
|
||||
nextTick(() => {
|
||||
drawRoute(result.route, state.maxRow, state.maxCol);
|
||||
});
|
||||
} else {
|
||||
layer.alert(response.message || '获取货架位置失败', { icon: 5 });
|
||||
}
|
||||
},
|
||||
error: (xhr, status, error) => {
|
||||
layer.alert('获取货架位置失败:' + error, { icon: 5 });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 组件挂载时执行
|
||||
onMounted(() => {
|
||||
const locations = [
|
||||
"A-01-02", "A-01-03",
|
||||
"A-02-04", "A-02-08",
|
||||
"A-03-02", "A-03-06",
|
||||
"A-04-08", "A-04-09",
|
||||
"A-05-02", "A-05-06",
|
||||
"A-06-13"
|
||||
];
|
||||
const result = calculateOptimalPickingRoute(locations);
|
||||
|
||||
// 更新状态
|
||||
state.route = result.route;
|
||||
state.totalDistance = result.totalDistance;
|
||||
state.pickingPoints = result.route.length - 1; // 减1是因为要排除起点
|
||||
|
||||
// 计算最大行列数
|
||||
calculateGridSize(locations);
|
||||
|
||||
// 绘制路径
|
||||
nextTick(() => {
|
||||
drawRoute(result.route, state.maxRow, state.maxCol);
|
||||
});
|
||||
});
|
||||
|
||||
// 返回模板需要使用的数据和方法
|
||||
return {
|
||||
state,
|
||||
getLocationsAndCalculateRoute,
|
||||
calculateGridSize
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// 挂载应用
|
||||
app.mount('#pickRoute');
|
||||
|
||||
// 添加CSS样式
|
||||
const style = document.createElement('style');
|
||||
style.textContent = `
|
||||
.picking-route {
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.route-info {
|
||||
margin-bottom: 20px;
|
||||
padding: 15px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
}
|
||||
.route-summary {
|
||||
margin: 10px 0;
|
||||
padding: 10px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
}
|
||||
.total-distance, .total-points {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
.route-steps {
|
||||
margin-top: 15px;
|
||||
line-height: 1.8;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.route-step {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
background: #fff;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
||||
}
|
||||
.route-step.start {
|
||||
background: #e8f5e9;
|
||||
border-color: #4CAF50;
|
||||
}
|
||||
.route-step.end {
|
||||
background: #ffebee;
|
||||
border-color: #f44336;
|
||||
}
|
||||
.route-step.point {
|
||||
background: #e3f2fd;
|
||||
border-color: #1976D2;
|
||||
}
|
||||
.route-visual {
|
||||
border: 1px solid #dee2e6;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
overflow: auto;
|
||||
}
|
||||
#routeCanvas {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
</script>
|
||||
47
HHWMS.Web/Areas/System/Controllers/jobs/SendWcsJob.cs
Normal file
47
HHWMS.Web/Areas/System/Controllers/jobs/SendWcsJob.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Quartz;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Support.Quartz;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
//[QuartzRepeat(10,10, true, 30)]
|
||||
[PersistJobDataAfterExecution]
|
||||
[DisallowConcurrentExecution]
|
||||
public class SendWcsJob : WtmJob
|
||||
{
|
||||
public override Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
var _unitwork = new UnitWork(Wtm);
|
||||
|
||||
#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);
|
||||
}
|
||||
Wtm.DoLog("任务下发", ActionLogTypesEnum.Job, "SendWcsJob");
|
||||
#endregion 更新时间
|
||||
}
|
||||
catch { }
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
HHWMS.Web/Areas/System/Controllers/jobs/SendWmsJob.cs
Normal file
43
HHWMS.Web/Areas/System/Controllers/jobs/SendWmsJob.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
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 SendWmsJob : WtmJob
|
||||
{
|
||||
public override Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
var _unitwork = new UnitWork(Wtm);
|
||||
|
||||
#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);
|
||||
}
|
||||
Wtm.DoLog("出库分解", ActionLogTypesEnum.Job, "SendWmsJob");
|
||||
|
||||
#endregion 更新时间
|
||||
}
|
||||
catch { }
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,9 +42,7 @@ namespace HHWMS.Web
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch(Exception ex) {
|
||||
Wtm.DoLog("测试", ActionLogTypesEnum.Job, "TestJob", request:"error", result:ex.Message);
|
||||
}
|
||||
catch { }
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
@ -12,7 +12,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class TaskDetailHistoryTemplateVM : BaseTemplateVM
|
||||
{
|
||||
public ExcelPropety TaskHeader_Excel = ExcelPropety.CreateProperty<TaskDetailHistory>(x => x.HeaderId);
|
||||
public ExcelPropety TaskHeader_Excel = ExcelPropety.CreateProperty<TaskDetailHistory>(x => x.TaskHeaderId);
|
||||
[Display(Name = "Inventory.ReceiptCode")]
|
||||
public ExcelPropety OrderCode_Excel = ExcelPropety.CreateProperty<TaskDetailHistory>(x => x.OrderCode);
|
||||
[Display(Name = "Inventory.ReceiptDetailId")]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -32,7 +32,7 @@ namespace HHWMS.Web
|
||||
protected override IEnumerable<IGridColumn<TaskDetailHistory_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<TaskDetailHistory_View>>{
|
||||
this.MakeGridHeader(x => x.HeaderId),
|
||||
this.MakeGridHeader(x => x.TaskNo_view),
|
||||
this.MakeGridHeader(x => x.OrderCode),
|
||||
this.MakeGridHeader(x => x.OrderDetailId),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
@ -52,7 +52,7 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<TaskDetailHistory_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<TaskDetailHistory>()
|
||||
.CheckEqual(Searcher.TaskHeaderId, x=>x.HeaderId)
|
||||
.CheckEqual(Searcher.TaskHeaderId, x=>x.TaskHeaderId)
|
||||
.CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
|
||||
.CheckContain(Searcher.MaterialName, x=>x.MaterialName)
|
||||
.CheckContain(Searcher.MaterialSpec, x=>x.MaterialSpec)
|
||||
@ -63,7 +63,7 @@ namespace HHWMS.Web
|
||||
.Select(x => new TaskDetailHistory_View
|
||||
{
|
||||
ID = x.ID,
|
||||
HeaderId = x.HeaderId,
|
||||
TaskNo_view = x.TaskHeader.TaskNo,
|
||||
OrderCode = x.OrderCode,
|
||||
OrderDetailId = x.OrderDetailId,
|
||||
MaterialCode = x.MaterialCode,
|
||||
@ -84,6 +84,8 @@ namespace HHWMS.Web
|
||||
}
|
||||
|
||||
public class TaskDetailHistory_View : TaskDetailHistory{
|
||||
[Display(Name = "Task.TaskNo")]
|
||||
public String TaskNo_view { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -16,6 +16,7 @@ namespace HHWMS.Web
|
||||
|
||||
public TaskDetailHistoryVM()
|
||||
{
|
||||
SetInclude(x => x.TaskHeader);
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
@ -12,11 +12,13 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class TaskDetailTemplateVM : BaseTemplateVM
|
||||
{
|
||||
public ExcelPropety TaskHeader_Excel = ExcelPropety.CreateProperty<TaskDetail>(x => x.HeaderId);
|
||||
public ExcelPropety TaskHeader_Excel = ExcelPropety.CreateProperty<TaskDetail>(x => x.TaskHeaderId);
|
||||
[Display(Name = "Inventory.ReceiptCode")]
|
||||
public ExcelPropety OrderCode_Excel = ExcelPropety.CreateProperty<TaskDetail>(x => x.OrderCode);
|
||||
[Display(Name = "Inventory.ReceiptDetailId")]
|
||||
public ExcelPropety OrderDetailId_Excel = ExcelPropety.CreateProperty<TaskDetail>(x => x.OrderDetailId);
|
||||
[Display(Name = "Inventory.UniqueCode")]
|
||||
public ExcelPropety UniqueCode_Excel = ExcelPropety.CreateProperty<TaskDetail>(x => x.UniqueCode);
|
||||
[Display(Name = "Inventory.MaterialCode")]
|
||||
public ExcelPropety MaterialCode_Excel = ExcelPropety.CreateProperty<TaskDetail>(x => x.MaterialCode);
|
||||
[Display(Name = "Inventory.MaterialName")]
|
||||
|
||||
@ -35,6 +35,7 @@ namespace HHWMS.Web
|
||||
this.MakeGridHeader(x => x.TaskNo_view),
|
||||
this.MakeGridHeader(x => x.OrderCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.OrderDetailId).SetHide(),
|
||||
this.MakeGridHeader(x => x.UniqueCode),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.MaterialName).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialSpec).SetHide(),
|
||||
@ -54,15 +55,17 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<TaskDetail_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<TaskDetail>()
|
||||
.CheckContain(Searcher.UniqueCode, x=>x.UniqueCode)
|
||||
.CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
|
||||
.CheckContain(Searcher.FromLocation, x=>x.FromLocation)
|
||||
.CheckContain(Searcher.ToLocation, x=>x.ToLocation)
|
||||
.Select(x => new TaskDetail_View
|
||||
{
|
||||
ID = x.ID,
|
||||
TaskNo_view = x.HeaderId.ToString(),
|
||||
TaskNo_view = x.TaskHeader.TaskNo,
|
||||
OrderCode = x.OrderCode,
|
||||
OrderDetailId = x.OrderDetailId,
|
||||
UniqueCode = x.UniqueCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialName = x.MaterialName,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
|
||||
@ -28,6 +28,7 @@ namespace HHWMS.Web
|
||||
this.MakeGridHeader(x => x.TaskNo_view),
|
||||
this.MakeGridHeader(x => x.OrderCode).SetHide(),
|
||||
this.MakeGridHeader(x => x.OrderDetailId).SetHide(),
|
||||
this.MakeGridHeader(x => x.UniqueCode),
|
||||
this.MakeGridHeader(x => x.MaterialCode),
|
||||
this.MakeGridHeader(x => x.MaterialName).SetHide(),
|
||||
this.MakeGridHeader(x => x.MaterialSpec).SetHide(),
|
||||
@ -46,13 +47,14 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<TaskDetail_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<TaskDetail>()
|
||||
.Where(x => x.HeaderId == Searcher.HeaderId)
|
||||
.Where(x => x.TaskHeaderId == Searcher.TaskHeaderId)
|
||||
.Select(x => new TaskDetail_View
|
||||
{
|
||||
ID = x.ID,
|
||||
TaskNo_view = $"{x.HeaderId}-{x.FromLocation}",
|
||||
TaskNo_view = $"{x.TaskHeader.TaskNo}-{x.FromLocation}",
|
||||
OrderCode = x.OrderCode,
|
||||
OrderDetailId = x.OrderDetailId,
|
||||
UniqueCode = x.UniqueCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialName = x.MaterialName,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
|
||||
@ -16,7 +16,7 @@ namespace HHWMS.Web
|
||||
public String UniqueCode { get; set; }
|
||||
|
||||
[Display(Name = "Task.TaskNo")]
|
||||
public int? HeaderId { get; set; }
|
||||
public int? TaskHeaderId { get; set; }
|
||||
|
||||
[Display(Name = "Inventory.MaterialCode")]
|
||||
public String MaterialCode { get; set; }
|
||||
|
||||
@ -16,6 +16,7 @@ namespace HHWMS.Web
|
||||
|
||||
public TaskDetailVM()
|
||||
{
|
||||
SetInclude(x => x.TaskHeader);
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllTaskHeaders" />
|
||||
<wt:combobox field="Entity.TaskHeaderId" items="AllTaskHeaders"/>
|
||||
<wt:textbox field="Entity.OrderCode" />
|
||||
<wt:textbox field="Entity.OrderDetailId" />
|
||||
<wt:textbox field="Entity.UniqueCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialName" />
|
||||
<wt:textbox field="Entity.MaterialSpec" />
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.TaskHeader.TaskNo" />
|
||||
<wt:display field="Entity.OrderCode" />
|
||||
<wt:display field="Entity.OrderDetailId" />
|
||||
<wt:display field="Entity.UniqueCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialName" />
|
||||
<wt:display field="Entity.MaterialSpec" />
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.TaskHeader.TaskNo" />
|
||||
<wt:display field="Entity.OrderCode" />
|
||||
<wt:display field="Entity.OrderDetailId" />
|
||||
<wt:display field="Entity.UniqueCode" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
<wt:display field="Entity.MaterialName" />
|
||||
<wt:display field="Entity.MaterialSpec" />
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@model HHWMS.Web.TaskDetailVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllTaskHeaders" />
|
||||
<wt:combobox field="Entity.TaskHeaderId" items="AllTaskHeaders"/>
|
||||
<wt:textbox field="Entity.OrderCode" />
|
||||
<wt:textbox field="Entity.OrderDetailId" />
|
||||
<wt:textbox field="Entity.UniqueCode" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
<wt:textbox field="Entity.MaterialName" />
|
||||
<wt:textbox field="Entity.MaterialSpec" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllTaskHeaders" />
|
||||
<wt:combobox field="Entity.TaskHeaderId" items="AllTaskHeaders"/>
|
||||
<wt:textbox field="Entity.OrderCode" />
|
||||
<wt:textbox field="Entity.OrderDetailId" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.TaskHeader.TaskNo" />
|
||||
<wt:display field="Entity.OrderCode" />
|
||||
<wt:display field="Entity.OrderDetailId" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.HeaderId" />
|
||||
<wt:display field="Entity.TaskHeader.TaskNo" />
|
||||
<wt:display field="Entity.OrderCode" />
|
||||
<wt:display field="Entity.OrderDetailId" />
|
||||
<wt:display field="Entity.MaterialCode" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@model HHWMS.Web.TaskDetailHistoryVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.HeaderId" items="AllTaskHeaders" />
|
||||
<wt:combobox field="Entity.TaskHeaderId" items="AllTaskHeaders"/>
|
||||
<wt:textbox field="Entity.OrderCode" />
|
||||
<wt:textbox field="Entity.OrderDetailId" />
|
||||
<wt:textbox field="Entity.MaterialCode" />
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
// WTM默认页面 Wtm buidin page
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.InterfaceLog")]
|
||||
public class InterfaceLogController : BaseController
|
||||
{
|
||||
[ActionDescription("Sys.Search")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<InterfaceLogListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(InterfaceLogSearcher searcher)
|
||||
{
|
||||
var vm = Wtm.CreateVM<InterfaceLogListVM>(passInit:true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[ActionDescription("Sys.Details")]
|
||||
public IActionResult Details(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<InterfaceLogVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(InterfaceLogListVM vm)
|
||||
{
|
||||
return vm.GetExportData();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(string[] IDs)
|
||||
{
|
||||
var vm = Wtm.CreateVM<InterfaceLogBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult DoBatchDelete(InterfaceLogBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete", vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.JobLog")]
|
||||
public class JobLogController : BaseController
|
||||
{
|
||||
[ActionDescription("Sys.Search")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<JobLogListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(JobLogSearcher searcher)
|
||||
{
|
||||
var vm = Wtm.CreateVM<JobLogListVM>(passInit:true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[ActionDescription("Sys.Details")]
|
||||
public IActionResult Details(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<JobLogVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(JobLogListVM vm)
|
||||
{
|
||||
return vm.GetExportData();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(string[] IDs)
|
||||
{
|
||||
var vm = Wtm.CreateVM<JobLogBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult DoBatchDelete(JobLogBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete", vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
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;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class InterfaceLogBatchVM : BaseBatchVM<InterfaceLog, InterfaceLog_BatchEdit>
|
||||
{
|
||||
public InterfaceLogBatchVM()
|
||||
{
|
||||
ListVM = new InterfaceLogListVM();
|
||||
LinkedVM = new InterfaceLog_BatchEdit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class to define batch edit fields
|
||||
/// </summary>
|
||||
public class InterfaceLog_BatchEdit : BaseVM
|
||||
{
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
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;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class InterfaceLogTemplateVM : BaseTemplateVM
|
||||
{
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class InterfaceLogImportVM : BaseImportVM<InterfaceLogTemplateVM, InterfaceLog>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
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;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class InterfaceLogListVM : BasePagedListVM<InterfaceLog_View, InterfaceLogSearcher>
|
||||
{
|
||||
protected override List<GridAction> InitGridAction()
|
||||
{
|
||||
return new List<GridAction>
|
||||
{
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"_Admin", dialogWidth: 800),
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "_Admin", dialogWidth: 800),
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "_Admin", dialogWidth: 800),
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "_Admin", dialogWidth: 800),
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "_Admin", dialogWidth: 800),
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "_Admin", dialogWidth: 800),
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "_Admin", dialogWidth: 800),
|
||||
this.MakeStandardAction("InterfaceLog", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "_Admin"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected override IEnumerable<IGridColumn<InterfaceLog_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<InterfaceLog_View>>{
|
||||
this.MakeGridHeader(x => x.ModuleName),
|
||||
this.MakeGridHeader(x => x.ActionName),
|
||||
this.MakeGridHeader(x => x.ITCode),
|
||||
this.MakeGridHeader(x => x.ActionUrl),
|
||||
this.MakeGridHeader(x => x.ActionTime),
|
||||
this.MakeGridHeader(x => x.Duration),
|
||||
this.MakeGridHeader(x => x.Remark),
|
||||
this.MakeGridHeader(x => x.IP),
|
||||
this.MakeGridHeader(x => x.LogType),
|
||||
this.MakeGridHeader(x => x.TenantCode),
|
||||
this.MakeGridHeader(x => x.Request),
|
||||
this.MakeGridHeader(x => x.Result),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<InterfaceLog_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<InterfaceLog>()
|
||||
.CheckContain(Searcher.ModuleName, x=>x.ModuleName)
|
||||
.CheckContain(Searcher.ActionName, x=>x.ActionName)
|
||||
.CheckContain(Searcher.ITCode, x=>x.ITCode)
|
||||
.CheckContain(Searcher.ActionUrl, x=>x.ActionUrl)
|
||||
.CheckBetween(Searcher.ActionTime?.GetStartTime(), Searcher.ActionTime?.GetEndTime(), x => x.ActionTime, includeMax: false)
|
||||
.CheckContain(Searcher.IP, x=>x.IP)
|
||||
.CheckEqual(Searcher.LogType, x=>x.LogType)
|
||||
.CheckContain(Searcher.Request, x=>x.Request)
|
||||
.CheckContain(Searcher.Result, x=>x.Result)
|
||||
.Select(x => new InterfaceLog_View
|
||||
{
|
||||
ID = x.ID,
|
||||
ModuleName = x.ModuleName,
|
||||
ActionName = x.ActionName,
|
||||
ITCode = x.ITCode,
|
||||
ActionUrl = x.ActionUrl,
|
||||
ActionTime = x.ActionTime,
|
||||
Duration = x.Duration,
|
||||
Remark = x.Remark,
|
||||
IP = x.IP,
|
||||
LogType = x.LogType,
|
||||
TenantCode = x.TenantCode,
|
||||
Request = x.Request,
|
||||
Result = x.Result,
|
||||
})
|
||||
.OrderBy(x => x.ID);
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class InterfaceLog_View : InterfaceLog
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
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;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class InterfaceLogSearcher : BaseSearcher
|
||||
{
|
||||
[Display(Name = "_Admin.Module")]
|
||||
public String ModuleName { get; set; }
|
||||
[Display(Name = "_Admin.Action")]
|
||||
public String ActionName { get; set; }
|
||||
[Display(Name = "_Admin.Account")]
|
||||
public String ITCode { get; set; }
|
||||
[Display(Name = "Url")]
|
||||
public String ActionUrl { get; set; }
|
||||
[Display(Name = "_Admin.ActionTime")]
|
||||
public DateRange ActionTime { get; set; }
|
||||
[Display(Name = "IP")]
|
||||
public String IP { get; set; }
|
||||
[Display(Name = "_Admin.LogType")]
|
||||
public ActionLogTypesEnum? LogType { get; set; }
|
||||
[Display(Name = "_Admin.Request")]
|
||||
public String Request { get; set; }
|
||||
[Display(Name = "_Admin.Response")]
|
||||
public String Result { get; set; }
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class InterfaceLogVM : BaseCRUDVM<InterfaceLog>
|
||||
{
|
||||
|
||||
public InterfaceLogVM()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DoAdd()
|
||||
{
|
||||
base.DoAdd();
|
||||
}
|
||||
|
||||
public override void DoEdit(bool updateAllFields = false)
|
||||
{
|
||||
base.DoEdit(updateAllFields);
|
||||
}
|
||||
|
||||
public override void DoDelete()
|
||||
{
|
||||
base.DoDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
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;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class JobLogBatchVM : BaseBatchVM<JobLog, JobLog_BatchEdit>
|
||||
{
|
||||
public JobLogBatchVM()
|
||||
{
|
||||
ListVM = new JobLogListVM();
|
||||
LinkedVM = new JobLog_BatchEdit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class to define batch edit fields
|
||||
/// </summary>
|
||||
public class JobLog_BatchEdit : BaseVM
|
||||
{
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
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;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class JobLogTemplateVM : BaseTemplateVM
|
||||
{
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class JobLogImportVM : BaseImportVM<JobLogTemplateVM, JobLog>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user