| | |
| | | { |
| | | if (CheckStartFree(plc.location)) |
| | | { |
| | | //PLCControl.CheckPackingLineFullTwo(plc); |
| | | PLCControl.CheckPackingLineFullThree(plc); |
| | | } |
| | | } |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 打包下线口到成品货架口——直接查询下线口通道内数据(四钴车间) |
| | | /// </summary> |
| | | /// <param name="timeStamp">时间戳</param> |
| | | /// <returns></returns> |
| | | internal static TimeCuoInfoComTwo TimeCuoTwo(int[] result) |
| | | { |
| | | //时间戳 地址读配置文件 |
| | | string FCWeightTotal = GetTrayCode(result.Skip(96).Take(2).ToArray());//总复称重量 |
| | | string timeCuo = GetTrayCode(result.Skip(98).Take(2).ToArray());//时间戳 |
| | | var timeCuoInfo = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("TimeCuo", timeCuo), "TimeCuoInfoComTwo"); |
| | | if(timeCuoInfo == null) |
| | | { |
| | | MongoDBSingleton.Instance.Insert<TimeCuoInfoComTwo>(new TimeCuoInfoComTwo() { TimeCuo = timeCuo,FCWeightTotal = FCWeightTotal }); |
| | | } |
| | | |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("TimeCuo", timeCuo)), "TimeCuoInfoComTwo"); |
| | | if(infoPack != null) |
| | | { |
| | | for (int i = 1; i <= 4; i++) |
| | | { |
| | | string empCode = RemoveNull(GetTrayCode(result.Skip((i - 1) * 24).Take(5).ToArray()));//员工编码 |
| | | string trayCode = RemoveNull(GetTrayCode(result.Skip((i - 1) * 24 + 5).Take(3).ToArray()));//托盘码 |
| | | string machineCode = RemoveNull(GetTrayCode(result.Skip((i - 1) * 24 + 8).Take(1).ToArray()));//包装机号 |
| | | int needWeight = Convert.ToInt32(Completion(result[((i - 1) * 24 + 9)]) + Completion(result[((i - 1) * 24 + 10)]), 2);//产品需求重量 |
| | | int oneWeight = Convert.ToInt32(Completion(result[((i - 1) * 24 + 11)]) + Completion(result[((i - 1) * 24 + 12)]), 2);//单托毛重 |
| | | int readWeight = Convert.ToInt32(Completion(result[((i - 1) * 24 + 13)]) + Completion(result[((i - 1) * 24 + 14)]), 2);//单托净重 |
| | | int fcWeight = Convert.ToInt32(Completion(result[((i - 1) * 24 + 15)]) + Completion(result[((i - 1) * 24 + 16)]), 2);//单托复称重量 |
| | | int trayType = Convert.ToInt32(Completion(result[((i - 1) * 24 + 17)]), 2);//托盘类型 |
| | | int addState = Convert.ToInt32(Completion(result[((i - 1) * 24 + 18)]), 2);//叠包层数 |
| | | int bagNumber = Convert.ToInt32(Completion(result[((i - 1) * 24 + 19)]), 2);//袋号 |
| | | int productTime = Convert.ToInt32(Completion(result[(i - 1) * 24 + 20]) + Completion(result[(i - 1) * 24 + 21]), 2);//生产日期 |
| | | string timeCuoTwo = Convert.ToInt32(Completion(result[(i - 1) * 24 + 22]) + Completion(result[(i - 1) * 24 + 23]), 2).ToString(); //时间戳 |
| | | |
| | | UpdateBuilder updateBuilder = Update.Set("employeeId" + i.ToString(), empCode).Set("trayCode" + i.ToString(), trayCode).Set("packingMachineNumber" + i.ToString(), machineCode).Set("needWeight" + i.ToString(), needWeight) |
| | | .Set("oneWeight" + i.ToString(), oneWeight).Set("realWeight" + i.ToString(), readWeight).Set("FCWeight" + i.ToString(), fcWeight).Set("trayType" + i.ToString(), trayType) |
| | | .Set("isFold" + i.ToString(), addState).Set("bagNumber" + i.ToString(), bagNumber).Set("productData" + i.ToString(), productTime).Set("timeCuo" + i.ToString(), timeCuoTwo); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("TimeCuo", timeCuo), updateBuilder, UpdateFlags.None); |
| | | } |
| | | //产品批次号 产品型号 物料名称 计量单位均可在erp表中根据物料编码获取 |
| | | |
| | | string materialCode = RemoveNull(GetTrayCode(result.Skip(130).Take(15).ToArray()).Trim().ToString()); |
| | | UpdateBuilder update = Update.Set("materialCode", materialCode); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("TimeCuo", timeCuo), update, UpdateFlags.None); |
| | | } |
| | | |
| | | return MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("TimeCuo", timeCuo), "TimeCuoInfoComTwo"); |
| | | } |
| | | |
| | | public static string TransUTF8(string text) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 3楼打包机下线,判断打包机是否由生成打包下线的任务(四钴车间) |
| | | /// </summary> |
| | | /// <param name="plc"></param> |
| | | internal static void CheckPackingLineFullTwo(Settings.PlcInfo plc) |
| | | { |
| | | //读plc信号,看有没有下线请求,判断是否已经有任务 |
| | | //没有任务,继续plc,包装下线的物料信号 |
| | | //检查打包机通道1是否有出料任务信号,如果有生成取料任务。 |
| | | if (CheckStartFree(plc.location)) |
| | | { |
| | | try |
| | | { |
| | | var 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) |
| | | { |
| | | //获取MODBUS通道里面存放的时间戳 |
| | | var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | addr = plc.readAddr + 10, |
| | | host = plc.ip, |
| | | port = plc.port, |
| | | dataNum = 170 |
| | | }); |
| | | if (resultTime.errCode == 0) |
| | | { |
| | | string wmstaskno = ""; |
| | | TimeCuoInfoComTwo timecuo = TimeCuoTwo(resultTime.result); |
| | | if (timecuo != null) |
| | | { |
| | | string timeStamp = timecuo.TimeCuo; |
| | | //string employeeId = timecuo.employeeId1; |
| | | //// ERP变更-调用ERP接口传输相关数据 |
| | | //WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeStamp, timeStamp, employeeId,true); |
| | | } |
| | | else CMMLog.Info($"时间戳接口返回值为空!"); |
| | | } |
| | | else CMMLog.Info($"MODBUS时间戳数据返回值错误:返回值解析:{JsonConvert.SerializeObject(result)}"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 打包机出口MODBUS交互(开始取料,取料完成) |
| | |
| | | /// 设备允许出料 1 PLC写,AMS读 1-设备请求出料;2-允许进入;3-确认货物取走,送出物料; |
| | | |
| | | ///打包线下线——小车开始取货 |
| | | internal static void PackingLineUnload1012(string ip, string taskNo) |
| | | internal static void PackingLineUnload1012(string ip, string taskNo, int port) |
| | | { |
| | | var plc = Settings.GetPlcInfo().Where(a => a.deviceType == "4").FirstOrDefault(); |
| | | var plc = Settings.GetPlcInfo().Where(a => a.ip == ip && a.port == port).FirstOrDefault(); |
| | | if (plc != null) |
| | | { |
| | | try |
| | |
| | | /// </summary> |
| | | /// <param name="ip"></param> |
| | | /// <param name="taskNo"></param> |
| | | internal static void PackingLineComplete4(string ip, string taskNo) |
| | | internal static void PackingLineComplete4(string ip, string taskNo, int port) |
| | | { |
| | | //取货完成后需要读取设备时间戳里面的数据,并将其暂存至中间表等到入库任务完成传输给WMS |
| | | |
| | | var plc = Settings.GetPlcInfo().Where(a => a.deviceType == "4").FirstOrDefault(); |
| | | var plc = Settings.GetPlcInfo().Where(a => a.ip == ip && a.port == port).FirstOrDefault(); |
| | | if (plc != null) |
| | | { |
| | | try |
| | |
| | | |
| | | internal static void CheckPackingLineFullThree(Settings.PlcInfo plc) |
| | | { |
| | | string trayCode = ""; |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 25, |
| | |
| | | if (result.result[0] == 1) |
| | | { |
| | | //获取物料信息 根据托盘码区分 |
| | | string trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码 |
| | | trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码 |
| | | |
| | | |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("trayCode", trayCode)), "TimeCuoInfoComTwo"); |
| | |
| | | }); |
| | | |
| | | string materialCode = RemoveNull(GetTrayCode(result.result.Skip(0).Take(15).ToArray()).Trim().ToString()); |
| | | UpdateBuilder update = Update.Set("materialCode", materialCode); |
| | | 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($"写入设备{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) |
| | | { |
| | | 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 |
| | | } |
| | |
| | | //if (mst.CN_S_BUSS_TYPE == "3楼复称入缓存架") PLCControl.SecondWeightInCache1012(plc.deviceType, mst.CN_S_TASK_NO);//二期:直接改参数 |
| | | if (mst.CN_S_BUSS_TYPE == "3楼缓存架入叠托") TSHelper.GoToAGV(mst.CN_S_TASK_NO, 10, 1); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼叠盘下线") PLCControl.StackingReqUnload(plc.deviceType, mst.CN_S_TASK_NO); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.PackingLineUnload1012(plc.ip, mst.CN_S_TASK_NO); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.PackingLineUnload1012(plc.ip, mst.CN_S_TASK_NO,plc.port); |
| | | if (mst.CN_S_BUSS_TYPE == "四钴辅材入库") PLCControl.productInWare(mst.CN_S_START_BIT, mst.CN_S_TASK_NO, true); |
| | | } |
| | | if (code == 4) |
| | |
| | | if (mst.CN_S_BUSS_TYPE.Contains("3楼包装取料")) PLCControl.PickUpFullDoorComplete(plc.ip, mst.CN_S_TASK_NO); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼复称入缓存架" || mst.CN_S_BUSS_TYPE == "3楼复称入缓存架NG") PLCControl.SecondWeightInCache4(plc.deviceType, mst.CN_S_TASK_NO); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼叠盘下线") PLCControl.StackingComplete(plc.deviceType, mst.CN_S_TASK_NO); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.PackingLineComplete4(plc.ip, mst.CN_S_SOURCE_NO); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.PackingLineComplete4(plc.ip, mst.CN_S_SOURCE_NO,plc.port); |
| | | if (mst.CN_S_BUSS_TYPE != "3楼包装取料") WMSHelper.ExecuteState(mst.CN_S_SOURCE_NO, 4); |
| | | if (mst.CN_S_BUSS_TYPE == "四钴辅材入库") PLCControl.productInWare(mst.CN_S_START_BIT, mst.CN_S_TASK_NO, false); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | //var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("timeStamp", timeStamp), "TimeCuoInfoCom"); |
| | | //CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:timeStamp={timeStamp},读出 TimeCuoInfoComTwo 表数据为:{JsonConvert.SerializeObject(time)}"); |
| | | //var erpItemTableInfo = MongoDBSingleton.Instance.FindOne<ERPItemTable>(Query.EQ("item_code", time.materialCode), "ERPItemTable"); |
| | | //CMMLog.Info($"WMSIn-{startBit}:查询条件:item_code={time.materialCode},读出 ERPItemTable 表数据为:{JsonConvert.SerializeObject(erpItemTableInfo)}"); |
| | | //if (ItemCode == "time" && time != null && erpItemTableInfo != null) |
| | | //{ |
| | | // CMMLog.Info($"WMSIn-{startBit}:time获取时间戳数据为:{time.TimeCuo}!"); |
| | | // model.data.Add(new ItemData() |
| | | // { |
| | | // itemCode = time.productModel, |
| | | // lotNo = time.lotNo, |
| | | // machineNo = time.packingMachineNumber1.ToString(), |
| | | // packageCode = time.bagNumber1.ToString(), |
| | | // foldingbag = time.isFold1.ToString(), |
| | | // timeStamp = int.Parse(time.TimeCuo), |
| | | // realWeight = time.realWeight1, |
| | | // |
| | | // Jm_Item_Code = time.materialCode, |
| | | // Jm_Item_Name = time.materialName, |
| | | // Jm_Item_Model = time.productModel, |
| | | // Jm_Item_Unit = time.measurementUnit, |
| | | // Jm_Item_Staff = employee_id |
| | | // }); |
| | | //} |
| | | var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("timeStamp", timeStamp), "TimeCuoInfoCom"); |
| | | CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:timeStamp={timeStamp},读出 TimeCuoInfoComTwo 表数据为:{JsonConvert.SerializeObject(time)}"); |
| | | var erpItemTableInfo = MongoDBSingleton.Instance.FindOne<ERPItemTable>(Query.EQ("item_code", time.materialCode), "ERPItemTable"); |
| | | CMMLog.Info($"WMSIn-{startBit}:查询条件:item_code={time.materialCode},读出 ERPItemTable 表数据为:{JsonConvert.SerializeObject(erpItemTableInfo)}"); |
| | | if (ItemCode == "time" && time != null && erpItemTableInfo != null) |
| | | { |
| | | CMMLog.Info($"WMSIn-{startBit}:time获取时间戳数据为:{time.TimeCuo}!"); |
| | | model.data.Add(new ItemData() |
| | | { |
| | | itemCode = erpItemTableInfo.item_code, |
| | | lotNo = erpItemTableInfo.item_spec, |
| | | machineNo = time.packingMachineNumber.ToString(), |
| | | packageCode = time.bagNumber.ToString(), |
| | | foldingbag = time.isFold.ToString(), |
| | | timeStamp = int.Parse(time.TimeCuo), |
| | | realWeight = time.realWeight, |
| | | |
| | | Jm_Item_Code = erpItemTableInfo.item_code, |
| | | Jm_Item_Name = erpItemTableInfo.item_name, |
| | | Jm_Item_Model = erpItemTableInfo.item_spec, |
| | | Jm_Item_Unit = erpItemTableInfo.item_uom, |
| | | Jm_Item_Staff = employee_id |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | //totalCount = time.totalCount, |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("timeStamp", timeStamp), "TimeCuoInfoCom"); |
| | | //CMMLog.Info($"WMSInTwo-{startBit}:{ItemCode}:查询条件:timeStamp={timeStamp},读出 TimeCuoInfoComTwo 表数据为:{JsonConvert.SerializeObject(time)}"); |
| | | //if (ItemCode == "time" && time != null) |
| | | //{ |
| | | // CMMLog.Info($"WMSInTwo-{startBit}:time获取时间戳数据为:{time.TimeCuo}!"); |
| | | // model.data.Add(new ItemData() |
| | | // { |
| | | // //1楼拆盘机调WMS获取入库终点,传输时间戳数据(暂定) |
| | | // //isFold = time.isFold, |
| | | // //packingMachineNumber = time.packingMachineNumber, |
| | | // itemCode = time.productModel, |
| | | // lotNo = time.lotNo, |
| | | // machineNo = time.packingMachineNumber1.ToString(), |
| | | // packageCode = time.bagNumber1.ToString(), |
| | | // //palletLayers = time.bagNumber1.ToString(), |
| | | // foldingbag = time.isFold1.ToString(), |
| | | // //totalWeight = time.totalWeight, |
| | | // timeStamp = int.Parse(time.TimeCuo), |
| | | // //productType = time.productModel, |
| | | // //bagNumber = time.bagNumber, |
| | | // //needWeight = time.needWeight, |
| | | // realWeight = time.realWeight1, |
| | | // //batchNumber = time.batchNumber, |
| | | // //totalCount = time.totalCount, |
| | | // |
| | | // Jm_Item_Code = time.materialCode, |
| | | // Jm_Item_Name = time.materialName, |
| | | // Jm_Item_Model = time.productModel, |
| | | // Jm_Item_Unit = time.measurementUnit, |
| | | // Jm_Item_Staff = employee_id |
| | | // }); |
| | | //} |
| | | } |
| | | |
| | | } |