change-2F小包出口调试完成版本

dev
liuwf 3 months ago
parent 64a04dce5f
commit 187f509f7e

@ -81,7 +81,7 @@ namespace SlnMesnac.Business
string epc = "A123456";
_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
string bigCode = GenerateBigBarcode(productPlanDto, epc);
BindingBarCode(bigCode, epc);
// BindingBarCode(bigCode, epc);
}
@ -121,14 +121,18 @@ namespace SlnMesnac.Business
Thread.Sleep(3000);
continue;
}
// plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), "JYHB01010125", 12);
if (plc.readByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号")) != 1)
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号")))
{
_logger.LogInformation("等待小包出口信号触发......");
Thread.Sleep(5000);
continue;
}
string rfid = plc.readStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"),12).Replace("\0","");
if (!string.IsNullOrWhiteSpace(rfid))
{
_logger.LogInformation("小包出口已经有RFID了无需再读");
@ -181,11 +185,12 @@ namespace SlnMesnac.Business
sqlSugarClient.AsTenant().BeginTran();
//1.生成大条码插入mes_barcode_info
string bigCode = GenerateBigBarcode(productPlanDto, epcStr);
//2.40个小条码及大条码绑定托盘号,小条码绑定大条码
BindingBarCode(bigCode, epcStr);
//2.40个小条码及大条码绑定托盘号,小条码绑定大条码,,托盘绑定大条码
BindingBarCode(bigCode, epcStr, productPlanDto);
//3.更新mes_product_plan及mes_product_order表更新已生产数量
UpdatePlanInfoAndOrder(productPlanDto);
// 删除正在使用的数据库托盘号
RealPalletTask realPallet = _realPalletTaskService.Query(x => x.PalletCode == epcStr).FirstOrDefault();
if (realPallet != null)
@ -193,7 +198,7 @@ namespace SlnMesnac.Business
sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPallet).ExecuteCommand();
}
// 写入PLC RFID号供调度使用
plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr);
plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr,12);
// plc.writeByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号"), 2);
readRfidAmount = 0;
sqlSugarClient.AsTenant().CommitTran();
@ -334,7 +339,7 @@ namespace SlnMesnac.Business
/// </summary>
/// <param name="bigBarcode"></param>
/// <param name="epcStr"></param>
private void BindingBarCode(string bigBarcode, string epcStr)
private void BindingBarCode(string bigBarcode, string epcStr, MesProductPlanDto productPlanDto)
{
List<MesPrdBarcodeInfo> list = _mesPrdBarCodeService.GetUseBarCodeList();
if (list == null || list.Count == 0)
@ -355,6 +360,16 @@ namespace SlnMesnac.Business
item.BindStatus = 1;
}
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(list).ExecuteCommand();
//托盘绑定大条码信息
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)

@ -362,5 +362,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
public override bool writeStringByAddress(string address, string value, int length)
{
throw new NotImplementedException();
}
}
}

@ -303,5 +303,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
public override bool writeStringByAddress(string address, string value, int length)
{
throw new NotImplementedException();
}
}
}

@ -306,5 +306,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
public override bool writeStringByAddress(string address, string value, int length)
{
throw new NotImplementedException();
}
}
}

@ -213,6 +213,34 @@ namespace SlnMesnac.Plc.Factory
}
}
/// <summary>
/// 通过PLC地址写入String类型数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public override bool writeStringByAddress(string address, string value,int length)
{
try
{
OperateResult operateResult = s7.Write(address, value, length);
if (!operateResult.IsSuccess)
{
throw new InvalidOperationException($"根据地址:{address};写入string数据失败{operateResult.Message}");
}
return operateResult.IsSuccess;
}
catch (Exception ex)
{
throw new InvalidOperationException($"根据地址:{address};写入string数据异常{ex.Message}");
}
}
/// <summary>
/// 通过PLC地址读取Bool类型数据
/// </summary>

@ -84,6 +84,16 @@ namespace SlnMesnac.Plc
/// <returns></returns>
public abstract bool writeStringByAddress(string address, string value);
/// <summary>
/// 通过PLC地址写入String类型数据
/// </summary>
/// <param name="address"></param>
/// <param name="SFC"></param>
/// <returns></returns>
public abstract bool writeStringByAddress(string address, string value, int length);
/// <summary>
/// 通过PLC地址读取Bool类型数据
/// </summary>

Loading…
Cancel
Save