diff --git a/SlnMesnac.Business/ProdCompletionBusiness.cs b/SlnMesnac.Business/ProdCompletionBusiness.cs
index 42daeb9..21d915a 100644
--- a/SlnMesnac.Business/ProdCompletionBusiness.cs
+++ b/SlnMesnac.Business/ProdCompletionBusiness.cs
@@ -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","");
+
+ string rfid = plc.readStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"),12).Replace("\0","");
+
if (!string.IsNullOrWhiteSpace(rfid))
{
_logger.LogInformation("小包出口已经有RFID了,无需再读");
@@ -181,10 +185,11 @@ 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();
@@ -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
///
///
///
- private void BindingBarCode(string bigBarcode, string epcStr)
+ private void BindingBarCode(string bigBarcode, string epcStr, MesProductPlanDto productPlanDto)
{
List 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().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)
diff --git a/SlnMesnac.Plc/Factory/InovanceFactory.cs b/SlnMesnac.Plc/Factory/InovanceFactory.cs
index 9fed6d0..7dc52d2 100644
--- a/SlnMesnac.Plc/Factory/InovanceFactory.cs
+++ b/SlnMesnac.Plc/Factory/InovanceFactory.cs
@@ -362,5 +362,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
+
+ public override bool writeStringByAddress(string address, string value, int length)
+ {
+ throw new NotImplementedException();
+ }
}
}
\ No newline at end of file
diff --git a/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs b/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs
index 8062672..f6f86e7 100644
--- a/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs
+++ b/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs
@@ -303,5 +303,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
+
+ public override bool writeStringByAddress(string address, string value, int length)
+ {
+ throw new NotImplementedException();
+ }
}
}
\ No newline at end of file
diff --git a/SlnMesnac.Plc/Factory/OmronNJFactory.cs b/SlnMesnac.Plc/Factory/OmronNJFactory.cs
index c70c581..1223b06 100644
--- a/SlnMesnac.Plc/Factory/OmronNJFactory.cs
+++ b/SlnMesnac.Plc/Factory/OmronNJFactory.cs
@@ -306,5 +306,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
+
+ public override bool writeStringByAddress(string address, string value, int length)
+ {
+ throw new NotImplementedException();
+ }
}
}
\ No newline at end of file
diff --git a/SlnMesnac.Plc/Factory/SiemensFactory.cs b/SlnMesnac.Plc/Factory/SiemensFactory.cs
index febdd40..1641769 100644
--- a/SlnMesnac.Plc/Factory/SiemensFactory.cs
+++ b/SlnMesnac.Plc/Factory/SiemensFactory.cs
@@ -213,6 +213,34 @@ namespace SlnMesnac.Plc.Factory
}
}
+
+ ///
+ /// 閫氳繃PLC鍦板潃鍐欏叆String绫诲瀷鏁版嵁
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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}");
+ }
+ }
+
+
+
+
///
/// 閫氳繃PLC鍦板潃璇诲彇Bool绫诲瀷鏁版嵁
///
diff --git a/SlnMesnac.Plc/PlcAbsractFactory.cs b/SlnMesnac.Plc/PlcAbsractFactory.cs
index 16101c2..65925ce 100644
--- a/SlnMesnac.Plc/PlcAbsractFactory.cs
+++ b/SlnMesnac.Plc/PlcAbsractFactory.cs
@@ -84,6 +84,16 @@ namespace SlnMesnac.Plc
///
public abstract bool writeStringByAddress(string address, string value);
+
+ ///
+ /// 閫氳繃PLC鍦板潃鍐欏叆String绫诲瀷鏁版嵁
+ ///
+ ///
+ ///
+ ///
+ public abstract bool writeStringByAddress(string address, string value, int length);
+
+
///
/// 閫氳繃PLC鍦板潃璇诲彇Bool绫诲瀷鏁版嵁
///