|
|
|
|
|
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 ScanBarCodeStation : NormarlStation, IStation
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 扫码工位
|
|
|
/// </summary>
|
|
|
/// <param name="station"></param>
|
|
|
/// <returns></returns>
|
|
|
public new bool PrepareWork(StationInfo station)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//通过壳体码查询主线工位是否OK,有NG则提示NG物料拿取
|
|
|
string KT_BarCode = station.Data.ProductBarcode;
|
|
|
ICSharpCode.Core.LoggingService.Debug("读取到产品条码:" + KT_BarCode);
|
|
|
|
|
|
if (KT_BarCode != "" || KT_BarCode != null)
|
|
|
{
|
|
|
if (KT_BarCode.Equals("ERROR"))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "PLC未上传壳体条码");
|
|
|
//暂时先给放行
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
|
|
|
return false;
|
|
|
}
|
|
|
bool iflag = IsOpen(station.stationID);
|
|
|
if (iflag)
|
|
|
{
|
|
|
bool selectAllStation = IsSelectAllStationData(station.stationID);
|
|
|
//判断是否查询全部工位合格信息
|
|
|
if (selectAllStation)
|
|
|
{
|
|
|
//先查询所有工位开关是否打开,未打开工位不进行验证是否合格
|
|
|
//通过壳体码查询主线A码
|
|
|
string SemBarCode = GetSemiBarcodeByProductBarCode(KT_BarCode);
|
|
|
//通过主线码查询所有工位质量
|
|
|
bool isNG = GetStationNGBySemiBarCode(SemBarCode);
|
|
|
//下发NG物料拿取
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//查询当前产品M码,机种,班组(01,02,03)
|
|
|
TSyTracestate syTracestate = GetTraceStateInfoByProductBarCode(KT_BarCode);
|
|
|
if (syTracestate.Barcode != null || syTracestate.Barcode != "")
|
|
|
{
|
|
|
string MainBarCode = syTracestate.Barcode;
|
|
|
//查询当前机种
|
|
|
string ProductID = syTracestate.ProductName;
|
|
|
//查询当前班组
|
|
|
string ShiftID = syTracestate.ShiftID;
|
|
|
ICSharpCode.Core.LoggingService.Debug("产品信息:" + MainBarCode +","+ ProductID +","+ ShiftID);
|
|
|
//自动打印铭牌
|
|
|
|
|
|
//PrintManager pm = new PrintManager();
|
|
|
//pm.Print(KT_BarCode, int.Parse(syTracestate.ProductID), syTracestate.ShiftID);
|
|
|
//这里插入打印记录
|
|
|
InsertScanBarCodePrintRecord(syTracestate);
|
|
|
|
|
|
//下发放行
|
|
|
FinishSavePLCWork(station);
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "壳体条码未绑定关系,自动生成流水号");
|
|
|
//首工位没绑定,自动生成流水号
|
|
|
//创建新的产品
|
|
|
//插入trace表
|
|
|
string ABarCode = CreatNewSemibarcode("A", "1");
|
|
|
//创建新的产品
|
|
|
string mainBarcode = CreatNewProduct(station);
|
|
|
syTracestate.Barcode = mainBarcode;
|
|
|
syTracestate.ProductBarcode = KT_BarCode;
|
|
|
DbHandler db = new DbHandler();
|
|
|
//查询当前的机种型号,不是机种要具体到型号
|
|
|
string machineID = db.GetNowProductionInfo();
|
|
|
db.InsertTrace(mainBarcode, ABarCode, KT_BarCode, machineID);
|
|
|
//PrintManager pm = new PrintManager();
|
|
|
//pm.Print(KT_BarCode, int.Parse(syTracestate.ProductID), syTracestate.ShiftID);
|
|
|
//这里插入打印记录
|
|
|
InsertScanBarCodePrintRecord(syTracestate);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "PLC未上传壳体条码");
|
|
|
//暂时先给放行
|
|
|
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//下发放行
|
|
|
FinishSavePLCWork(station);
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("铭牌打印工位错误:" + "/r/n" + ex.ToString());
|
|
|
FinishSavePLCWork(station);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|