Browse Source

1.新增CalendarTable的Model&Controller

2.修改維修資料統計增加關聯CalendarTable讀取相關欄位
PTD
Marvin 3 years ago
parent
commit
f5a7278f34
  1. 4
      AMESCoreStudio.Web/Views/REP/REP012.cshtml
  2. 156
      AMESCoreStudio.WebApi/Controllers/AMES/CalendarTablesController.cs
  3. 5
      AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs
  4. 133
      AMESCoreStudio.WebApi/Models/AMES/CalendarTable.cs
  5. 5
      AMESCoreStudio.WebApi/Models/AMESContext.cs

4
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: "料卷號"

156
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
{
/// <summary>
///
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class CalendarTablesController : ControllerBase
{
private readonly AMESContext _context;
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public CalendarTablesController(AMESContext context)
{
_context = context;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
// GET: api/CalendarTables
[HttpGet]
public async Task<ActionResult<IEnumerable<CalendarTable>>> GetCalendarTable()
{
return await _context.CalendarTables.ToListAsync();
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// GET: api/CalendarTables/5
[HttpGet("{id}")]
public async Task<ActionResult<CalendarTable>> GetCalendarTable(DateTime id)
{
var calendarTable = await _context.CalendarTables.FindAsync(id);
if (calendarTable == null)
{
return NotFound();
}
return calendarTable;
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="calendarTable"></param>
/// <returns></returns>
// 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<IActionResult> 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();
}
/// <summary>
///
/// </summary>
/// <param name="calendarTable"></param>
/// <returns></returns>
// 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<ActionResult<CalendarTable>> 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);
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/CalendarTables/5
[HttpDelete("{id}")]
public async Task<ActionResult<CalendarTable>> 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);
}
}
}

5
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,

133
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
{
/// <summary>
/// 日曆
/// </summary>
[Table("CALENDAR_TABLE", Schema = "JHAMES")]
public class CalendarTable
{
/// <summary>
/// 時間
/// </summary>
[Key]
[Column("TIME_ID")]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "時間")]
[DataMember]
public DateTime TimeID { get; set; }
/// <summary>
/// 年份
/// </summary>
[Column("YEAR")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "年份")]
public string Year { get; set; }
/// <summary>
/// 月份
/// </summary>
[Column("MONTH")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "月份")]
public string Month { get; set; }
/// <summary>
/// 日期
/// </summary>
[Column("DAY")]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "日期")]
[DataMember]
public string Day { get; set; }
/// <summary>
/// 月份描述
/// </summary>
[Column("MONTH_NAME")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "月份描述")]
public string MonthName { get; set; }
/// <summary>
/// 日期描述
/// </summary>
[Column("DAY_NAME")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "日期描述")]
public string DayName { get; set; }
/// <summary>
/// 當月第幾周
/// </summary>
[Column("WEEK_OF_MONTH")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "當月第幾周")]
public int WeekOfMonth { get; set; }
/// <summary>
/// 當年第幾周(ISO)
/// </summary>
[Column("WEEK_OF_YEAR_ISO")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "當年第幾周(ISO)")]
public int WeekOfYearISO { get; set; }
/// <summary>
/// 當月最後一天
/// </summary>
[Column("MONTH_END_DAY")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "當月最後一天")]
public DateTime MonthEndDay { get; set; }
/// <summary>
/// 週日期起訖
/// </summary>
[Column("WEEK_RANGE")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "週日期起訖")]
public string WeekRange { get; set; }
/// <summary>
/// 當年第幾周
/// </summary>
[Column("WEEK_OF_YEAR")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "當年第幾周")]
public int WeekOfYear { get; set; }
/// <summary>
/// 當年第幾周(客戶)
/// </summary>
[Column("WEEK_OF_YEAR_ADVANTECH")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "當年第幾周(客戶)")]
public int WeekOfYearAdvantech { get; set; }
/// <summary>
/// 假日
/// </summary>
[Column("HOLIDAY")]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "假日")]
[StringLength(2, ErrorMessage = "{0},不能大于{1}")]
[DataMember]
public string Holiday { get; set; }
}
}

5
AMESCoreStudio.WebApi/Models/AMESContext.cs

@ -700,6 +700,11 @@ namespace AMESCoreStudio.WebApi
/// </summary>
public virtual DbSet<WipKp> WipKps { get; set; }
/// <summary>
/// 日曆資料表
/// </summary>
public DbSet<CalendarTable> CalendarTables { get; set; }
}
}

Loading…
Cancel
Save