|
|
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.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 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;
|
|
|
|
|
|
///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
|
|
|
{
|
|
|
#region 未登录不让放卷涨紧生产,便于记录生产者
|
|
|
/*if (StringExtension.IsBlank(ConfigHelper.GetConfig("roleId")))
|
|
|
{
|
|
|
MessageBox.Show("请先登录再开始生产");
|
|
|
LogHelper.Info("请先登录再开始生产");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "请先登录再开始生产");
|
|
|
|
|
|
return;
|
|
|
}*/
|
|
|
#endregion
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "冷压放卷位涨紧信号触发成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "冷压放卷位涨紧信号触发成功");
|
|
|
LogHelper.Info("冷压放卷位涨紧信号触发成功");
|
|
|
|
|
|
//读取卷筒RFID物料信息
|
|
|
ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == position).FirstOrDefault();
|
|
|
if (proEquip == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "获取放卷位读写器设备信息异常");
|
|
|
return;
|
|
|
}
|
|
|
string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId);
|
|
|
epc = epc.Replace("\0", "").Trim();
|
|
|
SaveReadRecord(proEquip, epc);
|
|
|
if (StringExtension.IsBlank(epc))
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
LogHelper.Info("放卷位RFID条码信息读取失败,下发PLC报警D6024写1");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷位RFID条码信息读取失败");
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = "",
|
|
|
sfc = "",
|
|
|
ea = "",
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
LogHelper.Info(String.Format("放卷位RFID条码信息读取成功:{0}", epc));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("放卷位RFID条码信息读取成功,RFID为{0}", epc));
|
|
|
//判断RFID标签是否重复
|
|
|
LogHelper.Info("判断RFID标签是否重复");
|
|
|
if (BusinessHelper.UpRfidIsRecur(epc, position).Result)
|
|
|
{
|
|
|
|
|
|
//判断是否已经生产结束
|
|
|
if (UpMaterialIsEndProduction(epc).Result)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc));
|
|
|
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)
|
|
|
{
|
|
|
PlcBusiness.writeStrPlc(appConfig.LyAddress.放卷SFC, upRecord.Sfc);
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
sfc = upRecord.Sfc,
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
}
|
|
|
LogHelper.Info("放卷位RFID读取到的条码:" + epc + "与前一读取相同并且生产未结束,可以继续生产");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷位RFID读取到的条码:" + epc + "与前一读取相同并且生产未结束,可以继续生产");
|
|
|
LogHelper.Info("冷压放卷流程处理成功,D6014写0");
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.放卷OK, 0);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
//读取数据刷新
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
//sfc = "",
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
MesBegin(position, epc, true);
|
|
|
}
|
|
|
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
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "冷压放卷位结束信号触发成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "冷压放卷位结束信号触发成功");
|
|
|
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)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷结束,获取上料信息为空");
|
|
|
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, "生成放卷信息");
|
|
|
|
|
|
upLoadBusiness.UpdateUpRecord(upRecord);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("冷压放卷位结束逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "冷压放卷位结束逻辑处理异常" + 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 + "收卷位涨紧信号触发成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "收卷位涨紧信号触发成功");
|
|
|
LogHelper.Info(logStr + "收卷位涨紧信号触发成功");
|
|
|
|
|
|
if (StringExtension.IsBlank(PlcBusiness.readStrPlc(appConfig.LyAddress.放卷SFC, 32)))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷位物料信息为空,先触发放卷位物料信息");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("开始读取{0}卷筒RFID物料信息", logStr));
|
|
|
|
|
|
List<TagMessage> positionTag = equipBusiness.ReadEPCByAntanaGroup(positionList);
|
|
|
foreach (var item in positionList)
|
|
|
{
|
|
|
if (item == 1) logStr = "1A轴小天线";
|
|
|
if (item == 2) logStr = "1A轴大天线";
|
|
|
if (item == 3) logStr = "1B轴大天线";
|
|
|
if (item == 4) logStr = "1B轴小天线";
|
|
|
if (item == 5) logStr = "2A轴小天线";
|
|
|
if (item == 6) logStr = "2A轴大天线";
|
|
|
if (item == 7) logStr = "2B轴大天线";
|
|
|
if (item == 8) logStr = "2B轴小天线";
|
|
|
|
|
|
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 + "读到标签条码信息:" + epc);
|
|
|
|
|
|
epc = epc.Replace("\0", "").Trim();
|
|
|
SaveReadRecord(new ProEquip() {
|
|
|
machineId = appConfig.machineId,
|
|
|
positionId = position,
|
|
|
equipId = appConfig.machineId,
|
|
|
equipAnt = position.ToString(),
|
|
|
}, epc);
|
|
|
if (StringExtension.IsBlank(epc))
|
|
|
{
|
|
|
LogHelper.Info(logStr + "读取RFID条码信息失败");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "读取RFID条码信息失败");
|
|
|
sendError(position, 2, false, 1);
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = "",
|
|
|
sfc = "",
|
|
|
ea = "",
|
|
|
position = item,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
continue;
|
|
|
}
|
|
|
LogHelper.Info(logStr + "读取RFID条码信息成功:" + epc);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "读取RFID条码信息成功:" + epc);
|
|
|
|
|
|
//判断是否串读 Add by wenjy 2022-10-05
|
|
|
if (PdRfidIsChuanDu(epc, item).Result)
|
|
|
{
|
|
|
sendError(position, 2, false, 1);
|
|
|
LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
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, "绑定卷轴与物料信息,获取卷轴信息为空");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "绑定卷轴与物料信息,获取卷轴信息为空");
|
|
|
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));
|
|
|
|
|
|
//判断RFID标签是否重复
|
|
|
LogHelper.Info("判断RFID标签是否重复");
|
|
|
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处理");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
//解绑RFID与SFC的绑定信息
|
|
|
LogHelper.Info("解绑RFID条码" + epc + "绑定的SFC信息");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "解绑RFID条码:" + epc + "绑定的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);
|
|
|
}
|
|
|
|
|
|
LogHelper.Info(String.Format("收卷流程处理完成,判断读取结果是否OK,位置:{0},标签数量:{1},条码信息:{2}", position, tagInfoList.Count, JsonChange.ModeToJson(tagInfoList)));
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
if (tagInfoList.Count == 1)
|
|
|
{
|
|
|
LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号");
|
|
|
this.sendSuccessByDownBegin(position);
|
|
|
}
|
|
|
}
|
|
|
else if (ConfigHelper.GetConfig("tagAmount") == "3")
|
|
|
{
|
|
|
if (position < 3)
|
|
|
{
|
|
|
if (tagInfoList.Count == 2)
|
|
|
{
|
|
|
LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号");
|
|
|
this.sendSuccessByDownBegin(position);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (tagInfoList.Count == 1)
|
|
|
{
|
|
|
LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号");
|
|
|
this.sendSuccessByDownBegin(position);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ConfigHelper.GetConfig("tagAmount") == "4")
|
|
|
{
|
|
|
if (tagInfoList.Count == 2)
|
|
|
{
|
|
|
LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号");
|
|
|
this.sendSuccessByDownBegin(position);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("冷压收卷涨紧信号逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "冷压收卷涨紧信号逻辑处理异常" + ex.Message);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
tagInfoList = new List<string>();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <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 + "收卷结束信号触发成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "收卷结束信号触发成功");
|
|
|
LogHelper.Info(logStr + "收卷结束信号触发成功");
|
|
|
//通过PLC读取收卷轴绑定的放卷位SFC信息
|
|
|
ProShaftInfo upMaterialInfo = new ProShaftInfo();
|
|
|
if (position == 1) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
if (position == 2) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
if (position == 3) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
if (position == 4) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
|
|
|
if (StringExtension.IsBlank(upMaterialInfo.bindSfc))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "通过PLC获取SFC为空");
|
|
|
this.sendSuccess(position);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (upMaterialInfo.bindSfc.Length > 0)
|
|
|
{
|
|
|
if(upMaterialInfo.bindSfc.Substring(0,2) == "L3")
|
|
|
{
|
|
|
if (upMaterialInfo.bindSfc.Length > 14)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "PLC获取的14位SFC为:" + upMaterialInfo.bindSfc + "长度超过14位进行截取");
|
|
|
upMaterialInfo.bindSfc = upMaterialInfo.bindSfc.Substring(0, 14);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (upMaterialInfo.bindSfc.Length > 18)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "PLC获取的18位SFC为:" + upMaterialInfo.bindSfc + "长度超过18位进行截取");
|
|
|
upMaterialInfo.bindSfc = upMaterialInfo.bindSfc.Substring(0, 18);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "PLC获取的SFC为:" + upMaterialInfo.bindSfc);
|
|
|
//获取卷轴绑定的物料信息
|
|
|
foreach (var item in positionList)
|
|
|
{
|
|
|
//获取当前卷轴绑定的物料信息
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(item);
|
|
|
if (shaftInfo == null || StringExtension.IsBlank(shaftInfo.bindRfid))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("{0}收卷完工获取绑定信息为空不进入结束流程", logStr));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("{0}收卷完工获取绑定信息为空不进入结束流程", logStr));
|
|
|
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 + "设备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, "PLC获取的最终SFC为:" + upMaterialInfo.bindSfc);
|
|
|
if (StringExtension.IsBlank(upMaterialInfo.bindSfc))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("{0}收卷完工获取卷轴绑定的SFC为空不进入结束流程", logStr));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("{0}收卷完工获取卷轴绑定的SFC为空不进入结束流程", logStr));
|
|
|
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, String.Format("{0}收卷完工获取放卷位物料信息为空不进入结束流程", logStr));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("{0}收卷完工获取放卷位物料信息为空不进入结束流程", logStr));
|
|
|
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, String.Format("通过MES获取放卷位{0}物料EA值为空", upMaterialInfo.bindSfc));
|
|
|
return;
|
|
|
}
|
|
|
upMaterialInfo.bindEaValue = upMaterialEaValue;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷位物料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, "收卷流程结束,获取下料信息异常");
|
|
|
LogHelper.Info("收卷流程结束,获取下料信息异常");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
}
|
|
|
if (x.endFlag == 1)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "完工最后一卷:" + x.bindRfid);
|
|
|
LogHelper.Info("完工最后一卷:" + x.bindRfid);
|
|
|
int mesEaValue = StringChange.ParseToInt(upMaterialInfo.bindEaValue);
|
|
|
|
|
|
#region Add by wenjy 20220826 最后一卷触发添加防呆过滤,避免四个收卷轴都有料时先完工最后一卷物料
|
|
|
//判断PLC地址中是否还存在该SFC
|
|
|
if (GetSameSfcByPlc(upMaterialInfo.bindSfc, position))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("{0}其它收卷位还有物料未完工,请勿提前完工最后一卷料", upMaterialInfo.bindSfc));
|
|
|
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 >= 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;
|
|
|
}
|
|
|
//拆分MES账目数量
|
|
|
if (!SpiltAccount(position, x, realEaValue, upMaterialInfo.bindSfc, upRecord, downRecord).Result)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "拆分MES账目数量异常");
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
i = i + 1;
|
|
|
}
|
|
|
|
|
|
x.bindEaValue = realEaValue.ToString();
|
|
|
}
|
|
|
|
|
|
x.bindSfc = GetBindSfcByMes(x.bindRfid);
|
|
|
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, String.Format("RFID:{0}绑定的膜卷号:{1}", x.bindRfid, 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 + "下料流程结束,下发PLC下料信号");
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "下料流程结束,下发PLC下料信号");
|
|
|
LogHelper.Info(logStr + "下料流程结束,下发PLC下料信号");
|
|
|
//下发PLC下料信号
|
|
|
this.sendSuccess(position);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("冷压收卷结束信号逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "冷压收卷结束信号逻辑处理异常" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <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.operationByA,
|
|
|
operationRevision = inifile.IniReadValue("AdujustQtyParam", "operationRevision"),
|
|
|
resource = appConfig.resource,
|
|
|
user = inifile.IniReadValue("AdujustQtyParam", "user"),
|
|
|
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)
|
|
|
{
|
|
|
string sfcStr = "";
|
|
|
DateTime beginTime = new DateTime();
|
|
|
ProcessLotServiceWSServiceParam processLotServiceWSServiceParam = new ProcessLotServiceWSServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"),
|
|
|
processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr)
|
|
|
};
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用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, "RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sfcStr = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("MES获取膜卷号接口调用异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "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"),
|
|
|
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, String.Format(logStr + "通过MES接口获取放卷物料{0}的SFC数量失败:{1}", bindSfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message)));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + "通过MES接口获取放卷物料{0}的SFC数量失败:{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获取SFC数量接口异常:{1}", ex.Message));
|
|
|
WebServiceLog.saveMiSFCQueryQtyServiceService(sFCQueryQtyServiceServiceParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, String.Format(logStr + "MES获取SFC数量接口异常:{1}", ex.Message));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + "MES获取SFC数量接口异常:{1}", 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, "拆分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, "调用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"),
|
|
|
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, "MES自动拆分接口调用失败:" + upLoadBusiness.GetMesMessage(result.code, result.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动拆分接口调用失败:" + upLoadBusiness.GetMesMessage(result.code, result.message));
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, result.code);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
LogHelper.Info("MES自动拆分接口调用成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "MES自动拆分接口调用成功");
|
|
|
|
|
|
#region 重量特征数据上传 Add By 2022-12-02
|
|
|
if (upLoadBusiness.JudgeResourceIsUplpadData()) //判断是否为190品种
|
|
|
{
|
|
|
string downSplitMaterialSfc = GetBindSfcByMes(shaftInfos.bindRfid);
|
|
|
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, "MES自动完工接口异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "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, "调用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_LYA_RF01",
|
|
|
//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"),
|
|
|
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)
|
|
|
{
|
|
|
if (position != 1)
|
|
|
{
|
|
|
if (PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)18).Replace("\0", "").Trim() == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
if (position != 2)
|
|
|
{
|
|
|
if (PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)18).Replace("\0", "").Trim() == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
if (position != 3)
|
|
|
{
|
|
|
if (PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)18).Replace("\0", "").Trim() == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
if (position != 4)
|
|
|
{
|
|
|
if (PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)18).Replace("\0", "").Trim() == bindSfc)
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断是否为最后一卷,20220826弃用,delete by wenjy
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
private bool isEndMaterial(int position, string bindSfc, string logStr, int realEaValue)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "判断是否为最后一卷料");
|
|
|
//获取放卷位SFC
|
|
|
string upMaterialSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.放卷SFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
try
|
|
|
{
|
|
|
if (upMaterialSfc != bindSfc)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "收卷结束,收卷位与放卷位SFC不一致," + bindSfc + ";最后一轮收卷");
|
|
|
LogHelper.Info(logStr + "收卷结束,收卷位与放卷位SFC不一致," + bindSfc + ";最后一轮收卷");
|
|
|
//通过MES获取PLC绑定的SFC MES账目中数量还有多少
|
|
|
int qty = StringChange.ParseToInt(GetUpMaterialQty(position,bindSfc, logStr));
|
|
|
|
|
|
#region 根据账目数量筛选最后一卷,已弃用
|
|
|
//if(qty > realEaValue)
|
|
|
//{
|
|
|
// if (qty - realEaValue > realEaValue)
|
|
|
// {
|
|
|
// LogHelper.Info("MES账目数量:" + qty + ",设备实际数量:" + realEaValue);
|
|
|
// return false;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// ////最后一轮
|
|
|
// if (position > 2)
|
|
|
// {
|
|
|
// return true;
|
|
|
// }
|
|
|
// return true;
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
// return true;
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
//最后一轮,根据PLC设定下料顺序
|
|
|
if (position > 2)
|
|
|
{
|
|
|
ProShaftInfo shaftInfo = this.GetShaftInfoByPosition(position).Result;
|
|
|
if (shaftInfo.endFlag == 1)
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "判断是否为最后一卷料异常:" + ex.Message);
|
|
|
LogHelper.Info("判断是否为最后一卷料异常:" + ex.Message);
|
|
|
}
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
string binSfc = GetBindSfcByMes(epc);//add by liulb 2022-11-09
|
|
|
|
|
|
LogHelper.Info($"获取涂布材料膜卷号{binSfc}");
|
|
|
|
|
|
LogHelper.Info("调用MES首工序获取SFC接口");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用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 = "",
|
|
|
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);
|
|
|
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.放卷OK, 1);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, firstOperationForsfcResponse.@return.code);
|
|
|
LogHelper.Info("MES首工序获取SFC接口调用失败,下发PLC泄气D6014报警D6025信号," + firstOperationForsfcResponse.@return.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "MES首工序获取SFC接口调用失败");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES首工序获取SFC接口调用失败" + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES首工序获取SFC接口调用失败" + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "MES首工序获取SFC接口调用失败,下发PLC泄气D6014报警D6025信号");
|
|
|
return;
|
|
|
}
|
|
|
sfc = firstOperationForsfcResponse.@return.sfc;
|
|
|
qty = firstOperationForsfcResponse.@return.qty;
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty));
|
|
|
LogHelper.Info(String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("调用MES首工序获取SFC接口异常:" + ex.Message);
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "调用MES首工序获取SFC接口异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES首工序获取SFC接口异常:" + ex.Message);
|
|
|
WebServiceLog.saveMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam, null
|
|
|
, beginTime, ex.Message);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.MES异常, 1);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sfc = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
qty = "2000";
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty));
|
|
|
|
|
|
}
|
|
|
//放卷位膜卷号写入PLC地址
|
|
|
PlcBusiness.writeStrPlc(appConfig.LyAddress.放卷SFC, sfc);
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "放卷位物料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, "绑定卷轴与RFID,获取卷轴信息为空");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "绑定卷轴与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);
|
|
|
|
|
|
upLoadBusiness.SaveUpRecord(upRecord);
|
|
|
|
|
|
//判断是否合卷
|
|
|
if (JudgementMaterial(sfc))
|
|
|
{
|
|
|
LogHelper.Info("上料成功,收卷位SFC与放卷SFC不同触发合卷报警");
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.合卷报警, 1);
|
|
|
}
|
|
|
LogHelper.Info("冷压放卷流程处理成功,D6014写0");
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.放卷OK, 0);
|
|
|
//手动写入自动下降U型块
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.手动上料, 1);
|
|
|
}
|
|
|
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, "判断是否合卷,放卷位SFC:" + sfc);
|
|
|
//获取正在生产收卷轴绑定的SFC
|
|
|
string downSfc = "";
|
|
|
//1A
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1A状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
LogHelper.Info("1A轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("1A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("1A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("1A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
//1B
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1B状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
LogHelper.Info("1B轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("1B轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("1B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("1B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
//2A
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2A状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
LogHelper.Info("2A轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("2A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("2A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("2A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2A轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
//2B
|
|
|
if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2B状态) == 1)
|
|
|
{
|
|
|
downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)18).Replace("\0", "").Trim();
|
|
|
LogHelper.Info("2B轴在生产,SFC:" + downSfc);
|
|
|
if (StringExtension.IsBlank(downSfc))
|
|
|
{
|
|
|
LogHelper.Info("2B轴绑定膜卷号为空,不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "1A轴绑定膜卷号为空,不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
if (downSfc == sfc)
|
|
|
{
|
|
|
LogHelper.Info("2B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "相同不触发合卷报警");
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("2B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "2B轴在生产,SFC:" + downSfc + ",和放卷位SFC:" + sfc + "不相同触发合卷异常");
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷成功气胀信号
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void sendSuccessByDownBegin(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 sendSuccess(int position)
|
|
|
{
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1AOK, 1);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1BOK, 1);
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2AOK, 1);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2BOK, 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁止下料
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void sendError(int position)
|
|
|
{
|
|
|
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>
|
|
|
private void UnBindRfidAndSfc(string rfidStr)
|
|
|
{
|
|
|
DateTime beginTime = new DateTime();
|
|
|
string sfcStr = GetSfcByRfid(rfidStr);
|
|
|
|
|
|
if (!StringExtension.IsBlank(sfcStr))
|
|
|
{
|
|
|
ProcessLotServiceWSServiceParam lotServiceWSServiceParam = new ProcessLotServiceWSServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("ProcessLotServiceWSServiceParam","url"),
|
|
|
site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"),
|
|
|
processlotref = "ProcessLotBO:2100," + rfidStr,
|
|
|
memberlist = new string[] { "SFCBO:2100," + sfcStr }
|
|
|
};
|
|
|
LogHelper.Info("MES解绑接口请求参数:" + JsonChange.ModeToJson(lotServiceWSServiceParam));
|
|
|
beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
removeMemberResponse removeMember = MesWebServices.iRemoveMember(lotServiceWSServiceParam);
|
|
|
LogHelper.Info("MES解绑接口返回参数:" + JsonChange.ModeToJson(removeMember));
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
WebServiceLog.saveRemoveMember(lotServiceWSServiceParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, String.Format("解绑接口调用异常:{0}", ex.Message));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("RFID条码:{0}解绑失败:{1}!!!", rfidStr, ex.Message));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("RFID条码:{0}解绑失败!!!", rfidStr));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("RFID条码:" + rfidStr + "未绑定SFC信息");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "RFID条码:" + rfidStr + "未绑定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, "获取卷轴信息为空");
|
|
|
LogHelper.Info("获取卷轴信息异常:" + ex.Message);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷结束获取最后一卷
|
|
|
/// </summary>
|
|
|
private async void UpdateShaftEndFlag(int position)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
List<ProShaftInfo> shaftInfos = new List<ProShaftInfo>();
|
|
|
string logStr = "";
|
|
|
List<int> positionList = PositionToList(position);
|
|
|
/*List<int> positionList = new List<int>();
|
|
|
if (position == 1)
|
|
|
{
|
|
|
positionList.Clear();
|
|
|
logStr = "1A轴";
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
positionList.Add(2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(1);
|
|
|
positionList.Add(2);
|
|
|
}
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
positionList.Clear();
|
|
|
logStr = "1B轴";
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
positionList.Add(3);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(3);
|
|
|
positionList.Add(4);
|
|
|
}
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
logStr = "2A轴";
|
|
|
positionList.Clear();
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
positionList.Add(6);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(6);
|
|
|
positionList.Add(5);
|
|
|
}
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
logStr = "2B轴";
|
|
|
positionList.Clear();
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
positionList.Add(7);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(7);
|
|
|
positionList.Add(8);
|
|
|
}
|
|
|
}*/
|
|
|
#endregion
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "当前收卷位生产轴:" + logStr);
|
|
|
//获取卷轴绑定的物料信息
|
|
|
foreach (var item in positionList)
|
|
|
{
|
|
|
//获取当前卷轴绑定的物料信息
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(item);
|
|
|
|
|
|
if (StringExtension.IsBlank(shaftInfo.bindRfid))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,判断最后一卷收卷物料获取收卷位绑定信息为空," + logStr);
|
|
|
LogHelper.Info("放卷结束,判断最后一卷收卷物料获取收卷位绑定信息为空," + logStr);
|
|
|
continue;
|
|
|
}
|
|
|
LogHelper.Info(String.Format("{0}当前绑定的物料信息为:{1}", logStr, JsonChange.ModeToJson(shaftInfo)));
|
|
|
|
|
|
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
if (position > 2)
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "最后收卷物料标识修改成功");
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "最后收卷物料标识修改失败");
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (item == 5 || item == 8)
|
|
|
{
|
|
|
shaftInfo.endFlag = 1;
|
|
|
LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid);
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "最后收卷物料标识修改成功");
|
|
|
LogHelper.Info("最后收卷物料标识修改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "最后收卷物料标识修改失败");
|
|
|
LogHelper.Info("最后收卷物料标识修改失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("放卷结束判断最后一卷物料逻辑处理异常", ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 强制下料
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void ForceDown(int position)
|
|
|
{
|
|
|
switch (position)
|
|
|
{
|
|
|
case 1:
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "1A轴异常下料信号触发,下发下料信号");
|
|
|
LogHelper.Info("1A轴异常下料信号触发,下发下料信号");
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1AOK, 1);
|
|
|
break;
|
|
|
case 2:
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "1B轴异常下料信号触发,下发下料信号");
|
|
|
LogHelper.Info("1B轴异常下料信号触发,下发下料信号");
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷1BOK, 1);
|
|
|
break;
|
|
|
case 3:
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "2A轴异常下料信号触发,下发下料信号");
|
|
|
LogHelper.Info("2A轴异常下料信号触发,下发下料信号");
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 0);
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2AOK, 1);
|
|
|
break;
|
|
|
case 4:
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "2B轴异常下料信号触发,下发下料信号");
|
|
|
LogHelper.Info("2B轴异常下料信号触发,下发下料信号");
|
|
|
plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 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;
|
|
|
exp = exp.And(x => x.bindRfid == epc && x.positionId != position.ToString() && 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")
|
|
|
{
|
|
|
positionList.Add(2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(1);
|
|
|
positionList.Add(2);
|
|
|
}
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
positionList.Clear();
|
|
|
logStr = "1B轴";
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
positionList.Add(3);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(4);
|
|
|
positionList.Add(3);
|
|
|
}
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
logStr = "2A轴";
|
|
|
positionList.Clear();
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
positionList.Add(6);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
positionList.Add(6);
|
|
|
positionList.Add(5);
|
|
|
}
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
logStr = "2B轴";
|
|
|
positionList.Clear();
|
|
|
if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2")
|
|
|
{
|
|
|
positionList.Add(7);
|
|
|
}
|
|
|
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>
|
|
|
/// <returns></returns>
|
|
|
private List<SysClient> GetSysConfigList(string paramType)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Expression<Func<SysClient, bool>> exp = s1 => true;
|
|
|
|
|
|
if (StringExtension.IsNotBlank(paramType))
|
|
|
{
|
|
|
exp = exp.And(x => x.paramType == paramType);
|
|
|
}
|
|
|
|
|
|
exp = exp.And(x => x.processId == appConfig.processId);
|
|
|
|
|
|
List<SysClient> info = sysClientServices.Query(exp).Result;
|
|
|
|
|
|
return info;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("获取配置列表异常", ex);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设备启动
|
|
|
/// </summary>
|
|
|
public void MachineStartUp()
|
|
|
{
|
|
|
#region Delete By wenjy 2022-12-27 ME要求改为原逻辑
|
|
|
// throw new NotImplementedException();
|
|
|
//LogRefreshEvent?.Invoke(LogType.PlcLog, "开机启动信号触发成功");
|
|
|
//LogHelper.Info("开机启动信号触发成功");
|
|
|
////通过PLC地址获取放卷膜卷号
|
|
|
//string sfc = PlcBusiness.readStrPlc("D6034", (ushort)18).Replace("\0", "").Trim();
|
|
|
////JudgementMaterial(放卷膜卷号),返回true合卷报警=>PLC 写报警值,返回false不处理
|
|
|
//if (StringExtension.IsNotBlank(sfc))
|
|
|
//{
|
|
|
// // 判断合卷
|
|
|
// if (JudgementMaterial(sfc))
|
|
|
// {
|
|
|
// LogHelper.Info("触发合卷报警,下发PLC报警指令");
|
|
|
// LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷位与收卷位膜卷号不同触发合卷报警");
|
|
|
// // 写入合卷报警
|
|
|
// plcBusiness.writePlc("D6114", 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, String.Format("当前RFID:{0}绑定的SFC为:{1}", rfidStr, 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, String.Format("当前SFC:{0}放卷结束时间为空,生产未结束", sfcStr));
|
|
|
result = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("当前SFC:{0}放卷结束时间为:{1}", sfcStr, upRecord.endTime));
|
|
|
result = true;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <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"),
|
|
|
processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr)
|
|
|
};
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用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, "RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sfcStr = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("MES获取膜卷号接口调用异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES获取膜卷号接口调用异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES获取膜卷号接口调用异常:" + ex.Message);
|
|
|
WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, null, beginTime, ex.Message);
|
|
|
}
|
|
|
return sfcStr;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 上传冷压数据 2022-11-7
|
|
|
/// </summary>
|
|
|
/// <param name="x"></param>
|
|
|
/// <param name="bindSfc"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool UpLYMesData(ProShaftInfo x, ProUpRecord upRecord,ProDownRecord downRecord, machineIntegrationParametricData[] data)
|
|
|
{
|
|
|
bool upResult = false;
|
|
|
try
|
|
|
{
|
|
|
#region 将物料上传到mes中
|
|
|
MachineIntegrationServiceParam machineIntegrationServiceParam = new MachineIntegrationServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("MachineIntegrationServiceParam","url"),
|
|
|
site = inifile.IniReadValue("MachineIntegrationServiceParam", "site"),
|
|
|
sfc = x.bindSfc, //将数据上传至拆分后的冷压下料膜卷号
|
|
|
operation = appConfig.operation,
|
|
|
operationRevision = inifile.IniReadValue("MachineIntegrationServiceParam", "operationRevision"),
|
|
|
activityId = inifile.IniReadValue("MachineIntegrationServiceParam", "activityId"),
|
|
|
resource = appConfig.resource,
|
|
|
dcGroup = inifile.IniReadValue("MachineIntegrationServiceParam", "dcGroup"),
|
|
|
dcGroupRevision = inifile.IniReadValue("MachineIntegrationServiceParam", "dcGroupRevision"),
|
|
|
parametricArray = data,
|
|
|
user = inifile.IniReadValue("MachineIntegrationServiceParam", "user"),
|
|
|
modeProcessSfc = WebService.MachineIntegrationServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC
|
|
|
};
|
|
|
LogHelper.Info("上传MES数据接口请求参数:" + JsonChange.ModeToJson(machineIntegrationServiceParam));
|
|
|
|
|
|
var dataCollectForSfcExResponse = MesWebServices.machineIntegration(machineIntegrationServiceParam);
|
|
|
|
|
|
var result = dataCollectForSfcExResponse.@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));
|
|
|
upResult = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "冷压数据上传MES成功");
|
|
|
LogHelper.Info("冷压数据上传MES成功");
|
|
|
|
|
|
upResult = true;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
return upResult;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info($"冷压数据异常:{ex.Message}");
|
|
|
return upResult = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取物料特征数据
|
|
|
/// </summary>
|
|
|
/// <param name="x"></param>
|
|
|
/// <param name="upRecord"></param>
|
|
|
/// <param name="downRecord"></param>
|
|
|
/// <returns></returns>
|
|
|
private machineIntegrationParametricData[] GetMaterialWeight(ProShaftInfo x, ProUpRecord upRecord, ProDownRecord downRecord)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string LY_SJFX = string.Empty;//收卷轴方向
|
|
|
string LY_FJFX = string.Empty;//放卷轴方向
|
|
|
string LY_SJZ = x.shaftName;//收卷轴1A轴小天线
|
|
|
string LY_HXMQ = string.Empty;//横向膜区方向
|
|
|
int LY_ZXMQ = 0;//L2 SFC拆分第几轮
|
|
|
string LY_WLMX = string.Empty;//物料面向 小轴方向
|
|
|
double LY_S_X01 = 0.00;//冷压S面某膜区特征值-01
|
|
|
double LY_S_X02 = 0.00;//冷压S面某膜区特征值-02
|
|
|
double LY_B_X01 = 0.00;//冷压B面某膜区特征值-01
|
|
|
double LY_B_X02 = 0.00;//冷压B面某膜区特征值-02
|
|
|
double S_TARGETCW = 0.00; // 单面目标净重
|
|
|
string upMaterialSfc = upRecord.UpMaterialId;
|
|
|
|
|
|
//获取涂布下料EA
|
|
|
//string upMaterialEaValue = GetUpMaterialQty(position,upMaterialInfo.bindSfc, logStr);
|
|
|
|
|
|
|
|
|
LogHelper.Info($"收卷轴:{LY_SJZ}");
|
|
|
#region 横向膜区
|
|
|
|
|
|
//1、判断轴的方向
|
|
|
LY_FJFX = PlcBusiness.readPlc(appConfig.LyAddress.放卷方向) == 0 ? "顺时针" : "逆时针";
|
|
|
LogHelper.Info($"放卷轴方向:{LY_FJFX}");
|
|
|
|
|
|
if (x.positionId == "1" || x.positionId == "2") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷1A方向) == 0 ? "顺时针" : "逆时针";
|
|
|
if (x.positionId == "3" || x.positionId == "4") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷1B方向) == 0 ? "顺时针" : "逆时针";
|
|
|
if (x.positionId == "5" || x.positionId == "6") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷2A方向) == 0 ? "顺时针" : "逆时针";
|
|
|
if (x.positionId == "7" || x.positionId == "8") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷2B方向) == 0 ? "顺时针" : "逆时针";
|
|
|
LogHelper.Info($"收卷轴方向:{LY_SJFX}");
|
|
|
//2、 根据posttion判断料是左中右那个膜区
|
|
|
string tagAmount = ConfigHelper.GetConfig("tagAmount");
|
|
|
if (tagAmount == "3")
|
|
|
{
|
|
|
//顺时针
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "1") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "2") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "3") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "4") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "5") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "6") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "7") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "8") LY_HXMQ = "中";
|
|
|
//逆时针
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "1") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "2") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "3") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "4") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "5") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "6") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "7") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "8") LY_HXMQ = "中";
|
|
|
LogHelper.Info($"横向膜区:{LY_HXMQ}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//顺时针
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "1") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "2") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "3") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "4") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "5") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "6") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "7") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && x.positionId == "8") LY_HXMQ = "右";
|
|
|
//逆时针
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "1") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "2") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "3") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "4") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "5") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "6") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "7") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && x.positionId == "8") LY_HXMQ = "左";
|
|
|
|
|
|
LogHelper.Info($"膜区:{LY_HXMQ}");
|
|
|
}
|
|
|
|
|
|
//3、物料面向
|
|
|
if (LY_SJFX == "顺时针" && LY_FJFX == "顺时针")
|
|
|
{
|
|
|
LY_WLMX = "S面";
|
|
|
}
|
|
|
if (LY_SJFX == "顺时针" && LY_FJFX == "逆时针")
|
|
|
{
|
|
|
LY_WLMX = "B面";
|
|
|
}
|
|
|
if (LY_SJFX == "逆时针" && LY_FJFX == "顺时针")
|
|
|
{
|
|
|
LY_WLMX = "B面";
|
|
|
}
|
|
|
if (LY_SJFX == "逆时针" && LY_FJFX == "逆时针")
|
|
|
{
|
|
|
LY_WLMX = "S面";
|
|
|
}
|
|
|
LogHelper.Info($"物料面向:{LY_WLMX}");
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 纵向膜区 update by wenjy 2022-11-11
|
|
|
//4、根据膜卷号和配置文件中的tagAmount,再根据膜卷号从数据库中查询条数、与tagAmount比较判断是第几轮
|
|
|
|
|
|
if (StringExtension.IsBlank(upMaterialSfc))
|
|
|
upMaterialSfc = ConfigHelper.GetConfig("LYsfc");
|
|
|
|
|
|
LogHelper.Info(String.Format("涂布来料膜卷号:{0};冷压上料膜卷号:{1};下料拆分膜卷号:{2}", upMaterialSfc, upRecord.Sfc, x.shaftName));
|
|
|
|
|
|
LY_ZXMQ = upLoadBusiness.GetLengthwaysArea(upMaterialSfc);
|
|
|
LogHelper.Info(String.Format("纵向膜区第几轮:{0}", LY_ZXMQ));
|
|
|
#endregion
|
|
|
|
|
|
#region 从mes中获取值
|
|
|
GetParametricValueRequestData[] t = null;
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_1_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_1_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_1_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_1_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_2_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_2_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_2_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_2_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_3_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_3_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_3_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_3_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_4_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_4_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_4_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_4_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_5_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_5_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_5_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_5_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_6_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_6_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_6_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_6_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
TBDataServiceParam tbServiceParam = new TBDataServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("TBParametricValueParam","url"),
|
|
|
site = inifile.IniReadValue("TBParametricValueParam", "site"),
|
|
|
sfc = upMaterialSfc, //使用涂布膜卷号获取涂布重量特征数据
|
|
|
memberlist = t
|
|
|
};
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
var tbresult = MesWebServices.findTBData(tbServiceParam);
|
|
|
|
|
|
LogHelper.Info($"从mes中获取涂布数据:{JsonChange.ModeToJson(tbresult)}");
|
|
|
foreach (var item in tbresult.paramValues)
|
|
|
{
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_1_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_1_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_1_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_1_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_2_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_2_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_2_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_2_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_3_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_3_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_3_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_3_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_4_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_4_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_4_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_4_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_5_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_5_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_5_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_5_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_6_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_6_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_6_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_6_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
}
|
|
|
LogHelper.Info(String.Format("涂布特征数据:LY_S_X01:{0};LY_S_X02:{1};LY_B_X01:{2};LY_B_X02:{3};S_TARGETCW:{4}", LY_S_X01, LY_S_X02, LY_B_X01, LY_B_X02, S_TARGETCW));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("冷压获取数值失败:" + ex.Message);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
LogHelper.Info($"冷压物料特征数据:LY_FJFX:{LY_FJFX}-LY_SJFX:{LY_SJFX}-LY_SJZ:{LY_SJZ}-LY_HXMQ:{LY_HXMQ}-:LY_ZXMQ{LY_ZXMQ}-LY_WLMX:{LY_WLMX}-LY_S_X01:{LY_S_X01}-LY_S_X02:{LY_S_X02}-LY_B_X01:{LY_B_X01}-LY_B_X02:{LY_B_X02}-S_TARGETCW:{S_TARGETCW}");
|
|
|
|
|
|
machineIntegrationParametricData[] data = {
|
|
|
new machineIntegrationParametricData() {name ="LY_FJFX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_FJFX.ToString())?"0":LY_FJFX.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_SJFX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_SJFX.ToString())?"0":LY_SJFX.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_SJZ",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_SJZ.ToString())?"0":LY_SJZ.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_HXMQ",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_HXMQ.ToString())?"0":LY_HXMQ.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_ZXMQ",dataType=ParameterDataType.NUMBER, value=LY_ZXMQ.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_WLMX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_WLMX.ToString())?"0":LY_WLMX.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_S_X01",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_S_X01.ToString())?"0":LY_S_X01.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_S_X02",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_S_X02.ToString())?"0":LY_S_X02.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_B_X01",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_B_X01.ToString())?"0":LY_B_X01.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_B_X02",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_B_X02.ToString())?"0":LY_B_X02.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="S_TARGETCW",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(S_TARGETCW.ToString())?"0":S_TARGETCW.ToString()},
|
|
|
};
|
|
|
return data;
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("冷压物料特征数据获取异常:"+ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "冷压物料特征数据获取异常:" + ex.Message);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 物料特征数据上传至服务器
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="sfcStr"></param>
|
|
|
/// <param name="downRecordId"></param>
|
|
|
/// <param name="datas"></param>
|
|
|
private void UpLoadMaterialWeight(int position,string sfcStr,string downRecordId, machineIntegrationParametricData[] datas)
|
|
|
{
|
|
|
//冷压特征数据上传至服务器
|
|
|
try
|
|
|
{
|
|
|
LyUpLoad lyUpLoad = new LyUpLoad()
|
|
|
{
|
|
|
sfcStr = sfcStr,
|
|
|
clientId = downRecordId,
|
|
|
positionId = position,
|
|
|
resource = appConfig.resource,
|
|
|
operation = appConfig.operation,
|
|
|
dcGroup = inifile.IniReadValue("MachineIntegrationServiceParam", "dcGroup"),
|
|
|
upDirection = datas.Where(x => x.name == "LY_FJFX").FirstOrDefault().value,
|
|
|
downDirection = datas.Where(x => x.name == "LY_SJFX").FirstOrDefault().value,
|
|
|
downPosition = datas.Where(x => x.name == "LY_SJZ").FirstOrDefault().value,
|
|
|
crosswiseArea = datas.Where(x => x.name == "LY_HXMQ").FirstOrDefault().value,
|
|
|
erectArea = datas.Where(x => x.name == "LY_ZXMQ").FirstOrDefault().value,
|
|
|
materialFace = datas.Where(x => x.name == "LY_WLMX").FirstOrDefault().value,
|
|
|
sx01 = datas.Where(x => x.name == "LY_S_X01").FirstOrDefault().value,
|
|
|
sx02 = datas.Where(x => x.name == "LY_S_X02").FirstOrDefault().value,
|
|
|
bx01 = datas.Where(x => x.name == "LY_B_X01").FirstOrDefault().value,
|
|
|
bx02 = datas.Where(x => x.name == "LY_B_X02").FirstOrDefault().value,
|
|
|
s_targetcws = datas.Where(x => x.name == "S_TARGETCW").FirstOrDefault().value,
|
|
|
recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
};
|
|
|
|
|
|
upLoadBusiness.SaveLyUpLoad(lyUpLoad);
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("冷压物料特征数据上传服务器异常:"+ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "冷压物料特征数据上传服务器异常:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void SaveReadRecord(ProEquip equip, string rfidStr)
|
|
|
{
|
|
|
ProReadRecord readRecord = new ProReadRecord()
|
|
|
{
|
|
|
MachineID = equip.machineId,
|
|
|
EquipID = equip.equipId,
|
|
|
PositionID = equip.positionId,
|
|
|
Ant = StringChange.ParseToInt(equip.equipAnt),
|
|
|
ReadEPC = rfidStr,
|
|
|
Result = StringExtension.IsBlank(rfidStr) ? "0" : "1",
|
|
|
ReadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
};
|
|
|
upLoadBusiness.SaveReadRecord(readRecord);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|