|
|
@@ -327,7 +327,7 @@ namespace PLC_S.ServerModel
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
-
|
|
|
+
|
|
|
#region 【可选】产品类型写入
|
|
|
if (!string.IsNullOrEmpty(plc_s.PLC_GOODSTYPE_CODE) && !string.IsNullOrEmpty(plc_s.PLC_GOODSTYPE_CODENUM))
|
|
|
{
|
|
|
@@ -609,6 +609,30 @@ namespace PLC_S.ServerModel
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ #region 【可选】成型工号写入
|
|
|
+ if (!string.IsNullOrEmpty(plc_s.PLC_GROUTINGUSER_CODE) && !string.IsNullOrEmpty(plc_s.PLC_GROUTINGUSER_CODENUM))
|
|
|
+ {
|
|
|
+ Int16 groutinguserCode = Convert.ToInt16(GetGroutingUserCode(barCode, e, logKeyT));
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(plc_s.PLC_IP))
|
|
|
+ {
|
|
|
+ outputMessage = $"[{e.Content}]SET_GROUTINGUSER=[{groutinguserCode}]{plc_s.PLC_GROUTINGUSER_CODE + plc_s.PLC_GROUTINGUSER_CODENUM}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ p_r = plc?.Write<short>(plc_s.PLC_GROUTINGUSER_CODE, plc_s.PLC_GROUTINGUSER_CODENUM, groutinguserCode);
|
|
|
+ outputMessage = $"[{e.Content}]END_GROUTINGUSER=[{p_r.ToString()}]{plc_s.PLC_GROUTINGUSER_CODE + plc_s.PLC_GROUTINGUSER_CODENUM}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ outputMessage = $"[{e.Content}]成型工号=[{groutinguserCode}]";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region 【可选】工序验证
|
|
|
if (!string.IsNullOrEmpty(plc_s.PROCEDURE_CHECKID))
|
|
|
{
|
|
|
@@ -847,6 +871,89 @@ namespace PLC_S.ServerModel
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ #region 【可选】(传入其他PLC数据)
|
|
|
+ if (!string.IsNullOrEmpty(plc_s.PLC_IP_NEW))
|
|
|
+ {
|
|
|
+ //创建新的PLC连接
|
|
|
+ SocketClient<SiemensS7_1200Model> plcnew = new SocketClient<SiemensS7_1200Model>();
|
|
|
+ plcnew.Connect(plc_s.PLC_IP_NEW, plc_s.PLC_PORT);
|
|
|
+ string intCode = "";
|
|
|
+ //产品型号代码
|
|
|
+ if (!string.IsNullOrEmpty(plc_s.PLC_SEATCOVER_CODE_OTHER) && !string.IsNullOrEmpty(plc_s.PLC_SEATCOVER_CODENUM_OTHER))
|
|
|
+ {
|
|
|
+ intCode = GetSeatCoverCode(barCode, e, logKeyE);
|
|
|
+ if (string.IsNullOrWhiteSpace(intCode))
|
|
|
+ {
|
|
|
+ outputMessage = $"[{e.Content}]此条码[{barCode}]未设置型号代码";
|
|
|
+ Logger.Error(null, outputMessage, logKeyT, logger_t);
|
|
|
+ Logger.Error(null, outputMessage, logKeyE, logger_e);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+
|
|
|
+ string outputMessages = $"[{e.Content}]SET_FLAG_CODE_OTHER[{2}]{plc_s.PLC_FLAG_CODE_OTHER + plc_s.PLC_FLAG_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessages, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessages);
|
|
|
+ plcnew?.Write<short>(plc_s.PLC_FLAG_CODE_OTHER, plc_s.PLC_FLAG_CODENUM_OTHER, 2);
|
|
|
+ Logger.Trace(outputMessages, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ outputMessage = $"[{e.Content}]SET_SEATCOVER_OTHER=[{intCode}]{plc_s.PLC_SEATCOVER_CODE_OTHER + plc_s.PLC_SEATCOVER_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ p_r = plcnew.Write<short>(plc_s.PLC_SEATCOVER_CODE_OTHER, plc_s.PLC_SEATCOVER_CODENUM_OTHER, (short)(intCode.ToInt32()));
|
|
|
+ p_r = plcnew.Write<short>(plc_s.PLC_SEATCOVER_CODE_OTHER, plc_s.PLC_SEATCOVER_CODENUM_OTHER, intCode.ToInt16());
|
|
|
+ outputMessage = $"[{e.Content}]END_SEATCOVER_OTHER=[{p_r.ToString()}]{plc_s.PLC_SEATCOVER_CODE_OTHER + plc_s.PLC_SEATCOVER_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ //产品型号
|
|
|
+ if (!string.IsNullOrEmpty(plc_s.PLC_GOODSCODE_CODE_OTHER) && !string.IsNullOrEmpty(plc_s.PLC_GOODSCODE_CODENUM_OTHER))
|
|
|
+ {
|
|
|
+ string goodsCode = GetGoodsCode(barCode, e, logKeyE);
|
|
|
+
|
|
|
+ outputMessage = $"[{e.Content}]SET_GOODSCODE_OTHER=[{goodsCode}]{plc_s.PLC_GOODSCODE_CODE_OTHER + plc_s.PLC_GOODSCODE_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ p_r = plcnew.Write<string>(plc_s.PLC_GOODSCODE_CODE_OTHER, plc_s.PLC_GOODSCODE_CODENUM_OTHER, goodsCode);
|
|
|
+ //再传一遍
|
|
|
+ p_r = plcnew.Write<short>(plc_s.PLC_SEATCOVER_CODE_OTHER, plc_s.PLC_SEATCOVER_CODENUM_OTHER, intCode.ToInt16());
|
|
|
+ outputMessage = $"[{e.Content}]END_GOODSCODE_OTHER=[{p_r}]{plc_s.PLC_GOODSCODE_CODE_OTHER + plc_s.PLC_GOODSCODE_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //当前条码
|
|
|
+ if (!string.IsNullOrEmpty(plc_s.PLC_BARCODE_CODE_OTHER) && !string.IsNullOrEmpty(plc_s.PLC_BARCODE_CODENUM_OTHER))
|
|
|
+ {
|
|
|
+ outputMessage = $"[{e.Content}]SET_BarCode_OTHER=[{barCode}]{plc_s.PLC_BARCODE_CODE_OTHER + plc_s.PLC_BARCODE_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ p_r = plcnew.Write<string>(plc_s.PLC_BARCODE_CODE_OTHER, plc_s.PLC_BARCODE_CODENUM_OTHER, barCode);
|
|
|
+ outputMessage = $"[{e.Content}]END_BarCode_OTHER=[{p_r}]{plc_s.PLC_BARCODE_CODE_OTHER + plc_s.PLC_BARCODE_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessage, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //扫码结果
|
|
|
+ if (!string.IsNullOrEmpty(plc_s.PLC_FLAG_CODE_OTHER) && !string.IsNullOrEmpty(plc_s.PLC_FLAG_CODENUM_OTHER))
|
|
|
+ {
|
|
|
+ string outputMessages = $"[{e.Content}]SET_FLAG_CODE_OTHER[{1}]{plc_s.PLC_FLAG_CODE_OTHER + plc_s.PLC_FLAG_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessages, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessages);
|
|
|
+ p_r = plcnew?.Write<short>(plc_s.PLC_FLAG_CODE_OTHER, plc_s.PLC_FLAG_CODENUM_OTHER, 1);
|
|
|
+ outputMessage = $"[{e.Content}]SET_FLAG_CODE_OTHER=[{p_r}]{plc_s.PLC_FLAG_CODE_OTHER + plc_s.PLC_FLAG_CODENUM_OTHER}";
|
|
|
+ Logger.Trace(outputMessages, logKeyT, logger_t);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ plcnew.Close();
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region 【可选】写入PLC扫码结果 【1:通过,2:扫码异常,3:工序异常,0:复位】
|
|
|
if (!string.IsNullOrEmpty(plc_s.PLC_FLAG_CODE) && !string.IsNullOrEmpty(plc_s.PLC_FLAG_CODENUM))
|
|
|
{
|
|
|
@@ -1268,6 +1375,38 @@ namespace PLC_S.ServerModel
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ //查询成型工号
|
|
|
+ private int GetGroutingUserCode(string barCode, ReceiveSession e, string loggerName)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (IDataAccess conn = PLC_S_DataAccess.GetDataAccess())
|
|
|
+ {
|
|
|
+ string sqlStr = @"
|
|
|
+ SELECT substr(GDD.USERCODE,2 ) USERCODE
|
|
|
+ FROM TP_PM_GROUTINGDAILYDETAIL GDD
|
|
|
+ WHERE GDD.BARCODE = :BARCODE
|
|
|
+ ";
|
|
|
+ DataTable dt = conn.ExecuteDatatable(sqlStr, new CDAParameter(":BARCODE", barCode));
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ string usercode = dt.Rows[0]["USERCODE"].ToString();
|
|
|
+ return Convert.ToInt16(usercode);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Logger.Error(ex, $"[{e.Content}]ERROR-GetDefectTypeId", loggerName, logger_e);
|
|
|
+ FormLogShow?.ShowLog($"[{e.Content}]ERROR-GetDefectTypeId={ex.Message}");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
private string GetSemiRepair(string barCode,ReceiveSession e,string loggerName)
|
|
|
{
|
|
|
@@ -1473,6 +1612,23 @@ namespace PLC_S.ServerModel
|
|
|
plc_s.WORKSTATION_ID = ini.Read(flag, "WORKSTATION_ID");
|
|
|
plc_s.WORKSTATION_NAME = ini.Read(flag, "WORKSTATION_NAME");
|
|
|
|
|
|
+ plc_s.PLC_IP_NEW = ini.Read(flag, "PLC_IP_NEW");
|
|
|
+
|
|
|
+ plc_s.PLC_SEATCOVER_CODE_OTHER = ini.Read(flag, "PLC_SEATCOVER_CODE_OTHER");
|
|
|
+ plc_s.PLC_SEATCOVER_CODENUM_OTHER = ini.Read(flag, "PLC_SEATCOVER_CODENUM_OTHER");
|
|
|
+
|
|
|
+ plc_s.PLC_GOODSCODE_CODE_OTHER = ini.Read(flag, "PLC_GOODSCODE_CODE_OTHER");
|
|
|
+ plc_s.PLC_GOODSCODE_CODENUM_OTHER = ini.Read(flag, "PLC_GOODSCODE_CODENUM_OTHER");
|
|
|
+
|
|
|
+ plc_s.PLC_BARCODE_CODE_OTHER = ini.Read(flag, "PLC_BARCODE_CODE_OTHER");
|
|
|
+ plc_s.PLC_BARCODE_CODENUM_OTHER = ini.Read(flag, "PLC_BARCODE_CODENUM_OTHER");
|
|
|
+
|
|
|
+ plc_s.PLC_FLAG_CODE_OTHER = ini.Read(flag, "PLC_FLAG_CODE_OTHER");
|
|
|
+ plc_s.PLC_FLAG_CODENUM_OTHER = ini.Read(flag, "PLC_FLAG_CODENUM_OTHER");
|
|
|
+
|
|
|
+ plc_s.PLC_GROUTINGUSER_CODE = ini.Read(flag, "PLC_GROUTINGUSER_CODE");
|
|
|
+ plc_s.PLC_GROUTINGUSER_CODENUM = ini.Read(flag, "PLC_GROUTINGUSER_CODENUM");
|
|
|
+
|
|
|
PLC_FLAGS.Add(flag, plc_s);
|
|
|
return plc_s;
|
|
|
}
|