You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
8.0 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Mesnac.Compressor.Data;
using Mesnac.Compressor.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mesnac.Compressor.Station
{
public class FirstStation : Common, IStation
{
/// <summary>
/// 只判断是否与计划相同
/// </summary>
/// <param name="station"></param>
/// <returns></returns>
public bool PrepareWork(StationInfo station)
{
//主线产品码未扫描到条码下发PLC报警
//if (string.IsNullOrEmpty(station.Data.subLineList[3].barcode) || station.Data.subLineList[3].barcode.Equals("ERROR"))
//{
// ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
// return false;
//}
//if (string.IsNullOrEmpty(station.Data.subLineList[4].barcode) || station.Data.subLineList[4].barcode.Equals("ERROR"))
//{
// ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
// return false;
//}
ICSharpCode.Core.LoggingService.Debug(station.StationCode + ",打印托盘号:"+ station.Data.RFIDNo);
//未扫描到托盘号也要下发PLC报警
if (string.IsNullOrEmpty(station.Data.RFIDNo) || station.Data.RFIDNo.Equals("A00"))
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的托盘号");
//this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NORFID);
//return false;
}
//先判断后台开关是否打开在进行逻辑验证
//这里校验是否与计划匹配,先预留,后期加==========
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return true;
}
public bool HandleData(StationInfo station)
{
try
{
//动静盘上线放行请求判断是否有码和是否NG
if (station.stationID == "1" || station.stationID == "2")
{
if (string.IsNullOrEmpty(station.Data.RFIDNo) || station.Data.RFIDNo.Equals("A00"))
{
//ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的托盘号");
//this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
return false;
}
if (string.IsNullOrEmpty(station.Data.subLineList[3].barcode) || station.Data.subLineList[3].barcode.Equals("ERROR") || station.Data.subLineList[3].barcode.Length != 20)
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
return false;
}
if (string.IsNullOrEmpty(station.Data.subLineList[4].barcode) || station.Data.subLineList[4].barcode.Equals("ERROR") || station.Data.subLineList[4].barcode.Length != 20)
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
return false;
}
else
{
station.Data.ProductBarcode = station.Data.subLineList[3].barcode;
}
}
//重投逻辑防呆,防止重投开关关闭时不走这里
//判断是否为重投
//动静盘重投
//根据静盘码查询是否重投
string JPData = GetReStartInfo("SemiBarcode", station.Data.subLineList[3].barcode, station.TableName, "ScanBarcode");
if (!string.IsNullOrEmpty(JPData))
{
//string MBarcode = GetReStartInfo("Barcode", station.Data.subLineList[3].barcode, station.TableName, "ScanBarcode");
//重投
ICSharpCode.Core.LoggingService.DebugFormatted("重投产品码:{0},A码:{1}" , station.Data.subLineList[3].barcode, JPData);
//根据A码更新T_SY_TraceState表更新T_RP_WorkTrayRealTimeInfo表
UpdateTrayChongtou(station.Data.RFIDNo, JPData);
//清空关系表
//UpdateTrayChongtou(station.Data.RFIDNo, station.Data.semibacode);
FinishSavePLCWork(station);
//this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
return false;
}
#region 动静盘在主线上,重投时需要带条码发请求放行,根据动静盘将壳体码查出
//动静盘在主线上,重投时需要带条码发请求放行,根据动静盘将壳体码查出
//string Sem = getSemiBarcodeAByDongPanCode(station.Data.subLineList[3].barcode);
//if (!string.IsNullOrEmpty(Sem))
//{
// string ISDis = getChongTouState("", Sem);
// if (ISDis == "1")
// {
// //动静盘重投20、30工位直接跳过从40开始
// station.Data.semibacode = Sem;
// ICSharpCode.Core.LoggingService.Debug("重投产品码:" + station.Data.ProductBarcode + ",A码:" + station.Data.semibacode);
// //UpdateTrayChongtou(station.Data.RFIDNo, station.Data.semibacode);
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
// return false;
// }
//}
#endregion
station.Data.semibacode = CreatNewSemibarcode(station.barcodeHead, station.lineID);
ICSharpCode.Core.LoggingService.Debug("Head:" + station.barcodeHead + "支线ID:" + station.lineID + "生成支线条码:" + station.Data.semibacode +"物料条码:"+ station.Data.ProductBarcode);
string mainBarcode = "";
if (station.IfMainline)
{
//ICSharpCode.Core.LoggingService.Debug("主线");
//创建新的产品
mainBarcode = CreatNewProduct(station);
DbHandler db = new DbHandler();
//查询当前的机种型号,不是机种要具体到型号
string machineID = db.GetNowProductionInfo();
db.InsertTrace(mainBarcode, station.Data.semibacode, machineID);
//动静盘条码
//InsertBarcodeRelationShip(station.Data.semibacode, station.Data.subLineList[2].barcode, station.Data.semibacode,1);
//InsertBarcodeRelationShip(station.Data.semibacode, station.Data.subLineList[4].barcode, station.Data.semibacode, 1);
}
base.UpdateTray(station.Data.RFIDNo, mainBarcode, station.Data.semibacode, station.stationID, station.Data.ProductOkNg);
ICSharpCode.Core.LoggingService.Debug("更新托盘信息:" + station.Data.RFIDNo + "+" + mainBarcode + "+" + station.Data.semibacode);
//保存数据
base.SaveStationData(station, StationType.FirstStation);
FinishSavePLCWork(station);
}
catch(Exception e)
{
ICSharpCode.Core.LoggingService.Error(e.ToString());
return false;
}
//finally
//{
// //这里要加一个OK放行
// FinishSavePLCWork(station);
//}
return true;
}
}
}