12 changed files with 1392 additions and 1053 deletions
File diff suppressed because it is too large
@ -0,0 +1,181 @@ |
|||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using AMESCoreStudio.WebApi.DTO.AMES; |
||||
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class WipSopLogController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public WipSopLogController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 工單投產纪錄資料文件
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<WipSopLog>>> GetWipSopLog() |
||||
|
{ |
||||
|
IQueryable<WipSopLog> q = _context.WipSopLogs; |
||||
|
q = q.OrderBy(p => p.WipSopID); |
||||
|
var WipSopLog = await q.ToListAsync(); |
||||
|
return WipSopLog; |
||||
|
} |
||||
|
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<WipSopLog>> GetWipSopLog(int id) |
||||
|
{ |
||||
|
IQueryable<WipSopLog> q = _context.WipSopLogs; |
||||
|
|
||||
|
var WipSopLog = await q.Where(p => p.WipID == id).FirstOrDefaultAsync(); |
||||
|
|
||||
|
if (WipSopLog == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return WipSopLog; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// SOP文件查詢
|
||||
|
/// </summary>
|
||||
|
/// <param name="itemNo">料號</param>
|
||||
|
/// <param name="unitNo">生產單位</param>
|
||||
|
/// <param name="fileName">檔案名稱</param>
|
||||
|
/// <param name="state">狀態</param>
|
||||
|
/// <param name="date_str">建立日期起</param>
|
||||
|
/// <param name="date_end">建立日期迄</param>
|
||||
|
/// <returns></returns>
|
||||
|
//[Route("[action]")]
|
||||
|
//[HttpGet]
|
||||
|
//public async Task<ResultModel<WipSopLogDto>> GetWipSopLogQuery(string itemNo = null, string unitNo = null
|
||||
|
// , string fileName = null, string state = null, string date_str = null, string date_end = null)
|
||||
|
//{
|
||||
|
// IQueryable<WipSopLog> q = _context.WipSopLogs;
|
||||
|
|
||||
|
// if (!string.IsNullOrWhiteSpace(itemNo))
|
||||
|
// q = q.Where(w => w.ItemNo == itemNo);
|
||||
|
|
||||
|
// if (!string.IsNullOrWhiteSpace(unitNo))
|
||||
|
// q = q.Where(w => w.UnitNo == unitNo);
|
||||
|
|
||||
|
// if (!string.IsNullOrWhiteSpace(fileName))
|
||||
|
// q = q.Where(w => w.FileName.Contains(fileName));
|
||||
|
|
||||
|
// if (!string.IsNullOrWhiteSpace(state))
|
||||
|
// q = q.Where(w => w.State == state);
|
||||
|
|
||||
|
|
||||
|
// DateTime dateValue;
|
||||
|
// if (DateTime.TryParse(date_str, out dateValue))
|
||||
|
// {
|
||||
|
// q = q.Where(w => w.CreateDate >= DateTime.Parse(date_str));
|
||||
|
// }
|
||||
|
|
||||
|
// if (DateTime.TryParse(date_end, out dateValue))
|
||||
|
// {
|
||||
|
// q = q.Where(w => w.CreateDate <= DateTime.Parse(date_end));
|
||||
|
// }
|
||||
|
|
||||
|
// ResultModel<WipSopLogDto> result = new ResultModel<WipSopLogDto>();
|
||||
|
// result.Data = await q.Select(s => new WipSopLogDto
|
||||
|
// {
|
||||
|
// WipSopLogID = s.WipSopLogID,
|
||||
|
// ItemNo = s.ItemNo,
|
||||
|
// UnitName = s.FactoryUnit.UnitName,
|
||||
|
// FileName = s.FileName,
|
||||
|
// FilePath = s.FilePath,
|
||||
|
// State = s.State == "Y" ? "使用中" : "停用",
|
||||
|
// NewName = s.NewName,
|
||||
|
// CreateDate = s.CreateDate,
|
||||
|
// CreateUserID = s.CreateUserID,
|
||||
|
// UpdateDate = s.UpdateDate,
|
||||
|
// UpdateUserID = s.UpdateUserID
|
||||
|
// }).ToListAsync();
|
||||
|
|
||||
|
// return result;
|
||||
|
//}
|
||||
|
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<WipSopLog>> PostWipSopLog([FromBody] WipSopLog wipSopLog) |
||||
|
{ |
||||
|
|
||||
|
ResultModel<WipSopLog> result = new ResultModel<WipSopLog>(); |
||||
|
Helper helper = new Helper(_context); |
||||
|
wipSopLog.WipID = helper.GetIDKeyNoPost("WIP_ID").Result; |
||||
|
wipSopLog.State = "Y"; |
||||
|
//wipLog.WipSopLogID = wipLog.WipID == 0 ? helper.GetIDKeyNoPost("WIP_ID").Result : wipLog.WipID;
|
||||
|
_context.WipSopLogs.Add(wipSopLog); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
//// PUT api/<WipSopLogController>/5
|
||||
|
//[HttpPut("{id}/{state}")]
|
||||
|
//public async Task<ResultModel<WipSopLog>> PutWipSopLog(int id, string state)
|
||||
|
//{
|
||||
|
// ResultModel<WipSopLog> result = new ResultModel<WipSopLog>();
|
||||
|
// var WipSopLog = new WipSopLog {
|
||||
|
// WipSopLogID = id,
|
||||
|
// State = state,
|
||||
|
// UpdateUserID = 1,
|
||||
|
// UpdateDate = System.DateTime.Now
|
||||
|
|
||||
|
// };
|
||||
|
// _context.Attach(WipSopLog);
|
||||
|
|
||||
|
// // 指定更新某個欄位
|
||||
|
// _context.Entry(WipSopLog).Property(p => p.State).IsModified = true;
|
||||
|
// _context.Entry(WipSopLog).Property(p => p.UpdateUserID).IsModified = true;
|
||||
|
// _context.Entry(WipSopLog).Property(p => p.UpdateDate).IsModified = true;
|
||||
|
|
||||
|
// try
|
||||
|
// {
|
||||
|
// await _context.SaveChangesAsync();
|
||||
|
// result.Success = true;
|
||||
|
// result.Msg = "OK";
|
||||
|
// }
|
||||
|
// catch (Exception ex)
|
||||
|
// {
|
||||
|
// result.Success = false;
|
||||
|
// result.Msg = ex.Message;
|
||||
|
// }
|
||||
|
// return result;
|
||||
|
//}
|
||||
|
|
||||
|
// DELETE api/<WipSopLogController>/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public void Delete(int id) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,45 +0,0 @@ |
|||||
using System; |
|
||||
using System.ComponentModel.DataAnnotations; |
|
||||
using System.ComponentModel.DataAnnotations.Schema; |
|
||||
using System.Runtime.Serialization; |
|
||||
|
|
||||
namespace AMESCoreStudio.WebApi.Models.AMES |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 組件資料檔
|
|
||||
/// </summary>
|
|
||||
[Table("ITEMS", Schema = "JHAMES")] |
|
||||
[DataContract] |
|
||||
public class Item |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 组件代碼
|
|
||||
/// </summary>
|
|
||||
[Column("ITEM_NO")] |
|
||||
[DataMember] |
|
||||
[Key] |
|
||||
public string ItemNo { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 组件名稱
|
|
||||
/// </summary>
|
|
||||
[Column("ITEM_NAME")] |
|
||||
[DataMember] |
|
||||
public string ItemName { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 組件類別
|
|
||||
/// </summary>
|
|
||||
[Column("ITEM_TYPE")] |
|
||||
[DataMember] |
|
||||
public string ItemType { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 組件區間管控
|
|
||||
/// </summary>
|
|
||||
[Column("SN_INTERVAL")] |
|
||||
[DataMember] |
|
||||
public string SnInerval { get; set; } |
|
||||
|
|
||||
} |
|
||||
} |
|
@ -0,0 +1,84 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 工單對應SOP文件紀錄
|
||||
|
/// </summary>
|
||||
|
[Table("WIP_SOP_LOG", Schema = "JHAMES")] |
||||
|
[DataContract] |
||||
|
public partial class WipSopLog |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// WIP_ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("WIP_ID", Order = 0)] |
||||
|
[DataMember] |
||||
|
public int WipID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// WIP_SOP_ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("WIP_SOP_ID", Order = 1)] |
||||
|
[DataMember] |
||||
|
public int WipSopID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 狀態
|
||||
|
/// </summary>
|
||||
|
[Column("STATE")] |
||||
|
[DataMember] |
||||
|
public string State { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立UserID
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[Required] |
||||
|
[DataMember] |
||||
|
public int CreateUserID { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立日期
|
||||
|
/// </summary>
|
||||
|
[Required] |
||||
|
[Column("CREATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime CreateDate { get; set; } = System.DateTime.Now; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新UserID
|
||||
|
/// </summary>
|
||||
|
[Column("UPDATE_USERID")] |
||||
|
[DataMember] |
||||
|
public int UpdateUserID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新日期
|
||||
|
/// </summary>
|
||||
|
[Column("UPDATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime? UpdateDate { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 工單資料
|
||||
|
/// </summary>
|
||||
|
[ForeignKey("WipID")] |
||||
|
public virtual WipInfo GetWipInfo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// SOP資料
|
||||
|
/// </summary>
|
||||
|
[ForeignKey("WipSopID")] |
||||
|
public virtual WipSop GetWipSop { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue