using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.TRACING.DAInterface;
using QMAPP.FJC.Entity.SA;
namespace QMAPP.FJC.TRACING.StateActions
{
///
/// 数量统计
///
public class StatisQTY : IStateAction
{
public void Execute(DAObject data)
{
var shift = data.Shift;
var wqtydal = new FJC.DAL.SA.WorkcellQtyCountDAL();
var wqty = wqtydal.GetByCondition(new WorkcellQtyCount
{
EQUIPMENT_CODE = data.MachineCode,
MATRIAL_CODE = data.WorkLocState.CurrentState.MATERIAL_CODE,
STATIS_DATE = data.Date.Date,
WORKCELL_CODE = data.WorkLocState.WORKCELL_CODE,
SHIFT_CODE = shift.PRODUCESHIFTTCODE
});
if (wqty == null)
{
wqty = new WorkcellQtyCount
{
EQUIPMENT_CODE = data.MachineCode,
MATRIAL_CODE = data.WorkLocState.CurrentState.MATERIAL_CODE,
STATIS_DATE = data.Date.Date,
WORKCELL_CODE = data.WorkLocState.WORKCELL_CODE,
SHIFT_CODE = shift.PRODUCESHIFTTCODE,
CREATEDATE = data.Date,
FACTORY_CODE = "",
NOK_QTY = 0,
OK_QTY = 1,
QTY = 1,
REWORK_QTY = 0,
PID = Guid.NewGuid().ToString(),
WORKCENTER_CODE = data.WorkLocState.WORKCENTER_CODE,
IsNewInfo = true
};
}
else
{
var eqty = data.GetPersistentEntity(wqty.PID);
if (eqty != null)
{
wqty = eqty;
}
wqty.QTY += 1;
wqty.OK_QTY += 1;
}
data.AddToPersistentList(wqty, wqty.PID);
}
}
}