|
|
using Mesnac.Compressor.Data;
|
|
|
using Mesnac.Compressor.Entity;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
namespace Mesnac.Compressor.Station
|
|
|
{
|
|
|
public class NoRFIDStation : Common, IStation
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 无RFID托盘的工位直接将产品条码号放到数据表中,没有系统条码之分,这样统计数据只能按最后一次来统计
|
|
|
/// 对于重投次数也不太好统计
|
|
|
/// </summary>
|
|
|
/// <param name="station"></param>
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool PrepareWork(StationInfo station)
|
|
|
{
|
|
|
//if (station.Data.subLineList.Count == 0)
|
|
|
//{
|
|
|
// ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
|
|
|
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
|
|
|
// return false;
|
|
|
//}
|
|
|
//ICSharpCode.Core.LoggingService.DebugFormatted("查询{0}是否开启MES", station.stationID);
|
|
|
//先判断后台开关是否打开在进行逻辑验证
|
|
|
bool iflag = IsOpen(station.stationID);
|
|
|
if (iflag)
|
|
|
{
|
|
|
//ICSharpCode.Core.LoggingService.Debug("查询已开启MES");
|
|
|
//主线产品码未扫描到条码下发PLC报警
|
|
|
if (station.stationID == "9" || station.stationID == "10")
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(station.Data.subLineList[2].barcode) || station.Data.subLineList[2].barcode.Equals("ERROR"))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.DebugFormatted("{0}收到PLC条码:{1}", station.StationCode, station.Data.subLineList[2].barcode);
|
|
|
}
|
|
|
}
|
|
|
else if(station.stationID == "2" || station.stationID == "20" || station.stationID == "22" || station.stationID == "25" || station.stationID == "26" || station.stationID == "27" || station.stationID == "28" || station.stationID == "29" || station.stationID == "30" || station.stationID == "31" || station.stationID == "32")
|
|
|
{
|
|
|
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;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.DebugFormatted("{0}收到PLC条码:{1}", station.StationCode, station.Data.ProductBarcode);
|
|
|
//240
|
|
|
if (station.stationID == "29")
|
|
|
{
|
|
|
string 预加油重量 = GetZhuYouByKTBarCode(station.Data.ProductBarcode.Trim(),"预加油重量");
|
|
|
string 裸机重量 = GetZhuYouByKTBarCode(station.Data.ProductBarcode.Trim(), "裸机重量");
|
|
|
|
|
|
if (string.IsNullOrEmpty(预加油重量))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未查询到预加油后重量");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
|
|
|
return false;
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(裸机重量))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未查询到裸机重量");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
|
|
|
return false;
|
|
|
}
|
|
|
ICSharpCode.Core.LoggingService.DebugFormatted("查询{0}预加油后重量:{1},裸机重量{2}", station.Data.ProductBarcode.Trim(), 预加油重量, 裸机重量);
|
|
|
float f_预加油后重量 = float.Parse(预加油重量);
|
|
|
float f_裸机重量 = float.Parse(裸机重量);
|
|
|
//ICSharpCode.Core.LoggingService.DebugFormatted("查询{0}裸机重量-120后:{1}", station.Data.subLineList[1].barcode, cc);
|
|
|
|
|
|
object[] ZhuYouLiang = floatToObject(f_预加油后重量);
|
|
|
object[] luojizhongliang = floatToObject(f_裸机重量);
|
|
|
//向PLC写入裸机重量
|
|
|
bool bflag = WritePLCByByte(station, 40, ZhuYouLiang);
|
|
|
bool bflag1 = WritePLCByByte(station, 50, luojizhongliang);
|
|
|
if (bflag && bflag1)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.DebugFormatted("写入{0}预加油后重量:{1},裸机重量{2}", station.Data.ProductBarcode.Trim(), 预加油重量, 裸机重量);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//静盘条码
|
|
|
else if (station.stationID == "12" || station.stationID == "16")
|
|
|
{
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
else if (station.stationID == "23")
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(station.Data.subLineList[1].barcode) || station.Data.subLineList[1].barcode.Equals("ERROR"))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
//ICSharpCode.Core.LoggingService.DebugFormatted("查询{0}工位已开启MES", preStationID);
|
|
|
string LastWorkInfo = "";
|
|
|
if (LastWorkInfo == "")
|
|
|
{
|
|
|
//后盖螺栓紧固工位新增查询壳体是否绑定后盖逻辑
|
|
|
if (station.stationID == "20")
|
|
|
{
|
|
|
//根据壳体码查询控制器是否绑定
|
|
|
string _hgCode = GetHCodeByProductBarCode(station.Data.ProductBarcode);
|
|
|
if (string.IsNullOrEmpty(_hgCode))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测未存在后盖绑定信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LastWorkInfo = "1";
|
|
|
}
|
|
|
}
|
|
|
//检漏工位
|
|
|
if (station.stationID == "23")
|
|
|
{
|
|
|
//启用绝缘工位互锁后检漏工位判断上工位是否合格业务逻辑
|
|
|
if (station.Data.subLineList[1].barcode.Trim() == "LOU PING XIAO YAN" || station.Data.subLineList[1].barcode.Trim() == "KONGPINGXIAOYAN" || station.Data.subLineList[1].barcode.Trim() == "KONGJIANH" || station.Data.subLineList[1].barcode.Trim() == "FU WEI" || station.Data.subLineList[1].barcode.Trim() == "FUWEI" || station.Data.subLineList[1].barcode.Trim() == "KONGJIAN"|| station.Data.subLineList[1].barcode.Trim() == "LOUPINGXIAOYAN")
|
|
|
{
|
|
|
LastWorkInfo = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bool _NGflag = GetStationNGBySemiBarCode(station.Data.subLineList[1].barcode.Trim(), "190");
|
|
|
if (!_NGflag)
|
|
|
{
|
|
|
LastWorkInfo = "1";
|
|
|
}
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(LastWorkInfo))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//控制器螺栓紧固
|
|
|
if (station.stationID == "25")
|
|
|
{
|
|
|
//根据壳体码查询控制器是否绑定
|
|
|
string _ktCode = GetKCodeByProductBarCode(station.Data.ProductBarcode);
|
|
|
if (string.IsNullOrEmpty(_ktCode))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LastWorkInfo = "1";
|
|
|
}
|
|
|
}
|
|
|
//性能测试
|
|
|
if (station.stationID == "28")
|
|
|
{
|
|
|
//ICSharpCode.Core.LoggingService.Debug("性能检测互锁查询");
|
|
|
DataTable _NGflag = GetXNByProductCode(station.Data.ProductBarcode.Trim(), "230_1");
|
|
|
if (_NGflag != null && _NGflag.Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < _NGflag.Rows.Count; i++)
|
|
|
{
|
|
|
string s = _NGflag.Rows[i]["State"].ToString();
|
|
|
if (_NGflag.Rows[i]["State"].ToString() != "1")
|
|
|
{
|
|
|
//区分报警类型
|
|
|
//控制器螺栓紧固
|
|
|
if (_NGflag.Rows[i]["TableName"].ToString() == "T_RP_StationPara_210")
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.LSJGNG);
|
|
|
return false;
|
|
|
}
|
|
|
//氦检
|
|
|
else if (_NGflag.Rows[i]["TableName"].ToString() == "T_RP_StationPara_190_1")
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.HJNG);
|
|
|
return false;
|
|
|
}
|
|
|
//控制器腔体检漏,称重
|
|
|
else if (_NGflag.Rows[i]["TableName"].ToString() == "T_RP_StationPara_220")
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.KZQQTNG);
|
|
|
return false;
|
|
|
}
|
|
|
else if (_NGflag.Rows[i]["TableName"].ToString() == "T_RP_StationPara_220_1")
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.CZNG);
|
|
|
return false;
|
|
|
}
|
|
|
ICSharpCode.Core.LoggingService.ErrorFormatted("{0}工位数据NG!", _NGflag.Rows[i]["StationName"].ToString());
|
|
|
}
|
|
|
}
|
|
|
LastWorkInfo = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LastWorkInfo = "1";
|
|
|
}
|
|
|
}
|
|
|
//注油称重锁性能
|
|
|
if (station.stationID == "29")
|
|
|
{
|
|
|
LastWorkInfo = LastWorkProductionInfo(station.Data.ProductBarcode.Trim(), "T_RP_StationPara_230_1", "ScanBarcode");
|
|
|
}
|
|
|
//螺栓紧固锁称重注油
|
|
|
if (station.stationID == "30")
|
|
|
{
|
|
|
LastWorkInfo = LastWorkProductionInfo(station.Data.ProductBarcode.Trim(), "T_RP_StationPara_240", "ScanBarcode");
|
|
|
}
|
|
|
|
|
|
if (station.stationID == "2" || station.stationID == "9" || station.stationID == "10" || station.stationID == "12" || station.stationID == "16" || station.stationID == "22" || station.stationID == "26" || station.stationID == "27" || station.stationID == "31" || station.stationID == "32")
|
|
|
{
|
|
|
LastWorkInfo = "1";
|
|
|
}
|
|
|
//没有上工位信息
|
|
|
if (string.IsNullOrEmpty(LastWorkInfo))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//NG物料拿取
|
|
|
if (LastWorkInfo != "1")
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//这里加一个物料是否匹配=======//还要加判断,当前工位是否需要判断
|
|
|
//ICSharpCode.Core.LoggingService.Debug("》》》》》》开始写入PLC反馈信号!");
|
|
|
}
|
|
|
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
|
|
|
//ICSharpCode.Core.LoggingService.Debug("》》》》》》写入PLC反馈信号完成!");
|
|
|
return true;
|
|
|
}
|
|
|
public bool HandleData(StationInfo station)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
SqlHelper sh = new SqlHelper();
|
|
|
DbHandler db = new DbHandler();
|
|
|
if ( station.stationID == "12" || station.stationID == "16")
|
|
|
{
|
|
|
station.Data.ProductBarcode = station.Data.subLineList[4].barcode;
|
|
|
}
|
|
|
else if (station.stationID == "23")
|
|
|
{
|
|
|
station.Data.ProductBarcode = station.Data.subLineList[1].barcode.Trim();
|
|
|
}
|
|
|
else if (station.stationID == "9" || station.stationID == "10")
|
|
|
{
|
|
|
station.Data.ProductBarcode = station.Data.subLineList[2].barcode.Trim();
|
|
|
}
|
|
|
DeleteStationData(station.TableName, station.Data.ProductBarcode);
|
|
|
|
|
|
foreach (subLine s in station.Data.subLineList)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(s.barcode))
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Debug(station.StationName + ",支线工位:" + station.StationCode + " ,物料条码:" + s.barcode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//插入新数据
|
|
|
string InsertSql = sh.DataInsertSql2(station);
|
|
|
db.ExecSql(InsertSql);
|
|
|
|
|
|
//更新工位
|
|
|
if (station.stationID != "2" || station.stationID != "9" && station.stationID != "10" && station.stationID != "12" && station.stationID != "16")
|
|
|
{
|
|
|
//根据组件码查询A码
|
|
|
if (!string.IsNullOrEmpty(station.Data.ProductBarcode))
|
|
|
{
|
|
|
if (station.stationID == "32")
|
|
|
{
|
|
|
/*UPDATE dbo.T_SY_TraceState SET FinishFlag = 1,EndTime = GETDATE(),CurrentStationID = '33',state = 1,NameplateInfo = @serialNum,MarkRecord = @bigCode WHERE SemiBarcode_A = @semibarcode*/
|
|
|
//结束工位
|
|
|
UpdateCompleteStationInfo(station.Data.ProductBarcode);
|
|
|
ICSharpCode.Core.LoggingService.DebugFormatted("{0}工位,{1}条码工位数据更新成功。", station.stationID, station.Data.ProductBarcode);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//根据A码查询M码
|
|
|
//获取系统M码
|
|
|
string Mainbarcode = GetMainBarcode(station.Data.ProductBarcode);
|
|
|
if (!string.IsNullOrEmpty(Mainbarcode))
|
|
|
{
|
|
|
if (station.Data.ProductOkNg != 1)
|
|
|
{
|
|
|
station.Data.MainBarcode = Mainbarcode;
|
|
|
UpdateTraceNgStation(station);
|
|
|
}
|
|
|
UpdateTraceStation(station.stationID, Mainbarcode);
|
|
|
ICSharpCode.Core.LoggingService.DebugFormatted("{0}工位,{1}条码工位数据更新成功。", station.stationID, station.Data.ProductBarcode);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
ICSharpCode.Core.LoggingService.Debug("工位:" + station.StationCode + " 保存数据成功。托盘号:" + station.Data.RFIDNo);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Info(e.ToString());
|
|
|
return false;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
//这里要加一个OK放行
|
|
|
FinishSavePLCWork(station);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
}
|