|
|
using GRreader;
|
|
|
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.MiSignOffSFCsServiceService;
|
|
|
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
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 模切PLC逻辑处理
|
|
|
/// </summary>
|
|
|
public class MQSignalReadBusiness : ISignalReadFunction
|
|
|
{
|
|
|
|
|
|
/// <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>();
|
|
|
|
|
|
//新加2022-11-08
|
|
|
private MesAlarmInfo mesAlarmInfo = new MesAlarmInfo();
|
|
|
|
|
|
private PlcBusiness plcBusiness = new PlcBusiness();
|
|
|
|
|
|
/// <summary>
|
|
|
/// 数据上传业务逻辑
|
|
|
/// </summary>
|
|
|
private UpLoadBusiness upLoadBusiness = UpLoadBusiness.Instance;
|
|
|
|
|
|
// INIFile配置文件
|
|
|
private INIFile inifile = new INIFile(System.Environment.CurrentDirectory + "/MesConfig/App.InI");
|
|
|
private AppConfigDto appConfig = AppConfigDto.Instance;
|
|
|
/// <summary>
|
|
|
/// 设备启动
|
|
|
/// </summary>
|
|
|
public void MachineStartUp()
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "开机启动信号触发成功");
|
|
|
LogHelper.Info("开机启动信号触发成功");
|
|
|
int upPosition = 0;
|
|
|
//判断放卷生产轴
|
|
|
if (appConfig.machineId == 3)
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24816") == 1) upPosition = 6;
|
|
|
if (PlcBusiness.readPlc("MW24818") == 1) upPosition = 5;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24816") == 1) upPosition = 5;
|
|
|
if (PlcBusiness.readPlc("MW24818") == 1) upPosition = 6;
|
|
|
}
|
|
|
LogHelper.Info("当前放卷生产轴为:" + Which(upPosition));
|
|
|
ProShaftInfo shaftInfo = this.GetShaftInfoByPosition(upPosition).Result;
|
|
|
|
|
|
//判断收卷轴
|
|
|
List<int> positions = new List<int>();
|
|
|
|
|
|
if (shaftInfo == null || StringExtension.IsBlank(shaftInfo.bindSfc))
|
|
|
{
|
|
|
LogHelper.Info("获取放卷轴信息为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
#region 重量特征数据上传 Add by Wenjy 2022-11-12 获取放卷运行方向并存储
|
|
|
if (upLoadBusiness.JudgeResourceIsUplpadData())
|
|
|
{
|
|
|
this.GetDirections(upPosition, shaftInfo);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//判断收卷生产轴
|
|
|
if (appConfig.machineId == 3)
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24676") == 1) positions.Add(3);
|
|
|
if (PlcBusiness.readPlc("MW24678") == 1) positions.Add(1);
|
|
|
if (PlcBusiness.readPlc("MW24680") == 1) positions.Add(4);
|
|
|
if (PlcBusiness.readPlc("MW24682") == 1) positions.Add(2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24676") == 1) positions.Add(1);
|
|
|
if (PlcBusiness.readPlc("MW24678") == 1) positions.Add(3);
|
|
|
if (PlcBusiness.readPlc("MW24680") == 1) positions.Add(2);
|
|
|
if (PlcBusiness.readPlc("MW24682") == 1) positions.Add(4);
|
|
|
}
|
|
|
|
|
|
if (positions.Count == 0)
|
|
|
{
|
|
|
LogHelper.Info("获取收卷轴信息为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
foreach (var x in positions)
|
|
|
{
|
|
|
string downStr = "";
|
|
|
downStr = Which(x);
|
|
|
LogHelper.Info("当前收卷生产轴为:" + downStr);
|
|
|
|
|
|
//判断是否合卷
|
|
|
bool info = SelectSfcIsHeJuan(upPosition, x).Result;
|
|
|
if (info)
|
|
|
{
|
|
|
LogHelper.Info("触发合卷报警,下发PLC报警指令写入2");
|
|
|
plcBusiness.writeDoublePlc("MW24624", 2);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//获取收卷轴绑定信息
|
|
|
ProShaftInfo downShaftInfo = this.GetShaftInfoByPosition(x).Result;
|
|
|
if (downShaftInfo == null)
|
|
|
{
|
|
|
LogHelper.Info("获取" + downStr + "轴绑定的信息为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
downShaftInfo.bindSfc = shaftInfo.bindSfc;
|
|
|
downShaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
if (shaftInfoServices.Update(downShaftInfo).Result)
|
|
|
{
|
|
|
LogHelper.Info(Which(upPosition) + "位,绑定" + downStr + "轴生产信息保存成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info(Which(upPosition) + "位,绑定" + downStr + "轴生产信息保存失败");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
#region 获取收卷运行方向并存储 Add by Wenjy 2022-11-12
|
|
|
this.GetDirections(x, downShaftInfo);
|
|
|
#endregion
|
|
|
}
|
|
|
StartTimerReadRfid();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷涨紧
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void UpMaterialBegin(int position)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
string logStr = Which(position);
|
|
|
#endregion
|
|
|
|
|
|
#region 未登录不让放卷涨紧生产,便于记录生产者
|
|
|
/*if (StringExtension.IsBlank(ConfigHelper.GetConfig("roleId")))
|
|
|
{
|
|
|
MessageBox.Show("请先登录再开始生产");
|
|
|
LogHelper.Info("请先登录再开始生产");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "请先登录再开始生产");
|
|
|
return;
|
|
|
}*/
|
|
|
#endregion
|
|
|
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, String.Format("{0}涨紧信号触发成功", logStr));
|
|
|
LogHelper.Info(String.Format("{0}涨紧信号触发成功", logStr));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("{0}涨紧信号触发成功", logStr));
|
|
|
//读取卷筒RFID物料信息
|
|
|
ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == position).FirstOrDefault();
|
|
|
if (proEquip == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "获取" + logStr + "读写器设备信息异常");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "获取" + logStr + "读写器设备信息异常");
|
|
|
return;
|
|
|
}
|
|
|
string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId);
|
|
|
//string epc = this.ReadEpcByPosition(position);
|
|
|
epc = epc.Replace("\0", "").Trim();
|
|
|
SaveReadRecord(proEquip, epc);
|
|
|
if (StringExtension.IsBlank(epc))
|
|
|
{
|
|
|
//下发读取结果:结果写2、 报警写1
|
|
|
AngrilyResultSendToPlc(position, 2, 1);
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = "",
|
|
|
sfc = "",
|
|
|
ea = "",
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "RFID条码信息读取失败");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "RFID条码信息读取失败");
|
|
|
LogHelper.Info(logStr + "RFID条码信息读取失败");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("{0}RFID读取成功,RFID为{1}", logStr, epc));
|
|
|
LogHelper.Info(String.Format("{0}RFID读取成功,RFID为{1}", logStr, epc));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("{0}RFID读取成功,RFID为{1}", logStr, epc));
|
|
|
|
|
|
//判断是否串读 Add by wenjy 2022-10-05
|
|
|
if (PdRfidIsChuanDu(epc, position).Result)
|
|
|
{
|
|
|
//下发读取结果 2NG、报警1
|
|
|
AngrilyResultSendToPlc(position, 2, 1);
|
|
|
LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//判断标签是否重复
|
|
|
if (BusinessHelper.UpRfidIsRecur(epc,position).Result)
|
|
|
{
|
|
|
|
|
|
//判断是否已经生产结束
|
|
|
if (UpMaterialIsEndProduction(epc).Result)
|
|
|
{
|
|
|
AngrilyResultSendToPlc(position, 2, 1);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc));
|
|
|
LogHelper.Info(String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc));
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info(logStr + "RFID读取到的条码:" + epc + "与前一读取相同并且生产未结束,可以继续生产");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "RFID读取到的条码:" + epc + "与前一读取相同并且生产未结束,可以继续生产");
|
|
|
UpmaterialReadSuccess(position);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
//放卷涨紧MES入账处理
|
|
|
UpMaterialBeginByMes(position, epc, true);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("模切放卷涨紧PLC信号逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "模切放卷涨紧PLC信号逻辑处理异常:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷开始信号
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void UpBegin(int position)
|
|
|
{
|
|
|
string logStr = this.Which(position);
|
|
|
LogHelper.Info(logStr + "放卷开始,下发禁止下料信号");
|
|
|
ForbidBlank(position);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷结束
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public async void UpMaterialEnd(int position)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
string logStr = "";
|
|
|
logStr = Which(position);
|
|
|
#endregion
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, "模切" + logStr + "位放卷结束信号触发成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "模切" + logStr + "位放卷结束信号触发成功");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "位放卷结束信号触发成功");
|
|
|
LogHelper.Info("模切" + logStr + "位结束信号触发成功");
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position);
|
|
|
if (shaftInfo == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "位放卷结束,获取卷轴绑定的信息为空");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "位放卷结束,获取卷轴绑定的信息为空");
|
|
|
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.RfidLog, logStr + "位放卷结束,获取上料信息为空");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "位放卷结束,获取上料信息为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//更新放卷信息
|
|
|
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 + "位放卷结束,生成放卷信息");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "位放卷结束,生成放卷信息");
|
|
|
|
|
|
upLoadBusiness.UpdateUpRecord(upRecord);
|
|
|
|
|
|
//清空绑定信息
|
|
|
//LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,清除卷轴绑定信息");
|
|
|
//shaftInfo.bindRfid = "";
|
|
|
//shaftInfo.bindSfc = "";
|
|
|
//shaftInfo.bindEaValue = "0";
|
|
|
shaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
await shaftInfoServices.Update(shaftInfo);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,更新绑定信息");
|
|
|
//放卷结束获取收卷轴最后一卷
|
|
|
IsEndFlag();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("放卷结束处理异常", ex);
|
|
|
//upLoadBusiness.SaveLogRecord(position, "放卷结束处理异常"+ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷结束处理异常:" + ex.Message);
|
|
|
}
|
|
|
|
|
|
//允许下料
|
|
|
AllowBlank(position);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷涨紧
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void DownMaterialBegin(int position)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
string logStr = "";
|
|
|
logStr = Which(position);
|
|
|
#endregion
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "轴涨紧触发成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("开始读取{0}轴卷筒RFID物料信息", logStr));
|
|
|
|
|
|
//读取卷筒RFID物料信息
|
|
|
ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == position).FirstOrDefault();
|
|
|
if (proEquip == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "获取" + logStr + "轴读写器设备信息异常");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "获取" + logStr + "轴读写器设备信息异常");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//读取协议更换
|
|
|
string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId);
|
|
|
epc = epc.Replace("\0", "").Trim();
|
|
|
|
|
|
SaveReadRecord(proEquip, epc);
|
|
|
if (StringExtension.IsBlank(epc))
|
|
|
{
|
|
|
LogHelper.Info(String.Format("{0}轴设备:{1};读取失败", logStr, proEquip.equipIp));
|
|
|
AngrilyResultSendToPlc(position, 2, 2);//收卷位报警
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "轴条码信息读取失败");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "轴条码信息读取失败");
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = "",
|
|
|
sfc = "",
|
|
|
ea = "",
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//判断是否串读 Add by wenjy 2022-10-05
|
|
|
if (PdRfidIsChuanDu(epc, position).Result)
|
|
|
{
|
|
|
AngrilyResultSendToPlc(position, 2, 1);
|
|
|
LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "轴读取成功,下发读取结果");
|
|
|
//add by yinzf 2022-8-11
|
|
|
UpmaterialReadSuccess(position);
|
|
|
//end add
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "RFID条码信息读取成功:" + epc);
|
|
|
LogHelper.Info(String.Format("{0}轴设备{1}读取RFID条码信息成功:{2}", logStr, proEquip.equipIp, epc));
|
|
|
|
|
|
//收卷位MES逻辑处理
|
|
|
DownMaterialBeginByMes(position, epc, true);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("模切收卷涨紧逻辑处理异常", ex);
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷位开始,Add by wenjy 20220905
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void DownBegin(int position)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 参数定义
|
|
|
string logStr = Which(position);
|
|
|
#endregion
|
|
|
lock (string.Empty)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "收卷开始,下发禁止下料信号");
|
|
|
//收卷开始下发收卷轴禁止下料
|
|
|
ForbidBlank(position);
|
|
|
|
|
|
//解绑RFID与SFC的绑定信息
|
|
|
ProShaftInfo downShaftInfo = this.GetShaftInfoByPosition(position).Result;
|
|
|
if (downShaftInfo != null)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "位收卷开始," + downShaftInfo.bindRfid + "绑定的SFC信息");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "位收卷开始,解绑RFID条码:" + downShaftInfo.bindRfid + "绑定的SFC信息");
|
|
|
this.UnBindRfidAndSfc(downShaftInfo.bindRfid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("收卷开始逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "收卷开始逻辑处理异常:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷结束
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public async void DownMaterialEnd(int position)
|
|
|
{
|
|
|
StopTimerReadRfid(position);
|
|
|
string logStr = "";
|
|
|
int qty = 0;
|
|
|
logStr = Which(position);
|
|
|
try
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "轴收卷结束信号触发成功");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "轴收卷结束信号触发成功");
|
|
|
LogHelper.Info(logStr + "轴收卷结束信号触发成功");
|
|
|
//add by yinzf 2022-8-7 收到完成信号通知PLC禁止下料,直到完工流程走完
|
|
|
ForbidBlank(position);
|
|
|
//end add
|
|
|
//获取收卷轴绑定的RFID条码信息,取最新数据
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position);
|
|
|
|
|
|
if (StringExtension.IsBlank(shaftInfo.bindSfc))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("{0}轴收卷完工获取绑定信息为空不进入结束流程", logStr));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("{0}轴收卷完工获取绑定信息为空不进入结束流程", logStr));
|
|
|
LogHelper.Info(String.Format("{0}轴收卷完工获取绑定信息为空不进入结束流程", logStr));
|
|
|
AllowBlank(position);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
LogHelper.Info(String.Format("{0}轴当前绑定的物料信息为:{1}", logStr, JsonChange.ModeToJson(shaftInfo)));
|
|
|
|
|
|
//EA新地址 Add by wenjy 2022-11-10
|
|
|
if (appConfig.machineId == 3)
|
|
|
{
|
|
|
if (position == 3) qty = PlcBusiness.readPlc("MW25928");
|
|
|
if (position == 1) qty = PlcBusiness.readPlc("MW25930");
|
|
|
if (position == 4) qty = PlcBusiness.readPlc("MW25932");
|
|
|
if (position == 2) qty = PlcBusiness.readPlc("MW25934");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1) qty = PlcBusiness.readPlc("MW25928");
|
|
|
if (position == 3) qty = PlcBusiness.readPlc("MW25930");
|
|
|
if (position == 2) qty = PlcBusiness.readPlc("MW25932");
|
|
|
if (position == 4) qty = PlcBusiness.readPlc("MW25934");
|
|
|
}
|
|
|
|
|
|
LogRefreshEvent.Invoke(LogType.PlcLog, String.Format("{0}轴读取设备EA值:{1}", logStr, qty));
|
|
|
LogHelper.Info(String.Format("{0}轴读取设备EA值:{1}", logStr, qty));
|
|
|
|
|
|
if (qty < 5 || qty > 350)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "获取设备EA为:" + qty + ",不进行完工处理,再判断绑定信息EA值为:"+shaftInfo.bindEaValue);
|
|
|
if (StringChange.ParseToInt(shaftInfo.bindEaValue) < 5 || StringChange.ParseToInt(shaftInfo.bindEaValue) > 350)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "获取设备EA为:" + qty + "绑定信息为:"+shaftInfo.bindEaValue+",不进行完工处理");
|
|
|
LogHelper.Info(logStr + "获取设备EA为:" + qty + "绑定信息为:" + shaftInfo.bindEaValue + ",不进行完工处理");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "获取设备EA为:" + qty + "绑定信息为:" + shaftInfo.bindEaValue + ",不进行完工处理");
|
|
|
AllowBlank(position);
|
|
|
plcBusiness.writeDoublePlc("MW24624", 0);//清除合卷报警
|
|
|
|
|
|
//清空卷轴绑定的物料信息
|
|
|
shaftInfo.bindRfid = "";
|
|
|
shaftInfo.bindSfc = "";
|
|
|
shaftInfo.bindEaValue = "";
|
|
|
await shaftInfoServices.Update(shaftInfo);
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
qty = StringChange.ParseToInt(shaftInfo.bindEaValue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//收卷结束MES逻辑处理
|
|
|
DownMaterialEndByMes(position, shaftInfo, qty);
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("模切收卷结束逻辑处理异常", ex);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "模切收卷结束逻辑处理异常:"+ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <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)
|
|
|
{
|
|
|
LogHelper.Info("获取卷轴信息异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "获取卷轴信息异常:" + ex.Message);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 通过RFID获取Mes账目数量
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="upMaterialSfc"></param>
|
|
|
/// <returns></returns>
|
|
|
private string GetMaterialEaByRfid(int position,string rfidStr)
|
|
|
{
|
|
|
string logStr = this.Which(position);
|
|
|
//获取RFID绑定的SFC信息
|
|
|
string sfc = GetSfcByRfid(rfidStr);
|
|
|
if (StringExtension.IsBlank(sfc))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, rfidStr + "未绑定SFC");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, rfidStr + "未绑定SFC");
|
|
|
return "0";
|
|
|
}
|
|
|
|
|
|
#region 获取放卷物料EA
|
|
|
LogHelper.Info(logStr + ",通过MES接口获取放卷物料的EA值");
|
|
|
MiSFCQueryQtyServiceServiceParam sFCQueryQtyServiceServiceParam = new MiSFCQueryQtyServiceServiceParam()
|
|
|
{
|
|
|
|
|
|
// url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiSFCQueryQtyServiceService?wsdl",
|
|
|
// site = "2100",
|
|
|
url = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "site"),
|
|
|
sfc = sfc
|
|
|
};
|
|
|
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}", sfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message)));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + ",通过MES接口获取放卷物料{0}的SFC数量失败:{1}", sfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message)));
|
|
|
LogHelper.Info("下发机台报警及气涨信号");
|
|
|
return "";
|
|
|
}
|
|
|
return sfcQueryQtyResponse.@return.qty;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "0";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info(String.Format(logStr + ",MES获取SFC数量接口异常:{1}", ex.Message));
|
|
|
WebServiceLog.saveMiSFCQueryQtyServiceService(sFCQueryQtyServiceServiceParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + ",MES获取SFC数量接口异常:{1}", ex.Message));
|
|
|
return "";
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷结束MES逻辑处理
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="shaftInfo"></param>
|
|
|
/// <param name="qty"></param>
|
|
|
public async void DownMaterialEndByMes(int position, ProShaftInfo shaftInfo, int qty)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
string logStr = "";
|
|
|
logStr = Which(position);
|
|
|
#endregion
|
|
|
|
|
|
LogHelper.Info(String.Format("{0}轴读取设备EA值:{1}", logStr, qty));
|
|
|
|
|
|
//获取RFID绑定的膜卷号
|
|
|
Expression<Func<ProDownRecord, bool>> exp = x => true;
|
|
|
exp = exp.And(x => x.PositionId == position && x.IsProduction == 0 && x.Rfid == shaftInfo.bindRfid);
|
|
|
Expression<Func<ProDownRecord, object>> orders = x => x.beginTime;
|
|
|
ProDownRecord downRecord = await downRecordServices.QueryFirst(exp, orders, false);
|
|
|
if (downRecord == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "收卷完成获取收卷记录信息为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
lock (string.Empty)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//获取重量特征数据上传至服务器
|
|
|
if (upLoadBusiness.JudgeResourceIsUplpadData())
|
|
|
{
|
|
|
machineIntegrationParametricData[] datas = GetMaterialWeight(shaftInfo, position, shaftInfo.bindSfc).Result;
|
|
|
UpLoadMaterialWeight(position, shaftInfo.bindSfc, downRecord.Id, datas);
|
|
|
}
|
|
|
#region 获取放卷物料EA
|
|
|
LogHelper.Info(logStr + "完工,通过MES接口获取放卷物料的EA值");
|
|
|
shaftInfo.bindEaValue = GetMaterialEaByMes(shaftInfo, position);
|
|
|
if (StringExtension.IsBlank(shaftInfo.bindEaValue))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "完工,Mes账目EA数量为空");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "完工,Mes账目EA数量为空");
|
|
|
return;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "完工,Mes账目EA数量:" + shaftInfo.bindEaValue + ";设备实物数量:" + qty);
|
|
|
LogHelper.Info(logStr + "完工,Mes账目EA数量:" + shaftInfo.bindEaValue + ";设备实物数量:" + qty);
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "完工,Mes账目EA数量:" + shaftInfo.bindEaValue + ";设备实物数量:" + qty);
|
|
|
//判断MES账目与实物数量,进行拆分完工
|
|
|
if (qty > StringChange.ParseToInt(shaftInfo.bindEaValue))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "实物数量大于MES数量,先调整再拆分");
|
|
|
LogHelper.Info("实物数量大于MES数量,先调整再拆分");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "实物数量大于MES数量,先调整再拆分");
|
|
|
|
|
|
if (StringExtension.IsBlank(downRecord.Sfc))
|
|
|
{
|
|
|
#region MES注销SFC接口
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "调用MES注销SFC接口");
|
|
|
//注销SFC
|
|
|
if (!SignOffSFCs(shaftInfo))
|
|
|
{
|
|
|
writeError(position, 2);
|
|
|
return;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region MES调整数量接口
|
|
|
int PLCqty = qty;
|
|
|
//调取MES调整数量接口
|
|
|
if (!AdujustQtySfcByMes(shaftInfo, position, PLCqty))
|
|
|
{
|
|
|
writeError(position, 2);
|
|
|
return;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region MES入账开始接口
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "MES入账开始接口");
|
|
|
if (!SFCBegin(shaftInfo))
|
|
|
{
|
|
|
writeError(position, 2);
|
|
|
return;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "已拆分完成不再调整数量");
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), logStr + "已拆分完成不再调整数量");
|
|
|
}
|
|
|
}
|
|
|
#region MES自动完工接口
|
|
|
if (!CompleteSfcByMes(shaftInfo, position, qty, downRecord))
|
|
|
{
|
|
|
writeError(position, 2);
|
|
|
return;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
downRecord.Sfc = GetSfcByRfid(shaftInfo.bindRfid);
|
|
|
downRecord.eaValue = qty;
|
|
|
downRecord.isFinish = 1;
|
|
|
downRecord.IsProduction = 1;
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, String.Format("RFID:{0}绑定膜卷号:{1}", downRecord.Rfid, downRecord.Sfc));
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = downRecord.Rfid,
|
|
|
sfc = downRecord.Sfc,
|
|
|
ea = downRecord.eaValue.ToString(),
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
|
|
|
LogHelper.Info(logStr + "下料成功解除合卷报警限制,MW24624写0");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "下料成功解除合卷报警限制,MW24624写0");
|
|
|
plcBusiness.writeDoublePlc("MW24624", 0);
|
|
|
|
|
|
//更新下料记录
|
|
|
//downRecord.DownMaterialId = shaftInfo.bindRfid;
|
|
|
downRecord.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
downRecordServices.Update(downRecord);
|
|
|
|
|
|
upLoadBusiness.UpdateDownRecord(downRecord);
|
|
|
|
|
|
//清空卷轴绑定的物料信息
|
|
|
shaftInfo.bindRfid = "";
|
|
|
shaftInfo.bindSfc = "";
|
|
|
shaftInfo.bindEaValue = "";
|
|
|
shaftInfoServices.Update(shaftInfo);
|
|
|
|
|
|
//别忘了更新绑定条码的状态***********************
|
|
|
LogHelper.Info(logStr + "完工流程结束,更新生产信息状态");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "完工流程结束,更新生产信息状态");
|
|
|
|
|
|
//add by yinzf 2022-8-7 流程走完,可以下料
|
|
|
AllowBlank(position);
|
|
|
//end add
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "收卷完工流程结束");
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
writeError(position, 4);
|
|
|
LogHelper.Info(e.ToString());
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "收卷结束MES流程处理异常:" + e.ToString());
|
|
|
//upLoadBusiness.SaveLogRecord(position, "收卷结束MES流程处理异常:" + e.ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 强制下料
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
public void ForceDown(int position)
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷涨紧MES入账处理
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="epc"></param>
|
|
|
/// <param name="auto"></param>
|
|
|
public async void UpMaterialBeginByMes(int position, string epc, bool auto)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
string sfc = "";
|
|
|
string qty = "";
|
|
|
string logStr = Which(position);
|
|
|
#endregion
|
|
|
|
|
|
//如果不是自动的就清掉PLC信号
|
|
|
if (!auto)
|
|
|
{
|
|
|
AngrilyResultSendToPlc(position, 1, 0);
|
|
|
ManualClearWarning(position);
|
|
|
}
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
sfc = "",
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
|
|
|
#region add by wenjy 20220903 放卷位入账EA防呆,小于20不入账
|
|
|
var mesQty = StringChange.ParseToInt(GetMaterialEaByRfid(position, epc));
|
|
|
if (mesQty < 20)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "自动入账失败:EA值小于20,实际为:" + mesQty);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "自动入账失败:EA值小于20,实际为:" + mesQty);
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "自动入账失败:EA值小于20,实际为:" + mesQty);
|
|
|
|
|
|
//下发上料结果
|
|
|
AngrilyResultSendToPlc(position, 2, 2);
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
LogHelper.Info("开始调用MES自动入账接口");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "调用MES入账接口");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "开始调用MES自动入账接口");
|
|
|
|
|
|
MiFirstOperationForsfcServiceServiceParam miFirstOperationForsfcServiceServiceParam = new MiFirstOperationForsfcServiceServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiFirstOperationForsfcServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//sfc = "",
|
|
|
//processLot = epc,
|
|
|
//operation = appConfig.operation,
|
|
|
//operationRevision = "#",
|
|
|
//resource = appConfig.resource,
|
|
|
//user = "SUP_LYA_RF01",
|
|
|
//activity = "",
|
|
|
//modeProcessSfc = "MODE_START_SFC",
|
|
|
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"),
|
|
|
|
|
|
};
|
|
|
DateTime beginTime = DateTime.Now;
|
|
|
miFirstOperationForsfcResponse firstOperationForsfcResponse = new miFirstOperationForsfcResponse();
|
|
|
try
|
|
|
{
|
|
|
LogHelper.Info("MES自动入账接口请求参数:" + JsonChange.ModeToJson(miFirstOperationForsfcServiceServiceParam));
|
|
|
//upLoadBusiness.SaveLogRecord(position, "MES自动入账接口请求参数:" + JsonChange.ModeToJson(miFirstOperationForsfcServiceServiceParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
firstOperationForsfcResponse = MesWebServices.iMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam);
|
|
|
LogHelper.Info("MES自动入账接口返回参数:" + JsonChange.ModeToJson(firstOperationForsfcResponse));
|
|
|
//upLoadBusiness.SaveLogRecord(position, "MES自动入账接口返回参数:" + JsonChange.ModeToJson(firstOperationForsfcResponse));
|
|
|
|
|
|
//判断返回结果
|
|
|
if (firstOperationForsfcResponse.@return.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES自动入账接口返回异常:" + firstOperationForsfcResponse.@return.message);
|
|
|
//upLoadBusiness.SaveLogRecord(position, "MES自动入账接口返回异常:" + firstOperationForsfcResponse.@return.message);
|
|
|
//下发上料结果
|
|
|
AngrilyResultSendToPlc(position, 2, 2);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "自动入账失败:" + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "自动入账失败,下发异常报警信息");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
sfc = firstOperationForsfcResponse.@return.sfc;
|
|
|
qty = firstOperationForsfcResponse.@return.qty;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sfc = System.Guid.NewGuid().ToString("N").Substring(0, 14);
|
|
|
qty = "14";
|
|
|
}
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "MES入账接口调用成功,SFC:" + sfc + ";EA:" + qty);
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "MES入账接口调用成功,SFC:" + sfc + ";EA:" + qty);
|
|
|
LogHelper.Info(logStr + "MES入账接口调用成功,SFC:" + sfc + ";EA:" + qty);
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "MES入账接口调用成功,SFC:" + sfc + ";EA:" + qty);
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info(logStr + "MES自动入账接口请求异常:" + ex.Message);
|
|
|
WebServiceLog.saveMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "MES自动入账接口异常:" + ex.Message);
|
|
|
//下发上料结果
|
|
|
AngrilyResultSendToPlc(position, 2, 2);
|
|
|
LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "MES自动入账接口异常下发异常报警信息");
|
|
|
//upLoadBusiness.SaveLogRecord(position, logStr + "MES自动入账接口请求异常:" + ex.Message);
|
|
|
return;
|
|
|
}
|
|
|
//下发PLC读取结果
|
|
|
UpmaterialReadSuccess(position);
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
position = position,
|
|
|
sfc = sfc,
|
|
|
ea = qty
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
|
|
|
//实时绑定卷轴与RFID信息
|
|
|
LogHelper.Info(String.Format("绑定{0}卷轴与RFID:{1}获取卷轴信息", logStr, epc));
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("绑定{0}卷轴与RFID:{1}获取卷轴信息", logStr, epc));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("绑定{0}卷轴与RFID:{1}获取卷轴信息", logStr, epc));
|
|
|
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position);
|
|
|
|
|
|
if (shaftInfo == null || StringExtension.IsBlank(shaftInfo.processId))
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "绑定卷轴与RFID获取卷轴信息为空");
|
|
|
LogHelper.Info("绑定卷轴与RFID获取卷轴信息为空");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "绑定卷轴与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");
|
|
|
if(await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogHelper.Info(String.Format("绑定{0}卷轴与RFID:{1}获取卷轴信息成功", logStr, epc));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info(String.Format("绑定{0}卷轴与RFID:{1}获取卷轴信息失败", logStr, epc));
|
|
|
}
|
|
|
|
|
|
string UpMaterialId = "";
|
|
|
|
|
|
#region 重量特征数据上传 Add By wenjy 2022-12-02 获取冷压重量特征数据
|
|
|
if (upLoadBusiness.JudgeResourceIsUplpadData())
|
|
|
{
|
|
|
GetParametricValueRequestData[] parametricValueRequestDatas = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "LY_WLMX" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_S_X01" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_S_X02" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_B_X01" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_B_X02" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" },
|
|
|
};
|
|
|
var lyMaterialCharacter = GetLyMaterialCharacter(sfc, parametricValueRequestDatas); //获取冷压特征数据
|
|
|
|
|
|
|
|
|
//foreach (var item in lyMaterialCharacter.paramValues)
|
|
|
//{
|
|
|
// if (item.parameter == "S_TARGETCW") item.parameter = ;
|
|
|
//}
|
|
|
LogHelper.Info("获取冷压重量特征数据:" + JsonChange.ModeToJson(lyMaterialCharacter));
|
|
|
//upLoadBusiness.SaveLogRecord(position, "获取冷压重量特征数据:" + JsonChange.ModeToJson(lyMaterialCharacter));
|
|
|
UpMaterialId = JsonChange.ModeToJson(lyMaterialCharacter);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
//添加上料记录
|
|
|
ProUpRecord upRecord = new ProUpRecord()
|
|
|
{
|
|
|
Id = System.Guid.NewGuid().ToString(),
|
|
|
MachineId = appConfig.machineId,
|
|
|
PositionId = position,
|
|
|
UpMaterialId = UpMaterialId,
|
|
|
Rfid = epc,
|
|
|
IsProduction = 0,
|
|
|
Sfc = sfc,
|
|
|
eaValue = StringChange.ParseToInt(qty),
|
|
|
RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
};
|
|
|
|
|
|
await upRecordServices.Add(upRecord);
|
|
|
|
|
|
upLoadBusiness.SaveUpRecord(upRecord);
|
|
|
|
|
|
WriteSfcToPLC(sfc, position);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 收卷位涨紧MES信息处理
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="epc"></param>
|
|
|
/// <param name="auto"></param>
|
|
|
public async void DownMaterialBeginByMes(int position, string epc, bool auto)
|
|
|
{
|
|
|
#region 参数定义
|
|
|
string logStr = Which(position);
|
|
|
#endregion
|
|
|
try
|
|
|
{
|
|
|
///如果是手动触发,清理信号
|
|
|
if (!auto)
|
|
|
{
|
|
|
AngrilyResultSendToPlc(position, 1, 0);
|
|
|
ManualClearWarning(position);
|
|
|
}
|
|
|
|
|
|
ViewModelRefreshEvent?.Invoke(new ViewModelDto()
|
|
|
{
|
|
|
rfidInfo = new RfidInfoDto()
|
|
|
{
|
|
|
rfid = epc,
|
|
|
position = position,
|
|
|
},
|
|
|
plcStatus = true,
|
|
|
});
|
|
|
|
|
|
// 不登录不让生产 AngrilyResultSendToPlc(position, 2, 2);//收卷位报警
|
|
|
|
|
|
//绑定卷轴与RFID信息
|
|
|
ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position);
|
|
|
|
|
|
if (shaftInfo == null)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "绑定卷轴与物料信息,获取卷轴信息为空");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "绑定卷轴与物料信息,获取卷轴信息为空");
|
|
|
LogHelper.Info("绑定卷轴与物料信息,获取卷轴信息为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if(StringExtension.IsBlank(shaftInfo.bindRfid) ||shaftInfo.bindRfid != epc)
|
|
|
{
|
|
|
shaftInfo.bindRfid = epc;
|
|
|
shaftInfo.bindSfc = "";
|
|
|
shaftInfo.bindEaValue = "";
|
|
|
shaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
await shaftInfoServices.Update(shaftInfo);
|
|
|
LogHelper.Info(String.Format("{0}绑定RFID条码信息:{1}", logStr, epc));
|
|
|
}
|
|
|
|
|
|
#region 清除定时读取RFID条码信息 Add By wenjy 2022-12-04
|
|
|
DeleteBindInfo(shaftInfo);
|
|
|
#endregion
|
|
|
|
|
|
//添加下料记录
|
|
|
ProDownRecord downRecord = new ProDownRecord()
|
|
|
{
|
|
|
Id = System.Guid.NewGuid().ToString("N"),
|
|
|
MachineId = appConfig.machineId,
|
|
|
PositionId = position,
|
|
|
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);
|
|
|
// 操作员字段,传到web -----------
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
LogHelper.Info(e.ToString());
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "收卷位涨紧MES信息处理异常:" + e.Message);
|
|
|
}
|
|
|
WriteSfcToPLC(epc, position);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// MES自动入账接口开始SFC
|
|
|
/// </summary>
|
|
|
/// <param name="shaftInfo"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool SFCBegin(ProShaftInfo shaftInfo)
|
|
|
{
|
|
|
LogHelper.Info("调用MES自动入账开始接口");
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES自动入账开始接口");
|
|
|
MiFirstOperationForsfcServiceServiceParam miFirstOperationForsfcServiceServiceParam = new MiFirstOperationForsfcServiceServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiFirstOperationForsfcServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//sfc = shaftInfo.bindSfc,
|
|
|
//processLot = "",
|
|
|
//operation = appConfig.operation,
|
|
|
//operationRevision = "#",
|
|
|
//resource = appConfig.resource,
|
|
|
//user = "SUP_LYA_RF01",
|
|
|
//activity = "",
|
|
|
//modeProcessSfc = "MODE_START_SFC",
|
|
|
url = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "site"),
|
|
|
sfc = shaftInfo.bindSfc,
|
|
|
processLot = "",
|
|
|
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"),
|
|
|
};
|
|
|
DateTime beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
LogHelper.Info("调用A面自动入账接口请求参数:" + JsonChange.ModeToJson(miFirstOperationForsfcServiceServiceParam));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用A面自动入账接口请求参数:" + JsonChange.ModeToJson(miFirstOperationForsfcServiceServiceParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
miFirstOperationForsfcResponse firstOperationForsfcResponse = MesWebServices.iMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam);
|
|
|
LogHelper.Info("调用A面自动入账接口返回参数:" + JsonChange.ModeToJson(firstOperationForsfcResponse));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用A面自动入账接口返回参数:" + JsonChange.ModeToJson(firstOperationForsfcResponse));
|
|
|
if (firstOperationForsfcResponse.@return.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES自动入账开始接口调用失败:" + firstOperationForsfcResponse.@return.message);
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES自动入账开始接口调用失败:" + firstOperationForsfcResponse.@return.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动入账开始接口调用失败:" + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES自动入账开始接口调用失败:" + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message));
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("调用MES自动入账接口异常:" + ex.Message);
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES自动入账接口异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "调用MES自动入账接口异常:" + ex.Message);
|
|
|
WebServiceLog.saveMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam, null, beginTime, ex.Message);
|
|
|
return false;
|
|
|
}
|
|
|
LogHelper.Info("调用MES自动入账接口成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES自动入账接口成功");
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES自动入账接口成功");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// MES注销SFC接口
|
|
|
/// </summary>
|
|
|
/// <param name="shaftInfo"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool SignOffSFCs(ProShaftInfo shaftInfo)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "调用MES注销SFC接口" + shaftInfo.bindSfc);
|
|
|
LogHelper.Info("调用MES注销SFC接口" + shaftInfo.bindSfc);
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES注销SFC接口" + shaftInfo.bindSfc);
|
|
|
MiSignOffSFCsServiceServiceParam miSignOffSFCsServiceServiceParam = new MiSignOffSFCsServiceServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiSignOffSFCsServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//user = "SUP_LYA_RF01",
|
|
|
//operation = appConfig.operation,
|
|
|
//operationRevision = "A",
|
|
|
//activityId = "EAP_WS",
|
|
|
//Resource = appConfig.resource,
|
|
|
//amount = "1",
|
|
|
//sfcDataArray = null,
|
|
|
//sfc = shaftInfo.bindSfc,
|
|
|
url = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam","url"),
|
|
|
site = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "site"),
|
|
|
user = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "user"),
|
|
|
operation = appConfig.operation,
|
|
|
operationRevision = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "operationRevision"),
|
|
|
activityId = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "activityId"),
|
|
|
Resource = appConfig.resource,
|
|
|
amount = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "amount"),
|
|
|
sfcDataArray = null,
|
|
|
sfc = shaftInfo.bindSfc,
|
|
|
};
|
|
|
DateTime beginTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
|
|
|
LogHelper.Info("调用MES注销SFC接口请求参数:" + JsonChange.ModeToJson(miSignOffSFCsServiceServiceParam));
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES注销SFC接口请求参数:" + JsonChange.ModeToJson(miSignOffSFCsServiceServiceParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
miSignOffSFCsResponse signOffSFCsResponse = MesWebServices.iMiSignOffSFCsServiceService(miSignOffSFCsServiceServiceParam);
|
|
|
LogHelper.Info("调用MES注销SFC接口返回参数:" + JsonChange.ModeToJson(signOffSFCsResponse));
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES注销SFC接口返回参数:" + JsonChange.ModeToJson(signOffSFCsResponse));
|
|
|
if (signOffSFCsResponse == null || signOffSFCsResponse.@return.code > 0)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "注销SFC接口调用失败:" + upLoadBusiness.GetMesMessage(signOffSFCsResponse.@return.code, signOffSFCsResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "注销SFC接口调用失败:" + upLoadBusiness.GetMesMessage(signOffSFCsResponse.@return.code, signOffSFCsResponse.@return.message));
|
|
|
LogHelper.Info("注销SFC接口调用失败:" + signOffSFCsResponse.@return.message);
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "注销SFC接口调用失败:" + signOffSFCsResponse.@return.message);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("调用MES注销SFC接口异常:" + ex.Message);
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES注销SFC接口异常:" + ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("调用MES注销SFC接口异常:", ex.Message));
|
|
|
WebServiceLog.saveMiSignOffSFCsServiceService(miSignOffSFCsServiceServiceParam, null, beginTime, ex.Message);
|
|
|
return false;
|
|
|
}
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, String.Format("注销SFC接口调用成功,SFC:{0}", shaftInfo.bindSfc));
|
|
|
LogHelper.Info(String.Format("注销SFC接口调用成功,SFC:{0}", shaftInfo.bindSfc));
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), String.Format("注销SFC接口调用成功,SFC:{0}", shaftInfo.bindSfc));
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 通过MES接口获取放卷位物料EA数量
|
|
|
/// </summary>
|
|
|
/// <param name="shaftInfo"></param>
|
|
|
/// <param name="position"></param>
|
|
|
private string GetMaterialEaByMes(ProShaftInfo shaftInfo, int position)
|
|
|
{
|
|
|
string logStr = Which(position);
|
|
|
string mesQty = "";
|
|
|
MiSFCQueryQtyServiceServiceParam sFCQueryQtyServiceServiceParam = new MiSFCQueryQtyServiceServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiSFCQueryQtyServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//sfc = shaftInfo.bindSfc
|
|
|
url = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "site"),
|
|
|
sfc = shaftInfo.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)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, String.Format(logStr + ",通过MES接口获取放卷物料{0}的SFC数量失败:{1}", shaftInfo.bindSfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message)));
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + ",通过MES接口获取放卷物料{0}的SFC数量失败:{1}", shaftInfo.bindSfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
mesQty = sfcQueryQtyResponse.@return.qty;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info(String.Format(logStr + "完工,MES获取SFC数量接口异常:{1}", ex.Message));
|
|
|
WebServiceLog.saveMiSFCQueryQtyServiceService(sFCQueryQtyServiceServiceParam, null, beginTime, ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + "完工,MES获取SFC数量接口异常:{1}", ex.Message));
|
|
|
writeError(position, 2);
|
|
|
}
|
|
|
return mesQty;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// MES自动完工接口
|
|
|
/// </summary>
|
|
|
/// <param name="shaftInfo"></param>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="qty"></param>
|
|
|
private bool CompleteSfcByMes(ProShaftInfo shaftInfo, int position, int qty,ProDownRecord downRecord)
|
|
|
{
|
|
|
bool boolFlag = false;
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES自动拆分接口");
|
|
|
LogHelper.Info("调用MES自动拆分接口");
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "调用MES自动拆分接口");
|
|
|
WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC;
|
|
|
machineIntegrationParametricData[] datas = GetCcdTreetopAmount(position);
|
|
|
#region 重量特征数据上传 Add By wenjy 2022-12-02 过账模式只拆分不完工
|
|
|
if (upLoadBusiness.JudgeResourceIsUplpadData())
|
|
|
{
|
|
|
LogHelper.Info("190品种获取重量特征数据");
|
|
|
modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_NONE;
|
|
|
|
|
|
datas = GetMaterialWeight(shaftInfo, position, shaftInfo.bindSfc).Result;
|
|
|
}
|
|
|
#endregion
|
|
|
miBatchCompleteSfcAndAdujustQtySfcEntity[] miBatchCompleteSfcAndAdujustQtySfcEntities = new miBatchCompleteSfcAndAdujustQtySfcEntity[]
|
|
|
{
|
|
|
new miBatchCompleteSfcAndAdujustQtySfcEntity()
|
|
|
{
|
|
|
processLot = shaftInfo.bindRfid,
|
|
|
qty = qty.ToString(),
|
|
|
unit = "EA",
|
|
|
}
|
|
|
};
|
|
|
|
|
|
var requestParam = new MiBatchCompleteSfcAndAdujustQtyServiceServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiBatchCompleteSfcAndAdujustQtyServiceService?wsdl",
|
|
|
url = inifile.IniReadValue("SplitSfcParam", "url"),
|
|
|
site = inifile.IniReadValue("SplitSfcParam", "site"),
|
|
|
sfcPre = shaftInfo.bindSfc,
|
|
|
processLotPre = "",
|
|
|
operation = appConfig.operation,
|
|
|
operationRevision = inifile.IniReadValue("SplitSfcParam", "operationRevision"),
|
|
|
resource = appConfig.resource,
|
|
|
user = inifile.IniReadValue("SplitSfcParam", "user"),
|
|
|
activity = inifile.IniReadValue("SplitSfcParam", "activity"),
|
|
|
modeProcessSfc = modeProcessSfc,
|
|
|
sfcList = miBatchCompleteSfcAndAdujustQtySfcEntities,
|
|
|
};
|
|
|
if (StringExtension.IsNotBlank(downRecord.shaftNumber))
|
|
|
{
|
|
|
requestParam.tailmark = downRecord.shaftNumber;
|
|
|
}
|
|
|
LogHelper.Info("MES自动拆分接口请求参数:" + JsonChange.ModeToJson(requestParam));
|
|
|
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
if (StringExtension.IsBlank(downRecord.Sfc))
|
|
|
{
|
|
|
MiBatchCompleteSfcAndAdujustQtyResponse batchCompleteSfcAndAdujustQtyResponse = MesWebServices.iMiBatchCompleteSfcAndAdujustQtyServiceService(requestParam);
|
|
|
LogHelper.Info("MES自动拆分接口返回参数:" + JsonChange.ModeToJson(batchCompleteSfcAndAdujustQtyResponse));
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES自动拆分接口返回参数:" + JsonChange.ModeToJson(batchCompleteSfcAndAdujustQtyResponse));
|
|
|
var result = batchCompleteSfcAndAdujustQtyResponse.@return;
|
|
|
|
|
|
if (result.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES自动拆分接口调用失败:" + batchCompleteSfcAndAdujustQtyResponse.@return.message);
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES自动拆分接口调用失败:" + batchCompleteSfcAndAdujustQtyResponse.@return.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES自动拆分接口调用失败:" + upLoadBusiness.GetMesMessage(batchCompleteSfcAndAdujustQtyResponse.@return.code, batchCompleteSfcAndAdujustQtyResponse.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动拆分接口调用失败:" + upLoadBusiness.GetMesMessage(batchCompleteSfcAndAdujustQtyResponse.@return.code, batchCompleteSfcAndAdujustQtyResponse.@return.message));
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
LogHelper.Info("MES自动拆分接口调用成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动拆分接口调用成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "MES自动拆分接口调用成功");
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES自动拆分接口调用成功");
|
|
|
|
|
|
#region 重量特征数据上传 Add By wenjy 2022-12-02
|
|
|
if (upLoadBusiness.JudgeResourceIsUplpadData())
|
|
|
{
|
|
|
string splitMaterialSfc = GetSfcByRfid(shaftInfo.bindRfid);
|
|
|
downRecord.Sfc = splitMaterialSfc;
|
|
|
downRecord.eaValue = qty;
|
|
|
downRecord.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
downRecordServices.Update(downRecord);
|
|
|
|
|
|
// ccd单独上传数据收集组*Y
|
|
|
// UpMQMesData1(position, GetCcdTreetopAmount(position), splitMaterialSfc);
|
|
|
|
|
|
if (UpMQMesData(position, datas, splitMaterialSfc,downRecord))
|
|
|
{
|
|
|
LogHelper.Info("模切数据上传成功");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "模切数据上传成功");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切数据上传成功");
|
|
|
|
|
|
boolFlag = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("模切数据上传失败");
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "模切数据上传失败");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切数据上传失败");
|
|
|
boolFlag = false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boolFlag = true;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
return boolFlag;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 调用MES调整数量接口
|
|
|
/// </summary>
|
|
|
/// <param name="shaftInfo"></param>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="PLCqty"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool AdujustQtySfcByMes(ProShaftInfo shaftInfo, int position, int PLCqty)
|
|
|
{
|
|
|
bool boolFlag = false;
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES调整数量接口");
|
|
|
MiBatchCompleteSfcAndAdujustQtyServiceServiceParam miBatchCompleteSfcAndAdujustQtyServiceServiceParam = new MiBatchCompleteSfcAndAdujustQtyServiceServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MiBatchCompleteSfcAndAdujustQtyServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//sfcPre = shaftInfo.bindSfc,
|
|
|
//processLotPre = "",
|
|
|
//operation = appConfig.operation,
|
|
|
//operationRevision = "A",
|
|
|
//resource = appConfig.resource,
|
|
|
//user = "SUP_LYA_RF01",
|
|
|
//activity = "Z_PR591",
|
|
|
//modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_NONE,
|
|
|
url = inifile.IniReadValue("AdujustQtyParam", "url"),
|
|
|
site = inifile.IniReadValue("AdujustQtyParam", "site"),
|
|
|
sfcPre = shaftInfo.bindSfc,
|
|
|
processLotPre = "",
|
|
|
operation = appConfig.operation,
|
|
|
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 = "",
|
|
|
sfc = shaftInfo.bindSfc,
|
|
|
qty = PLCqty.ToString(),
|
|
|
unit = "EA"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
};
|
|
|
LogHelper.Info("调用MES接口调整物料" + shaftInfo.bindSfc + "数量");
|
|
|
LogHelper.Info("MES调整数量接口请求参数:" + JsonChange.ModeToJson(miBatchCompleteSfcAndAdujustQtyServiceServiceParam));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES调整数量接口请求参数:" + JsonChange.ModeToJson(miBatchCompleteSfcAndAdujustQtyServiceServiceParam));
|
|
|
if (appConfig.isMesFlag == 1)
|
|
|
{
|
|
|
var requestResult = MesWebServices.iMiBatchCompleteSfcAndAdujustQtyServiceService(miBatchCompleteSfcAndAdujustQtyServiceServiceParam);
|
|
|
LogHelper.Info("MES调整数量接口返回参数:" + JsonChange.ModeToJson(requestResult));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES调整数量接口返回参数:" + JsonChange.ModeToJson(requestResult));
|
|
|
if (requestResult.@return.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("MES调整数量接口调用失败:" + requestResult.@return.message);
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES调整数量接口调用失败:" + requestResult.@return.message);
|
|
|
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES调整数量接口调用失败:" + upLoadBusiness.GetMesMessage(requestResult.@return.code, requestResult.@return.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES调整数量接口调用失败:" + upLoadBusiness.GetMesMessage(requestResult.@return.code, requestResult.@return.message));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boolFlag = true;
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "MES调整数量接口调用成功");
|
|
|
//upLoadBusiness.SaveLogRecord(StringChange.ParseToInt(shaftInfo.positionId), "MES调整数量接口调用成功");
|
|
|
}
|
|
|
}
|
|
|
return boolFlag;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 合卷判断
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private async Task<bool> SelectSfcIsHeJuan(int upPosition, int downPosition)
|
|
|
{
|
|
|
string logStr = Which(downPosition);
|
|
|
string upStr = Which(upPosition);
|
|
|
LogHelper.Info("合卷逻辑判断:判断"+logStr+"轴与"+upStr+"轴绑定的SFC是否一致");
|
|
|
//获取放卷位信息
|
|
|
ProShaftInfo upShaftInfo = await this.GetShaftInfoByPosition(upPosition);
|
|
|
//获取收卷轴绑定信息
|
|
|
ProShaftInfo downShaftInfo = await this.GetShaftInfoByPosition(downPosition);
|
|
|
LogHelper.Info(String.Format("当前放卷轴信息:{0},收卷轴信息:{1}",JsonChange.ModeToJson(upShaftInfo),JsonChange.ModeToJson(downShaftInfo)));
|
|
|
|
|
|
if(StringExtension.IsNotBlank(upShaftInfo.bindSfc) && StringExtension.IsNotBlank(downShaftInfo.bindSfc))
|
|
|
{
|
|
|
if (upShaftInfo.bindSfc != downShaftInfo.bindSfc)
|
|
|
{
|
|
|
LogHelper.Info("合卷逻辑判断:" + logStr + "轴"+downShaftInfo.bindSfc+"与" + upStr + "轴" + upShaftInfo.bindSfc + "绑定的SFC不一致,触发合卷报警");
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + "轴与" + upStr + "轴绑定的SFC不一致,触发合卷报警");
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <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);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "串读逻辑处理异常:" + ex.Message);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 解绑RFID与SFC
|
|
|
/// </summary>
|
|
|
/// <param name="rfidStr"></param>
|
|
|
private void UnBindRfidAndSfc(string rfidStr)
|
|
|
{
|
|
|
//获取当前RFID是否绑定
|
|
|
string sfcStr = GetSfcByRfid(rfidStr);
|
|
|
DateTime beginTime = new DateTime();
|
|
|
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.AlarmLog, String.Format("RFID条码:{0}解绑失败:{1}!!!", rfidStr, ex.Message));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("RFID条码:" + rfidStr + "未绑定SFC信息");
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, "RFID条码:" + rfidStr + "未绑定SFC信息");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 涨紧逻辑处理结果及报警信息
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="result">1、OK,2、NG</param>
|
|
|
/// <param name="alarm">0、取消报警,1、RFID读取失败,2、MES接口异常</param>
|
|
|
private void AngrilyResultSendToPlc(int position, int result, int alarm)
|
|
|
{
|
|
|
if (appConfig.processId.Equals("MQ_A"))
|
|
|
{
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24652", result);
|
|
|
plcBusiness.writePlc("MW24656", alarm);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24668", result);
|
|
|
plcBusiness.writePlc("MW24672", alarm);
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24644", result);
|
|
|
plcBusiness.writePlc("MW24648", alarm);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24660", result);
|
|
|
plcBusiness.writePlc("MW24664", alarm);
|
|
|
}
|
|
|
if (position == 5)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24636", result); //RFID扫描结果
|
|
|
plcBusiness.writePlc("MW24640", alarm); //RFID报警信息
|
|
|
}
|
|
|
if (position == 6)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24628", result);
|
|
|
plcBusiness.writePlc("MW24632", alarm);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24652", result);
|
|
|
plcBusiness.writePlc("MW24656", alarm);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24668", result);
|
|
|
plcBusiness.writePlc("MW24672", alarm);
|
|
|
}
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24644", result);
|
|
|
plcBusiness.writePlc("MW24648", alarm);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24660", result);
|
|
|
plcBusiness.writePlc("MW24664", alarm);
|
|
|
}
|
|
|
if (position == 5)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24628", result);
|
|
|
plcBusiness.writePlc("MW24632", alarm); //RFID报警信息
|
|
|
}
|
|
|
if (position == 6)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24636", result); //RFID扫描结果
|
|
|
plcBusiness.writePlc("MW24640", alarm);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷RFID读取成功,下发PLC读取结果
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
private void UpmaterialReadSuccess(int position)
|
|
|
{
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24652", 1);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24668", 1);
|
|
|
}
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24644", 1);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24660", 1);
|
|
|
}
|
|
|
if (position == 5)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24636", 1);
|
|
|
}
|
|
|
if (position == 6)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24628", 1);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 3)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24652", 1);
|
|
|
}
|
|
|
if (position == 4)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24668", 1);
|
|
|
}
|
|
|
if (position == 1)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24644", 1);
|
|
|
}
|
|
|
if (position == 2)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24660", 1);
|
|
|
}
|
|
|
if (position == 5)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24628", 1);
|
|
|
}
|
|
|
if (position == 6)
|
|
|
{
|
|
|
plcBusiness.writePlc("MW24636", 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁止下料
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
private void ForbidBlank(int position)
|
|
|
{
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 1)
|
|
|
plcBusiness.writePlc("MW24826", 1);
|
|
|
if (position == 2)
|
|
|
plcBusiness.writePlc("MW24830", 1);
|
|
|
if (position == 3)
|
|
|
plcBusiness.writePlc("MW24824", 1);
|
|
|
if (position == 4)
|
|
|
plcBusiness.writePlc("MW24828", 1);
|
|
|
if (position == 5)
|
|
|
plcBusiness.writePlc("MW24822", 1);
|
|
|
if (position == 6)
|
|
|
plcBusiness.writePlc("MW24820", 1);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1)
|
|
|
plcBusiness.writePlc("MW24824", 1);
|
|
|
if (position == 2)
|
|
|
plcBusiness.writePlc("MW24828", 1);
|
|
|
if (position == 3)
|
|
|
plcBusiness.writePlc("MW24826", 1);
|
|
|
if (position == 4)
|
|
|
plcBusiness.writePlc("MW24830", 1);
|
|
|
if (position == 5)
|
|
|
plcBusiness.writePlc("MW24820", 1);
|
|
|
if (position == 6)
|
|
|
plcBusiness.writePlc("MW24822", 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 允许下料
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
private void AllowBlank(int position)
|
|
|
{
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
|
|
|
if (position == 3)
|
|
|
plcBusiness.writePlc("MW24824", 0);
|
|
|
if (position == 1)
|
|
|
plcBusiness.writePlc("MW24826", 0);
|
|
|
if (position == 4)
|
|
|
plcBusiness.writePlc("MW24828", 0);
|
|
|
if (position == 2)
|
|
|
plcBusiness.writePlc("MW24830", 0);
|
|
|
if (position == 5)
|
|
|
plcBusiness.writePlc("MW24822", 0);
|
|
|
if (position == 6)
|
|
|
plcBusiness.writePlc("MW24820", 0);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1)
|
|
|
plcBusiness.writePlc("MW24824", 0);
|
|
|
if (position == 3)
|
|
|
plcBusiness.writePlc("MW24826", 0);
|
|
|
if (position == 2)
|
|
|
plcBusiness.writePlc("MW24828", 0);
|
|
|
if (position == 4)
|
|
|
plcBusiness.writePlc("MW24830", 0);
|
|
|
if (position == 5)
|
|
|
plcBusiness.writePlc("MW24820", 0);
|
|
|
if (position == 6)
|
|
|
plcBusiness.writePlc("MW24822", 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
///判断当前是哪个轴
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private string Which(int position)
|
|
|
{
|
|
|
string logStr = "";
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 3) logStr = "上收卷左";
|
|
|
if (position == 1) logStr = "上收卷右";
|
|
|
if (position == 4) logStr = "下收卷左";
|
|
|
if (position == 2) logStr = "下收卷右";
|
|
|
if (position == 5) logStr = "右放卷";
|
|
|
if (position == 6) logStr = "左放卷";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1) logStr = "上收卷左";
|
|
|
if (position == 3) logStr = "上收卷右";
|
|
|
if (position == 2) logStr = "下收卷左";
|
|
|
if (position == 4) logStr = "下收卷右";
|
|
|
if (position == 5) logStr = "左放卷";
|
|
|
if (position == 6) logStr = "右放卷";
|
|
|
}
|
|
|
return logStr;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 写入SFC
|
|
|
/// </summary>
|
|
|
/// <param name="sfc"></param>
|
|
|
/// <param name="position"></param>
|
|
|
private void WriteSfcToPLC(string sfc, int position)
|
|
|
{
|
|
|
string str = Which(position);
|
|
|
string PLCaddress = "";
|
|
|
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 3)
|
|
|
PLCaddress = "MW24848";
|
|
|
if (position == 1)
|
|
|
PLCaddress = "MW24850";
|
|
|
if (position == 4)
|
|
|
PLCaddress = "MW24852";
|
|
|
if (position == 2)
|
|
|
PLCaddress = "MW24854";
|
|
|
if (position == 5)
|
|
|
PLCaddress = "MW24846";
|
|
|
if (position == 6)
|
|
|
PLCaddress = "MW248544";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1)
|
|
|
PLCaddress = "MW24848";
|
|
|
if (position == 3)
|
|
|
PLCaddress = "MW24850";
|
|
|
if (position == 2)
|
|
|
PLCaddress = "MW24852";
|
|
|
if (position == 4)
|
|
|
PLCaddress = "MW24854";
|
|
|
if (position == 5)
|
|
|
PLCaddress = "MW248544";
|
|
|
if (position == 6)
|
|
|
PLCaddress = "MW24846";
|
|
|
}
|
|
|
LogHelper.Info(str + "向PLC地址:" + PLCaddress + "写入SFC:" + sfc);
|
|
|
PlcBusiness.writeStrPlc(PLCaddress, sfc);
|
|
|
}
|
|
|
|
|
|
private void writeError(int position, int alarmType)
|
|
|
{
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 3) plcBusiness.writePlc("MW24648", alarmType);
|
|
|
if (position == 1) plcBusiness.writePlc("MW24656", alarmType);
|
|
|
if (position == 4) plcBusiness.writePlc("MW24664", alarmType);
|
|
|
if (position == 2) plcBusiness.writePlc("MW24672", alarmType);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1) plcBusiness.writePlc("MW24648", alarmType);
|
|
|
if (position == 3) plcBusiness.writePlc("MW24656", alarmType);
|
|
|
if (position == 2) plcBusiness.writePlc("MW24664", alarmType);
|
|
|
if (position == 4) plcBusiness.writePlc("MW24672", alarmType);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 手动写入时,清除当前报警信号
|
|
|
/// </summary>
|
|
|
private void ManualClearWarning(int position)
|
|
|
{
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 3)
|
|
|
plcBusiness.writePlc("MW24836", 1);
|
|
|
if (position == 1)
|
|
|
plcBusiness.writePlc("MW24838", 1);
|
|
|
if (position == 4)
|
|
|
plcBusiness.writePlc("MW24840", 1);
|
|
|
if (position == 2)
|
|
|
plcBusiness.writePlc("MW24842", 1);
|
|
|
if (position == 5)
|
|
|
plcBusiness.writePlc("MW24834", 1);
|
|
|
if (position == 6)
|
|
|
plcBusiness.writePlc("MW24832", 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1)
|
|
|
plcBusiness.writePlc("MW24836", 1);
|
|
|
if (position == 3)
|
|
|
plcBusiness.writePlc("MW24838", 1);
|
|
|
if (position == 2)
|
|
|
plcBusiness.writePlc("MW24840", 1);
|
|
|
if (position == 4)
|
|
|
plcBusiness.writePlc("MW24842", 1);
|
|
|
if (position == 5)
|
|
|
plcBusiness.writePlc("MW24832", 1);
|
|
|
if (position == 6)
|
|
|
plcBusiness.writePlc("MW24834", 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷位四通道读写器读取
|
|
|
/// </summary>
|
|
|
/// <param name="ant"></param>
|
|
|
/// <returns></returns>
|
|
|
private string ReadEpcByPosition(int position)
|
|
|
{
|
|
|
List<int> positionList = new List<int>();
|
|
|
positionList.Add(position);
|
|
|
List<TagMessage> positionTag = equipBusiness.ReadEPCByAntanaGroup(positionList);
|
|
|
|
|
|
string epc = "";
|
|
|
//add by wenjy 判断读取结果是否为null 20220825
|
|
|
if (positionTag != null)
|
|
|
{
|
|
|
foreach (var Tag in positionTag)
|
|
|
{
|
|
|
if (Tag.position == position)
|
|
|
{
|
|
|
epc = Tag.EPC;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return epc;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 放卷位物料是否结束生产
|
|
|
/// </summary>
|
|
|
/// <param name="epc"></param>
|
|
|
private async Task<bool> UpMaterialIsEndProduction(string rfidStr)
|
|
|
{
|
|
|
bool result = false;
|
|
|
//通过MES获取RFID绑定的SFC
|
|
|
string sfcStr = GetSfcByRfid(rfidStr);
|
|
|
if (StringExtension.IsNotBlank(sfcStr))
|
|
|
{
|
|
|
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.Sfc == sfcStr);
|
|
|
Expression<Func<ProUpRecord, object>> order = s1 => s1.RecordTime;
|
|
|
ProUpRecord upRecord = await upRecordServices.QueryFirst(exp, order, false);
|
|
|
LogHelper.Info(String.Format("获取{0}对应的上料记录:{1}",sfcStr,JsonChange.ModeToJson(upRecord)));
|
|
|
if (upRecord != null)
|
|
|
{
|
|
|
if (upRecord.IsProduction != 1)
|
|
|
{
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("当前Rfid:{0}绑定的SFC为空,不允许继续生产!", rfidStr));
|
|
|
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 = "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)
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
#region RFID串读过滤方案 Add By wenjy 2022-11-26
|
|
|
private System.Timers.Timer timer = new System.Timers.Timer(1000 * 60 * 5);
|
|
|
private IBaseServices<ProTagInfo> tagInfoServices = new BaseServices<ProTagInfo>();
|
|
|
private void StartTimerReadRfid()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (!timer.Enabled)
|
|
|
{
|
|
|
timer.Elapsed += new System.Timers.ElapsedEventHandler(ReadRfidByTimer);
|
|
|
timer.AutoReset = true;
|
|
|
timer.Enabled = false;
|
|
|
timer.Start();
|
|
|
LogHelper.Info("进入StartTimerReadRfid(),开启定时读取RFID");
|
|
|
}
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("StartTimerReadRfid异常", ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private async void ReadRfidByTimer(object source, System.Timers.ElapsedEventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//判断当前收卷生产轴
|
|
|
List<int> positions = new List<int>();
|
|
|
if (appConfig.machineId == 3)
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24676") == 1) positions.Add(3);
|
|
|
if (PlcBusiness.readPlc("MW24678") == 1) positions.Add(1);
|
|
|
if (PlcBusiness.readPlc("MW24680") == 1) positions.Add(4);
|
|
|
if (PlcBusiness.readPlc("MW24682") == 1) positions.Add(2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24676") == 1) positions.Add(1);
|
|
|
if (PlcBusiness.readPlc("MW24678") == 1) positions.Add(3);
|
|
|
if (PlcBusiness.readPlc("MW24680") == 1) positions.Add(2);
|
|
|
if (PlcBusiness.readPlc("MW24682") == 1) positions.Add(4);
|
|
|
}
|
|
|
|
|
|
foreach (int item in positions)
|
|
|
{
|
|
|
string logStr = Which(item);
|
|
|
LogHelper.Info(String.Format("生产过程中定时读取{0}RFID卷筒标签", logStr));
|
|
|
ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == item).FirstOrDefault();
|
|
|
if (proEquip == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
//读取协议更换
|
|
|
List<TagInfo> tagInfos = equipBusiness.ReadEpcByProduction(proEquip.equipId);
|
|
|
|
|
|
//存储数据
|
|
|
ProShaftInfo shaftInfo = this.GetShaftInfoByPosition(item).Result;
|
|
|
|
|
|
|
|
|
if (shaftInfo != null)
|
|
|
{
|
|
|
Expression<Func<ProTagInfo, bool>> queryExp = s1 => true;
|
|
|
queryExp = queryExp.And(x => x.PositionId == shaftInfo.id.ToString());
|
|
|
List<ProTagInfo> bindInfos = await tagInfoServices.Query(queryExp);
|
|
|
if (bindInfos.Count >= 100)
|
|
|
{
|
|
|
if (timer.Enabled)
|
|
|
{
|
|
|
timer.Stop();
|
|
|
timer.Close();
|
|
|
timer.Dispose();
|
|
|
timer = new System.Timers.Timer(1000 * 60 * 5);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (tagInfos != null)
|
|
|
{
|
|
|
int tagInfoLength = tagInfos.Count;
|
|
|
for (int i = 0; i < tagInfoLength; i++)
|
|
|
{
|
|
|
ProTagInfo tagInfo = new ProTagInfo()
|
|
|
{
|
|
|
Id = System.Guid.NewGuid().ToString("N"),
|
|
|
MachineId = appConfig.machineId.ToString(),
|
|
|
PositionId = shaftInfo.id.ToString(),
|
|
|
Count = tagInfos[i].Count.ToString(),
|
|
|
Rssi = tagInfos[i].RSSI.ToString(),
|
|
|
Antana = tagInfos[i].Antana.ToString(),
|
|
|
Pcstring = tagInfos[i].PCstring == null ? "" : tagInfos[i].PCstring,
|
|
|
Epcstring = tagInfos[i].EPCstring == null ? "" : tagInfos[i].EPCstring
|
|
|
};
|
|
|
|
|
|
await tagInfoServices.Add(tagInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("生产过程中定时读取RFID异常",ex);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private async void StopTimerReadRfid(int position)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
LogHelper.Info("进入StopTimerReadRfid(),停止并释放定时读取");
|
|
|
if (timer.Enabled)
|
|
|
{
|
|
|
timer.Stop();
|
|
|
timer.Close();
|
|
|
timer.Dispose();
|
|
|
timer = new System.Timers.Timer(1000 * 60 * 5);
|
|
|
}
|
|
|
|
|
|
string logStr = Which(position);
|
|
|
LogHelper.Info(String.Format("收卷结束,过滤{0}读取的RFID标签", logStr));
|
|
|
|
|
|
Dictionary<string, int> keyValuePairs = new Dictionary<string, int>();
|
|
|
|
|
|
ProShaftInfo shaftInfo = this.GetShaftInfoByPosition(position).Result;
|
|
|
|
|
|
Expression<Func<ProDownRecord, bool>> downexp = x => true;
|
|
|
downexp = downexp.And(x => x.PositionId == position && x.IsProduction == 0 && x.Rfid == shaftInfo.bindRfid);
|
|
|
Expression<Func<ProDownRecord, object>> orders = x => x.beginTime;
|
|
|
ProDownRecord downRecord = await downRecordServices.QueryFirst(downexp, orders, false);
|
|
|
|
|
|
Expression<Func<ProTagInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.PositionId == shaftInfo.id.ToString());
|
|
|
List<ProTagInfo> tagInfos = await tagInfoServices.Query(exp);
|
|
|
|
|
|
if (tagInfos == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
List<TagInfo> tagInfoList = new List<TagInfo>();
|
|
|
|
|
|
if(tagInfos != null)
|
|
|
{
|
|
|
int tagInfosLength = tagInfos.Count;
|
|
|
for(int i = 0; i < tagInfosLength; i++)
|
|
|
{
|
|
|
TagInfo tagInfo = new TagInfo()
|
|
|
{
|
|
|
Count = StringChange.ParseToInt(tagInfos[i].Count),
|
|
|
RSSI = StringChange.ParseToInt(tagInfos[i].Rssi),
|
|
|
Antana = StringChange.ParseToInt(tagInfos[i].Antana),
|
|
|
PCstring = tagInfos[i].Pcstring,
|
|
|
EPCstring = tagInfos[i].Epcstring
|
|
|
};
|
|
|
tagInfoList.Add(tagInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
string result = equipBusiness.FilterEpcByProductionEnd(tagInfoList);
|
|
|
|
|
|
LogHelper.Info("获取最终RFID条码为:" + result);
|
|
|
|
|
|
//判断最终获取的条码
|
|
|
if (StringExtension.IsNotBlank(result))
|
|
|
{
|
|
|
if (shaftInfo.bindRfid != result)
|
|
|
{
|
|
|
shaftInfo.bindRfid = result;
|
|
|
bool updateShaftInfo = await shaftInfoServices.Update(shaftInfo);
|
|
|
if (updateShaftInfo)
|
|
|
{
|
|
|
LogHelper.Info("最终获取的RFID条码与涨紧读取绑定不一致,绑定信息更改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("最终获取的RFID条码与涨紧读取绑定不一致,绑定信息更改失败");
|
|
|
}
|
|
|
}
|
|
|
//更新下料信息
|
|
|
if (downRecord != null)
|
|
|
{
|
|
|
if (downRecord.Rfid != result)
|
|
|
{
|
|
|
downRecord.Rfid = result;
|
|
|
bool downRecordResult = await downRecordServices.Update(downRecord);
|
|
|
if (downRecordResult)
|
|
|
{
|
|
|
LogHelper.Info("最终获取的RFID条码与涨紧读取绑定不一致,下料信息更改成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info("最终获取的RFID条码与涨紧读取绑定不一致,下料信息更改失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tagInfos.ForEach(x =>
|
|
|
{
|
|
|
tagInfoServices.Delete(x);
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("定时读取结束异常", ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private async void DeleteBindInfo(ProShaftInfo shaftInfo)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Expression<Func<ProTagInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.PositionId == shaftInfo.id.ToString());
|
|
|
List<ProTagInfo> tagInfos = await tagInfoServices.Query(exp);
|
|
|
|
|
|
if (tagInfos == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
tagInfos.ForEach(x =>
|
|
|
{
|
|
|
tagInfoServices.Delete(x);
|
|
|
});
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("DeleteBindInfo异常", ex);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取物料重量特征
|
|
|
/// </summary>
|
|
|
/// <param name="shaftInfo"></param>
|
|
|
/// <param name="position"></param>
|
|
|
/// <param name="splitSfc"></param>
|
|
|
/// <param name="downRecord"></param>
|
|
|
/// <returns></returns>
|
|
|
private async Task<machineIntegrationParametricData[]> GetMaterialWeight(ProShaftInfo shaftInfo, int position, string splitSfc)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string logStr = this.Which(position);
|
|
|
//获取放卷方向-放卷开始时读取PLC地址将内容存入绑定信息:false(0)为顺时针,True(1)为逆时针
|
|
|
//根据收卷轴绑定的SFC获取放卷轴
|
|
|
Expression<Func<ProShaftInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.bindSfc == shaftInfo.bindSfc);
|
|
|
Expression<Func<ProShaftInfo, object>> order = s1 => s1.bindTime;
|
|
|
ProShaftInfo upShaftInfo = await shaftInfoServices.QueryFirst(exp, order, false);
|
|
|
if (upShaftInfo == null)
|
|
|
{
|
|
|
LogHelper.Info(String.Format("{0}上传数据获取放卷绑定信息为空", logStr));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("{0}上传数据获取放卷绑定信息为空", logStr));
|
|
|
return null;
|
|
|
}
|
|
|
string upDirection = upShaftInfo.endFlag == 0 ? "顺时针" : "逆时针";
|
|
|
|
|
|
//获取收卷方向-收卷开始时读取PLC地址将内容存入绑定信息
|
|
|
string downDirection = shaftInfo.endFlag == 0 ? "顺时针" : "逆时针";
|
|
|
|
|
|
//是否首检,根据下料记录统计是否为换班后收卷料
|
|
|
bool isFirst = await IsFirstFlag();
|
|
|
|
|
|
LogHelper.Info(String.Format("{0}收卷结束,当前卷放卷方向:{1};收卷方向:{2};是否首检:{3}", logStr, upDirection, downDirection, isFirst));
|
|
|
|
|
|
//根据上料记录获取冷压特征数据
|
|
|
Expression<Func<ProUpRecord, bool>> upExp = s1 => true;
|
|
|
upExp = upExp.And(x => x.Sfc == upShaftInfo.bindSfc);
|
|
|
Expression<Func<ProUpRecord, object>> upOrder = s1 => s1.RecordTime;
|
|
|
ProUpRecord upRecord = await upRecordServices.QueryFirst(upExp, upOrder, false);
|
|
|
if (upRecord == null)
|
|
|
{
|
|
|
LogHelper.Info(String.Format("{0}上传数据获取放卷信息为空", logStr));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("{0}上传数据获取放卷信息为空", logStr));
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
var lyMaterialCharacter = JsonChange.JsonToMode<TBParametricValueResult>(upRecord.UpMaterialId);
|
|
|
|
|
|
LogHelper.Info("获取冷压重量特征数据:" + JsonChange.ModeToJson(lyMaterialCharacter));
|
|
|
//upLoadBusiness.SaveLogRecord(position, "获取冷压重量特征数据:" + lyMaterialCharacter);
|
|
|
|
|
|
//获取冷压重量特征数据,如果数据库中为空则通过MES重新获取并存入数据库 Add by wenjy 2022-11-15
|
|
|
if (lyMaterialCharacter == null)
|
|
|
{
|
|
|
GetParametricValueRequestData[] parametricValueRequestDatas = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "LY_WLMX" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_S_X01" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_S_X02" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_B_X01" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_B_X02" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_B_X02" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" },
|
|
|
};
|
|
|
lyMaterialCharacter = GetLyMaterialCharacter(upShaftInfo.bindSfc, parametricValueRequestDatas); //获取冷压特征数据
|
|
|
string lyMaterialCharacterJsonStr = JsonChange.ModeToJson(lyMaterialCharacter);
|
|
|
LogHelper.Info(String.Format("数据库中冷压物料特征数据为空,通过MES获取{0}的物料特征数据:{1}", upShaftInfo.bindSfc, lyMaterialCharacterJsonStr));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("数据库中冷压物料特征数据为空,通过MES获取{0}的物料特征数据:{1}", upShaftInfo.bindSfc, lyMaterialCharacterJsonStr));
|
|
|
upRecord.UpMaterialId = lyMaterialCharacterJsonStr;
|
|
|
|
|
|
await upRecordServices.Update(upRecord);
|
|
|
}
|
|
|
|
|
|
//物料面向
|
|
|
string mqMaterialFace = "";
|
|
|
string stargetcwStr = "";
|
|
|
var lyMaterialFace = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_WLMX").FirstOrDefault();
|
|
|
var S_TARGETCW = lyMaterialCharacter.paramValues.Where(x => x.parameter == "S_TARGETCW").FirstOrDefault();
|
|
|
if (lyMaterialFace != null)
|
|
|
{
|
|
|
mqMaterialFace = MaterialFaceStr(lyMaterialFace.value, upShaftInfo.endFlag, shaftInfo.endFlag);
|
|
|
}
|
|
|
|
|
|
if(S_TARGETCW != null){
|
|
|
stargetcwStr = S_TARGETCW.value;
|
|
|
}else{
|
|
|
LogHelperBusiness.LogInfo("手动完工获取模切数据S_TARGETCW为null");
|
|
|
}
|
|
|
|
|
|
LogHelper.Info(String.Format("冷压物料面向:{0};模切物料面向:{1}", lyMaterialFace, mqMaterialFace));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("冷压物料面向:{0};模切物料面向:{1}", lyMaterialFace, mqMaterialFace));
|
|
|
string jrDirection = "";//卷绕理论方向
|
|
|
string S_CW = "";//模切S面某膜区某特征值
|
|
|
string B_CW = "";//模切B面某膜区某特征值
|
|
|
|
|
|
if (position % 2 != 0)
|
|
|
{
|
|
|
jrDirection = shaftInfo.endFlag == 0 ? "逆时针" : "顺时针";
|
|
|
|
|
|
var LY_S_X01 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_S_X01").FirstOrDefault();
|
|
|
var LY_B_X01 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_B_X01").FirstOrDefault();
|
|
|
|
|
|
if (LY_S_X01 != null) S_CW = LY_S_X01.value;
|
|
|
if (LY_B_X01 != null) B_CW = LY_B_X01.value;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
jrDirection = downDirection;
|
|
|
|
|
|
var LY_S_X02 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_S_X02").FirstOrDefault();
|
|
|
var LY_B_X02 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_B_X02").FirstOrDefault();
|
|
|
|
|
|
if (LY_S_X02 != null) S_CW = LY_S_X02.value;
|
|
|
if (LY_B_X02 != null) B_CW = LY_B_X02.value;
|
|
|
}
|
|
|
|
|
|
LogHelper.Info(String.Format("卷绕理论方向:{0};S面特征值:{1};B面特征值:{1}", jrDirection, S_CW, B_CW));
|
|
|
machineIntegrationParametricData[] ccdTreetopAmount = GetCcdTreetopAmount(position);
|
|
|
machineIntegrationParametricData[] data = {
|
|
|
new machineIntegrationParametricData() {name ="MQ_FJFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(upDirection) ? "0" : upDirection},
|
|
|
new machineIntegrationParametricData() {name ="MQ_SJFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(downDirection) ? "0" :downDirection},
|
|
|
new machineIntegrationParametricData() {name ="MQ_SJZ",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(logStr) ? "0" :logStr},
|
|
|
new machineIntegrationParametricData() {name ="FIRST ARTICLE",dataType=ParameterDataType.TEXT, value= isFirst == true ? "OK" : "NG"},
|
|
|
new machineIntegrationParametricData() {name ="MQ_WLMX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(mqMaterialFace) ? "0" :mqMaterialFace},
|
|
|
new machineIntegrationParametricData() {name ="MQ_JRLLFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(jrDirection) ? "0" :jrDirection},
|
|
|
new machineIntegrationParametricData() {name ="S_CW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(S_CW) ? "0" : S_CW},
|
|
|
new machineIntegrationParametricData() {name ="B_CW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(B_CW) ? "0" : B_CW},
|
|
|
ccdTreetopAmount[0], // ccd打标数
|
|
|
new machineIntegrationParametricData() {name ="S_TARGETCW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(stargetcwStr) ? "0" : stargetcwStr},
|
|
|
};
|
|
|
LogHelper.Info("GetMaterialWeight获取模切物料特征数据:" + JsonChange.ModeToJson(data));
|
|
|
return data;
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "模切物料特征数据获取异常:" + ex.Message);
|
|
|
LogHelper.Error("模切物料特种数据获取异常",ex);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 模切物料特征数据上传服务器
|
|
|
/// </summary>
|
|
|
/// <param name="positionId"></param>
|
|
|
/// <param name="sfcStr"></param>
|
|
|
/// <param name="downRecordId"></param>
|
|
|
/// <param name="data"></param>
|
|
|
private void UpLoadMaterialWeight(int positionId,string sfcStr,string downRecordId,machineIntegrationParametricData[] data)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
MqUpLoad mqUpLoad = new MqUpLoad()
|
|
|
{
|
|
|
sfcStr = sfcStr,//拆分后膜卷号改为放卷位膜卷号
|
|
|
clientId = downRecordId,
|
|
|
positionId = positionId,
|
|
|
resource = appConfig.resource,
|
|
|
operation = appConfig.operation,
|
|
|
dcGroup = inifile.IniReadValue("MachineIntegrationServiceParam", "dcGroup"),
|
|
|
upDirection = data.Where(x => x.name == "MQ_FJFX").FirstOrDefault().value,
|
|
|
downDirection = data.Where(x => x.name == "MQ_SJFX").FirstOrDefault().value,
|
|
|
downPosition = data.Where(x => x.name == "MQ_SJZ").FirstOrDefault().value,
|
|
|
firstArticle = data.Where(x => x.name == "FIRST ARTICLE").FirstOrDefault().value,
|
|
|
mqMaterialFace = data.Where(x => x.name == "MQ_WLMX").FirstOrDefault().value,
|
|
|
jrDirection = data.Where(x => x.name == "MQ_JRLLFX").FirstOrDefault().value,
|
|
|
scw = data.Where(x => x.name == "S_CW").FirstOrDefault().value,
|
|
|
bcw = data.Where(x => x.name == "B_CW").FirstOrDefault().value,
|
|
|
// s_targetcw = data.Where(x => x.name == "S_TARGETCW").FirstOrDefault().value,
|
|
|
recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
};
|
|
|
upLoadBusiness.SaveMqUpLoad(mqUpLoad);
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("模切物料特征数据上传服务器异常:"+ex.Message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "模切物料特征数据上传服务器异常:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取CCD打标数
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
/// <returns></returns>
|
|
|
private machineIntegrationParametricData[] GetCcdTreetopAmount(int position)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string logStr = this.Which(position);
|
|
|
|
|
|
string treeTop = "";
|
|
|
|
|
|
if (appConfig.machineId==3)
|
|
|
{
|
|
|
if (position == 1) treeTop = PlcBusiness.readStrPlc("MW44400", 60); //上右
|
|
|
if (position == 2) treeTop = PlcBusiness.readStrPlc("MW45200", 60); //下右
|
|
|
if (position == 3) treeTop = PlcBusiness.readStrPlc("MW44000", 60); //上左
|
|
|
if (position == 4) treeTop = PlcBusiness.readStrPlc("MW44800", 60); //下左
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 3) treeTop = PlcBusiness.readStrPlc("MW44000", 60); //上左
|
|
|
if (position == 4) treeTop = PlcBusiness.readStrPlc("MW44800", 60); //下左
|
|
|
if (position == 1) treeTop = PlcBusiness.readStrPlc("MW44400", 60); //上右
|
|
|
if (position == 2) treeTop = PlcBusiness.readStrPlc("MW45200", 60); //下右
|
|
|
}
|
|
|
LogHelper.Info("通过PLC获取CCD打标数:" + treeTop);
|
|
|
string[] array = treeTop.Replace("\0","").Trim().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
string amount = array.Length.ToString();
|
|
|
LogHelper.Info("CCD打标数:" + amount);
|
|
|
// //upLoadBusiness.SaveLogRecord(position, String.Format("卷绕理论方向:{0};S面特征值:{1};B面特征值:{1}", jrDirection, S_CW, B_CW));
|
|
|
machineIntegrationParametricData[] data = {
|
|
|
new machineIntegrationParametricData() {name ="CCD",dataType=ParameterDataType.TEXT, value= amount}
|
|
|
};
|
|
|
|
|
|
return data;
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("获取CCD打标数异常:" + ex.Message);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 上传模切数据 2022-11-8
|
|
|
/// </summary>
|
|
|
/// <param name="x"></param>
|
|
|
/// <param name="bindSfc"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool UpMQMesData(int position, machineIntegrationParametricData[] data,string splitSfc,ProDownRecord downRecord)
|
|
|
{
|
|
|
bool result = false;
|
|
|
string logStr = this.Which(position);
|
|
|
try
|
|
|
{
|
|
|
MachineIntegrationServiceParam machineIntegrationServiceParam = new MachineIntegrationServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MachineIntegrationServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//sfc = splitSfc, //将数据上传至拆分后的膜卷号
|
|
|
//operation = appConfig.operation,
|
|
|
//operationRevision = "#",
|
|
|
//activityId = "EAP_WS",
|
|
|
//resource = appConfig.resource,
|
|
|
//dcGroup = upLoadBusiness.GerDcGroupByResource(),
|
|
|
//dcGroupRevision = "#",
|
|
|
//parametricArray = data,
|
|
|
//modeProcessSfc = WebService.MachineIntegrationServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC
|
|
|
url = inifile.IniReadValue("MachineIntegrationServiceParam","url"),
|
|
|
site = inifile.IniReadValue("MachineIntegrationServiceParam", "site"),
|
|
|
sfc = splitSfc, //将数据上传至拆分后的膜卷号
|
|
|
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,
|
|
|
modeProcessSfc = WebService.MachineIntegrationServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC
|
|
|
};
|
|
|
|
|
|
LogHelper.Info("上传MES数据接口请求参数:" + JsonChange.ModeToJson(machineIntegrationServiceParam));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(position, "上传MES数据接口请求参数:" + JsonChange.ModeToJson(machineIntegrationServiceParam));
|
|
|
var dataCollectForSfcExResponse = MesWebServices.machineIntegration(machineIntegrationServiceParam);
|
|
|
var dataCollectForSfcExResponseResult = dataCollectForSfcExResponse.@return;
|
|
|
|
|
|
if (dataCollectForSfcExResponseResult.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("模切数据上传MES失败:" + dataCollectForSfcExResponseResult.message);
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切数据上传MES失败:" + dataCollectForSfcExResponseResult.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "模切数据上传MES失败:" + upLoadBusiness.GetMesMessage(dataCollectForSfcExResponseResult.code, dataCollectForSfcExResponseResult.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "模切数据上传MES失败:" + upLoadBusiness.GetMesMessage(dataCollectForSfcExResponseResult.code, dataCollectForSfcExResponseResult.message));
|
|
|
result = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "模切数据上传MES成功");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切数据上传MES成功");
|
|
|
LogHelper.Info("模切数据上传MES成功");
|
|
|
result = true;
|
|
|
}
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("模切重量特征数据上传异常:" + ex.Message);
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切重量特征数据上传异常:" + ex.Message);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// ccd单独上传*Y数据收集组
|
|
|
/// </summary>
|
|
|
/// <param name="x"></param>
|
|
|
/// <param name="bindSfc"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool UpMQMesData1(int position, machineIntegrationParametricData[] data, string splitSfc)
|
|
|
{
|
|
|
bool result = false;
|
|
|
string logStr = this.Which(position);
|
|
|
try
|
|
|
{
|
|
|
MachineIntegrationServiceParam machineIntegrationServiceParam = new MachineIntegrationServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("MachineIntegrationServiceParam", "url"),
|
|
|
site = inifile.IniReadValue("MachineIntegrationServiceParam", "site"),
|
|
|
sfc = splitSfc, //将数据上传至拆分后的膜卷号
|
|
|
operation = appConfig.operation,
|
|
|
operationRevision = inifile.IniReadValue("MachineIntegrationServiceParam", "operationRevision"),
|
|
|
activityId = inifile.IniReadValue("MachineIntegrationServiceParam", "activityId"),
|
|
|
resource = appConfig.resource,
|
|
|
dcGroup = "*Y",
|
|
|
dcGroupRevision = inifile.IniReadValue("MachineIntegrationServiceParam", "dcGroupRevision"),
|
|
|
parametricArray = data,
|
|
|
modeProcessSfc = WebService.MachineIntegrationServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC
|
|
|
};
|
|
|
LogHelper.Info("ccd单独上传MES数据接口请求参数:" + JsonChange.ModeToJson(machineIntegrationServiceParam));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(position, "上传MES数据接口请求参数:" + JsonChange.ModeToJson(machineIntegrationServiceParam));
|
|
|
var dataCollectForSfcExResponse = MesWebServices.machineIntegration(machineIntegrationServiceParam);
|
|
|
var dataCollectForSfcExResponseResult = dataCollectForSfcExResponse.@return;
|
|
|
|
|
|
if (dataCollectForSfcExResponseResult.code > 0)
|
|
|
{
|
|
|
LogHelper.Info("ccd单独上传MES失败:" + dataCollectForSfcExResponseResult.message);
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切数据上传MES失败:" + dataCollectForSfcExResponseResult.message);
|
|
|
LogRefreshEvent?.Invoke(LogType.AlarmLog, "ccd单独上传MES失败:" + upLoadBusiness.GetMesMessage(dataCollectForSfcExResponseResult.code, dataCollectForSfcExResponseResult.message));
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "ccd单独上传MES失败:" + upLoadBusiness.GetMesMessage(dataCollectForSfcExResponseResult.code, dataCollectForSfcExResponseResult.message));
|
|
|
result = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogRefreshEvent?.Invoke(LogType.MesLog, "ccd上传MES数据收集组*Y成功");
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切数据上传MES成功");
|
|
|
LogHelper.Info("ccd上传MES数据收集组*Y成功");
|
|
|
result = true;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("ccd上传MES数据收集组*Y上传异常:" + ex.Message);
|
|
|
//upLoadBusiness.SaveLogRecord(position, "模切重量特征数据上传异常:" + ex.Message);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取放卷、收卷运行方向
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
private async void GetDirections(int position,ProShaftInfo shaftInfo)
|
|
|
{
|
|
|
string logStr = this.Which(position);
|
|
|
LogHelper.Info(String.Format("读取{0}轴运行方向", logStr));
|
|
|
//false(0)为顺时针,True(1)为逆时针
|
|
|
int directions = 0;
|
|
|
if (position > 4)
|
|
|
{
|
|
|
directions = Convert.ToInt32(PlcBusiness.readBoolPlc("MW20000.0"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position % 2 != 0) //上轴
|
|
|
{
|
|
|
directions = Convert.ToInt32(PlcBusiness.readBoolPlc("MW20001.0"));
|
|
|
}
|
|
|
else //下轴
|
|
|
{
|
|
|
directions = Convert.ToInt32(PlcBusiness.readBoolPlc("MW20001.1"));
|
|
|
}
|
|
|
}
|
|
|
//绑定信息存储运行方向
|
|
|
shaftInfo.endFlag = directions; //使用endFlag存储运行方向
|
|
|
|
|
|
if (await shaftInfoServices.Update(shaftInfo))
|
|
|
{
|
|
|
LogHelper.Info(String.Format("{0}运行方向更新成功:{1}", logStr, directions == 0 ? "顺时针" : "逆时针"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogHelper.Info(String.Format("{0}运行方向更新失败:{1}", logStr, directions == 0 ? "顺时针" : "逆时针"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 是否首件
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private async Task<bool> IsFirstFlag()
|
|
|
{
|
|
|
bool result = false;
|
|
|
try
|
|
|
{
|
|
|
DateTime dayShift = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 12:00:00"));
|
|
|
DateTime nightShift = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
|
|
|
LogHelper.Info(String.Format("判断当前物料是否为首件,白班时间{0},夜班时间{1}",dayShift,nightShift));
|
|
|
Expression<Func<ProDownRecord, bool>> exp = s1 => true;
|
|
|
if (DateTime.Now > dayShift && DateTime.Now < nightShift)
|
|
|
{
|
|
|
exp = exp.And(x => Convert.ToDateTime(x.RecordTime) > dayShift);
|
|
|
}else if(DateTime.Now > nightShift && DateTime.Now < dayShift.AddDays(1))
|
|
|
{
|
|
|
exp = exp.And(x => Convert.ToDateTime(x.RecordTime) > nightShift);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//次日凌晨直接返回
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
List<ProDownRecord> downRecords = await downRecordServices.Query(exp);
|
|
|
|
|
|
if (downRecords.Count < 2)
|
|
|
{
|
|
|
result = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result = false;
|
|
|
}
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("判断当前物料是否为首件异常:"+ex.Message);
|
|
|
result = false;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据冷压面向、膜区收放卷放卷判断膜区面向
|
|
|
/// </summary>
|
|
|
/// <param name="lyMaterialFace"></param>
|
|
|
/// <param name="upDirections"></param>
|
|
|
/// <param name="downDirections"></param>
|
|
|
/// <returns></returns>
|
|
|
private string MaterialFaceStr(string lyMaterialFace,int upDirections,int downDirections)
|
|
|
{
|
|
|
string mqMaterialFace = "";
|
|
|
|
|
|
if (StringExtension.IsBlank(lyMaterialFace))
|
|
|
{
|
|
|
return mqMaterialFace;
|
|
|
}
|
|
|
|
|
|
if(lyMaterialFace == "S面")
|
|
|
{
|
|
|
if(upDirections == downDirections)
|
|
|
{
|
|
|
mqMaterialFace = "S面";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
mqMaterialFace = "B面";
|
|
|
}
|
|
|
}else if(lyMaterialFace == "B面")
|
|
|
{
|
|
|
if (upDirections == downDirections)
|
|
|
{
|
|
|
mqMaterialFace = "B面";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
mqMaterialFace = "S面";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return mqMaterialFace;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取冷压物料面向
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private TBParametricValueResult GetLyMaterialCharacter(string sfc, GetParametricValueRequestData[] parameters)
|
|
|
{
|
|
|
TBDataServiceParam tbServiceParam = new TBDataServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("TBParametricValueParam","url"),
|
|
|
site = inifile.IniReadValue("TBParametricValueParam", "site"),
|
|
|
sfc = sfc,
|
|
|
memberlist = parameters
|
|
|
};
|
|
|
|
|
|
var lyresult = MesWebServices.findTBData(tbServiceParam);
|
|
|
|
|
|
return lyresult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取最后一卷,绑定信息中的endFlag用于存储运行方向,使用ProDownRecord中的shaftNumber存储是否最后一卷
|
|
|
/// 放卷结束后进行判断
|
|
|
/// </summary>
|
|
|
private async void IsEndFlag()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//通过PLC获取收卷轴,设置下轴为最后一卷
|
|
|
//判断当前收卷生产轴
|
|
|
List<int> positions = new List<int>();
|
|
|
if (appConfig.machineId == 3)
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24676") == 1) positions.Add(3);
|
|
|
if (PlcBusiness.readPlc("MW24678") == 1) positions.Add(1);
|
|
|
if (PlcBusiness.readPlc("MW24680") == 1) positions.Add(4);
|
|
|
if (PlcBusiness.readPlc("MW24682") == 1) positions.Add(2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (PlcBusiness.readPlc("MW24676") == 1) positions.Add(1);
|
|
|
if (PlcBusiness.readPlc("MW24678") == 1) positions.Add(3);
|
|
|
if (PlcBusiness.readPlc("MW24680") == 1) positions.Add(2);
|
|
|
if (PlcBusiness.readPlc("MW24682") == 1) positions.Add(4);
|
|
|
}
|
|
|
int position = positions.Max();
|
|
|
|
|
|
ProShaftInfo shaftInfo = await GetShaftInfoByPosition(position);
|
|
|
|
|
|
Expression<Func<ProDownRecord, bool>> downexp = x => true;
|
|
|
downexp = downexp.And(x => x.PositionId == position && x.IsProduction == 0);
|
|
|
|
|
|
if (shaftInfo!= null)
|
|
|
{
|
|
|
downexp = downexp.And(x => x.Rfid == shaftInfo.bindRfid);
|
|
|
}
|
|
|
|
|
|
Expression<Func<ProDownRecord, object>> orders = x => x.beginTime;
|
|
|
ProDownRecord downRecord = await downRecordServices.QueryFirst(downexp, orders, false);
|
|
|
LogHelper.Info("放卷结束,获取最后一卷收卷轴信息:" + JsonChange.ModeToJson(downRecord));
|
|
|
if (downRecord != null)
|
|
|
{
|
|
|
downRecord.shaftNumber = "X";
|
|
|
await downRecordServices.Update(downRecord);
|
|
|
}
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("放卷结束,标识最后一卷收卷轴异常:"+ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|