From 327ef35c547926471711754b7639592349b2e511 Mon Sep 17 00:00:00 2001 From: zhougf Date: Sat, 2 Mar 2024 21:30:40 +0800 Subject: [PATCH] printcontroller test iot --- .../Configs/Controllers/PrintController.cs | 77 +++++-------------- HHWMS.Web/HHWMS.Web.csproj | 2 + 2 files changed, 21 insertions(+), 58 deletions(-) diff --git a/HHWMS.Web/Areas/Configs/Controllers/PrintController.cs b/HHWMS.Web/Areas/Configs/Controllers/PrintController.cs index 0a3b46a..ab336a8 100644 --- a/HHWMS.Web/Areas/Configs/Controllers/PrintController.cs +++ b/HHWMS.Web/Areas/Configs/Controllers/PrintController.cs @@ -1,12 +1,11 @@ -using System; using System.Collections.Generic; using System.Linq; using HHWMS.Web.Models; -using ICSharpCode.SharpZipLib.Core; -using Microsoft.AspNetCore.Http; +using IoTClient.Clients.PLC; +using IoTClient.Common.Enums; +using IoTClient.Enums; using Microsoft.AspNetCore.Mvc; using WalkingTec.Mvvm.Core; -using WalkingTec.Mvvm.Core.Extensions; using WalkingTec.Mvvm.Mvc; namespace HHWMS.Web.Controllers @@ -15,11 +14,11 @@ namespace HHWMS.Web.Controllers [ActionDescription("打印管理")] public partial class PrintController : BaseController { - private readonly IUnitWork _unitwork; + private readonly IUnitWork _unitWork; - public PrintController(IUnitWork unitwork) + public PrintController(IUnitWork unitWork) { - _unitwork = unitwork; + _unitWork = unitWork; } #region Search @@ -27,62 +26,24 @@ namespace HHWMS.Web.Controllers [ActionDescription("Sys.Search")] public ActionResult Index() { - var inv = _unitwork.Find(x => x.TaskStatus != InventoryTaskStatus.任务中) + SiemensClient client = new SiemensClient(SiemensVersion.S7_1500, "127.0.0.1", 102); + client.Write("V2209", 33); + + Dictionary addresses = new Dictionary(); + addresses.Add("DB4.24", DataTypeEnum.Float); + addresses.Add("DB1.434.0", DataTypeEnum.Bool); + addresses.Add("V4109", DataTypeEnum.Byte); + var result = client.BatchRead(addresses); + var tt = result.Value.First(x => x.Key.Equals("DB1.434.0")).Value; + + var inv = _unitWork + .Find(x => x.TaskStatus != InventoryTaskStatus.任务中) .ToList() .GroupBy(x => x.ContainerCode); var vm = Wtm.CreateVM(); return PartialView(vm); } + #endregion Search - - [HttpPost] - public ActionResult ScanCode(string code) - { - var material = _unitwork.FindSingle(x => x.QRCode.Equals(code)); - if (material == null) - { - return JsonMore(null, 500, $"二维码{code}不存在!"); - } - else - { - return JsonMore(null); - } - } - - [HttpPost] - public ActionResult GenCode(string code, int num = 1) - { - var material = _unitwork.FindSingle(x => x.QRCode.Equals(code)); - if (material == null) - { - return JsonMore(null, 500, $"二维码{code}不存在!"); - } - else - { - var materialQrList = new List(); - var printList = new List(); - for (int i = 0; i < num; i++) - { - var prefix = code.Split("@")[1].Substring(2); - var uniqueCode = _unitwork.GetSerialNumber(prefix, length: 8); - //var uniqueCode = prefix + unique; - - materialQrList.Add(new MaterialQr - { - QRCode = code, - UniqueCode = uniqueCode, - CreateTime = DateTime.Now, - CreateBy = Wtm.LoginUserInfo.ITCode - }); - printList.Add(new - { - UniqueCode = uniqueCode, - Batch = material.Batch - }); - } - _unitwork.BatchAdd(materialQrList.ToArray()); - return JsonMore(printList); - } - } } } diff --git a/HHWMS.Web/HHWMS.Web.csproj b/HHWMS.Web/HHWMS.Web.csproj index bf84376..7d2ea1e 100644 --- a/HHWMS.Web/HHWMS.Web.csproj +++ b/HHWMS.Web/HHWMS.Web.csproj @@ -27,11 +27,13 @@ + + all runtime; build; native; contentfiles; analyzers; buildtransitive