|
|
@ -1210,6 +1210,9 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
if (model.QaResult == "P") |
|
|
|
await _fqcApi.PassingByFQC(model.InhouseNo, model.SeqID, GetLogInUserID()); |
|
|
|
|
|
|
|
//FQC報表自動派送
|
|
|
|
await CheckFQCToMail(fqcInhouseMaster.ItemNo, model.QaResult, model.InhouseNo, model.SeqID); |
|
|
|
|
|
|
|
var _msg = "新增成功!"; |
|
|
|
return RedirectToAction("WindowReload", "Home", new { msg = _msg }); |
|
|
|
} |
|
|
@ -1222,6 +1225,60 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 自動寄信
|
|
|
|
/// <summary>
|
|
|
|
/// 判斷是否設定FQC自動自動寄信
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="Material">料號</param>
|
|
|
|
/// <param name="Result">抽驗結果</param>
|
|
|
|
/// <param name="inhouseNo">FQC單號</param>
|
|
|
|
/// <param name="seqID">FQC單號_編號</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckFQCToMail(string Material, string Result, string inhouseNo, int seqID) |
|
|
|
{ |
|
|
|
var result = await _fqcApi.GetFqcNoticeMailQuery(material: Material, fqcResult: Result, status: "Y"); |
|
|
|
if (result.Data.Count() != 0) |
|
|
|
{ |
|
|
|
var MailGroup = result.Data.Select(s => s.MailGroup).ToArray(); |
|
|
|
// 檔案上傳 到暫存區
|
|
|
|
string FileName = $"{inhouseNo}_{seqID} {DateTime.Now:yyyyMMddHHmm}.xls"; |
|
|
|
string NewName = string.Empty; |
|
|
|
string FilePath = string.Empty; |
|
|
|
//取得使用者上傳檔案的原始檔名
|
|
|
|
//取原始檔名中的副檔名
|
|
|
|
//var fileExt = Path.GetExtension(FileName);
|
|
|
|
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
|
|
|
|
//NewName = Path.GetRandomFileName() + fileExt;
|
|
|
|
//指定要寫入的路徑、檔名和副檔名
|
|
|
|
FilePath = $@"{_env.WebRootPath}\UploadFolder\FQC\Temp"; |
|
|
|
var path = $@"{FilePath}\{FileName}"; |
|
|
|
|
|
|
|
if (!Directory.Exists(FilePath)) |
|
|
|
{ |
|
|
|
Directory.CreateDirectory(FilePath); |
|
|
|
} |
|
|
|
|
|
|
|
string mimeType = ""; |
|
|
|
int extension = 1; |
|
|
|
Dictionary<string, string> param = new Dictionary<string, string>(); |
|
|
|
var localReport = GetReprot(inhouseNo, seqID); |
|
|
|
var reportResult = localReport.Result.Execute(RenderType.Excel, extension, param, mimeType); |
|
|
|
|
|
|
|
using (var stream = new FileStream(path, FileMode.Create)) |
|
|
|
{ |
|
|
|
await stream.WriteAsync(reportResult.MainStream, 0, reportResult.MainStream.Length); |
|
|
|
} |
|
|
|
|
|
|
|
Result = Result == "P" ? "允收" : "驗退"; |
|
|
|
string Subject = $"FQC自動派送發信 FQC單號:{inhouseNo} 料號:{Material}"; |
|
|
|
string Body = $@"FQC單號:{inhouseNo} 料號:{Material} <br/>
|
|
|
|
檢驗結果為:{Result}";
|
|
|
|
|
|
|
|
await _bllApi.PostToMail(Subject, Body, string.Join(',', MailGroup) , "", false, path); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 附件
|
|
|
|
[HttpGet] |
|
|
|
public async Task<IActionResult> FQC007D(int fqc) |
|
|
@ -1294,7 +1351,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ModelState.AddModelError("error", "ssddf"); |
|
|
|
ModelState.AddModelError("error", "請確認是否夾帶檔案"); |
|
|
|
} |
|
|
|
model.fqcResultMasterBlobs = await _fqcApi.GetFqcResultMasterBlobByFqcID(model.FqcID); |
|
|
|
return View("FQC007D", model); |
|
|
@ -1519,133 +1576,38 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
{ |
|
|
|
string mimeType = ""; |
|
|
|
int extension = 1; |
|
|
|
var path = $"{this._env.WebRootPath}\\Reports\\FQC010View.rdlc"; |
|
|
|
LocalReport localReport = new LocalReport(path); |
|
|
|
Dictionary<string, string> param = new Dictionary<string, string>(); |
|
|
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); |
|
|
|
System.Text.Encoding.GetEncoding(1252); |
|
|
|
var FQC010Master = new FQC010VIiew(); |
|
|
|
IResultModel<FqcDto> resultFqcQuery; |
|
|
|
resultFqcQuery = _fqcApi.GetFqcQuery(inhouseNo, seqID).InvokeAsync().Result; |
|
|
|
|
|
|
|
if (resultFqcQuery.Data.Count() != 0) |
|
|
|
{ |
|
|
|
var FqcQuery = resultFqcQuery.Data.FirstOrDefault(); |
|
|
|
// Enum 轉換
|
|
|
|
FqcQuery.AQLType = EnumFQC.GetDisplayName((EnumFQC.EnumAQL_Type)Enum.Parse(typeof(EnumFQC.EnumAQL_Type), FqcQuery.AQLType)); |
|
|
|
FqcQuery.InspectionStatus = EnumFQC.GetDisplayName((EnumFQC.EnumInspection_Status)Enum.Parse(typeof(EnumFQC.EnumInspection_Status), FqcQuery.InspectionStatus)); |
|
|
|
|
|
|
|
FQC010Master = new FQC010VIiew() |
|
|
|
{ |
|
|
|
DefectDescription = FqcQuery.QaMeno, |
|
|
|
InspectionDate = FqcQuery.EndTime, |
|
|
|
AC = FqcQuery.AcQty.ToString(), |
|
|
|
Approved = FqcQuery.Supervisor_Name, |
|
|
|
AQL = FqcQuery.AQL.ToString(), |
|
|
|
SpeciallyAdoption = FqcQuery.SpecialPo, |
|
|
|
BIOSVer = FqcQuery.BIOS, |
|
|
|
ECN = FqcQuery.PLMECN, |
|
|
|
ECNMemo = FqcQuery.ECN_Memo, |
|
|
|
Factory = FqcQuery.Werk.Split('-')[0], |
|
|
|
FactoryRemark = FqcQuery.Werk.Split('-')[1], |
|
|
|
InspectionInstrumentNumber = FqcQuery.OutfitNo, |
|
|
|
InspectionItems = $"OS:[{FqcQuery.OS}] CPU test:[{FqcQuery.CPU}] RAM test:[{FqcQuery.RAM}]", |
|
|
|
InspectionNumber = FqcQuery.InhouseNo, |
|
|
|
InspectionStatus = FqcQuery.InspectionStatus, |
|
|
|
InspectionType = FqcQuery.InspectionTypeName, |
|
|
|
Inspector = FqcQuery.UpdateUser_Name, |
|
|
|
Judgment = "Defect Quantity", |
|
|
|
Line = FqcQuery.InhouseMemo, |
|
|
|
LotSize = FqcQuery.InhouseQty.ToString(), |
|
|
|
Major = FqcQuery.MajorQty.ToString(), |
|
|
|
MedicalModel = FqcQuery.CustomerMedical, |
|
|
|
Minor = FqcQuery.MinorQty.ToString(), |
|
|
|
Model = FqcQuery.ItemNo, |
|
|
|
ModelName = FqcQuery.ModelNo, |
|
|
|
NOTE = FqcQuery.Note, |
|
|
|
OrderNumber = FqcQuery.WipNo, |
|
|
|
QuotDescription = FqcQuery.QuotDescription, |
|
|
|
ReMajor = FqcQuery.ReQty.ToString(), |
|
|
|
Sample = FqcQuery.QcQty.ToString(), |
|
|
|
QuotName = FqcQuery.QuotName, |
|
|
|
//StorageLocation = "9000",
|
|
|
|
Avalue = "AVALUE", |
|
|
|
VIP = FqcQuery.CustomerVIP, |
|
|
|
WaiveRequisition = FqcQuery.StatusName, |
|
|
|
AQLType = FqcQuery.AQLType |
|
|
|
}; |
|
|
|
|
|
|
|
// 抓全部檢驗工項
|
|
|
|
var result_QcItem = await _fqcApi.GetQcItemQuery(0, 0, 0); |
|
|
|
// 取綁定工單檢驗工項資料
|
|
|
|
var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(FqcQuery.WipNo); |
|
|
|
if (result_WipFQC.Count == 0) |
|
|
|
{ |
|
|
|
//工單無設定檢驗工項時 在抓料號綁定檢驗工項
|
|
|
|
var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(FqcQuery.ItemNo); |
|
|
|
if (result_MaterialFQC.Count != 0) |
|
|
|
{ |
|
|
|
// 檢驗工項
|
|
|
|
foreach (var item in result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList()) |
|
|
|
{ |
|
|
|
FQC010Master.Detail1.Add(new FQC010Detail1 |
|
|
|
{ |
|
|
|
ItemID = item.ItemID.ToString(), |
|
|
|
ItemName = item.ItemNameCN, |
|
|
|
ItemType = item.ItemTypeName |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// 檢驗工項
|
|
|
|
foreach (var item in result_QcItem.Data.Where(w => result_WipFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList()) |
|
|
|
{ |
|
|
|
FQC010Master.Detail1.Add(new FQC010Detail1 |
|
|
|
{ |
|
|
|
ItemID = item.ItemID.ToString(), |
|
|
|
ItemName = item.ItemNameCN, |
|
|
|
ItemType = item.ItemTypeName |
|
|
|
}); |
|
|
|
} |
|
|
|
var localReport = GetReprot(inhouseNo, seqID); |
|
|
|
var result = localReport.Result.Execute(RenderType.Pdf, extension, param, mimeType); |
|
|
|
return File(result.MainStream, "application/pdf"); |
|
|
|
} |
|
|
|
|
|
|
|
// 條碼細項
|
|
|
|
var fqcDetail = await _fqcApi.FQC007InhouseDetails(FqcQuery.InhouseNo, Convert.ToInt32(FqcQuery.SeqID)); |
|
|
|
foreach (var item in fqcDetail.Data) |
|
|
|
{ |
|
|
|
FQC010Master.Detail2.Add(new FQC010Detail2 |
|
|
|
public async Task<IActionResult> FQC010_Excel(string inhouseNo, int seqID) |
|
|
|
{ |
|
|
|
ProductionSerialNumber = item.BarcodeNo, |
|
|
|
ShippingSerialNumber = item.ExtraBarcodeNo, |
|
|
|
IsSample = item.IsSample, |
|
|
|
InspectionResults = item.StatusNo |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var FQC010Masters = new List<FQC010VIiew>(); |
|
|
|
FQC010Masters.Add(FQC010Master); |
|
|
|
string mimeType = ""; |
|
|
|
int extension = 1; |
|
|
|
Dictionary<string, string> param = new Dictionary<string, string>(); |
|
|
|
var localReport = GetReprot(inhouseNo, seqID); |
|
|
|
var result = localReport.Result.Execute(RenderType.Excel, extension, param, mimeType); |
|
|
|
return File(result.MainStream, "application/msexcel", "Export.xls"); |
|
|
|
//return File(result.MainStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Export.xlsx");
|
|
|
|
|
|
|
|
localReport.AddDataSource("DataSet1", FQC010Masters); |
|
|
|
localReport.AddDataSource("DataSet2", FQC010Master.Detail1); |
|
|
|
localReport.AddDataSource("DataSet3", FQC010Master.Detail2); |
|
|
|
|
|
|
|
var result = localReport.Execute(RenderType.Pdf, extension, param, mimeType); |
|
|
|
return File(result.MainStream, "application/pdf"); |
|
|
|
|
|
|
|
//var result = localReport.Execute(RenderType.Excel, extension, param, mimeType);
|
|
|
|
//return File(result.MainStream, "application/msexcel", "Export.xls");
|
|
|
|
} |
|
|
|
|
|
|
|
public async Task<IActionResult> FQC010_Excel(string inhouseNo, int seqID) |
|
|
|
/// <summary>
|
|
|
|
/// 產生FQC報表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="inhouseNo">FQC單號</param>
|
|
|
|
/// <param name="seqID">FQC單號_編號</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<LocalReport> GetReprot(string inhouseNo, int seqID) |
|
|
|
{ |
|
|
|
string mimeType = ""; |
|
|
|
int extension = 1; |
|
|
|
var path = $"{this._env.WebRootPath}\\Reports\\FQC010View.rdlc"; |
|
|
|
LocalReport localReport = new LocalReport(path); |
|
|
|
Dictionary<string, string> param = new Dictionary<string, string>(); |
|
|
|
|
|
|
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); |
|
|
|
System.Text.Encoding.GetEncoding(1252); |
|
|
|
var FQC010Master = new FQC010VIiew(); |
|
|
@ -1756,12 +1718,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
localReport.AddDataSource("DataSet2", FQC010Master.Detail1); |
|
|
|
localReport.AddDataSource("DataSet3", FQC010Master.Detail2); |
|
|
|
|
|
|
|
//var result = localReport.Execute(RenderType.Pdf, extension, param, mimeType);
|
|
|
|
//return File(result.MainStream, "application/pdf");
|
|
|
|
|
|
|
|
var result = localReport.Execute(RenderType.Excel, extension, param, mimeType); |
|
|
|
await _bllApi.PostToMail("主旨", "內容", "", "raylin@hotmail.com", false, result.MainStream); |
|
|
|
return File(result.MainStream, "application/msexcel", "Export.xls"); |
|
|
|
return localReport; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|