+
+
@@ -90,8 +100,10 @@
var wipNO = $("#wipNO").val();
var dateStart = $("#dateStart").val();
var dateEnd = $("#dateEnd").val();
+ var factoryID = $("#factoryID").val();
+ var factoryName = $("#factoryID option:selected").text();
- var query = "?modelNO=" + modelNO + "&itemNO=" + itemNO + "&wipNO=" + wipNO + "&dateStart=" + dateStart + "&dateEnd=" + dateEnd;
+ var query = "?modelNO=" + modelNO + "&itemNO=" + itemNO + "&wipNO=" + wipNO + "&dateStart=" + dateStart + "&dateEnd=" + dateEnd + "&factoryID=" + factoryID + "&factoryName=" + factoryName;
hg.open('FQC查詢報表', '/QRS/QRS016A' + query, '', '', true);
};
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs
index 16a8fe3d..a0ae044b 100644
--- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs
@@ -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
///
序號
///
[HttpGet("ByInhouseNo/{inhouseNo}/{seq}")]
- public async Task
>> GetFqcResultMasterByInhouseNo(string inhouseNo , int seq)
+ public async Task>> 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
///
[Route("[action]")]
[HttpGet]
- public async Task> GetFQCHeaderData4QRS016(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd)
+ public async Task> GetFQCHeaderData4QRS016(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd ,string factoryID)
{
ResultModel result = new ResultModel();
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;
}
+ ///
+ /// FQC查詢報表QRS016 細項統計
+ ///
+ ///
+ [Route("[action]")]
+ [HttpGet]
+ public async Task> GetFQCHeaderData4QRS016ByDetail(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd, string factoryID)
+ {
+ ResultModel result = new ResultModel();
+ 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();
+ 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;
+ }
+
///
/// 查詢FQC明細資料
///