|
|
@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore; |
|
|
|
using AMESCoreStudio.WebApi; |
|
|
|
using AMESCoreStudio.WebApi.Models.AMES; |
|
|
|
using AMESCoreStudio.CommonTools.Result; |
|
|
|
using AMESCoreStudio.WebApi.DTO; |
|
|
|
|
|
|
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
{ |
|
|
@ -47,7 +48,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
/// <param name="seq">序號</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("ByInhouseNo/{inhouseNo}/{seq}")] |
|
|
|
public async Task<ActionResult<IEnumerable<FqcResultMaster>>> GetFqcResultMasterByInhouseNo(string inhouseNo , int seq) |
|
|
|
public async Task<ActionResult<IEnumerable<FqcResultMaster>>> GetFqcResultMasterByInhouseNo(string inhouseNo, int seq) |
|
|
|
{ |
|
|
|
var fqcResultMaster = await _context.FqcResultMasters |
|
|
|
.Where(w => w.InhouseNo == inhouseNo && w.SeqID == seq) |
|
|
@ -67,11 +68,12 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
/// <returns></returns>
|
|
|
|
[Route("[action]")]
|
|
|
|
[HttpGet] |
|
|
|
public async Task<ResultModel<dynamic>> GetFQCHeaderData4QRS016(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd) |
|
|
|
public async Task<ResultModel<dynamic>> GetFQCHeaderData4QRS016(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd ,string factoryID) |
|
|
|
{ |
|
|
|
ResultModel<dynamic> result = new ResultModel<dynamic>(); |
|
|
|
var q = from q1 in _context.FqcResultMasters |
|
|
|
join q2 in _context.CalendarTables on q1.CreateDate.Date equals q2.TimeID |
|
|
|
join q3 in _context.WipInfos on q1.WipNo equals q3.WipNO |
|
|
|
select new |
|
|
|
{ |
|
|
|
q1.FqcID, |
|
|
@ -83,7 +85,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
q1.PassQty, |
|
|
|
q1.FailQty, |
|
|
|
q1.QaResult, |
|
|
|
q2.WeekOfYear |
|
|
|
q2.WeekOfYear, |
|
|
|
q3.Werks |
|
|
|
}; |
|
|
|
|
|
|
|
if (wipNO != null && wipNO != "") |
|
|
@ -98,6 +101,10 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
{ |
|
|
|
q = q.Where(w => w.ModelNo == modelNO); |
|
|
|
} |
|
|
|
if (factoryID != null && factoryID != "") |
|
|
|
{ |
|
|
|
q = q.Where(w => w.Werks == factoryID); |
|
|
|
} |
|
|
|
if (dateStart != null && dateStart != "" && dateEnd != null && dateEnd != "") |
|
|
|
{ |
|
|
|
q = q.Where(w => w.CreateDate >= DateTime.Parse(dateStart + " 00:00:00") && w.CreateDate <= DateTime.Parse(dateEnd + " 23:59:59")); |
|
|
@ -145,6 +152,123 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// FQC查詢報表QRS016 細項統計
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[Route("[action]")]
|
|
|
|
[HttpGet] |
|
|
|
public async Task<ResultModel<DTO.AMES.QRS016Detail>> GetFQCHeaderData4QRS016ByDetail(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd, string factoryID) |
|
|
|
{ |
|
|
|
ResultModel<DTO.AMES.QRS016Detail> result = new ResultModel<DTO.AMES.QRS016Detail>(); |
|
|
|
var q = from q1 in _context.FqcResultMasters |
|
|
|
join q2 in _context.WipInfos on q1.WipNo equals q2.WipNO |
|
|
|
select new DTO.AMES.QRS016Detail |
|
|
|
{ |
|
|
|
wipNo = q1.WipNo, |
|
|
|
itemNo = q1.ItemNo, |
|
|
|
modelNo = q1.ModelNo, |
|
|
|
werks = q2.Werks, |
|
|
|
startTime = q1.StartTime, |
|
|
|
qaResult = q1.QaResult, |
|
|
|
customerMedical = q2.CustomerMedical, |
|
|
|
unitNo = q2.UnitNO |
|
|
|
}; |
|
|
|
|
|
|
|
if (wipNO != null && wipNO != "") |
|
|
|
{ |
|
|
|
q = q.Where(w => w.wipNo.Trim().ToUpper() == wipNO.Trim().ToUpper()); |
|
|
|
} |
|
|
|
if (itemNO != null && itemNO != "") |
|
|
|
{ |
|
|
|
q = q.Where(w => w.itemNo.Trim().ToUpper() == itemNO.Trim().ToUpper()); |
|
|
|
} |
|
|
|
if (modelNO != null && modelNO != "") |
|
|
|
{ |
|
|
|
q = q.Where(w => w.modelNo.Trim().ToUpper() == modelNO.Trim().ToUpper()); |
|
|
|
} |
|
|
|
|
|
|
|
if (factoryID != null && factoryID != "") |
|
|
|
{ |
|
|
|
q = q.Where(w => w.werks == factoryID); |
|
|
|
} |
|
|
|
|
|
|
|
if (dateStart != null && dateStart != "" && dateEnd != null && dateEnd != "") |
|
|
|
{ |
|
|
|
q = q.Where(w => w.startTime >= DateTime.Parse(dateStart + " 00:00:00") && w.startTime <= DateTime.Parse(dateEnd + " 23:59:59")); |
|
|
|
} |
|
|
|
|
|
|
|
var query = new List<DTO.AMES.QRS016Detail>(); |
|
|
|
int allQty = 0; |
|
|
|
int passQty = 0; |
|
|
|
int failQty = 0; |
|
|
|
double rejectRate = 0; |
|
|
|
|
|
|
|
// 醫療
|
|
|
|
var data = q.Where(w => w.customerMedical == "Y").ToList(); |
|
|
|
allQty = data.Count(); |
|
|
|
passQty = data.Where(w => w.qaResult == "P").Count(); |
|
|
|
failQty = data.Where(w => w.qaResult == "R").Count(); |
|
|
|
rejectRate = failQty == 0 ? 0 : Math.Round(((double)failQty / (double)allQty), 2, MidpointRounding.AwayFromZero) * 100; |
|
|
|
|
|
|
|
query.Add(new DTO.AMES.QRS016Detail |
|
|
|
{ |
|
|
|
type = "醫療", |
|
|
|
allQty = allQty, |
|
|
|
passQty = passQty, |
|
|
|
failQty = failQty, |
|
|
|
rejectRate = rejectRate |
|
|
|
}); |
|
|
|
|
|
|
|
// 系統組裝
|
|
|
|
data.Clear(); |
|
|
|
data = q.Where(w => w.customerMedical == "N" && w.unitNo == "B").ToList(); |
|
|
|
allQty = data.Count(); |
|
|
|
passQty = data.Where(w => w.qaResult == "P").Count(); |
|
|
|
failQty = data.Where(w => w.qaResult == "R").Count(); |
|
|
|
rejectRate = failQty == 0 ? 0 : Math.Round(((double)failQty / (double)allQty), 2, MidpointRounding.AwayFromZero) * 100; |
|
|
|
query.Add(new DTO.AMES.QRS016Detail |
|
|
|
{ |
|
|
|
type = "系統組裝", |
|
|
|
allQty = allQty, |
|
|
|
passQty = passQty, |
|
|
|
failQty = failQty, |
|
|
|
rejectRate = rejectRate |
|
|
|
}); |
|
|
|
|
|
|
|
// 單板
|
|
|
|
data.Clear(); |
|
|
|
data = q.Where(w => w.customerMedical == "N" && w.unitNo == "S").ToList(); |
|
|
|
allQty = data.Count(); |
|
|
|
passQty = data.Where(w => w.qaResult == "P").Count(); |
|
|
|
failQty = data.Where(w => w.qaResult == "R").Count(); |
|
|
|
rejectRate = failQty == 0 ? 0 : Math.Round(((double)failQty / (double)allQty), 2, MidpointRounding.AwayFromZero) * 100; |
|
|
|
query.Add(new DTO.AMES.QRS016Detail |
|
|
|
{ |
|
|
|
type = "單板", |
|
|
|
allQty = allQty, |
|
|
|
passQty = passQty, |
|
|
|
failQty = failQty, |
|
|
|
rejectRate = rejectRate |
|
|
|
}); |
|
|
|
|
|
|
|
//紀錄筆數
|
|
|
|
result.DataTotal = query.Count(); |
|
|
|
|
|
|
|
result.Data = query; |
|
|
|
|
|
|
|
if (query.Count == 0) |
|
|
|
{ |
|
|
|
result.Msg = "查無資料"; |
|
|
|
result.Success = false; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
result.Success = true; |
|
|
|
result.Msg = "OK"; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 查詢FQC明細資料
|
|
|
|
/// </summary>
|
|
|
|