|
|
using MaterialTraceability.Common;
|
|
|
using MaterialTraceability.Entity.DAO;
|
|
|
using MaterialTraceability.Entity.DTO;
|
|
|
using MaterialTraceability.Entity.Enum;
|
|
|
using MaterialTraceability.Entity.UpLoad;
|
|
|
using MaterialTraceability.SqlSugar;
|
|
|
using MaterialTraceability.SqlSugar.ServiceImpl;
|
|
|
using MaterialTraceability.WebService;
|
|
|
using MaterialTraceability.WebService.GetParametricValueServiceService;
|
|
|
using MaterialTraceability.WebService.MachineIntegrationServiceService;
|
|
|
using MaterialTraceability.WebService.MiBatchCompleteSfcAndAdujustQtyServiceService;
|
|
|
using MaterialTraceability.WebService.MiFirstOperationForsfcServiceService;
|
|
|
using MaterialTraceability.WebService.Param;
|
|
|
using MaterialTraceability.WebService.ProcessLotServiceWSService;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Linq.Expressions;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace MaterialTraceability.Business.Impl
|
|
|
{
|
|
|
public class LYSignalReadBusiness : ISignalReadFunction
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// INIFile配置文件
|
|
|
/// </summary>
|
|
|
private INIFile inifile = new INIFile(System.Environment.CurrentDirectory + "/MesConfig/App.InI");
|
|
|
private INIFile inifile2 = new INIFile(System.Environment.CurrentDirectory + "/App.InI");
|
|
|
|
|
|
private AppConfigDto appConfig = AppConfigDto.Instance;
|
|
|
/// <summary>
|
|
|
/// 日志刷新
|
|
|
/// </summary>
|
|
|
/// <param name="type">日志内容</param>
|
|
|
/// <param name="massage"></param>
|
|
|
public delegate void LogRefresh(LogType logType, string massage);
|
|
|
public static event LogRefresh LogRefreshEvent;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 视图层数据刷新
|
|
|
/// </summary>
|
|
|
/// <param name="viewModelDto"></param>
|
|
|
public delegate void ViewModelRefresh(ViewModelDto viewModelDto);
|
|
|
public static event ViewModelRefresh ViewModelRefreshEvent;
|
|
|
|
|
|
/// <summary>
|
|
|
/// PLC信号事件
|
|
|
/// </summary>
|
|
|
/// <param name="status"></param>
|
|
|
/// <param name="position"></param>
|
|
|
public delegate void SignalReadInvoke(int status, int position);
|
|
|
|
|
|
/// <summary>
|
|
|
/// RFID读写器业务
|
|
|
/// </summary>
|
|
|
private EquipBusiness equipBusiness = new EquipBusiness();
|
|
|
|
|
|
/// <summary>
|
|
|
/// Mes WebService接口
|
|
|
/// </summary>
|
|
|
private IMesWebServices MesWebServices = new MesWebServicesImpl();
|
|
|
|
|
|
//卷轴信息
|
|
|
private IBaseServices<ProShaftInfo> shaftInfoServices = new BaseServices<ProShaftInfo>();
|
|
|
|
|
|
//收卷记录
|
|
|
private IBaseServices<ProDownRecord> downRecordServices = new BaseServices<ProDownRecord>();
|
|
|
|
|
|
//上料记录
|
|
|
private IBaseServices<ProUpRecord> upRecordServices = new BaseServices<ProUpRecord>();
|
|
|
|
|
|
private IBaseServices<SysClient> sysClientServices = new BaseServices<SysClient>();
|
|
|
|
|
|
private MesAlarmInfo mesAlarmInfo = new MesAlarmInfo();
|
|
|
|
|
|
private PlcBusiness plcBusiness = new PlcBusiness();
|
|
|
|
|
|
private UpLoadBusiness upLoadBusiness = UpLoadBusiness.Instance;
|
|
|
int rfid = 0;
|
|
|
|
|
|
///add by yinzf
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void UpBegin(int position)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
//end add
|
|
|
/// <summary>
|
|
|
/// 放卷涨紧
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void UpMaterialBegin(int position)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//判断AB放卷轴
|
|
|
string logStr = position == 0 ? LanguageHelper.ShowMessage("A放卷轴") : LanguageHelper.ShowMessage("B放卷轴");
|
|
|
//冷压设备手动写入后会给涨紧信号
|
|
|
string isAutoWrite = inifile2.IniReadValue("SystemConfig", "isAutoWrite");
|
|
|
if (isAutoWrite == "是")
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("放卷手动写入后收到涨紧信号,不进行读取!"));
|
|
|
LogHelper.Info("放卷手动写入后收到涨紧信号,不进行读取");
|
|
|
inifile2.IniWriteValue("SystemConfig", "isAutoWrite", "否");
|
|
|
return;
|
|
|
}
|
|
|
#region 未登录不让放卷涨紧生产,便于记录生产者
|
|
|
/*if (StringExtension.IsBlank(ConfigHelper.GetConfig("roleId")))
|
|
|
{
|
|
|
MessageBox.Show("请先登录再开始生产");
|
|
|
LogHelper.Info("请先登录再开始生产");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "请先登录再开始生产");
|
|
|
|
|
|
return;
|
|
|
}*/
|
|
|
#endregion
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + LanguageHelper.ShowMessage("涨紧信号触发成功"));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("涨紧信号触发成功"));
|
|
|
LogHelper.Info(logStr + "涨紧信号触发成功");
|
|
|
if (position == 0)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.B放卷上料OK, 0);
|
|
|
}
|
|
|
//读取卷筒RFID物料信息
|
|
|
ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == position).FirstOrDefault();
|
|
|
if (proEquip == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("获取放卷位RFID设备信息异常"));
|
|
|
return;
|
|
|
}
|
|
|
string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId);
|
|
|
epc = epc.Replace("\0", "").Trim();
|
|
|
//RFID写入PLC
|
|
|
//WriteRFIDtoPLC(position, epc);
|
|
|
//if (epc == "" || epc == null)
|
|
|
//{
|
|
|
// Random random = new Random();
|
|
|
|
|
|
// epc = "JSLY4RDA0000" + random.Next(10, 99);
|
|
|
//}
|
|
|
|
|
|
|
|
|
if (StringExtension.IsBlank(epc) || !epc.Contains("JSLY") && !epc.Contains("CATT"))
|
|
|
{
|
|
|
if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
//手动写入自动下降U型块
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
}
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
LogHelper.Info(logStr+"RFID条码信息读取失败,下发PLC报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr+ LanguageHelper.ShowMessage("RFID条码信息读取失败"));
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = "",
|
|
|
sfc = "",
|
|
|
ea = "",
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
LogHelper.Info(String.Format(logStr+"RFID条码信息读取成功:{0}", epc));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+ LanguageHelper.ShowMessage("RFID条码信息读取成功,RFID为")+ epc);
|
|
|
//判断RFID标签是否重复
|
|
|
//LogHelper.Info("判断RFID标签是否重复");
|
|
|
if (BusinessHelper.UpRfidIsRecur(epc, position).Result)
|
|
|
{
|
|
|
|
|
|
//判断是否已经生产结束
|
|
|
if (UpMaterialIsEndProduction(epc).Result)
|
|
|
{
|
|
|
if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
//手动写入自动下降U型块
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 0);
|
|
|
}
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, epc + LanguageHelper.ShowMessage("当前读取的RFID,已经生产结束不允许再次上料" ));
|
|
|
LogHelper.Info(String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc));
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Expression<Func<ProUpRecord, bool>> exp = s1 => true;
|
|
|
Expression<Func<ProUpRecord, object>> order = (x) => x.RecordTime;
|
|
|
ProUpRecord upRecord = upRecordServices.QueryFirst(exp, order, false).Result;
|
|
|
if (upRecord != null)
|
|
|
{
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
sfc = upRecord.Sfc,
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
}
|
|
|
LogHelper.Info(logStr+"RFID读取到的条码:" + epc + "与前一次读取相同并且生产未结束,可以继续生产");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+","+ epc + LanguageHelper.ShowMessage("RFID读取到的条码与前一次读取相同并且生产未结束,可以继续生产"));
|
|
|
//LogHelper.Info("冷压放卷流程处理成功,D6014写0");
|
|
|
if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
//手动写入自动下降U型块
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 0)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.B放卷上料OK, 1);
|
|
|
}
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
//读取数据刷新
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
//sfc = "",
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
MesBegin(position, epc, true);
|
|
|
//SaveReadRecord(proEquip, epc);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("放卷涨紧逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷涨紧逻辑处理异常" + ex.Message);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷结束
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public async void UpMaterialEnd(int position)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string logStr = position == 0 ? LanguageHelper.ShowMessage("A放卷轴") : LanguageHelper.ShowMessage("B放卷轴");
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr+ LanguageHelper.ShowMessage("放卷位结束信号触发成功"));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷位结束信号触发成功"));
|
|
|
LogHelper.Info("放卷位结束信号触发成功");
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position);
|
|
|
if (shaftInfo == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,获取卷轴绑定的信息为空");
|
|
|
return;
|
|
|
}
|
|
|
Expression<Func<ProUpRecord, bool>> upExp = s1 => true;
|
|
|
upExp = upExp.And(x => x.Sfc == shaftInfo.bindSfc && x.Rfid == shaftInfo.bindRfid && x.IsProduction == 0);
|
|
|
Expression<Func<ProUpRecord, object>> upOrder = (x) => x.RecordTime;
|
|
|
ProUpRecord upRecord = await upRecordServices.QueryFirst(upExp, upOrder, false);
|
|
|
if (upRecord == null)
|
|
|
{
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 1);
|
|
|
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 0);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr+ LanguageHelper.ShowMessage("放卷结束,获取上料信息为空"));
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//清空绑定信息
|
|
|
//shaftInfo.bindSfc = String.Empty;
|
|
|
//shaftInfo.bindRfid = String.Empty;
|
|
|
//shaftInfo.bindEaValue = String.Empty;
|
|
|
//await shaftInfoServices.Update(shaftInfo);
|
|
|
//LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,清除卷轴绑定信息");
|
|
|
|
|
|
//LogRefreshEvent?.Invoke(LogType.RfidLog, "获取当前正在生产的收卷轴");
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1A状态) == 1)
|
|
|
{
|
|
|
UpdateShaftEndFlag(1);
|
|
|
}
|
|
|
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1B状态) == 1)
|
|
|
{
|
|
|
UpdateShaftEndFlag(2);
|
|
|
}
|
|
|
|
|
|
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2A状态) == 1)
|
|
|
{
|
|
|
UpdateShaftEndFlag(3);
|
|
|
}
|
|
|
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2B状态) == 1)
|
|
|
{
|
|
|
UpdateShaftEndFlag(4);
|
|
|
}
|
|
|
|
|
|
|
|
|
//更新放卷信息
|
|
|
upRecord.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
upRecord.IsProduction = 1;
|
|
|
upRecord.isFinish = 1;
|
|
|
await upRecordServices.Update(upRecord);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("生成放卷信息"));
|
|
|
|
|
|
//upLoadBusiness.UpdateUpRecord(upRecord);
|
|
|
//if (PlcBusiness.readPlc(appConfig.LyAddress.放卷上料OK)==1)
|
|
|
//{
|
|
|
// plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 0);
|
|
|
//}
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 1);
|
|
|
|
|
|
inifile2.IniWriteValue("SystemConfig", "isAutoWrite", "否");
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 1);
|
|
|
|
|
|
//if (PlcBusiness.readPlc(appConfig.LyAddress.放卷上料OK) == 1)
|
|
|
//{
|
|
|
// plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 0);
|
|
|
//}
|
|
|
inifile2.IniWriteValue("SystemConfig", "isAutoWrite", "否");
|
|
|
|
|
|
|
|
|
LogHelper.Error("冷压放卷位结束逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("冷压放卷位结束逻辑处理异常") + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷涨紧
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public async void DownMaterialBegin(int position)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
List<ProEquip> proEquips = new List<ProEquip>();
|
|
|
|
|
|
List<int> positionList = PositionToList(position);
|
|
|
List<string> tagInfoList = new List<string>();
|
|
|
string logStr = Which(position);
|
|
|
#endregion
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + LanguageHelper.ShowMessage( "收卷位涨紧信号触发成功"));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "收卷位涨紧信号触发成功");
|
|
|
LogHelper.Info(logStr + "收卷位涨紧信号触发成功");
|
|
|
ClearSuccessOkSignal(position);
|
|
|
//判断放卷生产轴
|
|
|
string FJSFC = "";
|
|
|
int FJAstate = PlcBusiness.readPlc(appConfig.LyAddress.放卷A状态);
|
|
|
if (FJAstate == 1)
|
|
|
{
|
|
|
FJSFC = PlcBusiness.readStrPlc(appConfig.LyAddress.A放卷SFC, 20).Replace("\0", "").Trim();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
int FJBstate = PlcBusiness.readPlc(appConfig.LyAddress.放卷B状态);
|
|
|
if (FJBstate == 1)
|
|
|
{
|
|
|
FJSFC = PlcBusiness.readStrPlc(appConfig.LyAddress.B放卷SFC, 20).Replace("\0", "").Trim();
|
|
|
}
|
|
|
}
|
|
|
if (FJSFC.Length > 0)
|
|
|
{
|
|
|
FJSFC = FJSFC.Substring(0, 18);
|
|
|
}
|
|
|
if (StringExtension.IsBlank(FJSFC))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("放卷位物料信息为空,先触发放卷位物料信息"));
|
|
|
WriteNGToPLC(position);
|
|
|
sendError(position, 2, false, 1);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+ LanguageHelper.ShowMessage("开始读取卷筒RFID物料信息" ));
|
|
|
|
|
|
List<TagMessage> positionTag = equipBusiness.ReadEPCByAntanaGroup(positionList);
|
|
|
foreach (var item in positionList)
|
|
|
{
|
|
|
if (item == 1) logStr = LanguageHelper.ShowMessage("1A轴1#天线");
|
|
|
if (item == 2) logStr = LanguageHelper.ShowMessage("1A轴2#天线");
|
|
|
if (item == 3) logStr = LanguageHelper.ShowMessage("1B轴1#天线");
|
|
|
if (item == 4) logStr = LanguageHelper.ShowMessage("1B轴2#天线");
|
|
|
if (item == 5) logStr = LanguageHelper.ShowMessage("2A轴3#天线");
|
|
|
if (item == 6) logStr = LanguageHelper.ShowMessage("2A轴4#天线");
|
|
|
if (item == 7) logStr = LanguageHelper.ShowMessage("2B轴3#天线");
|
|
|
if (item == 8) logStr = LanguageHelper.ShowMessage("2B轴4#天线");
|
|
|
|
|
|
string epc = "";
|
|
|
//add by wenjy 判断读取结果是否为null 20220825
|
|
|
if (positionTag != null)
|
|
|
{
|
|
|
foreach (var Tag in positionTag)
|
|
|
{
|
|
|
if (Tag.position == item)
|
|
|
{
|
|
|
epc = Tag.EPC;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//epc = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("读到标签条码信息:")+ epc);
|
|
|
|
|
|
epc = epc.Replace("\0", "").Trim();
|
|
|
//RFID写入PLC
|
|
|
//WriteRFIDtoPLC(position,epc);
|
|
|
//if (epc == "" || epc == null)
|
|
|
//{
|
|
|
// Random random = new Random();
|
|
|
|
|
|
// epc = "JSLY4RDA0000" + random.Next(10, 99);
|
|
|
//}
|
|
|
//SaveReadRecord(new ProEquip()
|
|
|
//{
|
|
|
// machineId = appConfig.machineId,
|
|
|
// positionId = position,
|
|
|
// equipId = appConfig.machineId,
|
|
|
|
|
|
// equipAnt = position.ToString(),
|
|
|
//}, epc);
|
|
|
//判断RFID标签是否重复
|
|
|
//LogHelper.Info("判断RFID标签是否重复");
|
|
|
|
|
|
if (StringExtension.IsBlank(epc) || !epc.Contains("JSLY") && !epc.Contains("CATT"))
|
|
|
{
|
|
|
WriteNGToPLC(position);
|
|
|
sendError(position, 2, false, 1);
|
|
|
|
|
|
LogHelper.Info(logStr + "RFID条码信息读取失败");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + LanguageHelper.ShowMessage( "RFID条码信息读取失败"));
|
|
|
//纳克读取失败先向轴写入下料OK,复位信号才能涨紧
|
|
|
//LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "写入下料OK,重新复位涨紧信号");
|
|
|
//SendXL_OK(position);
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = "",
|
|
|
sfc = "",
|
|
|
ea = "",
|
|
|
position = item,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
continue;
|
|
|
}
|
|
|
//判断是否串读 Add by wenjy 2022-10-05
|
|
|
//if (PdRfidIsChuanDu(epc, position).Result)
|
|
|
//{
|
|
|
// WriteNGToPLC(position);
|
|
|
// sendError(position, 2, false, 1);
|
|
|
// LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
|
|
|
// LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
// continue;
|
|
|
//}
|
|
|
LogHelper.Info(logStr + "RFID读取成功,RFID为:" + epc);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("RFID读取成功,RFID为:") + epc);
|
|
|
|
|
|
//判断是否串读 Add by wenjy 2022-10-05
|
|
|
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
position = item,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
tagInfoList.Add(epc);
|
|
|
//绑定卷轴与物料信息
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(item);
|
|
|
|
|
|
if (shaftInfo == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage( "绑定卷轴与物料信息,获取卷轴信息为空"));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("绑定卷轴与物料信息,获取卷轴信息为空"));
|
|
|
LogHelper.Info("绑定卷轴与物料信息,获取卷轴信息为空");
|
|
|
continue;
|
|
|
}
|
|
|
shaftInfo.bindRfid = epc;
|
|
|
shaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
shaftInfo.endFlag = 0;
|
|
|
await shaftInfoServices.Update(shaftInfo);
|
|
|
LogHelper.Info(String.Format("{0}绑定RFID条码信息:{1}", logStr, epc));
|
|
|
|
|
|
//if (BusinessHelper.DownRfidIsRecur(epc, item).Result)
|
|
|
//{
|
|
|
// LogHelper.Info(logStr + "RFID读取到的条码:" + epc + "与上一读取相同不做MES处理");
|
|
|
// LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "RFID读取到的条码:" + epc + "与上一读取相同不做MES处理");
|
|
|
// LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "RFID读取到的条码:" + epc + "与上一读取相同不做MES处理");
|
|
|
// this.sendSuccessByDownBegin(position);
|
|
|
// continue;
|
|
|
//}
|
|
|
LogHelper.Info(String.Format("收卷流程处理完成,判断读取结果是否OK,位置:{0},标签数量:{1},条码信息:{2}", position, tagInfoList.Count, JsonChange.ModeToJson(tagInfoList)));
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2" || ConfigHelper.GetConfig("tagAmount") == "1")
|
|
|
{
|
|
|
if (tagInfoList.Count == 1)
|
|
|
{
|
|
|
//这里要判断是否存在其他位置
|
|
|
if (JudgeSame(tagInfoList, position))
|
|
|
{
|
|
|
WriteNGToPLC(position);
|
|
|
sendError(position, 2, false, 1);
|
|
|
LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + epc+ LanguageHelper.ShowMessage("RFID条码已存在其它位置,检查是否重复"));
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号");
|
|
|
this.sendSuccessByDownBegin(position);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ConfigHelper.GetConfig("tagAmount") == "3")
|
|
|
{
|
|
|
if (position < 3)
|
|
|
{
|
|
|
if (tagInfoList.Count == 2)
|
|
|
{
|
|
|
//这里要判断是否存在其他位置
|
|
|
if (JudgeSame(tagInfoList, position))
|
|
|
{
|
|
|
WriteNGToPLC(position);
|
|
|
sendError(position, 2, false, 1);
|
|
|
LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + epc + LanguageHelper.ShowMessage("RFID条码已存在其它位置,检查是否重复"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号");
|
|
|
this.sendSuccessByDownBegin(position);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (tagInfoList.Count == 1)
|
|
|
{
|
|
|
if (JudgeSame(tagInfoList, position))
|
|
|
{
|
|
|
WriteNGToPLC(position);
|
|
|
sendError(position, 2, false, 1);
|
|
|
LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + epc + LanguageHelper.ShowMessage("RFID条码已存在其它位置,检查是否重复"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号");
|
|
|
this.sendSuccessByDownBegin(position);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
//解绑RFID与SFC的绑定信息
|
|
|
LogHelper.Info("解绑RFID条码" + epc + "绑定的SFC信息");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + epc+ LanguageHelper.ShowMessage("解绑RFID条码绑定的SFC信息"));
|
|
|
this.UnBindRfidAndSfc(epc);
|
|
|
}
|
|
|
|
|
|
//添加下料记录
|
|
|
ProDownRecord downRecord = new ProDownRecord()
|
|
|
{
|
|
|
Id = System.Guid.NewGuid().ToString("N"),
|
|
|
MachineId = appConfig.machineId,
|
|
|
PositionId = item,
|
|
|
Rfid = epc,
|
|
|
IsProduction = 0,
|
|
|
beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
};
|
|
|
await downRecordServices.Add(downRecord);
|
|
|
|
|
|
//upLoadBusiness.SaveDownRecord(downRecord);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
WriteNGToPLC(position);
|
|
|
sendError(position, 2, false, 1);
|
|
|
LogHelper.Error("冷压收卷涨紧信号逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("冷压收卷涨紧信号逻辑处理异常") + ex.Message);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
tagInfoList = new List<string>();
|
|
|
}
|
|
|
}
|
|
|
private bool JudgeSame(List<string> tagInfoList,int position)
|
|
|
{
|
|
|
bool iflag = false;
|
|
|
try
|
|
|
{
|
|
|
foreach (var item in tagInfoList)
|
|
|
{
|
|
|
if (PdRfidIsChuanDu(item, position).Result)
|
|
|
{
|
|
|
iflag = true;
|
|
|
return iflag;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷结束
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public async void DownMaterialEnd(int position)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
List<ProShaftInfo> shaftInfos = new List<ProShaftInfo>();
|
|
|
List<int> positionList = PositionToList(position);
|
|
|
string logStr = Which(position);
|
|
|
int realEaValue = 0;
|
|
|
#endregion
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + LanguageHelper.ShowMessage("收卷结束信号触发成功"));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("收卷结束信号触发成功"));
|
|
|
LogHelper.Info(logStr + "收卷结束信号触发成功");
|
|
|
//通过PLC读取收卷轴绑定的放卷位SFC信
|
|
|
ProShaftInfo upMaterialInfo = new ProShaftInfo();
|
|
|
if (position == 1) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, 18).Replace("\0", "").Trim();
|
|
|
if (position == 2) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, 18).Replace("\0", "").Trim();
|
|
|
if (position == 3) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, 18).Replace("\0", "").Trim();
|
|
|
if (position == 4) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, 18).Replace("\0", "").Trim();
|
|
|
//LogHelper.PlcLog("通过PLC获取SFC截取前长度:" + upMaterialInfo.bindSfc.Length);
|
|
|
//LogHelper.PlcLog("PLC获取截取前的SFC为:" + upMaterialInfo.bindSfc);
|
|
|
if (StringExtension.IsBlank(upMaterialInfo.bindSfc))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("通过PLC获取SFC为空"));
|
|
|
|
|
|
this.sendSuccess(position);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (upMaterialInfo.bindSfc.Length > 0)
|
|
|
{
|
|
|
//LogRefreshEvent?.Invoke(LogType.RfidLog, "PLC获取的18位SFC为:" + upMaterialInfo.bindSfc + "长度超过18位进行截取");
|
|
|
upMaterialInfo.bindSfc = upMaterialInfo.bindSfc.Substring(0, 18);
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("通过PLC获取的SFC为:") + upMaterialInfo.bindSfc);
|
|
|
//LogHelper.PlcLog("通过PLC获取SFC截取后长度:" + upMaterialInfo.bindSfc.Length);
|
|
|
|
|
|
//获取卷轴绑定的物料信息
|
|
|
foreach (var item in positionList)
|
|
|
{
|
|
|
//获取当前卷轴绑定的物料信息
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(item);
|
|
|
if (shaftInfo == null || StringExtension.IsBlank(shaftInfo.bindRfid))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+ LanguageHelper.ShowMessage("收卷完工获取绑定信息为空不进入结束流程"));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr+LanguageHelper.ShowMessage("收卷完工获取绑定信息为空不进入结束流程"));
|
|
|
LogHelper.Info(String.Format("{0}收卷完工获取绑定信息为空不进入结束流程", logStr));
|
|
|
continue;
|
|
|
}
|
|
|
LogHelper.Info(String.Format("{0}当前绑定的物料信息为:{1}", logStr, JsonChange.ModeToJson(shaftInfo)));
|
|
|
//1A轴:1,1B轴:2,2A轴:3,2B轴:4
|
|
|
//读取卷轴的EA值
|
|
|
LogHelper.Info("读取" + logStr + "的EA值");
|
|
|
if (position == 1) realEaValue = PlcBusiness.readPlc(appConfig.LyAddress.收卷1AEA);
|
|
|
if (position == 2) realEaValue = PlcBusiness.readPlc(appConfig.LyAddress.收卷1BEA);
|
|
|
if (position == 3) realEaValue = PlcBusiness.readPlc(appConfig.LyAddress.收卷2AEA);
|
|
|
if (position == 4) realEaValue = PlcBusiness.readPlc(appConfig.LyAddress.收卷2BEA);
|
|
|
// LogHelper.Info(logStr + "设备EA值:" + realEaValue);
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + LanguageHelper.ShowMessage("设备EA值:") + realEaValue);
|
|
|
shaftInfo.bindEaValue = realEaValue.ToString();
|
|
|
shaftInfos.Add(shaftInfo);
|
|
|
|
|
|
//if (realEaValue >= 700)
|
|
|
//{
|
|
|
// LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("{0}获取实物EA数量:{1},大于700EA不进行拆分完工", logStr, realEaValue));
|
|
|
// LogHelper.Info(String.Format("{0}获取实物EA数量:{1},大于700EA不进行拆分完工", logStr, realEaValue));
|
|
|
// this.sendSuccess(position);
|
|
|
// return;
|
|
|
//}
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = shaftInfo.bindRfid,
|
|
|
sfc = "",
|
|
|
ea = shaftInfo.bindEaValue,
|
|
|
position = item,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("PLC获取的最终SFC为:") + upMaterialInfo.bindSfc);
|
|
|
if (StringExtension.IsBlank(upMaterialInfo.bindSfc))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr+LanguageHelper.ShowMessage("收卷完工获取卷轴绑定的SFC为空不进入结束流程"));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+LanguageHelper.ShowMessage("收卷完工获取卷轴绑定的SFC为空不进入结束流程"));
|
|
|
LogHelper.Info(String.Format("{0}收卷完工获取卷轴绑定的SFC为空不进入结束流程", logStr));
|
|
|
//下发PLC下料信号
|
|
|
this.sendSuccess(position);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
Expression<Func<ProUpRecord, bool>> upExp = s1 => true;
|
|
|
upExp = upExp.And(x => x.Sfc == upMaterialInfo.bindSfc);
|
|
|
Expression<Func<ProUpRecord, object>> upOrder = s => s.RecordTime;
|
|
|
ProUpRecord upRecord = await upRecordServices.QueryFirst(upExp, upOrder, false);
|
|
|
if (upRecord == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr+LanguageHelper.ShowMessage("收卷完工获取放卷位物料信息为空不进入结束流程"));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+LanguageHelper.ShowMessage("收卷完工获取放卷位物料信息为空不进入结束流程"));
|
|
|
LogHelper.Info(String.Format("{0}收卷完工获取放卷位物料信息为空不进入结束流程", logStr));
|
|
|
//下发PLC下料信号
|
|
|
this.sendSuccess(position);
|
|
|
return;
|
|
|
}
|
|
|
//下发禁止下料
|
|
|
sendError(position);
|
|
|
upMaterialInfo.bindRfid = upRecord.Rfid;
|
|
|
upMaterialInfo.bindEaValue = upRecord.eaValue.ToString();
|
|
|
|
|
|
//获取放卷物料MES账目
|
|
|
#region 获取放卷物料EA
|
|
|
string upMaterialEaValue = GetUpMaterialQty(position,upMaterialInfo.bindSfc, logStr);
|
|
|
if (StringExtension.IsBlank(upMaterialEaValue))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, upMaterialInfo.bindSfc+LanguageHelper.ShowMessage("通过MES获取放卷位物料EA值为空"));
|
|
|
return;
|
|
|
}
|
|
|
upMaterialInfo.bindEaValue = upMaterialEaValue;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("放卷位物料EA:" )+ upMaterialInfo.bindEaValue);
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
//获取绑定的SFC
|
|
|
foreach (ProShaftInfo x in shaftInfos)
|
|
|
{
|
|
|
|
|
|
Expression<Func<ProDownRecord, bool>> exp = s1 => true;
|
|
|
exp = exp.And(z => z.Rfid == x.bindRfid && z.IsProduction == 0);
|
|
|
Expression<Func<ProDownRecord, object>> order = (s) => s.beginTime;
|
|
|
ProDownRecord downRecord = await downRecordServices.QueryFirst(exp, order, false);
|
|
|
|
|
|
if (downRecord == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog,LanguageHelper.ShowMessage("收卷流程结束,获取下料信息异常"));
|
|
|
LogHelper.Info("收卷流程结束,获取下料信息异常");
|
|
|
return;
|
|
|
}
|
|
|
#region 物料特征上传LY23取消
|
|
|
//if (upLoadBusiness.JudgeResourceIsUplpadData())
|
|
|
//{
|
|
|
// x.bindSfc = upMaterialInfo.bindSfc;
|
|
|
// x.bindEaValue = realEaValue + "";
|
|
|
// await shaftInfoServices.Update(x);
|
|
|
// machineIntegrationParametricData[] data = GetMaterialWeight(x, upRecord, downRecord);
|
|
|
// UpLoadMaterialWeight(position, upMaterialInfo.bindSfc, downRecord.Id, data);
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
if (x.endFlag == 1)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("完工最后一卷:") + x.bindRfid);
|
|
|
LogHelper.Info("完工最后一卷:" + x.bindRfid);
|
|
|
int mesEaValue = StringChange.ParseToInt(upMaterialInfo.bindEaValue);
|
|
|
|
|
|
#region Add by wenjy 20220826 最后一卷触发添加防呆过滤,避免四个收卷轴都有料时先完工最后一卷物料
|
|
|
//最后一卷拆分防呆 add by CaesarBao 20231101
|
|
|
if (mesEaValue > int.Parse(ConfigHelper.GetConfig("MaxEA")) || mesEaValue < int.Parse(ConfigHelper.GetConfig("MinEA")))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr+LanguageHelper.ShowMessage("获取MES账目EA数量:"+ mesEaValue + LanguageHelper.ShowMessage(",<")+ int.Parse(ConfigHelper.GetConfig("MinEA")) + "EA,>"+ int.Parse(ConfigHelper.GetConfig("MaxEA") + "EA,"+ LanguageHelper.ShowMessage("不进行拆分完工"))));
|
|
|
sendError(position, 2, false, 1);
|
|
|
continue;
|
|
|
}
|
|
|
//判断PLC地址中是否还存在该SFC
|
|
|
|
|
|
if (GetSameSfcByPlc(upMaterialInfo.bindSfc, position))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, upMaterialInfo.bindSfc+LanguageHelper.ShowMessage("其它收卷位还有物料未完工,请勿提前完工最后一卷料" ));
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, 1);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
// 最后一卷全部按照账目数量拆分
|
|
|
LogHelper.Info(String.Format("最后一卷MES账目{0},实物账目{1},全部按照账目拆分", mesEaValue, realEaValue));
|
|
|
|
|
|
if (!SpiltAccount(position, x, mesEaValue, upMaterialInfo.bindSfc, upRecord, downRecord).Result)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "拆分MES账目数量异常");
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
i = i + 1;
|
|
|
}
|
|
|
|
|
|
x.bindEaValue = mesEaValue.ToString();
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 非最后一卷实物>700不拆分,最后一卷不验证超过700不拆分
|
|
|
if (realEaValue > int.Parse(ConfigHelper.GetConfig("MaxEA")) || realEaValue < int.Parse(ConfigHelper.GetConfig("MinEA")))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + LanguageHelper.ShowMessage("获取设备EA数量:" + realEaValue + LanguageHelper.ShowMessage(",<") + int.Parse(ConfigHelper.GetConfig("MinEA")) + "EA,>" + int.Parse(ConfigHelper.GetConfig("MaxEA") + "EA," + LanguageHelper.ShowMessage("不进行拆分完工"))));
|
|
|
//LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("{0}获取实物EA数量:{1},小于{2}EA或大于{3}EA不进行拆分完工", logStr, realEaValue, int.Parse(ConfigHelper.GetConfig("MinEA")), int.Parse(ConfigHelper.GetConfig("MaxEA"))));
|
|
|
LogHelper.Info(String.Format("{0}获取实物EA数量:{1},小于{2}EA或大于{3}EA不进行拆分完工", logStr, realEaValue, int.Parse(ConfigHelper.GetConfig("MinEA")), int.Parse(ConfigHelper.GetConfig("MaxEA"))));
|
|
|
sendError(position, 2, false, 1);
|
|
|
|
|
|
//this.sendSuccess(position);
|
|
|
return;
|
|
|
}
|
|
|
//拆分MES账目数量
|
|
|
if (!SpiltAccount(position, x, realEaValue, upMaterialInfo.bindSfc, upRecord, downRecord).Result)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "拆分MES账目数量异常");
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
i = i + 1;
|
|
|
//判断一下1A,1B轴拆完清掉SFC,防止PLC未清掉
|
|
|
//if (appConfig.PLCType == ("HNLYPLcAddress"))
|
|
|
//{
|
|
|
// ClearPLC_SFCInfo(logStr, x);
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
x.bindEaValue = realEaValue.ToString();
|
|
|
}
|
|
|
|
|
|
x.bindSfc = GetBindSfcByMes(x.bindRfid,false);
|
|
|
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, x.bindRfid + LanguageHelper.ShowMessage("RFID绑定的膜卷号:")+ x.bindSfc);
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = x.bindRfid,
|
|
|
sfc = x.bindSfc,
|
|
|
ea = x.bindEaValue,
|
|
|
position = StringChange.ParseToInt(x.positionId)
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
|
|
|
//本地保存绑定信息
|
|
|
await BusinessHelper.BindRfidAndSfc(x.bindRfid, x.bindSfc);
|
|
|
|
|
|
//更新下料记录
|
|
|
downRecord.Sfc = x.bindSfc;
|
|
|
downRecord.eaValue = StringChange.ParseToInt(x.bindEaValue);
|
|
|
downRecord.IsProduction = 1;
|
|
|
downRecord.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
await downRecordServices.Update(downRecord);
|
|
|
|
|
|
//upLoadBusiness.UpdateDownRecord(downRecord);
|
|
|
|
|
|
//清除收卷轴绑定信息
|
|
|
x.bindRfid = "";
|
|
|
x.bindSfc = "";
|
|
|
x.bindEaValue = "";
|
|
|
x.endFlag = 0;
|
|
|
await shaftInfoServices.Update(x);
|
|
|
};
|
|
|
|
|
|
if (i == shaftInfos.Count)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("下料流程结束,下发PLC下料信号"));
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + LanguageHelper.ShowMessage("下料流程结束,下发PLC下料信号"));
|
|
|
LogHelper.Info(logStr + "下料流程结束,下发PLC下料信号");
|
|
|
//下发PLC下料信号
|
|
|
this.sendSuccess(position);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("冷压收卷结束信号逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog,LanguageHelper.ShowMessage("冷压收卷结束信号逻辑处理异常"));
|
|
|
}
|
|
|
}
|
|
|
private void ClearPLC_SFCInfo(string logStr,ProShaftInfo ProShaftInfo)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string ClearSFC = " ";
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
//拆分数量为2时,暂时不加
|
|
|
//if (ProShaftInfo.positionId == "2")
|
|
|
//{
|
|
|
// PlcBusiness.writeStrPlc(appConfig.LyAddress.收卷1ASFC, ClearSFC);
|
|
|
//}
|
|
|
//else if (ProShaftInfo.positionId == "3")
|
|
|
//{
|
|
|
// PlcBusiness.writeStrPlc(appConfig.LyAddress.收卷1BSFC, ClearSFC);
|
|
|
//}
|
|
|
}
|
|
|
else if (ConfigHelper.GetConfig("tagAmount") == "3")
|
|
|
{
|
|
|
//拆分数量为3时需要将SFC清除
|
|
|
if (ProShaftInfo.positionId == "2")
|
|
|
{
|
|
|
PlcBusiness.writeStrPlc(appConfig.LyAddress.收卷1ASFC, ClearSFC);
|
|
|
}
|
|
|
else if (ProShaftInfo.positionId == "3")
|
|
|
{
|
|
|
PlcBusiness.writeStrPlc(appConfig.LyAddress.收卷1BSFC, ClearSFC);
|
|
|
}
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "清除SFC");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 调整MES数量
|
|
|
/// </summary>
|
|
|
/// <param name="bindSfc"></param>
|
|
|
/// <param name="bindRfid"></param>
|
|
|
/// <param name="eaValue"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool UpdateMesEaValue(int position,string bindSfc, string bindRfid, int eaValue)
|
|
|
{
|
|
|
//调取MES调整数量接口
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES调整数量接口");
|
|
|
MiBatchCompleteSfcAndAdujustQtyServiceServiceParam miBatchCompleteSfcAndAdujustQtyServiceServiceParam = new MiBatchCompleteSfcAndAdujustQtyServiceServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("AdujustQtyParam","url"),
|
|
|
site = inifile.IniReadValue("AdujustQtyParam", "site"),
|
|
|
sfcPre = bindSfc,
|
|
|
processLotPre = "",
|
|
|
operation = appConfig.operation,
|
|
|
operationRevision = inifile.IniReadValue("AdujustQtyParam", "operationRevision"),
|
|
|
resource = appConfig.resource,
|
|
|
user = inifile.IniReadValue("AdujustQtyParam", "user"),
|
|
|
loginUser = inifile.IniReadValue("AdujustQtyParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("AdujustQtyParam", "password"),
|
|
|
activity = inifile.IniReadValue("AdujustQtyParam", "activity"),
|
|
|
modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_NONE,
|
|
|
sfcList = new miBatchCompleteSfcAndAdujustQtySfcEntity[]
|
|
|
{
|
|
|
new miBatchCompleteSfcAndAdujustQtySfcEntity()
|
|
|
{
|
|
|
processLot = bindRfid,
|
|
|
sfc = "",
|
|
|
qty =eaValue.ToString(),
|
|
|
unit = "EA"
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
LogHelper.Info("调用MES接口调整物料" + bindSfc + "数量");
|
|
|
LogHelper.Info("MES调整数量接口请求参数:" + JsonChange.ModeToJson(miBatchCompleteSfcAndAdujustQtyServiceServiceParam));
|
|
|
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
var requestResult = MesWebServices.iMiBatchCompleteSfcAndAdujustQtyServiceService(miBatchCompleteSfcAndAdujustQtyServiceServiceParam);
|
|
|
LogHelper.Info("MES调整数量接口返回参数:" + JsonChange.ModeToJson(requestResult));
|
|
|
if (requestResult.@return.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES调整数量接口调用失败:" + requestResult.@return.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES调整数量接口调用失败:" + upLoadBusiness.GetMesMessage(requestResult.@return.code, requestResult.@return.message));
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, requestResult.@return.code);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES调整数量接口调用成功");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 通过MES获取拆分后绑定的SFC
|
|
|
/// </summary>
|
|
|
/// <param name="bindRfid"></param>
|
|
|
/// <returns></returns>
|
|
|
private string GetBindSfcByMes(string rfidStr,bool iflag)
|
|
|
{
|
|
|
string sfcStr = "";
|
|
|
DateTime beginTime = new DateTime();
|
|
|
ProcessLotServiceWSServiceParam processLotServiceWSServiceParam = new ProcessLotServiceWSServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"),
|
|
|
loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password"),
|
|
|
site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"),
|
|
|
processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr)
|
|
|
};
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("调用MES接口获取RFID绑定的SFC"));
|
|
|
LogHelper.Info("MES获取膜卷号接口请求参数:" + JsonChange.ModeToJson(processLotServiceWSServiceParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
readProcessLotResponse readProcessLotResponse = MesWebServices.readProcessLot(processLotServiceWSServiceParam);
|
|
|
LogHelper.Info("MES获取膜卷号接口返回参数:" + JsonChange.ModeToJson(readProcessLotResponse));
|
|
|
if (readProcessLotResponse.Response.processLotMemberList != null)
|
|
|
{
|
|
|
sfcStr = readProcessLotResponse.Response.processLotMemberList[0].memberContext.Substring(11);
|
|
|
LogHelper.Info("RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, rfidStr + LanguageHelper.ShowMessage("RFID绑定的膜卷号:") + sfcStr);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//LYL3PC022308240064
|
|
|
Random random = new Random();
|
|
|
sfcStr = "LYL3PC0223082400" + random.Next(10,99);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
if (iflag)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
if (appConfig.PLCType != ("LY4NKLYPLcAddress"))
|
|
|
{
|
|
|
if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sendError(0,1,false,1);
|
|
|
LogHelper.Info("MES获取膜卷号接口调用异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage( "MES获取膜卷号接口调用异常:") + ex.Message);
|
|
|
WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, null, beginTime, ex.Message);
|
|
|
}
|
|
|
return sfcStr;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取放卷位EA值
|
|
|
/// </summary>
|
|
|
/// <param name="bindSfc"></param>
|
|
|
/// <param name="logStr"></param>
|
|
|
/// <returns></returns>
|
|
|
private string GetUpMaterialQty(int position,string bindSfc, string logStr)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "通过MES接口获取放卷物料的EA值");
|
|
|
MiSFCQueryQtyServiceServiceParam sFCQueryQtyServiceServiceParam = new MiSFCQueryQtyServiceServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "url"),
|
|
|
loginUser = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "password"),
|
|
|
site = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "site"),
|
|
|
sfc = bindSfc
|
|
|
};
|
|
|
LogHelper.Info(logStr + "完工,MES获取物料EA值接口请求参数:" + JsonChange.ModeToJson(sFCQueryQtyServiceServiceParam));
|
|
|
DateTime beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
var sfcQueryQtyResponse = MesWebServices.iMiSFCQueryQtyServiceService(sFCQueryQtyServiceServiceParam);
|
|
|
LogHelper.Info(logStr + "MES获取物料EA值接口返回参数:" + JsonChange.ModeToJson(sfcQueryQtyResponse));
|
|
|
|
|
|
if (sfcQueryQtyResponse.@return.code > 0)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "MES获取物料EA值接口请求失败:" + sfcQueryQtyResponse.@return.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + bindSfc +LanguageHelper.ShowMessage("通过MES获取放卷物料的EA数量失败:")+ sfcQueryQtyResponse.@return.code+ sfcQueryQtyResponse.@return.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + bindSfc + LanguageHelper.ShowMessage("通过MES获取放卷物料的EA数量失败:") + sfcQueryQtyResponse.@return.code + sfcQueryQtyResponse.@return.message);
|
|
|
//LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + "通过MES获取放卷物料{0}的EA数量失败:{1}", bindSfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message)));
|
|
|
return "";
|
|
|
}
|
|
|
return sfcQueryQtyResponse.@return.qty;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "2600";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info(String.Format(logStr + "MES获取EA数量接口异常:{1}", ex.Message));
|
|
|
WebServiceLog.saveMiSFCQueryQtyServiceService(sFCQueryQtyServiceServiceParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + LanguageHelper.ShowMessage("MES获取EA数量接口异常:"+ ex.Message));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + LanguageHelper.ShowMessage("MES获取EA数量接口异常:" + ex.Message));
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 拆分MES账目数量
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="shaftInfos"></param>
|
|
|
/// <param name="eaValue"></param>
|
|
|
/// <param name="upMaterialSfc"></param>
|
|
|
private async Task<bool> SpiltAccount(int position, ProShaftInfo shaftInfos, int eaValue, string upMaterialSfc, ProUpRecord upRecord, ProDownRecord downRecord)
|
|
|
{
|
|
|
LogHelper.Info("拆分MES账目数量");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("拆分MES账目数量:") + eaValue);
|
|
|
miBatchCompleteSfcAndAdujustQtySfcEntity[] miBatchCompleteSfcAndAdujustQtySfcEntities = new miBatchCompleteSfcAndAdujustQtySfcEntity[1];
|
|
|
shaftInfos.bindEaValue = eaValue.ToString();
|
|
|
|
|
|
miBatchCompleteSfcAndAdujustQtySfcEntities[0] = new miBatchCompleteSfcAndAdujustQtySfcEntity()
|
|
|
{
|
|
|
processLot = shaftInfos.bindRfid,
|
|
|
qty = shaftInfos.bindEaValue,
|
|
|
unit = "EA",
|
|
|
};
|
|
|
|
|
|
//更新绑定信息
|
|
|
await shaftInfoServices.Update(shaftInfos);
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog,LanguageHelper.ShowMessage("调用MES拆分接口"));
|
|
|
LogHelper.Info("调用MES拆分接口");
|
|
|
WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC;
|
|
|
#region 重量特征数据上传 Add By wenjy 2022-12-02 过账模式只拆分不完工
|
|
|
//if (upLoadBusiness.JudgeResourceIsUplpadData())
|
|
|
//{
|
|
|
// modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_NONE;
|
|
|
//}
|
|
|
#endregion
|
|
|
MiBatchCompleteSfcAndAdujustQtyServiceServiceParam requestParam = new MiBatchCompleteSfcAndAdujustQtyServiceServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("SplitSfcParam","url"),
|
|
|
site = inifile.IniReadValue("SplitSfcParam", "site"),
|
|
|
sfcPre = upMaterialSfc,
|
|
|
processLotPre = "",
|
|
|
operation = appConfig.operation, //阳极ANCAP1 //阴极CACAP1
|
|
|
operationRevision = inifile.IniReadValue("SplitSfcParam", "operationRevision"),
|
|
|
resource = appConfig.resource,
|
|
|
user = inifile.IniReadValue("SplitSfcParam", "user"),
|
|
|
loginUser = inifile.IniReadValue("SplitSfcParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("SplitSfcParam", "password"),
|
|
|
activity = inifile.IniReadValue("SplitSfcParam", "activity"),
|
|
|
//modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_NONE,
|
|
|
modeProcessSfc = modeProcessSfc,
|
|
|
sfcList = miBatchCompleteSfcAndAdujustQtySfcEntities,
|
|
|
|
|
|
};
|
|
|
MiBatchCompleteSfcAndAdujustQtyResponse batchCompleteSfcAndAdujustQtyResponse = new MiBatchCompleteSfcAndAdujustQtyResponse();
|
|
|
DateTime beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
LogHelper.Info("MES拆分接口请求参数:" + JsonChange.ModeToJson(requestParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
if (StringExtension.IsBlank(downRecord.Sfc))
|
|
|
{
|
|
|
batchCompleteSfcAndAdujustQtyResponse = MesWebServices.iMiBatchCompleteSfcAndAdujustQtyServiceService(requestParam);
|
|
|
LogHelper.Info("MES拆分接口返回参数:" + JsonChange.ModeToJson(batchCompleteSfcAndAdujustQtyResponse));
|
|
|
|
|
|
var result = batchCompleteSfcAndAdujustQtyResponse.@return;
|
|
|
if (result.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES自动拆分接口调用失败:" + result.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage( "MES自动拆分接口调用失败:") + upLoadBusiness.GetMesMessage(result.code, result.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("MES自动拆分接口调用失败:") + upLoadBusiness.GetMesMessage(result.code, result.message));
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, result.code);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
LogHelper.Info("MES自动拆分接口调用成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog,LanguageHelper.ShowMessage( "MES自动拆分接口调用成功"));
|
|
|
#region 重量特征数据上传 Add By 2022-12-02
|
|
|
//if (appConfig.isMesFlag == 0)
|
|
|
//{
|
|
|
// if (upLoadBusiness.JudgeResourceIsUplpadData()) //判断是否为190品种
|
|
|
// {
|
|
|
// string downSplitMaterialSfc = GetBindSfcByMes(shaftInfos.bindRfid,false);
|
|
|
// downRecord.Sfc = downSplitMaterialSfc;
|
|
|
// downRecord.eaValue = StringChange.ParseToInt(shaftInfos.bindEaValue);
|
|
|
// downRecord.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
// await downRecordServices.Update(downRecord);
|
|
|
|
|
|
// shaftInfos.bindSfc = downSplitMaterialSfc;
|
|
|
// machineIntegrationParametricData[] data = GetMaterialWeight(shaftInfos, upRecord, downRecord);
|
|
|
// if (UpLYMesData(shaftInfos, upRecord, downRecord, data))
|
|
|
// {
|
|
|
// LogHelper.Info("冷压物料特征数据上传成功");
|
|
|
// LogRefreshEvent?.Invoke(LogType.RfidLog, "冷压物料特征数据上传成功");
|
|
|
|
|
|
// return true;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// LogHelper.Info("冷压物料特征数据上传失败");
|
|
|
// LogRefreshEvent?.Invoke(LogType.AlarmLog, "冷压物料特征数据上传失败");
|
|
|
// return false;
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("MES自动拆分接口调用异常", ex);
|
|
|
LogHelper.Info("MES自动拆分接口调用异常:" + ex.Message);
|
|
|
|
|
|
WebServiceLog.saveMiBatchCompleteSfcAndAdujustQtyServiceService(requestParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("MES自动拆分接口调用异常:") + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("MES自动拆分接口调用异常:") + ex.Message);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, 1);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 完工数据
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="shaftInfos"></param>
|
|
|
/// <param name="eaValue"></param>
|
|
|
/// <param name="upMaterialSfc"></param>
|
|
|
private async Task<bool> CompleteAccount(int position, ProShaftInfo shaftInfos, int eaValue, string upMaterialSfc)
|
|
|
{
|
|
|
LogHelper.Info("调用MES完工接口");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("调用MES完工接口"));
|
|
|
miBatchCompleteSfcAndAdujustQtySfcEntity[] miBatchCompleteSfcAndAdujustQtySfcEntities = new miBatchCompleteSfcAndAdujustQtySfcEntity[1];
|
|
|
shaftInfos.bindEaValue = eaValue.ToString();
|
|
|
|
|
|
miBatchCompleteSfcAndAdujustQtySfcEntities[0] = new miBatchCompleteSfcAndAdujustQtySfcEntity()
|
|
|
{
|
|
|
processLot = shaftInfos.bindRfid,
|
|
|
qty = shaftInfos.bindEaValue,
|
|
|
unit = "EA",
|
|
|
};
|
|
|
|
|
|
//更新绑定信息
|
|
|
await shaftInfoServices.Update(shaftInfos);
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "调用MES完工接口");
|
|
|
LogHelper.Info("调用MES完工接口");
|
|
|
MiBatchCompleteSfcAndAdujustQtyServiceServiceParam requestParam = new MiBatchCompleteSfcAndAdujustQtyServiceServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiBatchCompleteSfcAndAdujustQtyServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//sfcPre = shaftInfos.bindSfc,
|
|
|
//processLotPre = "",
|
|
|
//operation = appConfig.operation, //阳极ANCAP1 //阴极CACAP1
|
|
|
//operationRevision = "A",
|
|
|
//resource = appConfig.resource,
|
|
|
//user = "SUP_LY3_CL09",
|
|
|
//activity = "Z_PR571",
|
|
|
url = inifile.IniReadValue("SplitSfcParam","url"),
|
|
|
site = inifile.IniReadValue("SplitSfcParam", "site"),
|
|
|
sfcPre = shaftInfos.bindSfc,
|
|
|
processLotPre = "",
|
|
|
operation = appConfig.operation, //阳极ANCAP1 //阴极CACAP1
|
|
|
operationRevision = inifile.IniReadValue("SplitSfcParam", "operationRevision"),
|
|
|
resource = appConfig.resource,
|
|
|
user = inifile.IniReadValue("SplitSfcParam", "user"),
|
|
|
loginUser = inifile.IniReadValue("SplitSfcParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("SplitSfcParam", "password"),
|
|
|
activity = inifile.IniReadValue("SplitSfcParam", "activity"),
|
|
|
modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC,//只拆分-new
|
|
|
sfcList = miBatchCompleteSfcAndAdujustQtySfcEntities,
|
|
|
};
|
|
|
MiBatchCompleteSfcAndAdujustQtyResponse batchCompleteSfcAndAdujustQtyResponse = new MiBatchCompleteSfcAndAdujustQtyResponse();
|
|
|
DateTime beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
LogHelper.Info("MES完工接口请求参数:" + JsonChange.ModeToJson(requestParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
batchCompleteSfcAndAdujustQtyResponse = MesWebServices.iMiBatchCompleteSfcAndAdujustQtyServiceService(requestParam);
|
|
|
LogHelper.Info("MES完工接口返回参数:" + JsonChange.ModeToJson(batchCompleteSfcAndAdujustQtyResponse));
|
|
|
var result = batchCompleteSfcAndAdujustQtyResponse.@return;
|
|
|
|
|
|
if (result.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES自动完工接口调用失败:" + result.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES自动完工接口调用失败:" + upLoadBusiness.GetMesMessage(result.code, result.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动完工接口调用失败:" + upLoadBusiness.GetMesMessage(result.code, result.message));
|
|
|
//sendError(position, 1, true,result.code);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, result.code);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("MES自动完工接口调用异常:" + ex.Message);
|
|
|
WebServiceLog.saveMiBatchCompleteSfcAndAdujustQtyServiceService(requestParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES自动完工接口异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动完工接口异常:" + ex.Message);
|
|
|
//sendError(position, 1, true,1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, 1);
|
|
|
return false;
|
|
|
}
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动完工接口调用成功");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断PLC地址中是否还存在该膜卷号,避免直接拆最后一卷
|
|
|
/// </summary>
|
|
|
/// <param name="bindSfc"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool GetSameSfcByPlc(string bindSfc, int position)
|
|
|
{
|
|
|
string SJ_1A = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
string SJ_1B = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
string SJ_2A = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
string SJ_2B = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
|
|
|
if (position != 1)
|
|
|
{
|
|
|
if (!SJ_1A.IsBlank() && SJ_1A.Length == 18)
|
|
|
{
|
|
|
if (SJ_1A == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (position != 2)
|
|
|
{
|
|
|
if (!SJ_1B.IsBlank() && SJ_1B.Length == 18)
|
|
|
{
|
|
|
if (SJ_1B == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
if (position != 3)
|
|
|
{
|
|
|
if (!SJ_2A.IsBlank() && SJ_2A.Length == 18)
|
|
|
{
|
|
|
if (SJ_2A == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
if (position != 4)
|
|
|
{
|
|
|
if (!SJ_2B.IsBlank() && SJ_2B.Length == 18)
|
|
|
{
|
|
|
if (SJ_2B == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 放卷涨紧手动写入
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="epc"></param>
|
|
|
/// <param name="auto"></param>
|
|
|
public async void MesBegin(int position, string epc, bool auto)
|
|
|
{
|
|
|
string sfc = "";
|
|
|
string qty = "";
|
|
|
try
|
|
|
{
|
|
|
|
|
|
//手动写入清除放卷位报警
|
|
|
if (!auto)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.手动上料, 1);
|
|
|
}
|
|
|
if (position == 0)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A手动上料, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.B手动上料, 0);
|
|
|
}
|
|
|
string binSfc = GetBindSfcByMes(epc, true);//add by liulb 2022-11-09
|
|
|
//add by 20250221 新增写入涂布膜卷号
|
|
|
//PlcBusiness.writeStrPlc(appConfig.LyAddress.放卷方向, binSfc);
|
|
|
|
|
|
//LogHelper.Info($"获取涂布材料膜卷号{binSfc}");
|
|
|
|
|
|
LogHelper.Info("调用MES首工序获取SFC接口");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage( "调用MES首工序获取SFC接口"));
|
|
|
//LogRefreshEvent?.Invoke(LogType.RfidLog, "调用MES首工序获取SFC接口");
|
|
|
//调MES首工序获取SFC接口
|
|
|
MiFirstOperationForsfcServiceServiceParam miFirstOperationForsfcServiceServiceParam = new MiFirstOperationForsfcServiceServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "site"),
|
|
|
sfc = "",
|
|
|
processLot = epc,
|
|
|
operation = appConfig.operation,
|
|
|
operationRevision = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "operationRevision"),
|
|
|
resource = appConfig.resource,
|
|
|
user = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "user"),
|
|
|
activity = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "activity"),
|
|
|
modeProcessSfc = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "modeProcessSfc"),
|
|
|
loginUser = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "password")
|
|
|
};
|
|
|
LogHelper.Info("MES首工序获取SFC接口请求参数:" + JsonChange.ModeToJson(miFirstOperationForsfcServiceServiceParam));
|
|
|
miFirstOperationForsfcResponse firstOperationForsfcResponse = new miFirstOperationForsfcResponse();
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
DateTime beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
firstOperationForsfcResponse = MesWebServices.iMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam);
|
|
|
LogHelper.Info("MES首工序获取SFC接口返回参数:" + JsonChange.ModeToJson(firstOperationForsfcResponse));
|
|
|
|
|
|
//判断返回结果
|
|
|
if (firstOperationForsfcResponse.@return.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES首工序获取SFC接口请求失败:" + firstOperationForsfcResponse.@return.message);
|
|
|
if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
//手动写入自动下降U型块
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
}
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, firstOperationForsfcResponse.@return.code);
|
|
|
LogHelper.Info("MES首工序获取SFC接口调用失败,下发PLC泄气报警信号," + firstOperationForsfcResponse.@return.message);
|
|
|
//LogRefreshEvent?.Invoke(LogType.RfidLog, "MES首工序获取SFC接口调用失败");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage( "MES首工序获取SFC接口调用失败:") + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("MES首工序获取SFC接口调用失败:") + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog,LanguageHelper.ShowMessage( "MES首工序获取SFC接口调用失败,下发PLC泄气报警信号"));
|
|
|
return;
|
|
|
}
|
|
|
sfc = firstOperationForsfcResponse.@return.sfc;
|
|
|
qty = firstOperationForsfcResponse.@return.qty;
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("MES首工序获取SFC接口调用成功,"+"SFC:"+ sfc + "EA:"+ qty));
|
|
|
LogHelper.Info(String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty));
|
|
|
if (!appConfig.PLCType.Contains("LY4"))
|
|
|
{
|
|
|
if (!auto)
|
|
|
{
|
|
|
inifile2.IniWriteValue("SystemConfig", "isAutoWrite", "是");
|
|
|
if (position == 0)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A手动上料, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.B手动上料, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.B放卷上料OK, 1);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("调用MES首工序获取SFC接口异常:" + ex.Message);
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage( "调用MES首工序获取SFC接口异常:") + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("调用MES首工序获取SFC接口异常:")+ ex.Message);
|
|
|
WebServiceLog.saveMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam, null
|
|
|
, beginTime, ex.Message);
|
|
|
if (position == 0)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A手动上料, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.B手动上料, 0);
|
|
|
}
|
|
|
if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
//手动写入自动下降U型块
|
|
|
}
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, 1);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//sfc = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
//LYL3PC022308240064
|
|
|
Random random = new Random();
|
|
|
sfc = "LYL3PC0223082400" + random.Next(10, 99);
|
|
|
qty = "2000";
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty));
|
|
|
|
|
|
}
|
|
|
if (appConfig.PLCType == ("LY4NKLYPLcAddress"))
|
|
|
{
|
|
|
inifile2.IniWriteValue("SystemConfig", "isAutoWrite", "是");
|
|
|
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
//手动写入自动下降U型块
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A手动上料, 1);
|
|
|
}
|
|
|
if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
//手动写入自动下降U型块
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A手动上料, 1);
|
|
|
}
|
|
|
if (appConfig.PLCType == ("HNLYPLcAddress")|| appConfig.PLCType == ("NKLYPLcAddress"))
|
|
|
{
|
|
|
if (position == 0)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.A放卷上料OK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.B放卷上料OK, 1);
|
|
|
}
|
|
|
}
|
|
|
if(position == 0)
|
|
|
{
|
|
|
PlcBusiness.writeStrPlc(appConfig.LyAddress.A放卷SFC, sfc);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
PlcBusiness.writeStrPlc(appConfig.LyAddress.B放卷SFC, sfc);
|
|
|
}
|
|
|
//LogHelper.Info("冷压放卷流程处理成功,D6014写0");
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.放卷上料OK, 1);
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, LanguageHelper.ShowMessage("放卷位物料SFC写入PLC地址:") + sfc);
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
sfc = sfc,
|
|
|
position = position,
|
|
|
ea = qty,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
|
|
|
//实时绑定卷轴与RFID信息
|
|
|
LogHelper.Info(String.Format("绑定放卷轴与RFID:{0};获取卷轴信息", epc));
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position);
|
|
|
|
|
|
if (shaftInfo == null || StringExtension.IsBlank(shaftInfo.processId))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("绑定卷轴与RFID,获取卷轴信息为空"));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("绑定卷轴与RFID,获取卷轴信息为空"));
|
|
|
LogHelper.Info("绑定卷轴与RFID,获取卷轴信息为空");
|
|
|
return;
|
|
|
}
|
|
|
LogHelper.Info("获取卷轴信息为:" + JsonChange.ModeToJson(shaftInfo));
|
|
|
shaftInfo.bindRfid = epc;
|
|
|
shaftInfo.bindSfc = sfc;
|
|
|
shaftInfo.bindEaValue = qty;
|
|
|
shaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
await shaftInfoServices.Update(shaftInfo);
|
|
|
|
|
|
//本地保存SFC,上料记录
|
|
|
ProUpRecord upRecord = new ProUpRecord()
|
|
|
{
|
|
|
Id = System.Guid.NewGuid().ToString(),
|
|
|
MachineId = appConfig.machineId,
|
|
|
UpMaterialId = binSfc, //存放涂布来料膜卷号
|
|
|
PositionId = position,
|
|
|
Rfid = epc,
|
|
|
Sfc = sfc,
|
|
|
eaValue = StringChange.ParseToInt(qty),
|
|
|
IsProduction = 0,
|
|
|
beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
};
|
|
|
await upRecordServices.Add(upRecord);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("放卷涨紧手动写入异常", ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断是否合卷
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private bool JudgementMaterial(string sfc)
|
|
|
{
|
|
|
|
|
|
if (ConfigHelper.GetConfig("isJudgementMaterial") == "0")
|
|
|
{
|
|
|
//LogHelper.Info("冷压合卷判断功能未启用");
|
|
|
//LogRefreshEvent?.Invoke(LogType.RfidLog, "冷压合卷判断功能未启用");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
LogHelper.Info("判断是否合卷,放卷位SFC:" + sfc);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage( "判断是否合卷,放卷位SFC:") + sfc);
|
|
|
//获取正在生产收卷轴绑定的SFC
|
|
|
string downSfc = "";
|
|
|
//1A
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1A状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)18).Replace("\0", "").Trim().Substring(0,18);
|
|
|
LogHelper.Info("1A轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("1A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A"+LanguageHelper.ShowMessage("绑定膜卷号为空,不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("1A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A,SFC:" + downSfc + "="+ sfc + LanguageHelper.ShowMessage("和放卷位SFC相同不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("1A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A,SFC:" + downSfc +"!="+ sfc + LanguageHelper.ShowMessage("和放卷位SFC不同触发合卷报警"));
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
//1B
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1B状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18);
|
|
|
LogHelper.Info("1B轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("1B轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1B" + LanguageHelper.ShowMessage("绑定膜卷号为空,不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("1B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1B,SFC:" + downSfc + "=" + sfc + LanguageHelper.ShowMessage("和放卷位SFC相同不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("1B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1B,SFC:" + downSfc + "!=" + sfc + LanguageHelper.ShowMessage("和放卷位SFC不同触发合卷报警"));
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
//2A
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2A状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18);
|
|
|
LogHelper.Info("2A轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("2A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2A" + LanguageHelper.ShowMessage("绑定膜卷号为空,不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("2A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2A,SFC:" + downSfc + "=" + sfc + LanguageHelper.ShowMessage("和放卷位SFC相同不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("2A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2A,SFC:" + downSfc + "!=" + sfc + LanguageHelper.ShowMessage("和放卷位SFC不同触发合卷报警"));
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
//2B
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2B状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18);
|
|
|
LogHelper.Info("2B轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("2B轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2B" + LanguageHelper.ShowMessage("绑定膜卷号为空,不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("2B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2B,SFC:" + downSfc + "=" + sfc + LanguageHelper.ShowMessage("和放卷位SFC相同不触发合卷报警"));
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("2B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2B,SFC:" + downSfc + "!=" + sfc + LanguageHelper.ShowMessage("和放卷位SFC不同触发合卷报警"));
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 赢和厂家单独逻辑判断对应轴读取NG泄气
|
|
|
/// </summary>
|
|
|
public void WriteNGToPLC(int position)
|
|
|
{
|
|
|
if (appConfig.PLCType == "LY4YHLYPLcAddress")
|
|
|
{
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 2);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 2);
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 2);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 2);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 0);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 0);
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 0);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
public void ClearSuccessOkSignal(int position)
|
|
|
{
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 0);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 0);
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 0);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷成功气胀信号
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void sendSuccessByDownBegin(int position)
|
|
|
{
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 0);
|
|
|
|
|
|
if (position == 1)
|
|
|
{
|
|
|
if (!appConfig.PLCType.Contains("LY4"))
|
|
|
{
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 1);
|
|
|
}
|
|
|
if(appConfig.PLCType == "LY4NKLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 1);
|
|
|
}
|
|
|
if (appConfig.PLCType == "LY4YHLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 0);
|
|
|
}
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
if (!appConfig.PLCType.Contains("LY4"))
|
|
|
{
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 1);
|
|
|
}
|
|
|
if (appConfig.PLCType == "LY4NKLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 1);
|
|
|
}
|
|
|
if (appConfig.PLCType == "LY4YHLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
if (!appConfig.PLCType.Contains("LY4"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 1);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料2AOK, 0);
|
|
|
}
|
|
|
if (appConfig.PLCType == "LY4NKLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 1);
|
|
|
}
|
|
|
if (appConfig.PLCType == "LY4YHLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (position == 4) {
|
|
|
|
|
|
if (!appConfig.PLCType.Contains("LY4"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 1);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料2BOK, 0);
|
|
|
}
|
|
|
if (appConfig.PLCType == "LY4NKLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 1);
|
|
|
}
|
|
|
if (appConfig.PLCType == "LY4YHLYPLcAddress")
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 下料成功
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void sendSuccess(int position)
|
|
|
{
|
|
|
if (position == 1)
|
|
|
{
|
|
|
if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料1AOK, 1);
|
|
|
}
|
|
|
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料1BOK, 1);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料2AOK, 1);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 1);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料2BOK, 1);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 1);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁止下料
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void sendError(int position)
|
|
|
{
|
|
|
if (appConfig.PLCType == ("LY4NKLYPLcAddress")|| appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
if (position == 1) plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 2);
|
|
|
if (position == 2) plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 2);
|
|
|
if (position == 3) plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 2);
|
|
|
if (position == 4) plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1) plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1);
|
|
|
if (position == 2) plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1);
|
|
|
if (position == 3) plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 1);
|
|
|
if (position == 4) plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 1);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 异常下发
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="errorType"></param>
|
|
|
/// <param name="isFinish"></param>
|
|
|
public void sendError(int position, int errorType, bool isFinish, int mesCode)
|
|
|
{
|
|
|
if (isFinish)
|
|
|
{
|
|
|
if (errorType == 1) //MES异常
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, mesCode);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (errorType == 1) //MES异常
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, mesCode);
|
|
|
}
|
|
|
if (errorType == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 解绑RFID与SFC
|
|
|
/// </summary>
|
|
|
/// <param name="rfidStr"></param>
|
|
|
public void UnBindRfidAndSfc(string rfidStr)
|
|
|
{
|
|
|
//获取当前RFID是否绑定
|
|
|
|
|
|
//string sfcStr = GetSfcByRfid(rfidStr);
|
|
|
string[] strlist = GetSfcListByRfid(rfidStr);
|
|
|
|
|
|
DateTime beginTime = new DateTime();
|
|
|
if (strlist != null && strlist.Count() > 0)
|
|
|
{
|
|
|
ProcessLotServiceWSServiceParam lotServiceWSServiceParam = new ProcessLotServiceWSServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"),
|
|
|
processlotref = "ProcessLotBO:2100," + rfidStr,
|
|
|
memberlist = strlist,
|
|
|
loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password")
|
|
|
};
|
|
|
LogHelper.Info("MES解绑接口请求参数:" + JsonChange.ModeToJson(lotServiceWSServiceParam));
|
|
|
beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
removeMemberResponse removeMember = MesWebServices.iRemoveMember(lotServiceWSServiceParam);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, rfidStr+ LanguageHelper.ShowMessage("RFID条码成功解绑SFC!"));
|
|
|
|
|
|
LogHelper.Info("MES解绑接口返回参数:" + JsonChange.ModeToJson(removeMember));
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
WebServiceLog.saveRemoveMember(lotServiceWSServiceParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, rfidStr+ LanguageHelper.ShowMessage("RFID条码解绑失败!")+ ex.Message);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("RFID条码:" + rfidStr + "未绑定SFC信息");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, rfidStr+LanguageHelper.ShowMessage("RFID条码未绑定SFC信息"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据设备位置获取卷轴信息
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<ProShaftInfo> GetShaftInfoByPosition(int position)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string str = appConfig.processId;
|
|
|
Expression<Func<ProShaftInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.positionId == position.ToString() && x.processId == str);
|
|
|
List<ProShaftInfo> result = await shaftInfoServices.Query(exp);
|
|
|
|
|
|
if (result != null || result.Count > 0)
|
|
|
{
|
|
|
ProShaftInfo shaftInfo = result.FirstOrDefault();
|
|
|
return shaftInfo;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("获取卷轴绑定信息为空"));
|
|
|
LogHelper.Info("获取卷轴绑定信息异常:" + ex.Message);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷结束获取最后一卷
|
|
|
/// </summary>
|
|
|
private async void UpdateShaftEndFlag(int position)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
List<ProShaftInfo> shaftInfos = new List<ProShaftInfo>();
|
|
|
string logStr = Which(position);
|
|
|
|
|
|
List<int> positionList = PositionToList(position);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+ LanguageHelper.ShowMessage("当前收卷位生产轴:"));
|
|
|
//获取卷轴绑定的物料信息
|
|
|
foreach (var item in positionList)
|
|
|
{
|
|
|
//获取当前卷轴绑定的物料信息
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(item);
|
|
|
|
|
|
if (StringExtension.IsBlank(shaftInfo.bindRfid))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷结束,判断最后一卷收卷物料获取收卷位绑定信息为空"));
|
|
|
LogHelper.Info("放卷结束,判断最后一卷收卷物料获取收卷位绑定信息为空," + logStr);
|
|
|
continue;
|
|
|
}
|
|
|
LogHelper.Info(String.Format("{0}当前绑定的物料信息为:{1}", logStr, JsonChange.ModeToJson(shaftInfo)));
|
|
|
if (appConfig.PLCType == ("LY4NKLYPLcAddress"))
|
|
|
{
|
|
|
//1出1不区分前后轴
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "1")
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+ LanguageHelper.ShowMessage("放卷结束,确定最后一卷收卷物料轴RFID条码为:") + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage( "最后收卷物料标识修改成功"));
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage( "最后收卷物料标识修改失败"));
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
if (position > 2)
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr+ LanguageHelper.ShowMessage( "放卷结束,确定最后一卷收卷物料轴RFID条码为:") + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改成功"));
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改失败"));
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (item == 5 || item == 8)
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷结束,确定最后一卷收卷物料轴RFID条码为:") + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改成功"));
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改失败"));
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//1出1不区分前后轴
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "1")
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷结束,确定最后一卷收卷物料轴RFID条码为:") + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改成功"));
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改失败"));
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
if (position > 2)
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷结束,确定最后一卷收卷物料轴RFID条码为:") + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改成功"));
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改失败"));
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (item == 5 || item == 8)
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷结束,确定最后一卷收卷物料轴RFID条码为:") + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改成功"));
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改失败"));
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "4")
|
|
|
{
|
|
|
if (item == 5 || item == 8)
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷结束,确定最后一卷收卷物料轴RFID条码为:") + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改成功"));
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("最后收卷物料标识修改失败"));
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("放卷结束判断最后一卷物料逻辑处理异常", ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 强制下料
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void ForceDown(int position)
|
|
|
{
|
|
|
string logStr = Which(position);
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + LanguageHelper.ShowMessage("异常下料信号触发,下发下料信号"));
|
|
|
switch (position)
|
|
|
{
|
|
|
case 1:
|
|
|
|
|
|
LogHelper.Info("1A轴异常下料信号触发,下发下料信号");
|
|
|
|
|
|
if (appConfig.PLCType == ("LY4NKLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1);
|
|
|
}
|
|
|
else if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料1AOK, 1);
|
|
|
}
|
|
|
break;
|
|
|
case 2:
|
|
|
//LogRefreshEvent?.Invoke(LogType.PlcLog, "1B轴异常下料信号触发,下发下料信号");
|
|
|
LogHelper.Info("1B轴异常下料信号触发,下发下料信号");
|
|
|
|
|
|
if (appConfig.PLCType == ("LY4NKLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1);
|
|
|
}
|
|
|
else if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料1BOK, 1);
|
|
|
}
|
|
|
break;
|
|
|
case 3:
|
|
|
//LogRefreshEvent?.Invoke(LogType.PlcLog, "2A轴异常下料信号触发,下发下料信号");
|
|
|
LogHelper.Info("2A轴异常下料信号触发,下发下料信号");
|
|
|
|
|
|
if (appConfig.PLCType == ("LY4NKLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料,1);
|
|
|
}
|
|
|
else if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料2AOK, 1);
|
|
|
}
|
|
|
break;
|
|
|
case 4:
|
|
|
//LogRefreshEvent?.Invoke(LogType.PlcLog, "2B轴异常下料信号触发,下发下料信号");
|
|
|
LogHelper.Info("2B轴异常下料信号触发,下发下料信号");
|
|
|
|
|
|
if (appConfig.PLCType == ("LY4NKLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料,1);
|
|
|
}
|
|
|
else if (appConfig.PLCType == ("LY4YHLYPLcAddress"))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 0);
|
|
|
//plcBusiness.writePlc(appConfig.LyAddress.收卷下料2BOK, 1);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷位开始信号
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void DownBegin(int position)
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断串读
|
|
|
/// </summary>
|
|
|
/// <param name="epc"></param>
|
|
|
/// <param name="position"></param>
|
|
|
/// <returns></returns>
|
|
|
private async Task<bool> PdRfidIsChuanDu(string epc, int position)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
LogHelper.Info("RFID条码:" + epc + "判断是否串读逻辑处理");
|
|
|
Expression<Func<ProShaftInfo, bool>> exp = s1 => true;
|
|
|
if (position == 1)
|
|
|
{
|
|
|
exp = exp.And(x => x.bindRfid == epc && x.positionId != "1" && x.positionId != "2" && x.processId == appConfig.processId);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
exp = exp.And(x => x.bindRfid == epc && x.positionId != "3" && x.positionId != "4" && x.processId == appConfig.processId);
|
|
|
}
|
|
|
|
|
|
if (position == 3)
|
|
|
{
|
|
|
exp = exp.And(x => x.bindRfid == epc && x.positionId != "5" && x.processId == appConfig.processId);
|
|
|
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
exp = exp.And(x => x.bindRfid == epc && x.positionId != "8" && x.processId == appConfig.processId);
|
|
|
}
|
|
|
List<ProShaftInfo> shaftInfos = await shaftInfoServices.Query(exp);
|
|
|
if (shaftInfos.Count > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("串读逻辑处理异常", ex);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private List<int> PositionToList(int position)
|
|
|
{
|
|
|
string logStr = "";
|
|
|
List<int> positionList = new List<int>();
|
|
|
if (position == 1)
|
|
|
{
|
|
|
positionList.Clear();
|
|
|
logStr = "1A轴";
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2"|| ConfigHelper.GetConfig("tagAmount") == "1")
|
|
|
{
|
|
|
positionList.Add(2);
|
|
|
//冷压1拆2用小天线
|
|
|
//positionList.Add(1);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(1);
|
|
|
positionList.Add(2);
|
|
|
}
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
positionList.Clear();
|
|
|
logStr = "1B轴";
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2" || ConfigHelper.GetConfig("tagAmount") == "1")
|
|
|
{
|
|
|
positionList.Add(3);
|
|
|
//冷压1拆2用小天线
|
|
|
//positionList.Add(4);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(4);
|
|
|
positionList.Add(3);
|
|
|
}
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
logStr = "2A轴";
|
|
|
positionList.Clear();
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2" || ConfigHelper.GetConfig("tagAmount") == "1")
|
|
|
{
|
|
|
//positionList.Add(6);
|
|
|
positionList.Add(5);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(6);
|
|
|
positionList.Add(5);
|
|
|
}
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
logStr = "2B轴";
|
|
|
positionList.Clear();
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2" || ConfigHelper.GetConfig("tagAmount") == "1")
|
|
|
{
|
|
|
//positionList.Add(7);
|
|
|
positionList.Add(8);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(8);
|
|
|
positionList.Add(7);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return positionList;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
///判断当前是哪个轴
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private string Which(int position)
|
|
|
{
|
|
|
string logStr = "";
|
|
|
if (position == 1) logStr = "1A";
|
|
|
if (position == 2) logStr = "1B";
|
|
|
if (position == 3) logStr = "2A";
|
|
|
if (position == 4) logStr = "2B";
|
|
|
return logStr;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 设备启动
|
|
|
/// </summary>
|
|
|
public void MachineStartUp()
|
|
|
{
|
|
|
#region Delete By wenjy 2022-12-27 ME要求改为原逻辑
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, LanguageHelper.ShowMessage("开机启动信号触发成功"));
|
|
|
LogHelper.Info("开机启动信号触发成功");
|
|
|
//通过PLC地址获取放卷膜卷号
|
|
|
string sfc = "";
|
|
|
int FJAstate = PlcBusiness.readPlc(appConfig.LyAddress.放卷A状态);
|
|
|
if (FJAstate == 1)
|
|
|
{
|
|
|
sfc = PlcBusiness.readStrPlc(appConfig.LyAddress.A放卷SFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18);
|
|
|
}
|
|
|
int FJBstate = PlcBusiness.readPlc(appConfig.LyAddress.放卷B状态);
|
|
|
if (FJBstate == 1)
|
|
|
{
|
|
|
sfc = PlcBusiness.readStrPlc(appConfig.LyAddress.B放卷SFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18);
|
|
|
}
|
|
|
|
|
|
//JudgementMaterial(放卷膜卷号),返回true合卷报警=>PLC 写报警值,返回false不处理
|
|
|
if (StringExtension.IsNotBlank(sfc))
|
|
|
{
|
|
|
// 判断合卷
|
|
|
if (JudgementMaterial(sfc))
|
|
|
{
|
|
|
LogHelper.Info("触发合卷报警,下发PLC报警指令");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog,LanguageHelper.ShowMessage("放卷位与收卷位膜卷号不同触发合卷报警"));
|
|
|
// 写入合卷报警
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.合卷报警, 1);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷位物料是否结束生产
|
|
|
/// </summary>
|
|
|
/// <param name="epc"></param>
|
|
|
private async Task<bool> UpMaterialIsEndProduction(string rfidStr)
|
|
|
{
|
|
|
bool result = false;
|
|
|
//通过MES获取RFID绑定的SFC并判断是否结束,冷压来料RFID绑定为涂布膜卷号,暂不使用SFC判断,使用RFID判断
|
|
|
string sfcStr = GetSfcByRfid(rfidStr);
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, rfidStr+LanguageHelper.ShowMessage("RFID绑定的膜卷号:") + sfcStr);
|
|
|
//通过SFC判断该卷物料是否已经生产结束,如果已生产返回true,未生产返回false
|
|
|
//upRecordServices
|
|
|
Expression<Func<ProUpRecord, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.Rfid == rfidStr);
|
|
|
Expression<Func<ProUpRecord, object>> order = s1 => s1.RecordTime;
|
|
|
ProUpRecord upRecord = await upRecordServices.QueryFirst(exp, order, false);
|
|
|
if (upRecord != null)
|
|
|
{
|
|
|
if (StringExtension.IsBlank(upRecord.endTime))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("当前SFC放卷结束时间为空,生产未结束"+ sfcStr));
|
|
|
result = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, sfcStr+ LanguageHelper.ShowMessage("当前SFC放卷结束时间为:"+ upRecord.endTime));
|
|
|
result = true;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 通过RFID获取SFC
|
|
|
/// </summary>
|
|
|
/// <param name="rfidStr"></param>
|
|
|
/// <returns></returns>
|
|
|
private string[] GetSfcListByRfid(string rfidStr)
|
|
|
{
|
|
|
string[] sfcStr = new string[0];
|
|
|
string strlog = "";
|
|
|
DateTime beginTime = new DateTime();
|
|
|
ProcessLotServiceWSServiceParam processLotServiceWSServiceParam = new ProcessLotServiceWSServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/manufacturing-papiservices/ProcessLotServiceWSService?wsdl",
|
|
|
//site = "2100",
|
|
|
url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"),
|
|
|
processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr),
|
|
|
loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password")
|
|
|
};
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("调用MES接口获取RFID绑定的SFC"));
|
|
|
LogHelper.Info("MES获取SFC接口请求参数:" + JsonChange.ModeToJson(processLotServiceWSServiceParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
readProcessLotResponse readProcessLotResponse = MesWebServices.readProcessLot(processLotServiceWSServiceParam);
|
|
|
LogHelper.Info("MES获取SFC接口返回参数:" + JsonChange.ModeToJson(readProcessLotResponse));
|
|
|
if (readProcessLotResponse.Response.processLotMemberList != null)
|
|
|
{
|
|
|
sfcStr = new string[readProcessLotResponse.Response.processLotMemberList.Count()];
|
|
|
for (int i = 0; i < readProcessLotResponse.Response.processLotMemberList.Count(); i++)
|
|
|
{
|
|
|
sfcStr[i] = readProcessLotResponse.Response.processLotMemberList[i].memberContext;
|
|
|
strlog += "RFID:" + rfidStr + "SFC:" + sfcStr[i].Substring(11) + "\r\n";
|
|
|
}
|
|
|
|
|
|
LogHelper.Info(strlog);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, strlog);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//sfcStr = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
Random random = new Random();
|
|
|
sfcStr[0] = "LYL3PC0223082400" + random.Next(10, 99);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
LogHelper.Info("MES获取SFC接口异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog,LanguageHelper.ShowMessage("调用MES获取SFC接口异常:") + ex.Message);
|
|
|
return null;
|
|
|
//WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, null, beginTime, ex.Message);
|
|
|
}
|
|
|
return sfcStr;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 通过RFID获取SFC
|
|
|
/// </summary>
|
|
|
/// <param name="rfidStr"></param>
|
|
|
/// <returns></returns>
|
|
|
private string GetSfcByRfid(string rfidStr)
|
|
|
{
|
|
|
string sfcStr = "";
|
|
|
DateTime beginTime = new DateTime();
|
|
|
ProcessLotServiceWSServiceParam processLotServiceWSServiceParam = new ProcessLotServiceWSServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"),
|
|
|
loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"),
|
|
|
password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password"),
|
|
|
processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr)
|
|
|
};
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("调用MES接口获取RFID绑定的SFC"));
|
|
|
LogHelper.Info("MES获取SFC接口请求参数:" + JsonChange.ModeToJson(processLotServiceWSServiceParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
readProcessLotResponse readProcessLotResponse = MesWebServices.readProcessLot(processLotServiceWSServiceParam);
|
|
|
LogHelper.Info("MES获取SFC接口返回参数:" + JsonChange.ModeToJson(readProcessLotResponse));
|
|
|
if (readProcessLotResponse.Response.processLotMemberList != null)
|
|
|
{
|
|
|
sfcStr = readProcessLotResponse.Response.processLotMemberList[0].memberContext.Substring(11);
|
|
|
LogHelper.Info("RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, rfidStr+ LanguageHelper.ShowMessage("RFID条码绑定的SFC条码为:" + sfcStr));
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//sfcStr = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
Random random = new Random();
|
|
|
sfcStr = "LYL3PC0223082400" + random.Next(10, 99);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
sendError(0, 1, false, 1);
|
|
|
LogHelper.Info("MES获取SFC接口调用异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, LanguageHelper.ShowMessage("调用MES获取SFC接口异常:") + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, LanguageHelper.ShowMessage("调用MES获取SFC接口异常:") + ex.Message);
|
|
|
WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, null, beginTime, ex.Message);
|
|
|
}
|
|
|
return sfcStr;
|
|
|
}
|
|
|
}
|
|
|
}
|