You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
245 lines
9.2 KiB
C#
245 lines
9.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using CentralControl.BaseData;
|
|
using System.Threading;
|
|
using CommonFunc;
|
|
using System.Security.Policy;
|
|
|
|
namespace CentralControl.App_Code
|
|
{
|
|
public static class StaticData
|
|
{
|
|
|
|
public static bool plcConnectionState = false;
|
|
public static bool plcConnectionState2 = false;
|
|
public static string Last_scanMaterial { get; set; }
|
|
|
|
/// <summary>
|
|
/// 运行状态 0,正常模式 ,1 无人模式,2 清库模式
|
|
/// </summary>
|
|
public static int RuningModel { get; set; }
|
|
|
|
/// <summary>
|
|
/// 数据库数据 基础数据 列表
|
|
/// </summary>
|
|
public static PlcHelper plcHelper = null;
|
|
public static PlcHelper plcHelper2 = null;
|
|
|
|
/// <summary>
|
|
/// 1号上件工位是否使用
|
|
/// </summary>
|
|
public static bool IsUsedLine1 = true;
|
|
|
|
public static object OutCarLock = new object();
|
|
|
|
public static bool IsOutCarGo = true;
|
|
|
|
/// <summary>
|
|
/// 上件物料小车锁
|
|
/// </summary>
|
|
public static object CarLock = new object();
|
|
|
|
/// <summary>
|
|
/// 上件物料小车锁
|
|
/// </summary>
|
|
public static object OutLocatorCarLock = new object();
|
|
|
|
/// <summary>
|
|
/// 查找库位锁
|
|
/// </summary>
|
|
public static object FindLocatorLock = new object();
|
|
/// <summary>
|
|
/// 上件物料小车锁
|
|
/// </summary>
|
|
public static object UpMaterialCarLock = new object();
|
|
/// <summary>
|
|
/// 上件物料小车锁
|
|
/// </summary>
|
|
public static object offMaterialCarLock = new object();
|
|
public static List<MaterialBom> MaterialBomList = new List<MaterialBom>();
|
|
public static List<LineCatchArea> LineCatchAreaList = new List<LineCatchArea>();
|
|
public static Dictionary<string, PlcSetting> PlcSettingList = new Dictionary<string, PlcSetting>();
|
|
public static List<LinePreInfo> LinePreInfoList = new List<LinePreInfo>();
|
|
public static List<NodeSetting> NodeSettingList = new List<NodeSetting>();
|
|
public static List<MaterialInfo> MateriaList = new List<MaterialInfo>();
|
|
public static List<Orderplan> OrderPlanList = new List<Orderplan>();
|
|
public static List<CarRealInfo> CarRealList = new List<CarRealInfo>();
|
|
public static List<NodePrecuss> NodeRelation = new List<NodePrecuss>();
|
|
//public static List<Car> CarList = new List<Car>();
|
|
//public static List<CarMaterial> CarMaterialList = new List<CarMaterial>();
|
|
//public static List<AreaInfo> AreaList = new List<AreaInfo>();//库区集合
|
|
//public static List<SiteNode> SiteNodeList = new List<SiteNode>();//站台集合
|
|
//public static
|
|
/// <summary>
|
|
/// 上件区物料队列
|
|
/// </summary>
|
|
public static List<UpLineMaterialList> UpMaterialAreaList = new List<UpLineMaterialList>();
|
|
/// <summary>
|
|
/// 上件区物料队列
|
|
/// </summary>
|
|
public static List<UpLineScanCarList> UpLineCarCanList = new List<UpLineScanCarList>();
|
|
/// <summary>
|
|
/// 下件区物料队列
|
|
/// </summary>
|
|
public static List<OffLineMaterialList> OffMaterialList = new List<OffLineMaterialList>();
|
|
|
|
/// <summary>
|
|
/// 上件线 工件列表
|
|
/// </summary>
|
|
// public static Dictionary<string, List<UpLineMaterialList>> InLineMaterialsDic = new Dictionary<string, List<UpLineMaterialList>>();
|
|
/// <summary>
|
|
/// 上件线 工件列表
|
|
/// </summary>
|
|
public static Dictionary<string, List<UpLineScanCarList>> InLineScanCarDic = new Dictionary<string, List<UpLineScanCarList>>();
|
|
/// <summary>
|
|
/// 上件线 工件列表
|
|
/// </summary>
|
|
public static Dictionary<string, List<OffLineMaterialList>> OffMaterialsDic = new Dictionary<string, List<OffLineMaterialList>>();
|
|
/// <summary>
|
|
/// 小车锁列表
|
|
/// </summary>
|
|
public static Dictionary<string, object> CarLockObjDic = new Dictionary<string, object>();
|
|
|
|
public static Dictionary<string, object> OffLineLockObjDic = new Dictionary<string, object>();
|
|
|
|
|
|
public static PlcSetting getPlcInfoByCode(string plcno)
|
|
{
|
|
if (StaticData.PlcSettingList.ContainsKey(plcno))
|
|
{
|
|
return StaticData.PlcSettingList[plcno];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取 成套 箱体库 ,库位
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static LineCatchArea getCarInputLocator(string lineno, CarRealInfo car)
|
|
{
|
|
LineCatchArea area = null;
|
|
//查找设置的库位物料
|
|
var areas = StaticData.LineCatchAreaList.Where(t => t.AreaType == 4);
|
|
//var areas = StaticData.LineCatchAreaList.Where(t => ((this.LineNo == "1") || (this.LineNo == "2" && t.LineNo == "2")) && t.AreaType == 4);
|
|
|
|
LineCatchArea temparea = null;
|
|
|
|
string[] materilnos = car.LoadingMaterial.Select(t => t.materialNo).ToArray();
|
|
//string[] productss = car.LoadingProduct.Select(t => t.productNo).ToArray();
|
|
//删除相同物料组成 bom的 产品bomid,为了排除,当前物料组成被包含的情况(A:1,2,3 ,B:1,2,3,4)
|
|
|
|
|
|
//检查已经库位是否设定了某种型号的物料, 并且是空库的
|
|
//int locatornum = StaticData.CarRealList.Count(t => productss.Contains(t.MaterialNo) && (t.LocatorId > 0 || t.LocatorNodeId > 0) && t.IsOutLocator == 0);
|
|
//if (locatornum <= 0)
|
|
//{
|
|
// foreach (var areael in areas)
|
|
// {
|
|
// var locatorss = StaticData.CarRealList.Where(t => (t.LocatorId == areael.Id || t.LocatorNodeId == areael.Id) && t.IsOutLocator == 0).ToList();
|
|
// //该库位为空,判断其他库区是否放过该料
|
|
// if (locatorss.Count() == 0)
|
|
// {
|
|
// area = areael;
|
|
// break;
|
|
// }
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
foreach (var areael in areas)
|
|
{
|
|
|
|
//便利所有库位查找未满库区,的物料是否相同
|
|
var locatorss = StaticData.CarRealList.Where(t => (t.LocatorId == areael.Id || t.LocatorNodeId == areael.Id) && t.IsOutLocator == 0).ToList();
|
|
//该库位非空,库区未满
|
|
if (locatorss.Count() > 0 && locatorss.Count() < areael.MaxNumber)
|
|
{
|
|
//获取库位内的第一个小车
|
|
var carlast = locatorss.OrderBy(t => t.OptDt).LastOrDefault();
|
|
//门体数量是否相同
|
|
if (carlast.LoadingMaterial.Count == car.LoadingMaterial.Count)
|
|
{
|
|
int matercount = carlast.LoadingMaterial.Count(t => materilnos.Contains(t.materialNo));
|
|
//查找到包含当前物料,并且数量相同的物料
|
|
if (matercount == materilnos.Length)
|
|
{
|
|
area = areael;
|
|
|
|
return area;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
//如果库区数量为空 ,并且设定物料等于该物料型号,再没有匹配到的情况下使用该库
|
|
if (temparea == null && locatorss.Count() == 0)
|
|
{
|
|
temparea = areael;
|
|
}
|
|
}
|
|
//}
|
|
|
|
if (area == null && temparea != null)
|
|
{
|
|
area = temparea;
|
|
}
|
|
return area;
|
|
}
|
|
|
|
public static Dictionary<string, List<ConveterData>> conveterDic = new Dictionary<string, List<ConveterData>>();
|
|
|
|
public static string getConveterData(string plcno, string label)
|
|
{
|
|
if (conveterDic.ContainsKey(plcno))
|
|
{
|
|
return conveterDic[plcno].Where(t => t.label == label).FirstOrDefault().value;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static string getReverseConveterData(string plcno, string value)
|
|
{
|
|
if (conveterDic.ContainsKey(plcno))
|
|
{
|
|
return conveterDic[plcno].Where(t => t.value == value).FirstOrDefault().label;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void AddConveterData(string plcno, List<ConveterData> data)
|
|
{
|
|
if (conveterDic.ContainsKey(plcno))
|
|
{
|
|
conveterDic[plcno] = data;
|
|
}
|
|
else
|
|
{
|
|
conveterDic.Add(plcno, data);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ConveterData
|
|
{
|
|
public string value { get; set; }
|
|
public string label { get; set; }
|
|
}
|
|
|
|
public class MesData
|
|
{
|
|
public string materialNo { get; set; }
|
|
public string ProdCode { get; set; }
|
|
public string BarCode { get; set; }
|
|
public string ProdDesc { get; set; }
|
|
public string Order { get; set; }
|
|
public string LineNo { get; set; }
|
|
public DateTime receDt { get; set; }
|
|
}
|
|
}
|