|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using SlnMesnac.Business.@base;
|
|
|
|
|
using SlnMesnac.Common;
|
|
|
|
|
using SlnMesnac.Config;
|
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
|
using SlnMesnac.Model.dto;
|
|
|
|
|
using SlnMesnac.Model.enums;
|
|
|
|
|
using SlnMesnac.Plc;
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
using SlnMesnac.Rfid;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using TouchSocket.Core;
|
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
|
|
|
|
|
|
#region << <20><> <20><> ע <20><> >>
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
|
* <EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> (c) 2024 WenJY <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* CLR<EFBFBD>汾<EFBFBD><EFBFBD>4.0.30319.42000
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>LAPTOP-E0N2L34V
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ䣺SlnMesnac.Business
|
|
|
|
|
* Ψһ<EFBFBD><EFBFBD>ʶ<EFBFBD><EFBFBD>f79d6d97-d9b0-4b0b-a442-e6bb1c1c79e6
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>WenJY
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䣺wenjy@mesnac.com
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣺2024-04-10 16:36:01
|
|
|
|
|
* <EFBFBD>汾<EFBFBD><EFBFBD>V1.0.0
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
*--------------------------------------------------------------------
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>
|
|
|
|
|
* ʱ<EFBFBD>䣺
|
|
|
|
|
* <EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD>汾<EFBFBD><EFBFBD>V1.0.0
|
|
|
|
|
*--------------------------------------------------------------------*/
|
|
|
|
|
#endregion << <20><> <20><> ע <20><> >>
|
|
|
|
|
namespace SlnMesnac.Business
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ProdCompletionBusiness : BaseBusiness
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private readonly IMesProductPlanService _mesProductPlanService;
|
|
|
|
|
private readonly IMesProductOrderService _mesProductOrderService;
|
|
|
|
|
private readonly IMesPrdBarCodeService _barCodeTaskService;
|
|
|
|
|
private readonly IBaseMaterialInfoService _baseMaterialInfoService;
|
|
|
|
|
private readonly IMesBaseBarcodeInfoService _mesBaseBarcodeInfoService;
|
|
|
|
|
public readonly IMesPrdBarCodeService _mesPrdBarCodeService;
|
|
|
|
|
private readonly IRealPalletTaskService _realPalletTaskService;
|
|
|
|
|
|
|
|
|
|
private ISqlSugarClient sqlSugarClient;
|
|
|
|
|
|
|
|
|
|
public ProdCompletionBusiness(ISqlSugarClient _sqlSugarClient, ILogger<BaseBusiness> logger, AppConfig appConfig, List<PlcAbsractFactory> plcFactories, List<RfidAbsractFactory> rfidFactories, IMesProductPlanService mesProductPlanService, IMesPrdBarCodeService barCodeTaskService, IServiceProvider serviceProvider) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient = _sqlSugarClient;
|
|
|
|
|
_mesProductPlanService = mesProductPlanService;
|
|
|
|
|
_barCodeTaskService = barCodeTaskService;
|
|
|
|
|
_realPalletTaskService = serviceProvider.GetRequiredService<IRealPalletTaskService>();
|
|
|
|
|
_mesBaseBarcodeInfoService = serviceProvider.GetRequiredService<IMesBaseBarcodeInfoService>();
|
|
|
|
|
_mesPrdBarCodeService = serviceProvider.GetRequiredService<IMesPrdBarCodeService>();
|
|
|
|
|
_mesProductOrderService = serviceProvider.GetRequiredService<IMesProductOrderService>();
|
|
|
|
|
_baseMaterialInfoService = serviceProvider.GetRequiredService<IBaseMaterialInfoService>();
|
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void test()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string epc = "A123456";
|
|
|
|
|
_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
|
|
|
|
|
string bigCode = GenerateBigBarcode(productPlanDto, epc);
|
|
|
|
|
// BindingBarCode(bigCode, epc);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static bool isEmptyPalletHandleRunning = false;
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
await EmptyPalletHandle();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
DeviceOutPutHandle();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void DeviceOutPutHandle()
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȡRFIDʧ<44><CAA7><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>
|
|
|
|
|
int readRfidAmount = 0;
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var plc = base.GetPlcByKey("plc");
|
|
|
|
|
|
|
|
|
|
if (plc == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("<22><>ȡС<C8A1><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>,PLC<4C><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢΪ<CFA2><CEAA>......");
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// plc.writeStringByAddress(GetPlcAddressByConfigKey("2¥<32><C2A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RFID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ"), "JYHB01010125", 12);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2¥С<C2A5><D0A1><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>λ<EFBFBD>ź<EFBFBD>")))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("<22>ȴ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źŴ<C5BA><C5B4><EFBFBD>......");
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string rfid = plc.readStringByAddress(GetPlcAddressByConfigKey("2¥<32><C2A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RFID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ"),12).Replace("\0","");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(rfid))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD>RFID<49>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>");
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorOut");
|
|
|
|
|
if (string.IsNullOrEmpty(epcStr))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("С<><D0A1><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>λ<EFBFBD>źŴ<C5BA><C5B4><EFBFBD>,<2C><>ȡRFIDʧ<44><CAA7>......");
|
|
|
|
|
//<2F>ж<EFBFBD>ǰһλ<D2BB><CEBB><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD><CCBB><EFBFBD>
|
|
|
|
|
RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault();
|
|
|
|
|
if (realPalletTask != null)
|
|
|
|
|
{
|
|
|
|
|
epcStr = realPalletTask.PalletCode;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
readRfidAmount++;
|
|
|
|
|
if (readRfidAmount == 5)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string virtualEpc = NoReadRFIDAlarm();
|
|
|
|
|
_logger.LogError("С<><D0A1><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>λ<EFBFBD>źŴ<C5BA><C5B4><EFBFBD>,<2C><>ȡRFIDʧ<44>ܳ<EFBFBD><DCB3><EFBFBD>5<EFBFBD><35>......");
|
|
|
|
|
if (!string.IsNullOrEmpty(virtualEpc))
|
|
|
|
|
{
|
|
|
|
|
epcStr = virtualEpc;
|
|
|
|
|
_logger.LogError("С<><D0A1><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>λ<EFBFBD>źŴ<C5BA><C5B4><EFBFBD>,<2C><>ȡRFIDʧ<44>ܳ<EFBFBD><DCB3><EFBFBD>5<EFBFBD><35>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>:" + virtualEpc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000 * 5);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RefreshMessage($"С<><D0A1><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><C8A1>RFID<49><44><EFBFBD><EFBFBD>{epcStr},<2C><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
|
|
|
|
|
_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
|
|
|
|
|
if (productPlanDto == null)
|
|
|
|
|
{
|
|
|
|
|
//TODO:û<>мƻ<D0BC><C6BB>Ļ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
|
|
|
|
throw new ArgumentException($"δ<><CEB4>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
|
//1.<2E><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mes_barcode_info<66><6F>
|
|
|
|
|
string bigCode = GenerateBigBarcode(productPlanDto, epcStr);
|
|
|
|
|
//2.40<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD>뼰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺ţ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>̰<CCB0><F3B6A8B4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
BindingBarCode(bigCode, epcStr, productPlanDto);
|
|
|
|
|
//3.<2E><><EFBFBD><EFBFBD>mes_product_plan<61><6E>mes_product_order<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UpdatePlanInfoAndOrder(productPlanDto);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>̺<EFBFBD>
|
|
|
|
|
List<RealPalletTask> realPalletList = _realPalletTaskService.Query(x => x.PalletCode == epcStr);
|
|
|
|
|
if (realPalletList != null && realPalletList.Count>0)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPalletList).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
// д<><D0B4>PLC RFID<49>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
|
|
|
|
plc.writeStringByAddress(GetPlcAddressByConfigKey("2¥<32><C2A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RFID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ"), epcStr,12);
|
|
|
|
|
// plc.writeByteByAddress(GetPlcAddressByConfigKey("2¥С<C2A5><D0A1><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>λ<EFBFBD>ź<EFBFBD>"), 2);
|
|
|
|
|
readRfidAmount = 0;
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
|
|
|
|
|
|
_logger.LogError($"DeviceOutPutHandle<6C>쳣:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(1000 * 5);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD><CCBA><EFBFBD>ʱʹ<CAB1>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺Ŵ<CCBA><C5B4>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD><CCBA>滻Ϊ<E6BBBB><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>
|
|
|
|
|
/// <return> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string NoReadRFIDAlarm()
|
|
|
|
|
{
|
|
|
|
|
string epcStr;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
epcStr = "TEMP" + DateTime.Now.ToString("MMddHHmm");
|
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
|
|
|
|
|
|
// <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>豸<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>߱<EFBFBD><DFB1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|
|
|
|
int warnRuleId = int.Parse(WarnStatusEnum.С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡRFIDʧ<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>.GetDescription());
|
|
|
|
|
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
|
if (dmsRecordAlarmTime == null)
|
|
|
|
|
{
|
|
|
|
|
DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsBaseAlarmRule>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
|
|
|
|
|
|
dmsRecordAlarmTime = new DmsRecordAlarmTime();
|
|
|
|
|
dmsRecordAlarmTime.DeviceId = dmsBaseAlarmRule.DeviceId;
|
|
|
|
|
dmsRecordAlarmTime.AlarmRuleId = warnRuleId;
|
|
|
|
|
dmsRecordAlarmTime.AlarmBeginTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡRFIDʧ<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>.ToString();
|
|
|
|
|
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>Ϊ:" + epcStr;
|
|
|
|
|
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
|
|
|
|
|
dmsRecordAlarmTime.CreateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
DmsRecordAlarmInfo dmsRecordAlarmInfo = new DmsRecordAlarmInfo();
|
|
|
|
|
dmsRecordAlarmInfo.DeviceId = dmsBaseAlarmRule.DeviceId;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmRuleId = warnRuleId;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmBeginTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmStatus = "0";
|
|
|
|
|
dmsRecordAlarmInfo.NoticeStatus = "0";
|
|
|
|
|
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡRFIDʧ<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>.ToString();
|
|
|
|
|
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>Ϊ:" + epcStr;
|
|
|
|
|
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
|
|
|
|
|
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
|
|
|
|
|
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
|
if (dmsRecordAlarmInfo != null)
|
|
|
|
|
{
|
|
|
|
|
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmInfo.UpdateBy = "SlnMesnac";
|
|
|
|
|
}
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
|
return epcStr;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
|
_logger.LogError($"NoReadRFIDAlarm<72>쳣:{ex.Message}");
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mes_barcode_info<66><6F>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="productPlanDto"></param>
|
|
|
|
|
/// <param name="epcStr"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string GenerateBigBarcode(MesProductPlanDto productPlanDto, string epcStr)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string bigBarcode = productPlanDto.PlanCode + DateTime.Now.ToString("_MMddHHmmss");
|
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = new MesBaseBarcodeInfo();
|
|
|
|
|
mesBaseBarcodeInfo.printTime = DateTime.Now;
|
|
|
|
|
mesBaseBarcodeInfo.printPerson = "SlnMesnac";
|
|
|
|
|
mesBaseBarcodeInfo.printFlag = "1";
|
|
|
|
|
mesBaseBarcodeInfo.batchFlag = "0";
|
|
|
|
|
mesBaseBarcodeInfo.barcodeType = "3";
|
|
|
|
|
mesBaseBarcodeInfo.barcodeInfo = bigBarcode;
|
|
|
|
|
mesBaseBarcodeInfo.batchCode = bigBarcode;
|
|
|
|
|
mesBaseBarcodeInfo.palletInfoCode = epcStr;
|
|
|
|
|
mesBaseBarcodeInfo.materialId = productPlanDto.MaterialId;
|
|
|
|
|
mesBaseBarcodeInfo.amount = 1;
|
|
|
|
|
mesBaseBarcodeInfo.printNumber = 1;
|
|
|
|
|
mesBaseBarcodeInfo.productionDate = DateTime.Now;
|
|
|
|
|
mesBaseBarcodeInfo.acceptedDate = DateTime.Now;
|
|
|
|
|
mesBaseBarcodeInfo.planCode = productPlanDto.PlanCode;
|
|
|
|
|
mesBaseBarcodeInfo.safeFlag = productPlanDto.SaleOrderId == 0 ? "1" : "0";
|
|
|
|
|
mesBaseBarcodeInfo.saleOrderId = productPlanDto.SaleOrderId;
|
|
|
|
|
mesBaseBarcodeInfo.saleorderCode = productPlanDto.SaleorderCode;
|
|
|
|
|
mesBaseBarcodeInfo.bindStatus = "1";
|
|
|
|
|
mesBaseBarcodeInfo.bindTime = DateTime.Now;
|
|
|
|
|
mesBaseBarcodeInfo.updateBy = "SlnMesnac";
|
|
|
|
|
mesBaseBarcodeInfo.updateTime = DateTime.Now;
|
|
|
|
|
mesBaseBarcodeInfo.completeFlag = "1";
|
|
|
|
|
mesBaseBarcodeInfo.singleFlag = "0";
|
|
|
|
|
var materialInfo = _baseMaterialInfoService.Query(x => x.MaterialId == productPlanDto.MaterialId).FirstOrDefault();
|
|
|
|
|
if (materialInfo != null)
|
|
|
|
|
{
|
|
|
|
|
mesBaseBarcodeInfo.barcodeSpec = materialInfo.MaterialSpec;
|
|
|
|
|
}
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(mesBaseBarcodeInfo).ExecuteCommand();
|
|
|
|
|
return bigBarcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 40<34><30>С<EFBFBD><D0A1><EFBFBD>뼰<EFBFBD><EBBCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺ţ<CCBA>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3B6A8B4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bigBarcode"></param>
|
|
|
|
|
/// <param name="epcStr"></param>
|
|
|
|
|
private void BindingBarCode(string bigBarcode, string epcStr, MesProductPlanDto productPlanDto)
|
|
|
|
|
{
|
|
|
|
|
List<MesPrdBarcodeInfo> list = _mesPrdBarCodeService.GetUseBarCodeList();
|
|
|
|
|
if (list == null || list.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("<22><><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><D4B0>С<EFBFBD><D0A1><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (list.Where(x => x.PrintFlag == "1").ToList().Count < 40)
|
|
|
|
|
{
|
|
|
|
|
// TODO<44><4F><EFBFBD>͵ͼ<CDB5><CDBC>𱨾<EFBFBD>
|
|
|
|
|
PrintLessThan40Alarm();
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
item.PalletInfoCode = epcStr;
|
|
|
|
|
item.MesBarcodeInfo = bigBarcode;
|
|
|
|
|
item.BindTime = DateTime.Now;
|
|
|
|
|
item.BindStatus = 1;
|
|
|
|
|
}
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(list).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>̰<CCB0><F3B6A8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
BasePalletInfo palletInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<BasePalletInfo>().Where(x => x.PalletInfoCode == epcStr).First();
|
|
|
|
|
if (palletInfo != null)
|
|
|
|
|
{
|
|
|
|
|
palletInfo.MaterialBarcode = bigBarcode;
|
|
|
|
|
palletInfo.MaterialId = productPlanDto.MaterialId;
|
|
|
|
|
}
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(palletInfo).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdatePlanInfoAndOrder(MesProductPlanDto productPlanDto)
|
|
|
|
|
{
|
|
|
|
|
MesProductPlan productPlan = _mesProductPlanService.Query(x => x.PlanCode == productPlanDto.PlanCode).FirstOrDefault();
|
|
|
|
|
if (productPlan == null)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("δ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>!");
|
|
|
|
|
}
|
|
|
|
|
MesProductOrder productOrder = _mesProductOrderService.Query(x => x.ProductOrderId == productPlan.ProductOrderId).FirstOrDefault();
|
|
|
|
|
if (productPlan == null)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("δ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
|
|
|
|
}
|
|
|
|
|
#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>
|
|
|
|
|
if (productPlan.CompleteAmount == 0)
|
|
|
|
|
{
|
|
|
|
|
productPlan.RealBeginTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
productPlan.CompleteAmount++;
|
|
|
|
|
if (productPlan.CompleteAmount == productPlan.PlanAmount)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
productPlan.RealEndTime = DateTime.Now;
|
|
|
|
|
productPlan.PlanStatus = Model.enums.PlanStatusEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
}
|
|
|
|
|
productPlan.UpdateTime = DateTime.Now;
|
|
|
|
|
productPlan.UpdateBy = "SlnMesnac";
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(productPlan).ExecuteCommand();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
if (productOrder.CompleteAmount == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
productOrder.RealBeginTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
productOrder.CompleteAmount++;
|
|
|
|
|
if (productOrder.CompleteAmount == productOrder.PlanAmount)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
productOrder.RealEndTime = DateTime.Now;
|
|
|
|
|
productOrder.OrderStatus = "2";
|
|
|
|
|
}
|
|
|
|
|
productOrder.UpdateTime = DateTime.Now;
|
|
|
|
|
productOrder.UpdateBy = "SlnMesnac";
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(productOrder).ExecuteCommand();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>40<34>ͼ<EFBFBD><CDBC>𱨾<EFBFBD>
|
|
|
|
|
/// <return> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void PrintLessThan40Alarm()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
|
|
|
|
|
|
// <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>豸<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>߱<EFBFBD><DFB1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|
|
|
|
int warnRuleId = int.Parse(WarnStatusEnum.<EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>40.GetDescription());
|
|
|
|
|
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
|
if (dmsRecordAlarmTime == null)
|
|
|
|
|
{
|
|
|
|
|
DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsBaseAlarmRule>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
|
|
|
|
|
|
dmsRecordAlarmTime = new DmsRecordAlarmTime();
|
|
|
|
|
dmsRecordAlarmTime.DeviceId = dmsBaseAlarmRule.DeviceId;
|
|
|
|
|
dmsRecordAlarmTime.AlarmRuleId = warnRuleId;
|
|
|
|
|
dmsRecordAlarmTime.AlarmBeginTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.<EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>40.ToString();
|
|
|
|
|
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
|
|
|
|
|
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
|
|
|
|
|
dmsRecordAlarmTime.CreateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
DmsRecordAlarmInfo dmsRecordAlarmInfo = new DmsRecordAlarmInfo();
|
|
|
|
|
dmsRecordAlarmInfo.DeviceId = dmsBaseAlarmRule.DeviceId;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmRuleId = warnRuleId;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmBeginTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmStatus = "0";
|
|
|
|
|
dmsRecordAlarmInfo.NoticeStatus = "0";
|
|
|
|
|
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
|
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.<EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>40.ToString();
|
|
|
|
|
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
|
|
|
|
|
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
|
|
|
|
|
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
|
|
|
|
|
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
|
if (dmsRecordAlarmInfo != null)
|
|
|
|
|
{
|
|
|
|
|
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
|
|
|
|
|
dmsRecordAlarmInfo.UpdateBy = "SlnMesnac";
|
|
|
|
|
}
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
|
_logger.LogError($"PrintLessThan40Alarm<72>쳣:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ,<2C><>ȡRFID<49><44><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async Task EmptyPalletHandle()
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡPLC<4C><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ź<EFBFBD>
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var plc = base.GetPlcByKey("plc");
|
|
|
|
|
if (plc == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("<22><>ȡPLC<4C><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<E2B5BD>ź<EFBFBD>,PLC<4C><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢΪ<CFA2><CEAA>......");
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2¥<32><C2A5><EFBFBD>λ<E2B5BD>ź<EFBFBD>")))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("<22>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>λ<EFBFBD>źŴ<C5BA><C5B4><EFBFBD>......");
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault();
|
|
|
|
|
if (realPalletTask != null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>λ<EFBFBD>źŴ<C5BA><C5B4><EFBFBD>,<2C>Ѿ<EFBFBD><D1BE>ж<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD>ٶ<EFBFBD>ȡ......");
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><>ȡRFID<49><44><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ִ<EFBFBD>еļƻ<C4BC><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD><CCB0><EFBFBD>
|
|
|
|
|
RefreshMessage("<22><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>λ<EFBFBD>źŴ<C5BA><C5B4><EFBFBD><EFBFBD>ɹ<EFBFBD>,<2C><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>RFID<49><44>Ϣ");
|
|
|
|
|
|
|
|
|
|
string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorPallet");
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(epcStr))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("<22><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>λ<EFBFBD>źŴ<C5BA><C5B4><EFBFBD>,<2C><>ȡRFIDʧ<44><CAA7>......");
|
|
|
|
|
Thread.Sleep(1000 * 10);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefreshMessage($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RFID<49><44>Ϣ<EFBFBD><CFA2>ȡ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>ǩ<EFBFBD><C7A9>Ϣ<EFBFBD><CFA2>{epcStr}");
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>¼
|
|
|
|
|
realPalletTask = new RealPalletTask()
|
|
|
|
|
{
|
|
|
|
|
PalletCode = epcStr,
|
|
|
|
|
RecordTime = DateTime.Now,
|
|
|
|
|
};
|
|
|
|
|
_realPalletTaskService.Insert(realPalletTask);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
RefreshMessage($"<22><><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3>{e.Message}");
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000 * 10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="barCode"></param>
|
|
|
|
|
/// <param name="result"></param>
|
|
|
|
|
/// <exception cref="InvalidOperationException"></exception>
|
|
|
|
|
private void ExtractNumber(string barCode, out int result)
|
|
|
|
|
{
|
|
|
|
|
string pattern = @"\b0*(\d{1,6})\b$";
|
|
|
|
|
|
|
|
|
|
Match match = Regex.Match(barCode, pattern);
|
|
|
|
|
if (match.Success)
|
|
|
|
|
{
|
|
|
|
|
result = Convert.ToInt32(match.Groups[1].Value) + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException($"ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:{barCode}<7D><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>쳣:δ<>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|