diff --git a/AMESCoreStudio.Web/Views/REP/REP012.cshtml b/AMESCoreStudio.Web/Views/REP/REP012.cshtml
index 05eed3f7..1322f251 100644
--- a/AMESCoreStudio.Web/Views/REP/REP012.cshtml
+++ b/AMESCoreStudio.Web/Views/REP/REP012.cshtml
@@ -244,6 +244,8 @@
'unitNO',
'lineDesc',
'createDate',
+ 'month',
+ 'weekOfYearISO',
'stationName',
'wipNO',
'planQTY',
@@ -284,7 +286,7 @@
]);
data.unshift({
- unitNO: "製程單位", lineDesc: "線別", createDate: "維修時間", stationName: "站別", wipNO: "工單號碼", planQTY: "數量", barcodeNo: "條碼", modelNO: "機種", itemNO: "料號", semiItemNo: "半成品料號", oldPartNo: "舊料號", newPartNo: "新料號",
+ unitNO: "製程單位", lineDesc: "線別", createDate: "維修時間", month: "月份", weekOfYearISO: "第幾週", stationName: "站別", wipNO: "工單號碼", planQTY: "數量", barcodeNo: "條碼", modelNO: "機種", itemNO: "料號", semiItemNo: "半成品料號", oldPartNo: "舊料號", newPartNo: "新料號",
ngNo: "不良代碼", reasonDesc: "不良描述", locationNo: "維修位置", changeMaterial: "更換零件", repairReason: "維修原因", repairType2: "維修類別", memo: "維修備註", repairDesc: "維修描述",
ngType2: "不良類別", rrDesc: "不良責任類別", userNo: "維修工號", userName: "維修人員", replyDate: "回覆時間", testDate: "測試時間", testUserNo: "測試工號", testUserName: "測試人員"
, testTypeName: "測試類別", qaTypeName: "QA類別", ngReasonDescEn: "英文不良描述", partNo: "零件料號", pinNo: "腳位", reelNo: "料卷號"
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/CalendarTablesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/CalendarTablesController.cs
new file mode 100644
index 00000000..b1bca939
--- /dev/null
+++ b/AMESCoreStudio.WebApi/Controllers/AMES/CalendarTablesController.cs
@@ -0,0 +1,156 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using AMESCoreStudio.WebApi;
+using AMESCoreStudio.WebApi.Models.AMES;
+
+namespace AMESCoreStudio.WebApi.Controllers.AMES
+{
+ ///
+ ///
+ ///
+ [Route("api/[controller]")]
+ [ApiController]
+ public class CalendarTablesController : ControllerBase
+ {
+ private readonly AMESContext _context;
+
+ ///
+ ///
+ ///
+ ///
+ public CalendarTablesController(AMESContext context)
+ {
+ _context = context;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ // GET: api/CalendarTables
+ [HttpGet]
+ public async Task>> GetCalendarTable()
+ {
+ return await _context.CalendarTables.ToListAsync();
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ // GET: api/CalendarTables/5
+ [HttpGet("{id}")]
+ public async Task> GetCalendarTable(DateTime id)
+ {
+ var calendarTable = await _context.CalendarTables.FindAsync(id);
+
+ if (calendarTable == null)
+ {
+ return NotFound();
+ }
+
+ return calendarTable;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ // PUT: api/CalendarTables/5
+ // To protect from overposting attacks, enable the specific properties you want to bind to, for
+ // more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
+ [HttpPut("{id}")]
+ public async Task PutCalendarTable(DateTime id, CalendarTable calendarTable)
+ {
+ if (id != calendarTable.TimeID)
+ {
+ return BadRequest();
+ }
+
+ _context.Entry(calendarTable).State = EntityState.Modified;
+
+ try
+ {
+ await _context.SaveChangesAsync();
+ }
+ catch (DbUpdateConcurrencyException)
+ {
+ if (!CalendarTableExists(id))
+ {
+ return NotFound();
+ }
+ else
+ {
+ throw;
+ }
+ }
+
+ return NoContent();
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ // POST: api/CalendarTables
+ // To protect from overposting attacks, enable the specific properties you want to bind to, for
+ // more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
+ [HttpPost]
+ public async Task> PostCalendarTable(CalendarTable calendarTable)
+ {
+ _context.CalendarTables.Add(calendarTable);
+ try
+ {
+ await _context.SaveChangesAsync();
+ }
+ catch (DbUpdateException)
+ {
+ if (CalendarTableExists(calendarTable.TimeID))
+ {
+ return Conflict();
+ }
+ else
+ {
+ throw;
+ }
+ }
+
+ return CreatedAtAction("GetCalendarTable", new { id = calendarTable.TimeID }, calendarTable);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ // DELETE: api/CalendarTables/5
+ [HttpDelete("{id}")]
+ public async Task> DeleteCalendarTable(DateTime id)
+ {
+ var calendarTable = await _context.CalendarTables.FindAsync(id);
+ if (calendarTable == null)
+ {
+ return NotFound();
+ }
+
+ _context.CalendarTables.Remove(calendarTable);
+ await _context.SaveChangesAsync();
+
+ return calendarTable;
+ }
+
+ private bool CalendarTableExists(DateTime id)
+ {
+ return _context.CalendarTables.Any(e => e.TimeID == id);
+ }
+ }
+}
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs
index 37067a14..d18d8255 100644
--- a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs
@@ -121,11 +121,14 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
join qf in _context.UserInfoes on q8.ReplyUserID equals qf.UserID
join qg in _context.RMAReasons on q1.RepairNo equals qg.RMAReasonNo
join qh in _context.QATypes on qg.QATypeId equals qh.QATypeID
+ join qi in _context.CalendarTables on q1.CreateDate.Date equals qi.TimeID
select new
{
q4.UnitNO,
q6.LineDesc,
q1.CreateDate,
+ qi.Month,
+ qi.WeekOfYearISO,
q7.StationName,
q4.WipNO,
q4.PlanQTY,
@@ -149,7 +152,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
qc.UserNo,
qc.UserName,
q8.ReplyDate,
- //RepairDays = (q8.ReplyDate-q2.CreateDate).TotalDays.ToString("0.00"),
+ //RepairDays = (q8.ReplyDate-q2.CreateDate).TotalDays,
TestDate = q2.CreateDate,
TestUserNo = qd.UserNo,
TestUserName = qd.UserName,
diff --git a/AMESCoreStudio.WebApi/Models/AMES/CalendarTable.cs b/AMESCoreStudio.WebApi/Models/AMES/CalendarTable.cs
new file mode 100644
index 00000000..2e4e6aa6
--- /dev/null
+++ b/AMESCoreStudio.WebApi/Models/AMES/CalendarTable.cs
@@ -0,0 +1,133 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Runtime.Serialization;
+
+namespace AMESCoreStudio.WebApi.Models.AMES
+{
+ ///
+ /// 日曆
+ ///
+ [Table("CALENDAR_TABLE", Schema = "JHAMES")]
+ public class CalendarTable
+ {
+ ///
+ /// 時間
+ ///
+ [Key]
+ [Column("TIME_ID")]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "時間")]
+ [DataMember]
+ public DateTime TimeID { get; set; }
+
+ ///
+ /// 年份
+ ///
+ [Column("YEAR")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "年份")]
+ public string Year { get; set; }
+
+ ///
+ /// 月份
+ ///
+ [Column("MONTH")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "月份")]
+ public string Month { get; set; }
+
+ ///
+ /// 日期
+ ///
+ [Column("DAY")]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "日期")]
+ [DataMember]
+ public string Day { get; set; }
+
+ ///
+ /// 月份描述
+ ///
+ [Column("MONTH_NAME")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "月份描述")]
+ public string MonthName { get; set; }
+
+ ///
+ /// 日期描述
+ ///
+ [Column("DAY_NAME")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "日期描述")]
+ public string DayName { get; set; }
+
+ ///
+ /// 當月第幾周
+ ///
+ [Column("WEEK_OF_MONTH")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "當月第幾周")]
+ public int WeekOfMonth { get; set; }
+
+ ///
+ /// 當年第幾周(ISO)
+ ///
+ [Column("WEEK_OF_YEAR_ISO")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "當年第幾周(ISO)")]
+ public int WeekOfYearISO { get; set; }
+
+ ///
+ /// 當月最後一天
+ ///
+ [Column("MONTH_END_DAY")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "當月最後一天")]
+ public DateTime MonthEndDay { get; set; }
+
+ ///
+ /// 週日期起訖
+ ///
+ [Column("WEEK_RANGE")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "週日期起訖")]
+ public string WeekRange { get; set; }
+
+ ///
+ /// 當年第幾周
+ ///
+ [Column("WEEK_OF_YEAR")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "當年第幾周")]
+ public int WeekOfYear { get; set; }
+
+ ///
+ /// 當年第幾周(客戶)
+ ///
+ [Column("WEEK_OF_YEAR_ADVANTECH")]
+ [DataMember]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "當年第幾周(客戶)")]
+ public int WeekOfYearAdvantech { get; set; }
+
+ ///
+ /// 假日
+ ///
+ [Column("HOLIDAY")]
+ [Required(ErrorMessage = "{0},不能空白")]
+ [Display(Name = "假日")]
+ [StringLength(2, ErrorMessage = "{0},不能大于{1}")]
+ [DataMember]
+ public string Holiday { get; set; }
+ }
+}
diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs
index 5490b5bc..fc168b7f 100644
--- a/AMESCoreStudio.WebApi/Models/AMESContext.cs
+++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs
@@ -700,6 +700,11 @@ namespace AMESCoreStudio.WebApi
///
public virtual DbSet WipKps { get; set; }
+ ///
+ /// 日曆資料表
+ ///
+ public DbSet CalendarTables { get; set; }
+
}
}