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.
191 lines
6.6 KiB
C#
191 lines
6.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using CentralControl.App_Code;
|
|
using System.Configuration;
|
|
using CentralControl.BaseData;
|
|
using CommonFunc;
|
|
using XGL.Thrift;
|
|
|
|
|
|
namespace CentralControl.App_Code
|
|
{
|
|
public class SystemMain
|
|
{
|
|
|
|
|
|
LogicLineSiteUp line1 = null;
|
|
LogicLineSiteUp line2 = null;
|
|
|
|
object orderPlanLock = new object();
|
|
|
|
|
|
/// <summary>
|
|
/// 系统启动初始化
|
|
/// </summary>
|
|
public void SystemInit()
|
|
{
|
|
|
|
try
|
|
{
|
|
|
|
|
|
//StaticData.LineinfoList = DBService.GetLineInfoList("");
|
|
StaticData.LineCatchAreaList = DBService.GetLineCatchAreaList("");
|
|
StaticData.PlcSettingList = DBService.GetPlcSettingList("");
|
|
StaticData.LinePreInfoList = DBService.GetLinePreInfoList("");
|
|
StaticData.NodeSettingList = DBService.GetNodeSettingList("", StaticData.LineCatchAreaList);
|
|
StaticData.MaterialBomList = DBService.GetMaterialBomList("");
|
|
StaticData.NodeRelation = DBService.getNodeRelation("");
|
|
//绑定 上件队列信息
|
|
StaticData.CarRealList = DBService.getCarInfoList("");
|
|
StaticData.UpLineCarCanList = DBService.getUpLineScanCarLists("");
|
|
StaticData.OffMaterialAreaList = DBService.getOffLineMaterialLists("");
|
|
|
|
//定时任务线程
|
|
Thread taskThread = new Thread(TaskStart);
|
|
taskThread.Start();
|
|
|
|
|
|
//StaticData.plcHelper = new PlcHelper();
|
|
//StaticData.plcHelper.Connection(127.0.0.1);
|
|
|
|
|
|
//根据计划选出产量最多的订单物料 ,按照库位设置的单品顺序排列
|
|
var orderlist = StaticData.OrderPlanList.OrderByDescending(t => t.amount).ToList();
|
|
var signarealist = StaticData.LineCatchAreaList.Where(t => t.AreaStorageType == 1).ToList();
|
|
int number = orderlist.Count > signarealist.Count ? signarealist.Count : signarealist.Count;
|
|
for (int i = 0; i < number; i++)
|
|
{
|
|
var catcharea = StaticData.LineCatchAreaList.Where(t => t.Id == signarealist[i].Id).FirstOrDefault();
|
|
var order = StaticData.OrderPlanList.Where(t => t.id == orderlist[i].id).FirstOrDefault();
|
|
|
|
if (catcharea != null && order != null)
|
|
{
|
|
catcharea.MaterialNo = order.matCode;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 定时任务
|
|
/// </summary>
|
|
private void TaskStart()
|
|
{
|
|
while(true)
|
|
{
|
|
if (DateTime.Now.Minute == 0)
|
|
{
|
|
//初始化订单信息
|
|
getPlanOrderList();
|
|
}
|
|
|
|
Thread.Sleep(60000);
|
|
}
|
|
}
|
|
|
|
private void StartThrift()
|
|
{
|
|
try
|
|
{
|
|
ThriftServiceImp business = new ThriftServiceImp();
|
|
//business.EmergencyAreaOpEvent += EmergencyAreaOp;
|
|
//business.FullAreaOpEvent += FullAreaOp;
|
|
//business.OffAreaOpEvent += OffAreaOp;
|
|
//business.OffAreaOpByNodeIdEvent += OffAreaOpByNodeId;
|
|
|
|
// ThriftCommon thriftCommon = new ThriftCommon();
|
|
// thriftCommon.Start(business);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
// Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新静态集合中的数据
|
|
/// </summary>
|
|
/// <param name="list"></param>
|
|
private void changeOrderPlanData(List<Orderplan> list)
|
|
{
|
|
lock (orderPlanLock)
|
|
{
|
|
//便利更新内存中的时序计划状态以及信息
|
|
foreach (Orderplan nplan in list)
|
|
{
|
|
if (StaticData.OrderPlanList.Count > 0)
|
|
{
|
|
foreach (Orderplan oplan in StaticData.OrderPlanList)
|
|
{
|
|
if (nplan.id == oplan.id)
|
|
{
|
|
|
|
oplan.orderId = nplan.orderId;
|
|
oplan.orderNo = nplan.orderNo;
|
|
oplan.timeOrderNo = nplan.timeOrderNo;
|
|
oplan.productCode = nplan.productCode;
|
|
oplan.productDesc = nplan.productDesc;
|
|
oplan.factoryNo = nplan.factoryNo;
|
|
oplan.matCode = nplan.matCode;
|
|
oplan.matDesc = nplan.matDesc;
|
|
oplan.amount = nplan.amount;
|
|
oplan.line = nplan.line;
|
|
oplan.orderStartDate = nplan.orderStartDate;
|
|
oplan.orderEndDate = nplan.orderEndDate;
|
|
oplan.planType = nplan.planType;
|
|
oplan.PlanOrder = nplan.PlanOrder;
|
|
oplan.planState = nplan.planState;
|
|
oplan.planStartTime = nplan.planStartTime;
|
|
oplan.upAmount = nplan.upAmount;
|
|
oplan.downAount = nplan.downAount;
|
|
}
|
|
else
|
|
{
|
|
StaticData.OrderPlanList.Add(nplan);
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
StaticData.OrderPlanList.Add(nplan);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 定时更新生产计划列表
|
|
/// </summary>
|
|
private void getPlanOrderList()
|
|
{
|
|
while (true)
|
|
{
|
|
// 增加时序计划的 开始结束时间条件
|
|
List<Orderplan> list = DBService.getOrderPlanList("");
|
|
changeOrderPlanData(list);
|
|
|
|
////or
|
|
// StaticData.OrderPlanList = DBService.getOrderPlanList("");
|
|
Thread.Sleep(60000);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|