You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
7.0 KiB
170 lines
7.0 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using QMAPP.MD.Entity;
|
||
|
using QMAPP.FJC.Entity.QT;
|
||
|
using QMAPP.FJC.DAL.QT;
|
||
|
|
||
|
namespace QMAPP.FJC.TRACING.DAInterface
|
||
|
{
|
||
|
public class WorkLocState : WorkCell
|
||
|
{
|
||
|
public WorkLocState(WorkCell workcell, string workloccode, Entity.QT.WorkCellRunState state, List<Entity.QT.DAICache> cache)
|
||
|
{
|
||
|
this.CREATEDATE = workcell.CREATEDATE;
|
||
|
this.CREATEUSER = workcell.CREATEUSER;
|
||
|
this.FLAG_BACKFLUSH = workcell.FLAG_BACKFLUSH;
|
||
|
this.PID = workcell.PID;
|
||
|
this.REMARK = workcell.REMARK;
|
||
|
this.UPDATEDATE = workcell.UPDATEDATE;
|
||
|
this.UPDATEUSER = workcell.UPDATEUSER;
|
||
|
this.WORKCELL_CODE = workcell.WORKCELL_CODE;
|
||
|
this.CURRENTPROCESS = workcell.CURRENTPROCESS;
|
||
|
this.WORKCELL_NAME = workcell.WORKCELL_NAME;
|
||
|
this.WORKCENTER_CODE = workcell.WORKCENTER_CODE;
|
||
|
this.WORKLOC_CODE = workloccode;
|
||
|
this.CurrentState = state;
|
||
|
this.DataCache = cache;
|
||
|
}
|
||
|
|
||
|
public WorkLocState(WorkCell workcell, string workloccode)
|
||
|
{
|
||
|
this.CREATEDATE = workcell.CREATEDATE;
|
||
|
this.CREATEUSER = workcell.CREATEUSER;
|
||
|
this.FLAG_BACKFLUSH = workcell.FLAG_BACKFLUSH;
|
||
|
this.PID = workcell.PID;
|
||
|
this.REMARK = workcell.REMARK;
|
||
|
this.UPDATEDATE = workcell.UPDATEDATE;
|
||
|
this.UPDATEUSER = workcell.UPDATEUSER;
|
||
|
this.WORKCELL_CODE = workcell.WORKCELL_CODE;
|
||
|
this.CURRENTPROCESS = workcell.CURRENTPROCESS;
|
||
|
this.WORKCELL_NAME = workcell.WORKCELL_NAME;
|
||
|
this.WORKCENTER_CODE = workcell.WORKCENTER_CODE;
|
||
|
this.WORKLOC_CODE = workloccode;
|
||
|
//this.CurrentState = state;
|
||
|
//this.DataCache = cache;
|
||
|
}
|
||
|
|
||
|
public void LoadState(string mouldcode)
|
||
|
{
|
||
|
this.CurrentState = LoadWorkCellState(this.WORKCELL_CODE, this.WORKLOC_CODE, mouldcode);
|
||
|
this.DataCache = LoadDAICache(this.WORKCELL_CODE, this.WORKLOC_CODE, mouldcode);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 加载工序状态
|
||
|
/// </summary>
|
||
|
/// <param name="workcellcode"></param>
|
||
|
/// <param name="workloccode"></param>
|
||
|
/// <returns></returns>
|
||
|
private WorkCellRunState LoadWorkCellState(string workcellcode, string workloccode, string mouldcode)
|
||
|
{
|
||
|
WorkCellRunStateDAL dal = new WorkCellRunStateDAL();
|
||
|
var state = dal.GetCurrentState(workcellcode, workloccode, mouldcode);
|
||
|
if (state == null) //如果状态信息不存在则创建
|
||
|
{
|
||
|
state = dal.GetNextState(workcellcode, 0);
|
||
|
state.PID = Guid.NewGuid().ToString();
|
||
|
state.UPDATEDATE = DateTime.Now;
|
||
|
state.WORKLOC_CODE = workloccode;
|
||
|
state.WORKCELL_CODE = workcellcode;
|
||
|
state.MODULE_CODE = mouldcode;
|
||
|
dal.Insert(state);
|
||
|
}
|
||
|
return state;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 加载数据采集缓存
|
||
|
/// </summary>
|
||
|
/// <param name="workcellcode">工序编码</param>
|
||
|
/// <param name="workloccode">工位编码</param>
|
||
|
/// <returns></returns>
|
||
|
private List<DAICache> LoadDAICache(string workcellcode, string workloccode, string mouldcode)
|
||
|
{
|
||
|
DAICacheDAL dal = new DAICacheDAL();
|
||
|
var cachelist = dal.GetList(workcellcode, workloccode, mouldcode).Where(p => !string.Equals(p.PREINPUT, "1")).ToList();
|
||
|
DAIDAL daidal = new DAIDAL();
|
||
|
var dailist = daidal.GetList(workcellcode);
|
||
|
if (cachelist == null || cachelist.Count == 0)
|
||
|
{
|
||
|
cachelist = new List<DAICache>();
|
||
|
foreach (var dai in dailist)
|
||
|
{
|
||
|
cachelist.Add(new DAICache
|
||
|
{
|
||
|
DA_CODE = dai.DA_CODE,
|
||
|
DA_SEQ = dai.DA_SEQ,
|
||
|
DA_STATE = dai.DA_STATUS,
|
||
|
DA_VALUE = "",
|
||
|
OBJ_PID = "",
|
||
|
DATA_TYPE = dai.DATA_TYPE,
|
||
|
MATERIAL_CODE = "",
|
||
|
DA_MODE = dai.DA_MODE,
|
||
|
DA_NAME = dai.DA_NAME,
|
||
|
PIVOTAL = dai.PIVOTAL,
|
||
|
ISPROCESSCODE = dai.ISPROCESSCODE,
|
||
|
MATERIAL_TYPE = dai.MATERIAL_TYPE,
|
||
|
PID = Guid.NewGuid().ToString(),
|
||
|
STATE_CODE = dai.STATE_CODE,
|
||
|
WORKCELL_CODE = dai.WORKCELL_CODE,
|
||
|
WORKLOC_CODE = workloccode,
|
||
|
UPDATEDATE = DateTime.Now,
|
||
|
MOULD_CODE = string.Equals("1", dai.DIVBY_MOULD) ? mouldcode : "",
|
||
|
SAVED = ""
|
||
|
});
|
||
|
}
|
||
|
dal.Insert(cachelist);
|
||
|
}
|
||
|
else if (cachelist.Count < dailist.Count)
|
||
|
{
|
||
|
foreach (var dai in dailist)
|
||
|
{
|
||
|
if (!cachelist.Exists(p => p.DA_CODE == dai.DA_CODE))
|
||
|
{
|
||
|
cachelist.Add(new DAICache
|
||
|
{
|
||
|
DA_CODE = dai.DA_CODE,
|
||
|
DA_SEQ = dai.DA_SEQ,
|
||
|
DA_STATE = dai.DA_STATUS,
|
||
|
DA_VALUE = "",
|
||
|
OBJ_PID = "",
|
||
|
DATA_TYPE = dai.DATA_TYPE,
|
||
|
MATERIAL_CODE = "",
|
||
|
DA_MODE = dai.DA_MODE,
|
||
|
DA_NAME = dai.DA_NAME,
|
||
|
PIVOTAL = dai.PIVOTAL,
|
||
|
ISPROCESSCODE = dai.ISPROCESSCODE,
|
||
|
MATERIAL_TYPE = dai.MATERIAL_TYPE,
|
||
|
PID = Guid.NewGuid().ToString(),
|
||
|
STATE_CODE = dai.STATE_CODE,
|
||
|
WORKCELL_CODE = dai.WORKCELL_CODE,
|
||
|
WORKLOC_CODE = workloccode,
|
||
|
UPDATEDATE = DateTime.Now,
|
||
|
IsNewInfo = true,
|
||
|
MOULD_CODE = string.Equals("1", dai.DIVBY_MOULD) ? mouldcode : "",
|
||
|
SAVED = ""
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
dal.Insert(cachelist.Where(p => p.IsNewInfo).ToList());
|
||
|
cachelist.ForEach((p) => { p.IsNewInfo = false; });
|
||
|
}
|
||
|
return cachelist;
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 工位代码
|
||
|
/// </summary>
|
||
|
public string WORKLOC_CODE { get; private set; }
|
||
|
/// <summary>
|
||
|
/// 当前状态
|
||
|
/// </summary>
|
||
|
public Entity.QT.WorkCellRunState CurrentState { get; private set; }
|
||
|
/// <summary>
|
||
|
/// 采集数据缓存
|
||
|
/// </summary>
|
||
|
public List<Entity.QT.DAICache> DataCache { get; private set; }
|
||
|
}
|
||
|
}
|