Align .editorconfig files Move Controller logic to DMO classes GlobalVars.AppSettings = Models.AppSettings.GetFromConfigurationManager(); Question EditorConfig Project level editorconfig Format White Spaces AppSetting when EnvironmentVariable not set Corrective Actions Tests Schedule Actions Tests DMO Tests Controller Tests Get ready to use VSCode IDE
1096 lines
52 KiB
C#
1096 lines
52 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Transactions;
|
|
|
|
using Dapper;
|
|
|
|
using Fab2ApprovalSystem.Misc;
|
|
using Fab2ApprovalSystem.Models;
|
|
using Fab2ApprovalSystem.ViewModels;
|
|
|
|
namespace Fab2ApprovalSystem.DMO;
|
|
|
|
public class LotDispositionDMO {
|
|
|
|
private readonly AppSettings _AppSettings;
|
|
private readonly WorkflowDMO wfDMO = new();
|
|
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
|
|
|
|
public LotDispositionDMO(AppSettings appSettings) =>
|
|
_AppSettings = appSettings;
|
|
|
|
public IEnumerable<IssuesViewModel> GetTaskList(int userID) {
|
|
// eventually, the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
//var lotDispostions = this.db.Query<IssuesViewModel>("GetLotDispositionsByUser", new { UserID = userID }, commandType: CommandType.StoredProcedure).ToList();
|
|
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
|
|
List<IssuesViewModel> lotDispostions = db.Query<IssuesViewModel>("GetTaskListByUser", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
public IEnumerable<OpenActionItemViewModel> GetMyOpenActionItems(int userID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
|
|
List<OpenActionItemViewModel> lotDispostions = db.Query<OpenActionItemViewModel>("GetOpenActionItemsByUser", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetLotDispositions() {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
List<IssuesViewModel> lotDispostions = db.Query<IssuesViewModel>("GetLotDispositions", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetDocuments() {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
List<IssuesViewModel> lotDispostions = db.Query<IssuesViewModel>("GetDocuments", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetWorkRequests() {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
List<IssuesViewModel> workReqs = db.Query<IssuesViewModel>("LTGetWorkRequests", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return workReqs;
|
|
}
|
|
|
|
public IEnumerable<AuditList> GetAuditList(int userID) {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
List<AuditList> al = db.Query<AuditList>("_8DGetAuditList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return al;
|
|
}
|
|
|
|
public IEnumerable<CorrectiveAction> GetCorrectiveActionList(int userID) {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
List<CorrectiveAction> cal = db.Query<CorrectiveAction>("_8DGetCorrectiveActionList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return cal;
|
|
}
|
|
|
|
public IEnumerable<ChangeControlList> GetChangeControls(int userID) {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
List<ChangeControlList> cc = db.Query<ChangeControlList>("CCGetChangeControlList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetMRBList(int userID) {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
List<IssuesViewModel> cc = db.Query<IssuesViewModel>("MRBGetMRBList", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetECNList(int userID) {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
List<IssuesViewModel> cc = db.Query<IssuesViewModel>("ECNGetECNList", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetLotDispositionList(int userID) {
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
List<IssuesViewModel> cc = db.Query<IssuesViewModel>("GetLotDispositionList", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
public LotDisposition GetLotDispositionItem(int issueID, out int isITAR, int userID) {
|
|
/* IsITAR
|
|
0 = false
|
|
1 = true
|
|
2 = not required
|
|
*/
|
|
isITAR = 2;
|
|
LotDisposition issueItem = new();
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", value: issueID);
|
|
parameters.Add("@UserID", userID);
|
|
//parameters.Add("@UserID", GlobalVars.USER_ID);
|
|
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
|
|
using (var multipleResultItems = db.QueryMultiple("GetLotDispositionItem", parameters, commandType: CommandType.StoredProcedure)) {
|
|
issueItem = multipleResultItems.Read<LotDisposition>().SingleOrDefault();
|
|
|
|
List<int> departments = multipleResultItems.Read<int>().ToList();
|
|
if (issueItem != null && departments != null) {
|
|
issueItem.DepartmentIDs.AddRange(departments);
|
|
}
|
|
|
|
isITAR = parameters.Get<int>("@IsITAR");
|
|
|
|
}
|
|
return issueItem;
|
|
}
|
|
|
|
public LotDisposition GetLotDispositionItemForRead(int issueID, out int isITAR, int userID) {
|
|
/* IsITAR
|
|
0 = false
|
|
1 = true
|
|
2 = not required
|
|
*/
|
|
isITAR = 2;
|
|
LotDisposition issueItem = new();
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", value: issueID);
|
|
parameters.Add("@UserID", userID);
|
|
//parameters.Add("@UserID", GlobalVars.USER_ID);
|
|
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
|
|
using (var multipleResultItems = db.QueryMultiple("GetLotDispositionItemForRead", parameters, commandType: CommandType.StoredProcedure)) {
|
|
issueItem = multipleResultItems.Read<LotDisposition>().SingleOrDefault();
|
|
|
|
List<int> departments = multipleResultItems.Read<int>().ToList();
|
|
if (issueItem != null && departments != null) {
|
|
issueItem.DepartmentIDs.AddRange(departments);
|
|
}
|
|
|
|
isITAR = parameters.Get<int>("@IsITAR");
|
|
|
|
}
|
|
return issueItem;
|
|
}
|
|
|
|
public int GetRHLotCount(int issueID) {
|
|
StringBuilder query = new("SELECT COUNT(*) FROM dbo.fnGetLot_RH(@IssueID) ");
|
|
//query.Append("WHERE UserID = @UserID AND AND EmployeeStatus = 'Active'");
|
|
return db.Query<int>(query.ToString(), new { IssueID = issueID }).SingleOrDefault();
|
|
}
|
|
|
|
public List<LotDispoDepartment> GetDepartments() {
|
|
List<LotDispoDepartment> departments = db.Query<LotDispoDepartment>("GetLotDispositionDepartments", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return departments;
|
|
}
|
|
|
|
#region LotDisposition
|
|
public LotDisposition InsertLotDisposition(LotDisposition lotDispo) {
|
|
DynamicParameters parameters = new();
|
|
using (TransactionScope transanction = new()) {
|
|
// Lot Disposition
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", value: lotDispo.IssueID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
parameters.Add("@Title", lotDispo.Title);
|
|
parameters.Add("@IssueDescription", lotDispo.IssueDescription);
|
|
parameters.Add("@PERequired", lotDispo.PERequired);
|
|
parameters.Add("@ResponsibilityID", lotDispo.ResponsibilityID);
|
|
parameters.Add("@IssueDate", lotDispo.IssueDate);
|
|
parameters.Add("@OriginatorID", lotDispo.OriginatorID);
|
|
parameters.Add("@ReasonForDisposition", lotDispo.ReasonForDisposition);
|
|
parameters.Add("@ResponsibilityIssueID", lotDispo.ResponsibilityIssueID);
|
|
parameters.Add("@SPNScrapCode", lotDispo.SPNScrapCode);
|
|
parameters.Add("@CurrentStep", lotDispo.CurrentStep);
|
|
|
|
db.Execute("InsertLotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
lotDispo.IssueID = parameters.Get<int>("@IssueID");
|
|
|
|
// Lot Update
|
|
|
|
//parameters = new DynamicParameters();
|
|
//IEnumerable<Lot> lots = lotDispo.Lots;
|
|
//foreach (Lot lot in lots)
|
|
//{
|
|
// parameters = new DynamicParameters();
|
|
// parameters.Add("@LotNumber", lot.LotNumber);
|
|
// parameters.Add("@IssueID", lotDispo.IssueID);
|
|
// parameters.Add("@Description", lot.Description);
|
|
// parameters.Add("@NewPartNo", lot.NewPartNo);
|
|
// parameters.Add("@WipPartNo", lot.WipPartNo);
|
|
// parameters.Add("@DiePartNo", lot.DiePartNo);
|
|
// parameters.Add("@ProductFamily", lot.ProductFamily);
|
|
// parameters.Add("@Gen", lot.Gen);
|
|
|
|
// parameters.Add("@Channel", lot.Channel);
|
|
// parameters.Add("@Hexsize", lot.Hexsize);
|
|
|
|
// parameters.Add("@Voltage", lot.Voltage);
|
|
// parameters.Add("@WaferCount", lot.WaferCount);
|
|
// parameters.Add("@DieCount", lot.DieCount);
|
|
|
|
// parameters.Add("@Location", lot.Location);
|
|
// parameters.Add("@TotalCost", lot.TotalCost);
|
|
// parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
|
|
|
|
// this.db.Execute("InsertLot", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
//}
|
|
|
|
// LotDispoDepartment
|
|
List<int> lotDispDepIDs = lotDispo.DepartmentIDs;
|
|
|
|
if (lotDispDepIDs != null) {
|
|
foreach (int depIds in lotDispDepIDs) {
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", depIds);
|
|
parameters.Add("@DepartMentID", lotDispo.IssueID);
|
|
db.Execute("InsertLotDispoDepartment", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
}
|
|
|
|
transanction.Complete();
|
|
|
|
return lotDispo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public ScrapLot GetLotStausDetail(int issueID, string lotNumber) =>
|
|
db.Query<ScrapLot>("SELECT L.WaferCount, S.* FROM ScrapLot S INNER JOIN Lot L ON S.IssueID = L.IssueID AND S.LotNo = L.LotNumber WHERE S.IssueID = @IssueID AND LotNo = @lotNumber", new { IssueID = issueID, lotNumber = lotNumber }).SingleOrDefault();
|
|
|
|
public void UpdateLotDisposition(LotDisposition lotDispo) {
|
|
DynamicParameters parameters = new();
|
|
using (TransactionScope transanction = new()) {
|
|
// Lot Disposition
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", lotDispo.IssueID);
|
|
parameters.Add("@Title", lotDispo.Title);
|
|
parameters.Add("@IssueDescription", lotDispo.IssueDescription);
|
|
parameters.Add("@PERequired", lotDispo.PERequired);
|
|
parameters.Add("@MRBRequired", lotDispo.MRBRequired);
|
|
parameters.Add("@DispositionByOCAP", lotDispo.DispositionByOCAP);
|
|
parameters.Add("@CANo", lotDispo.CANo);
|
|
parameters.Add("@ResponsibilityID", lotDispo.ResponsibilityID);
|
|
parameters.Add("@IssueDate", lotDispo.IssueDate);
|
|
parameters.Add("@ReasonForDisposition", lotDispo.ReasonForDisposition);
|
|
parameters.Add("@ResponsibilityIssueID", lotDispo.ResponsibilityIssueID);
|
|
parameters.Add("@SPNScrapCode", lotDispo.SPNScrapCode);
|
|
|
|
db.Execute("UpdateLotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
List<int> lotDispDepIDs = lotDispo.DepartmentIDs;
|
|
|
|
if (lotDispDepIDs != null) {
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", lotDispo.IssueID);
|
|
db.Execute("DeleteLotDispositionDepartment", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
foreach (int depIds in lotDispDepIDs) {
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", lotDispo.IssueID);
|
|
parameters.Add("@DepartmentID", depIds);
|
|
db.Execute("InsertLotDispositionDepartment", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
}
|
|
transanction.Complete();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LotDispoitio Lot
|
|
|
|
public int InsertLot(Lot lot, bool getLotInfo) {
|
|
if (getLotInfo) {
|
|
MiscDMO.GetLotInformation(lot);
|
|
}
|
|
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@LotID", value: lot.LotID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
parameters.Add("@LotNumber", lot.LotNumber);
|
|
parameters.Add("@DieLotNumber", lot.DieLotNumber);
|
|
parameters.Add("@IssueID", lot.IssueID);
|
|
parameters.Add("@Description", lot.Description);
|
|
parameters.Add("@NewPartNo", lot.NewPartNo);
|
|
parameters.Add("@WipPartNo", lot.WipPartNo);
|
|
parameters.Add("@DiePartNo", lot.DiePartNo);
|
|
parameters.Add("@ProductFamily", lot.ProductFamily);
|
|
parameters.Add("@Gen", lot.Gen);
|
|
|
|
parameters.Add("@Channel", lot.Channel);
|
|
parameters.Add("@Hexsize", lot.Hexsize);
|
|
|
|
parameters.Add("@Voltage", lot.Voltage);
|
|
parameters.Add("@WaferCount", lot.WaferCount);
|
|
parameters.Add("@DieCount", lot.DieCount);
|
|
|
|
parameters.Add("@Location", lot.Location);
|
|
parameters.Add("@TotalCost", lot.TotalCost);
|
|
parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
|
|
parameters.Add("@QualityCode", lot.QualityCode);
|
|
parameters.Add("@OpenIssueWithExistingLot", dbType: DbType.Int32, direction: ParameterDirection.Output);
|
|
|
|
db.Execute("InsertLotDispositionLot", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
int lotID = parameters.Get<int>("@LotID");
|
|
if (parameters.Get<int>("@OpenIssueWithExistingLot") != 0) {
|
|
lot.OpenIssueWithExistingLots = parameters.Get<int>("@OpenIssueWithExistingLot");
|
|
}
|
|
|
|
return lotID;
|
|
}
|
|
|
|
public IEnumerable<SPN_MRB> GetMRBsFromSPN(string lotNumber) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@LotNo", lotNumber);
|
|
List<SPN_MRB> mrbList = db.Query<SPN_MRB>("GetMRBsFromSPN", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
|
|
return mrbList;
|
|
}
|
|
|
|
public void InsertChildLot_NotInTheMRB(string lotNumber) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@LotNo", lotNumber);
|
|
db.Execute("InsertChildLot_NotInTheMRB_LD", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public void DeleteCADocument(int CANo, int userID, string caTypeString) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@UserID", userID);
|
|
parameters.Add("@CANo", CANo);
|
|
parameters.Add("@CAType", caTypeString);
|
|
|
|
db.Execute("_8DDeleteCADocument", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public void DeleteLotDispoLot(int lotID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@LotID", lotID);
|
|
db.Execute("DeleteLotDispositionLot", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public void DeleteAllLotDispoLot(int issueID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", issueID);
|
|
db.Execute("DeleteLotDispositionAllLots", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public void UpdateLotDispoLot(Lot lot) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@LotID", lot.LotID);
|
|
parameters.Add("@LotNumber", lot.LotNumber);
|
|
parameters.Add("@DieLotNumber", lot.DieLotNumber);
|
|
parameters.Add("@IssueID", lot.IssueID);
|
|
parameters.Add("@Description", lot.Description);
|
|
parameters.Add("@NewPartNo", lot.NewPartNo);
|
|
parameters.Add("@WipPartNo", lot.WipPartNo);
|
|
parameters.Add("@DiePartNo", lot.DiePartNo);
|
|
parameters.Add("@ProductFamily", lot.ProductFamily);
|
|
parameters.Add("@Gen", lot.Gen);
|
|
|
|
parameters.Add("@Channel", lot.Channel);
|
|
parameters.Add("@Hexsize", lot.Hexsize);
|
|
|
|
parameters.Add("@Voltage", lot.Voltage);
|
|
parameters.Add("@WaferCount", lot.WaferCount);
|
|
parameters.Add("@DieCount", lot.DieCount);
|
|
|
|
parameters.Add("@Location", lot.Location);
|
|
parameters.Add("@TotalCost", lot.TotalCost);
|
|
parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
|
|
|
|
db.Execute("UpdateLotDispositionLot", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
// Update the Scrap Lot table =====================================================================
|
|
ScrapLot sl = new();
|
|
sl.IssueID = lot.IssueID;
|
|
sl.LotNo = lot.LotNumber;
|
|
sl.WaferCount = lot.WaferCount;
|
|
|
|
foreach (PropertyInfo pi in sl.GetType().GetProperties()) {
|
|
if (pi.Name.ToLower().StartsWith("lot") && pi.Name.ToLower().EndsWith("state")) {
|
|
if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Release)
|
|
pi.SetValue(sl, (byte)1, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Scrap)
|
|
pi.SetValue(sl, (byte)2, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable)
|
|
pi.SetValue(sl, (byte)3, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.M_Suffix)
|
|
pi.SetValue(sl, (byte)4, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Select_Wafers)
|
|
pi.SetValue(sl, (byte)5, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.CloseToQDB)
|
|
pi.SetValue(sl, (byte)6, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.SplitOffHold)
|
|
pi.SetValue(sl, (byte)7, null);
|
|
}
|
|
}
|
|
|
|
// if the Lot Status is M_Suffix, the whole lot is automatically in a Release state per Hans
|
|
if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Release
|
|
|| lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.M_Suffix
|
|
|| lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.CloseToQDB) {
|
|
sl.ScrapCount = 0;
|
|
sl.ReleaseCount = lot.WaferCount > 0 ? lot.WaferCount : lot.DieCount;
|
|
lot.ScrapCount = 0;
|
|
lot.ReleaseCount = sl.ReleaseCount;
|
|
|
|
} else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Scrap) {
|
|
sl.ScrapCount = lot.WaferCount > 0 ? lot.WaferCount : lot.DieCount;
|
|
sl.ReleaseCount = 0;
|
|
|
|
lot.ScrapCount = lot.WaferCount > 0 ? lot.WaferCount : lot.DieCount;
|
|
lot.ReleaseCount = 0;
|
|
} else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.SplitOffHold
|
|
|| lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable) {
|
|
sl.ScrapCount = 0;
|
|
sl.ReleaseCount = 0;
|
|
|
|
lot.ScrapCount = 0;
|
|
lot.ReleaseCount = 0;
|
|
}
|
|
//else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable)
|
|
//{
|
|
// sl.ScrapCount = 0;
|
|
// sl.ReleaseCount = 0;
|
|
|
|
// lot.ScrapCount = 0;
|
|
// lot.ReleaseCount = 0;
|
|
//}
|
|
|
|
UpdateLotScrapReleaseStatus(sl);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the Lot object with additional info based on Lot data downlaoded from SPN
|
|
/// </summary>
|
|
|
|
//void GetLotInformation(Lot lot)
|
|
//{
|
|
// string qryLotInfo = "SELECT WP_LOT_NO, WP_PART_NUMBER, MP_PRODUCT_FAMILY, MP_DESCRIPTION, WP_CURRENT_QTY, WP_CURRENT_LOCATION, DieLotNumber, DiePartNo, DieCount FROM SPNLot WHERE WP_Lot_No = @LotNumber ";
|
|
// var lotInfoRow = this.db.Query<dynamic>(qryLotInfo, new { lot.LotNumber }).ToList();
|
|
|
|
// //lot.LotNumber = lotInfoRow.Get<string>("@WP_LOT_NO");
|
|
// //lot.WipPartNo = lotInfoRow.Get<int>("@WP_Part_Number");
|
|
// ////lotInfoRow.WP_LOT_NO;
|
|
// //lot.WipPartNo = lotInfoRow.WP_Part_Number;
|
|
|
|
// foreach (dynamic lotInfoColumn in lotInfoRow)
|
|
// {
|
|
|
|
// lot.LotNumber = lotInfoColumn.WP_LOT_NO;
|
|
// lot.DieLotNumber = lotInfoColumn.DieLotNumber;
|
|
|
|
// if (lotInfoColumn.WP_PART_NUMBER != null)
|
|
// lot.WipPartNo = lotInfoColumn.WP_PART_NUMBER.Trim();
|
|
|
|
// if (lotInfoColumn.WP_CURRENT_LOCATION != null)
|
|
// {
|
|
// lot.Location = lotInfoColumn.WP_CURRENT_LOCATION;
|
|
// }
|
|
|
|
// if (lotInfoColumn.MP_DESCRIPTION != null)
|
|
// {
|
|
// lot.Description = lotInfoColumn.MP_DESCRIPTION;
|
|
// if (lot.Description.Length > 0)
|
|
// {
|
|
// string[] temp = lot.Description.Split(new char[] { ',' });
|
|
// if (temp.Length > 0)
|
|
// {
|
|
// try
|
|
// {
|
|
// lot.ProductFamily = temp[0];
|
|
// }
|
|
// catch { } // ignore the error
|
|
|
|
// try
|
|
// {
|
|
// lot.Gen = double.Parse(temp[2].Substring(1,temp[2].Length - 1));
|
|
// }
|
|
// catch { }// ignore the error
|
|
// try
|
|
// {
|
|
// lot.Hexsize = double.Parse(temp[6]);
|
|
// }
|
|
// catch { }// ignore the error
|
|
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// if (lotInfoColumn.DieCount != null)
|
|
// lot.DieCount = int.Parse(lotInfoColumn.DieCount.ToString());
|
|
|
|
// if (lotInfoColumn.DiePartNo != null)
|
|
// lot.DiePartNo = lotInfoColumn.DiePartNo.Trim();
|
|
|
|
// if (lotInfoColumn.WP_CURRENT_QTY != null)
|
|
// lot.WaferCount = lotInfoColumn.WP_CURRENT_QTY;
|
|
|
|
// if (lot.WipPartNo.Length > 0 || lot.DiePartNo.Length > 0)
|
|
// {
|
|
// qryLotInfo = "SELECT DiePartNo, SourceFAB, Diameter, Silicon, Gen, Layers,HexSize,Voltage,Channel, Type AS ProductFamily, WaferCost, DieCost FROM FabApprovalSystem.dbo.StdCost WHERE WIPWaferNo = @WIPPartNo OR DiePartNo = @DiePartNo ";
|
|
// var moreLotInfoRow = this.db.Query<dynamic>(qryLotInfo, new { lot.WipPartNo, lot.DiePartNo }).ToList();
|
|
|
|
// foreach (var moreLotInfoColumn in moreLotInfoRow)
|
|
// {
|
|
// lot.DieCost = double.Parse(moreLotInfoColumn.DieCost.ToString());
|
|
// lot.WaferCost = double.Parse(moreLotInfoColumn.WaferCost.ToString());
|
|
|
|
// if (moreLotInfoColumn.Channel != null)
|
|
// lot.Channel = moreLotInfoColumn.Channel;
|
|
|
|
// //if (moreLotInfoColumn.ProductFamily != null)
|
|
// // lot.ProductFamily = moreLotInfoColumn.ProductFamily;
|
|
|
|
// if (moreLotInfoColumn.Hexsize != null)
|
|
// lot.Hexsize = moreLotInfoColumn.Hexsize;
|
|
|
|
// if (moreLotInfoColumn.Voltage != null)
|
|
// lot.Voltage = moreLotInfoColumn.Voltage;
|
|
|
|
// //if (moreLotInfoColumn.Gen != null)
|
|
// // lot.Gen = moreLotInfoColumn.Gen;
|
|
|
|
// if (lot.DieCount == 0)
|
|
// lot.TotalCost = Math.Round(lot.WaferCount * lot.WaferCost,2);
|
|
// else
|
|
// lot.TotalCost = Math.Round(lot.DieCount * lot.DieCost,2);
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //return lotStatusOption;
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
public IEnumerable<LotStatusOptionViewModel> GetLotStatusOptions() {
|
|
List<LotStatusOptionViewModel> lotStatusOption = db.Query<LotStatusOptionViewModel>("SELECT * FROM LotStatusOption").ToList();
|
|
return lotStatusOption;
|
|
}
|
|
|
|
public IEnumerable<Lot> GetLotDispositionLots(int issueID) {
|
|
// NOTE: Any new fields that needs to be added to select list , needs to be referenced prior to the "LS.LotStatusOptionID , LS.LotStatusOption" fields
|
|
|
|
db.Open();
|
|
#region Commented Code
|
|
/*
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("SELECT DISTINCT SQ.IssueIDs AS MRBsLinkedToLot , DispoType.MRBDispoType, SQP.IssueIDs AS IssueIDWithoutMRB, ");
|
|
sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 1 ");
|
|
sql.Append("WHEN PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2 THEN 0 ");
|
|
sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 0 ");
|
|
|
|
sql.Append("WHEN (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
|
|
sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND LS.LotStatusOptionID <> 6 ) ");
|
|
sql.Append(" AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB') THEN 0 ");
|
|
|
|
sql.Append("ELSE 1 ");
|
|
sql.Append("END AS GoodToSubmit, ");
|
|
|
|
sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 'NA' ");
|
|
sql.Append("WHEN (PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2) ");
|
|
sql.Append("OR ( ");
|
|
sql.Append(" (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
|
|
sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND LS.LotStatusOptionID <> 6 AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB')) ");
|
|
sql.Append(" )");
|
|
sql.Append(" THEN 'MRB Disposition different from Lot Dispostion' ");
|
|
|
|
sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 'MRB Dispo missing' ");
|
|
sql.Append("ELSE 'NA' ");
|
|
sql.Append("END AS SubmitErrorMessage, ");
|
|
|
|
sql.Append(" ");
|
|
sql.Append("L.LotID, L.LotNumber, L.IssueID ,L.DieLotNumber ,L.Description ,L.NewPartNo ,L.WipPartNo ,L.DiePartNo ,L.ProductFamily, ");
|
|
sql.Append("L.Gen ,L.Channel, L.HexSize, L.Voltage, L.WaferCount, L.DieCount, L.Location, L.TotalCost, L.LotStatusOptionID,");
|
|
sql.Append("S.ReleaseCount, S.ScrapCount, L.QualityCode, LS.LotStatusOptionID , LS.LotStatusOption FROM Lot L ");
|
|
sql.Append("INNER JOIN LotStatusOption LS ON L.LotStatusOptionID = LS.LotStatusOptionID ");
|
|
sql.Append("LEFT JOIN ScrapLot S ON L.LotNumber = S.LotNo AND L.IssueID = S.IssueID ");
|
|
|
|
sql.Append("LEFT JOIN ");
|
|
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
|
|
// Code changed 12/11/2019 RJK
|
|
//sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
|
|
sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) + '_' + CAST(ISNULL(ML.DispoType,'') AS varchar(512)) ");
|
|
sql.Append("FROM vMRBLot ML ");
|
|
//sql.Append("WHERE SUBSTRING(LTRIM(RTRIM(L.LotNumber)),1,7) = SUBSTRING(LTRIM(RTRIM(ML.LotNumber)),1,7) ");
|
|
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
|
|
sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
|
|
sql.Append("FROM Lot L) AS SQ ");
|
|
sql.Append("ON L.LotID = SQ.LotID ");
|
|
|
|
sql.Append("LEFT JOIN ");
|
|
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
|
|
sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
|
|
sql.Append("FROM vMRBLot ML ");
|
|
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
|
|
sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
|
|
sql.Append("FROM Lot L) AS SQP ");
|
|
sql.Append("ON L.LotID = SQP.LotID ");
|
|
|
|
sql.Append("LEFT JOIN ");
|
|
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
|
|
sql.Append("((SELECT DISTINCT ',' + CAST(ISNULL(ML.DispoType, 'X') AS varchar(512)) ");
|
|
sql.Append("FROM vMRBLot ML ");
|
|
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
|
|
sql.Append("FOR XML PATH('')), 1, 1, '') AS MRBDispoType ");
|
|
sql.Append("FROM Lot L) AS DispoType ");
|
|
sql.Append("ON L.LotID = DispoType.LotID ");
|
|
|
|
sql.Append("WHERE L.IssueID = " + issueID);
|
|
|
|
var data = this.db.Query<Lot, LotStatusOptionViewModel, Lot>
|
|
(sql.ToString(), (lot, lotstatusoption) =>
|
|
{
|
|
lot.LotStatusOption = lotstatusoption;
|
|
return lot;
|
|
},
|
|
splitOn: "LotStatusOptionID").ToList();
|
|
|
|
*/
|
|
#endregion
|
|
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", issueID, DbType.Int32);
|
|
List<Lot> data = db.Query<Lot, LotStatusOptionViewModel, Lot>
|
|
("GetLotDispositionLots", (lot, lotstatusoption) => {
|
|
lot.LotStatusOption = lotstatusoption;
|
|
return lot;
|
|
},
|
|
param: parameters,
|
|
commandType: CommandType.StoredProcedure,
|
|
splitOn: "LotStatusOptionID").ToList();
|
|
|
|
return data;
|
|
}
|
|
|
|
public IEnumerable<Attachment> GetLotDispoAttachments(int issueID) {
|
|
List<Attachment> attachments = db.Query<Attachment>("SELECT A.AttachmentID, A.IssueID, A.FileName, A.UserID, CONVERT(VARCHAR(10), A.UploadDate, 101) AS UploadDate, U.FirstName + ' ' + U.LastName AS FullName FROM Attachment A INNER JOIN Users U ON A.UserID = U.UserID WHERE IssueID = @IssueID ", new { IssueID = issueID }).ToList();
|
|
return attachments;
|
|
}
|
|
|
|
public void DeleteLotDispoAttachment(int attachmentID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@AttachmentID", attachmentID);
|
|
db.Execute("DeleteLotDispositionAttachment", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public void InsertLotDispositionAttachment(Attachment attach) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", attach.IssueID);
|
|
parameters.Add("@UserID", attach.UserID);
|
|
parameters.Add("@FileName", attach.FileName);
|
|
|
|
db.Execute("InsertLotDispositionAttachment", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public IEnumerable<Lot> SearchLots(string searchText) {
|
|
// string sql = "SELECT WP_LOT_NO AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' OR DieLotNumber LIKE '%" + searchText + "%'";
|
|
string sql = "SELECT WP_LOT_NO AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
|
|
List<Lot> lotList = db.Query<Lot>(sql).ToList();
|
|
return lotList;
|
|
}
|
|
|
|
public IEnumerable<Users> GetUserList() {
|
|
StringBuilder sql = new();
|
|
sql.Append("SELECT FirstName + ' ' + LastName AS OriginatorName, U.UserID AS OriginatorID, FirstName ");
|
|
sql.Append("FROM Users U ");
|
|
sql.Append("ORDER BY FirstName");
|
|
|
|
return db.Query<Users>(sql.ToString()).ToList();
|
|
}
|
|
|
|
public List<Responsibility> GetResponsibilityList() {
|
|
List<Responsibility> departments = db.Query<Responsibility>("SELECT ResponsibilityID, ResponsibilityName FROM Responsibility ORDER BY ResponsibilityName ", null, commandType: CommandType.Text).ToList();
|
|
return departments;
|
|
}
|
|
|
|
public List<ResponsibilityIssue> GetResponsibilityIssueList(int responsibilityID) {
|
|
List<ResponsibilityIssue> respIssue = db.Query<ResponsibilityIssue>("SELECT ResponsibilityIssueID, Issue FROM ResponsibilityIssue WHERE ResponsibilityID = @ResponsibilityID ORDER BY Issue ", new { @ResponsibilityID = responsibilityID }, commandType: CommandType.Text).ToList();
|
|
return respIssue;
|
|
}
|
|
|
|
public void UpdateLotScrapReleaseStatus(ScrapLot scrap) {
|
|
StringBuilder qryInsert = new();
|
|
qryInsert.Append("DELETE FROM ScrapLot WHERE LotNo = @LotNo AND IssueID = @IssueID");
|
|
qryInsert.Append(" INSERT INTO ScrapLot(LotNo,IssueID,ScrapCount,ReleaseCount, Lot1State,Lot2State,Lot3State,Lot4State,Lot5State,Lot6State,Lot7State,Lot8State,Lot9State,Lot10State, ");
|
|
qryInsert.Append(" Lot11State,Lot12State,Lot13State,Lot14State,Lot15State,Lot16State,Lot17State,Lot18State,Lot19State,Lot20State, ");
|
|
qryInsert.Append(" Lot21State,Lot22State,Lot23State,Lot24State,Lot25State,Lot26State,Lot27State,Lot28State,Lot29State,Lot30State, ");
|
|
qryInsert.Append(" Lot31State,Lot32State,Lot33State,Lot34State,Lot35State,Lot36State,Lot37State,Lot38State,Lot39State,Lot40State, ");
|
|
qryInsert.Append(" Lot41State,Lot42State,Lot43State,Lot44State,Lot45State,Lot46State,Lot47State,Lot48State,Lot49State,Lot50State) ");
|
|
qryInsert.Append(" VALUES(@LotNo,@IssueID,@ScrapCount,@ReleaseCount,@Lot1State,@Lot2State,@Lot3State,@Lot4State,@Lot5State,@Lot6State,@Lot7State,@Lot8State,@Lot9State,@Lot10State,");
|
|
qryInsert.Append(" @Lot11State,@Lot12State,@Lot13State,@Lot14State,@Lot15State,@Lot16State,@Lot17State,@Lot18State,@Lot19State,@Lot20State,");
|
|
qryInsert.Append(" @Lot21State,@Lot22State,@Lot23State,@Lot24State,@Lot25State,@Lot26State,@Lot27State,@Lot28State,@Lot29State,@Lot30State,");
|
|
qryInsert.Append(" @Lot31State,@Lot32State,@Lot33State,@Lot34State,@Lot35State,@Lot36State,@Lot37State,@Lot38State,@Lot39State,@Lot40State,");
|
|
qryInsert.Append(" @Lot41State,@Lot42State,@Lot43State,@Lot44State,@Lot45State,@Lot46State,@Lot47State,@Lot48State,@Lot49State,@Lot50State)");
|
|
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@LotNo", scrap.LotNo);
|
|
parameters.Add("@IssueID", scrap.IssueID);
|
|
parameters.Add("@ScrapCount", scrap.ScrapCount);
|
|
parameters.Add("@ReleaseCount", scrap.ReleaseCount);
|
|
parameters.Add("@Lot1State", scrap.Lot1State);
|
|
parameters.Add("@Lot2State", scrap.Lot2State);
|
|
parameters.Add("@Lot3State", scrap.Lot3State);
|
|
parameters.Add("@Lot4State", scrap.Lot4State);
|
|
parameters.Add("@Lot5State", scrap.Lot5State);
|
|
parameters.Add("@Lot6State", scrap.Lot6State);
|
|
parameters.Add("@Lot7State", scrap.Lot7State);
|
|
parameters.Add("@Lot8State", scrap.Lot8State);
|
|
parameters.Add("@Lot9State", scrap.Lot9State);
|
|
parameters.Add("@Lot10State", scrap.Lot10State);
|
|
parameters.Add("@Lot11State", scrap.Lot11State);
|
|
parameters.Add("@Lot12State", scrap.Lot12State);
|
|
parameters.Add("@Lot13State", scrap.Lot13State);
|
|
parameters.Add("@Lot14State", scrap.Lot14State);
|
|
parameters.Add("@Lot15State", scrap.Lot15State);
|
|
parameters.Add("@Lot16State", scrap.Lot16State);
|
|
parameters.Add("@Lot17State", scrap.Lot17State);
|
|
parameters.Add("@Lot18State", scrap.Lot18State);
|
|
parameters.Add("@Lot19State", scrap.Lot19State);
|
|
parameters.Add("@Lot20State", scrap.Lot20State);
|
|
parameters.Add("@Lot21State", scrap.Lot21State);
|
|
parameters.Add("@Lot22State", scrap.Lot22State);
|
|
parameters.Add("@Lot23State", scrap.Lot23State);
|
|
parameters.Add("@Lot24State", scrap.Lot24State);
|
|
parameters.Add("@Lot25State", scrap.Lot25State);
|
|
parameters.Add("@Lot26State", scrap.Lot26State);
|
|
parameters.Add("@Lot27State", scrap.Lot27State);
|
|
parameters.Add("@Lot28State", scrap.Lot28State);
|
|
parameters.Add("@Lot29State", scrap.Lot29State);
|
|
parameters.Add("@Lot30State", scrap.Lot30State);
|
|
parameters.Add("@Lot31State", scrap.Lot31State);
|
|
parameters.Add("@Lot32State", scrap.Lot32State);
|
|
parameters.Add("@Lot33State", scrap.Lot33State);
|
|
parameters.Add("@Lot34State", scrap.Lot34State);
|
|
parameters.Add("@Lot35State", scrap.Lot35State);
|
|
parameters.Add("@Lot36State", scrap.Lot36State);
|
|
parameters.Add("@Lot37State", scrap.Lot37State);
|
|
parameters.Add("@Lot38State", scrap.Lot38State);
|
|
parameters.Add("@Lot39State", scrap.Lot39State);
|
|
parameters.Add("@Lot40State", scrap.Lot40State);
|
|
parameters.Add("@Lot41State", scrap.Lot41State);
|
|
parameters.Add("@Lot42State", scrap.Lot42State);
|
|
parameters.Add("@Lot43State", scrap.Lot43State);
|
|
parameters.Add("@Lot44State", scrap.Lot44State);
|
|
parameters.Add("@Lot45State", scrap.Lot45State);
|
|
parameters.Add("@Lot46State", scrap.Lot46State);
|
|
parameters.Add("@Lot47State", scrap.Lot47State);
|
|
parameters.Add("@Lot48State", scrap.Lot48State);
|
|
parameters.Add("@Lot49State", scrap.Lot49State);
|
|
parameters.Add("@Lot50State", scrap.Lot50State);
|
|
|
|
db.Execute(qryInsert.ToString(), parameters, commandType: CommandType.Text);
|
|
}
|
|
|
|
public void UpdateLotStatus(ScrapLot lotStatus) {
|
|
//if all the wafers in a lot is either "RELEASE" or "SCRAP" from the "SELECT WAFERS SCREEN" set the Lot Status Option accodingly for the particula lot
|
|
int tempLotStatus;
|
|
if ((lotStatus.ReleaseCount == lotStatus.WaferCount || lotStatus.ScrapCount == lotStatus.WaferCount) && (lotStatus.ReleaseCount > 0 || lotStatus.WaferCount > 0)) {
|
|
// set the LotStatus appropriately because the entire lot either is set to "RELEASE" or "SCRAP"'
|
|
tempLotStatus = lotStatus.ReleaseCount == lotStatus.WaferCount ? (int)GlobalVars.LotStatusOption.Release : (int)GlobalVars.LotStatusOption.Scrap;
|
|
|
|
// Close to QDB is count as "Release"
|
|
if ((lotStatus.CloseToQDBCount == lotStatus.WaferCount) && (lotStatus.CloseToQDBCount > 0 || lotStatus.WaferCount > 0)) {
|
|
tempLotStatus = (int)GlobalVars.LotStatusOption.CloseToQDB;
|
|
}
|
|
} else if ((lotStatus.SplitOfHoldCount == lotStatus.WaferCount) && (lotStatus.SplitOfHoldCount > 0 || lotStatus.WaferCount > 0)) {
|
|
tempLotStatus = (int)GlobalVars.LotStatusOption.SplitOffHold;
|
|
} else {
|
|
tempLotStatus = (int)GlobalVars.LotStatusOption.Select_Wafers;
|
|
}
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@LotNo", lotStatus.LotNo);
|
|
parameters.Add("@IssueID", lotStatus.IssueID);
|
|
parameters.Add("@LotStatus", tempLotStatus);
|
|
db.Execute("UpdateLotStatus", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update the Status of all the lots for a given Lot disposition document
|
|
/// </summary>
|
|
|
|
public void UpdateLotStatusAll(ScrapLot scrap, int lotStatus) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", scrap.IssueID);
|
|
parameters.Add("@LotStatus", lotStatus);
|
|
parameters.Add("@ScrapCount", 0);
|
|
parameters.Add("@Lot1State", scrap.Lot1State);
|
|
parameters.Add("@Lot2State", scrap.Lot2State);
|
|
parameters.Add("@Lot3State", scrap.Lot3State);
|
|
parameters.Add("@Lot4State", scrap.Lot4State);
|
|
parameters.Add("@Lot5State", scrap.Lot5State);
|
|
parameters.Add("@Lot6State", scrap.Lot6State);
|
|
parameters.Add("@Lot7State", scrap.Lot7State);
|
|
parameters.Add("@Lot8State", scrap.Lot8State);
|
|
parameters.Add("@Lot9State", scrap.Lot9State);
|
|
parameters.Add("@Lot10State", scrap.Lot10State);
|
|
parameters.Add("@Lot11State", scrap.Lot11State);
|
|
parameters.Add("@Lot12State", scrap.Lot12State);
|
|
parameters.Add("@Lot13State", scrap.Lot13State);
|
|
parameters.Add("@Lot14State", scrap.Lot14State);
|
|
parameters.Add("@Lot15State", scrap.Lot15State);
|
|
parameters.Add("@Lot16State", scrap.Lot16State);
|
|
parameters.Add("@Lot17State", scrap.Lot17State);
|
|
parameters.Add("@Lot18State", scrap.Lot18State);
|
|
parameters.Add("@Lot19State", scrap.Lot19State);
|
|
parameters.Add("@Lot20State", scrap.Lot20State);
|
|
parameters.Add("@Lot21State", scrap.Lot21State);
|
|
parameters.Add("@Lot22State", scrap.Lot22State);
|
|
parameters.Add("@Lot23State", scrap.Lot23State);
|
|
parameters.Add("@Lot24State", scrap.Lot24State);
|
|
parameters.Add("@Lot25State", scrap.Lot25State);
|
|
parameters.Add("@Lot26State", scrap.Lot26State);
|
|
parameters.Add("@Lot27State", scrap.Lot27State);
|
|
parameters.Add("@Lot28State", scrap.Lot28State);
|
|
parameters.Add("@Lot29State", scrap.Lot29State);
|
|
parameters.Add("@Lot30State", scrap.Lot30State);
|
|
parameters.Add("@Lot31State", scrap.Lot31State);
|
|
parameters.Add("@Lot32State", scrap.Lot32State);
|
|
parameters.Add("@Lot33State", scrap.Lot33State);
|
|
parameters.Add("@Lot34State", scrap.Lot34State);
|
|
parameters.Add("@Lot35State", scrap.Lot35State);
|
|
parameters.Add("@Lot36State", scrap.Lot36State);
|
|
parameters.Add("@Lot37State", scrap.Lot37State);
|
|
parameters.Add("@Lot38State", scrap.Lot38State);
|
|
parameters.Add("@Lot39State", scrap.Lot39State);
|
|
parameters.Add("@Lot40State", scrap.Lot40State);
|
|
parameters.Add("@Lot41State", scrap.Lot41State);
|
|
parameters.Add("@Lot42State", scrap.Lot42State);
|
|
parameters.Add("@Lot43State", scrap.Lot43State);
|
|
parameters.Add("@Lot44State", scrap.Lot44State);
|
|
parameters.Add("@Lot45State", scrap.Lot45State);
|
|
parameters.Add("@Lot46State", scrap.Lot46State);
|
|
parameters.Add("@Lot47State", scrap.Lot47State);
|
|
parameters.Add("@Lot48State", scrap.Lot48State);
|
|
parameters.Add("@Lot49State", scrap.Lot49State);
|
|
parameters.Add("@Lot50State", scrap.Lot50State);
|
|
|
|
db.Execute("UpdateScrapLotAll", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public LotDispositionLotSummaryViewModel GetLotDispositionLotSummary(int issueID) {
|
|
StringBuilder sql = new();
|
|
sql.Append("SELECT L.WaferCount AS 'TotalWaferCount', L.DieCount AS 'TotalDieCount', L.TotalCost AS 'TotalCost', S.ScrapCount AS 'ScrapWaferCount', S.ReleaseCount AS 'ReleaseWaferCount', L.LotStatusOptionID AS 'LotStatusOption' ");
|
|
sql.Append("FROM ScrapLot S INNER JOIN Lot L ON S.IssueID = L.IssueID AND S.LotNo = L.LotNumber ");
|
|
sql.Append("WHERE S.IssueID = @issueID");
|
|
|
|
List<LotDispositionLotSummaryViewModel> LotDispositionLotList = db.Query<LotDispositionLotSummaryViewModel>(sql.ToString(), new { issueID = issueID }).ToList();
|
|
int lotCount = 0;
|
|
|
|
int totalWaferScrapCount = 0;
|
|
int totalDieScrapCount = 0;
|
|
double totalScrapCost = 0;
|
|
|
|
int totalWaferReleaseCount = 0;
|
|
int totalDieReleaseCount = 0;
|
|
double totalReleaseCost = 0;
|
|
|
|
int releaseWaferCount = 0;
|
|
double releaseCost = 0;
|
|
int releaseDieCount = 0;
|
|
|
|
int scrapWaferCount = 0;
|
|
double scrapCost = 0;
|
|
int scrapDieCount = 0;
|
|
|
|
foreach (LotDispositionLotSummaryViewModel ld in LotDispositionLotList) {
|
|
releaseWaferCount = 0;
|
|
releaseCost = 0;
|
|
releaseDieCount = 0;
|
|
|
|
scrapWaferCount = 0;
|
|
scrapCost = 0;
|
|
scrapDieCount = 0;
|
|
|
|
// Wafer===================================================================
|
|
if (ld.ScrapWaferCount > 0 && ld.TotalWaferCount > 0 && ld.TotalCost > 0) {
|
|
scrapWaferCount = ld.ScrapWaferCount;
|
|
double perWaferCost = ld.TotalCost / ld.TotalWaferCount;
|
|
scrapCost = scrapWaferCount * perWaferCost;
|
|
} else if (ld.ScrapWaferCount == 0) {
|
|
scrapWaferCount = ld.ScrapWaferCount;
|
|
scrapCost = 0;
|
|
}
|
|
|
|
if (ld.ReleaseWaferCount > 0 && ld.TotalWaferCount > 0 && ld.TotalCost > 0) {
|
|
releaseWaferCount = ld.ReleaseWaferCount;
|
|
double perWaferCost = ld.TotalCost / ld.TotalWaferCount;
|
|
releaseCost = releaseWaferCount * perWaferCost;
|
|
} else if (ld.ReleaseWaferCount == 0) {
|
|
releaseWaferCount = ld.ReleaseWaferCount;
|
|
releaseCost = 0;
|
|
}
|
|
|
|
// Die ===================================================================
|
|
if (
|
|
(ld.LotStatusOption == (int)GlobalVars.LotStatusOption.Release
|
|
|| ld.LotStatusOption == (int)GlobalVars.LotStatusOption.M_Suffix
|
|
|| ld.LotStatusOption == (int)GlobalVars.LotStatusOption.CloseToQDB)
|
|
&& ld.TotalDieCount > 0) {
|
|
releaseDieCount = ld.TotalDieCount;//
|
|
releaseCost = ld.TotalCost;
|
|
}
|
|
|
|
if (ld.LotStatusOption == (int)GlobalVars.LotStatusOption.Scrap && ld.TotalDieCount > 0) {
|
|
scrapDieCount = ld.TotalDieCount;//
|
|
scrapCost = ld.TotalCost;
|
|
}
|
|
|
|
// Summarize
|
|
lotCount++;
|
|
totalWaferScrapCount += scrapWaferCount;
|
|
totalWaferReleaseCount += releaseWaferCount;
|
|
|
|
totalDieScrapCount += scrapDieCount;
|
|
totalDieReleaseCount += releaseDieCount;
|
|
|
|
totalScrapCost += scrapCost;
|
|
totalReleaseCost += releaseCost;
|
|
}
|
|
|
|
//}
|
|
|
|
return new LotDispositionLotSummaryViewModel() {
|
|
LotCount = lotCount,
|
|
ReleaseCost = string.Format("{0:C}", totalReleaseCost),
|
|
//Math.Round(totalReleaseCost, 2).ToString(,
|
|
ReleaseWaferCount = totalWaferReleaseCount,
|
|
ReleaseDieCount = totalDieReleaseCount,
|
|
ScrapCost = string.Format("{0:C}", totalScrapCost),
|
|
//Math.Round(totalScrapCost, 2),
|
|
ScrapWaferCount = totalWaferScrapCount,
|
|
ScrapDieCount = totalDieScrapCount
|
|
|
|
};
|
|
}
|
|
|
|
public int SubmitDocument(int issueID, bool peRequired, bool mrbRequired, int userID) {
|
|
string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.LotDisposition);
|
|
|
|
// bubble the error
|
|
int appoverCount = 0;
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@UserID", userID);
|
|
parameters.Add("@PERequired", peRequired);
|
|
parameters.Add("@MRBRequired", mrbRequired);
|
|
parameters.Add("@DocumentTypeID", 1); // Lot Dispostion
|
|
parameters.Add("@SubRoleCategoriesClause", subRoles);
|
|
parameters.Add("@AppoverCount", appoverCount, dbType: DbType.Int32, direction: ParameterDirection.Output);
|
|
|
|
db.Execute("SubmitForApproval_LotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
appoverCount = parameters.Get<int>("@AppoverCount");
|
|
return appoverCount;
|
|
}
|
|
|
|
public List<string> GetRejectionOrginatorEmailList(int issueID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", issueID);
|
|
List<string> emailList = db.Query<string>("GetRejectionOrginatorEmailList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return emailList;
|
|
}
|
|
|
|
public void UpdateReasonForDisposition(int issueID, string reasonForDisposition) {
|
|
DynamicParameters parameters = new();
|
|
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@ReasonForDisposition", reasonForDisposition);
|
|
db.Execute("UpdateReasonForDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public void InsertComments(int issueID, string comments, int commentedBy) {
|
|
DynamicParameters parameters = new();
|
|
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@Comments", comments);
|
|
parameters.Add("@CommentedBy", commentedBy);
|
|
db.Execute("InsertComments", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
internal void DeleteLotDisposition(int issueID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", issueID);
|
|
db.Execute("DeleteLotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
internal IEnumerable<Comments> GetComments(int issueID) {
|
|
IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
|
|
return db.Query<Comments>("GetComments", new { @IssueID = issueID }, commandType: CommandType.StoredProcedure).ToList();
|
|
}
|
|
|
|
public void ReleaseLockOnDocument(int userID, int issueID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@UserID", userID);
|
|
db.Execute("ReleaseLockOnLotDispoDoc", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public string GetFileName(string attachmentID) {
|
|
DynamicParameters parameters = new();
|
|
parameters.Add("@AttachmentID", attachmentID);
|
|
var fileName = db.Query<string>("GetFileName", parameters, commandType: CommandType.StoredProcedure).Single();
|
|
return fileName;
|
|
}
|
|
|
|
public void AttachSave(int issueID, int userId, string fullFileName, Stream stream) {
|
|
// Some browsers send file names with full path.
|
|
// We are only interested in the file name.
|
|
var fileName = Path.GetFileName(fullFileName);
|
|
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
|
|
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "LotDisposition", fileName);
|
|
|
|
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
|
|
stream.CopyTo(fileStream);
|
|
}
|
|
Attachment attach = new() {
|
|
IssueID = issueID,
|
|
FileName = fileName,
|
|
UserID = userId,
|
|
};
|
|
InsertLotDispositionAttachment(attach);
|
|
}
|
|
|
|
public string ExcelLotOpen(int issueID, string userIdentityName, string lotTempPipeLine, string fullFileName, Stream stream) {
|
|
string physicalPath;
|
|
|
|
var fileExtension = Path.GetExtension(fullFileName);
|
|
string fName = userIdentityName + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
|
|
|
|
physicalPath = Path.Combine(lotTempPipeLine, fName + "." + fileExtension);
|
|
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
|
|
stream.CopyTo(fileStream);
|
|
}
|
|
#if !NET8
|
|
ExcelData x = new ExcelData(physicalPath);
|
|
var lotNumbers = x.ReadData();
|
|
|
|
foreach (var lotInfo in lotNumbers) {
|
|
Lot l = new Lot();
|
|
l.LotNumber = lotInfo.LotNo;
|
|
l.IssueID = issueID;
|
|
if (l.LotStatusOptionID == 0)
|
|
l.LotStatusOption.LotStatusOptionID = (int)GlobalVars.LotStatusOption.Release;
|
|
|
|
InsertLot(l, true);
|
|
//if (!mrbDMO.DoesMRBLotExist(lotInfo.LotNo))
|
|
//{
|
|
// //get All the MRBs associated to the Parent lot
|
|
// //insert the lot into the MRBChildLotNotInMRB table and NOT in the MRB Lot table for each MRB
|
|
// InsertChildLot_NotInTheMRB(lotInfo.LotNo);
|
|
|
|
//}
|
|
}
|
|
#endif
|
|
|
|
FileInfo f = new(physicalPath);
|
|
if (f.Exists)
|
|
f.Delete();
|
|
|
|
return physicalPath;
|
|
}
|
|
|
|
} |