| | |
| | | /// <param name="actionCode"></param> |
| | | public static void SetStatus(string taskNo, int orderNo, string actionCode, string forkliftNo, bool success = false) { |
| | | HardwareAccessObject AMSHao = HardwareAccessHelper.Instance.GetEquipmentsHAO(Constants.WMS_DEVICE_TYPE_AMS); |
| | | if (AMSHao != null) { |
| | | if (AMSHao != null) |
| | | { |
| | | // if (actionCode == "2") |
| | | // { |
| | | //actionCode = "完成"; |
| | |
| | | { |
| | | list.ForEach(a => |
| | | { |
| | | if(a.deviceType == "1") |
| | | { |
| | | PLCControl.PickUpBlank(a); |
| | | } |
| | | else |
| | | { |
| | | PLCControl.PickUpBlankTwo(a); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |
| | |
| | | { |
| | | lock (lock10015) |
| | | { |
| | | //ERPService.insertMidTable(); |
| | | ERPService.insertMidTable(); |
| | | } |
| | | } |
| | | #endregion |
| | |
| | | public string FStaffNumber { get; set; } |
| | | } |
| | | |
| | | public class trayTypeTable |
| | | { |
| | | |
| | | public ObjectId _id { get; set; } |
| | | /// <summary> |
| | | /// 货位编码 |
| | | /// </summary> |
| | | public string locCode { get; set; } |
| | | /// <summary> |
| | | /// 托盘类型 |
| | | /// </summary> |
| | | public string trayType { get; set; } |
| | | } |
| | | |
| | | public class STOCK_LOCATION_Two |
| | | { |
| | | public ObjectId _id { get; set; } |
| | | public string CN_S_LOCATION_CODE { get; set; } |
| | | public int CN_N_AGV_LOCATION { get; set; } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | var result = false; |
| | | try |
| | | { |
| | | string taskState = state == 3 ? "开始取货" : state == 4 ? "取货完成" : state == 5 ? "开始卸货" : state == 6 ? "卸货完成" : ""; |
| | | string taskState = state == 3 ? "开始取货" : state == 4 ? "取货完成" : state == 5 ? "开始卸货" : state == 6 ? "卸货完成" : state == 2 ? "完成" : ""; |
| | | CMMLog.Info($"SQLServer 更新任务状态:任务号:{taskNo},更改状态:{taskState}"); |
| | | if (!string.IsNullOrEmpty(taskState)) result = new SqlHelper<SQL_TN_I_TASK_MST>().ExecuteSql($"update dbo.tn_am_task_mst set CN_S_STATUS='{taskState}' where CN_S_TASK_NO='{taskNo}'"); |
| | | } |
| | |
| | | CMMLog.Debug($"改AGV参数:10,4"); |
| | | //判断任务起点,找到起点包装机设备号,在中间表MachineInfo中查找上一台设备(包装机)的数据,通过modbus通道传入(数据需要转换,ASCII转16short,可能还需要数据拆分) |
| | | var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); |
| | | if (plc.deviceType == "21") |
| | | if (plc.deviceType == "22") |
| | | { |
| | | //四钴车间 |
| | | var machine = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), "MachineInfo"); |
| | | var machine = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), "MachineInfoTetracobalt"); |
| | | if (machine != null) |
| | | { |
| | | CMMLog.Debug("进入machine判断"); |
| | |
| | | }); |
| | | if (result.result.Length > 0) |
| | | { |
| | | if(plc.deviceType == "22") |
| | | { |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("trayCode", model.ext2), Update.Set("secondNg", result.result[2]), UpdateFlags.None); |
| | | } |
| | | else |
| | | { |
| | | MongoDBSingleton.Instance.Update<MachineInfo>(Query.EQ("trayCode", model.ext2), Update.Set("secondNg", result.result[2]), UpdateFlags.None); |
| | | } |
| | | |
| | | //获取从复称平台读出的 时间戳,并转换处理为 string 字符串 |
| | | //string timeStamp = Convert.ToInt32(Completion(result.result[26]) + Completion(result.result[27]), 2).ToString(); |
| | | string timeStamp = Convert.ToInt32(Completion(result.result[25]) + Completion(result.result[26]), 2).ToString(); |
| | |
| | | if (result.result[0] == 3 && result.result[2] == 1) |
| | | { |
| | | CMMLog.Info($"SecondWeightActionOne:准备生成复称入缓存架任务,开始确定托盘号:{model.ext2}"); |
| | | if(plc.deviceType == "22") |
| | | { |
| | | req = WMSHelper.WMSInTwo(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | else |
| | | { |
| | | req = WMSHelper.WMSIn(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | |
| | | ERPService.updatePackageInfo(model.machince, model.ext2, result.result); |
| | | //if (req) TSHelper.GoToAGV(cN_S_TASK_NO, 10, 6); |
| | | //else CMMLog.Debug($"WMS返回{req}"); |
| | |
| | | { |
| | | //复称平台复称货物NG——进入NG复称流程 调用WMS接口分配货架库位 |
| | | //TSHelper.GoToAGV(cN_S_TASK_NO, 10, 6); |
| | | if(plc.deviceType == "22") |
| | | { |
| | | req = WMSHelper.WMSInTwo(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | else |
| | | { |
| | | req = WMSHelper.WMSIn(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | |
| | | if (req) CMMLog.Info($"SecondWeightActionOne:复称入缓存架NG流程:WMS生成任务成功!"); |
| | | else CMMLog.Info($"SecondWeightActionOne:复称入缓存架NG流程:WMS生成任务失败!"); |
| | | var plcInfo = Settings.GetPlcInfo().Where(a => a.location == model.ext3).FirstOrDefault(); |
| | |
| | | CMMLog.Debug($"三楼双层缓存架卸货交互:trayCode:{trayCodeTask.CN_S_BATCH_NO}"); |
| | | if (plc.deviceType =="22") |
| | | { |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("trayCode", trayCodeTask.CN_S_BATCH_NO), "MachineInfo", RemoveFlags.Single); |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("trayCode", trayCodeTask.CN_S_BATCH_NO), "MachineInfoTetracobalt", RemoveFlags.Single); |
| | | if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("trayCode", trayCodeTask.CN_S_BATCH_NO), "MachineInfoTetracobalt", RemoveFlags.Single); |
| | | } |
| | | else |
| | |
| | | |
| | | public static void WriteCacheStackingData(Settings.PlcInfo plc, TN_I_TASK_MST task, WMSInfo machine) |
| | | { |
| | | if (plc.deviceType == "23") |
| | | if (plc.deviceType == "22") |
| | | { |
| | | //四钴车间 |
| | | var machineTwo = MongoDBSingleton.Instance.FindOne<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwo"); |
| | | var machineTwo = MongoDBSingleton.Instance.FindOne<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwoTetracobalt"); |
| | | CMMLog.Info($"3楼缓存架入叠托:收到信号4,查询MachineInfoTwoTetracobalt表信息:{JsonConvert.SerializeObject(machineTwo)}。"); |
| | | if (machineTwo != null) |
| | | { |
| | |
| | | CMMLog.Info($"3楼缓存架入叠托:返回数据:{JsonConvert.SerializeObject(wirteall01)},IPort:{plc.ip},{plc.port}"); |
| | | if (wirteall01.errCode == 0) |
| | | { |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwo", RemoveFlags.Single); |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwoTetracobalt", RemoveFlags.Single); |
| | | } |
| | | } |
| | | } |
| | |
| | | string trayType = ""; |
| | | if(plc.deviceType == "25") trayType = result.result[1] == 1 ? "川字托" : "田字托"; |
| | | bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode,"","",false, trayType); |
| | | if (req) CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务成功!"); |
| | | if (req) |
| | | { |
| | | CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务成功!"); |
| | | if (plc.deviceType == "25") |
| | | { |
| | | //记录托盘类型 |
| | | var trayTypeInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", plc.location), "trayTypeTable"); |
| | | if (trayTypeInfo == null) |
| | | { |
| | | MongoDBSingleton.Instance.Insert<trayTypeTable>(new trayTypeTable |
| | | { |
| | | locCode = plc.location, |
| | | trayType = result.result[1].ToString() |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | else CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务失败!"); |
| | | } |
| | | } |
| | |
| | | { |
| | | CMMLog.Info($"数据处理流程:进入数据处理流程!"); |
| | | |
| | | string empCode = GetTrayCode(result.Take(5).ToArray());//员工编码 |
| | | string empCode = RemoveNull(GetTrayCode(result.Take(5).ToArray()));//员工编码 |
| | | string trayCode = GetTrayCode(result.Skip(5).Take(3).ToArray());//托盘码 |
| | | trayCode = "0"; |
| | | string location = GetTrayCode(result.Skip(8).Take(1).ToArray());//设备货位编码 |
| | | if(trayCode != null && location != null) |
| | | { |
| | |
| | | } |
| | | else CMMLog.Info($"数据处理流程:包装机无MES情况下,模拟MES数据,中间表<MachineInfoTetracobalt>中已有当前包装机号{location}为首的数据"); |
| | | } |
| | | var info = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("machineNo", location), "MachineInfo"); |
| | | var info = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("machineNo", location), "MachineInfoTetracobalt"); |
| | | |
| | | if (info != null) |
| | | { |
| | |
| | | } |
| | | else CMMLog.Info($"数据处理流程:请查询<MachineInfoTetracobalt>表中machineNo字段是否为当前包装机号,并且trayCode是否为0"); |
| | | |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.And(Query.EQ("machineNo", location), Query.EQ("trayCode", "0")), "MachineInfo"); |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.And(Query.EQ("machineNo", location), Query.EQ("trayCode", "0")), "MachineInfoTetracobalt"); |
| | | |
| | | if (infoPack != null) |
| | | { |
| | |
| | | //注意:这里赋值中间表参数请对照信息交互表具体通道值对应 |
| | | UpdateBuilder update = Update.Set("palletLayers", info.secondNg.ToString()).Set("overlappingLayers", info.addState.ToString()).Set("bagNo", info.packageCode). |
| | | Set("lotNo", info.lotNo).Set("productType", info.productType).Set("materialCode", info.materialCode).Set("materialName", info.materialName).Set("measurementUnit", info.measurementUnit); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("machineNo", location), update, "MachineInfo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), update, "MachineInfoTwo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("machineNo", location), update, "MachiMachineInfoTetracobaltneInfo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), update, "MachineInfoTwoTetracobalt", UpdateFlags.None); |
| | | } |
| | | //在中间表中找到刚刚插入的MES数据(目前还没有读取并写入设备数据) |
| | | var query1 = Query.And(Query.EQ("machineNo", location), Query.EQ("trayCode", "0")); |
| | | UpdateBuilder updateBuider = Update.Set("empCode", info.empCode).Set("location", info.location). |
| | | Set("trayCode", info.trayCode).Set("productWeight", info.productWeight). |
| | | Set("trayCodeWeight", info.trayCodeWeight).Set("oneTrayWeight", info.oneTrayWeight). |
| | | Set("trayCodeWeight", info.trayCodeWeight).Set("oneTrayWeight", info.oneTrayWeight).Set("trayType", info.trayType).Set("addState", info.addState). |
| | | Set("addWeight", info.addWeight).Set("packNg", info.packNg).Set("secondNg", info.secondNg).Set("productTime", info.productTime). |
| | | Set("jsonData", json).Set("modify", DateTime.Now); |
| | | MongoDBSingleton.Instance.Update<MachineInfo>(query1, updateBuider, "MachineInfo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), updateBuider, "MachineInfoTwo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(query1, updateBuider, "MachineInfoTetracobalt", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), updateBuider, "MachineInfoTwoTetracobalt", UpdateFlags.None); |
| | | CMMLog.Info($"数据处理流程:更新MachineInfoTetracobalt中间表刚刚插入的MES数据!设备号为:{location},托盘号为:{trayCode}"); |
| | | } |
| | | else |
| | |
| | | Set("trayCodeWeight", info.trayCodeWeight).Set("oneTrayWeight", info.oneTrayWeight). |
| | | Set("addWeight", info.addWeight).Set("packNg", info.packNg).Set("secondNg", info.secondNg).Set("productTime", info.productTime). |
| | | Set("jsonData", json).Set("modify", DateTime.Now); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(query2, updateBuider, "MachineInfo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), updateBuider, "MachineInfoTwo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(query2, updateBuider, "MachineInfoTetracobalt", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), updateBuider, "MachineInfoTwoTetracobalt", UpdateFlags.None); |
| | | CMMLog.Info($"数据处理流程:更新MachineInfoTetracobalt中间表其他设备的数据!设备号为:{location},托盘号为:{trayCode}"); |
| | | } |
| | | else CMMLog.Info($"数据处理流程:无法在MachineInfoTetracobalt中间表中找到当前设备编号的数据!当前设备编号为:{location},托盘码为:{trayCode}"); |
| | |
| | | internal static void CheckPackingMachineTetracobalt(Settings.PlcInfo pmInfo) |
| | | { |
| | | //var count = MongoDBSingleton.Instance.FindOne<>//occupy |
| | | var count = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("occupy", "1"), "MachineInfo"); |
| | | var count = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("occupy", "1"), "MachineInfoTetracobalt"); |
| | | |
| | | //检查包装机通道0是否有下料信号,如果有生成下料任务。线程循环读取,无需设置循环。——通道0参数为1 |
| | | if (count == null) |
| | |
| | | { |
| | | //获取托盘码等信息 读取通道 11、12、13的数据作为托盘码 读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表 |
| | | GetMachineDataTetracobalt(trayCode.result, false); |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo"); |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTetracobalt"); |
| | | if (tray != null) |
| | | { |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:MachineInfoTetracobalt数据插入成功!"); |
| | | bool IsContLaterCode = true; |
| | | if (ERPService.ERPSwitch01 == "1") |
| | | { |
| | | string employeeId = "G" + tray.trayCodeWeight.PadLeft(7, '0'); |
| | | string employeeId = "G" + tray.empCode.PadLeft(7, '0'); |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:员工编码:{employeeId}"); |
| | | // 判断当前【员工编号】通道信息读出来的员工编号是否已经存在于我们的员工信息表-ERPEmployeeTable(查询字段-employee_id) |
| | | var erpEmployeeInfo = MongoDBSingleton.Instance.FindOne<ERPEmployeeTable>(Query.EQ("employee_id", employeeId), "ERPEmployeeTable"); |
| | | if (erpEmployeeInfo == null) IsContLaterCode = false; |
| | | else CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:员工编码查询成功"); |
| | | } |
| | | |
| | | if (IsContLaterCode) |
| | | { |
| | | 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); |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:托盘码:{tray.trayCode}"); |
| | | if (tray.addState == 0) |
| | | { |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfo", RemoveFlags.None); |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTetracobalt", RemoveFlags.None); |
| | | if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTwo", RemoveFlags.None); |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:叠托层数为0,不允许生成任务"); |
| | | } |
| | | else if (tray.trayCode != "0" && !string.IsNullOrEmpty(tray.trayCode)) |
| | | { |
| | | string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); |
| | | HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3楼包装取料(四钴)", 0, tray.trayCode, timeStamp); |
| | | if (req.success) |
| | | { |
| | | string weight = (double.Parse(tray.oneTrayWeight) / 100).ToString(); |
| | | //int weight = int.Parse(tray.oneTrayWeight) / 100; |
| | | ERPService.packageInfo(tray.machineNo, tray.trayCode, tray.lotNo, weight); |
| | | |
| | | //记录托盘类型 |
| | | var trayTypeInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", pmInfo.location), "trayTypeTable"); |
| | | if(trayTypeInfo == null) |
| | | { |
| | | MongoDBSingleton.Instance.Insert<trayTypeTable>(new trayTypeTable |
| | | { |
| | | locCode = pmInfo.location, |
| | | trayType = tray.trayType |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:员工编码查询失败"); |
| | | //检索员工信息失败写入对方通道值1 读取地址+3 |
| | | var wirteall01 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | |
| | | // } |
| | | // else CMMLog.Info($"当前包装机出现故障,无法生成任务。包装机号:{pmInfo.location}"); |
| | | } |
| | | else CMMLog.Debug($"当前machineInfo中间表已存在数据:{JsonConvert.SerializeObject(count)}"); |
| | | else CMMLog.Debug($"当前MachineInfoTetracobalt中间表已存在数据:{JsonConvert.SerializeObject(count)}"); |
| | | } |
| | | |
| | | |
| | |
| | | string TRow = string.IsNullOrEmpty(end.CN_S_FLOOR) ? "1" : end.CN_S_FLOOR; |
| | | CMMLog.Info($"任务推送:货位编码:起点信息:{JsonConvert.SerializeObject(start)},终点信息:{JsonConvert.SerializeObject(end)};任务信息:{JsonConvert.SerializeObject(mst)}"); |
| | | |
| | | var trayInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", mst.CN_S_START_BIT), "trayTypeTable"); |
| | | if (trayInfo != null && trayInfo.trayType == "2") |
| | | { |
| | | start.CN_N_AGV_LOCATION = MongoDBSingleton.Instance.FindOne<STOCK_LOCATION_Two>(Query.EQ("CN_S_LOCATION_CODE", mst.CN_S_START_BIT), "STOCK_LOCATION_Two").CN_N_AGV_LOCATION; |
| | | end.CN_N_AGV_LOCATION = MongoDBSingleton.Instance.FindOne<STOCK_LOCATION_Two>(Query.EQ("CN_S_LOCATION_CODE", mst.CN_S_END_BIT), "STOCK_LOCATION_Two").CN_N_AGV_LOCATION; |
| | | CMMLog.Info($"任务推送:田字托起点终点 站点更改,起点:{start.CN_N_AGV_LOCATION},终点:{end.CN_N_AGV_LOCATION}"); |
| | | } |
| | | |
| | | if (mst.CN_S_BUSS_TYPE == "3楼复称入缓存架") |
| | | { |
| | | CMMLog.Info($"任务推送特殊任务处理-3楼复称入缓存架:任务号:{mst.CN_S_TASK_NO},准备获取 sendBit 配置数据。备注:此任务类型仅获取起点。"); |
| | |
| | | { |
| | | start.CN_N_AGV_LOCATION = agvLoc.Site[emp.Quantity - 1]; |
| | | } |
| | | if(agvLoc.trayType == 2) |
| | | { |
| | | end.CN_N_AGV_LOCATION = MongoDBSingleton.Instance.FindOne<STOCK_LOCATION_Two>(Query.EQ("CN_S_LOCATION_CODE", mst.CN_S_END_BIT), "STOCK_LOCATION_Two").CN_N_AGV_LOCATION; |
| | | } |
| | | } |
| | | } |
| | | try |
| | |
| | | { |
| | | // 因调用AMSAPI无法在开始取货时更新车号,因此此处直接连接AMS数据库进行更新 |
| | | MoboxHelper.UpdateEndBit(mst.CN_S_TASK_NO, action.CN_S_DEVICE_CODE); |
| | | if (action.CN_N_ACTION_CODE != 1 && action.CN_N_ACTION_CODE != 2) MoboxHelper.UpdateTaskState(mst.CN_S_TASK_NO, action.CN_N_ACTION_CODE); |
| | | if (action.CN_N_ACTION_CODE != 1) MoboxHelper.UpdateTaskState(mst.CN_S_TASK_NO, action.CN_N_ACTION_CODE); |
| | | } |
| | | if (action.CN_N_ACTION_CODE == 1) |
| | | { |
| | |
| | | if (mst.CN_S_BUSS_TYPE == "3楼缓存架入叠托") WMSHelper.ExecuteState(mst.CN_S_SOURCE_NO, action.CN_N_ACTION_CODE); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼缓存架入叠托") PLCControl.writeStackingMouth6(mst.CN_S_END_BIT, mst.CN_S_TASK_NO); |
| | | if (mst.CN_S_BUSS_TYPE == "包装线补空") PLCControl.PickUpBlankCompleteTetracobalt(mst.CN_S_END_BIT, mst.CN_S_START_BIT); |
| | | |
| | | //四钴车间根据起点改变货位托盘类型绑定关系 |
| | | var trayInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", mst.CN_S_START_BIT), "trayTypeTable"); |
| | | if(trayInfo != null) |
| | | { |
| | | MongoDBSingleton.Instance.Update<trayTypeTable>(Query.EQ("locCode", mst.CN_S_START_BIT), Update.Set("locCode", mst.CN_S_END_BIT), UpdateFlags.None); |
| | | } |
| | | } |
| | | if (action.CN_N_ACTION_CODE == 6) |
| | | { |
| | | AMSHelper.SetStatus(action.CN_S_TASK_NO, 1, "6", action.CN_S_DEVICE_CODE, true); |
| | | if (mst.CN_S_BUSS_TYPE == "3楼包装补空") |
| | | { |
| | | //将数据记录到中间表 |
| | |
| | | { |
| | | MongoDBSingleton.Instance.Update<SLPTLoc>(Query.EQ("locCode", mst.CN_S_END_BIT), Update.Set("taskNum", slptInfo.taskNum - 1).Set("count", slptInfo.count + 1), UpdateFlags.None); |
| | | } |
| | | |
| | | //四钴成品出库卸货完成,删除货位托盘类型绑定表数据 |
| | | MongoDBSingleton.Instance.Remove<trayTypeTable>(Query.EQ("locCode", mst.CN_S_END_BIT), "trayTypeTable", RemoveFlags.None); |
| | | } |
| | | } |
| | | if (action.CN_N_ACTION_CODE == 2) { |
| | |
| | | |
| | | iCallTask.DeleteTask(mst.CN_S_TASK_NO); |
| | | } |
| | | //if (action.CN_N_ACTION_CODE == 5) |
| | | //{ |
| | | // CMMLog.Info($"3楼缓存架入叠托:收到信号5,开始准备写入叠盘机数据。"); |
| | | //} |
| | | } |
| | | } |
| | | #endregion |
| | |
| | | { |
| | | bool bResult = false; |
| | | //TN_I_TASK_DTL_ACTION GoToAction = WorkFlowAction.GetActionNode(taskNo, orderNo, 0); |
| | | TN_I_TASK_DTL_ACTION GoToAction = WorkFlowAction.GetActionNode(taskNo, 1, 0); |
| | | if (GoToAction != null) { |
| | | HardwareAccessObject GoToAGVHao = HardwareAccessHelper.Instance.GetEquipmentsHAO(GoToAction.CN_S_PROGRAM_CODE); |
| | | //TN_I_TASK_DTL_ACTION GoToAction = WorkFlowAction.GetActionNode(taskNo, 1, 0); |
| | | //if (GoToAction != null) { |
| | | |
| | | //HardwareAccessObject GoToAGVHao = HardwareAccessHelper.Instance.GetEquipmentsHAO(GoToAction.CN_S_PROGRAM_CODE); |
| | | HardwareAccessObject GoToAGVHao = HardwareAccessHelper.Instance.GetEquipmentsHAO("1"); |
| | | if (GoToAGVHao != null) { |
| | | //发送行走指令 到AGV |
| | | CMMLog.Info($"【杭叉AGV】GoToAGVHao:{GoToAGVHao}"); |
| | |
| | | CMMLog.Info($"【杭叉AGV】GoToAGVHao==null!"); |
| | | Console.WriteLine($"【杭叉AGV】GoToAGVHao==null!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CMMLog.Info($"【杭叉AGV】GoToAction==null!"); |
| | | Console.WriteLine($"【杭叉AGV】GoToAction==null!"); |
| | | } |
| | | //} |
| | | //else |
| | | //{ |
| | | // CMMLog.Info($"【杭叉AGV】GoToAction==null!"); |
| | | // Console.WriteLine($"【杭叉AGV】GoToAction==null!"); |
| | | //} |
| | | return bResult; |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="startBit"></param> |
| | | /// <param name="ItemCode"></param> |
| | | /// <param name="taskNo"></param> |
| | | /// <param name="trayCode"></param> |
| | | /// <param name="timeStamp"></param> |
| | | /// <param name="employee_id">员工编码</param> |
| | | /// <returns></returns> |
| | | public static bool WMSInTwo(string startBit, string ItemCode, ref string taskNo, ref string trayCode, string timeStamp = "", string employee_id = "", bool isTwo = false, string trayType = "") |
| | | { |
| | | //XMZ001A11-1 |
| | | //startBit = startBit.Substring(0, 9); |
| | | bool result = false; |
| | | HardwareAccessObject hao = HardwareAccessHelper.Instance.GetEquipmentsHAO(Constants.WMS_DEVICE_TYPE_WMS); |
| | | string msg = ""; |
| | | if (hao != null) |
| | | { |
| | | //http://192.168.1.199:9001/api/wmsapi/InWorkArea |
| | | WMSInModel model = new WMSInModel(); |
| | | model.startBit = startBit; |
| | | model.isTransport = "N"; |
| | | model.needCreateAMSTask = "Y"; |
| | | model.projectCode = "glm"; |
| | | model.trayType = trayType; |
| | | model.data = new List<ItemData>(); |
| | | CMMLog.Info($"WMSInTwo-{startBit}:ItemCode类型为:{ItemCode}"); |
| | | if (!string.IsNullOrEmpty(ItemCode)) |
| | | { |
| | | //var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoCom>(Query.Or(Query.EQ("isNeedTray", 1), Query.EQ("isNeedTray", 2)), "TimeCuoInfoCom"); |
| | | if (ItemCode == "time" || ItemCode == "拆盘变更") |
| | | { |
| | | if (!isTwo) |
| | | { |
| | | int timeInt = int.Parse(trayCode); |
| | | var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoCom>(Query.EQ("timeStamp", timeInt), "TimeCuoInfoCom"); |
| | | CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:timeStamp={timeInt},读出 TimeCuoInfoCom 表数据为:{JsonConvert.SerializeObject(time)}"); |
| | | if (ItemCode == "time" && time != null) |
| | | { |
| | | int TimeStamp = string.IsNullOrEmpty(timeStamp) ? time.timeStamp : int.Parse(timeStamp); |
| | | CMMLog.Info($"WMSIn-{startBit}:time获取时间戳数据为:{TimeStamp}!"); |
| | | model.data.Add(new ItemData() |
| | | { |
| | | //1楼拆盘机调WMS获取入库终点,传输时间戳数据(暂定) |
| | | //isFold = time.isFold, |
| | | //packingMachineNumber = time.packingMachineNumber, |
| | | itemCode = time.productModel, |
| | | lotNo = time.batchNumber, |
| | | machineNo = time.packingMachineNumber.ToString(), |
| | | packageCode = time.bagNumber, |
| | | palletLayers = time.isNeedTray.ToString(), |
| | | foldingbag = time.isFold.ToString(), |
| | | //totalWeight = time.totalWeight, |
| | | timeStamp = TimeStamp, |
| | | photoURL = time.photoURL, |
| | | //productType = time.productModel, |
| | | //bagNumber = time.bagNumber, |
| | | //needWeight = time.needWeight, |
| | | realWeight = time.realWeight, |
| | | //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 |
| | | }); |
| | | |
| | | // 非ERP变更流程可以直接删除 TimeCuoInfoCom 表 |
| | | if (ERPService.ERPSwitch01 == "0") |
| | | { |
| | | CMMLog.Info($"WMSIn-{startBit}:查询条件:timeStamp={timeInt},非ERP变更流程直接删除 TimeCuoInfoCom 表!"); |
| | | MongoDBSingleton.Instance.Remove<TimeCuoInfoCom>(Query.EQ("timeStamp", timeInt), RemoveFlags.Single); |
| | | } |
| | | } |
| | | else if (ItemCode == "拆盘变更") |
| | | { |
| | | model.data.Add(new ItemData() |
| | | { |
| | | //1楼拆盘机调WMS获取入库终点,传输时间戳数据(暂定) |
| | | //isFold = time.isFold, |
| | | //packingMachineNumber = time.packingMachineNumber, |
| | | itemCode = "1", |
| | | lotNo = "1", |
| | | machineNo = "1", |
| | | packageCode = "1", |
| | | palletLayers = "1", |
| | | |
| | | foldingbag = "1", |
| | | //totalWeight = time.totalWeight, |
| | | timeStamp = 1, |
| | | photoURL = "1", |
| | | //productType = time.productModel, |
| | | //bagNumber = time.bagNumber, |
| | | //needWeight = time.needWeight, |
| | | realWeight = 1, |
| | | //batchNumber = time.batchNumber, |
| | | //totalCount = time.totalCount, |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("timeStamp", timeStamp), "TimeCuoInfoCom"); |
| | | CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:timeStamp={timeStamp},读出 TimeCuoInfoComTwo 表数据为:{JsonConvert.SerializeObject(time)}"); |
| | | if (ItemCode == "time" && time != null) |
| | | { |
| | | CMMLog.Info($"WMSIn-{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 |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | var info = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("trayCode", ItemCode), "MachineInfoTetracobalt"); |
| | | // ERP变更新增数据直接从 ERP物料中间表-ERPItemTable 获取(根据物料编码) |
| | | CMMLog.Info($"WMSInTwo-{startBit}:查询条件:trayCode={ItemCode},读出 MachineInfoTetracobalt 表数据为:{JsonConvert.SerializeObject(info)}"); |
| | | if (info != null) |
| | | { |
| | | var erpItemTableInfo = MongoDBSingleton.Instance.FindOne<ERPItemTable>(Query.EQ("item_code", info.materialCode), "ERPItemTable"); |
| | | CMMLog.Info($"WMSInTwo-{startBit}:查询条件:item_code={info.materialCode},读出 ERPItemTable 表数据为:{JsonConvert.SerializeObject(erpItemTableInfo)}"); |
| | | model.locationGear = info.secondNg.ToString(); |
| | | model.trayCode = info.trayCode; |
| | | string product = !string.IsNullOrEmpty(info.productType) ? info.productType : erpItemTableInfo.item_spec; |
| | | model.data.Add(new ItemData() |
| | | { |
| | | itemCode = product, |
| | | lotNo = info.lotNo, |
| | | machineNo = info.machineNo, |
| | | packageCode = info.packageCode, |
| | | palletLayers = info.palletLayers, |
| | | foldingbag = info.overlappingLayers, |
| | | itemState = info.secondNg, |
| | | productWeight = info.productWeight, |
| | | trayCodeWeight = info.trayCodeWeight, |
| | | oneTrayWeight = info.oneTrayWeight, |
| | | //bagNo = info.bagNo, |
| | | //productType = info.productType, |
| | | //materialCode = info.materialCode, |
| | | //location = info.location, |
| | | //addWeight = info.addWeight, |
| | | //packNg = info.packNg, |
| | | //addState = info.addState, |
| | | |
| | | Jm_Item_Code = info.materialCode, |
| | | Jm_Item_Name = erpItemTableInfo.item_name, |
| | | Jm_Item_Model = erpItemTableInfo.item_spec, |
| | | Jm_Item_Unit = erpItemTableInfo.item_uom, |
| | | Jm_Item_Staff = info.trayCodeWeight |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | string msgData = JsonConvert.SerializeObject(model); |
| | | string reqStr = "物料名=" + ItemCode + ";数量"; |
| | | string feedback = ""; |
| | | |
| | | CMMLog.Info($"WMSIn-{startBit}:【调用wms获取入库货位】:发送数据:{JsonConvert.SerializeObject(msgData)},物料条件:ItemCode:{ItemCode},trayCode:{trayCode}"); |
| | | var url = hao.WebUrl + "GlmInSendTask"; |
| | | try |
| | | { |
| | | //hao.WebUrl = "http://192.168.1.199:9001/api/"; |
| | | feedback = helper.WebPost(url, msgData).Replace(@"\", "").Trim(); |
| | | Console.WriteLine(feedback); |
| | | CMMLog.Info($"WMSIn-{startBit}:【调用wms获取入库货位】:接收数据:" + feedback); |
| | | if (!string.IsNullOrEmpty(feedback)) |
| | | { |
| | | //var wmsResponse = JsonConvert.DeserializeObject<WMSResponseModel>(feedback.Substring(1, feedback.Length - 2)); |
| | | var wmsResponse = JsonConvert.DeserializeObject<WMSResponseModel>(feedback); |
| | | //var res = feedback.Replace("{", "").Replace("}", "").Replace(":", "=").Replace(",", ";").Replace('"', ' '); |
| | | if (wmsResponse.Success == true) |
| | | { |
| | | msg = $"WMSIn-{startBit}:【调用wms获取入库货位】成功!返回结果=" + wmsResponse.Success + ";调用WebUrl=" + url + ";输入参数=" + msgData; |
| | | } |
| | | else |
| | | { |
| | | string errMsg = wmsResponse.Code + "-" + wmsResponse.Msg; |
| | | msg = $"WMSIn-{startBit}:【调用wms获取入库货位】失败!错误原因=" + errMsg + ";调用WebUrl=" + url + ";输入参数=" + msgData; |
| | | } |
| | | result = wmsResponse.Success; |
| | | } |
| | | else |
| | | { |
| | | string errMsg = "参数反馈空值"; |
| | | msg = $"WMSIn-{startBit}:【调用wms获取入库货位】失败!错误原因=" + errMsg + ";调用WebUrl=" + url + ";输入参数=" + msgData; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | CMMLog.Error(string.Format($"WMSIn-{startBit}:【调用wms获取入库货位失败】异常{0}", e.Message), e); |
| | | msg = $"WMSIn-{startBit}:【调用wms获取入库货位】失败!解析返回值出错=" + feedback + ";调用WebUrl=" + url + ";输入参数=" + msgData; |
| | | } |
| | | } |
| | | else msg = string.Format($"WMSIn-{startBit}:调用wms失败,ams工作中心没有设置!"); |
| | | CMMLog.Info(msg); |
| | | Console.WriteLine(msg); |
| | | return result; |
| | | } |
| | | |
| | | public static bool WMSOut(string endBit, string ItemCode) { |
| | | //endBit = endBit.Substring(0, 9); |
| | | bool result = false; |
New file |
| | |
| | | { |
| | | "Version": 1, |
| | | "WorkspaceRootPath": "C:\\software\\A-\u5DE5\u4F5C\\\u6E90\u7801\\GIT\\\u6CF0\u5DDE\u683C\u6797\u7F8E\\ams\\Hanhe.iWCS.TaizhouGEMTwoTCP\\", |
| | | "Documents": [], |
| | | "DocumentGroupContainers": [ |
| | | { |
| | | "Orientation": 0, |
| | | "VerticalTabListWidth": 256, |
| | | "DocumentGroups": [ |
| | | { |
| | | "DockedWidth": 200, |
| | | "SelectedChildIndex": -1, |
| | | "Children": [ |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:0:0:{eefa5220-e298-11d0-8f78-00a0c9110057}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:130:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:0:0:{b1e99781-ab81-11d0-b683-00aa00a3ee26}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:129:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}" |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | "DockedWidth": 22, |
| | | "SelectedChildIndex": -1, |
| | | "Children": [ |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:0:0:{d78612c7-9962-4b83-95d9-268046dad23a}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:0:0:{34e76e81-ee4a-11d0-ae2e-00a0c90fffc3}" |
| | | }, |
| | | { |
| | | "$type": "Bookmark", |
| | | "Name": "ST:1:0:{e8034f19-ab72-4f06-83fd-f6832b41aa63}" |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | } |
New file |
| | |
| | | |
| | | Microsoft Visual Studio Solution File, Format Version 12.00 |
| | | # Visual Studio Version 17 |
| | | VisualStudioVersion = 17.12.35707.178 d17.12 |
| | | MinimumVisualStudioVersion = 10.0.40219.1 |
| | | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hanhe.iWCS.TaizhouGEMTwoTCP", "Hanhe.iWCS.TaizhouGEMTwoTCP.csproj", "{4F1FB9D4-758C-4C66-9CA9-6D3EC3DED6C7}" |
| | | EndProject |
| | | Global |
| | | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
| | | Debug|Any CPU = Debug|Any CPU |
| | | Release|Any CPU = Release|Any CPU |
| | | EndGlobalSection |
| | | GlobalSection(ProjectConfigurationPlatforms) = postSolution |
| | | {4F1FB9D4-758C-4C66-9CA9-6D3EC3DED6C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {4F1FB9D4-758C-4C66-9CA9-6D3EC3DED6C7}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {4F1FB9D4-758C-4C66-9CA9-6D3EC3DED6C7}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {4F1FB9D4-758C-4C66-9CA9-6D3EC3DED6C7}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | EndGlobalSection |
| | | GlobalSection(SolutionProperties) = preSolution |
| | | HideSolutionNode = FALSE |
| | | EndGlobalSection |
| | | EndGlobal |