diff --git a/MaterialTraceability.Business/Impl/ABSignalReadBusiness.cs b/MaterialTraceability.Business/Impl/ABSignalReadBusiness.cs new file mode 100644 index 0000000..ba9cf46 --- /dev/null +++ b/MaterialTraceability.Business/Impl/ABSignalReadBusiness.cs @@ -0,0 +1,1382 @@ +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.MiReleaseSfcWithActivityServiceService; +using MaterialTraceability.WebService.Param; +using MaterialTraceability.WebService.ProcessLotServiceWSService; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace MaterialTraceability.Business.Impl +{ + public class ABSignalReadBusiness : ISignalReadFunction + { + /// + /// INIFile配置文件 + /// + private INIFile inifile = new INIFile(System.Environment.CurrentDirectory + "/MesConfig/App.InI"); + private AppConfigDto appConfig = AppConfigDto.Instance; + /// + /// 日志刷新 + /// + /// 日志内容 + /// + public delegate void LogRefresh(LogType logType, string massage); + public static event LogRefresh LogRefreshEvent; + + /// + /// 视图层数据刷新 + /// + /// + public delegate void ViewModelRefresh(ViewModelDto viewModelDto); + public static event ViewModelRefresh ViewModelRefreshEvent; + + /// + /// PLC信号事件 + /// + /// + /// + public delegate void SignalReadInvoke(int status, int position); + + /// + /// RFID读写器业务 + /// + private EquipBusiness equipBusiness = new EquipBusiness(); + + /// + /// Mes WebService接口 + /// + private IMesWebServices MesWebServices = new MesWebServicesImpl(); + + //卷轴信息 + private IBaseServices shaftInfoServices = new BaseServices(); + + //收卷记录 + private IBaseServices downRecordServices = new BaseServices(); + + //上料记录 + private IBaseServices upRecordServices = new BaseServices(); + + private IBaseServices sysClientServices = new BaseServices(); + + private MesAlarmInfo mesAlarmInfo = new MesAlarmInfo(); + + private PlcBusiness plcBusiness = new PlcBusiness(); + + private UpLoadBusiness upLoadBusiness = UpLoadBusiness.Instance; + + ///add by yinzf + /// + /// 放卷开始 + /// + /// + public void UpBegin(int position) + { + //禁止下料 + LogHelper.Info("放卷开始,下发禁止下料信号"); + LogRefreshEvent?.Invoke(LogType.PlcLog, "放卷开始,下发禁止下料信号"); + sendError(position); + } + //end add + /// + /// 放卷涨紧 + /// + /// + public void UpMaterialBegin(int position) + { + try + { + #region 未登录不让放卷涨紧生产,便于记录生产者 + /*if (StringExtension.IsBlank(ConfigHelper.GetConfig("roleId"))) + { + MessageBox.Show("请先登录再开始生产"); + LogHelper.Info("请先登录再开始生产"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "请先登录再开始生产"); + + return; + }*/ + #endregion + plcBusiness.writePlc(appConfig.AbAddress.放卷手动上料, 0); + + LogRefreshEvent?.Invoke(LogType.PlcLog, "凹版放卷位涨紧信号触发成功"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "凹版放卷位涨紧信号触发成功"); + LogHelper.Info("凹版放卷位涨紧信号触发成功"); + + //读取卷筒RFID物料信息 + ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == position).FirstOrDefault(); + if (proEquip == null) + { + LogRefreshEvent?.Invoke(LogType.AlarmLog, "获取放卷位读写器设备信息异常"); + return; + } + string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId); + epc = epc.Replace("\0", "").Trim(); + //add by CaesarBao 这里需要截取标签 + //if (epc == "" || epc == null) + //{ + // Random random = new Random(); + + // epc = "JSLY4RDA0000" + random.Next(10, 99); + //} + //SaveReadRecord(proEquip, epc); + if (StringExtension.IsBlank(epc)) + { + sendError(position, 2, false, 1); + plcBusiness.writePlc(appConfig.AbAddress.放卷气胀轴泄气, 1); + + + //plcBusiness.writePlc(appConfig.AbAddress.RFID异常, 1); + LogHelper.Info("放卷位RFID条码信息读取失败,下发PLC报警D6024写1"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷位RFID条码信息读取失败"); + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = "", + sfc = "", + ea = "", + position = position, + }, + plcStatus = true, + }); + return; + } + LogHelper.Info(String.Format("放卷位RFID条码信息读取成功:{0}", epc)); + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("放卷位RFID条码信息读取成功,RFID为{0}", epc)); + //判断RFID标签是否重复 + LogHelper.Info("判断RFID标签是否重复"); + if (BusinessHelper.UpRfidIsRecur(epc, position).Result) + { + + //判断是否已经生产结束 + if (UpMaterialIsEndProduction(epc).Result) + { + plcBusiness.writePlc(appConfig.AbAddress.RFID异常, 1); + LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc)); + LogHelper.Info(String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc)); + return; + } + else + { + Expression> exp = s1 => true; + Expression> order = (x) => x.RecordTime; + ProUpRecord upRecord = upRecordServices.QueryFirst(exp, order, false).Result; + if (upRecord != null) + { + //PlcBusiness.writeStrPlc(appConfig.AbAddress.放卷SFC, upRecord.Sfc); + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = epc, + sfc = upRecord.Sfc, + position = position, + }, + plcStatus = true, + }); + } + LogHelper.Info("放卷位RFID读取到的条码:" + epc + "与前一读取相同并且生产未结束,可以继续生产"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷位RFID读取到的条码:" + epc + "与前一读取相同并且生产未结束,可以继续生产"); + return; + } + } + //读取数据刷新 + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = epc, + //sfc = "", + position = position, + }, + plcStatus = true, + }); + FJMesBegin(position, epc, true); + } + catch (Exception ex) + { + LogHelper.Error("凹版放卷涨紧逻辑处理异常", ex); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "凹版放卷涨紧逻辑处理异常" + ex.Message); + + } + } + + /// + /// 放卷结束 + /// + /// + public async void UpMaterialEnd(int position) + { + try + { + LogRefreshEvent?.Invoke(LogType.PlcLog, "凹版放卷位结束信号触发成功"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "凹版放卷位结束信号触发成功"); + LogHelper.Info("凹版放卷位结束信号触发成功"); + + ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position); + if (shaftInfo == null) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, "放卷结束,获取卷轴绑定的信息为空"); + return; + } + Expression> upExp = s1 => true; + upExp = upExp.And(x => x.Sfc == shaftInfo.bindSfc && x.Rfid == shaftInfo.bindRfid && x.IsProduction == 0); + Expression> upOrder = (x) => x.RecordTime; + ProUpRecord upRecord = await upRecordServices.QueryFirst(upExp, upOrder, false); + if (upRecord == null) + { + LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷结束,获取上料信息为空"); + 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, "生成放卷信息"); + //放卷结束允许下料 + sendSuccess(position); + //upLoadBusiness.UpdateUpRecord(upRecord); + } + catch (Exception ex) + { + LogHelper.Error("凹版放卷位结束逻辑处理异常", ex); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "凹版放卷位结束逻辑处理异常" + ex.Message); + } + } + + /// + /// 收卷涨紧 + /// + /// + public async void DownMaterialBegin(int position) + { + #region 参数定义 + List proEquips = new List(); + List tagInfoList = new List(); + #endregion + try + { + LogRefreshEvent?.Invoke(LogType.PlcLog, "收卷位涨紧信号触发成功"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "收卷位涨紧信号触发成功"); + LogHelper.Info("收卷位涨紧信号触发成功"); + + //if (StringExtension.IsBlank(PlcBusiness.readStrPlc(appConfig.AbAddress.放卷SFC, 32))) + //{ + // LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷位物料信息为空,先触发放卷位物料信息"); + // return; + //} + + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("开始读取收卷轴RFID物料信息")); + ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == position).FirstOrDefault(); + if (proEquip == null) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, "获取收卷轴读写器设备信息异常"); + return; + } + string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId); + epc = epc.Replace("\0", "").Trim(); + + //add by CaesarBao 这里需要截取标签 + if (epc == "" || epc == null) + { + Random random = new Random(); + + epc = "JSLY4RDA0000" + random.Next(10, 99); + } + if (StringExtension.IsBlank(epc)) + { + plcBusiness.writePlc(appConfig.AbAddress.收卷气胀轴泄气, 1); + + LogHelper.Info("收卷读取RFID条码信息失败"); + LogRefreshEvent?.Invoke(LogType.AlarmLog,"收卷读取RFID条码信息失败"); + sendError(position, 2, false, 1); + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = "", + sfc = "", + ea = "", + position = position, + }, + plcStatus = true, + }); + } + LogHelper.Info("收卷位设备:" + proEquip.equipIp + "涨紧信号读取成功:" + epc); + + LogRefreshEvent?.Invoke(LogType.RfidLog,"收卷RFID条码信息读取成功:" + epc); + + lock (string.Empty) + { + LogHelper.Info("判断RFID标签是否重复"); + + if (BusinessHelper.DownRfidIsRecur(epc, position).Result) + { + LogHelper.Info("收卷RFID读取到的条码:" + epc + "与前一读取相同不做MES处理"); + + LogRefreshEvent?.Invoke(LogType.RfidLog, "收卷RFID读取到的条码:" + epc + "与前一读取相同不做MES处理"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "收卷RFID读取到的条码:" + epc + "与前一读取相同不做MES处理"); + //plcBusiness.writePlc(appConfig.AbAddress.是否转塔, 1); + return; + } + + SJMesBegin(position, epc, true); + } + } + catch (Exception ex) + { + LogHelper.Error("凹版收卷涨紧信号逻辑处理异常", ex); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "凹版收卷涨紧信号逻辑处理异常" + ex.Message); + } + finally + { + tagInfoList = new List(); + } + } + + /// + /// 收卷结束 + /// + /// + public async void DownMaterialEnd(int position) + { + #region 参数定义 + List shaftInfos = new List(); + + string logStr = Which(position); + #endregion + try + { + LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "收卷结束信号触发成功"); + LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "收卷结束信号触发成功"); + LogHelper.Info(logStr + "收卷结束信号触发成功"); + //获取收卷轴绑定的RFID条码信息,取最新数据 + Expression> exp = s1 => true; + exp = exp.And(x => x.positionId == position.ToString() && x.processId == appConfig.processId); + Expression> order = (x) => x.bindTime; + ProShaftInfo shaftInfo = await shaftInfoServices.QueryFirst(exp, order, false); + + + LogRefreshEvent?.Invoke(LogType.RfidLog, "PLC获取的最终SFC为:" + shaftInfo.bindSfc); + if (StringExtension.IsBlank(shaftInfo.bindSfc)) + { + LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("{0}收卷完工获取卷轴绑定的SFC为空不进入结束流程", logStr)); + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("{0}收卷完工获取卷轴绑定的SFC为空不进入结束流程", logStr)); + LogHelper.Info(String.Format("{0}收卷完工获取卷轴绑定的SFC为空不进入结束流程", logStr)); + //下发PLC下料信号 + this.sendSuccess(position); + return; + } + + Expression> down = s1 => true; + down = down.And(z => z.Rfid == shaftInfo.bindRfid && z.IsProduction == 0); + Expression> downorder = (s) => s.beginTime; + ProDownRecord downRecord = await downRecordServices.QueryFirst(down, downorder, false); + + if (downRecord == null) + { + LogRefreshEvent?.Invoke(LogType.AlarmLog, "收卷流程结束,获取下料信息异常"); + LogHelper.Info("收卷流程结束,获取下料信息异常"); + return; + } + //下发禁止下料 + sendError(position); + //调用MES获取数量接口 + string upMaterialEaValue = GetUpMaterialQty(position, shaftInfo.bindSfc, logStr); + + if (StringExtension.IsBlank(upMaterialEaValue)) + { + LogRefreshEvent?.Invoke(LogType.MesLog, String.Format("通过MES获取收卷位{0}物料EA值为空", shaftInfo.bindSfc)); + return; + } + downRecord.eaValue = int.Parse(upMaterialEaValue); + LogRefreshEvent?.Invoke(LogType.RfidLog, "收卷位物料EA:" + upMaterialEaValue); + if (!SpiltAccount(position, shaftInfo, downRecord.eaValue, shaftInfo.bindSfc, new ProUpRecord(), downRecord).Result) + { + LogHelper.Info(logStr + "完工MES账目数量异常"); + + return; + } + //下料成功 + sendSuccess(position); + + } + catch (Exception ex) + { + LogHelper.Error("凹版收卷结束信号逻辑处理异常", ex); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "凹版收卷结束信号逻辑处理异常" + ex.Message); + } + } + + /// + /// 调整MES数量 + /// + /// + /// + /// + /// + private bool UpdateMesEaValue(int position,string bindSfc, string bindRfid, int eaValue) + { + //调取MES调整数量接口 + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES调整数量接口"); + MiBatchCompleteSfcAndAdujustQtyServiceServiceParam miBatchCompleteSfcAndAdujustQtyServiceServiceParam = new MiBatchCompleteSfcAndAdujustQtyServiceServiceParam() + { + url = inifile.IniReadValue("AdujustQtyParam","url"), + site = inifile.IniReadValue("AdujustQtyParam", "site"), + sfcPre = bindSfc, + processLotPre = "", + operation = appConfig.operationByA, + operationRevision = inifile.IniReadValue("AdujustQtyParam", "operationRevision"), + resource = appConfig.resource, + user = inifile.IniReadValue("AdujustQtyParam", "user"), + activity = inifile.IniReadValue("AdujustQtyParam", "activity"), + modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_NONE, + sfcList = new miBatchCompleteSfcAndAdujustQtySfcEntity[] + { + new miBatchCompleteSfcAndAdujustQtySfcEntity() + { + processLot = bindRfid, + sfc = "", + qty =eaValue.ToString(), + unit = "EA" + } + } + }; + LogHelper.Info("调用MES接口调整物料" + bindSfc + "数量"); + LogHelper.Info("MES调整数量接口请求参数:" + JsonChange.ModeToJson(miBatchCompleteSfcAndAdujustQtyServiceServiceParam)); + + if (appConfig.isMesFlag == 1) + { + var requestResult = MesWebServices.iMiBatchCompleteSfcAndAdujustQtyServiceService(miBatchCompleteSfcAndAdujustQtyServiceServiceParam); + LogHelper.Info("MES调整数量接口返回参数:" + JsonChange.ModeToJson(requestResult)); + if (requestResult.@return.code > 0) + { + LogHelper.Info("MES调整数量接口调用失败:" + requestResult.@return.message); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES调整数量接口调用失败:" + upLoadBusiness.GetMesMessage(requestResult.@return.code, requestResult.@return.message)); + plcBusiness.writePlc(appConfig.AbAddress.MES异常, requestResult.@return.code); + return false; + } + } + LogRefreshEvent?.Invoke(LogType.MesLog, "MES调整数量接口调用成功"); + return true; + } + + /// + /// 通过MES获取拆分后绑定的SFC + /// + /// + /// + private string GetBindSfcByMes(string rfidStr) + { + string sfcStr = ""; + DateTime beginTime = new DateTime(); + ProcessLotServiceWSServiceParam processLotServiceWSServiceParam = new ProcessLotServiceWSServiceParam() + { + url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"), + site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"), + processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr) + }; + + try + { + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES接口获取RFID绑定的SFC"); + LogHelper.Info("MES获取膜卷号接口请求参数:" + JsonChange.ModeToJson(processLotServiceWSServiceParam)); + if (appConfig.isMesFlag == 1) + { + readProcessLotResponse readProcessLotResponse = MesWebServices.readProcessLot(processLotServiceWSServiceParam); + LogHelper.Info("MES获取膜卷号接口返回参数:" + JsonChange.ModeToJson(readProcessLotResponse)); + if (readProcessLotResponse.Response.processLotMemberList != null) + { + sfcStr = readProcessLotResponse.Response.processLotMemberList[0].memberContext.Substring(11); + LogHelper.Info("RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr); + LogRefreshEvent?.Invoke(LogType.MesLog, "RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr); + } + } + else + { + sfcStr = System.Guid.NewGuid().ToString("N").Substring(0, 14); + } + } + catch (Exception ex) + { + LogHelper.Info("MES获取膜卷号接口调用异常:" + ex.Message); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES获取膜卷号接口调用异常:" + ex.Message); + WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, null, beginTime, ex.Message); + } + return sfcStr; + } + + /// + /// 获取放卷位EA值 + /// + /// + /// + /// + private string GetUpMaterialQty(int position,string bindSfc, string logStr) + { + LogHelper.Info(logStr + "通过MES接口获取放卷物料的EA值"); + MiSFCQueryQtyServiceServiceParam sFCQueryQtyServiceServiceParam = new MiSFCQueryQtyServiceServiceParam() + { + url = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "url"), + site = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "site"), + sfc = bindSfc + }; + LogHelper.Info(logStr + "完工,MES获取物料EA值接口请求参数:" + JsonChange.ModeToJson(sFCQueryQtyServiceServiceParam)); + DateTime beginTime = DateTime.Now; + try + { + if (appConfig.isMesFlag == 1) + { + var sfcQueryQtyResponse = MesWebServices.iMiSFCQueryQtyServiceService(sFCQueryQtyServiceServiceParam); + LogHelper.Info(logStr + "MES获取物料EA值接口返回参数:" + JsonChange.ModeToJson(sfcQueryQtyResponse)); + + if (sfcQueryQtyResponse.@return.code > 0) + { + LogHelper.Info(logStr + "MES获取物料EA值接口请求失败:" + sfcQueryQtyResponse.@return.message); + LogRefreshEvent?.Invoke(LogType.MesLog, String.Format(logStr + "通过MES接口获取放卷物料{0}的SFC数量失败:{1}", bindSfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message))); + LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + "通过MES接口获取放卷物料{0}的SFC数量失败:{1}", bindSfc, upLoadBusiness.GetMesMessage(sfcQueryQtyResponse.@return.code, sfcQueryQtyResponse.@return.message))); + return ""; + } + return sfcQueryQtyResponse.@return.qty; + } + else + { + return "2600"; + } + } + catch (Exception ex) + { + LogHelper.Info(String.Format(logStr + "MES获取SFC数量接口异常:{1}", ex.Message)); + WebServiceLog.saveMiSFCQueryQtyServiceService(sFCQueryQtyServiceServiceParam, null, beginTime, ex.Message); + LogRefreshEvent?.Invoke(LogType.MesLog, String.Format(logStr + "MES获取SFC数量接口异常:{1}", ex.Message)); + LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format(logStr + "MES获取SFC数量接口异常:{1}", ex.Message)); + return ""; + } + } + + /// + /// 拆分MES账目数量 + /// + /// + /// + /// + /// + private async Task SpiltAccount(int position, ProShaftInfo shaftInfos, int eaValue, string upMaterialSfc, ProUpRecord upRecord, ProDownRecord downRecord) + { + LogHelper.Info("自动完工MES账目数量"); + LogRefreshEvent?.Invoke(LogType.MesLog, "自动完工MES账目数量:" + eaValue); + miBatchCompleteSfcAndAdujustQtySfcEntity[] miBatchCompleteSfcAndAdujustQtySfcEntities = new miBatchCompleteSfcAndAdujustQtySfcEntity[1]; + shaftInfos.bindEaValue = eaValue.ToString(); + + miBatchCompleteSfcAndAdujustQtySfcEntities[0] = new miBatchCompleteSfcAndAdujustQtySfcEntity() + { + processLot = shaftInfos.bindRfid, + qty = shaftInfos.bindEaValue, + unit = "EA", + }; + + //更新绑定信息 + await shaftInfoServices.Update(shaftInfos); + + LogRefreshEvent?.Invoke(LogType.RfidLog, "调用MES自动完工接口"); + LogHelper.Info("调用MES自动完工接口"); + WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC; + MiBatchCompleteSfcAndAdujustQtyServiceServiceParam requestParam = new MiBatchCompleteSfcAndAdujustQtyServiceServiceParam() + { + url = inifile.IniReadValue("SplitSfcParam","url"), + site = inifile.IniReadValue("SplitSfcParam", "site"), + sfcPre = upMaterialSfc, + processLotPre = "", + operation = appConfig.operation, //阳极ANCAP1 //阴极CACAP1 + operationRevision = inifile.IniReadValue("SplitSfcParam", "operationRevision"), + resource = appConfig.resource, + user = inifile.IniReadValue("SplitSfcParam", "user"), + activity = inifile.IniReadValue("SplitSfcParam", "activity"), + //modeProcessSfc = WebService.MiBatchCompleteSfcAndAdujustQtyServiceService.ModeProcessSfc.MODE_NONE, + modeProcessSfc = modeProcessSfc, + sfcList = miBatchCompleteSfcAndAdujustQtySfcEntities, + + }; + MiBatchCompleteSfcAndAdujustQtyResponse batchCompleteSfcAndAdujustQtyResponse = new MiBatchCompleteSfcAndAdujustQtyResponse(); + DateTime beginTime = DateTime.Now; + try + { + LogHelper.Info("MES自动完工接口请求参数:" + JsonChange.ModeToJson(requestParam)); + if (appConfig.isMesFlag == 1) + { + if (StringExtension.IsBlank(downRecord.Sfc)) + { + batchCompleteSfcAndAdujustQtyResponse = MesWebServices.iMiBatchCompleteSfcAndAdujustQtyServiceService(requestParam); + LogHelper.Info("MES自动完工接口返回参数:" + JsonChange.ModeToJson(batchCompleteSfcAndAdujustQtyResponse)); + + var result = batchCompleteSfcAndAdujustQtyResponse.@return; + if (result.code > 0) + { + LogHelper.Info("MES自动完工接口调用失败:" + result.message); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES自动完工接口调用失败:" + upLoadBusiness.GetMesMessage(result.code, result.message)); + LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动完工接口调用失败:" + upLoadBusiness.GetMesMessage(result.code, result.message)); + plcBusiness.writePlc(appConfig.AbAddress.MES异常, result.code); + return false; + } + } + + LogHelper.Info("MES自动完工接口调用成功"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "MES自动完工接口调用成功"); + + + } + } + catch (Exception ex) + { + LogHelper.Error("MES自动完工接口调用异常", ex); + LogHelper.Info("MES自动完工接口调用异常:" + ex.Message); + + WebServiceLog.saveMiBatchCompleteSfcAndAdujustQtyServiceService(requestParam, null, beginTime, ex.Message); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES自动完工接口异常:" + ex.Message); + LogRefreshEvent?.Invoke(LogType.MesLog, "MES自动完工接口异常:" + ex.Message); + plcBusiness.writePlc(appConfig.AbAddress.MES异常, 1); + return false; + } + return true; + } + + /// + /// 卷筒涨紧MES处理信号 + /// + /// + /// + /// 是否是自动读取,如果不是自动读取需要把PLC信号清掉 + public async void SJMesBegin(int position, string epc, bool auto) + { + string logStr = position == 1 ? "收卷轴" : "放卷轴"; + string sfc = ""; + ///把之前的信号清除了,但是现在还有问题,现在泄气以后, + ///现场应该还要再涨紧,还会给我信号 + if (!auto) + { + //清除泄气信号 + plcBusiness.writePlc(appConfig.AbAddress.收卷气胀轴泄气, 0); + + // plcBusiness.writePlc(appConfig.AbAddress.气涨泄气, 0); + //清除报警 + plcBusiness.writePlc(appConfig.AbAddress.RFID异常, 0); + } + try + { + + #region Add By wenjy 2022-09-20 获取工单信息,判断是否需要更换工单 + //if (!ShopOrderAlarm(position)) + //{ + // //MES接口返回异常,控制PLC气胀轴写1泄气 + // plcBusiness.writePlc(appConfig.AbAddress.气涨泄气, 1); + // //写入报警 + // plcBusiness.writePlc(appConfig.AbAddress.MES异常, 1); + // return; + //} + #endregion + + //调用MES接口获取SFC + #region Update By wenjy 2022-09-20 凹版工单下达逻辑修改,判断第一位不为L时重新获取 + sfc = GetSFC(position); + if (StringExtension.IsBlank(sfc)) + { + return; + } + #endregion + + LogHelper.Info("凹版工单下达接口调用成功,SFC膜卷号为:" + sfc); + LogRefreshEvent?.Invoke(LogType.MesLog, "MES凹版工单下达接口调用成功,膜卷号:" + sfc); + //GetSFCByMesEvent?.Invoke(true, sfc); + + WriteSfcAndEpc(position, sfc, epc); + + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = epc, + position = position, + sfc = sfc, + ea = "", + }, + plcStatus = true, + }); + LogHelper.Info("本地保存RFID及膜卷号信息生成收卷记录"); + + //实时绑定卷轴与RFID信息 + LogHelper.Info(String.Format("绑定{0}卷轴与RFID:{1}获取卷轴信息", logStr, epc)); + Expression> exp = s1 => true; + exp = exp.And(x => x.positionId == position.ToString() && x.processId == appConfig.processId); + Expression> order = (x) => x.bindTime; + ProShaftInfo shaftInfo = await shaftInfoServices.QueryFirst(exp, order, true); + + if (shaftInfo == null) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, "绑定卷轴与RFID条码获取卷轴信息为空"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "绑定卷轴与RFID条码获取卷轴信息为空"); + LogHelper.Info("绑定卷轴与RFID获取卷轴信息为空"); + return; + } + LogHelper.Info("获取卷轴信息为:" + JsonChange.ModeToJson(shaftInfo)); + shaftInfo.bindRfid = epc; + shaftInfo.bindSfc = sfc; + shaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + await shaftInfoServices.Update(shaftInfo); + + LogHelper.Info("本地绑定RFID:" + epc + ",SFC:" + sfc); + //PLC允许转塔 D9602写1 + //plcBusiness.writePlc(appConfig.AbAddress.是否转塔, 1); + + //添加下料记录 + ProDownRecord downRecord = new ProDownRecord() + { + Id = System.Guid.NewGuid().ToString("N"), + MachineId = appConfig.machineId, + PositionId = position, + Rfid = epc, + Sfc = sfc, + IsProduction = 0, + beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + await downRecordServices.Add(downRecord); + + //upLoadBusiness.SaveDownRecord(downRecord); + } + catch (Exception e) + { + LogHelper.Info(e.ToString()); + } + + } + private void WriteSfcAndEpc(int position, string sfcStr, string rfidStr) + { + if (position == 1) + { + //LogHelper.Info("将SFC与RFID写入PLC地址"); + //PlcBusiness.writeStrPlc(appConfig.AbAddress.收卷轴SFC, sfcStr); + LogRefreshEvent?.Invoke(LogType.PlcLog, "将SFC与RFID写入PLC地址"); + } + else + { + //LogHelper.Info("将SFC与RFID写入PLC地址"); + //PlcBusiness.writeStrPlc(appConfig.AbAddress.放卷SFC, sfcStr); + LogRefreshEvent?.Invoke(LogType.PlcLog, "将SFC与RFID写入PLC地址"); + } + + } + /// + /// 凹版工单下达 + /// + /// + private string GetSFC(int position) + { + string sfc = ""; + LogHelper.Info("调用MES凹版工单下达接口"); + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES凹版工单下达接口"); + //调MES凹版工单下达接口获取SFC + MiReleaseSfcWithActivityServiceServiceParam miReleaseSfcWithActivityServiceServiceParam = new MiReleaseSfcWithActivityServiceServiceParam() + { + url = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "url"), + site = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "site"), + user = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "user"), + operation = appConfig.operation, + operationRevision = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "operationRevision"), + activityId = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "activity"), + Resource = appConfig.resource, + sfcQty = 1, + modeProcessSfc = modeProcessSFC.MODE_START_SFC, //MODE_START_SFC + isCarrierType = false, + loginUser = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "loginUser"), + password = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "password"), + }; + DateTime beginTime = DateTime.Now; + try + { + LogHelper.Info("凹版工单下达接口请求参数:" + JsonChange.ModeToJson(miReleaseSfcWithActivityServiceServiceParam)); + + if (appConfig.isMesFlag == 1) + { + miReleaseSfcWithActivityResponse releaseSfcWithActivityResponse = MesWebServices.iMiReleaseSfcWithActivityServiceService(miReleaseSfcWithActivityServiceServiceParam); + LogHelper.Info("凹版工单下发接口返回参数:" + JsonChange.ModeToJson(releaseSfcWithActivityResponse)); + if (releaseSfcWithActivityResponse.@return.code > 0) + { + LogRefreshEvent?.Invoke(LogType.MesLog, "MES凹版工单获取失败:" + upLoadBusiness.GetMesMessage(releaseSfcWithActivityResponse.@return.code, releaseSfcWithActivityResponse.@return.message)); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES凹版工单单获取:" + upLoadBusiness.GetMesMessage(releaseSfcWithActivityResponse.@return.code, releaseSfcWithActivityResponse.@return.message)); + //GetSFCByMesEvent?.Invoke(false, ""); + //MES接口返回异常,控制PLC气胀轴写1泄气 + //plcBusiness.writePlc(appConfig.AbAddress.RFID异常, 1); + if (position == 0) + { + plcBusiness.writePlc(appConfig.AbAddress.放卷气胀轴泄气, 1); + } + else + { + plcBusiness.writePlc(appConfig.AbAddress.收卷气胀轴泄气, 1); + } + //写入报警 + plcBusiness.writePlc(appConfig.AbAddress.MES异常, 1); + //写入转塔是否可以旋转 + //plcBusiness.writePlc(appConfig.AbAddress.是否转塔, 0); + LogHelper.Info("凹版工单下达接口获取失败:" + releaseSfcWithActivityResponse.@return.message + ",下发气胀轴泄气D9608,下发MES接口返回异常报警D9612"); + + return ""; + } + sfc = releaseSfcWithActivityResponse.@return.sfcArray[0].sfc; + } + else + { + Random random = new Random(); + sfc = "LYL3PC0223082400" + random.Next(10, 99); + //qty = "2000"; + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("MES首工序获取SFC接口调用成功,SFC:{0}", sfc)); + } + return sfc; + } + catch (Exception ex) + { + WebServiceLog.saveMiReleaseSfcWithActivityServiceService(miReleaseSfcWithActivityServiceServiceParam, null, beginTime, ex.Message); + + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES凹版工单下达接口调用异常:" + ex.Message); + LogRefreshEvent?.Invoke(LogType.MesLog, "MES凹版工单下达接口调用异常:" + ex.Message); + //GetSFCByMesEvent?.Invoke(false, ""); + //读取失败,控制PLC气胀轴 + //plcBusiness.writePlc(appConfig.AbAddress.气涨泄气, 1); + if (position == 0) + { + plcBusiness.writePlc(appConfig.AbAddress.放卷气胀轴泄气, 1); + } + else + { + plcBusiness.writePlc(appConfig.AbAddress.收卷气胀轴泄气, 1); + } + //写入报警 + plcBusiness.writePlc(appConfig.AbAddress.MES异常, 1); + //写入转塔是否可以旋转 + // plcBusiness.writePlc(appConfig.AbAddress.是否转塔, 0); + return ""; + } + } + /// + /// 放卷涨紧手动写入 + /// + /// + /// + /// + public async void FJMesBegin(int position, string epc, bool auto) + { + string sfc = ""; + string qty = ""; + try + { + //手动写入清除放卷位报警 + if (!auto) + { + plcBusiness.writePlc(appConfig.AbAddress.放卷气胀轴泄气, 0); + plcBusiness.writePlc(appConfig.AbAddress.RFID异常, 0); + plcBusiness.writePlc(appConfig.AbAddress.MES异常, 0); + } + //凹版上料 + LogHelper.Info("调用MES凹版自动上料接口"); + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES凹版自动上料接口"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "调用MES凹版自动上料接口"); + + + + LogHelper.Info("调用MES首工序获取SFC接口"); + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES首工序获取SFC接口"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "调用MES首工序获取SFC接口"); + sfc = GetSFC(position); + if (StringExtension.IsBlank(sfc)) + { + return; + } + + //放卷位膜卷号写入PLC地址 + WriteSfcAndEpc(position, sfc,epc); + LogRefreshEvent?.Invoke(LogType.PlcLog, "放卷位物料SFC写入PLC地址:" + sfc); + + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = epc, + sfc = sfc, + position = position, + ea = qty, + }, + plcStatus = true, + }); + + //实时绑定卷轴与RFID信息 + LogHelper.Info(String.Format("绑定放卷轴与RFID:{0};获取卷轴信息", epc)); + ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position); + + if (shaftInfo == null || StringExtension.IsBlank(shaftInfo.processId)) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, "绑定卷轴与RFID,获取卷轴信息为空"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "绑定卷轴与RFID,获取卷轴信息为空"); + LogHelper.Info("绑定卷轴与RFID,获取卷轴信息为空"); + return; + } + LogHelper.Info("获取卷轴信息为:" + JsonChange.ModeToJson(shaftInfo)); + shaftInfo.bindRfid = epc; + shaftInfo.bindSfc = sfc; + shaftInfo.bindEaValue = qty; + shaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + await shaftInfoServices.Update(shaftInfo); + + //本地保存SFC,上料记录 + ProUpRecord upRecord = new ProUpRecord() + { + Id = System.Guid.NewGuid().ToString(), + MachineId = appConfig.machineId, + UpMaterialId = sfc, //存放凹版来料膜卷号 + PositionId = position, + Rfid = epc, + Sfc = sfc, + eaValue = StringChange.ParseToInt(qty), + IsProduction = 0, + beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + await upRecordServices.Add(upRecord); + + //upLoadBusiness.SaveUpRecord(upRecord); + + //判断是否合卷 + //if (JudgementMaterial(sfc)) + //{ + // LogHelper.Info("上料成功,收卷位SFC与放卷SFC不同触发合卷报警"); + // plcBusiness.writePlc(appConfig.AbAddress.合卷报警, 1); + //} + //手动写入自动下降U型块 + if (!auto) + { + plcBusiness.writePlc(appConfig.AbAddress.放卷手动上料, 1); + + } + } + catch (Exception ex) + { + LogHelper.Error("放卷涨紧手动写入异常", ex); + } + } + + /// + /// 下料成功 + /// + /// + public void sendSuccess(int position) + { + if (position == 1) + { + plcBusiness.writePlc(appConfig.AbAddress.收卷控制下料, 0); + } + if (position == 0) + { + plcBusiness.writePlc(appConfig.AbAddress.放卷控制下料, 0); + } + } + + /// + /// 禁止下料 + /// + /// + public void sendError(int position) + { + if (position == 0) plcBusiness.writePlc(appConfig.AbAddress.放卷控制下料, 1); + if (position == 1) plcBusiness.writePlc(appConfig.AbAddress.收卷控制下料, 1); + + } + + /// + /// 异常下发 + /// + /// + /// + /// + public void sendError(int position, int errorType, bool isFinish, int mesCode) + { + if (isFinish) + { + if (errorType == 1) //MES异常 + { + plcBusiness.writePlc(appConfig.AbAddress.MES异常, mesCode); + } + } + else + { + if (errorType == 1) //MES异常 + { + plcBusiness.writePlc(appConfig.AbAddress.MES异常, mesCode); + } + if (errorType == 2) + { + plcBusiness.writePlc(appConfig.AbAddress.RFID异常, 1); + } + } + } + /// + /// 通过RFID获取SFC + /// + /// + /// + private string[] GetSfcListByRfid(string rfidStr) + { + string[] sfcStr = new string[0]; + string strlog = ""; + DateTime beginTime = new DateTime(); + ProcessLotServiceWSServiceParam processLotServiceWSServiceParam = new ProcessLotServiceWSServiceParam() + { + //url = "http://lymesa.catlbattery.com:8103/manufacturing-papiservices/ProcessLotServiceWSService?wsdl", + //site = "2100", + url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"), + site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"), + processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr), + loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"), + password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password") + }; + + try + { + LogRefreshEvent?.Invoke(LogType.MesLog, "调用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 = new string[readProcessLotResponse.Response.processLotMemberList.Count()]; + for (int i = 0; i < readProcessLotResponse.Response.processLotMemberList.Count(); i++) + { + sfcStr[i] = readProcessLotResponse.Response.processLotMemberList[i].memberContext; + strlog += "RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr[i].Substring(11) + "\r\n"; + } + + LogHelper.Info(strlog); + LogRefreshEvent?.Invoke(LogType.MesLog, strlog); + } + } + else + { + //sfcStr = System.Guid.NewGuid().ToString("N").Substring(0, 14); + Random random = new Random(); + sfcStr = new string[1]; + sfcStr[0] = "LYL3PC0223082400" + random.Next(10, 99); + } + } + catch (Exception ex) + { + + LogHelper.Info("MES获取膜卷号接口调用异常:" + ex.Message); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES获取膜卷号接口调用异常:" + ex.Message); + return null; + //WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, null, beginTime, ex.Message); + } + return sfcStr; + } + /// + /// 解绑RFID与SFC + /// + /// + public void UnBindRfidAndSfc(string rfidStr) + { + //获取当前RFID是否绑定 + int lowQuantity; + //string sfcStr = GetSfcByRfid(rfidStr); + string[] strlist = GetSfcListByRfid(rfidStr); + + DateTime beginTime = new DateTime(); + if (strlist != null && strlist.Count() > 0) + { + ProcessLotServiceWSServiceParam lotServiceWSServiceParam = + new ProcessLotServiceWSServiceParam() + { + url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"), + site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"), + processlotref = "ProcessLotBO:2100," + rfidStr, + memberlist = strlist, + loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"), + password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password") + }; + LogHelper.Info("MES解绑接口请求参数:" + JsonChange.ModeToJson(lotServiceWSServiceParam)); + beginTime = DateTime.Now; + try + { + if (appConfig.isMesFlag == 1) + { + removeMemberResponse removeMember = + MesWebServices.iRemoveMember(lotServiceWSServiceParam); + LogRefreshEvent?.Invoke(LogType.RfidLog, "RFID条码:" + rfidStr + "成功解绑SFC!"); + + 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信息"); + } + } + + /// + /// 根据设备位置获取卷轴信息 + /// + /// + /// + public async Task GetShaftInfoByPosition(int position) + { + try + { + string str = appConfig.processId; + Expression> exp = s1 => true; + exp = exp.And(x => x.positionId == position.ToString() && x.processId == str); + List result = await shaftInfoServices.Query(exp); + + if (result != null || result.Count > 0) + { + ProShaftInfo shaftInfo = result.FirstOrDefault(); + return shaftInfo; + } + return null; + } + catch (Exception ex) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, "获取卷轴信息为空"); + LogHelper.Info("获取卷轴信息异常:" + ex.Message); + return null; + } + } + + + /// + /// 强制下料 + /// + /// + public void ForceDown(int position) + { + switch (position) + { + case 1: + LogRefreshEvent?.Invoke(LogType.PlcLog, "收卷轴异常下料信号触发,下发下料信号"); + LogHelper.Info("收卷轴异常下料信号触发,下发下料信号"); + plcBusiness.writePlc(appConfig.AbAddress.收卷控制下料, 0); + break; + default: + break; + } + } + + /// + /// 收卷位开始信号 + /// + /// + public void DownBegin(int position) + { + string logStr = position == 1 ? "收卷轴" : "放卷轴"; + try + { + //禁止下料 + sendError(position); + LogHelper.Info(logStr + "收卷开始信号触发成功,解绑RFID绑定的SFC条码"); + LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "收卷开始信号触发成功"); + LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "解绑RFID绑定的SFC条码"); + //获取RFID条码信息 + ProShaftInfo shaftInfo = this.GetShaftInfoByPosition(position).Result; + this.UnBindRfidAndSfc(shaftInfo.bindRfid); + } + catch (Exception ex) + { + LogHelper.Info(logStr + "收卷开始信号逻辑处理异常:" + ex.Message); + upLoadBusiness.SaveLogRecord(position, logStr + "收卷开始信号逻辑处理异常:" + ex.Message); + } + } + + /// + /// 判断收卷位是否合卷 + /// + /// + /// + /// + private async Task PdRfidIsChuanDu(string epc, int position) + { + try + { + LogHelper.Info("RFID条码:" + epc + "判断是否串读逻辑处理"); + Expression> exp = s1 => true; + exp = exp.And(x => x.bindRfid == epc && x.positionId != position.ToString() && x.processId == appConfig.processId); + List shaftInfos = await shaftInfoServices.Query(exp); + if (shaftInfos.Count > 0) + { + return true; + } + return false; + } + catch (Exception ex) + { + LogHelper.Error("串读逻辑处理异常", ex); + return false; + } + } + + /// + ///判断当前是哪个轴 + /// + /// + private string Which(int position) + { + string logStr = ""; + if (position == 1) logStr = "收卷轴"; + return logStr; + } + + + /// + /// 设备启动 + /// + public void MachineStartUp() + { + #region Delete By wenjy 2022-12-27 ME要求改为原逻辑 + // throw new NotImplementedException(); + //LogRefreshEvent?.Invoke(LogType.PlcLog, "开机启动信号触发成功"); + //LogHelper.Info("开机启动信号触发成功"); + ////通过PLC地址获取放卷膜卷号 + //string sfc = PlcBusiness.readStrPlc("D6034", (ushort)18).Replace("\0", "").Trim(); + ////JudgementMaterial(放卷膜卷号),返回true合卷报警=>PLC 写报警值,返回false不处理 + //if (StringExtension.IsNotBlank(sfc)) + //{ + // // 判断合卷 + // if (JudgementMaterial(sfc)) + // { + // LogHelper.Info("触发合卷报警,下发PLC报警指令"); + // LogRefreshEvent?.Invoke(LogType.AlarmLog, "放卷位与收卷位膜卷号不同触发合卷报警"); + // // 写入合卷报警 + // plcBusiness.writePlc("D6114", 1); + // } + //} + #endregion + } + + /// + /// 放卷位物料是否结束生产 + /// + /// + private async Task UpMaterialIsEndProduction(string rfidStr) + { + bool result = false; + //通过MES获取RFID绑定的SFC并判断是否结束,凹版来料RFID绑定为凹版膜卷号,暂不使用SFC判断,使用RFID判断 + string sfcStr = GetSfcByRfid(rfidStr); + + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("当前RFID:{0}绑定的SFC为:{1}", rfidStr, sfcStr)); + //通过SFC判断该卷物料是否已经生产结束,如果已生产返回true,未生产返回false + //upRecordServices + Expression> exp = s1 => true; + exp = exp.And(x => x.Rfid == rfidStr); + Expression> order = s1 => s1.RecordTime; + ProUpRecord upRecord = await upRecordServices.QueryFirst(exp, order, false); + if (upRecord != null) + { + if (StringExtension.IsBlank(upRecord.endTime)) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("当前SFC:{0}放卷结束时间为空,生产未结束", sfcStr)); + result = false; + } + else + { + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("当前SFC:{0}放卷结束时间为:{1}", sfcStr, upRecord.endTime)); + result = true; + } + } + return result; + } + + /// + /// 通过RFID获取SFC + /// + /// + /// + private string GetSfcByRfid(string rfidStr) + { + string sfcStr = ""; + DateTime beginTime = new DateTime(); + ProcessLotServiceWSServiceParam processLotServiceWSServiceParam = new ProcessLotServiceWSServiceParam() + { + url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"), + site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"), + processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr) + }; + + try + { + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES接口获取RFID绑定的SFC"); + LogHelper.Info("MES获取膜卷号接口请求参数:" + JsonChange.ModeToJson(processLotServiceWSServiceParam)); + if (appConfig.isMesFlag == 1) + { + readProcessLotResponse readProcessLotResponse = MesWebServices.readProcessLot(processLotServiceWSServiceParam); + LogHelper.Info("MES获取膜卷号接口返回参数:" + JsonChange.ModeToJson(readProcessLotResponse)); + if (readProcessLotResponse.Response.processLotMemberList != null) + { + sfcStr = readProcessLotResponse.Response.processLotMemberList[0].memberContext.Substring(11); + LogHelper.Info("RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr); + LogRefreshEvent?.Invoke(LogType.MesLog, "RFID条码:" + rfidStr + "绑定的SFC条码为:" + sfcStr); + } + } + else + { + sfcStr = System.Guid.NewGuid().ToString("N").Substring(0, 14); + } + } + catch (Exception ex) + { + LogHelper.Info("MES获取膜卷号接口调用异常:" + ex.Message); + LogRefreshEvent?.Invoke(LogType.MesLog, "MES获取膜卷号接口调用异常:" + ex.Message); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES获取膜卷号接口调用异常:" + ex.Message); + WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, null, beginTime, ex.Message); + } + return sfcStr; + } + + 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); + } + + + } +} diff --git a/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs b/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs index aa27cc3..3e50119 100644 --- a/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs +++ b/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs @@ -79,12 +79,12 @@ namespace MaterialTraceability.Business.Impl ///add by yinzf /// - /// + /// 放卷开始 /// /// public void UpBegin(int position) { - + //禁止下料 } //end add /// @@ -1751,18 +1751,6 @@ namespace MaterialTraceability.Business.Impl plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 0); plcBusiness.writePlc(appConfig.LyAddress.收卷1BOK, 1); break; - case 3: - LogRefreshEvent?.Invoke(LogType.PlcLog, "2A轴异常下料信号触发,下发下料信号"); - LogHelper.Info("2A轴异常下料信号触发,下发下料信号"); - plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 0); - plcBusiness.writePlc(appConfig.LyAddress.收卷2AOK, 1); - break; - case 4: - LogRefreshEvent?.Invoke(LogType.PlcLog, "2B轴异常下料信号触发,下发下料信号"); - LogHelper.Info("2B轴异常下料信号触发,下发下料信号"); - plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 0); - plcBusiness.writePlc(appConfig.LyAddress.收卷2BOK, 1); - break; default: break; } @@ -1774,7 +1762,7 @@ namespace MaterialTraceability.Business.Impl /// public void DownBegin(int position) { - throw new NotImplementedException(); + //禁止下料 } /// diff --git a/MaterialTraceability.Business/MainBusiness.cs b/MaterialTraceability.Business/MainBusiness.cs index 30b62af..b2488c2 100644 --- a/MaterialTraceability.Business/MainBusiness.cs +++ b/MaterialTraceability.Business/MainBusiness.cs @@ -57,6 +57,9 @@ namespace MaterialTraceability.Business switch (appConfig.processId) { + case "AB": + signalRead = new ABSignalReadBusiness(); + break; case "TB": signalRead = new TBSignalReadBusiness(); break; diff --git a/MaterialTraceability.Business/MaterialTraceability.Business.csproj b/MaterialTraceability.Business/MaterialTraceability.Business.csproj index e8f2f32..3a6f338 100644 --- a/MaterialTraceability.Business/MaterialTraceability.Business.csproj +++ b/MaterialTraceability.Business/MaterialTraceability.Business.csproj @@ -55,6 +55,7 @@ + diff --git a/MaterialTraceability.Business/PlcBusiness.cs b/MaterialTraceability.Business/PlcBusiness.cs index d5fcff7..cbb6838 100644 --- a/MaterialTraceability.Business/PlcBusiness.cs +++ b/MaterialTraceability.Business/PlcBusiness.cs @@ -168,6 +168,69 @@ namespace MaterialTraceability.Business { //获取工序编号 TB-涂布、LY冷压预分切、MQ-模切、JR-卷绕 string processCode = appConfig.processId; + #region 凹版 + //凹版工序 + if (processCode.Equals("AB")) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.心跳, 1); + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.放卷开始) == 1) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.放卷开始, 0); + SignalRefreshEvent?.Invoke(6, 0); + } + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.收卷开始) == 1) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.收卷开始, 0); + SignalRefreshEvent?.Invoke(7, 1); + } + //放卷 涨紧信号 + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.放卷涨紧) == 1) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.放卷涨紧, 0); + SignalRefreshEvent?.Invoke(1, 0); + } + + //放卷结束信号 + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.放卷结束) == 1) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.放卷结束, 0); + SignalRefreshEvent?.Invoke(2, 0); + } + + //收卷涨紧信号-1A气胀轴 + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.收卷涨紧) == 1) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.收卷涨紧, 0); + SignalRefreshEvent?.Invoke(3, 1); + } + + + //收卷结束信号-1A气胀轴 + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.收卷结束) == 1) + { + lock (string.Empty) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.收卷结束, 0); + SignalRefreshEvent?.Invoke(4, 1); + } + } + + + //异常下料-1A + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.放卷异常下料) == 1) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.放卷异常下料, 0); + SignalRefreshEvent?.Invoke(5, 1); + } + //异常下料-1B + if (plcInstance.readInt32ByAddress(appConfig.AbAddress.收卷异常下料) == 1) + { + plcInstance.writeInt32ByAddress(appConfig.AbAddress.收卷异常下料, 0); + SignalRefreshEvent?.Invoke(5, 2); + } + + } + #endregion #region 涂布 if (processCode.Equals("TB")) { @@ -750,6 +813,7 @@ namespace MaterialTraceability.Business } } #endregion + } catch (Exception ex) { diff --git a/MaterialTraceability.Common/LogHelper.cs b/MaterialTraceability.Common/LogHelper.cs index 609725c..b749df8 100644 --- a/MaterialTraceability.Common/LogHelper.cs +++ b/MaterialTraceability.Common/LogHelper.cs @@ -39,10 +39,10 @@ namespace MaterialTraceability.Common /// public static void PlcLog(string msg) { - /*if (logPlc.IsInfoEnabled) + if (logPlc.IsInfoEnabled) { logPlc.Info(msg); - }*/ + } } /// diff --git a/MaterialTraceability.Entity/Config/AbAddress.cs b/MaterialTraceability.Entity/Config/AbAddress.cs new file mode 100644 index 0000000..950ad35 --- /dev/null +++ b/MaterialTraceability.Entity/Config/AbAddress.cs @@ -0,0 +1,59 @@ +using MaterialTraceability.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MaterialTraceability.Entity.Config +{ + public sealed class AbAddress + { + private static INIFile iNIFile = new INIFile(System.Environment.CurrentDirectory + "/PlcConfig/App.InI"); + private static readonly Lazy lazy = new Lazy(() => new AbAddress()); + + public static AbAddress Instance + { + get + { + return lazy.Value; + } + } + + private AbAddress() { } + + public string 心跳 = iNIFile.IniReadValue("ABPLcAddress", "心跳"); + + public string 放卷开始 = iNIFile.IniReadValue("ABPLcAddress", "放卷开始"); + + public string 放卷涨紧 = iNIFile.IniReadValue("ABPLcAddress", "放卷涨紧"); + + public string 放卷结束 = iNIFile.IniReadValue("ABPLcAddress", "放卷结束"); + + public string 收卷开始 = iNIFile.IniReadValue("ABPLcAddress", "收卷开始"); + + public string 收卷涨紧 = iNIFile.IniReadValue("ABPLcAddress", "收卷涨紧"); + + public string 收卷结束 = iNIFile.IniReadValue("ABPLcAddress", "收卷结束"); + + public string 放卷异常下料 = iNIFile.IniReadValue("ABPLcAddress", "放卷异常下料"); + + public string 收卷异常下料 = iNIFile.IniReadValue("ABPLcAddress", "收卷异常下料"); + + public string 放卷控制下料 = iNIFile.IniReadValue("ABPLcAddress", "放卷控制下料"); + + public string 收卷控制下料 = iNIFile.IniReadValue("ABPLcAddress", "收卷控制下料"); + + public string RFID异常 = iNIFile.IniReadValue("ABPLcAddress", "RFID异常"); + + public string MES异常 = iNIFile.IniReadValue("ABPLcAddress", "MES异常"); + + public string 放卷手动上料 = iNIFile.IniReadValue("ABPLcAddress", "放卷手动上料"); + + public string 收卷手动上料 = iNIFile.IniReadValue("ABPLcAddress", "收卷手动上料"); + + public string 放卷气胀轴泄气 = iNIFile.IniReadValue("ABPLcAddress", "放卷气胀轴泄气"); + + public string 收卷气胀轴泄气 = iNIFile.IniReadValue("ABPLcAddress", "收卷气胀轴泄气"); + } +} diff --git a/MaterialTraceability.Entity/DTO/AppConfigDto.cs b/MaterialTraceability.Entity/DTO/AppConfigDto.cs index 6232a70..8a49de0 100644 --- a/MaterialTraceability.Entity/DTO/AppConfigDto.cs +++ b/MaterialTraceability.Entity/DTO/AppConfigDto.cs @@ -55,5 +55,7 @@ namespace MaterialTraceability.Entity.DTO public LyAddress LyAddress = LyAddress.Instance; public MqAddress mqAddress = MqAddress.Instance; + + public AbAddress AbAddress = AbAddress.Instance; } } diff --git a/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj b/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj index 38d6c7c..dd908b5 100644 --- a/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj +++ b/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj @@ -44,6 +44,7 @@ + diff --git a/MaterialTraceabilityUI/ConfigInfo.xaml.cs b/MaterialTraceabilityUI/ConfigInfo.xaml.cs index 318cdce..321a167 100644 --- a/MaterialTraceabilityUI/ConfigInfo.xaml.cs +++ b/MaterialTraceabilityUI/ConfigInfo.xaml.cs @@ -46,6 +46,9 @@ namespace MaterialTraceabilityUI case "MQ_A": iniSection = "MQPLcAddress"; break; + case "AB": + iniSection = "ABPLcAddress"; + break; default: break; } diff --git a/MaterialTraceabilityUI/DownMaterialRecord.xaml.cs b/MaterialTraceabilityUI/DownMaterialRecord.xaml.cs index 740b548..54a1a3a 100644 --- a/MaterialTraceabilityUI/DownMaterialRecord.xaml.cs +++ b/MaterialTraceabilityUI/DownMaterialRecord.xaml.cs @@ -73,7 +73,10 @@ namespace MaterialTraceabilityUI { exp = exp.And(x => x.Sfc.Contains(this.sfcText.Text.ToString())); } - + if (appConfig.processId == "AB") + { + exp = exp.And(x => x.MachineId == appConfig.machineId); + } Expression> order = x => x.beginTime; List proUpRecords = this.SelectDownRecords(exp).Result; diff --git a/MaterialTraceabilityUI/LogRecordControl.xaml.cs b/MaterialTraceabilityUI/LogRecordControl.xaml.cs index 5d1ae43..9b69a2a 100644 --- a/MaterialTraceabilityUI/LogRecordControl.xaml.cs +++ b/MaterialTraceabilityUI/LogRecordControl.xaml.cs @@ -1,4 +1,5 @@ using MaterialTraceability.Entity.DAO; +using MaterialTraceability.Entity.DTO; using MaterialTraceability.SqlSugar; using MaterialTraceability.SqlSugar.ServiceImpl; using MaterialTraceabilityUI.Common; @@ -25,6 +26,7 @@ namespace MaterialTraceabilityUI /// public partial class LogRecordControl : UserControl { + private AppConfigDto appConfig = AppConfigDto.Instance; private IBaseServices logInfoServices = new BaseServices(); public LogRecordControl() { @@ -61,7 +63,10 @@ namespace MaterialTraceabilityUI int isAlarm = Convert.ToString(this.isAlarm.SelectedItem) == "是" ? 1 : 0; exp = exp.And(x => x.isAlarm == isAlarm); } - + if (appConfig.processId == "AB") + { + exp = exp.And(x => x.machineId == appConfig.machineId.ToString()); + } List recordLogInfos = logInfoServices.Query(exp).Result; this.LogRecordDataGrid.ItemsSource = recordLogInfos; diff --git a/MaterialTraceabilityUI/MainWindow.xaml.cs b/MaterialTraceabilityUI/MainWindow.xaml.cs index 3193631..38d0a84 100644 --- a/MaterialTraceabilityUI/MainWindow.xaml.cs +++ b/MaterialTraceabilityUI/MainWindow.xaml.cs @@ -20,6 +20,9 @@ namespace MaterialTraceabilityUI public partial class MainWindow : Window, INotifyPropertyChanged { #region 界面引用 + //凹版页面 + private intaglioPage intaglioPage = new intaglioPage(); + //涂布界面 private CoatingProcess coatingProcess = new CoatingProcess(); @@ -165,6 +168,10 @@ namespace MaterialTraceabilityUI { UserContent = firstPage; } + else if (processId.Contains("AB")) + { + UserContent = intaglioPage; + } else { UserContent = dieCuttingProcess; @@ -237,6 +244,10 @@ namespace MaterialTraceabilityUI { UserContent = coatingProcess; } + else if (processId.Contains("AB")) + { + UserContent = intaglioPage; + } else if (processId.Contains("LY")) { UserContent = firstPage; diff --git a/MaterialTraceabilityUI/SplitSfc.xaml b/MaterialTraceabilityUI/SplitSfc.xaml index 1713f1f..b63b56e 100644 --- a/MaterialTraceabilityUI/SplitSfc.xaml +++ b/MaterialTraceabilityUI/SplitSfc.xaml @@ -106,9 +106,9 @@ - public partial class UpMaterialRecord : UserControl { - + private AppConfigDto appConfig = AppConfigDto.Instance; private IBaseServices uprecordServices = new BaseServices(); public UpMaterialRecord() @@ -72,8 +72,10 @@ namespace MaterialTraceabilityUI { exp = exp.And(x => x.Sfc.Contains(this.sfcText.Text.ToString())); } - - //exp = exp.And(x => x.MachineId == Convert.ToInt32(ConfigHelper.GetConfig("MachineID"))); + if (appConfig.processId == "AB") + { + exp = exp.And(x => x.MachineId == appConfig.machineId); + } Expression> order = x => x.beginTime; List proUpRecords = this.SelectUpRecords(exp).Result; diff --git a/MaterialTraceabilityUI/WriteInfo.xaml.cs b/MaterialTraceabilityUI/WriteInfo.xaml.cs index cb3d1b0..1044adb 100644 --- a/MaterialTraceabilityUI/WriteInfo.xaml.cs +++ b/MaterialTraceabilityUI/WriteInfo.xaml.cs @@ -36,6 +36,8 @@ namespace MaterialTraceabilityUI private LYSignalReadBusiness lYSignalRead = new LYSignalReadBusiness(); private MQSignalReadBusiness mQSignalRead = new MQSignalReadBusiness(); + + private ABSignalReadBusiness ABSignalRead = new ABSignalReadBusiness(); public WriteInfo() { InitializeComponent(); @@ -46,7 +48,23 @@ namespace MaterialTraceabilityUI this.processId = processId; this.position = position; InitializeComponent(); - this.rfidCode.Text = "JSLY5RD"; + if (processId == "AB") + { + if (position == 0) + { + //this.rfidCode.Text = ""; + + } + else + { + this.rfidCode.Text = "JSLY5RD"; + + } + } + else + { + this.rfidCode.Text = "JSLY5RD"; + } } /// @@ -100,7 +118,19 @@ namespace MaterialTraceabilityUI MessageBox.Show("冷压RFID条码信息写入成功"); } + else if (processId == "AB") + { + if (position == 0) + { + ABSignalRead.FJMesBegin(position, rfidCode, false); + } + else + { + ABSignalRead.SJMesBegin(position, rfidCode, false); + } + MessageBox.Show("凹版RFID条码信息写入成功"); + } this.Close(); } diff --git a/MaterialTraceabilityUI/intaglioPage.xaml b/MaterialTraceabilityUI/intaglioPage.xaml index 7aa7bf4..3db7437 100644 --- a/MaterialTraceabilityUI/intaglioPage.xaml +++ b/MaterialTraceabilityUI/intaglioPage.xaml @@ -46,7 +46,7 @@ - + - + - + + diff --git a/MaterialTraceabilityUI/intaglioPage.xaml.cs b/MaterialTraceabilityUI/intaglioPage.xaml.cs index 18c9c20..491a64d 100644 --- a/MaterialTraceabilityUI/intaglioPage.xaml.cs +++ b/MaterialTraceabilityUI/intaglioPage.xaml.cs @@ -35,11 +35,11 @@ namespace MaterialTraceabilityUI InitializeComponent(); try { - if (appConfig.processId.Contains("LY")) + if (appConfig.processId == "AB") { MainBusiness.LogRefreshEvent += LogRefresh; - LYSignalReadBusiness.LogRefreshEvent += LogRefresh; - LYSignalReadBusiness.ViewModelRefreshEvent += ProductionParam; + ABSignalReadBusiness.LogRefreshEvent += LogRefresh; + ABSignalReadBusiness.ViewModelRefreshEvent += ProductionParam; UserControlInit(); refreshThread(); @@ -78,138 +78,138 @@ namespace MaterialTraceabilityUI case 1: action = () => { - this.Down_SFC_1.Text = "SFC:" + viewModelDto.rfidInfo.sfc; + this.Down_SFC_5.Text = "SFC:" + viewModelDto.rfidInfo.sfc; }; - Down_SFC_1.Dispatcher.BeginInvoke(action); + Down_SFC_5.Dispatcher.BeginInvoke(action); action = () => { - this.Down_RFID_1.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + this.Down_RFID_5.Text = "RFID:" + viewModelDto.rfidInfo.rfid; }; - Down_RFID_1.Dispatcher.BeginInvoke(action); + Down_RFID_5.Dispatcher.BeginInvoke(action); action = () => { - this.Down_EA_1.Text = "EA:"+viewModelDto.rfidInfo.ea; + this.Down_EA_5.Text = "EA:" + viewModelDto.rfidInfo.ea; }; - Down_EA_1.Dispatcher.BeginInvoke(action); + Down_EA_5.Dispatcher.BeginInvoke(action); break; case 2: - action = () => - { - this.Down_SFC_2.Text = "SFC:" + viewModelDto.rfidInfo.sfc; - }; - Down_SFC_2.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_RFID_2.Text = "RFID:"+viewModelDto.rfidInfo.rfid; - }; - Down_RFID_2.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_EA_2.Text = "EA:"+viewModelDto.rfidInfo.ea; - }; - Down_EA_2.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_SFC_2.Text = "SFC:" + viewModelDto.rfidInfo.sfc; + //}; + //Down_SFC_2.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_RFID_2.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + //}; + //Down_RFID_2.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_EA_2.Text = "EA:"+viewModelDto.rfidInfo.ea; + //}; + //Down_EA_2.Dispatcher.BeginInvoke(action); break; case 5: - action = () => - { - this.Down_SFC_3.Text = "SFC:"+viewModelDto.rfidInfo.sfc; - }; - Down_SFC_3.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_RFID_3.Text = "RFID:"+viewModelDto.rfidInfo.rfid; - }; - Down_RFID_3.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_EA_3.Text = "EA:"+viewModelDto.rfidInfo.ea; - }; - Down_EA_3.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_SFC_3.Text = "SFC:"+viewModelDto.rfidInfo.sfc; + //}; + //Down_SFC_3.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_RFID_3.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + //}; + //Down_RFID_3.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_EA_3.Text = "EA:"+viewModelDto.rfidInfo.ea; + //}; + //Down_EA_3.Dispatcher.BeginInvoke(action); break; case 6: - action = () => - { - this.Down_SFC_4.Text = "SFC:"+viewModelDto.rfidInfo.sfc; - }; - Down_SFC_4.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_RFID_4.Text = "RFID:"+viewModelDto.rfidInfo.rfid; - }; - Down_RFID_4.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_EA_4.Text = "EA:"+viewModelDto.rfidInfo.ea; - }; - Down_EA_4.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_SFC_4.Text = "SFC:"+viewModelDto.rfidInfo.sfc; + //}; + //Down_SFC_4.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_RFID_4.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + //}; + //Down_RFID_4.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_EA_4.Text = "EA:"+viewModelDto.rfidInfo.ea; + //}; + //Down_EA_4.Dispatcher.BeginInvoke(action); break; case 4: - action = () => - { - this.Down_SFC_5.Text = "SFC:"+viewModelDto.rfidInfo.sfc; - }; - Down_SFC_5.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_RFID_5.Text = "RFID:"+viewModelDto.rfidInfo.rfid; - }; - Down_RFID_5.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_EA_5.Text = "EA:"+viewModelDto.rfidInfo.ea; - }; - Down_EA_5.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_SFC_5.Text = "SFC:"+viewModelDto.rfidInfo.sfc; + //}; + //Down_SFC_5.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_RFID_5.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + //}; + //Down_RFID_5.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_EA_5.Text = "EA:"+viewModelDto.rfidInfo.ea; + //}; + //Down_EA_5.Dispatcher.BeginInvoke(action); break; case 3: - action = () => - { - this.Down_SFC_6.Text = "SFC:"+viewModelDto.rfidInfo.sfc; - }; - Down_SFC_6.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_RFID_6.Text = "RFID:"+viewModelDto.rfidInfo.rfid; - }; - Down_RFID_6.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_EA_6.Text = "EA:"+viewModelDto.rfidInfo.ea; - }; - Down_EA_6.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_SFC_6.Text = "SFC:"+viewModelDto.rfidInfo.sfc; + //}; + //Down_SFC_6.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_RFID_6.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + //}; + //Down_RFID_6.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_EA_6.Text = "EA:"+viewModelDto.rfidInfo.ea; + //}; + //Down_EA_6.Dispatcher.BeginInvoke(action); break; case 8: - action = () => - { - this.Down_SFC_7.Text = "SFC:"+viewModelDto.rfidInfo.sfc; - }; - Down_SFC_7.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_RFID_7.Text = "RFID:"+viewModelDto.rfidInfo.rfid; - }; - Down_RFID_7.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_EA_7.Text = "EA:"+viewModelDto.rfidInfo.ea; - }; - Down_EA_7.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_SFC_7.Text = "SFC:"+viewModelDto.rfidInfo.sfc; + //}; + //Down_SFC_7.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_RFID_7.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + //}; + //Down_RFID_7.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_EA_7.Text = "EA:"+viewModelDto.rfidInfo.ea; + //}; + //Down_EA_7.Dispatcher.BeginInvoke(action); break; case 7: - action = () => - { - this.Down_SFC_8.Text = "SFC:"+viewModelDto.rfidInfo.sfc; - }; - Down_SFC_8.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_RFID_8.Text = "RFID:"+viewModelDto.rfidInfo.rfid; - }; - Down_RFID_8.Dispatcher.BeginInvoke(action); - action = () => - { - this.Down_EA_8.Text = "EA:"+viewModelDto.rfidInfo.ea; - }; - Down_EA_8.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_SFC_8.Text = "SFC:"+viewModelDto.rfidInfo.sfc; + //}; + //Down_SFC_8.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_RFID_8.Text = "RFID:"+viewModelDto.rfidInfo.rfid; + //}; + //Down_RFID_8.Dispatcher.BeginInvoke(action); + //action = () => + //{ + // this.Down_EA_8.Text = "EA:"+viewModelDto.rfidInfo.ea; + //}; + //Down_EA_8.Dispatcher.BeginInvoke(action); break; default: break; @@ -404,8 +404,8 @@ namespace MaterialTraceabilityUI logInfoServices.Add(new RecordLogInfo() { id = System.Guid.NewGuid().ToString("N"), - processId = "LY_A", - machineId = ConfigurationManager.AppSettings["machineId"].ToString(), + processId = appConfig.processId, + machineId = appConfig.machineId.ToString(), alarmType = logTypeStr, alarmInfo = info, isAlarm = isAlarm, @@ -565,8 +565,8 @@ namespace MaterialTraceabilityUI /// private void down_5_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { - //WriteInfo write = new WriteInfo(appConfig.processId, 4); - //write.ShowDialog(); + WriteInfo write = new WriteInfo(appConfig.processId, 1); + write.ShowDialog(); } ///