23 changed files with 1957 additions and 999 deletions
File diff suppressed because it is too large
@ -0,0 +1,157 @@ |
|||||
|
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; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 料號基本資料檔Controller
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class MaterialKpController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建構式
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public MaterialKpController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查詢料號基本資料檔
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/<MaterialKpController>
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<MaterialKp>>> GetMaterialKp() |
||||
|
{ |
||||
|
IQueryable<MaterialKp> q = _context.MaterialKps; |
||||
|
q = q.OrderBy(p => p.ItemID); |
||||
|
var MaterialKp = await q.ToListAsync(); |
||||
|
return MaterialKp; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號基本資料檔 to ItemID
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">ItemID</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ResultModel<MaterialKp>> GetMaterialKp(int id) |
||||
|
{ |
||||
|
IQueryable<MaterialKp> q = _context.MaterialKps; |
||||
|
|
||||
|
ResultModel<MaterialKp> result = new ResultModel<MaterialKp>(); |
||||
|
result.Data = await q.Where(p => p.ItemID == id).ToListAsync(); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Keypart查詢
|
||||
|
/// </summary>
|
||||
|
/// <param name="itemno">料號</param>
|
||||
|
/// <param name="station">站別</param>
|
||||
|
/// <returns></returns>
|
||||
|
[Route("[action]")]
|
||||
|
[HttpGet] |
||||
|
public async Task<ResultModel<MaterialKpDto>> GetMaterialKpQuery(string itemno, string station) |
||||
|
{ |
||||
|
IQueryable<MaterialKp> q = _context.MaterialKps; |
||||
|
|
||||
|
if (!string.IsNullOrWhiteSpace(itemno)) |
||||
|
q = q.Where(w => w.MaterialItem.ItemNo == itemno); |
||||
|
|
||||
|
if (!string.IsNullOrWhiteSpace(station)) |
||||
|
q = q.Where(w => w.StationType == station); |
||||
|
|
||||
|
|
||||
|
ResultModel<MaterialKpDto> result = new ResultModel<MaterialKpDto>(); |
||||
|
result.Data = await q.Select(s => new MaterialKpDto |
||||
|
{ |
||||
|
ItemName = s.MaterialItem.ItemNo, |
||||
|
KpName = s.KpName, |
||||
|
Station = s.StationTypeList.TypeDesc, |
||||
|
KpSeq= s.KpSeq, |
||||
|
KpNo = s.KpNo, |
||||
|
MaterialKpID = s.MaterialKpID, |
||||
|
Length = s.Length, |
||||
|
Title = s.Title |
||||
|
}).ToListAsync(); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增料號基本資料檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="MaterialKp"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<MaterialKp>> PostMaterialKp([FromBody] MaterialKp MaterialKp) |
||||
|
{ |
||||
|
ResultModel<MaterialKp> result = new ResultModel<MaterialKp>(); |
||||
|
Helper helper = new Helper(_context); |
||||
|
|
||||
|
_context.MaterialKps.Add(MaterialKp); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改料號基本資料檔
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPut] |
||||
|
public async Task<ResultModel<MaterialKp>> PutMaterialKp([FromBody] MaterialKp MaterialKp) |
||||
|
{ |
||||
|
ResultModel<MaterialKp> result = new ResultModel<MaterialKp>(); |
||||
|
_context.Attach(MaterialKp); |
||||
|
// 指定更新某個欄位
|
||||
|
_context.Entry(MaterialKp).Property(p => p.MaterialKpID).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/<MaterialKpController>/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public void DeleteMaterialKp(int id) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.AspNetCore.Mvc.Rendering; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class WipBarcodeOthersController : Controller |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public WipBarcodeOthersController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
// /// <summary>
|
||||
|
// /// 獲取產品別資料
|
||||
|
// /// </summary>
|
||||
|
// /// <returns></returns>
|
||||
|
// // GET: api/SystemInfoes
|
||||
|
// [HttpGet]
|
||||
|
// public async Task<ActionResult<IEnumerable<WipBarcodeOther>>> GetWipBarcodeOther()
|
||||
|
// {
|
||||
|
// IQueryable<WipBarcodeOther> q = _context.WipBarcodeOther;
|
||||
|
|
||||
|
// q = q.OrderBy(p => p.WipNO);
|
||||
|
|
||||
|
// //q = q.OrderByDescending(p => p.SystemID);
|
||||
|
|
||||
|
// var WipBarcodeOther = await q.ToListAsync();
|
||||
|
|
||||
|
// //return await _context.SystemInfoes.ToListAsync();
|
||||
|
|
||||
|
// return WipBarcodeOther;
|
||||
|
// }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
/////
|
||||
|
///// </summary>
|
||||
|
///// <param name="UnitNO">生產單位</param>
|
||||
|
///// <param name="WipNO">工單號碼</param>
|
||||
|
///// <returns></returns>
|
||||
|
// // GET: api/FlowRules/Unit/S
|
||||
|
// [HttpGet("Unit/{UnitNO}/{WipNO}")]
|
||||
|
// public async Task<ActionResult<IEnumerable<WipBarcodeOther>>> GetWipBarcodeOtherByUnit(string UnitNO , string WipNO)
|
||||
|
// {
|
||||
|
// IQueryable<WipInfo> q1 = _context.WipInfos.Where(w => w.UnitNO.Contains(UnitNO) && w.WipNO.Contains(WipNO));
|
||||
|
// IQueryable<WipBarcodeOther> q2 = _context.WipBarcodeOther;
|
||||
|
|
||||
|
// //if (no != null)
|
||||
|
// //{
|
||||
|
// // if (no != "")
|
||||
|
// // {
|
||||
|
// // q = q.Where(p => p.UnitNo.Equals(no));
|
||||
|
// // }
|
||||
|
// //}
|
||||
|
// //q.OrderBy(p => p.FlowRuleName);
|
||||
|
|
||||
|
// var flowRule = await q2.ToListAsync();
|
||||
|
|
||||
|
// //if (flowRule == null)
|
||||
|
// //{
|
||||
|
// // return NotFound();
|
||||
|
// //}
|
||||
|
|
||||
|
// return flowRule;
|
||||
|
// }
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.DTO.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// MaterialKpDtp Select Dto
|
||||
|
/// </summary>
|
||||
|
public class MaterialKpDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 料號KP_ID
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public int MaterialKpID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號Name
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public string ItemName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// KP料號名稱
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public string KpName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// KP料號NO
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public string KpNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 順序
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public int KpSeq { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 前置碼
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public string Title { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 長度
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public int Length { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 站(前段)
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public string Station { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 創建者ID
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public int CreateUserID { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 創建日期
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public DateTime CreateDate { get; set; } = System.DateTime.Now; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新者ID
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public int UpdateUserID { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新日期
|
||||
|
/// </summary>
|
||||
|
|
||||
|
public DateTime UpdateDate { get; set; } = System.DateTime.Now; |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,70 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.DTO.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// WipInfo Select Dto
|
||||
|
/// </summary>
|
||||
|
public class WipSopDto |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// WIP_SOP_ID
|
||||
|
/// </summary>
|
||||
|
public int WipSopID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號
|
||||
|
/// </summary>
|
||||
|
public string ItemNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 生產單位
|
||||
|
/// </summary>
|
||||
|
public string UnitName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 上傳檔案名稱
|
||||
|
/// </summary>
|
||||
|
public string FileName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 存放檔案名稱
|
||||
|
/// </summary>
|
||||
|
public string NewName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 檔案路徑
|
||||
|
/// </summary>
|
||||
|
public string FilePath { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Y:使用中N:停用
|
||||
|
/// </summary>
|
||||
|
public string State { get; set; } = "Y"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立UserID
|
||||
|
/// </summary>
|
||||
|
public int CreateUserID { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立日期
|
||||
|
/// </summary>
|
||||
|
public DateTime CreateDate { get; set; } = System.DateTime.Now; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新UserID
|
||||
|
/// </summary>
|
||||
|
public int UpdateUserID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新日期
|
||||
|
/// </summary>
|
||||
|
public DateTime? UpdateDate { get; set; } |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue