new
This commit is contained in:
parent
76d5c3d5c7
commit
228d3d2a86
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,5 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {}
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "9.0.6",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,11 +10,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<PublishUrl>D:\AD盘\新建文件夹</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>d3b021e9-97fd-4f90-817a-24ec873e547b</ProjectGuid>
|
||||
<SelfContained>true</SelfContained>
|
||||
|
||||
@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>D:\盛原成\骏马二期\MES\backend\code\apps\Syc.Basic.Web.WMS.HttpApi.Host\bin\Release\net6.0\publish\</_PublishTargetUrl>
|
||||
<History>True|2024-10-17T08:48:40.2516489Z;True|2024-10-11T16:31:58.0638668+08:00;</History>
|
||||
<_PublishTargetUrl>D:\AD盘\新建文件夹</_PublishTargetUrl>
|
||||
<History>True|2025-10-14T01:55:20.8397035Z||;True|2025-10-14T09:47:50.6329259+08:00||;True|2025-10-14T09:21:41.0082215+08:00||;True|2025-10-14T09:12:48.2246215+08:00||;True|2025-10-13T15:49:11.3000400+08:00||;True|2025-10-13T15:39:23.3882777+08:00||;True|2025-10-13T15:37:36.1898742+08:00||;True|2025-10-13T15:24:03.8577628+08:00||;True|2025-10-13T15:22:18.1040326+08:00||;True|2025-10-13T14:52:42.5366229+08:00||;True|2025-10-13T14:30:45.1293637+08:00||;True|2025-10-13T13:44:04.9559440+08:00||;True|2025-10-13T11:23:33.0973594+08:00||;True|2025-10-13T11:19:07.8165478+08:00||;True|2025-10-13T11:03:15.1919334+08:00||;True|2025-10-13T10:59:11.0905529+08:00||;False|2025-10-13T10:58:29.5919735+08:00||;True|2025-10-12T17:23:43.5067894+08:00||;True|2025-10-12T17:12:07.1250247+08:00||;True|2025-10-12T17:10:07.6819749+08:00||;True|2025-10-12T17:03:16.4435860+08:00||;True|2025-10-12T16:48:49.6634960+08:00||;True|2025-10-12T16:47:52.7450982+08:00||;True|2025-10-12T16:41:34.1386818+08:00||;True|2025-10-12T16:21:47.1876143+08:00||;True|2025-10-12T15:37:11.6532017+08:00||;True|2025-10-12T15:28:04.8417959+08:00||;True|2025-10-11T14:47:40.1965699+08:00||;True|2025-10-07T15:48:49.6803059+08:00||;True|2025-07-09T18:15:14.6157523+08:00||;True|2025-07-09T18:03:48.5671798+08:00||;True|2025-07-09T17:22:07.0714896+08:00||;True|2025-07-09T16:51:02.1734781+08:00||;True|2025-07-09T15:36:53.8844874+08:00||;True|2025-07-04T17:48:33.6869691+08:00||;True|2025-07-04T12:18:47.2920156+08:00||;True|2025-07-04T12:17:31.7702038+08:00||;True|2024-10-17T16:48:40.2516489+08:00||;True|2024-10-11T16:31:58.0638668+08:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -5,6 +5,6 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>Syc.Basic.Web.WMS.HttpApi.Host</ActiveDebugProfile>
|
||||
<NameOfLastUsedPublishProfile>D:\盛原成\骏马二期\MES\backend\code\apps\Syc.Basic.Web.WMS.HttpApi.Host\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
<NameOfLastUsedPublishProfile>D:\D盘\项目\榆林\YuLInHSCode\Seyounth.Auto.Hs\apps\Syc.Basic.Web.WMS.HttpApi.Host\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -25,7 +25,7 @@
|
||||
"ValidateAudience": true,
|
||||
"Audience": "www.phqmo.blog.com",
|
||||
"ValidateLifetime": true,
|
||||
"ExpiredTime": 120,
|
||||
"ExpiredTime": 1440,
|
||||
"ClockSkew": 2
|
||||
},
|
||||
"CAP": {
|
||||
@ -63,13 +63,15 @@
|
||||
{
|
||||
//人工扫纱扫码枪
|
||||
"Id": 1,
|
||||
"IP": "127.0.0.1",//"192.168.3.202",
|
||||
//"IP": "192.168.3.202",
|
||||
"IP": "127.0.0.1",
|
||||
"Port": 2002
|
||||
},
|
||||
{
|
||||
//料箱扫码枪
|
||||
"Id": 2,
|
||||
"IP": "127.0.0.1",//"192.168.3.120",
|
||||
//"IP": "192.168.3.120",
|
||||
"IP": "127.0.0.1",
|
||||
"Port": 2003
|
||||
}
|
||||
],
|
||||
@ -77,13 +79,15 @@
|
||||
{
|
||||
//丝锭
|
||||
"Id": 1,
|
||||
"IP": "127.0.0.1",
|
||||
"IP": "192.168.3.217",
|
||||
//"IP": "127.0.0.1",
|
||||
"Port": 9102
|
||||
},
|
||||
{
|
||||
//装箱
|
||||
"Id": 2,
|
||||
"IP": "192.168.3.217",
|
||||
//"IP": "127.0.0.1",
|
||||
"Port": 9101
|
||||
}
|
||||
],
|
||||
@ -92,18 +96,22 @@
|
||||
//丝锭
|
||||
"Id": 1,
|
||||
"IP": "192.168.3.99",
|
||||
"Port": 9110
|
||||
//"IP": "127.0.0.1",
|
||||
"Port": 9100
|
||||
},
|
||||
{
|
||||
//装箱
|
||||
"Id": 2,
|
||||
"IP": "192.168.3.100",
|
||||
"Port": 9111
|
||||
//"IP": "127.0.0.1",
|
||||
"Port": 9100
|
||||
}
|
||||
],
|
||||
"Plc": {
|
||||
//PLC
|
||||
"IP": "192.168.3.30",
|
||||
"Port":502
|
||||
"Port": 502
|
||||
//"IP": "127.0.0.1",
|
||||
//"Port": 6000
|
||||
}
|
||||
}
|
||||
@ -24,15 +24,18 @@ namespace Syc.Basic.Web.WMS.Dto
|
||||
//生产批号
|
||||
public string Lot_No { get; set; }
|
||||
//长度
|
||||
public double? Length { get; set; }
|
||||
public string? Length { get; set; }
|
||||
//打包时间
|
||||
public DateTime? Dom_Time { get; set; }
|
||||
public string? Dom_Time { get; set; }
|
||||
//生产日期
|
||||
public string? Exp_Time { get; set; }
|
||||
public int DataType { get; set; }
|
||||
public string Mark { get; set; }
|
||||
/// <summary>
|
||||
/// 是否在装箱
|
||||
/// </summary>
|
||||
public bool IsUse { get; set; } = true;
|
||||
public int IsDelete { get; set; }
|
||||
public DateTime? Create_Time { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,100 @@
|
||||
using BarTender;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Syc.Basic.Web.WMS.Dto;
|
||||
using Syc.Basic.Web.WMS.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Syc.Basic.Web.WMS
|
||||
{
|
||||
public class BarTenderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 打印标签
|
||||
/// </summary>
|
||||
/// <param name="templatePath">模板全路径,如:D://AD盘/新建文件夹/xxxx.btw</param>
|
||||
/// <param name="deviceName">打印机名称</param>
|
||||
/// <param name="@params">模板变量参数</param>
|
||||
/// <returns></returns>
|
||||
public static void Print(string templatePath,string deviceName,Dictionary<string,string> @params = null)
|
||||
{
|
||||
Console.WriteLine("开始打印");
|
||||
|
||||
Application bartenderApp = new Application();
|
||||
var btFormat = bartenderApp.Formats.Open(templatePath,false,deviceName);
|
||||
if (@params is not null && @params.Any())
|
||||
{
|
||||
foreach (var param in @params)
|
||||
btFormat.SetNamedSubStringValue(param.Key, param.Value);
|
||||
}
|
||||
|
||||
btFormat.IdenticalCopiesOfLabel = 1;
|
||||
//设置打印份数,自动贴标就只出一张
|
||||
BarTender.Messages btMsgs;
|
||||
//开始打印
|
||||
var btPrintRtn = btFormat.Print(PrintJobName:"打印标签",WaitForSpoolJobToComplete:false,Messages:out btMsgs);
|
||||
if (btPrintRtn != BarTender.BtPrintResult.btSuccess)
|
||||
foreach (BarTender.Message msg in btMsgs)
|
||||
{
|
||||
var text = msg.Message;
|
||||
}
|
||||
//输出错误日志
|
||||
if (btPrintRtn != BarTender.BtPrintResult.btSuccess)
|
||||
{
|
||||
foreach(BarTender.Message msg in btMsgs)
|
||||
{
|
||||
var text = msg.Message;
|
||||
}
|
||||
}
|
||||
|
||||
//关闭模板
|
||||
btFormat.Close(BarTender.BtSaveOptions.btPromptSave);
|
||||
//退出打印程序
|
||||
bartenderApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印箱子标签
|
||||
/// </summary>
|
||||
/// <param name="box"></param>
|
||||
public static void BoxPrint(Box box)
|
||||
{
|
||||
Dictionary<string, string> list = new Dictionary<string, string>()
|
||||
{
|
||||
{"$TYPE", box.Type },
|
||||
{"$SPEC", box.Spec },
|
||||
{"$QTY", box.Qty.ToString()},
|
||||
{"$CTN", Math.Round(box.Net_Weight.Value,2).ToString()},
|
||||
{ "$LOTNO", box.Lot_No },
|
||||
{"$LENGTH", box.Length },
|
||||
{ "$DATE", box.Dom_Time.ToString()},
|
||||
{ "$EXP", box.Exp_Time.ToString()},
|
||||
{ "$CODE", box.Code }
|
||||
};
|
||||
|
||||
Print(@"D:\btw\装箱码垛标签.btw", "NOVEXX Solutions XLP 504 (300 dpi)Max", list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印丝锭标签
|
||||
/// </summary>
|
||||
/// <param name="box"></param>
|
||||
public static void SilkPrint(Silk silk)
|
||||
{
|
||||
Dictionary<string, string> list = new Dictionary<string, string>()
|
||||
{
|
||||
{"$Name", silk.Name },
|
||||
{"$Type", silk.Type },
|
||||
{"$NetWeight", Math.Round(silk.Net_Weight.Value,2).ToString() },
|
||||
{ "$Length", silk.Length},
|
||||
{"$Date", silk.Date.ToString() },
|
||||
{ "$LotNo", silk.Lot_No},
|
||||
{ "$Code", silk.Code}
|
||||
};
|
||||
|
||||
Print(@"D:\btw\丝锭标签.btw", "NOVEXX Solutions XLP 504 (300 dpi)Min", list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -27,8 +27,9 @@ namespace Syc.Basic.Web.WMS.DeviceEventHandle
|
||||
private readonly IPrinterService printerService;
|
||||
private readonly IUnitOfWorkManager unitOfWork;
|
||||
private readonly ILogger<DefaultBalanceEventHandle> logger;
|
||||
private readonly IRepository<AutoLabel> autoRepository;
|
||||
private readonly static object _lock = new object();
|
||||
public DefaultBalanceEventHandle(IRepository<Silk> silkRepository,IPlcService plcService,IRepository<Produce> produceRepository,IRepository<Box> boxRepository,IPrinterService printerService,IUnitOfWorkManager unitOfWork, ILogger<DefaultBalanceEventHandle> logger)
|
||||
public DefaultBalanceEventHandle(IRepository<Silk> silkRepository, IPlcService plcService, IRepository<Produce> produceRepository, IRepository<Box> boxRepository, IPrinterService printerService, IUnitOfWorkManager unitOfWork, ILogger<DefaultBalanceEventHandle> logger, IRepository<AutoLabel> autoRepository)
|
||||
{
|
||||
this.silkRepository = silkRepository;
|
||||
this.plcService = plcService;
|
||||
@ -37,13 +38,14 @@ namespace Syc.Basic.Web.WMS.DeviceEventHandle
|
||||
this.printerService = printerService;
|
||||
this.unitOfWork = unitOfWork;
|
||||
this.logger = logger;
|
||||
this.autoRepository = autoRepository;
|
||||
}
|
||||
|
||||
|
||||
public async Task ExecAsync(decimal weight, int id)
|
||||
{
|
||||
|
||||
using (var uow = unitOfWork.Reserve(UnitOfWork.UnitOfWorkReservationName))
|
||||
{
|
||||
using (var uow = unitOfWork.Reserve(UnitOfWork.UnitOfWorkReservationName))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -69,7 +71,7 @@ namespace Syc.Basic.Web.WMS.DeviceEventHandle
|
||||
logger.LogError(ex.GetBaseException(), "称重报错");
|
||||
await uow.RollbackAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -80,38 +82,96 @@ namespace Syc.Basic.Web.WMS.DeviceEventHandle
|
||||
/// <returns></returns>
|
||||
public async Task Yanr(decimal weight)
|
||||
{
|
||||
if (await silkRepository.AnyAsync(e => e.Status == 0 && e.IsDelete == 0))
|
||||
{
|
||||
var silk = await silkRepository.FirstOrDefaultAsync(e => e.Status == 0 && e.IsDelete == 0);//QueueManage.YarnBalanceQueue.Dequeue();
|
||||
silk.Status = 1;
|
||||
silk.Status_Details = "已称重待装箱";
|
||||
silk.Net_Weight = (double)weight;
|
||||
await silkRepository.UpdateAsync(silk);
|
||||
string content = "#!A1" +
|
||||
"\r\n#N13" +
|
||||
"\r\n#PC1017/0" +
|
||||
"\r\n#IMR44/46" +
|
||||
//"\r\n#HV50" +
|
||||
"\r\n#PR6//" +
|
||||
"\r\n#PO0" +
|
||||
"\r\n#ERNC/1//0.00" +
|
||||
"\r\n#R0/0" +
|
||||
"\r\n#T3.64 #J43.18 #FD/0/L #SS100/BVUN/21X21/0 #VW/L/\"YuLinHengShenXinCaiLiaoYouXianGongSi\"#G" +
|
||||
"\r\n#T11.85 #J40.47 #FD/0/L #SS100/BVUN/19X19/0 #VW/L/\"Yulin Hengshen COLtd\"#G" +
|
||||
"\r\n#T2.28 #J25.31 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Name " + silk.Name +"\"#G" +
|
||||
"\r\n#T2.28 #J20.91 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Type " +silk.Type+ "\"#G" +
|
||||
"\r\n#T2.28 #J16.51 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Net Weight "+silk.Net_Weight+ "\"#G" +
|
||||
"\r\n#T2.28 #J12.61 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Length "+silk.Length+ "\"#G" +
|
||||
"\r\n#T2.28 #J7.95 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Date "+silk.Date.ToString()+ "\"#G" +
|
||||
"\r\n#T2.28 #J3.89 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Lot No "+silk.Lot_No+ "\"#G" +
|
||||
"\r\n#T11.51 #J29.54 #FD/0/L #SB13/ONKP2.0/8.80/2 #VW/L/\"" + silk.Code+"\"#G" +
|
||||
"\r\n#Q1#G" +
|
||||
"\r\n#!P1" +
|
||||
"\r\n";
|
||||
await printerService.PrintAsync(1, content);
|
||||
#region 扫码称重注释
|
||||
//要扫码称重的
|
||||
//if (await silkRepository.AnyAsync(e => e.Status == 0 && e.IsDelete == 0))
|
||||
//{
|
||||
// var silk = await silkRepository.FirstOrDefaultAsync(e => e.Status == 0 && e.IsDelete == 0);//QueueManage.YarnBalanceQueue.Dequeue();
|
||||
// silk.Status = (int)SilkStatus.已称重;
|
||||
// silk.Status_Details = "已称重";
|
||||
// silk.Net_Weight = (double)weight;
|
||||
// await silkRepository.UpdateAsync(silk);
|
||||
// string content = "#!A1" +
|
||||
// "\r\n#N13" +
|
||||
// "\r\n#PC1017/0" +
|
||||
// "\r\n#IMR44/46" +
|
||||
// //"\r\n#HV50" +
|
||||
// "\r\n#PR6//" +
|
||||
// "\r\n#PO0" +
|
||||
// "\r\n#ERNC/1//0.00" +
|
||||
// "\r\n#R0/0" +
|
||||
// "\r\n#T3.64 #J43.18 #FD/0/L #SS100/BVUN/21X21/0 #VW/L/\"YuLinHengShenXinCaiLiaoYouXianGongSi\"#G" +
|
||||
// "\r\n#T11.85 #J40.47 #FD/0/L #SS100/BVUN/19X19/0 #VW/L/\"Yulin Hengshen COLtd\"#G" +
|
||||
// "\r\n#T2.28 #J25.31 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Name " + silk.Name +"\"#G" +
|
||||
// "\r\n#T2.28 #J20.91 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Type " +silk.Type+ "\"#G" +
|
||||
// "\r\n#T2.28 #J16.51 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Net Weight "+silk.Net_Weight+ "\"#G" +
|
||||
// "\r\n#T2.28 #J12.61 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Length "+silk.Length+ "\"#G" +
|
||||
// "\r\n#T2.28 #J7.95 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Date "+silk.Date.ToString()+ "\"#G" +
|
||||
// "\r\n#T2.28 #J3.89 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Lot No "+silk.Lot_No+ "\"#G" +
|
||||
// "\r\n#T11.51 #J29.54 #FD/0/L #SB13/ONKP2.0/8.80/2 #VW/L/\"" + silk.Code+"\"#G" +
|
||||
// "\r\n#Q1#G" +
|
||||
// "\r\n#!P1" +
|
||||
// "\r\n";
|
||||
// await printerService.PrintAsync(1, content);
|
||||
|
||||
// logger.LogInformation($"Silk({silk.Id}|{silk.Code})状态更改为【已称重待装箱】,同时向打印机发送打印标签指令");
|
||||
//}
|
||||
#endregion
|
||||
|
||||
//不扫码称重
|
||||
|
||||
logger.LogInformation("称重的体重为" + weight);
|
||||
|
||||
if ((double)weight < 0.2)
|
||||
return;
|
||||
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1 && x.IsDelete == 0);
|
||||
|
||||
if (produce == null)
|
||||
throw Oops.Oh("没有生产设置");
|
||||
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.单品流水号);
|
||||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 0,
|
||||
Mark = timestr,
|
||||
Type = (int)AutoLabelType.单品流水号
|
||||
}, true);
|
||||
|
||||
logger.LogInformation($"Silk({silk.Id}|{silk.Code})状态更改为【已称重待装箱】,同时向打印机发送打印标签指令");
|
||||
}
|
||||
autolabel.Sort += 1;
|
||||
logger.LogInformation(timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
await autoRepository.UpdateAsync(autolabel);
|
||||
|
||||
var silk = new Silk()
|
||||
{
|
||||
Status = (int)SilkStatus.已称重,
|
||||
Status_Details = "已称重",
|
||||
Net_Weight = (double)weight,
|
||||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||||
Createtime = DateTime.Now,
|
||||
IsDelete = 0,
|
||||
Date = DateTime.Now,
|
||||
Name = produce.Type,
|
||||
Length = produce.Length,
|
||||
Lot_No = produce.Lot_No,
|
||||
Type = produce.Spec
|
||||
};
|
||||
|
||||
var data = await silkRepository.InsertAsync(silk, true);
|
||||
|
||||
//打印丝锭小标签
|
||||
|
||||
BarTenderHelper.SilkPrint(silk);
|
||||
|
||||
logger.LogInformation($"Silk({data.Id}|{silk.Code})状态更改为【已称重】,同时向打印机发送打印标签指令");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -121,25 +181,55 @@ namespace Syc.Basic.Web.WMS.DeviceEventHandle
|
||||
public async Task Box(decimal weight)
|
||||
{
|
||||
/* PLC未给顶升到位信号则忽略此次事件处理 */
|
||||
if (!await plcService.IsTop()) return;
|
||||
|
||||
if (!await plcService.IsTop())
|
||||
{
|
||||
var a = await plcService.IsTop();
|
||||
logger.LogInformation($"上顶的状态{a}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (await silkRepository.AnyAsync(e => e.Status == 1 && e.IsDelete == 0))
|
||||
{
|
||||
var query = await silkRepository.GetQueryableAsync();
|
||||
query =query.Where(x => x.Status == 1 && x.IsDelete == 0);
|
||||
{
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(e => e.IfUse == 1 && e.IsDelete == 0);
|
||||
|
||||
var query = await silkRepository.GetQueryableAsync();
|
||||
query = query.Where(x => x.Status == 1 && x.IsDelete == 0 && x.Type == produce.Spec && x.Name == produce.Type && x.Length == produce.Length && x.Lot_No == produce.Lot_No);
|
||||
var count = query.Count();
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(e => e.IfUse == 1);
|
||||
|
||||
if (produce is null)
|
||||
throw Oops.Oh("无生产信息,请先设置生产信息再扫码");
|
||||
throw Oops.Oh("无生产信息,请先设置生产信息再称重");
|
||||
|
||||
if (produce.Qty.Value > count)
|
||||
{
|
||||
throw Oops.Oh("数量未满箱,无法打印标签");
|
||||
throw Oops.Oh($"{produce.Type}数量未满箱,无法打印标签");
|
||||
}
|
||||
|
||||
logger.LogInformation($"当前生产信息:{produce.Name}|{produce.Spec}|{produce.Lot_No}|{produce.BoxSpec}|{produce.Qty}");
|
||||
//var netWeight = query.FirstOrDefault(e => e.Code == QueueManage.BoxQueue.FirstOrDefault()).Net_Weight * produce.Qty.Value;
|
||||
var takeQuery = query.Take(produce.Qty.Value);
|
||||
var netWeight = takeQuery.Sum(e => e.Net_Weight);
|
||||
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 0,
|
||||
Mark = timestr,
|
||||
Type = (int)AutoLabelType.成箱码垛流水号
|
||||
}, true);
|
||||
|
||||
}
|
||||
autolabel.Sort += 1;
|
||||
logger.LogInformation("成箱流水号:" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
await autoRepository.UpdateAsync(autolabel);
|
||||
|
||||
var box = new Box()
|
||||
{
|
||||
Dom_Time = DateTime.Now,
|
||||
@ -148,34 +238,21 @@ namespace Syc.Basic.Web.WMS.DeviceEventHandle
|
||||
Qty = produce.Qty,
|
||||
Length = produce.Length,
|
||||
Lot_No = produce.Lot_No,
|
||||
Code = Guid.NewGuid().ToString().Substring(9, 18),
|
||||
//Code = Guid.NewGuid().ToString().Substring(9, 18),
|
||||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||||
Net_Weight = netWeight,
|
||||
Spec = produce.BoxSpec,
|
||||
Spec = produce.Spec,
|
||||
Gross_Weight = (double)weight,
|
||||
IsUse = true,
|
||||
IsDelete = 0
|
||||
IsDelete = 0,
|
||||
DataType = (int)BoxDataType.装箱,
|
||||
Create_Time = DateTime.Now,
|
||||
Mark = "已称重装箱打印标签,箱子内装单品数量" + produce.Qty
|
||||
};
|
||||
string content = "#!A1" +
|
||||
"\r\n#N13" +
|
||||
"\r\n#PC1017/0" +
|
||||
"\r\n#IMR104/130" +
|
||||
//"\r\n#HV50" +
|
||||
"\r\n#PR6//" +
|
||||
"\r\n#PO0" +
|
||||
"\r\n#ERNC/1//0.00" +
|
||||
"\r\n#R0/0" +
|
||||
"\r\n#T7.28 #J11.17 #FD/1/L #SS100/BVUN/51X68/0 #VW/L/\"YuLinHengShenXinCaiLiaoYouXianGongSi\"#G" +
|
||||
"\r\n#T13.37 #J40.30 #FD/1/L #SS100/BVUN/46X62/0 #VW/L/\"Yulin Hengshen COLtd\"#G" +
|
||||
"\r\n#T52.15 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"TYPE " + box.Type + "\"#G" +
|
||||
"\r\n#T67.39 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"QTY/PCS " + box.Qty + "\"#G" +
|
||||
"\r\n#T82.63 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"LOT NO. " + box.Lot_No + "\"#G" +
|
||||
"\r\n#T98.97 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"DOM. " + box.Dom_Time.ToString() + "\"#G" +
|
||||
"\r\n#T52.15 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"SPEC " + box.Spec + "\"#G" +
|
||||
"\r\n#T67.39 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"CTY./NO. " + box.Net_Weight + "\"#G" +
|
||||
"\r\n#T81.19 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"LENGTH " + box.Length + "\"#G" +
|
||||
"\r\n#T98.21 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"EXP. " + box.Exp_Time.ToString() + "\"#G" +
|
||||
"\r\n#T41.06 #J6.68 #FD/1/L #SB13/ONKP2.0/20.82/5 #VW/L/\"" + box.Code + "\"#G" +
|
||||
"\r\n#Q1#G\r\n#!P1\r\n";
|
||||
|
||||
//打印成箱大标签
|
||||
BarTenderHelper.BoxPrint(box);
|
||||
logger.LogInformation($"打印条码{box.Code},成箱码垛标签打印成功");
|
||||
|
||||
var entity = await boxRepository.InsertAsync(box, true);
|
||||
var silks = takeQuery.ToList();
|
||||
@ -186,15 +263,18 @@ namespace Syc.Basic.Web.WMS.DeviceEventHandle
|
||||
{
|
||||
logger.LogInformation($"{e.Code}已装箱");
|
||||
e.BoxId = entity.Id;
|
||||
e.Status = 2;
|
||||
e.Status = (int)SilkStatus.已装箱;
|
||||
e.Status_Details = "已装箱";
|
||||
});
|
||||
await silkRepository.UpdateManyAsync(silks);
|
||||
await printerService.PrintAsync(2, content);
|
||||
|
||||
await plcService.ClearTop();
|
||||
await plcService.ClearData();
|
||||
await plcService.BoxTagPrintDoneAsync((short)1);
|
||||
logger.LogInformation($"称重完成,已将数据({box.Id}|{box.Code})插入到box表,同时向打印机发送出标指令");
|
||||
}
|
||||
await plcService.PrintEnd();
|
||||
|
||||
logger.LogInformation($"称重完成,已将数据({entity.Id}|{box.Code})插入到box表,同时向打印机发送出标指令");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,28 +46,28 @@ namespace Syc.Basic.Web.WMS
|
||||
/// <returns></returns>
|
||||
public async Task ExecAsync(string code, int id)
|
||||
{
|
||||
using (var uow = uowm.Reserve(UnitOfWork.UnitOfWorkReservationName))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 1)
|
||||
await Yarn(code);
|
||||
else
|
||||
await Box(code);
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
catch (Exception ex) when (ex is FriendlyException friendlyException)
|
||||
{
|
||||
logger.LogError(ex.GetBaseException(),"扫码报错");
|
||||
await WebSocketManager.SocketManager.BroadcastAsync(friendlyException.Message);
|
||||
await uow.RollbackAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex.GetBaseException(), "扫码报错");
|
||||
await uow.RollbackAsync();
|
||||
}
|
||||
}
|
||||
//using (var uow = uowm.Reserve(UnitOfWork.UnitOfWorkReservationName))
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (id == 1)
|
||||
// await Yarn(code);
|
||||
// else
|
||||
// await Box(code);
|
||||
// await uow.CompleteAsync();
|
||||
// }
|
||||
// catch (Exception ex) when (ex is FriendlyException friendlyException)
|
||||
// {
|
||||
// logger.LogError(ex.GetBaseException(),"扫码报错");
|
||||
// await WebSocketManager.SocketManager.BroadcastAsync(friendlyException.Message);
|
||||
// await uow.RollbackAsync();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// logger.LogError(ex.GetBaseException(), "扫码报错");
|
||||
// await uow.RollbackAsync();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Syc.Basic.Web.WMS.Dto
|
||||
{
|
||||
public class FullPalletInput
|
||||
{
|
||||
public int Num { get; set; }
|
||||
}
|
||||
}
|
||||
@ -12,11 +12,12 @@ namespace Syc.Basic.Web.WMS.Dto
|
||||
public int Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Spec { get; set; }
|
||||
public double Length { get; set; }
|
||||
public string Length { get; set; }
|
||||
public string Lot_No { get; set; }
|
||||
public string Name { get; set; }
|
||||
//public string Name { get; set; }
|
||||
public int? Qty { get; set; }
|
||||
public string BoxSpec { get; set; }
|
||||
//public string BoxSpec { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Exp_Time { get; set; }
|
||||
public int IfUse { get; set; }
|
||||
public int IsDelete { get; set; }
|
||||
|
||||
@ -18,7 +18,7 @@ namespace Syc.Basic.Web.WMS.Dto
|
||||
//净重
|
||||
public double? Net_Weight { get; set; }
|
||||
//长度
|
||||
public double? Length { get; set; }
|
||||
public string? Length { get; set; }
|
||||
//包装时间
|
||||
public DateTime? Date { get; set; }
|
||||
//生产批号
|
||||
|
||||
15
services/Syc.Basic.Web.WMS.Application/Dto/UserInput.cs
Normal file
15
services/Syc.Basic.Web.WMS.Application/Dto/UserInput.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Syc.Basic.Web.WMS.Dto
|
||||
{
|
||||
public class UserInput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string JiuPassword { get; set; }
|
||||
public string NewPassword { get; set; }
|
||||
}
|
||||
}
|
||||
34
services/Syc.Basic.Web.WMS.Application/Enum.cs
Normal file
34
services/Syc.Basic.Web.WMS.Application/Enum.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Syc.Basic.Web.WMS
|
||||
{
|
||||
public enum BoxDataType
|
||||
{
|
||||
装箱,
|
||||
已码垛,
|
||||
单品码垛,
|
||||
成箱码垛,
|
||||
手动装箱,
|
||||
手动成箱未包含单品信息
|
||||
}
|
||||
public enum SilkStatus
|
||||
{
|
||||
已扫码待称重,
|
||||
已称重,
|
||||
已装箱,
|
||||
已码垛,
|
||||
手动添加称重,
|
||||
已手动装箱
|
||||
}
|
||||
|
||||
public enum AutoLabelType
|
||||
{
|
||||
小标签条码流水号,
|
||||
成箱码垛流水号,
|
||||
单品流水号
|
||||
}
|
||||
}
|
||||
@ -25,7 +25,6 @@ using Volo.Abp.Domain.Repositories;
|
||||
namespace Syc.Basic.Web.WMS.Service
|
||||
{
|
||||
//[ApiExplorerSettings(GroupName = "鉴权/授权服务"), Authorize]
|
||||
[AllowAnonymous]
|
||||
public class AuthService : ApiService, IAuthService
|
||||
{
|
||||
private readonly IJwtTokenService jwtTokenService;
|
||||
@ -54,7 +53,7 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[HttpPost,AllowAnonymous]
|
||||
public async Task<AuthResultDto> LoginAsync(LoginInput input)
|
||||
{
|
||||
var userDO = await userDomainService.GetUserByAccountAsync(input.UserName);
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Seyounth.Auto.Hs.Runtime.Plc;
|
||||
using Seyounth.Auto.Hs.Runtime.Printer;
|
||||
using Syc.Basic.Web.WMS.Dto;
|
||||
using Syc.Basic.Web.WMS.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Syc.Basic.Web.WMS.Service
|
||||
{
|
||||
[AllowAnonymous]
|
||||
public class AutoService : ApiService
|
||||
{
|
||||
private readonly IPrinterService printerService;
|
||||
private readonly IRepository<AutoLabel> autoReposutory;
|
||||
private readonly ILogger<AutoService> logger;
|
||||
private readonly IPlcService plcService;
|
||||
|
||||
public AutoService(IPrinterService PrinterService,IRepository<AutoLabel> AutoReposutory,ILogger<AutoService> logger,IPlcService plcService)
|
||||
{
|
||||
printerService = PrinterService;
|
||||
autoReposutory = AutoReposutory;
|
||||
this.logger = logger;
|
||||
this.plcService = plcService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印唯一标签
|
||||
/// </summary>
|
||||
/// <param name="num"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task AutoLabel(int num)
|
||||
{
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoReposutory.FirstOrDefaultAsync(x => x.Date == date&&x.Type==(int)AutoLabelType.小标签条码流水号);
|
||||
|
||||
var d = date.ToString("yyMMdd");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoReposutory.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 1,
|
||||
Mark = "T" + d,
|
||||
Type = (int)AutoLabelType.小标签条码流水号
|
||||
},true);
|
||||
|
||||
}
|
||||
|
||||
//for (var i = 1; i <= num; i++)
|
||||
//{
|
||||
|
||||
// autolabel.Sort += 1;
|
||||
|
||||
// logger.LogInformation(autolabel.Mark + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
|
||||
// string content = "^XA" +
|
||||
// "\r\n^MMP" +
|
||||
// "\r\n^LL0" +
|
||||
// "\r\n^JUS" +
|
||||
// "\r\n#!A1" +
|
||||
// "\r\n#N13" +
|
||||
// "\r\n#PC1017/0" +
|
||||
// "\r\n#IMR44/46" +
|
||||
// "\r\n#PR6//" +
|
||||
// "\r\n#PO0" +
|
||||
// "\r\n#ERNC/1//0.00" +
|
||||
// "\r\n#R0/0" +
|
||||
// "\r\n#T11.51 #J29.54 #FD/0/L #SB13/ONKP2.0/8.80/2 #VW/L/\"" + autolabel.Mark + autolabel.Sort.ToString().PadLeft(4, '0') + "\"#G" +
|
||||
// "\r\n#Q1#G" +
|
||||
// "\r\n#!P1" +
|
||||
// "\r\n^XZ";
|
||||
// await printerService.PrintAsync(1, content);
|
||||
//}
|
||||
|
||||
await autoReposutory.UpdateAsync(autolabel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -29,8 +29,9 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
private readonly IPlcService plcService;
|
||||
private readonly ILogger<BoxService> logger;
|
||||
private readonly IPrinterService printerService;
|
||||
private readonly IRepository<AutoLabel> autoRepository;
|
||||
|
||||
public BoxService(IRepository<Box> boxRepository,IRepository<Produce> produceRepository,IRepository<Silk> silkRepository,IPlcService plcService, ILogger<BoxService> logger,IPrinterService printerService)
|
||||
public BoxService(IRepository<Box> boxRepository, IRepository<Produce> produceRepository, IRepository<Silk> silkRepository, IPlcService plcService, ILogger<BoxService> logger, IPrinterService printerService, IRepository<AutoLabel> autoRepository)
|
||||
{
|
||||
this.boxRepository = boxRepository;
|
||||
this.produceRepository = produceRepository;
|
||||
@ -38,6 +39,7 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
this.plcService = plcService;
|
||||
this.logger = logger;
|
||||
this.printerService = printerService;
|
||||
this.autoRepository = autoRepository;
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询纸箱
|
||||
@ -54,7 +56,7 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
if (input.Spec != null)
|
||||
boxlist = boxlist.Where(x => x.Spec.Contains(input.Spec));
|
||||
|
||||
var result = boxlist.PageResult(input.Page, input.PageSize);
|
||||
var result = boxlist.OrderByDescending(x => x.Id).PageResult(input.Page, input.PageSize);
|
||||
var data = result.Queryable.Select(e => new BoxDto()
|
||||
{
|
||||
Length = e.Length,
|
||||
@ -62,8 +64,11 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
Qty = e.Qty,
|
||||
Id = e.Id,
|
||||
Code = e.Code,
|
||||
Dom_Time = e.Dom_Time,
|
||||
Exp_Time = e.Exp_Time.ToString(),
|
||||
Dom_Time = DateTime.Parse(e.Dom_Time.ToString()).ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
DataType = e.DataType,
|
||||
Mark = e.Mark,
|
||||
Create_Time = e.Create_Time,
|
||||
Exp_Time = DateTime.Parse(e.Exp_Time.ToString()).ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
Lot_No = e.Lot_No,
|
||||
Spec = e.Spec,
|
||||
Gross_Weight = e.Gross_Weight,
|
||||
@ -72,9 +77,9 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
|
||||
PageOutput<BoxDto> pageOutput = new PageOutput<BoxDto>();
|
||||
pageOutput.Total = boxlist.Count();
|
||||
pageOutput.Data = data.OrderByDescending(x=>x.Id);
|
||||
pageOutput.Data = data;
|
||||
pageOutput.PageIndex = input.Page;
|
||||
pageOutput.PageSize=input.PageSize;
|
||||
pageOutput.PageSize = input.PageSize;
|
||||
return pageOutput;
|
||||
}
|
||||
/// <summary>
|
||||
@ -85,19 +90,23 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[HttpGet]
|
||||
public async Task<List<BoxDto>> GetBoxByNum()
|
||||
{
|
||||
var produce=await produceRepository.FirstOrDefaultAsync(x=>x.IfUse==1);
|
||||
var silks = await silkRepository.GetListAsync(x=>x.Status==1||x.Status==0);
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||||
if (produce == null)
|
||||
throw Oops.Oh("没有生产设置");
|
||||
//var silks = await silkRepository.GetListAsync(x=>x.Status==1||x.Status==0);
|
||||
var boxlist = await boxRepository.GetQueryableAsync();
|
||||
boxlist = boxlist.Where(x => x.IsDelete == 0);
|
||||
|
||||
var data = boxlist.Select(e => new BoxDto()
|
||||
boxlist = boxlist.Where(x => x.IsDelete == 0 && x.Spec == produce.Spec && x.Type == produce.Type && x.Lot_No == produce.Lot_No);
|
||||
|
||||
var data = boxlist.Where(x => x.DataType == 0).Select(e => new BoxDto()
|
||||
{
|
||||
Net_Weight = e.Net_Weight,
|
||||
Id = e.Id,
|
||||
Code = e.Code
|
||||
Code = e.Code,
|
||||
DataType = e.DataType,
|
||||
Mark = e.Mark
|
||||
}).ToList();
|
||||
|
||||
return data.OrderByDescending(x => x.Id).ToList().Take(1).ToList();
|
||||
return data.OrderByDescending(x => x.Id).Take(15).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加纸箱
|
||||
@ -107,53 +116,128 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[HttpPost]
|
||||
public async Task InsertBox(BoxDto input)
|
||||
{
|
||||
if (await boxRepository.AnyAsync(x => x.Code == input.Code))
|
||||
throw Oops.Oh("条码已存在,不允许添加");
|
||||
var boxs = await boxRepository.GetListAsync(e => e.IsUse);
|
||||
if (boxs.Any())
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||||
var silksQuery = await silkRepository.GetQueryableAsync();
|
||||
var silks = silksQuery.Where(x => x.IsDelete == 0 && x.Status == (int)SilkStatus.手动添加称重).OrderBy(x => x.Id).Take((int)produce.Qty).ToList();
|
||||
|
||||
if (produce == null)
|
||||
throw Oops.Oh("没有生产设置");
|
||||
|
||||
if (silks.Count < produce.Qty)
|
||||
{
|
||||
boxs.ForEach(e => e.IsUse = false);
|
||||
await boxRepository.UpdateManyAsync(boxs);
|
||||
logger.LogWarning($"没有{produce.Qty}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||||
throw Oops.Oh($"没有{produce.Qty}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||||
//return;
|
||||
}
|
||||
|
||||
var netWeight = silks.Sum(x => x.Net_Weight);
|
||||
var weight = silks.Average(x => x.Net_Weight);
|
||||
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 0,
|
||||
Mark = timestr,
|
||||
Type = (int)AutoLabelType.成箱码垛流水号
|
||||
}, true);
|
||||
|
||||
}
|
||||
autolabel.Sort += 1;
|
||||
logger.LogInformation("手动添加成箱信息" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
await autoRepository.UpdateAsync(autolabel);
|
||||
|
||||
var box = new Box()
|
||||
{
|
||||
Dom_Time = DateTime.Now,
|
||||
Exp_Time = string.IsNullOrWhiteSpace(input.Exp_Time) ? null : Convert.ToDateTime(input.Exp_Time),
|
||||
Exp_Time = produce.Exp_Time,
|
||||
Qty = produce.Qty,
|
||||
Length = produce.Length,
|
||||
Lot_No = produce.Lot_No,
|
||||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||||
Net_Weight = netWeight,
|
||||
Spec = produce.Spec,
|
||||
Create_Time = DateTime.Now,
|
||||
Type = produce.Type,
|
||||
IsUse = true,
|
||||
IsDelete = 0,
|
||||
DataType = (int)BoxDataType.手动装箱,
|
||||
Mark = "已经手动添加装箱信息"
|
||||
};
|
||||
|
||||
var entity = await boxRepository.InsertAsync(box, true);
|
||||
|
||||
logger.LogInformation($"已手动添加装箱信息,装箱编号:{box.Code},包含单品数量:{silks.Count}");
|
||||
|
||||
List<Silk> list = new List<Silk>();
|
||||
foreach (var silk in silks)
|
||||
{
|
||||
silk.Status = (int)SilkStatus.已手动装箱;
|
||||
silk.BoxId = entity.Id;
|
||||
silk.Status_Details = "已手动装箱";
|
||||
list.Add(silk);
|
||||
}
|
||||
|
||||
await silkRepository.UpdateManyAsync(list);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加纸箱
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task AddInsertBox(BoxDto input)
|
||||
{
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 0,
|
||||
Mark = timestr,
|
||||
Type = (int)AutoLabelType.成箱码垛流水号
|
||||
}, true);
|
||||
|
||||
}
|
||||
autolabel.Sort += 1;
|
||||
logger.LogInformation("手动添加成箱信息" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
await autoRepository.UpdateAsync(autolabel);
|
||||
|
||||
var box = new Box()
|
||||
{
|
||||
Dom_Time = DateTime.Now,
|
||||
Exp_Time = DateTime.Parse(input.Exp_Time),
|
||||
Qty = input.Qty,
|
||||
Length = input.Length,
|
||||
Lot_No = input.Lot_No,
|
||||
Code = input.Code,
|
||||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||||
Net_Weight = input.Net_Weight,
|
||||
Spec = input.Spec,
|
||||
Create_Time = DateTime.Now,
|
||||
Type = input.Type,
|
||||
IsUse = true,
|
||||
IsDelete = 0
|
||||
IsDelete = 0,
|
||||
DataType = (int)BoxDataType.手动成箱未包含单品信息,
|
||||
Mark = "手动添加的成箱信息数据库未绑定单品信息"
|
||||
};
|
||||
|
||||
var entity= await boxRepository.InsertAsync(box,true);
|
||||
string content = "#!A1" +
|
||||
"\r\n#N13" +
|
||||
"\r\n#PC1017/0" +
|
||||
"\r\n#IMR104/130" +
|
||||
//"\r\n#HV50" +
|
||||
"\r\n#PR6//" +
|
||||
"\r\n#PO0" +
|
||||
"\r\n#ERNC/1//0.00" +
|
||||
"\r\n#R0/0" +
|
||||
"\r\n#T7.28 #J11.17 #FD/1/L #SS100/BVUN/51X68/0 #VW/L/\"YuLinHengShenXinCaiLiaoYouXianGongSi\"#G" +
|
||||
"\r\n#T13.37 #J40.30 #FD/1/L #SS100/BVUN/46X62/0 #VW/L/\"Yulin Hengshen COLtd\"#G" +
|
||||
"\r\n#T52.15 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"TYPE " + box.Type + "\"#G" +
|
||||
"\r\n#T67.39 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"QTY/PCS " + box.Qty + "\"#G" +
|
||||
"\r\n#T82.63 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"LOT NO. " + box.Lot_No + "\"#G" +
|
||||
"\r\n#T98.97 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"DOM. " + box.Dom_Time.ToString() + "\"#G" +
|
||||
"\r\n#T52.15 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"SPEC " + box.Spec + "\"#G" +
|
||||
"\r\n#T67.39 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"CTY./NO. " + box.Net_Weight + "\"#G" +
|
||||
"\r\n#T81.19 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"LENGTH " + box.Length + "\"#G" +
|
||||
"\r\n#T98.21 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"EXP. " + box.Exp_Time.ToString() + "\"#G" +
|
||||
"\r\n#T41.06 #J6.68 #FD/1/L #SB13/ONKP2.0/20.82/5 #VW/L/\"" + box.Code + "\"#G" +
|
||||
"\r\n#Q1#G\r\n#!P1\r\n";
|
||||
await printerService.PrintAsync(2, content);
|
||||
var entity = await boxRepository.InsertAsync(box, true);
|
||||
|
||||
logger.LogInformation($"手动添加的成箱信息未绑定单品信息:{box.Code},未含单品数量");
|
||||
|
||||
BarTenderHelper.BoxPrint(box);
|
||||
logger.LogInformation($"打印条码{box.Code},成箱标签打印成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -164,30 +248,12 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[HttpPost]
|
||||
public async Task PrintBox(DelInput input)
|
||||
{
|
||||
var box = await boxRepository.FirstOrDefaultAsync(x=>x.Id==input.id);
|
||||
var box = await boxRepository.FirstOrDefaultAsync(x => x.Id == input.id);
|
||||
|
||||
BarTenderHelper.BoxPrint(box);
|
||||
logger.LogInformation($"打印条码{box.Code},成箱标签打印成功");
|
||||
//throw Oops.Oh("成箱标签打印成功");
|
||||
|
||||
string content = "#!A1" +
|
||||
"\r\n#N13" +
|
||||
"\r\n#PC1017/0" +
|
||||
"\r\n#IMR104/130" +
|
||||
//"\r\n#HV50" +
|
||||
"\r\n#PR6//" +
|
||||
"\r\n#PO0" +
|
||||
"\r\n#ERNC/1//0.00" +
|
||||
"\r\n#R0/0" +
|
||||
"\r\n#T7.28 #J11.17 #FD/1/L #SS100/BVUN/51X68/0 #VW/L/\"YuLinHengShenXinCaiLiaoYouXianGongSi\"#G" +
|
||||
"\r\n#T13.37 #J40.30 #FD/1/L #SS100/BVUN/46X62/0 #VW/L/\"Yulin Hengshen COLtd\"#G" +
|
||||
"\r\n#T52.15 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"TYPE " + box.Type + "\"#G" +
|
||||
"\r\n#T67.39 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"QTY/PCS " + box.Qty + "\"#G" +
|
||||
"\r\n#T82.63 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"LOT NO. " + box.Lot_No + "\"#G" +
|
||||
"\r\n#T98.97 #J9.14 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"DOM. " + box.Dom_Time.ToString() + "\"#G" +
|
||||
"\r\n#T52.15 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"SPEC " + box.Spec + "\"#G" +
|
||||
"\r\n#T67.39 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"CTY./NO. " + box.Net_Weight + "\"#G" +
|
||||
"\r\n#T81.19 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"LENGTH " + box.Length + "\"#G" +
|
||||
"\r\n#T98.21 #J69.25 #FD/1/L #SS100/BVUN/47X63/0 #VW/L/\"EXP. " + box.Exp_Time.ToString() + "\"#G" +
|
||||
"\r\n#T41.06 #J6.68 #FD/1/L #SB13/ONKP2.0/20.82/5 #VW/L/\"" + box.Code + "\"#G" +
|
||||
"\r\n#Q1#G\r\n#!P1\r\n";
|
||||
await printerService.PrintAsync(2, content);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
@ -202,10 +268,11 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
|
||||
box.Spec = input.Spec;
|
||||
box.Length = input.Length;
|
||||
box.Code = input.Code;
|
||||
//box.Code = input.Code;
|
||||
box.Lot_No = input.Lot_No;
|
||||
box.Net_Weight = input.Net_Weight;
|
||||
box.Dom_Time = DateTime.Now;
|
||||
box.Type = input.Type;
|
||||
box.Qty = input.Qty;
|
||||
box.Exp_Time = string.IsNullOrWhiteSpace(input.Exp_Time) ? null : Convert.ToDateTime(input.Exp_Time);
|
||||
await boxRepository.UpdateAsync(box);
|
||||
@ -236,7 +303,7 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
var boxs = await boxRepository.GetListAsync(x => input.ids.Contains(x.Id));
|
||||
if (boxs.Count == 0)
|
||||
throw Oops.Oh("删除失败,数据为空");
|
||||
for(var i = 0; i < boxs.Count; i++)
|
||||
for (var i = 0; i < boxs.Count; i++)
|
||||
{
|
||||
boxs[i].IsDelete = 1;
|
||||
}
|
||||
@ -249,7 +316,17 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
/// <returns></returns>
|
||||
public async Task SetTemperature(ByIdInput<short> input)
|
||||
{
|
||||
await plcService.SetTemperatureAsync(input.Id);
|
||||
await plcService.SetTemperatureAsync(input.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task ClearData()
|
||||
{
|
||||
await plcService.ClearData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -258,7 +335,180 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetTemperature()
|
||||
{
|
||||
return await plcService.GetTemperatureAsync();
|
||||
return await plcService.GetTemperatureAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 整箱码垛打印标签
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task BoxsPalletPrint(FullPalletInput input)
|
||||
{
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||||
var boxQuery = await boxRepository.GetQueryableAsync();
|
||||
var boxs = boxQuery.Where(x => x.DataType == 0 && x.IsDelete == 0).OrderBy(x => x.Id).Take(input.Num).ToList();
|
||||
|
||||
if (produce == null)
|
||||
throw Oops.Oh("没有生产设置");
|
||||
|
||||
if (boxs.Count < input.Num)
|
||||
{
|
||||
logger.LogWarning($"没有{input.Num}条{produce.Type}的整箱的信息,只有{boxs.Count}条,无法创建码垛信息");
|
||||
throw Oops.Oh($"没有{input.Num}条{produce.Type}的整箱的信息,只有{boxs.Count}条,无法创建码垛信息");
|
||||
//return;
|
||||
}
|
||||
|
||||
#region 生成自定义Code
|
||||
var netWeight = boxs.Sum(x => x.Net_Weight);
|
||||
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 0,
|
||||
Mark = timestr,
|
||||
Type = (int)AutoLabelType.成箱码垛流水号
|
||||
}, true);
|
||||
|
||||
}
|
||||
autolabel.Sort += 1;
|
||||
logger.LogInformation("整箱码垛生成Code" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
await autoRepository.UpdateAsync(autolabel);
|
||||
#endregion
|
||||
|
||||
var box = new Box()
|
||||
{
|
||||
Dom_Time = DateTime.Now,
|
||||
Type = produce.Type,
|
||||
Exp_Time = produce.Exp_Time,
|
||||
Qty = input.Num,
|
||||
Length = produce.Length,
|
||||
Lot_No = produce.Lot_No,
|
||||
//Code = Guid.NewGuid().ToString().Substring(9, 18),
|
||||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||||
Net_Weight = netWeight,
|
||||
Spec = produce.Spec,
|
||||
IsUse = true,
|
||||
IsDelete = 0,
|
||||
DataType = (int)BoxDataType.成箱码垛,
|
||||
Create_Time = DateTime.Now,
|
||||
Mark = "整箱手动码垛,码垛整箱数量" + input.Num
|
||||
};
|
||||
|
||||
var Box = await boxRepository.InsertAsync(box, true);
|
||||
logger.LogInformation($"已添加码垛信息,码垛编号:{box.Code},包含整箱数量:{boxs.Count}");
|
||||
|
||||
List<Box> list = new List<Box>();
|
||||
foreach (var item in boxs)
|
||||
{
|
||||
item.DataType = (int)BoxDataType.已码垛;
|
||||
item.Mark = "已码垛到编号" + Box.Code + "中,码垛数据编号ID" + Box.Id;
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
await boxRepository.UpdateManyAsync(list);
|
||||
|
||||
#region 打印标签
|
||||
//打印标签
|
||||
BarTenderHelper.BoxPrint(box);
|
||||
logger.LogInformation($"打印条码{box.Code},成箱码垛标签打印成功");
|
||||
//throw Oops.Oh("成箱码垛标签打印成功");
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单品码垛打印标签
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task SilksPalletPrint(FullPalletInput input)
|
||||
{
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||||
var silksQuery = await silkRepository.GetQueryableAsync();
|
||||
var silks = silksQuery.Where(x => x.IsDelete == 0 && x.Status == (int)SilkStatus.已称重).OrderBy(x => x.Id).Take(input.Num).ToList();
|
||||
|
||||
if (produce == null)
|
||||
throw Oops.Oh("没有生产设置");
|
||||
|
||||
if (silks.Count < input.Num)
|
||||
{
|
||||
logger.LogWarning($"没有{input.Num}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||||
throw Oops.Oh($"没有{input.Num}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||||
//return;
|
||||
}
|
||||
|
||||
var netWeight = silks.Sum(x => x.Net_Weight);
|
||||
var weight = silks.Average(x => x.Net_Weight);
|
||||
|
||||
#region 自动生成成箱码垛流水号
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 0,
|
||||
Mark = timestr,
|
||||
Type = (int)AutoLabelType.成箱码垛流水号
|
||||
}, true);
|
||||
|
||||
}
|
||||
autolabel.Sort += 1;
|
||||
logger.LogInformation("丝锭码垛生成Code" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
await autoRepository.UpdateAsync(autolabel);
|
||||
#endregion
|
||||
|
||||
var box = new Box()
|
||||
{
|
||||
Dom_Time = DateTime.Now,
|
||||
Type = produce.Type,
|
||||
Exp_Time = produce.Exp_Time,
|
||||
Qty = input.Num,
|
||||
Length = produce.Length,
|
||||
Lot_No = produce.Lot_No,
|
||||
//Code = Guid.NewGuid().ToString().Substring(9, 18),
|
||||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||||
Net_Weight = netWeight,
|
||||
Spec = produce.Spec,
|
||||
IsUse = true,
|
||||
IsDelete = 0,
|
||||
DataType = (int)BoxDataType.单品码垛,
|
||||
Create_Time = DateTime.Now,
|
||||
Mark = "单品手动码垛,码垛单品数量" + input.Num
|
||||
};
|
||||
|
||||
var Box = await boxRepository.InsertAsync(box, true);
|
||||
logger.LogInformation($"已添加码垛信息,码垛编号:{box.Code},包含单品数量:{silks.Count}");
|
||||
|
||||
List<Silk> list = new List<Silk>();
|
||||
foreach (var silk in silks)
|
||||
{
|
||||
silk.Status = 3;
|
||||
silk.BoxId = Box.Id;
|
||||
silk.Status_Details = "已码垛";
|
||||
list.Add(silk);
|
||||
}
|
||||
|
||||
await silkRepository.UpdateManyAsync(list);
|
||||
|
||||
#region 打印标签
|
||||
//打印标签
|
||||
BarTenderHelper.BoxPrint(box);
|
||||
logger.LogInformation($"打印条码{box.Code},丝锭码垛标签打印成功");
|
||||
//throw Oops.Oh("丝锭码垛标签打印成功");
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,10 +47,11 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
Id = x.Id,
|
||||
Length = x.Length,
|
||||
Type = x.Type,
|
||||
BoxSpec = x.BoxSpec,
|
||||
//BoxSpec = x.BoxSpec,
|
||||
Date = x.Date.HasValue ? x.Exp_Time.Value.ToString("yyyy-MM-dd HH:m") : "-",
|
||||
Exp_Time = x.Exp_Time.HasValue ? x.Exp_Time.Value.ToString("yyyy-MM-dd HH:m") : "-",
|
||||
IfUse = x.IfUse,
|
||||
Name = x.Name,
|
||||
//Name = x.Name,
|
||||
Qty = x.Qty
|
||||
});
|
||||
|
||||
@ -100,10 +101,11 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
Spec = input.Spec,
|
||||
Type = input.Type,
|
||||
Qty = input.Qty,
|
||||
BoxSpec = input.BoxSpec,
|
||||
BoxSpec = input.Spec,
|
||||
Date= string.IsNullOrWhiteSpace(input.Date) ? null : Convert.ToDateTime(input.Exp_Time),
|
||||
Exp_Time = string.IsNullOrWhiteSpace(input.Exp_Time) ? null : Convert.ToDateTime(input.Exp_Time),
|
||||
IfUse = 1,
|
||||
Name = input.Name,
|
||||
Name = input.Type,
|
||||
IsDelete = 0
|
||||
};
|
||||
|
||||
@ -124,8 +126,9 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
produce.Length = input.Length;
|
||||
produce.Lot_No = input.Lot_No;
|
||||
produce.Qty = input.Qty;
|
||||
produce.Name = input.Name;
|
||||
produce.BoxSpec = input.BoxSpec;
|
||||
produce.Name = input.Type;
|
||||
produce.BoxSpec = input.Spec;
|
||||
produce.Date = string.IsNullOrWhiteSpace(input.Date) ? null : Convert.ToDateTime(input.Date);
|
||||
produce.Exp_Time = string.IsNullOrWhiteSpace(input.Exp_Time) ? null : Convert.ToDateTime(input.Exp_Time);
|
||||
await produceRepository.UpdateAsync(produce);
|
||||
}
|
||||
|
||||
@ -16,19 +16,21 @@ using Volo.Abp.Domain.Repositories;
|
||||
namespace Syc.Basic.Web.WMS.Service
|
||||
{
|
||||
[AllowAnonymous]
|
||||
public class SilkService:ApiService
|
||||
public class SilkService : ApiService
|
||||
{
|
||||
private readonly IPrinterService printerService;
|
||||
private readonly IRepository<Produce> produceRepository;
|
||||
private readonly IRepository<Silk> silkRepository;
|
||||
private readonly ILogger<SilkService> logger;
|
||||
private readonly IRepository<AutoLabel> autoRepository;
|
||||
|
||||
public SilkService(IPrinterService printerService,IRepository<Produce> produceRepository ,IRepository<Silk> silkRepository,ILogger<SilkService> logger)
|
||||
public SilkService(IPrinterService printerService, IRepository<Produce> produceRepository, IRepository<Silk> silkRepository, ILogger<SilkService> logger, IRepository<AutoLabel> autoRepository)
|
||||
{
|
||||
this.printerService = printerService;
|
||||
this.produceRepository = produceRepository;
|
||||
this.silkRepository = silkRepository;
|
||||
this.logger = logger;
|
||||
this.autoRepository = autoRepository;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据数量查询丝锭
|
||||
@ -38,9 +40,11 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[HttpGet]
|
||||
public async Task<List<SilkDto>> GetSilkByNum()
|
||||
{
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1 && x.IsDelete == 0);
|
||||
if (produce == null)
|
||||
throw Oops.Oh("没有生产设置");
|
||||
var list = await silkRepository.GetQueryableAsync();
|
||||
list = list.Where(x => x.Status==1 && x.IsDelete == 0 || x.Status == 0 && x.IsDelete == 0);
|
||||
list = list.Where(x => x.Status == 1 && x.IsDelete == 0 && x.Type == produce.Spec && x.Lot_No == produce.Lot_No && x.Name == produce.Type || x.Status == 0 && x.IsDelete == 0 && x.Type == produce.Spec && x.Lot_No == produce.Lot_No && x.Name == produce.Type);
|
||||
|
||||
var data = list.Select(e => new SilkDto()
|
||||
{
|
||||
@ -51,7 +55,7 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
Status_Details = e.Status_Details
|
||||
}).ToList();
|
||||
|
||||
return data.OrderByDescending(x => x.Id).ToList().ToList();
|
||||
return data.OrderByDescending(x => x.Id).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询丝锭
|
||||
@ -68,25 +72,25 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
if (input.Lot_No != null)
|
||||
silklist = silklist.Where(x => x.Type.Contains(input.Lot_No));
|
||||
|
||||
var result = silklist.PageResult(input.Page, input.PageSize);
|
||||
var data = result.Queryable.Select(x=>new SilkDto()
|
||||
var result = silklist.OrderByDescending(x => x.Id).PageResult(input.Page, input.PageSize);
|
||||
var data = result.Queryable.Select(x => new SilkDto()
|
||||
{
|
||||
Name=x.Name,
|
||||
Net_Weight=x.Net_Weight,
|
||||
Lot_No=x.Lot_No,
|
||||
Code=x.Code,
|
||||
Date=x.Date,
|
||||
Id=x.Id,
|
||||
Length=x.Length,
|
||||
Type=x.Type,
|
||||
BoxId=x.BoxId,
|
||||
Status=x.Status,
|
||||
Status_Details=x.Status_Details
|
||||
Name = x.Name,
|
||||
Net_Weight = x.Net_Weight,
|
||||
Lot_No = x.Lot_No,
|
||||
Code = x.Code,
|
||||
Date = x.Date,
|
||||
Id = x.Id,
|
||||
Length = x.Length,
|
||||
Type = x.Type,
|
||||
BoxId = x.BoxId,
|
||||
Status = x.Status,
|
||||
Status_Details = x.Status_Details
|
||||
});
|
||||
|
||||
PageOutput<SilkDto> pageOutput = new PageOutput<SilkDto>();
|
||||
pageOutput.Total = silklist.Count();
|
||||
pageOutput.Data = data.OrderByDescending(x => x.Id);
|
||||
pageOutput.Data = data;
|
||||
pageOutput.PageIndex = input.Page;
|
||||
pageOutput.PageSize = input.PageSize;
|
||||
return pageOutput;
|
||||
@ -99,44 +103,50 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[HttpPost]
|
||||
public async Task InsertSilk(SilkDto input)
|
||||
{
|
||||
if (await silkRepository.AnyAsync(x => x.Code == input.Code&&x.IsDelete==0))
|
||||
throw Oops.Oh("条码已存在,不允许添加");
|
||||
|
||||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||||
|
||||
if (produce == null)
|
||||
throw Oops.Oh("没有生产设置");
|
||||
|
||||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.单品流水号);
|
||||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
if (autolabel == null)
|
||||
{
|
||||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||||
{
|
||||
Date = date,
|
||||
Sort = 0,
|
||||
Mark = timestr,
|
||||
Type = (int)AutoLabelType.单品流水号
|
||||
}, true);
|
||||
|
||||
}
|
||||
autolabel.Sort += 1;
|
||||
logger.LogInformation("添加丝锭单品流水号" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||||
await autoRepository.UpdateAsync(autolabel);
|
||||
|
||||
var silk = new Silk()
|
||||
{
|
||||
Date = DateTime.Now,
|
||||
Length = input.Length,
|
||||
Lot_No = input.Lot_No,
|
||||
Code = input.Code,
|
||||
Length = produce.Length,
|
||||
Lot_No = produce.Lot_No,
|
||||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||||
Net_Weight = input.Net_Weight,
|
||||
Name = input.Name,
|
||||
Type = input.Type,
|
||||
Name = produce.Type,
|
||||
Type = produce.Spec,
|
||||
Createtime = DateTime.Now,
|
||||
Status = (int)SilkStatus.手动添加称重,
|
||||
Status_Details = "手动添加称重",
|
||||
IsDelete = 0
|
||||
};
|
||||
var entity = await silkRepository.InsertAsync(silk,true);
|
||||
var entity = await silkRepository.InsertAsync(silk, true);
|
||||
|
||||
string content = "#!A1" +
|
||||
"\r\n#N13" +
|
||||
"\r\n#PC1017/0" +
|
||||
"\r\n#IMR44/46" +
|
||||
//"\r\n#HV50" +
|
||||
"\r\n#PR6//" +
|
||||
"\r\n#PO0" +
|
||||
"\r\n#ERNC/1//0.00" +
|
||||
"\r\n#R0/0" +
|
||||
"\r\n#T3.64 #J43.18 #FD/0/L #SS100/BVUN/21X21/0 #VW/L/\"YuLinHengShenXinCaiLiaoYouXianGongSi\"#G" +
|
||||
"\r\n#T11.85 #J40.47 #FD/0/L #SS100/BVUN/19X19/0 #VW/L/\"Yulin Hengshen COLtd\"#G" +
|
||||
"\r\n#T2.28 #J25.31 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Name " + silk.Name + "\"#G" +
|
||||
"\r\n#T2.28 #J20.91 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Type " + silk.Type + "\"#G" +
|
||||
"\r\n#T2.28 #J16.51 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Net Weight " + silk.Net_Weight + "\"#G" +
|
||||
"\r\n#T2.28 #J12.61 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Length " + silk.Length + "\"#G" +
|
||||
"\r\n#T2.28 #J7.95 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Date " + silk.Date.ToString() + "\"#G" +
|
||||
"\r\n#T2.28 #J3.89 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Lot No " + silk.Lot_No + "\"#G" +
|
||||
"\r\n#T11.51 #J29.54 #FD/0/L #SB13/ONKP2.0/8.80/2 #VW/L/\"" + silk.Code + "\"#G" +
|
||||
"\r\n#Q1#G" +
|
||||
"\r\n#!P1" +
|
||||
"\r\n";
|
||||
await printerService.PrintAsync(1,content);
|
||||
logger.LogInformation($"添加丝锭成功");
|
||||
|
||||
BarTenderHelper.SilkPrint(silk);
|
||||
logger.LogInformation($"打印{silk.Code}条码丝锭标签成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -147,30 +157,10 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[HttpPost]
|
||||
public async Task PrintSilk(DelInput input)
|
||||
{
|
||||
var silk = await silkRepository.FirstOrDefaultAsync(x=>x.Id==input.id);
|
||||
var silk = await silkRepository.FirstOrDefaultAsync(x => x.Id == input.id);
|
||||
|
||||
string content = "#!A1" +
|
||||
"\r\n#N13" +
|
||||
"\r\n#PC1017/0" +
|
||||
"\r\n#IMR44/46" +
|
||||
//"\r\n#HV50" +
|
||||
"\r\n#PR6//" +
|
||||
"\r\n#PO0" +
|
||||
"\r\n#ERNC/1//0.00" +
|
||||
"\r\n#R0/0" +
|
||||
"\r\n#T3.64 #J43.18 #FD/0/L #SS100/BVUN/21X21/0 #VW/L/\"YuLinHengShenXinCaiLiaoYouXianGongSi\"#G" +
|
||||
"\r\n#T11.85 #J40.47 #FD/0/L #SS100/BVUN/19X19/0 #VW/L/\"Yulin Hengshen COLtd\"#G" +
|
||||
"\r\n#T2.28 #J25.31 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Name " + silk.Name + "\"#G" +
|
||||
"\r\n#T2.28 #J20.91 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Type " + silk.Type + "\"#G" +
|
||||
"\r\n#T2.28 #J16.51 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Net Weight " + silk.Net_Weight + "\"#G" +
|
||||
"\r\n#T2.28 #J12.61 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Length " + silk.Length + "\"#G" +
|
||||
"\r\n#T2.28 #J7.95 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Date " + silk.Date.ToString() + "\"#G" +
|
||||
"\r\n#T2.28 #J3.89 #FD/0/L #SS100/BVUN/20X20/0 #VW/L/\"Lot No " + silk.Lot_No + "\"#G" +
|
||||
"\r\n#T11.51 #J29.54 #FD/0/L #SB13/ONKP2.0/8.80/2 #VW/L/\"" + silk.Code + "\"#G" +
|
||||
"\r\n#Q1#G" +
|
||||
"\r\n#!P1" +
|
||||
"\r\n";
|
||||
await printerService.PrintAsync(1, content);
|
||||
BarTenderHelper.SilkPrint(silk);
|
||||
logger.LogInformation($"打印{silk.Code}条码丝锭标签成功");
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改丝锭
|
||||
@ -180,12 +170,12 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[HttpPost]
|
||||
public async Task UpdateSilk(SilkDto input)
|
||||
{
|
||||
var silks = await silkRepository.FirstOrDefaultAsync(x=>x.Id==input.Id);
|
||||
var silks = await silkRepository.FirstOrDefaultAsync(x => x.Id == input.Id);
|
||||
|
||||
silks.Name = input.Name;
|
||||
silks.Type = input.Type;
|
||||
silks.Length = input.Length;
|
||||
silks.Code = input.Code;
|
||||
//silks.Code = input.Code;
|
||||
silks.Lot_No = input.Lot_No;
|
||||
silks.Net_Weight = input.Net_Weight;
|
||||
silks.Date = DateTime.Now;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using DotNetCore.CAP;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Seyounth.Auto.Hs.Runtime.Printer;
|
||||
using Syc.Authorize.JwtBearer;
|
||||
using Syc.Basic.Web.Services;
|
||||
using Syc.Basic.Web.WMS.Dtos.Auth;
|
||||
@ -19,7 +21,17 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
[AllowAnonymous]
|
||||
public class TestService:ApiService
|
||||
{
|
||||
|
||||
private readonly IPrinterService printerService;
|
||||
private readonly IRepository<AutoLabel> autoReposutory;
|
||||
private readonly ILogger<AutoService> logger;
|
||||
|
||||
public TestService(IPrinterService PrinterService, IRepository<AutoLabel> AutoReposutory, ILogger<AutoService> logger)
|
||||
{
|
||||
printerService = PrinterService;
|
||||
autoReposutory = AutoReposutory;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<object> GetTest()
|
||||
{
|
||||
|
||||
@ -21,6 +21,7 @@ using System.Threading.Tasks;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Syc.Basic.Web.WMS.Dto;
|
||||
|
||||
namespace Syc.Basic.Web.WMS.Service
|
||||
{
|
||||
@ -83,12 +84,28 @@ namespace Syc.Basic.Web.WMS.Service
|
||||
if (users.Count > 0)
|
||||
await repository.DeleteManyAsync(users);
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改密码
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task EditPassword(UserInput input)
|
||||
{
|
||||
var userDO = await repository.FirstOrDefaultAsync(x=>x.Id==input.Id);
|
||||
if (userDO.Password != Tools.SecurityUtil.MD5Encrypt(input.NewPassword, Encoding.ASCII))
|
||||
throw Oops.Oh("旧密码与密码不一致");
|
||||
if (userDO.IsNullOrEmpty())
|
||||
throw Oops.Oh("用户不存在");
|
||||
if (input.NewPassword == input.JiuPassword)
|
||||
throw Oops.Oh("新密码不能与旧密码一样");
|
||||
|
||||
userDO.Password = Tools.SecurityUtil.MD5Encrypt(input.NewPassword, Encoding.ASCII);
|
||||
|
||||
await repository.UpdateAsync(userDO);
|
||||
}
|
||||
|
||||
public async Task Edit(UserInsertInput input)
|
||||
{
|
||||
var accountExist = await repository.AnyAsync(e => e.Account == input.username && e.Id != input.id);
|
||||
if (accountExist)
|
||||
throw Oops.Oh("账号已存在,请重复使用");
|
||||
var userDO = await userRepository.GetUserByAccountAsync(input.username);
|
||||
if(userDO.IsNullOrEmpty())
|
||||
throw Oops.Oh("用户不存在");
|
||||
|
||||
@ -9,6 +9,18 @@
|
||||
<DocumentationFile>$(MSBuildProjectName).xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<COMReference Include="BarTender">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<VersionMajor>11</VersionMajor>
|
||||
<Guid>d58562c1-e51b-11cf-8941-00a024a9083f</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNetCore.CAP" Version="8.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
|
||||
@ -4,6 +4,27 @@
|
||||
<name>Syc.Basic.Web.WMS.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:Syc.Basic.Web.WMS.BarTenderHelper.Print(System.String,System.String,System.Collections.Generic.Dictionary{System.String,System.String})">
|
||||
<summary>
|
||||
打印标签
|
||||
</summary>
|
||||
<param name="templatePath">模板全路径,如:D://AD盘/新建文件夹/xxxx.btw</param>
|
||||
<param name="deviceName">打印机名称</param>
|
||||
<param name="@params">模板变量参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.BarTenderHelper.BoxPrint(Syc.Basic.Web.WMS.Entitys.Box)">
|
||||
<summary>
|
||||
打印箱子标签
|
||||
</summary>
|
||||
<param name="box"></param>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.BarTenderHelper.SilkPrint(Syc.Basic.Web.WMS.Entitys.Silk)">
|
||||
<summary>
|
||||
打印丝锭标签
|
||||
</summary>
|
||||
<param name="box"></param>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.DeviceEventHandle.DefaultBalanceEventHandle.Yanr(System.Decimal)">
|
||||
<summary>
|
||||
丝锭称重
|
||||
@ -76,6 +97,13 @@
|
||||
<returns></returns>
|
||||
<exception cref="T:System.NotImplementedException"></exception>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.AutoService.AutoLabel(System.Int32)">
|
||||
<summary>
|
||||
打印唯一标签
|
||||
</summary>
|
||||
<param name="num"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.BoxService.GetBoxList(Syc.Basic.Web.WMS.Dto.BoxInput)">
|
||||
<summary>
|
||||
查询纸箱
|
||||
@ -97,6 +125,13 @@
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.BoxService.AddInsertBox(Syc.Basic.Web.WMS.Dto.BoxDto)">
|
||||
<summary>
|
||||
添加纸箱
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.BoxService.PrintBox(Syc.Basic.Web.WMS.Dto.DelInput)">
|
||||
<summary>
|
||||
打印纸箱
|
||||
@ -131,12 +166,32 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.BoxService.ClearData">
|
||||
<summary>
|
||||
复位
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.BoxService.GetTemperature">
|
||||
<summary>
|
||||
设置热缩机温度
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.BoxService.BoxsPalletPrint(Syc.Basic.Web.WMS.Dto.FullPalletInput)">
|
||||
<summary>
|
||||
整箱码垛打印标签
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.BoxService.SilksPalletPrint(Syc.Basic.Web.WMS.Dto.FullPalletInput)">
|
||||
<summary>
|
||||
单品码垛打印标签
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.ProduceService.GetProduceList(Syc.Basic.Web.WMS.Dto.ProduceInput)">
|
||||
<summary>
|
||||
查询生产
|
||||
@ -235,6 +290,13 @@
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.UserAppService.EditPassword(Syc.Basic.Web.WMS.Dto.UserInput)">
|
||||
<summary>
|
||||
修改密码
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Syc.Basic.Web.WMS.Service.UserAppService.Profile">
|
||||
<summary>
|
||||
个人信息
|
||||
|
||||
17
services/Syc.Basic.Web.WMS.Domain/Entitys/AutoLabel.cs
Normal file
17
services/Syc.Basic.Web.WMS.Domain/Entitys/AutoLabel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
|
||||
namespace Syc.Basic.Web.WMS.Entitys
|
||||
{
|
||||
public class AutoLabel:Entity<int>
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public int Type { get; set; }
|
||||
public int Sort { get; set; }
|
||||
public string Mark { get; set; }
|
||||
}
|
||||
}
|
||||
@ -24,15 +24,20 @@ namespace Syc.Basic.Web.WMS.Entitys
|
||||
//生产批号
|
||||
public string Lot_No { get; set; }
|
||||
//长度
|
||||
public double? Length { get; set; }
|
||||
public string? Length { get; set; }
|
||||
//打包时间
|
||||
public DateTime? Dom_Time { get; set; }
|
||||
//生产日期
|
||||
public DateTime? Exp_Time { get; set; }
|
||||
//数据类型(0:整箱,1码垛)
|
||||
public int DataType { get; set; }
|
||||
//描述
|
||||
public string? Mark { get; set; }
|
||||
/// <summary>
|
||||
/// 是否在装箱
|
||||
/// </summary>
|
||||
public bool IsUse { get; set; } = true;
|
||||
public int IsDelete { get; set; }
|
||||
public DateTime? Create_Time { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ namespace Syc.Basic.Web.WMS.Entitys
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public string Spec { get; set; }
|
||||
public double Length { get; set; }
|
||||
public string Length { get; set; }
|
||||
public string Lot_No { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int? Qty { get; set; }
|
||||
public string BoxSpec { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
public DateTime? Exp_Time { get; set; }
|
||||
public int IfUse { get; set; }
|
||||
public int IsDelete { get; set; }
|
||||
|
||||
@ -19,14 +19,14 @@ namespace Syc.Basic.Web.WMS.Entitys
|
||||
//净重
|
||||
public double? Net_Weight { get; set; }
|
||||
//长度
|
||||
public double? Length { get; set; }
|
||||
public string? Length { get; set; }
|
||||
//包装时间
|
||||
public DateTime? Date { get; set; }
|
||||
//生产批号
|
||||
public string Lot_No { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 0:已扫码待称重 1:已称重待装箱 2:已装箱
|
||||
/// 0:已扫码待称重 1:已称重待装箱 2:已装箱 3:已码垛
|
||||
/// </summary>
|
||||
[ConcurrencyCheck]
|
||||
public int Status { get; set; }
|
||||
|
||||
@ -180,6 +180,12 @@ namespace Syc.Basic.Web.EntityFrameworkCore
|
||||
b.ConfigureByConvention();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AutoLabel>(b =>
|
||||
{
|
||||
b.ToTable(nameof(AutoLabel));
|
||||
b.ConfigureByConvention();
|
||||
});
|
||||
|
||||
return modelBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,6 +82,8 @@ public class WMSDbContext :
|
||||
public virtual DbSet<Silk> Silk { get; set; }
|
||||
//生产
|
||||
public virtual DbSet<Produce> Produce { get; set; }
|
||||
//自动生成条码
|
||||
public virtual DbSet<AutoLabel> AutoLabel { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
|
||||
@ -123,18 +123,21 @@ namespace Seyounth.Auto.Hs.Runtime.Balances
|
||||
weight = Convert.ToDecimal(matchs.Value);
|
||||
;
|
||||
//logger.LogInformation("YYYYYYYYYYYYYYYYYYYY");
|
||||
//logger.LogInformation($"Received data: {result},weight:{weight},tag:{tag}");
|
||||
//1.刚开机,重量为 0
|
||||
if (weight <= 0)
|
||||
{
|
||||
//logger.LogInformation("tag=true");
|
||||
tag = true;
|
||||
continue;
|
||||
}
|
||||
;
|
||||
//logger.LogInformation($"cccccccc");
|
||||
if (MonitorWeightStability(_weights, weight))
|
||||
{
|
||||
//logger.LogInformation($"BBBBBBBB");
|
||||
if (tag)
|
||||
{
|
||||
//logger.LogInformation($"丝锭称接收数据:{result},字节数:{readCount}");
|
||||
logger.LogInformation($"丝锭称接收数据:{result},字节数:{readCount}");
|
||||
using (var scope = serviceProvider.CreateAsyncScope())
|
||||
{
|
||||
var handles = scope.ServiceProvider.GetService<IEnumerable<IBalanceEventHandle>>();
|
||||
|
||||
@ -103,7 +103,7 @@ public class HsAutoRuntime : IHsAutoRuntime
|
||||
}
|
||||
}
|
||||
|
||||
public Task RunAsync()
|
||||
public Task RunAsync()
|
||||
{
|
||||
var tasks = new List<Task>
|
||||
{
|
||||
@ -135,6 +135,16 @@ public class HsAutoRuntime : IHsAutoRuntime
|
||||
: $"Printer connection failed. error: {t.Exception?.Message}");
|
||||
})
|
||||
};
|
||||
|
||||
//while (true)
|
||||
//{
|
||||
// foreach (var task in tasks)
|
||||
// {
|
||||
// _logger.LogInformation($"{task.Id}:{task.Status}");
|
||||
// }
|
||||
// await Task.Delay(1000);
|
||||
//}
|
||||
|
||||
return Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ public class HsBackgroundService(IHsAutoRuntime hs) : BackgroundService
|
||||
{
|
||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await hs.RunAsync();
|
||||
hs.RunAsync();
|
||||
await base.StartAsync(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +55,16 @@ public interface IPlcService
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task ClearTop();
|
||||
/// <summary>
|
||||
/// 复位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task ClearData();
|
||||
/// <summary>
|
||||
/// 打印完成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task PrintEnd();
|
||||
|
||||
/// <summary>
|
||||
/// 外箱标签打印完成
|
||||
|
||||
@ -8,7 +8,7 @@ public class PlcService : IPlcService
|
||||
private readonly ILogger<PlcService> _logger;
|
||||
|
||||
private readonly IPlc _plc;
|
||||
public PlcService(IPlc plc,ILogger<PlcService> logger)
|
||||
public PlcService(IPlc plc, ILogger<PlcService> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_plc = plc;
|
||||
@ -56,14 +56,14 @@ public class PlcService : IPlcService
|
||||
|
||||
public async Task<bool> IsTop()
|
||||
{
|
||||
var arr = await _plc.ReadAsync<short>("1002", 1);
|
||||
var arr = await _plc.ReadAsync<short>("1002", 1);
|
||||
//_logger.LogInformation($"是否顶升寄存器值:{arr?.FirstOrDefault()}");
|
||||
return arr?.FirstOrDefault() == 1;
|
||||
return arr?.FirstOrDefault() == 1;
|
||||
}
|
||||
|
||||
public async Task BoxTagPrintDoneAsync(short value)
|
||||
{
|
||||
await _plc.WriteAsync<short>("1102",value);
|
||||
await _plc.WriteAsync<short>("1102", value);
|
||||
_logger.LogInformation("已回复打印完成信号");
|
||||
}
|
||||
|
||||
@ -74,6 +74,18 @@ public class PlcService : IPlcService
|
||||
|
||||
public async Task ClearTop()
|
||||
{
|
||||
await _plc.WriteAsync("1002",0);
|
||||
await _plc.WriteAsync("1002", 0);
|
||||
}
|
||||
|
||||
public async Task PrintEnd()
|
||||
{
|
||||
await _plc.WriteAsync<short>("1101", 1);
|
||||
_logger.LogInformation("已向1101写入1发送打印完成信号");
|
||||
}
|
||||
|
||||
public async Task ClearData()
|
||||
{
|
||||
await _plc.WriteAsync<short>("1103", 1);
|
||||
_logger.LogInformation("已向1103写入1发送复位信号");
|
||||
}
|
||||
}
|
||||
@ -54,46 +54,47 @@ namespace Seyounth.Auto.Hs.Runtime.Scanner
|
||||
/// <returns></returns>
|
||||
public async Task ConnectAsync()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (_tcp is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tcp.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
/*
|
||||
* 忽略释放异常
|
||||
*/
|
||||
}
|
||||
logger.LogInformation("箱扫码枪已弃用不连接");
|
||||
//while (true)
|
||||
//{
|
||||
// if (_tcp is not null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// _tcp.Dispose();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// /*
|
||||
// * 忽略释放异常
|
||||
// */
|
||||
// }
|
||||
|
||||
}
|
||||
_tcp = new TcpClient();
|
||||
try
|
||||
{
|
||||
await _tcp.ConnectAsync(new IPEndPoint(IPAddress.Parse(DeviceConnectConfig.IP), DeviceConnectConfig.Port));
|
||||
if (_stream is not null)
|
||||
_stream.Dispose();
|
||||
_stream = _tcp.GetStream();
|
||||
logger.LogInformation("箱扫码枪连接成功,开始接收数据");
|
||||
_receiveDataCancellationToken?.Cancel();
|
||||
_receiveDataCancellationToken = new CancellationTokenSource();
|
||||
ReceiveData(_receiveDataCancellationToken.Token);
|
||||
break;
|
||||
}
|
||||
catch (Exception ex) when (ex.GetBaseException() is OperationCanceledException oce || ex.GetBaseException() is SocketException socketException)
|
||||
{
|
||||
await Task.Delay(1000 * 5);
|
||||
logger.LogError(ex.GetBaseException(), "箱扫码枪连接失败,尝试重连中");
|
||||
continue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "箱扫码枪连接失败");
|
||||
}
|
||||
}
|
||||
// }
|
||||
// _tcp = new TcpClient();
|
||||
// try
|
||||
// {
|
||||
// await _tcp.ConnectAsync(new IPEndPoint(IPAddress.Parse(DeviceConnectConfig.IP), DeviceConnectConfig.Port));
|
||||
// if (_stream is not null)
|
||||
// _stream.Dispose();
|
||||
// _stream = _tcp.GetStream();
|
||||
// logger.LogInformation("箱扫码枪连接成功,开始接收数据");
|
||||
// _receiveDataCancellationToken?.Cancel();
|
||||
// _receiveDataCancellationToken = new CancellationTokenSource();
|
||||
// ReceiveData(_receiveDataCancellationToken.Token);
|
||||
// break;
|
||||
// }
|
||||
// catch (Exception ex) when (ex.GetBaseException() is OperationCanceledException oce || ex.GetBaseException() is SocketException socketException)
|
||||
// {
|
||||
// await Task.Delay(1000 * 5);
|
||||
// logger.LogError(ex.GetBaseException(), "箱扫码枪连接失败,尝试重连中");
|
||||
// continue;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// logger.LogError(ex, "箱扫码枪连接失败");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -48,46 +48,47 @@ namespace Seyounth.Auto.Hs.Runtime.Scanner
|
||||
/// <returns></returns>
|
||||
public async Task ConnectAsync()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (_tcp is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tcp.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
/*
|
||||
* 忽略释放异常
|
||||
*/
|
||||
}
|
||||
logger.LogInformation("丝锭扫码枪已弃用");
|
||||
//while (true)
|
||||
//{
|
||||
// if (_tcp is not null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// _tcp.Dispose();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// /*
|
||||
// * 忽略释放异常
|
||||
// */
|
||||
// }
|
||||
|
||||
}
|
||||
_tcp = new TcpClient();
|
||||
try
|
||||
{
|
||||
await _tcp.ConnectAsync(new IPEndPoint(IPAddress.Parse(DeviceConnectConfig.IP), DeviceConnectConfig.Port));
|
||||
if (_stream is not null)
|
||||
_stream.Dispose();
|
||||
_stream = _tcp.GetStream();
|
||||
logger.LogInformation("人工扫码枪连接成功,开始接收数据");
|
||||
_receiveDataCancellationToken?.Cancel();
|
||||
_receiveDataCancellationToken = new CancellationTokenSource();
|
||||
ReceiveData(_receiveDataCancellationToken.Token);
|
||||
break;
|
||||
}
|
||||
catch (Exception ex) when (ex.GetBaseException() is OperationCanceledException oce || ex.GetBaseException() is SocketException socketException)
|
||||
{
|
||||
await Task.Delay(1000 * 5);
|
||||
logger.LogError(ex.GetBaseException(), "人工扫码枪连接失败,尝试重连中");
|
||||
continue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "人工扫码枪连接失败");
|
||||
}
|
||||
}
|
||||
// }
|
||||
// _tcp = new TcpClient();
|
||||
// try
|
||||
// {
|
||||
// await _tcp.ConnectAsync(new IPEndPoint(IPAddress.Parse(DeviceConnectConfig.IP), DeviceConnectConfig.Port));
|
||||
// if (_stream is not null)
|
||||
// _stream.Dispose();
|
||||
// _stream = _tcp.GetStream();
|
||||
// logger.LogInformation("人工扫码枪连接成功,开始接收数据");
|
||||
// _receiveDataCancellationToken?.Cancel();
|
||||
// _receiveDataCancellationToken = new CancellationTokenSource();
|
||||
// ReceiveData(_receiveDataCancellationToken.Token);
|
||||
// break;
|
||||
// }
|
||||
// catch (Exception ex) when (ex.GetBaseException() is OperationCanceledException oce || ex.GetBaseException() is SocketException socketException)
|
||||
// {
|
||||
// await Task.Delay(1000 * 5);
|
||||
// logger.LogError(ex.GetBaseException(), "人工扫码枪连接失败,尝试重连中");
|
||||
// continue;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// logger.LogError(ex, "人工扫码枪连接失败");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -6,6 +6,18 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<COMReference Include="BarTender">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<VersionMajor>11</VersionMajor>
|
||||
<Guid>d58562c1-e51b-11cf-8941-00a024a9083f</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
|
||||
<!--<ItemGroup>
|
||||
<Compile Remove="Handlers\**" />
|
||||
<EmbeddedResource Remove="Handlers\**" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user