Browse Source

1. 更換工單綁SOP相關Table 名稱

2. 修正過站邏輯判斷
3. 新增FQC007 FQC抽驗資料
PTD
ray 3 years ago
parent
commit
44e1979735
  1. 41
      AMESCoreStudio.Web/Controllers/PCSController.cs
  2. 41
      AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs
  3. 2
      AMESCoreStudio.Web/ViewModels/PCS/PCS001RViewModel.cs
  4. 2
      AMESCoreStudio.Web/ViewModels/WipViewModel.cs
  5. 2
      AMESCoreStudio.Web/Views/PCS/PCS001.cshtml
  6. 13
      AMESCoreStudio.Web/Views/PCS/PCS021.cshtml
  7. 4
      AMESCoreStudio.Web/Views/PCS/PCS027.cshtml
  8. 4
      AMESCoreStudio.Web/Views/PCS/PCS030.cshtml
  9. 4
      AMESCoreStudio.Web/Views/PCS/PCS030C.cshtml
  10. 61
      AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs
  11. 185
      AMESCoreStudio.WebApi/Controllers/AMES/MaterialSopController.cs
  12. 193
      AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs
  13. 181
      AMESCoreStudio.WebApi/Controllers/AMES/WipSopLogController.cs
  14. 160
      AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs
  15. 8
      AMESCoreStudio.WebApi/DTO/AMES/MaterialSopDto.cs
  16. 1
      AMESCoreStudio.WebApi/Models/AMES/FqcInhouseDetail.cs
  17. 2
      AMESCoreStudio.WebApi/Models/AMES/FqcResultMaster.cs
  18. 124
      AMESCoreStudio.WebApi/Models/AMES/MaterialSop.cs
  19. 81
      AMESCoreStudio.WebApi/Models/AMES/WipSop.cs
  20. 86
      AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs
  21. 8
      AMESCoreStudio.WebApi/Models/AMESContext.cs

41
AMESCoreStudio.Web/Controllers/PCSController.cs

