From 7f21f4bd76feca517c3bf66ebe2d3e0afca7b839 Mon Sep 17 00:00:00 2001 From: "BB.Wang" Date: Thu, 2 Feb 2023 10:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=9C=E4=B8=8A=E5=82=B3yiru=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=AA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AMES/CZmomaterialListController.cs | 70 +++++++++++++++++++ .../Models/AMES/CzmomaterialList.cs | 53 ++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/CZmomaterialListController.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/CzmomaterialList.cs diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/CZmomaterialListController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/CZmomaterialListController.cs new file mode 100644 index 00000000..afeaa4dd --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/CZmomaterialListController.cs @@ -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 +{ + /// + /// 條碼變更資料表 + /// + [Route("api/[controller]")] + [ApiController] + public class CZmomaterialListController : ControllerBase + { + + private readonly AMESContext _context; + + /// + /// + /// + /// + public CZmomaterialListController(AMESContext context) + { + _context = context; + } + + /// + /// 工單發料資料表 + /// + /// + [HttpGet] + public async Task>> GetCZmomaterialLists() + { + IQueryable q = _context.CZmomaterialLists; + return await q.ToListAsync(); + } + + + /// + /// 工單發料資料表 by ByMoID 查詢 + /// + /// MoID + /// + [HttpGet("ByMoID/{id}")] + public async Task>> 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(); + } + + + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/CzmomaterialList.cs b/AMESCoreStudio.WebApi/Models/AMES/CzmomaterialList.cs new file mode 100644 index 00000000..2a9d5921 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/CzmomaterialList.cs @@ -0,0 +1,53 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 條碼變更資料表 + /// + [Table("C_ZMOMATERIALLIST", Schema = "JHAMES")] + [DataContract] + public class CZmomaterialList + { + /// + /// 條碼置換ID + /// + [Column("MOID")] + [DataMember] + [Display(Name = "工單號碼")] + + + public string MoID { get; set; } + + /// + /// 條碼ID + /// + [Column("MATERIAL_NO")] + [DataMember] + [Display(Name = "物料")] + + public string MaterialNo { get; set; } + + /// + /// + /// + [Column("DEMAND_QTY")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "數量")] + public float DemandQty { get; set; } + + /// + /// + /// + [Column("REALSEND_QTY")] + [DataMember] + [Display(Name = "數量")] + [Required(ErrorMessage = "{0},不能空白")] + public float RealsendQty { get; set; } + + } +}