天津投入产出系统后端
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.
 
 
 
 
 
 

59 lines
2.4 KiB

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.TRACING.DAInterface;
using QMAPP.FJC.DAL.Produce;
using QMAPP.FJC.DAL.Basic;
using QMAPP.FJC.Entity.Operation;
using QMAPP.FJC.DAL.Operation;
using QMAPP.FJC.Entity.Basic;
using QMAPP.MD.Entity;
using QMAPP.MD.DAL;
using QMAPP.MD.Entity.View;
using QMAPP.FJC.Entity.ProductionPlan;
using QMAPP.FJC.Entity;
namespace QMAPP.FJC.TRACING.StateActions
{
/// <summary>
/// 线边包装数量
/// </summary>
public class PackageConsume : IStateAction
{
/// <summary>
/// 执行
/// </summary>
/// <param name="data"></param>
public void Execute(DAObject data)
{
WorkCellRunStateDAL wcrsdal = new WorkCellRunStateDAL();
var state = wcrsdal.GetNextState(data.WorkLocState.WORKCELL_CODE, data.WorkLocState.CurrentState.STATE_SEQ);
bool workcellend = state == null; //如果当前为工序最终状态
//List<DAICache> unsavedDai = new List<DAICache>();
foreach (var dai in data.WorkLocState.DataCache)
{
if (workcellend && !string.IsNullOrWhiteSpace(dai.MATERIAL_CODE) && !dai.MATERIAL_CODE.Equals(data.WorkLocState.CurrentState.MATERIAL_CODE)) //如果采集的物料号于产品物料号一直则不保存产品组成
{
StringBuilder sql = new StringBuilder();
sql.AppendLine("UPDATE T_AW_PACKAGE ");
sql.AppendLine("SET USINGCOUNT=USINGCOUNT+1 ");
sql.AppendLine(",USINGSTATE=CASE WHEN CAPACITY>USINGCOUNT+1 THEN 1 ELSE 2 END ");
sql.AppendLine("WHERE PID IN (SELECT TOP 1 PID ");
sql.AppendLine(" FROM T_AW_PACKAGE ");
sql.AppendLine(" WHERE MATERIAL_CODE=@materialcode ");
sql.AppendLine(" AND USINGSTATE<2 ");
sql.AppendLine(" AND USINGCOUNT<CAPACITY ");
sql.AppendLine(" ORDER BY CREATEDATE)");
data.SQLCommands.Add(new SQLCommand(sql.ToString(), new DataParameter("materialcode", dai.MATERIAL_CODE)));
}
}
//DAICacheDAL dcdal = new DAICacheDAL();
//dcdal.Update(unsavedDai, data.DataSession);
}
}
}