| | |
| | | using static Hanhe.iWCS.TaizhouGEMTwoProtocol.ProtocolAnalysis; |
| | | using log4net.Appender; |
| | | using System.Net.Configuration; |
| | | using static System.Runtime.CompilerServices.RuntimeHelpers; |
| | | using System.Reflection.Emit; |
| | | using System.Text.RegularExpressions; |
| | | |
| | | namespace Hanhe.iWCS.TaizhouGEMTwoProtocol |
| | | { |
| | |
| | | |
| | | WriteCacheStackingData(plc, task, machine); |
| | | |
| | | |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = plc.writeAddr + 1, |
| | |
| | | //读取通道1里面参数是否为1,判断叠盘机是否需要上料 |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | dataNum = 2, |
| | | addr = pmInfo.readAddr + 1, |
| | | host = pmInfo.ip, |
| | | port = pmInfo.port |
| | | }); |
| | | CMMLog.Info($"获取碟盘入口信息:{JsonConvert.SerializeObject(result)}"); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | //参数1表示叠托点申请入料 |
| | |
| | | else CMMLog.Debug($"调用WMS获取碟盘出库生成任务失败!"); |
| | | } |
| | | else CMMLog.Debug($"检查当前叠托点是否有任务占用,或者MST主表中有缓存架入叠盘机的任务!"); |
| | | } |
| | | if (pmInfo.deviceType == "23" && result.result[1] == 1) |
| | | { |
| | | //四钴车间,人工上料模式 |
| | | result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 21, |
| | | addr = pmInfo.readAddr + 120, |
| | | host = pmInfo.ip, |
| | | port = pmInfo.port |
| | | }); |
| | | CMMLog.Info($"获取碟盘人工上料写入信息:{JsonConvert.SerializeObject(result)}"); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | string lotNo = RemoveNull(GetTrayCode(result.result.Skip(0).Take(20).ToArray()).Trim().ToString()); //批次号 |
| | | string bagNumber = Convert.ToInt32(Completion(result.result[20]), 2).ToString(); |
| | | var machinInfo = MongoDBSingleton.Instance.FindOne<MachineInfoTwoTetracobalt>(Query.And(Query.EQ("lotNo", lotNo), Query.EQ("packageCode", bagNumber)), "MachineInfoTwoTetracobalt"); |
| | | if(machinInfo != null) |
| | | { |
| | | TN_I_TASK_MST task = new TN_I_TASK_MST |
| | | { |
| | | CN_S_BATCH_NO = machinInfo.trayCode |
| | | }; |
| | | WMSInfo machine = new WMSInfo |
| | | { |
| | | location = machinInfo.location, |
| | | productWeight = machinInfo.productWeight, |
| | | oneTrayWeight = machinInfo.oneTrayWeight, |
| | | addState = machinInfo.addState, |
| | | packageCode = machinInfo.packageCode, |
| | | itemCode = machinInfo.materialCode |
| | | }; |
| | | PLCControl.WriteCacheStackingData(pmInfo, task,machine); |
| | | machinInfo = MongoDBSingleton.Instance.FindOne<MachineInfoTwoTetracobalt>(Query.And(Query.EQ("lotNo", lotNo), Query.EQ("packageCode", bagNumber)), "MachineInfoTwoTetracobalt"); |
| | | if(machinInfo == null) |
| | | { |
| | | //信息写入成功 |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = pmInfo.writeAddr + 2, |
| | | host = pmInfo.ip, |
| | | port = pmInfo.port, |
| | | data = 1 |
| | | }); |
| | | CMMLog.Info("人工叠包信息查询成功,写入1"); |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = pmInfo.writeAddr + 2, |
| | | host = pmInfo.ip, |
| | | port = pmInfo.port, |
| | | data = 2 |
| | | }); |
| | | CMMLog.Info("人工叠包信息查询失败,写入2"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else CMMLog.Debug($"缓存入叠盘机,创建任务,result={result.errMsg}"); |
| | |
| | | num[8] = int.Parse(AsciiToTen(machine.location));//包装机号 |
| | | for (int b = 9; b <= 10; b++) |
| | | { |
| | | int k = b % 2 == 0 ? 0 : 16; |
| | | int k = b % 2 == 0 ? 16 : 0; |
| | | num[b] = Convert.ToInt32(Convert.ToString(int.Parse(machine.productWeight), 2).PadLeft(32, '0').ToString().Substring(k, 16), 2); |
| | | } |
| | | for (int b = 11; b <= 12; b++) |
| | | { |
| | | int k = b % 2 == 0 ? 0 : 16; |
| | | int k = b % 2 == 0 ? 16 : 0; |
| | | num[b] = Convert.ToInt32(Convert.ToString(int.Parse(machineInfoTwo.trayCodeWeight), 2).PadLeft(32, '0').ToString().Substring(k, 16), 2); |
| | | } |
| | | for (int b = 13; b <= 14; b++) |
| | | { |
| | | int k = b % 2 == 0 ? 0 : 16; |
| | | int k = b % 2 == 0 ? 16 : 0; |
| | | num[b] = Convert.ToInt32(Convert.ToString(int.Parse(machine.oneTrayWeight), 2).PadLeft(32, '0').ToString().Substring(k, 16), 2); |
| | | } |
| | | for (int b = 15; b <= 16; b++) |
| | |
| | | for (int x = maxLength + 1; x <= 54; x++) num[x] = 0;//将产品批次号无数据的通道全部置为 0 |
| | | #endregion |
| | | |
| | | #region 55~64 => 61~70 产品型号 |
| | | #region 55~64 => 61~70 产品型号(四钴产品型号有中文和英文) |
| | | |
| | | ERPService.HandleItemInfoChina(machine.itemCode, 55, 64, num);// 中文处理 55~64 61~70 |
| | | if (Regex.IsMatch(ErpItemInfo.item_spec, @"[\u4e00-\u9fff]")) |
| | | { |
| | | ERPService.HandleItemInfoChina(ErpItemInfo.item_spec, 55, 64, num);// 中文处理 55~64 61~70 |
| | | } |
| | | else |
| | | { |
| | | ERPService.HandleItemInfo(ErpItemInfo.item_spec, 55, 64, num); |
| | | } |
| | | |
| | | |
| | | //string data2 = machine.itemCode; |
| | | //CMMLog.Info($"51~50data2_1:{data2}"); |
| | |
| | | if (result != null && result.errCode == 0 && result.result.Count() > 0) |
| | | { |
| | | //1:取料 |
| | | if (result.result[0] == 1) |
| | | if (result.result[0] == 1 || result.result[0] == 5) |
| | | { |
| | | string PlcBit02 = Settings.GetPlcInfo().Where(a => a.deviceType == "22").FirstOrDefault().location; |
| | | //包装下线任务,终点为复称位置(这里判断包装机起点,复称起点终点均无任务,则推送任务) |
| | |
| | | port = pmInfo.port, |
| | | data = 4 |
| | | }); |
| | | |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:ip:{pmInfo.ip},port:{pmInfo.port},addr:{pmInfo.writeAddr},写入4"); |
| | | //string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); |
| | | //tray.trayCode = "VW" + timeStamp; |
| | | //MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("_id", tray._id), Update.Set("trayCode", tray.trayCode), UpdateFlags.None); |
| | |
| | | } |
| | | else if (tray.trayCode != "0" && !string.IsNullOrEmpty(tray.trayCode)) |
| | | { |
| | | HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3楼包装取料(四钴)", 0, tray.trayCode, timeStamp); |
| | | if (req.success) |
| | | if (result.result[0] == 1) |
| | | { |
| | | string weight = (double.Parse(tray.oneTrayWeight) / 100).ToString(); |
| | | ERPService.packageInfo(tray.machineNo, tray.trayCode, tray.lotNo, weight); |
| | | |
| | | //记录托盘类型 |
| | | var trayTypeInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", pmInfo.location), "trayTypeTable"); |
| | | if(trayTypeInfo == null) |
| | | HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3楼包装取料(四钴)", 0, tray.trayCode, timeStamp); |
| | | if (req.success) |
| | | { |
| | | MongoDBSingleton.Instance.Insert<trayTypeTable>(new trayTypeTable |
| | | string weight = (double.Parse(tray.oneTrayWeight) / 100).ToString(); |
| | | ERPService.packageInfo(tray.machineNo, tray.trayCode, tray.lotNo, weight); |
| | | |
| | | //记录托盘类型 |
| | | var trayTypeInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", pmInfo.location), "trayTypeTable"); |
| | | if (trayTypeInfo == null) |
| | | { |
| | | locCode = pmInfo.location, |
| | | trayType = tray.trayType |
| | | }); |
| | | MongoDBSingleton.Instance.Insert<trayTypeTable>(new trayTypeTable |
| | | { |
| | | locCode = pmInfo.location, |
| | | trayType = tray.trayType |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //var writeRes0 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | //{ |
| | | // host = pmInfo.ip, |
| | | // addr = pmInfo.writeAddr, |
| | | // data = 5,//原先是1,单个写入 |
| | | // port = pmInfo.port |
| | | //}); |
| | | |
| | | //人工模式,无需生成任务 |
| | | //删除MachineInfoTetracobalt表中的数据 |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.And(Query.EQ("machineNo", pmInfo.location), Query.EQ("trayCode", tray.trayCode)), "MachineInfoTetracobalt", RemoveFlags.None); |
| | | |
| | | //删除 MachineInfoTwoTetracobalt 重复的数据 |
| | | var twoInfo = MongoDBSingleton.Instance.Find<MachineInfoTwoTetracobalt>(Query.And(Query.EQ("lotNo", tray.lotNo), Query.EQ("packageCode",tray.packageCode)), "MachineInfoTwoTetracobalt"); |
| | | if(twoInfo.Count > 1) |
| | | { |
| | | foreach(var a in twoInfo) |
| | | { |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTwoTetracobalt>(Query.EQ("_id", a._id),RemoveFlags.None); |
| | | if (MongoDBSingleton.Instance.Find<MachineInfoTwoTetracobalt>(Query.And(Query.EQ("lotNo", tray.lotNo), Query.EQ("packageCode", tray.packageCode)), "MachineInfoTwoTetracobalt").Count == 1) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //记录包装间下料信息 |
| | | string Weight = (decimal.Parse(tray.oneTrayWeight) / 100).ToString("F2"); |
| | | MongoDBSingleton.Instance.Insert<packageInfoModel>(new packageInfoModel { machineNo = tray.machineNo, trayCode = tray.trayCode, batchNo = tray.lotNo, time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), weight = Weight }); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | internal static void CheckPackingLineFullThree(Settings.PlcInfo plc) |
| | | { |
| | | string trayCode = ""; |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 25, |
| | | addr = plc.readAddr, |
| | | dataNum = 1, |
| | | addr = plc.readAddr + 1, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Info($"下线口 ip:{plc.ip},port:{plc.port},addr:{plc.writeAddr + 1},reuslt:{JsonConvert.SerializeObject(result)}."); |
| | | if(result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //获取物料信息 根据托盘码区分 |
| | | trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码 |
| | | |
| | | |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("trayCode", trayCode)), "TimeCuoInfoComTwo"); |
| | | if (infoPack != null) |
| | | var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | string empCode = RemoveNull(GetTrayCode(result.result.Skip(1).Take(5).ToArray()));//员工编码 |
| | | string machineCode = RemoveNull(GetTrayCode(result.result.Skip(9).Take(1).ToArray()));//包装机号 |
| | | int needWeight = Convert.ToInt32(Completion(result.result[10]) + Completion(result.result[11]), 2);//产品需求重量 |
| | | int oneWeight = Convert.ToInt32(Completion(result.result[12]) + Completion(result.result[13]), 2);//单托毛重 |
| | | int readWeight = Convert.ToInt32(Completion(result.result[14]) + Completion(result.result[15]), 2);//单托净重 |
| | | int fcWeight = Convert.ToInt32(Completion(result.result[16]) + Completion(result.result[17]), 2);//单托复称重量 |
| | | int trayType = Convert.ToInt32(Completion(result.result[18]), 2);//托盘类型 |
| | | int addState = Convert.ToInt32(Completion(result.result[19]), 2);//叠包层数 |
| | | int bagNumber = Convert.ToInt32(Completion(result.result[20]), 2);//袋号 |
| | | int productTime = Convert.ToInt32(Completion(result.result[21]) + Completion(result.result[22]), 2);//生产日期 |
| | | string timeCuoTwo = Convert.ToInt32(Completion(result.result[23]) + Completion(result.result[24]), 2).ToString(); //时间戳 |
| | | |
| | | UpdateBuilder updateBuilder = Update.Set("employeeId", empCode).Set("trayCode", trayCode).Set("packingMachineNumber", machineCode).Set("needWeight", needWeight) |
| | | .Set("oneWeight", oneWeight).Set("realWeight", readWeight).Set("FCWeight", fcWeight).Set("trayType", trayType) |
| | | .Set("isFold", addState).Set("bagNumber", bagNumber).Set("productData", productTime); |
| | | //产品批次号 产品型号 物料名称 计量单位均可在erp表中根据物料编码获取 |
| | | dataNum = 26, |
| | | addr = plc.readAddr + 8, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Info($"下线口 ip:{plc.ip},port:{plc.port},addr:{plc.writeAddr + 8},reuslt:{JsonConvert.SerializeObject(resultTime)}."); |
| | | if (resultTime.errCode == 0) |
| | | { |
| | | string timeCuoData = (resultTime.result[0] * 65536 + resultTime.result[1]).ToString(); |
| | | string empCode = RemoveNull(GetTrayCode(resultTime.result.Skip(2).Take(5).ToArray()));//员工编码 |
| | | string machineCode = RemoveNull(GetTrayCode(resultTime.result.Skip(10).Take(1).ToArray()));//包装机号 |
| | | int needWeight = Convert.ToInt32(Completion(resultTime.result[11]) + Completion(resultTime.result[12]), 2);//产品需求重量 |
| | | int oneWeight = Convert.ToInt32(Completion(resultTime.result[13]) + Completion(resultTime.result[14]), 2);//单托毛重 |
| | | int readWeight = Convert.ToInt32(Completion(resultTime.result[15]) + Completion(resultTime.result[16]), 2);//单托净重 |
| | | int fcWeight = Convert.ToInt32(Completion(resultTime.result[17]) + Completion(resultTime.result[18]), 2);//单托复称重量 |
| | | int trayType = Convert.ToInt32(Completion(resultTime.result[19]), 2);//托盘类型 |
| | | int addState = Convert.ToInt32(Completion(resultTime.result[20]), 2);//叠包层数 |
| | | int bagNumber = Convert.ToInt32(Completion(resultTime.result[21]), 2);//袋号 |
| | | int productTime = Convert.ToInt32(Completion(resultTime.result[22]) + Completion(resultTime.result[23]), 2);//生产日期 |
| | | |
| | | result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 15, |
| | | addr = plc.readAddr + 131, |
| | | dataNum = 70, |
| | | addr = plc.readAddr + 110, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | |
| | | string materialCode = RemoveNull(GetTrayCode(result.result.Skip(0).Take(15).ToArray()).Trim().ToString()); |
| | | UpdateBuilder update = Update.Set("materialCode", materialCode).Set("createTime",DateTime.Now); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), update, UpdateFlags.None); |
| | | |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | CMMLog.Info($"下线口,ip:{plc.ip},port:{plc.port},addr:{plc.readAddr + 140},result:{JsonConvert.SerializeObject(result)}"); |
| | | string lotNo = RemoveNull(GetTrayCode(result.result.Skip(0).Take(20).ToArray()).Trim().ToString()); |
| | | string materialCode = RemoveNull(GetTrayCode(result.result.Skip(30).Take(15).ToArray()).Trim().ToString()); |
| | | CMMLog.Info($"下线口:timeCuoData:{timeCuoData},empCode:{empCode},machineCode:{machineCode},needWeight:{needWeight},oneWeight:{oneWeight},readWeight:{readWeight}" + |
| | | $",fcWeight:{fcWeight},trayType:{trayType},addState:{addState},bagNumber:{bagNumber},productTime:{productTime},TimeCuo:{timeCuoData}"); |
| | | var timeTwo = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("TimeCuo", timeCuoData), "TimeCuoInfoComTwo"); |
| | | if (timeTwo == null) |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr, |
| | | data = 1, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为1."); |
| | | } |
| | | } |
| | | } |
| | | |
| | | var xxPlc = Settings.GetPlcInfo().Where(a => a.deviceType == "27" && a.enable == 1).FirstOrDefault(); |
| | | if(xxPlc != null) |
| | | { |
| | | result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr + 1, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if(result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 2, |
| | | addr = plc.readAddr + 8, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if (resultTime.errCode == 0) |
| | | { |
| | | string timeCuoData = (resultTime.result[0] * 65536 + resultTime.result[1]).ToString(); |
| | | TimeCuoInfoComTwo time = null; |
| | | var timeTwo = MongoDBSingleton.Instance.Find<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), "TimeCuoInfoComTwo"); |
| | | if(timeTwo.Count > 0) |
| | | MongoDBSingleton.Instance.Insert<TimeCuoInfoComTwo>(new TimeCuoInfoComTwo |
| | | { |
| | | time = timeTwo.OrderBy(a => a.createTime).FirstOrDefault(); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("_id", time._id),Update.Set("TimeCuo", timeCuoData)); |
| | | } |
| | | string wmstaskno = ""; |
| | | WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeCuoData, timeCuoData, time.employeeId, true); |
| | | timeCuo = timeCuoData, |
| | | employeeId = empCode, |
| | | packingMachineNumber = machineCode, |
| | | needWeight = needWeight, |
| | | oneWeight = oneWeight, |
| | | realWeight = readWeight, |
| | | FCWeight = fcWeight, |
| | | trayType = trayType.ToString(), |
| | | isFold = addState, |
| | | bagNumber = bagNumber, |
| | | productData = productTime.ToString(), |
| | | TimeCuo = timeCuoData, |
| | | lotNo = lotNo, |
| | | materialCode = materialCode |
| | | }, "TimeCuoInfoComTwo"); |
| | | } |
| | | else |
| | | { |
| | | var query1 = Query.EQ("TimeCuo", timeCuoData); |
| | | UpdateBuilder updateBuilder = Update.Set("employeeId", empCode).Set("packingMachineNumber", machineCode).Set("needWeight", needWeight) |
| | | .Set("oneWeight", oneWeight).Set("realWeight", readWeight).Set("FCWeight", fcWeight).Set("trayType", trayType.ToString()) |
| | | .Set("isFold", addState).Set("bagNumber", bagNumber).Set("productData", productTime.ToString()).Set("TimeCuo", timeCuoData) |
| | | .Set("materialCode", materialCode); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(query1, updateBuilder, "TimeCuoInfoComTwo", UpdateFlags.None); |
| | | } |
| | | string wmstaskno = ""; |
| | | WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeCuoData, timeCuoData, empCode, true); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CMMLog.Info("下线口设备未配置"); |
| | | } |
| | | |
| | | |
| | | //string trayCode = ""; |
| | | //var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | //{ |
| | | // dataNum = 25, |
| | | // addr = plc.readAddr, |
| | | // host = plc.ip, |
| | | // port = plc.port |
| | | //}); |
| | | //CMMLog.Info($"贴标机获取信息,ip:{plc.ip},port:{plc.port},addr:{plc.readAddr},result:{JsonConvert.SerializeObject(result)}"); |
| | | //if(result != null && result.errCode == 0) |
| | | //{ |
| | | // if (result.result[0] == 1) |
| | | // { |
| | | // //获取物料信息 根据托盘码区分 |
| | | // trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码 |
| | | // |
| | | // if (!string.IsNullOrEmpty(trayCode)) |
| | | // { |
| | | // var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("trayCode", trayCode)), "TimeCuoInfoComTwo"); |
| | | // if (infoPack == null) |
| | | // { |
| | | // string empCode = RemoveNull(GetTrayCode(result.result.Skip(1).Take(5).ToArray()));//员工编码 |
| | | // string machineCode = RemoveNull(GetTrayCode(result.result.Skip(9).Take(1).ToArray()));//包装机号 |
| | | // int needWeight = Convert.ToInt32(Completion(result.result[10]) + Completion(result.result[11]), 2);//产品需求重量 |
| | | // int oneWeight = Convert.ToInt32(Completion(result.result[12]) + Completion(result.result[13]), 2);//单托毛重 |
| | | // int readWeight = Convert.ToInt32(Completion(result.result[14]) + Completion(result.result[15]), 2);//单托净重 |
| | | // int fcWeight = Convert.ToInt32(Completion(result.result[16]) + Completion(result.result[17]), 2);//单托复称重量 |
| | | // int trayType = Convert.ToInt32(Completion(result.result[18]), 2);//托盘类型 |
| | | // int addState = Convert.ToInt32(Completion(result.result[19]), 2);//叠包层数 |
| | | // int bagNumber = Convert.ToInt32(Completion(result.result[20]), 2);//袋号 |
| | | // int productTime = Convert.ToInt32(Completion(result.result[21]) + Completion(result.result[22]), 2);//生产日期 |
| | | // string timeCuoTwo = Convert.ToInt32(Completion(result.result[23]) + Completion(result.result[24]), 2).ToString(); //时间戳 |
| | | // |
| | | // UpdateBuilder updateBuilder = Update.Set("employeeId", empCode).Set("trayCode", trayCode).Set("packingMachineNumber", machineCode).Set("needWeight", needWeight) |
| | | // .Set("oneWeight", oneWeight).Set("realWeight", readWeight).Set("FCWeight", fcWeight).Set("trayType", trayType) |
| | | // .Set("isFold", addState).Set("bagNumber", bagNumber).Set("productData", productTime); |
| | | // //产品批次号 产品型号 物料名称 计量单位均可在erp表中根据物料编码获取 |
| | | // |
| | | // result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | // { |
| | | // dataNum = 15, |
| | | // addr = plc.readAddr + 131, |
| | | // host = plc.ip, |
| | | // port = plc.port |
| | | // }); |
| | | // CMMLog.Info($"贴标机,ip:{plc.ip},port:{plc.port},addr:{plc.readAddr + 131},result:{JsonConvert.SerializeObject(result)}"); |
| | | // string materialCode = RemoveNull(GetTrayCode(result.result.Skip(0).Take(15).ToArray()).Trim().ToString()); |
| | | // UpdateBuilder update = Update.Set("materialCode", materialCode).Set("createTime", DateTime.Now); |
| | | // MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), update, UpdateFlags.None); |
| | | // |
| | | // var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | // { |
| | | // host = plc.ip, |
| | | // addr = plc.writeAddr, |
| | | // data = 1, |
| | | // port = plc.port |
| | | // }); |
| | | // CMMLog.Debug($"贴标机,写入 ip:{plc.ip},port:{plc.port},addr:{plc.writeAddr}的数据为1."); |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | // |
| | | //var xxPlc = Settings.GetPlcInfo().Where(a => a.deviceType == "27" && a.enable == 1).FirstOrDefault(); |
| | | //if(xxPlc != null) |
| | | //{ |
| | | // if (CheckStartFree(plc.location)) |
| | | // { |
| | | // result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | // { |
| | | // dataNum = 1, |
| | | // addr = plc.readAddr + 1, |
| | | // host = plc.ip, |
| | | // port = plc.port |
| | | // }); |
| | | // |
| | | // CMMLog.Debug($"下线口 ip:{plc.ip},port:{plc.port},addr:{plc.writeAddr + 1},reuslt:{JsonConvert.SerializeObject(result)}."); |
| | | // if (result != null && result.errCode == 0) |
| | | // { |
| | | // if (result.result[0] == 1) |
| | | // { |
| | | // var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | // { |
| | | // dataNum = 2, |
| | | // addr = plc.readAddr + 8, |
| | | // host = plc.ip, |
| | | // port = plc.port |
| | | // }); |
| | | // CMMLog.Debug($"下线口 ip:{plc.ip},port:{plc.port},addr:{plc.writeAddr + 8},reuslt:{JsonConvert.SerializeObject(result)}."); |
| | | // if (resultTime.errCode == 0) |
| | | // { |
| | | // string timeCuoData = (resultTime.result[0] * 65536 + resultTime.result[1]).ToString(); |
| | | // TimeCuoInfoComTwo time = null; |
| | | // var timeTwo = MongoDBSingleton.Instance.Find<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), "TimeCuoInfoComTwo"); |
| | | // if (timeTwo.Count > 0) |
| | | // { |
| | | // time = timeTwo.OrderBy(a => a.createTime).FirstOrDefault(); |
| | | // MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("_id", time._id), Update.Set("TimeCuo", timeCuoData)); |
| | | // } |
| | | // string wmstaskno = ""; |
| | | // WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeCuoData, timeCuoData, time.employeeId, true); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // CMMLog.Info("下线口设备未配置"); |
| | | //} |
| | | |
| | | } |
| | | #endregion |