using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.FJC.DAL.QT;
using QMAPP.FJC.Entity.QT;
using QMAPP.FJC.Entity.Produce;
using QMAPP.FJC.TRACING.DAInterface;
using QMAPP.FJC.DAL.Produce;
using QMAPP.FJC.DAL.Basic;
using QMAPP.FJC.Entity.Basic;
namespace QMAPP.FJC.TRACING.StateActions
{
///
/// 将提前输入的数据推送到当前加工
///
public class PushData : IStateAction
{
///
/// 执行
///
///
public void Execute(DAObject data)
{
DAICacheDAL dal = new DAICacheDAL();
var precachelist = dal.GetList(data.WorkLocState.WORKCELL_CODE, data.WorkLocState.WORKLOC_CODE).Where(p => string.Equals(p.PREINPUT, "1")).ToList();
DAL.Basic.MachineInfoDAL machinedal = new DAL.Basic.MachineInfoDAL();
var machine = machinedal.GetMachineInfo(new MachineInfo { MACHINECODDE = data.MachineCode });
if (machine.ISSTATION == 2)
{
precachelist = precachelist.Where(p => p.MOULD_CODE == data.MouldCode).ToList();
}
foreach (var pre in precachelist)
{
var cache = data.WorkLocState.DataCache.FirstOrDefault(p => p.DA_CODE == pre.DA_CODE);
if (cache != null)
{
cache.MATERIAL_CODE = pre.MATERIAL_CODE;
cache.DA_VALUE = pre.DA_VALUE;
cache.OBJ_PID = pre.OBJ_PID;
cache.SAVED = cache.SAVED.Replace(data.MouldCode, "");
pre.MATERIAL_CODE = "";
pre.DA_VALUE = "";
pre.OBJ_PID = "";
//resetDai.Add(dai);
data.AddToPersistentList(pre, pre.PID);
data.AddToPersistentList(cache, cache.PID);
}
else
{
throw new Exception("da lost!");
}
}
}
}
}