@ -1069,12 +1069,12 @@ namespace AMESCoreStudio.Web.Controllers
} }
} }
// 工單對應SOP Log // 工單對應SOP
var q = await _pcsApi.GetWipSopQuery(itemNo: model.wipAtt.ItemNO, unitNo: model.wipInfo.UnitNO, state: "Y"); var q = await _pcsApi.GetMaterialSopQuery(itemNo: model.wipAtt.ItemNO, unitNo: model.wipInfo.UnitNO, state: "Y");
if (q.Data.Count() != 0) if (q.Data.Count() != 0)
{ {
model.wipSopLog.WipSopID = q.Data.FirstOrDefault().WipSopID; model.wipSop.MaterialSopID = q.Data.FirstOrDefault().MaterialSopID;
await _pcsApi.PostWipSopLog(JsonConvert.SerializeObject(model.wipSopLog)); await _pcsApi.PostWipSop(JsonConvert.SerializeObject(model.wipSop));
} }
// 內部條碼 // 內部條碼
@ -1155,8 +1155,8 @@ namespace AMESCoreStudio.Web.Controllers
model.ruleStation = await _basApi.GetRuleStationsByFlow(model.wipInfo.FlowRuleID); model.ruleStation = await _basApi.GetRuleStationsByFlow(model.wipInfo.FlowRuleID);
model.ruleStation = model.ruleStation.OrderBy(o => o.Sequence); model.ruleStation = model.ruleStation.OrderBy(o => o.Sequence);
var q1 = await _pcsApi.GetWipSopQuery(itemNo: model.wipAtt.ItemNO); var q1 = await _pcsApi.GetMaterialSopQuery(itemNo: model.wipAtt.ItemNO);
model.wipSop = q1.Data; model.materialSop = q1.Data;
model.materialKp = await _pcsApi.GetMaterialKpQuery(itemno: model.wipAtt.ItemNO); model.materialKp = await _pcsApi.GetMaterialKpQuery(itemno: model.wipAtt.ItemNO);
@ -2094,10 +2094,10 @@ namespace AMESCoreStudio.Web.Controllers
} }
} }
var wipsop = await _pcsApi.GetWipSopLog(q.FirstOrDefault().WipID); var wipsop = await _pcsApi.GetWipSop(q.FirstOrDefault().WipID);
if (wipsop != null) if (wipsop != null)
{ {
model.SopPath = wipsop.GetWipSop.FilePath + wipsop.GetWipSop.NewName; model.SopPath = wipsop.GetMaterialSop.FilePath + wipsop.GetMaterialSop.NewName;
} }
} }
@ -2270,6 +2270,9 @@ namespace AMESCoreStudio.Web.Controllers
await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation));
// 新增 BarCodeItem // 新增 BarCodeItem
// 先查詢已綁定組件數量
var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID);
int KpItemQty = BarCodeItems.Count();
for (int i = 0; i < Kp.Count(); i++) for (int i = 0; i < Kp.Count(); i++)
{ {
@ -2282,7 +2285,7 @@ namespace AMESCoreStudio.Web.Controllers
BarcodeID = model.BarCodeID, BarcodeID = model.BarCodeID,
WipID = model.WipID, WipID = model.WipID,
RuleStationID = model.RuleStation, RuleStationID = model.RuleStation,
ItemNo = model.MaterialKps[i].KpNo, ItemNo = model.MaterialKps[i + KpItemQty].KpNo,
PartNo = Kp[i], PartNo = Kp[i],
SysType = "S", SysType = "S",
CreateUserID = 0, CreateUserID = 0,
@ -2608,7 +2611,7 @@ namespace AMESCoreStudio.Web.Controllers
public async Task<IActionResult> PCS030QueryAsync(string itemNo, string unitNo public async Task<IActionResult> PCS030QueryAsync(string itemNo, string unitNo
, string fileName, string state, string date_str, string date_end) , string fileName, string state, string date_str, string date_end)
{ {
IResultModel<WipSopDto> result = await _pcsApi.GetWipSopQuery(itemNo: itemNo, unitNo: unitNo IResultModel<MaterialSopDto> result = await _pcsApi.GetMaterialSopQuery(itemNo: itemNo, unitNo: unitNo
, fileName: fileName, state: state, date_str: date_str, date_end: date_end); , fileName: fileName, state: state, date_str: date_str, date_end: date_end);
if (result.Data.Count() != 0) if (result.Data.Count() != 0)
@ -2619,14 +2622,14 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpPost] [HttpPost]
public async Task<JsonResult> PCS030StateAsync(int wipSopID, bool state) public async Task<JsonResult> PCS030StateAsync(int MaterialSopID, bool state)
{ {
//IResultModel result; //IResultModel result;
if (!state) if (!state)
await _pcsApi.PutWipSop(wipSopID, "N"); await _pcsApi.PutMaterialSop(MaterialSopID, "N");
else else
await _pcsApi.PutWipSop(wipSopID, "Y"); await _pcsApi.PutMaterialSop(MaterialSopID, "Y");
var _msg = "修改成功!"; var _msg = "修改成功!";
return Json(_msg); return Json(_msg);
@ -2640,7 +2643,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpPost] [HttpPost]
public async Task<IActionResult> PCS030CAsync(WipSop model, IFormFile formFile) public async Task<IActionResult> PCS030CAsync(MaterialSop model, IFormFile formFile)
{ {
string FileName = string.Empty; string FileName = string.Empty;
string NewName = string.Empty; string NewName = string.Empty;
@ -2681,10 +2684,10 @@ namespace AMESCoreStudio.Web.Controllers
model.NewName = NewName; model.NewName = NewName;
model.FilePath = FilePath;// fileInfo.PhysicalPath; model.FilePath = FilePath;// fileInfo.PhysicalPath;
result = await _pcsApi.PostWipSop(JsonConvert.SerializeObject(model)); result = await _pcsApi.PostMaterialSop(JsonConvert.SerializeObject(model));
if (result.Success) if (result.Success)
{ {
var _msg = model.WipSopID == 0 ? "新增成功!" : "修改成功!"; var _msg = model.MaterialSopID == 0 ? "新增成功!" : "修改成功!";
return RedirectToAction("Refresh", "Home", new { msg = _msg }); return RedirectToAction("Refresh", "Home", new { msg = _msg });
} }
else else
@ -2945,7 +2948,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpPost] [HttpPost]
public async Task<IActionResult> PCS027CAsync(WipSop model, IFormFile formFile) public async Task<IActionResult> PCS027CAsync(MaterialSop model, IFormFile formFile)
{ {
string FileName = string.Empty; string FileName = string.Empty;
string NewName = string.Empty; string NewName = string.Empty;
@ -2986,10 +2989,10 @@ namespace AMESCoreStudio.Web.Controllers
model.NewName = NewName; model.NewName = NewName;
model.FilePath = FilePath;// fileInfo.PhysicalPath; model.FilePath = FilePath;// fileInfo.PhysicalPath;
result = await _pcsApi.PostWipSop(JsonConvert.SerializeObject(model)); result = await _pcsApi.PostMaterialSop(JsonConvert.SerializeObject(model));
if (result.Success) if (result.Success)
{ {
var _msg = model.WipSopID == 0 ? "新增成功!" : "修改成功!"; var _msg = model.MaterialSopID == 0 ? "新增成功!" : "修改成功!";
return RedirectToAction("Refresh", "Home", new { msg = _msg }); return RedirectToAction("Refresh", "Home", new { msg = _msg });
} }
else else

41
AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs

@ -237,6 +237,15 @@ namespace AMESCoreStudio.Web
#endregion #endregion
#region BarcodeItem BarCode組件維護 PCS021
/// <summary>
/// 查詢組件序號 by BarCodeID
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/BarcodeItems/ByBarCodeID")]
ITask<List<BarcodeItem>> GetBarcodeItemByBarCodeID(int barcodeID);
#endregion
#region NgInfo 測試不良基本資料檔 PCS021 #region NgInfo 測試不良基本資料檔 PCS021
[WebApiClient.Attributes.HttpPost("api/NgInfo")] [WebApiClient.Attributes.HttpPost("api/NgInfo")]
ITask<ResultModel<NgInfo>> PostNgInfo([FromBody, RawJsonContent] string model); ITask<ResultModel<NgInfo>> PostNgInfo([FromBody, RawJsonContent] string model);
@ -490,13 +499,13 @@ namespace AMESCoreStudio.Web
ITask<List<MaterialStationsItem>> GetMaterialStationsItemByItemID(int id); ITask<List<MaterialStationsItem>> GetMaterialStationsItemByItemID(int id);
#endregion #endregion
#region SOP文件維護 #region MaterialSop SOP文件維護
/// <summary> /// <summary>
/// SOP文件查詢 /// SOP文件查詢
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/WipSop/{id}")] [WebApiClient.Attributes.HttpGet("api/MaterialSop/{id}")]
ITask<WipSop> GetWipSop(int id); ITask<MaterialSop> GetMaterialSop(int id);
/// <summary> /// <summary>
@ -512,41 +521,41 @@ namespace AMESCoreStudio.Web
/// <param name="date_end">鎖定日期迄</param> /// <param name="date_end">鎖定日期迄</param>
/// <returns></returns> /// <returns></returns>
/// <returns></returns> /// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/WipSop/GetWipSopQuery")] [WebApiClient.Attributes.HttpGet("api/MaterialSop/GetMaterialSopQuery")]
ITask<ResultModel<WipSopDto>> GetWipSopQuery(string itemNo = null, string unitNo = null ITask<ResultModel<MaterialSopDto>> GetMaterialSopQuery(string itemNo = null, string unitNo = null
, string fileName = null, string state = null, string date_str = null, string date_end = null); , string fileName = null, string state = null, string date_str = null, string date_end = null);
/// <summary> /// <summary>
/// 新增SOP文件 /// 新增SOP文件
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[WebApiClient.Attributes.HttpPost("api/WipSop")] [WebApiClient.Attributes.HttpPost("api/MaterialSop")]
ITask<ResultModel<WipSop>> PostWipSop([FromBody, RawJsonContent] string model); ITask<ResultModel<MaterialSop>> PostMaterialSop([FromBody, RawJsonContent] string model);
/// <summary> /// <summary>
/// SOP文件變更狀態 /// SOP文件變更狀態
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[WebApiClient.Attributes.HttpPut("api/WipSop/{id}/{state}")] [WebApiClient.Attributes.HttpPut("api/MaterialSop/{id}/{state}")]
ITask<ResultModel<WipSop>> PutWipSop(int id, string state); ITask<ResultModel<MaterialSop>> PutMaterialSop(int id, string state);
#endregion #endregion
#region WipSopLog 工單對應SOP log #region WipSop 工單對應SOP
/// <summary> /// <summary>
/// 查詢工單對應SOP log /// 查詢工單對應SOP log
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/WipSopLog/{id}")] [WebApiClient.Attributes.HttpGet("api/WipSop/{id}")]
ITask<WipSopLog> GetWipSopLog(int id); ITask<WipSop> GetWipSop(int id);
/// <summary> /// <summary>
/// 新增工單對應SOP log /// 新增工單對應SOP
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[WebApiClient.Attributes.HttpPost("api/WipSopLog")] [WebApiClient.Attributes.HttpPost("api/WipSop")]
ITask<ResultModel<WipSopLog>> PostWipSopLog([FromBody, RawJsonContent] string model); ITask<ResultModel<WipSop>> PostWipSop([FromBody, RawJsonContent] string model);
#endregion #endregion
#region PCS024組件維護相關 #region PCS024組件維護相關
@ -702,7 +711,7 @@ namespace AMESCoreStudio.Web
/// <param name="unitNo">生產單位ID</param> /// <param name="unitNo">生產單位ID</param>
/// <param name="inputKP">過站刷入組件序號</param> /// <param name="inputKP">過站刷入組件序號</param>
[WebApiClient.Attributes.HttpGet("api/BarCodeCheck/BarCodeKP")] [WebApiClient.Attributes.HttpGet("api/BarCodeCheck/BarCodeKP")]
ITask<ResultModel<string>> CheckBarCodeKP(string wipno , string barcode , string unitNo, List<string> inputKP); ITask<ResultModel<string>> CheckBarCodeKP(string wipno, string barcode, string unitNo, List<string> inputKP);
#endregion #endregion

2
AMESCoreStudio.Web/ViewModels/PCS/PCS001RViewModel.cs

@ -22,7 +22,7 @@ namespace AMESCoreStudio.Web.ViewModels.PCS
public IEnumerable<RuleStation> ruleStation { get; set; } public IEnumerable<RuleStation> ruleStation { get; set; }
public IEnumerable<WipSopDto> wipSop { get; set; } public IEnumerable<MaterialSopDto> materialSop { get; set; }
public IEnumerable<MaterialKpDto> materialKp { get; set; } public IEnumerable<MaterialKpDto> materialKp { get; set; }

2
AMESCoreStudio.Web/ViewModels/WipViewModel.cs

@ -40,7 +40,7 @@ namespace AMESCoreStudio.Web.ViewModels
public FactoryUnit factoryUnit { get; set; } public FactoryUnit factoryUnit { get; set; }
public WipSopLog wipSopLog { get; set; } public WipSop wipSop { get; set; }
public WipLabel wipLabel { get; set; } public WipLabel wipLabel { get; set; }

2
AMESCoreStudio.Web/Views/PCS/PCS001.cshtml

@ -19,7 +19,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<form enctype="multipart/form-data" method="post" asp-action="PCS001" class="layui-form"> <form enctype="multipart/form-data" method="post" asp-action="PCS001" class="layui-form">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="wipSopLog.State" value="Y" /> <input type="hidden" asp-for="wipSop.Status" value="Y" />
<div class="layui-form-item"> <div class="layui-form-item">

13
AMESCoreStudio.Web/Views/PCS/PCS021.cshtml

@ -86,12 +86,6 @@
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">作業站:</label>
<div class="layui-input-inline" style="width:100px">
<select id="stations" lay-filter="stations" lay-verify="required" asp-for="Station" asp-items="@ViewBag.GetRuleStationByFlowRuleIDList" lay-submit>
</select>
</div>
<label class="layui-form-label">工單號碼:</label> <label class="layui-form-label">工單號碼:</label>
<div class="layui-input-inline" style="width:100px"> <div class="layui-input-inline" style="width:100px">
<input type="text" onkeydown="SearchNo(event);" asp-for="WipNO" asp-action="PCS021_GetWip" class="layui-input" autocomplete="off" /> <input type="text" onkeydown="SearchNo(event);" asp-for="WipNO" asp-action="PCS021_GetWip" class="layui-input" autocomplete="off" />
@ -99,6 +93,13 @@
<input type="hidden" asp-for="FlowRuleID" value="@Model.FlowRuleID" /> <input type="hidden" asp-for="FlowRuleID" value="@Model.FlowRuleID" />
<input type="submit" id="GetWipData" asp-action="PCS021_GetWip" style="display:none;" /> <input type="submit" id="GetWipData" asp-action="PCS021_GetWip" style="display:none;" />
</div> </div>
<label class="layui-form-label">作業站:</label>
<div class="layui-input-inline" style="width:100px">
<select id="stations" lay-filter="stations" lay-verify="required" asp-for="Station" asp-items="@ViewBag.GetRuleStationByFlowRuleIDList" lay-submit>
</select>
</div>
</div> </div>
</div> </div>
</div> </div>

4
AMESCoreStudio.Web/Views/PCS/PCS027.cshtml

@ -1,4 +1,4 @@
@model AMESCoreStudio.WebApi.Models.AMES.WipSop @model AMESCoreStudio.WebApi.Models.AMES.MaterialSop
@{ ViewData["Title"] = "PCS030C"; @{ ViewData["Title"] = "PCS030C";
@ -15,7 +15,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<form enctype="multipart/form-data" method="post" asp-action="PCS030C" class="layui-form"> <form enctype="multipart/form-data" method="post" asp-action="PCS030C" class="layui-form">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="WipSopID" /> <input type="hidden" asp-for="MaterialSopID" />
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">

4
AMESCoreStudio.Web/Views/PCS/PCS030.cshtml

@ -110,7 +110,7 @@
@section Scripts{ @section Scripts{
<script type="text/html" id="switchState"> <script type="text/html" id="switchState">
<!-- 这里的 checked 的状态只是演示 --> <!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="state" value="{{d.wipSopID}}" lay-skin="switch" lay-text="啟用|停用" lay-filter="state" {{ d.state == "使用中" ? 'checked' : '' }}> <input type="checkbox" name="state" value="{{d.materialSopID}}" lay-skin="switch" lay-text="啟用|停用" lay-filter="state" {{ d.state == "使用中" ? 'checked' : '' }}>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
@ -153,7 +153,7 @@
$.ajax({ $.ajax({
url: '@Url.Action("PCS030State", "PCS")', url: '@Url.Action("PCS030State", "PCS")',
dataType: 'json', dataType: 'json',
data: { "wipSopID": strSplit, "state": checked }, data: { "materialSopID": strSplit, "state": checked },
cache: false, cache: false,
type: "POST", type: "POST",
success: function (data, textStatus, jqXHR) { success: function (data, textStatus, jqXHR) {

4
AMESCoreStudio.Web/Views/PCS/PCS030C.cshtml

@ -1,4 +1,4 @@
@model AMESCoreStudio.WebApi.Models.AMES.WipSop @model AMESCoreStudio.WebApi.Models.AMES.MaterialSop
@{ ViewData["Title"] = "PCS030C"; @{ ViewData["Title"] = "PCS030C";
@ -15,7 +15,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<form enctype="multipart/form-data" method="post" asp-action="PCS030C" class="layui-form"> <form enctype="multipart/form-data" method="post" asp-action="PCS030C" class="layui-form">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="WipSopID" /> <input type="hidden" asp-for="MaterialSopID" />
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">

61
AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs

@ -131,6 +131,67 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return result; return result;
} }
/// <summary>
/// FQC抽驗資料
/// </summary>
/// <param name="inhouseNo">入庫單號碼</param>
/// <param name="seqid">序號</param>
/// <returns></returns>
[HttpGet("FqcQuery")]
public async Task<ResultModel<FqcDto>> GetFqcQuery(string inhouseNo, int seqid = 1)
{
IQueryable<FqcDto> q = from q1 in _context.FqcInhouseMasters.Where(w => w.InhouseNo == inhouseNo && w.SeqID == seqid)
join q2 in _context.FqcResultMasters on new { q1.InhouseNo, q1.SeqID } equals new { q2.InhouseNo, q2.SeqID }
into cp
from q2 in cp.DefaultIfEmpty()
join q3 in _context.QcCriteria on q1.CritID equals q3.CritID
select new FqcDto
{
InhouseNo = q1.InhouseNo,
SeqID = q1.SeqID,
WipNo = q1.WipNo,
ItemNo = q1.ItemNo,
ModelNo = q1.ModelNo,
QcQty = q3.QcQty,
ReQty = q3.ReQty,
StatusName = q1.Status,
FqcID = q2.FqcID == null ? new Nullable<int>() : q2.FqcID,
InhouseMemo = q2.InhouseMemo,
ManualQaMeno = q2.ManualQaMeno,
QaMeno = q2.QaMeno
};
var query = await q.ToListAsync();
var FqcDetail = new List<FqcDto.FqcDetailDto>();
if (query.Count() != 0)
{
var Detail = _context.FqcInhouseDetails.Where(w => w.InhouseNo == inhouseNo && w.SeqID == seqid);
foreach (var item in Detail)
{
// 取抽驗結果明細檔資料
var FqcResultDetail = _context.FqcResultDetails.Where(w => w.FqcID == query.FirstOrDefault().FqcID
&& w.BoxNo == item.SerialNo).ToList();
FqcDetail.Add(new FqcDto.FqcDetailDto
{
SerialNo = item.SerialNo,
Qty = _context.BarcodeInfoes.Where(w => w.BoxNo == item.SerialNo).Count(),
HasQty = FqcResultDetail.Count(),
PassQty = FqcResultDetail.Where(w => w.StatusNo == "P").Count(),
FailQty = FqcResultDetail.Where(w => w.StatusNo == "F").Count()
});
}
}
ResultModel<FqcDto> result = new ResultModel<FqcDto>();
result.Data = query;
foreach (var item in result.Data)
{
item.fqcDetails = FqcDetail;
}
return result;
}
/// <summary> /// <summary>
/// 更新入庫單 /// 更新入庫單
/// </summary> /// </summary>

185
AMESCoreStudio.WebApi/Controllers/AMES/MaterialSopController.cs

@ -0,0 +1,185 @@
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 MaterialSopController : ControllerBase
{
private readonly AMESContext _context;
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public MaterialSopController(AMESContext context)
{
_context = context;
}
/// <summary>
/// SOPFile資料查詢
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<ActionResult<IEnumerable<MaterialSop>>> GetMaterialSop()
{
IQueryable<MaterialSop> q = _context.MaterialSops;
q = q.OrderBy(p => p.MaterialSopID);
var materialSops = await q.ToListAsync();
return materialSops;
}
/// <summary>
/// SOPFile資料查詢 by ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public async Task<ActionResult<MaterialSop>> GetMaterialSop(int id)
{
IQueryable<MaterialSop> q = _context.MaterialSops;
var materialSop = await q.Where(p => p.MaterialSopID == id).FirstOrDefaultAsync();
//if (wipSop == null)
//{
// return NotFound();
//}
return materialSop;
}
/// <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<MaterialSopDto>> GetMaterialSopQuery(string itemNo = null, string unitNo = null
, string fileName = null, string state = null, string date_str = null, string date_end = null)
{
IQueryable<MaterialSop> q = _context.MaterialSops;
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);
if (DateTime.TryParse(date_str, out _))
{
q = q.Where(w => w.CreateDate >= DateTime.Parse(date_str));
}
if (DateTime.TryParse(date_end, out _))
{
q = q.Where(w => w.CreateDate <= DateTime.Parse(date_end));
}
ResultModel<MaterialSopDto> result = new ResultModel<MaterialSopDto>();
result.Data = await q.Select(s => new MaterialSopDto
{
MaterialSopID = s.MaterialSopID,
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<MaterialSop>> PostMaterialSop([FromBody] MaterialSop materialSop)
{
ResultModel<MaterialSop> result = new ResultModel<MaterialSop>();
Helper helper = new Helper(_context);
materialSop.MaterialSopID = helper.GetIDKey("MATERIAL_SOP_ID").Result;
materialSop.State = "Y";
//wipLog.WipSopID = wipLog.WipID == 0 ? helper.GetIDKeyNoPost("WIP_ID").Result : wipLog.WipID;
_context.MaterialSops.Add(materialSop);
try
{
await _context.SaveChangesAsync();
result.Success = true;
result.Msg = "OK";
}
catch (Exception ex)
{
result.Success = false;
result.Msg = ex.Message;
}
return result;
}
[HttpPut("{id}/{state}")]
public async Task<ResultModel<MaterialSop>> PutMaterialSop(int id, string state)
{
ResultModel<MaterialSop> result = new ResultModel<MaterialSop>();
var materialSop = new MaterialSop
{
MaterialSopID = id,
State = state,
UpdateUserID = 1,
UpdateDate = System.DateTime.Now
};
_context.Attach(materialSop);
// 指定更新某個欄位
_context.Entry(materialSop).Property(p => p.State).IsModified = true;
_context.Entry(materialSop).Property(p => p.UpdateUserID).IsModified = true;
_context.Entry(materialSop).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/<WipSopController>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

193
AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs

@ -28,36 +28,31 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
} }
/// <summary> /// <summary>
/// SOPFile資料查詢 /// 工單投產纪錄資料文件
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public async Task<ActionResult<IEnumerable<WipSop>>> GetWipSop() public async Task<ActionResult<IEnumerable<WipSop>>> GetWipSop()
{ {
IQueryable<WipSop> q = _context.WipSops; IQueryable<WipSop> q = _context.WipSops;
q = q.OrderBy(p => p.WipSopID); q = q.OrderBy(p => p.MaterialSopID);
var wipSop = await q.ToListAsync(); var WipSop = await q.ToListAsync();
return wipSop; return WipSop;
} }
/// <summary>
/// SOPFile資料查詢 by ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")] [HttpGet("{id}")]
public async Task<ActionResult<WipSop>> GetWipSop(int id) public async Task<ActionResult<WipSop>> GetWipSop(int id)
{ {
IQueryable<WipSop> q = _context.WipSops; IQueryable<WipSop> q = _context.WipSops;
var wipSop = await q.Where(p => p.WipSopID == id).FirstOrDefaultAsync(); var WipSop = await q.Where(p => p.WipID == id).FirstOrDefaultAsync();
//if (wipSop == null) //if (WipSopLog == null)
//{ //{
// return NotFound(); // return NotFound();
//} //}
return wipSop; return WipSop;
} }
/// <summary> /// <summary>
@ -70,64 +65,66 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
/// <param name="date_str">建立日期起</param> /// <param name="date_str">建立日期起</param>
/// <param name="date_end">建立日期迄</param> /// <param name="date_end">建立日期迄</param>
/// <returns></returns> /// <returns></returns>
[Route("[action]")] //[Route("[action]")]
[HttpGet] //[HttpGet]
public async Task<ResultModel<WipSopDto>> GetWipSopQuery(string itemNo = null, string unitNo = null //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) // , string fileName = null, string state = null, string date_str = null, string date_end = null)
{ //{
IQueryable<WipSop> q = _context.WipSops; // IQueryable<WipSopLog> q = _context.WipSopLogs;
if (!string.IsNullOrWhiteSpace(itemNo)) // if (!string.IsNullOrWhiteSpace(itemNo))
q = q.Where(w => w.ItemNo == itemNo); // q = q.Where(w => w.ItemNo == itemNo);
if (!string.IsNullOrWhiteSpace(unitNo)) // if (!string.IsNullOrWhiteSpace(unitNo))
q = q.Where(w => w.UnitNo == unitNo); // q = q.Where(w => w.UnitNo == unitNo);
if (!string.IsNullOrWhiteSpace(fileName)) // if (!string.IsNullOrWhiteSpace(fileName))
q = q.Where(w => w.FileName.Contains(fileName)); // q = q.Where(w => w.FileName.Contains(fileName));
if (!string.IsNullOrWhiteSpace(state)) // if (!string.IsNullOrWhiteSpace(state))
q = q.Where(w => w.State == state); // q = q.Where(w => w.State == state);
if (DateTime.TryParse(date_str, out _)) // DateTime dateValue;
{ // if (DateTime.TryParse(date_str, out dateValue))
q = q.Where(w => w.CreateDate >= DateTime.Parse(date_str)); // {
} // q = q.Where(w => w.CreateDate >= DateTime.Parse(date_str));
// }
if (DateTime.TryParse(date_end, out _))
{ // if (DateTime.TryParse(date_end, out dateValue))
q = q.Where(w => w.CreateDate <= DateTime.Parse(date_end)); // {
} // q = q.Where(w => w.CreateDate <= DateTime.Parse(date_end));
// }
ResultModel<WipSopDto> result = new ResultModel<WipSopDto>();
result.Data = await q.Select(s => new WipSopDto // ResultModel<WipSopLogDto> result = new ResultModel<WipSopLogDto>();
{ // result.Data = await q.Select(s => new WipSopLogDto
WipSopID = s.WipSopID, // {
ItemNo = s.ItemNo, // WipSopLogID = s.WipSopLogID,
UnitName = s.FactoryUnit.UnitName, // ItemNo = s.ItemNo,
FileName = s.FileName, // UnitName = s.FactoryUnit.UnitName,
FilePath = s.FilePath, // FileName = s.FileName,
State = s.State == "Y" ? "使用中" : "停用", // FilePath = s.FilePath,
NewName = s.NewName, // State = s.State == "Y" ? "使用中" : "停用",
CreateDate = s.CreateDate, // NewName = s.NewName,
CreateUserID = s.CreateUserID, // CreateDate = s.CreateDate,
UpdateDate = s.UpdateDate, // CreateUserID = s.CreateUserID,
UpdateUserID = s.UpdateUserID // UpdateDate = s.UpdateDate,
}).ToListAsync(); // UpdateUserID = s.UpdateUserID
// }).ToListAsync();
return result;
} // return result;
//}
[HttpPost] [HttpPost]
public async Task<ResultModel<WipSop>> PostWipSop([FromBody] WipSop wipsop) public async Task<ResultModel<WipSop>> PostWipSop([FromBody] WipSop wipSop)
{ {
ResultModel<WipSop> result = new ResultModel<WipSop>(); ResultModel<WipSop> result = new ResultModel<WipSop>();
Helper helper = new Helper(_context); Helper helper = new Helper(_context);
wipsop.WipSopID = helper.GetIDKey("WIP_SOP_ID").Result; wipSop.WipID = helper.GetIDKeyNoPost("WIP_ID").Result;
wipsop.State = "Y"; wipSop.Status = "Y";
//wipLog.WipSopID = wipLog.WipID == 0 ? helper.GetIDKeyNoPost("WIP_ID").Result : wipLog.WipID; //wipLog.WipSopLogID = wipLog.WipID == 0 ? helper.GetIDKeyNoPost("WIP_ID").Result : wipLog.WipID;
_context.WipSops.Add(wipsop); _context.WipSops.Add(wipSop);
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
@ -142,40 +139,40 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return result; return result;
} }
// PUT api/<WipSopController>/5 //// PUT api/<WipSopLogController>/5
[HttpPut("{id}/{state}")] //[HttpPut("{id}/{state}")]
public async Task<ResultModel<WipSop>> PutWipSop(int id, string state) //public async Task<ResultModel<WipSopLog>> PutWipSopLog(int id, string state)
{ //{
ResultModel<WipSop> result = new ResultModel<WipSop>(); // ResultModel<WipSopLog> result = new ResultModel<WipSopLog>();
var wipSop = new WipSop { // var WipSopLog = new WipSopLog {
WipSopID = id, // WipSopLogID = id,
State = state, // State = state,
UpdateUserID = 1, // UpdateUserID = 1,
UpdateDate = System.DateTime.Now // UpdateDate = System.DateTime.Now
}; // };
_context.Attach(wipSop); // _context.Attach(WipSopLog);
// 指定更新某個欄位 // // 指定更新某個欄位
_context.Entry(wipSop).Property(p => p.State).IsModified = true; // _context.Entry(WipSopLog).Property(p => p.State).IsModified = true;
_context.Entry(wipSop).Property(p => p.UpdateUserID).IsModified = true; // _context.Entry(WipSopLog).Property(p => p.UpdateUserID).IsModified = true;
_context.Entry(wipSop).Property(p => p.UpdateDate).IsModified = true; // _context.Entry(WipSopLog).Property(p => p.UpdateDate).IsModified = true;
try // try
{ // {
await _context.SaveChangesAsync(); // await _context.SaveChangesAsync();
result.Success = true; // result.Success = true;
result.Msg = "OK"; // result.Msg = "OK";
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
result.Success = false; // result.Success = false;
result.Msg = ex.Message; // result.Msg = ex.Message;
} // }
return result; // return result;
} //}
// DELETE api/<WipSopController>/5 // DELETE api/<WipSopLogController>/5
[HttpDelete("{id}")] [HttpDelete("{id}")]
public void Delete(int id) public void Delete(int id)
{ {

181
AMESCoreStudio.WebApi/Controllers/AMES/WipSopLogController.cs

@ -1,181 +0,0 @@
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)
{
}
}
}

160
AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs

@ -0,0 +1,160 @@
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.DTO.AMES
{
/// <summary>
/// 入庫單資料檔 Dto
/// </summary>
public partial class FqcDto
{
/// <summary>
/// 入庫單號碼
/// </summary>
[DataMember]
[Display(Name = "入庫單號")]
public string InhouseNo { get; set; }
/// <summary>
/// 序號
/// </summary>
[DataMember]
[Display(Name = "序號")]
public int SeqID { get; set; } = 1;
/// <summary>
/// FqcID
/// </summary>
[DataMember]
[Display(Name = "FqcID")]
public int? FqcID { get; set; } = 0;
/// <summary>
/// 工單號碼
/// </summary>
[DataMember]
[Display(Name = "工單號碼")]
public string WipNo { get; set; }
/// <summary>
/// 料號
/// </summary>
[DataMember]
[Display(Name = "料號")]
public string ItemNo { get; set; }
/// <summary>
/// 品名/機種
/// </summary>
[DataMember]
[Display(Name = "品名")]
public string ModelNo { get; set; }
/// <summary>
/// 抽驗狀態 P-PASS(允收);R-REJECT(批退); A-初始狀態
/// </summary>
[DataMember]
[Display(Name = "抽驗狀態")]
public string StatusName { get; set; } = "A";
/// <summary>
/// 抽驗數量
/// </summary>
[DataMember]
[Display(Name = "抽驗數量")]
public int QcQty { get; set; } = 0;
/// <summary>
/// PASS數量
/// </summary>
[DataMember]
[Display(Name = "PASS數量")]
public int PassQty { get; set; } = 0;
/// <summary>
/// 不良數
/// </summary>
[DataMember]
[Display(Name = "不良數")]
public int FailQty { get; set; } = 0;
/// <summary>
/// 拒收數量
/// </summary>
[DataMember]
[Display(Name = "拒收數量")]
public int ReQty { get; set; } = 0;
/// <summary>
/// 判定備註
/// </summary>
[DataMember]
[Display(Name = "判定備註")]
public string QaMeno { get; set; }
/// <summary>
/// 手動判定備註
/// </summary>
[DataMember]
[Display(Name = "手動判定備註")]
public string ManualQaMeno { get; set; }
/// <summary>
/// 入庫單備註
/// </summary>
[DataMember]
[Display(Name = "入庫單備註")]
public string InhouseMemo { get; set; }
public List<FqcDetailDto> fqcDetails { get; set; }
public class FqcDetailDto
{
/// <summary>
/// 箱號
/// </summary>
[DataMember]
[Display(Name = "箱號")]
public string SerialNo { get; set; }
/// <summary>
/// 總數量
/// </summary>
[DataMember]
[Display(Name = "總數量")]
public int Qty { get; set; } = 0;
/// <summary>
/// 已抽驗數
/// </summary>
[DataMember]
[Display(Name = "已抽驗數")]
public int HasQty { get; set; } = 0;
/// <summary>
/// PASS數量
/// </summary>
[DataMember]
[Display(Name = "PASS數量")]
public int PassQty { get; set; } = 0;
/// <summary>
/// FAIL數量
/// </summary>
[DataMember]
[Display(Name = "不良數")]
public int FailQty { get; set; } = 0;
}
}
}

8
AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs → AMESCoreStudio.WebApi/DTO/AMES/MaterialSopDto.cs

@ -8,13 +8,13 @@ namespace AMESCoreStudio.WebApi.DTO.AMES
/// <summary> /// <summary>
/// WipInfo Select Dto /// WipInfo Select Dto
/// </summary> /// </summary>
public class WipSopDto public class MaterialSopDto
{ {
/// <summary> /// <summary>
/// WIP_SOP_ID /// MATERIAL_SOP_ID
/// </summary> /// </summary>
public int WipSopID { get; set; } public int MaterialSopID { get; set; }
/// <summary> /// <summary>
/// 料號 /// 料號
@ -54,7 +54,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES
/// <summary> /// <summary>
/// 建立日期 /// 建立日期
/// </summary> /// </summary>
public DateTime CreateDate { get; set; } = System.DateTime.Now; public DateTime CreateDate { get; set; } = DateTime.Now;
/// <summary> /// <summary>
/// 更新UserID /// 更新UserID

1
AMESCoreStudio.WebApi/Models/AMES/FqcInhouseDetail.cs

@ -41,6 +41,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
/// <summary> /// <summary>
/// 箱號/條碼 /// 箱號/條碼
/// </summary> /// </summary>
[Key]
[DataMember] [DataMember]
[Display(Name = "箱號/條碼")] [Display(Name = "箱號/條碼")]
[Required(ErrorMessage = "{0},不能空白")] [Required(ErrorMessage = "{0},不能空白")]

2
AMESCoreStudio.WebApi/Models/AMES/FqcResultMaster.cs

@ -23,7 +23,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
[Required(ErrorMessage = "{0},不能空白")] [Required(ErrorMessage = "{0},不能空白")]
[Key] [Key]
[Column("FQC_ID")] [Column("FQC_ID")]
public int FqcID { get; set; } public int? FqcID { get; set; }
/// <summary> /// <summary>
/// 入庫單號碼 /// 入庫單號碼

124
AMESCoreStudio.WebApi/Models/AMES/MaterialSop.cs

@ -0,0 +1,124 @@
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("MATERIAL_SOP", Schema = "JHAMES")]
[DataContract]
public partial class MaterialSop
{
/// <summary>
/// MaterialSopID
/// </summary>
[Key]
[Column("MATERIAL_SOP_ID")]
[DataMember]
public int MaterialSopID { get; set; }
/// <summary>
/// 料號
/// </summary>
[DataMember]
[Display(Name = "料號")]
[Required(ErrorMessage = "{0},不能空白")]
[Column("ITEM_NO")]
[StringLength(20)]
public string ItemNo { get; set; }
/// <summary>
/// 生產單位ID
/// </summary>
[Display(Name = "生產單位")]
[Required]
[Column("UNIT_NO")]
[StringLength(1)]
[DataMember]
public string UnitNo { get; set; }
/// <summary>
/// 上傳檔案名稱
/// </summary>
[Display(Name = "檔案名稱")]
[Required]
[Column("FILENAME")]
[StringLength(100)]
[DataMember]
public string FileName { get; set; }
/// <summary>
/// 存放檔案名稱
/// </summary>
[Display(Name = "存放檔案名稱")]
[Required]
[Column("NEWNAME")]
[StringLength(100)]
[DataMember]
public string NewName { get; set; }
/// <summary>
/// 檔案路徑
/// </summary>
[DataMember]
[Display(Name = "檔案路徑")]
[Required]
[Column("FILEPATH")]
[StringLength(100)]
public string FilePath { get; set; }
/// <summary>
/// Y:使用中N:停用
/// </summary>
[Display(Name = "狀態")]
[Column("STATE")]
[StringLength(1)]
[DataMember]
public string State { get; set; } = "Y";
/// <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; } = DateTime.Now;
/// <summary>
/// 更新UserID
/// </summary>
[Column("UPDATE_USERID")]
[DataMember]
public int UpdateUserID { get; set; } = 0;
/// <summary>
/// 更新日期
/// </summary>
[Column("UPDATE_DATE")]
[DataMember]
public DateTime? UpdateDate { get; set; } = DateTime.Now;
/// <summary>
/// 生產單位資料
/// </summary>
[ForeignKey("UnitNo")]
public virtual BAS.FactoryUnit FactoryUnit { get; set; }
}
}

81
AMESCoreStudio.WebApi/Models/AMES/WipSop.cs

@ -10,79 +10,34 @@ using System.Runtime.Serialization;
namespace AMESCoreStudio.WebApi.Models.AMES namespace AMESCoreStudio.WebApi.Models.AMES
{ {
/// <summary> /// <summary>
/// SOP文件紀錄 /// 工單對應SOP文件紀錄
/// </summary> /// </summary>
[Table("WIP_SOP", Schema = "JHAMES")] [Table("WIP_SOP", Schema = "JHAMES")]
[DataContract] [DataContract]
public partial class WipSop public partial class WipSop
{ {
/// <summary> /// <summary>
/// WIP_SOP_ID /// WIP_ID
/// </summary> /// </summary>
[Key] [Key]
[Column("WIP_SOP_ID")] [Column("WIP_ID")]
[DataMember] [DataMember]
public int WipSopID { get; set; } public int WipID { get; set; }
/// <summary> /// <summary>
/// 料號 /// MATERIAL_SOP_ID
/// </summary>
[DataMember]
[Display(Name = "料號")]
[Required(ErrorMessage = "{0},不能空白")]
[Column("ITEM_NO")]
[StringLength(20)]
public string ItemNo { get; set; }
/// <summary>
/// 生產單位ID
/// </summary>
[Display(Name = "生產單位")]
[Required]
[Column("UNIT_NO")]
[StringLength(1)]
[DataMember]
public string UnitNo { get; set; }
/// <summary>
/// 上傳檔案名稱
/// </summary>
[Display(Name = "檔案名稱")]
[Required]
[Column("FILENAME")]
[StringLength(100)]
[DataMember]
public string FileName { get; set; }
/// <summary>
/// 存放檔案名稱
/// </summary>
[Display(Name = "存放檔案名稱")]
[Required]
[Column("NEWNAME")]
[StringLength(100)]
[DataMember]
public string NewName { get; set; }
/// <summary>
/// 檔案路徑
/// </summary> /// </summary>
[Key]
[Column("MATERIAL_SOP_ID")]
[DataMember] [DataMember]
[Display(Name = "檔案路徑")] public int MaterialSopID { get; set; }
[Required]
[Column("FILEPATH")]
[StringLength(100)]
public string FilePath { get; set; }
/// <summary> /// <summary>
/// Y:使用中N:停用 /// 狀態
/// </summary> /// </summary>
[Display(Name = "狀態")] [Column("STATUS")]
[Column("STATE")]
[StringLength(1)]
[DataMember] [DataMember]
public string State { get; set; } = "Y"; public string Status { get; set; }
/// <summary> /// <summary>
/// 建立UserID /// 建立UserID
@ -115,11 +70,17 @@ namespace AMESCoreStudio.WebApi.Models.AMES
public DateTime? UpdateDate { get; set; } = DateTime.Now; public DateTime? UpdateDate { get; set; } = DateTime.Now;
/// <summary> /// <summary>
/// 生產單位資料 /// 工單資料
/// </summary> /// </summary>
[ForeignKey("UnitNo")] [ForeignKey("WipID")]
public virtual AMESCoreStudio.WebApi.Models.BAS.FactoryUnit FactoryUnit { get; set; } [DataMember]
public virtual WipInfo GetWipInfo { get; set; }
//public virtual List<WipSopLog> WipSopLogs { get; set; } /// <summary>
/// SOP資料
/// </summary>
[ForeignKey("MaterialSopID")]
[DataMember]
public virtual MaterialSop GetMaterialSop { get; set; }
} }
} }

86
AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs

@ -1,86 +0,0 @@
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")]
[DataMember]
public int WipID { get; set; }
/// <summary>
/// WIP_SOP_ID
/// </summary>
[Key]
[Column("WIP_SOP_ID")]
[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")]
[DataMember]
public virtual WipInfo GetWipInfo { get; set; }
/// <summary>
/// SOP資料
/// </summary>
[ForeignKey("WipSopID")]
[DataMember]
public virtual WipSop GetWipSop { get; set; }
}
}

8
AMESCoreStudio.WebApi/Models/AMESContext.cs

@ -40,7 +40,7 @@ namespace AMESCoreStudio.WebApi
modelBuilder.Entity<WipBarcode>().HasKey(c => new { c.WipNO, c.StartNO, c.EndNO }); modelBuilder.Entity<WipBarcode>().HasKey(c => new { c.WipNO, c.StartNO, c.EndNO });
modelBuilder.Entity<WipLog>().HasKey(c => new { c.WipID, c.CreateDate }); modelBuilder.Entity<WipLog>().HasKey(c => new { c.WipID, c.CreateDate });
modelBuilder.Entity<PartMap>().HasKey(c => new { c.CorpSN }); modelBuilder.Entity<PartMap>().HasKey(c => new { c.CorpSN });
modelBuilder.Entity<WipSopLog>().HasKey(c => new { c.WipID, c.WipSopID }); modelBuilder.Entity<WipSop>().HasKey(c => new { c.WipID, c.MaterialSopID });
modelBuilder.Entity<BarcodeWip>().HasKey(c => new { c.WipID, c.BarcodeID }); modelBuilder.Entity<BarcodeWip>().HasKey(c => new { c.WipID, c.BarcodeID });
modelBuilder.Entity<BarcodeStation>().HasKey(c => new { c.BarcodeID ,c.WipID, c.RuleStationID ,c.RuleStatus ,c.InputDate }); modelBuilder.Entity<BarcodeStation>().HasKey(c => new { c.BarcodeID ,c.WipID, c.RuleStationID ,c.RuleStatus ,c.InputDate });
@ -83,7 +83,7 @@ namespace AMESCoreStudio.WebApi
modelBuilder.Entity<BarcodeGroup>().HasKey(c => new { c.GroupID, c.BarcodeID }); modelBuilder.Entity<BarcodeGroup>().HasKey(c => new { c.GroupID, c.BarcodeID });
modelBuilder.Entity<FqcInhouseMaster>().HasKey(c => new { c.InhouseNo, c.SeqID }); modelBuilder.Entity<FqcInhouseMaster>().HasKey(c => new { c.InhouseNo, c.SeqID });
modelBuilder.Entity<FqcInhouseDetail>().HasKey(c => new { c.InhouseNo, c.SeqID }); modelBuilder.Entity<FqcInhouseDetail>().HasKey(c => new { c.InhouseNo, c.SeqID , c.SerialNo });
modelBuilder.Entity<FqcResultDetail>().HasKey(c => new { c.FqcID, c.BoxNo ,c.BarcodeNo }); modelBuilder.Entity<FqcResultDetail>().HasKey(c => new { c.FqcID, c.BoxNo ,c.BarcodeNo });
modelBuilder.Entity<FqcBarcode>().HasKey(c => new { c.FqcID, c.BarcodeID }); modelBuilder.Entity<FqcBarcode>().HasKey(c => new { c.FqcID, c.BarcodeID });
modelBuilder.Entity<FqcItem>().HasKey(c => new { c.FqcID, c.ItemID }); modelBuilder.Entity<FqcItem>().HasKey(c => new { c.FqcID, c.ItemID });
@ -368,7 +368,7 @@ namespace AMESCoreStudio.WebApi
/// <summary> /// <summary>
/// SOP文件維護 /// SOP文件維護
/// </summary> /// </summary>
public virtual DbSet<WipSop> WipSops { get; set; } public virtual DbSet<MaterialSop> MaterialSops { get; set; }
public virtual DbSet<MaterialItem> MaterialItems { get; set; } public virtual DbSet<MaterialItem> MaterialItems { get; set; }
@ -395,7 +395,7 @@ namespace AMESCoreStudio.WebApi
/// <summary> /// <summary>
/// 工單對應SOP文件log /// 工單對應SOP文件log
/// </summary> /// </summary>
public virtual DbSet<WipSopLog> WipSopLogs { get; set; } public virtual DbSet<WipSop> WipSops { get; set; }
/// <summary> /// <summary>
/// 工單資料-標籤 /// 工單資料-標籤

Loading…
Cancel
Save