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.

91 lines
4.1 KiB
C#

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.ProductBarcode) || station.Data.ProductBarcode.Equals("ERROR"))
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
return false;
}
ICSharpCode.Core.LoggingService.Error(station.StationCode + ",打印托盘号:"+ station.Data.RFIDNo +",条码号:"+station.Data.ProductBarcode);
//未扫描到托盘号也要下发PLC报警
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 (station.Data.Restart)
{
//if (string.IsNullOrEmpty(station.Data.ProductBarcode) || station.Data.ProductBarcode.Equals("ERROR"))
//{
// ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
// return false;
//}
return Chongtou(station);
}
//先判断后台开关是否打开在进行逻辑验证
WorkTray tray = new WorkTray();
//这里校验是否与计划匹配,先预留,后期加==========
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return true;
}
public bool HandleData(StationInfo station)
{
try
{
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.ProductBarcode, 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;
}
}
}