2 changed files with 123 additions and 0 deletions
@ -0,0 +1,70 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using AMESCoreStudio.WebApi.Models.AMES; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using AMESCoreStudio.CommonTools.Result; |
|||
|
|||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|||
|
|||
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|||
{ |
|||
/// <summary>
|
|||
/// 條碼變更資料表
|
|||
/// </summary>
|
|||
[Route("api/[controller]")]
|
|||
[ApiController] |
|||
public class CZmomaterialListController : ControllerBase |
|||
{ |
|||
|
|||
private readonly AMESContext _context; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="context"></param>
|
|||
public CZmomaterialListController(AMESContext context) |
|||
{ |
|||
_context = context; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 工單發料資料表
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
[HttpGet] |
|||
public async Task<ActionResult<IEnumerable<CZmomaterialList>>> GetCZmomaterialLists() |
|||
{ |
|||
IQueryable<CZmomaterialList> q = _context.CZmomaterialLists; |
|||
return await q.ToListAsync(); |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 工單發料資料表 by ByMoID 查詢
|
|||
/// </summary>
|
|||
/// <param name="id">MoID</param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("ByMoID/{id}")] |
|||
public async Task<ActionResult<IEnumerable<dynamic>>> GetCZmomaterialListByMoID(string id) |
|||
{ |
|||
var q = from q1 in _context.CZmomaterialLists.Where(w => w.MoID == id) |
|||
join q2 in _context.PlmMeterialInfos.Where( w=> w.MeterialDesc.ToUpper().Contains("POWER CORD") && w.MeterialNo.StartsWith("E17")) on q1.MaterialNo equals q2.MeterialNo |
|||
select new |
|||
{ |
|||
q1.MoID, |
|||
q1.MaterialNo, |
|||
q1.DemandQty, |
|||
q1.RealsendQty |
|||
|
|||
}; |
|||
|
|||
return await q.ToListAsync(); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,53 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.ComponentModel.DataAnnotations.Schema; |
|||
using System.Runtime.Serialization; |
|||
|
|||
namespace AMESCoreStudio.WebApi.Models.AMES |
|||
{ |
|||
/// <summary>
|
|||
/// 條碼變更資料表
|
|||
/// </summary>
|
|||
[Table("C_ZMOMATERIALLIST", Schema = "JHAMES")] |
|||
[DataContract] |
|||
public class CZmomaterialList |
|||
{ |
|||
/// <summary>
|
|||
/// 條碼置換ID
|
|||
/// </summary>
|
|||
[Column("MOID")] |
|||
[DataMember] |
|||
[Display(Name = "工單號碼")] |
|||
|
|||
|
|||
public string MoID { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 條碼ID
|
|||
/// </summary>
|
|||
[Column("MATERIAL_NO")] |
|||
[DataMember] |
|||
[Display(Name = "物料")] |
|||
|
|||
public string MaterialNo { get; set; } |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
[Column("DEMAND_QTY")] |
|||
[DataMember] |
|||
[Required(ErrorMessage = "{0},不能空白")] |
|||
[Display(Name = "數量")] |
|||
public float DemandQty { get; set; } |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
[Column("REALSEND_QTY")] |
|||
[DataMember] |
|||
[Display(Name = "數量")] |
|||
[Required(ErrorMessage = "{0},不能空白")] |
|||
public float RealsendQty { get; set; } |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue