From ff88bafa61517ccb9a5a0c08ee10ea9f98f87297 Mon Sep 17 00:00:00 2001 From: Sai Date: Wed, 6 Sep 2023 10:30:35 +0800 Subject: [PATCH] =?UTF-8?q?1.=20RPT002=20=E5=93=81=E8=B3=AA=E7=9C=8B?= =?UTF-8?q?=E6=9D=BF=E5=8A=A0=E5=85=A530=E7=A7=92=E5=A4=96=E5=8C=85?= =?UTF-8?q?=E5=BB=A0=E5=95=86=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/RPTController.cs | 25 ++++++++++++++---- AMESCoreStudio.Web/HttpApis/AMES/IRPT.cs | 2 +- AMESCoreStudio.Web/Views/RPT/RPT002.cshtml | 12 ++++++++- .../Controllers/BLL/RPTController.cs | 26 ++++++++++++------- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/RPTController.cs b/AMESCoreStudio.Web/Controllers/RPTController.cs index 31d1b5c9..8a342dbe 100644 --- a/AMESCoreStudio.Web/Controllers/RPTController.cs +++ b/AMESCoreStudio.Web/Controllers/RPTController.cs @@ -75,16 +75,30 @@ namespace AMESCoreStudio.Web.Controllers var edate = ""; var model = await _rptApi.GetRPT002View(sdate, edate); model.SerachData = DateTime.Now.ToString("yyyy/MM"); + ViewBag.werksNoSeq = 0; return View(model); } [HttpPost] - public async Task RPT002(string SerachData) + public async Task RPT002(string SerachData, int werksNoSeq) { var Data = DateTime.Parse(SerachData); var sDate = new DateTime(Data.Year, Data.Month, 1).ToString("yyyy/MM/dd"); var eDate = new DateTime(Data.Year, Data.Month, DateTime.DaysInMonth(Data.Year, Data.Month)).ToString("yyyy/MM/dd"); - var model = await _rptApi.GetRPT002View(sDate, eDate); + + var werkNo = string.Empty; + var werksNoArrsy = new List { "YS31", "YS32", "YS33", "YS34" }; + if (werksNoArrsy.Count >= werksNoSeq + 1) + { + werkNo = werksNoArrsy[werksNoSeq]; + ViewBag.werksNoSeq = werksNoSeq + 1; + } + else + { + ViewBag.werksNoSeq = 0; + } + + var model = await _rptApi.GetRPT002View(sDate, eDate, werkNo); model.SerachData = SerachData; return View(model); } @@ -1701,7 +1715,8 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task RPT003D(string year, string month, string qcRateType, string productType) { - var model = new QcRate(){ + var model = new QcRate() + { Yrer = year, Month = month, QcRateType = qcRateType, @@ -1722,9 +1737,9 @@ namespace AMESCoreStudio.Web.Controllers /// 筆數 /// [HttpGet] - public async Task RPT003Query(string year , string month , string qcRateType,string productType, int page = 0, int limit = 10) + public async Task RPT003Query(string year, string month, string qcRateType, string productType, int page = 0, int limit = 10) { - IResultModel result = await _rptApi.GetQcRatesQuery(year,month,qcRateType,productType,page,limit); + IResultModel result = await _rptApi.GetQcRatesQuery(year, month, qcRateType, productType, page, limit); if (result.Data.Count() != 0) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IRPT.cs b/AMESCoreStudio.Web/HttpApis/AMES/IRPT.cs index 47400e90..dbd3617c 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IRPT.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IRPT.cs @@ -25,7 +25,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/RPT/GetRPT002View")] - ITask GetRPT002View(string sDate, string eDate); + ITask GetRPT002View(string sDate, string eDate ,string werksNo = null); /// /// 生產看板 diff --git a/AMESCoreStudio.Web/Views/RPT/RPT002.cshtml b/AMESCoreStudio.Web/Views/RPT/RPT002.cshtml index 7d376420..ee8fbde0 100644 --- a/AMESCoreStudio.Web/Views/RPT/RPT002.cshtml +++ b/AMESCoreStudio.Web/Views/RPT/RPT002.cshtml @@ -77,7 +77,9 @@
-
+ + +
@@ -345,5 +347,13 @@ , theme: 'grid' }); }); + + // 自動提交 + function autoSubmitForm() { + document.getElementById('rpt002Form').submit(); + } + + // 每30秒執行autoSubmitForm + setInterval(autoSubmitForm, 30000); } \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/RPTController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/RPTController.cs index d14c51e5..c74f4833 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/RPTController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/RPTController.cs @@ -435,7 +435,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL return result; } - private (int iIPQC_Fail_Total,int iIPQC_Fail) Get_IPQC_Rate(string sDate, string eDate) + private (int iIPQC_Fail_Total, int iIPQC_Fail) Get_IPQC_Rate(string sDate, string eDate) { var e = new InspectionResultMastersController(_context).GetIPQCHeaderData4QRS015(null, null, null, sDate, eDate); @@ -512,7 +512,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL /// 月 /// 電子或機構 /// - private async Task Get_IQC_Rate(string MEDICAL, string C_YEAR,string C_MONTH, string PARTTYPE) + private async Task Get_IQC_Rate(string MEDICAL, string C_YEAR, string C_MONTH, string PARTTYPE) { #region IQC進料批退 SMSContext _SMS_context = new SMSContext(); @@ -582,7 +582,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL DbConnection conn = _SMS_context.Database.GetDbConnection(); if (conn.State != ConnectionState.Open) { - await conn.OpenAsync(); + await conn.OpenAsync(); } string sMS_SQL = @" SELECT M1.THE_YEAR,M1.THE_MONTH,M1.MONTH_OF_YEAR,ISNULL(M2.QTY, 0) FLAG_3,ISNULL(M3.QTY, 0) FLAG_4"; @@ -644,7 +644,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL var dRate2 = dtSMS_TB.Select("MONTH_OF_YEAR='" + C_MONTH + "'")[0]["FLAG_4"]; int iTotal = 0; - for(int i= 1; i<=12; i++) + for (int i = 1; i <= 12; i++) { iTotal = iTotal + int.Parse(dtSMS_TB.Select("MONTH_OF_YEAR='" + i.ToString() + "'")[0]["FLAG_3"].ToString()); } @@ -708,7 +708,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL sMS_SQL += " ) M"; sMS_SQL += " GROUP BY M.C_YEAR,M.C_MONTH"; sMS_SQL += " UNION "; - sMS_SQL += " SELECT M1.C_YEAR,M1.C_MONTH,'OnTimeCloseRate' FLAG_DESC, 4 FLAG_SEQ "; + sMS_SQL += " SELECT M1.C_YEAR,M1.C_MONTH,'OnTimeCloseRate' FLAG_DESC, 4 FLAG_SEQ "; sMS_SQL += " ,(CASE WHEN M1.Sub_Total_Qty >0 THEN cast(round(ISNULL(M2.Less_Days_Qty,0)*100.0/M1.Sub_Total_Qty,0) as int) ELSE 0 END) Rate"; //四舍五入取整 sMS_SQL += " FROM "; sMS_SQL += " ( SELECT M.C_YEAR,M.C_MONTH,COUNT(M.CAR_NUMBER) Sub_Total_Qty"; @@ -859,9 +859,10 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL ///
/// 開始日期 /// 結束日期 + /// 外包廠商代號 /// [HttpGet("GetRPT002View")] - public async Task GetRPT002View(string sDate, string eDate) + public async Task GetRPT002View(string sDate, string eDate, string werksNo) { if (string.IsNullOrWhiteSpace(sDate) || string.IsNullOrWhiteSpace(eDate)) { @@ -869,6 +870,11 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL eDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)).ToString("yyyy/MM/dd"); } + if (string.IsNullOrWhiteSpace(werksNo)) + { + werksNo = "YS31"; + } + var result = new RPT002ViewDto(); var vYear = DateTime.Parse(sDate).Year; @@ -959,7 +965,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL // DOA Board //result.DOABoard = 0.04; - sReturn_Data = await Get_QC_Rate(vYear.ToString(), vMonth.ToString(),"DOA"); + sReturn_Data = await Get_QC_Rate(vYear.ToString(), vMonth.ToString(), "DOA"); sData_Ary = sReturn_Data.Split("|"); result.DOABoard = double.Parse(sData_Ary[0].ToString()); @@ -1289,7 +1295,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL // FPY Board #region 立德 委外 Board //result.FPYBoard = 100.00; - var f_FPYBoard = await new WipStationController(_context).GetWipStation4QRS014GroupB(null, sDate, eDate, null, "YS31", null); + var f_FPYBoard = await new WipStationController(_context).GetWipStation4QRS014GroupB(null, sDate, eDate, null, werksNo, null); if (f_FPYBoard.DataTotal > 0) { double sum_rate = 100.0; @@ -1394,7 +1400,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL // FPY System #region 立德 委外 System //result.FPYSystem = 99.12; - var f_FPYSystem = await new WipStationController(_context).GetWipStation4QRS014GroupS(null, sDate, eDate, null, "YS31", null); + var f_FPYSystem = await new WipStationController(_context).GetWipStation4QRS014GroupS(null, sDate, eDate, null, werksNo, null); if (f_FPYSystem.DataTotal > 0) { double sum_rate = 100.0; @@ -1499,7 +1505,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL // FPY Medical #region 立德 委外 Medical //result.FPYMedical = 12.12; - var f_FPYMedical = await new WipStationController(_context).GetWipStation4QRS014GroupS(null, sDate, eDate, null, "YS31", null); + var f_FPYMedical = await new WipStationController(_context).GetWipStation4QRS014GroupS(null, sDate, eDate, null, werksNo, null); if (f_FPYMedical.DataTotal > 0) { double sum_rate = 100.0;