using iWare_SCADA_Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace iWare_SCADA_BusinessLogical.Utils
{
///
/// 业务系统帮助类
///
public class SystemBussinessHelper
{
///
/// 设置WorkPieceLog 的创建人
///
///
///
///
public static void SetWorkPieceLogMiddleForCreatedUserName(ref WorkPieceLogMiddle workPieceLog, string _DataCapturePointCode, string _DataCapturePointName)
{
workPieceLog.CreatedUserName = _DataCapturePointCode;
workPieceLog.DataCapturePointCname = _DataCapturePointName;
}
///
/// 设置WorkPieceLog 的创建人
///
///
///
///
public static void SetWorkPieceLogMiddleForCreatedUserName(ref WorkPieceLog workPieceLog, string _DataCapturePointCode, string _DataCapturePointName)
{
workPieceLog.CreatedUserName = _DataCapturePointCode;
workPieceLog.DataCapturePointCname = _DataCapturePointName;
}
///
/// 设置WorkPieceLog 的更新人
///
///
///
///
public static void SetWorkPieceLogMiddleForUpdatedUserName(ref WorkPieceLogMiddle workPieceLog, string _DataCapturePointCode, string _DataCapturePointName)
{
workPieceLog.UpdatedUserName = _DataCapturePointCode;
workPieceLog.UpdateDataCapturePointCname = _DataCapturePointName;
}
///
/// 是否允许修改WorkPieceState 为WIP
///
///
///
///
///
public static bool IsAllowUpdateWorkPieceStateToWip(WorkPieceInfo info, DbModel db, WorkPieceLogMiddle logMiddle)
{
//这里修复OP10、OP40 因为PLC先推 SPC推出、再推 产品下线问题,导致 产品下线更新数据时,把SPC数据覆盖的问题 【Editby shaocx,2024-08-27】
if (logMiddle.WorkingProcedure == "OP10" || logMiddle.WorkingProcedure == "OP40")
{
var curPross = db.WorkPieceProcess.Where(x => x.WorkPieceID == info.WorkPieceID).OrderByDescending(x => x.Id).FirstOrDefault();
if (curPross != null && curPross.OperationType == OperationType.SPC.ToString())
{
return false;
}
return true;
}
return true;
}
}
}