28 changed files with 1515 additions and 1216 deletions
@ -0,0 +1,187 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Newtonsoft.Json; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using AMESCoreStudio.Web.Models; |
||||
|
using System.Collections.Generic; |
||||
|
using Microsoft.AspNetCore.Mvc.Rendering; |
||||
|
using System.Linq; |
||||
|
using AMESCoreStudio.WebApi.Models; |
||||
|
using System; |
||||
|
using System.Data; |
||||
|
using AMESCoreStudio.Web.ViewModels; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.WebApi.DTO.AMES; |
||||
|
|
||||
|
namespace AMESCoreStudio.Web.Controllers |
||||
|
{ |
||||
|
public class LABController : Controller |
||||
|
{ |
||||
|
private readonly ILogger<LABController> _logger; |
||||
|
public readonly IREP _repApi; |
||||
|
public readonly IPPS _ppsApi; |
||||
|
public readonly IBAS _basApi; |
||||
|
public readonly IPCS _pcsApi; |
||||
|
public readonly ISYS _sysApi; |
||||
|
public readonly IKCS _kcsApi; |
||||
|
public readonly IQRS _qrsApi; |
||||
|
public readonly ILAB _labApi; |
||||
|
|
||||
|
private readonly IWebHostEnvironment _env; |
||||
|
|
||||
|
public LABController(ILogger<LABController> logger, IREP repApi, IPPS ppsApi, IBAS basApi, IPCS pcsApi, ISYS sysApi, IKCS kcsApi, IWebHostEnvironment env, IQRS qrsApi, IESUN esunApi, ILAB labApi) |
||||
|
{ |
||||
|
_logger = logger; |
||||
|
_repApi = repApi; |
||||
|
_ppsApi = ppsApi; |
||||
|
_basApi = basApi; |
||||
|
_pcsApi = pcsApi; |
||||
|
_sysApi = sysApi; |
||||
|
_kcsApi = kcsApi; |
||||
|
_qrsApi = qrsApi; |
||||
|
_labApi = labApi; |
||||
|
|
||||
|
_env = env; |
||||
|
} |
||||
|
private void GetFlagList() |
||||
|
{ |
||||
|
|
||||
|
var FlagList = new List<SelectListItem>(); |
||||
|
|
||||
|
|
||||
|
FlagList.Add(new SelectListItem("Y", "Y")); |
||||
|
FlagList.Add(new SelectListItem("N", "N")); |
||||
|
|
||||
|
ViewBag.FlagList = FlagList; |
||||
|
} |
||||
|
public void GetUserID() |
||||
|
{ |
||||
|
var userID = ""; |
||||
|
HttpContext.Request.Cookies.TryGetValue("UserID", out userID); |
||||
|
int user_id = 0; |
||||
|
if (userID != null) |
||||
|
{ |
||||
|
if (int.Parse(userID.ToString()) >= 0) |
||||
|
{ |
||||
|
user_id = int.Parse(userID.ToString()); |
||||
|
} |
||||
|
} |
||||
|
ViewBag.UserID = user_id; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#region LAB001工作群組維護相關
|
||||
|
|
||||
|
public IActionResult LAB001() |
||||
|
{ |
||||
|
return View(); |
||||
|
} |
||||
|
|
||||
|
//新增頁面
|
||||
|
public IActionResult LAB001C() |
||||
|
{ |
||||
|
GetFlagList(); |
||||
|
return View(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
//修改页面
|
||||
|
[HttpGet] |
||||
|
public async Task<IActionResult> LAB001U(int id) |
||||
|
{ |
||||
|
GetFlagList(); |
||||
|
var result = await _labApi.GetLabelParam(id); |
||||
|
|
||||
|
if (result.LabelFieldID == 0) |
||||
|
{ |
||||
|
return View(); |
||||
|
} |
||||
|
return View(result); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//頁面提交,id=0 添加,id>0 修改
|
||||
|
[HttpPost] |
||||
|
public async Task<IActionResult> LAB001CSaveAsync(LabelParam model) |
||||
|
{ |
||||
|
if (ModelState.IsValid) |
||||
|
{ |
||||
|
IResultModel result; |
||||
|
|
||||
|
result = await _labApi.PostLabelParam(JsonConvert.SerializeObject(model)); |
||||
|
|
||||
|
|
||||
|
if (result.Success) //yiru modify 2022-09-27
|
||||
|
{ |
||||
|
var _msg = "添加成功!"; |
||||
|
return RedirectToAction("Refresh", "Home", new { msg = _msg }); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (result.Errors.Count > 0) |
||||
|
{ |
||||
|
ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
ModelState.AddModelError("error", result.Msg); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return View("LAB001C", model); |
||||
|
} |
||||
|
|
||||
|
public async Task<IActionResult> LAB001USaveAsync(LabelParam model) |
||||
|
{ |
||||
|
if (ModelState.IsValid) |
||||
|
{ |
||||
|
IResultModel result; |
||||
|
|
||||
|
result = await _labApi.PutLabelParam(model.LabelFieldID, JsonConvert.SerializeObject(model)); |
||||
|
|
||||
|
if (result.Success) |
||||
|
{ |
||||
|
var _msg = "修改成功!"; |
||||
|
return RedirectToAction("Refresh", "Home", new { msg = _msg }); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (result.Errors.Count > 0) |
||||
|
{ |
||||
|
ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
ModelState.AddModelError("error", result.Msg); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return View("LAB001U", model); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
[ResponseCache(Duration = 0)] |
||||
|
[HttpGet] |
||||
|
public async Task<IActionResult> GetLabParamsAsync() |
||||
|
{ |
||||
|
var result = await _labApi.GetLabParams(); |
||||
|
|
||||
|
if (result.Count > 0) |
||||
|
{ |
||||
|
return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); |
||||
|
} |
||||
|
|
||||
|
return Json(new Table() { count = 0, data = null }); |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,113 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using WebApiClient; |
||||
|
using WebApiClient.Attributes; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.WebApi.Models.BAS; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using AMESCoreStudio.WebApi.DTO.AMES; |
||||
|
|
||||
|
namespace AMESCoreStudio.Web |
||||
|
{ |
||||
|
[JsonReturn] |
||||
|
public interface ILAB: IHttpApi |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數查詢by ID
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/LabelParam/{id}")] |
||||
|
ITask<LabelParam> GetLabelParam(int id); |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數儲存
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPost("api/LabelParam")] |
||||
|
ITask<ResultModel<LabelParam>> PostLabelParam([FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數修改
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPut("api/LabelParam")] |
||||
|
ITask<ResultModel<LabelParam>> PutLabelParam(int id, [FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 獲取Label 全部參數資料
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/LabelParam")] |
||||
|
ITask<List<LabelParam>> GetLabParams(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數儲存
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPost("api/LabelTemplateMaster")] |
||||
|
ITask<ResultModel<LabelTemplateMaster>> PostLabelTemplateMaster([FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數修改
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPut("api/LabelTemplateMaster")] |
||||
|
ITask<ResultModel<LabelTemplateMaster>> PutLabeTemplateMaster(int id, [FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數儲存
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPost("api/LabelTemplatDetail")] |
||||
|
ITask<ResultModel<LabelTemplateDetail>> PostLabelTemplateDetail([FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數修改
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPut("api/LabelTemplateDetail")] |
||||
|
ITask<ResultModel<LabelTemplateDetail>> PutLabeTemplateDetail(int id, [FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數查詢by ID
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/LabelTemplateMaster/{id}")] |
||||
|
ITask<LabelTemplateMaster> GetLabelTemplateMaster(int id); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Label 參數查詢by ID
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/LabelTemplateDetail/{id}")] |
||||
|
ITask<List<LabelTemplateDetail>> GetLabelTemplateDetail(int id); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 獲取Label 全部參數資料
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/LabelTemplateMaster/LabelTemplatebyMatnr/{LabelMatnr}/{Status}")] |
||||
|
ITask<List<LabelTemplateMaster>> GetLabelTemplateDto(string LabelMatnr, string Status, int page , int limit ); |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 獲取Label 全部參數資料
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/LabelTemplateDetail/byTemplateIDMulti/{id}")] |
||||
|
ITask<List<dynamic>> GetLabelTemplatebyMatnr(int id); |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,102 @@ |
|||||
|
@{ |
||||
|
ViewData["Title"] = "Label 需填寫欄位維護"; |
||||
|
Layout = "~/Views/Shared/_AMESLayout.cshtml"; |
||||
|
} |
||||
|
|
||||
|
<div class="layui-card"> |
||||
|
<div class="layui-card-header"> |
||||
|
<div class="layui-form"> |
||||
|
<div class="layui-form-item "> |
||||
|
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-card-body"> |
||||
|
<table class="layui-hide" id="test" lay-filter="test"></table> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts{ |
||||
|
<script type="text/javascript"> |
||||
|
//监听表单提交事件 |
||||
|
hg.form.onsubmit('querysubmit', function (data) { |
||||
|
table && table.reload(data); |
||||
|
}); |
||||
|
var tableCols = [[ |
||||
|
{ |
||||
|
field: 'labelFieldID', |
||||
|
width: 200, |
||||
|
title: '#' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'labelFieldName', |
||||
|
title: '標籤欄位名稱' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'paramName', |
||||
|
title: '標籤變數名稱' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'statusNo', |
||||
|
title: '狀態', |
||||
|
templet: function (d) { |
||||
|
return d.statusNo === 'Y' ? '啟用' : '停用'; |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
field: 'right', |
||||
|
width: 200, |
||||
|
title: '操作', |
||||
|
fixed: 'right', |
||||
|
templet: function (d) { |
||||
|
return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-edit" lay-event="edit">修改</a>' |
||||
|
} |
||||
|
}] |
||||
|
]; |
||||
|
|
||||
|
//通过行tool编辑,lay-event="edit" |
||||
|
function edit(obj) { |
||||
|
if (obj.data.labelFieldID) { |
||||
|
hg.open('修改參數名稱', '/LAB/LAB001U/' + obj.data.labelFieldID, 640,320); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//通过行tool删除,lay-event="del" |
||||
|
function del(obj) { |
||||
|
if (obj.data.groupID) { |
||||
|
hg.confirm("工作群組:" + obj.data.groupName + ",确定要删除吗?", function () { |
||||
|
$.ajax({ |
||||
|
url: '/WHS/WHS001D', |
||||
|
data: { id: obj.data.groupID }, |
||||
|
type: 'POST', |
||||
|
success: function (data) { |
||||
|
if (data.success) { |
||||
|
obj.del(); //只删本地数据 |
||||
|
hg.msghide("删除成功!"); |
||||
|
} |
||||
|
else { |
||||
|
hg.msg(data.msg); |
||||
|
} |
||||
|
}, |
||||
|
error: function () { |
||||
|
hg.msg("网络请求失败!"); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
var toolbar = [{ |
||||
|
text: '新增', |
||||
|
layuiicon: '', |
||||
|
class: 'layui-btn-normal', |
||||
|
handler: function () { |
||||
|
hg.open('新增工作群組', '/LAB/LAB001C', 640, 320); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
]; |
||||
|
//基本数据表格 |
||||
|
var table = hg.table.datatable('test', 'Label 需填寫欄位', '/LAB/GetLabParams', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); |
||||
|
</script> |
||||
|
|
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.LabelParam |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "WHS001C"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; } |
||||
|
|
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !important; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="LAB001CSave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="LabelFieldName" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="LabelFieldName" class="form-control col-sm-9" placeholder="請輸入欄位名稱" /> |
||||
|
<span asp-validation-for="LabelFieldName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ParamName" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ParamName" class="form-control col-sm-9" placeholder="請輸入變數名稱" /> |
||||
|
<span asp-validation-for="ParamName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="StatusNo" class="control-label col-sm-3"></label> |
||||
|
<label class="layui-form-label" style="margin-right: 10px;"> |
||||
|
<input type="radio" asp-for="StatusNo" value="Y" checked> |
||||
|
啟用 |
||||
|
</label> |
||||
|
<label class="layui-form-label"> |
||||
|
<input type="radio" asp-for="StatusNo" value="N"> |
||||
|
停用 |
||||
|
</label> |
||||
|
</div> |
||||
|
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> |
||||
|
<div class="form-group"> |
||||
|
<input type="submit" value="儲存" class="btn btn-primary offset-sm-3" /> |
||||
|
</div> |
||||
|
|
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts { |
||||
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); |
||||
|
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
$(document).ready(function () { |
||||
|
var error = '@Html.ValidationMessage("error")'; |
||||
|
if ($(error).text() != '') { |
||||
|
parent.hg.msg(error); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,65 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.LabelParam |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "LAB001U"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; } |
||||
|
|
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !important; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="LAB001USave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
<input type="hidden" asp-for="LabelFieldID" /> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="LabelFieldName" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="LabelFieldName" class="form-control col-sm-9" readonly="readonly" /> |
||||
|
<span asp-validation-for="LabelFieldName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ParamName" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ParamName" class="form-control col-sm-9" readonly="readonly" /> |
||||
|
<span asp-validation-for="ParamName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="StatusNo" class="control-label col-sm-3"></label> |
||||
|
<label class="layui-form-label" style="margin-right: 10px;"> |
||||
|
<input type="radio" asp-for="StatusNo" value="Y"> |
||||
|
啟用 |
||||
|
</label> |
||||
|
<label class="layui-form-label"> |
||||
|
<input type="radio" asp-for="StatusNo" value="N"> |
||||
|
停用 |
||||
|
</label> |
||||
|
</div> |
||||
|
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> |
||||
|
<div class="form-group"> |
||||
|
<input type="submit" value="儲存" class="btn btn-primary offset-sm-3" /> |
||||
|
</div> |
||||
|
|
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts { |
||||
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); |
||||
|
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
$(document).ready(function () { |
||||
|
var error = '@Html.ValidationMessage("error")'; |
||||
|
if ($(error).text() != '') { |
||||
|
parent.hg.msg(error); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -1,196 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Http; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.EntityFrameworkCore; |
|
||||
using AMESCoreStudio.WebApi; |
|
||||
using AMESCoreStudio.WebApi.Models.AMES; |
|
||||
using AMESCoreStudio.CommonTools.Result; |
|
||||
using System.Text.RegularExpressions; |
|
||||
using Dapper; |
|
||||
using AMESCoreStudio.WebApi.Extensions; |
|
||||
using System.Data; |
|
||||
|
|
||||
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// FQC檢驗項目群組名稱設定檔
|
|
||||
/// </summary>
|
|
||||
[Route("api/[controller]")]
|
|
||||
[ApiController] |
|
||||
public class FqcItemGroupController : ControllerBase |
|
||||
{ |
|
||||
private readonly AMESContext _context; |
|
||||
|
|
||||
public FqcItemGroupController(AMESContext context) |
|
||||
{ |
|
||||
_context = context; |
|
||||
} |
|
||||
|
|
||||
[HttpGet] |
|
||||
public async Task<ActionResult<IEnumerable<FqcItemGroup>>> GetFqcItemGroups() |
|
||||
{ |
|
||||
return await _context.FqcItemGroups.ToListAsync(); |
|
||||
} |
|
||||
|
|
||||
[HttpGet("{id}")] |
|
||||
public async Task<ActionResult<FqcItemGroup>> GetFqcItemGroup(int id) |
|
||||
{ |
|
||||
var fqcItemGroup = await _context.FqcItemGroups.FindAsync(id); |
|
||||
return fqcItemGroup; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// FQC檢驗項目群組名稱設定檔 By Query
|
|
||||
/// </summary>
|
|
||||
/// <param name="no">群組代號</param>
|
|
||||
/// <param name="name">群組名稱</param>
|
|
||||
/// <param name="desc">群組描述</param>
|
|
||||
/// <param name="itemNo">料號</param>
|
|
||||
/// <param name="page">頁數</param>
|
|
||||
/// <param name="limit">筆數</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpGet("FqcItemGroupQuery")] |
|
||||
public async Task<ResultModel<FqcItemGroup>> GetFqcItemGroupQuery(string no, string name, string desc, string itemNo, int page = 0, int limit = 10) |
|
||||
{ |
|
||||
ResultModel<FqcItemGroup> result = new ResultModel<FqcItemGroup>(); |
|
||||
|
|
||||
var query = @$" SELECT DISTINCT
|
|
||||
G.FQC_ITEM_GROUP_ID AS fqcItemGroupId , |
|
||||
G.ITEM_GROUP_NO AS itemGroupNo , |
|
||||
G.ITEM_GROUP_NAME AS itemGroupName , |
|
||||
G.ITEM_GROUP_DESC AS itemGroupDesc |
|
||||
FROM JHAMES.FQC_ITEM_GROUP G |
|
||||
LEFT JOIN JHAMES.FQC_ITEM_GROUP_MATERIAL GM ON G.FQC_ITEM_GROUP_ID = GM.GROUP_ID |
|
||||
LEFT JOIN JHAMES.MATERIAL_ITEM M ON GM.ITEM_ID = M.ITEM_ID |
|
||||
WHERE 1 = 1 ";
|
|
||||
|
|
||||
DynamicParameters p = new DynamicParameters(); |
|
||||
if (!string.IsNullOrWhiteSpace(no)) |
|
||||
{ |
|
||||
query += " AND UPPER(G.ITEM_GROUP_NO) LIKE :No "; |
|
||||
p.Add("No", $"%{no.Trim().ToUpper()}%", DbType.String); |
|
||||
} |
|
||||
|
|
||||
if (!string.IsNullOrWhiteSpace(name)) |
|
||||
{ |
|
||||
query += " AND G.ITEM_GROUP_NAME LIKE :Name "; |
|
||||
p.Add("Name", $"%{name.Trim().ToUpper()}%", DbType.String); |
|
||||
} |
|
||||
|
|
||||
if (!string.IsNullOrWhiteSpace(desc)) |
|
||||
{ |
|
||||
query += " AND G.ITEM_GROUP_DESC LIKE :GroupDesc "; |
|
||||
p.Add("GroupDesc", $"%{desc.Trim().ToUpper()}%", DbType.String); |
|
||||
} |
|
||||
|
|
||||
if (!string.IsNullOrWhiteSpace(itemNo)) |
|
||||
{ |
|
||||
query += " AND UPPER(M.ITEM_NO) LIKE :ItemNo "; |
|
||||
p.Add("ItemNo", $"%{itemNo.Trim().ToUpper()}%", DbType.String); |
|
||||
} |
|
||||
|
|
||||
var q = await _context.Database.DapperQueryAsync<FqcItemGroup>(query, p); |
|
||||
|
|
||||
// 紀錄筆數
|
|
||||
result.DataTotal = q.Count(); |
|
||||
|
|
||||
// Table 頁數
|
|
||||
if (page > 0) |
|
||||
{ |
|
||||
q = q.Skip((page - 1) * limit).Take(limit); |
|
||||
} |
|
||||
result.Data = q; |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 更新FQC檢驗項目群組名稱設定檔
|
|
||||
/// </summary>
|
|
||||
/// <param name="fqcItemGroup"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPut] |
|
||||
public async Task<ResultModel<FqcItemGroup>> PutFqcItemGroup(FqcItemGroup fqcItemGroup) |
|
||||
{ |
|
||||
ResultModel<FqcItemGroup> result = new ResultModel<FqcItemGroup>(); |
|
||||
_context.Entry(fqcItemGroup).State = EntityState.Modified; |
|
||||
_context.Entry<FqcItemGroup>(fqcItemGroup).Property("CreateDate").IsModified = false; |
|
||||
_context.Entry<FqcItemGroup>(fqcItemGroup).Property("CreateUserID").IsModified = false; |
|
||||
fqcItemGroup.UpdateDate = DateTime.Now; |
|
||||
|
|
||||
try |
|
||||
{ |
|
||||
await _context.SaveChangesAsync(); |
|
||||
result.Success = true; |
|
||||
result.Msg = "OK"; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
result.Success = false; |
|
||||
result.Msg = ex.InnerException.Message; |
|
||||
} |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 新增FQC檢驗項目群組名稱設定檔
|
|
||||
/// </summary>
|
|
||||
/// <param name="fqcItemGroup"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
public async Task<ResultModel<FqcItemGroup>> PostFqcItemGroup(FqcItemGroup fqcItemGroup) |
|
||||
{ |
|
||||
ResultModel<FqcItemGroup> result = new ResultModel<FqcItemGroup>(); |
|
||||
Helper helper = new Helper(_context); |
|
||||
fqcItemGroup.FqcItemGroupId = helper.GetIDKey("FQC_ITEM_GROUP_ID").Result; |
|
||||
_context.FqcItemGroups.Add(fqcItemGroup); |
|
||||
try |
|
||||
{ |
|
||||
await _context.SaveChangesAsync(); |
|
||||
result.Success = true; |
|
||||
result.Msg = "OK"; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
result.Success = false; |
|
||||
result.Msg = ex.InnerException.Message; |
|
||||
} |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
[HttpDelete("{id}")] |
|
||||
public async Task<ResultModel<string>> DeleteFqcItemGroup(int id) |
|
||||
{ |
|
||||
ResultModel<string> result = new ResultModel<string>(); |
|
||||
var fqcItemGroup = await _context.FqcItemGroups.FindAsync(id); |
|
||||
var fqcItem = await _context.FqcItems.Where(w => w.GroupId == id).ToListAsync(); |
|
||||
var fqcItemGroupMaterial = await _context.FqcItemGroupMaterials |
|
||||
.Where(w => w.GroupId == id).ToListAsync(); |
|
||||
try |
|
||||
{ |
|
||||
if (fqcItemGroup == null) |
|
||||
{ |
|
||||
result.Success = false; |
|
||||
result.Msg = "找不到要刪除資料"; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
_context.FqcItemGroups.Remove(fqcItemGroup); |
|
||||
_context.FqcItems.RemoveRange(fqcItem); |
|
||||
_context.FqcItemGroupMaterials.RemoveRange(fqcItemGroupMaterial); |
|
||||
await _context.SaveChangesAsync(); |
|
||||
result.Success = true; |
|
||||
result.Msg = "OK"; |
|
||||
} |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
result.Success = false; |
|
||||
result.Msg = ex.InnerException.Message; |
|
||||
} |
|
||||
return result; |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,159 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Http; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.EntityFrameworkCore; |
|
||||
using AMESCoreStudio.WebApi; |
|
||||
using AMESCoreStudio.WebApi.Models.AMES; |
|
||||
using AMESCoreStudio.CommonTools.Result; |
|
||||
using System.Text.RegularExpressions; |
|
||||
using Dapper; |
|
||||
using AMESCoreStudio.WebApi.Extensions; |
|
||||
|
|
||||
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// FQC檢驗項目群組指定料號設定檔
|
|
||||
/// </summary>
|
|
||||
[Route("api/[controller]")]
|
|
||||
[ApiController] |
|
||||
public class FqcItemGroupMaterialController : ControllerBase |
|
||||
{ |
|
||||
private readonly AMESContext _context; |
|
||||
|
|
||||
public FqcItemGroupMaterialController(AMESContext context) |
|
||||
{ |
|
||||
_context = context; |
|
||||
} |
|
||||
|
|
||||
[HttpGet] |
|
||||
public async Task<ActionResult<IEnumerable<FqcItemGroupMaterial>>> GetFqcItemGroupMaterials() |
|
||||
{ |
|
||||
return await _context.FqcItemGroupMaterials.ToListAsync(); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// By GroupId 查詢
|
|
||||
/// </summary>
|
|
||||
/// <param name="id">GroupId</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpGet("ByGroupId/{id}")] |
|
||||
public async Task<ActionResult<IEnumerable<FqcItemGroupMaterial>>> GetFqcItemGroupMaterialByGroupId(int id) |
|
||||
{ |
|
||||
var query = @" SELECT
|
|
||||
F.GROUP_ID AS groupId , |
|
||||
M.ITEM_ID AS itemId , |
|
||||
M.ITEM_NO AS itemNo , |
|
||||
M.ITEM_DESC AS itemDesc , |
|
||||
F.CREATE_USERID AS createUserID , |
|
||||
F.CREATE_DATE AS createDate , |
|
||||
F.UPDATE_USERID AS updateUserID , |
|
||||
F.UPDATE_DATE AS updateDate |
|
||||
FROM JHAMES.FQC_ITEM_GROUP_MATERIAL F |
|
||||
INNER JOIN JHAMES.MATERIAL_ITEM M ON F.ITEM_ID = M.ITEM_ID |
|
||||
WHERE F.GROUP_ID = :GroupId";
|
|
||||
DynamicParameters p = new DynamicParameters(); |
|
||||
p.Add("GroupId", id); |
|
||||
var result = await _context.Database.DapperQueryAsync<FqcItemGroupMaterial>(query, p); |
|
||||
return result.ToList(); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// By ItemId 查詢
|
|
||||
/// </summary>
|
|
||||
/// <param name="id">ItemId</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpGet("ByItemId/{id}")] |
|
||||
public async Task<ActionResult<IEnumerable<FqcItemGroupMaterial>>> GetFqcItemGroupMaterialByItemId(int id) |
|
||||
{ |
|
||||
var query = @" SELECT
|
|
||||
F.GROUP_ID AS groupId , |
|
||||
M.ITEM_ID AS itemId , |
|
||||
M.ITEM_NO AS itemNo , |
|
||||
M.ITEM_DESC AS itemDesc , |
|
||||
F.CREATE_USERID AS createUserID , |
|
||||
F.CREATE_DATE AS createDate , |
|
||||
F.UPDATE_USERID AS updateUserID , |
|
||||
F.UPDATE_DATE AS updateDate |
|
||||
FROM JHAMES.FQC_ITEM_GROUP_MATERIAL F |
|
||||
INNER JOIN JHAMES.MATERIAL_ITEM M ON F.ITEM_ID = M.ITEM_ID |
|
||||
WHERE F.ITEM_ID = :ItemId";
|
|
||||
DynamicParameters p = new DynamicParameters(); |
|
||||
p.Add("ItemId", id); |
|
||||
var result = await _context.Database.DapperQueryAsync<FqcItemGroupMaterial>(query, p); |
|
||||
return result.ToList(); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 更新檢驗群組指定料號設定檔
|
|
||||
/// </summary>
|
|
||||
/// <param name="fqcItemGroupMaterial"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPut] |
|
||||
public async Task<ResultModel<FqcItemGroupMaterial>> PutFqcItemGroupMaterial(FqcItemGroupMaterial fqcItemGroupMaterial) |
|
||||
{ |
|
||||
ResultModel<FqcItemGroupMaterial> result = new ResultModel<FqcItemGroupMaterial>(); |
|
||||
_context.Entry(fqcItemGroupMaterial).State = EntityState.Modified; |
|
||||
_context.Entry<FqcItemGroupMaterial>(fqcItemGroupMaterial).Property("CreateDate").IsModified = false; |
|
||||
_context.Entry<FqcItemGroupMaterial>(fqcItemGroupMaterial).Property("CreateUserID").IsModified = false; |
|
||||
fqcItemGroupMaterial.UpdateDate = DateTime.Now; |
|
||||
|
|
||||
try |
|
||||
{ |
|
||||
await _context.SaveChangesAsync(); |
|
||||
result.Success = true; |
|
||||
result.Msg = "OK"; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
result.Success = false; |
|
||||
result.Msg = ex.InnerException.Message; |
|
||||
} |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 新增檢驗群組指定料號設定檔
|
|
||||
/// </summary>
|
|
||||
/// <param name="fqcItemGroupMaterial"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
public async Task<ResultModel<FqcItemGroupMaterial>> PostFqcItemGroupMaterial(FqcItemGroupMaterial fqcItemGroupMaterial) |
|
||||
{ |
|
||||
ResultModel<FqcItemGroupMaterial> result = new ResultModel<FqcItemGroupMaterial>(); |
|
||||
_context.FqcItemGroupMaterials.Add(fqcItemGroupMaterial); |
|
||||
try |
|
||||
{ |
|
||||
await _context.SaveChangesAsync(); |
|
||||
result.Success = true; |
|
||||
result.Msg = "OK"; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
result.Success = false; |
|
||||
result.Msg = ex.InnerException.Message; |
|
||||
} |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 刪除 檢驗群組指定料號設定檔
|
|
||||
/// </summary>
|
|
||||
/// <param name="id">GroupId</param>
|
|
||||
/// <param name="id1">itemId</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpDelete("{id}/{id1}")] |
|
||||
public async Task<ActionResult<int>> DeleteFqcItemGroupMaterial(int id, int id1) |
|
||||
{ |
|
||||
var query = @" DELETE JHAMES.FQC_ITEM_GROUP_MATERIAL WHERE GROUP_ID =:id
|
|
||||
AND ITEM_ID = :id1";
|
|
||||
DynamicParameters p = new DynamicParameters(); |
|
||||
p.Add("id", id); |
|
||||
p.Add("id1", id1); |
|
||||
var result = await _context.Database.DapperExecuteAsync(query, p); |
|
||||
return result; |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,129 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class LabelParamController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public LabelParamController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
// GET: api/LabelParam
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<LabelParam>>> GetLabelParams() |
||||
|
{ |
||||
|
return await _context.LabelParams.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// GET: api/LabelParam/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<LabelParam>> GetLabelParam(int id) |
||||
|
{ |
||||
|
var LabelParam = await _context.LabelParams.FindAsync(id); |
||||
|
|
||||
|
if (LabelParam == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return LabelParam; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新Label參數檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="labelParam"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPut] |
||||
|
public async Task<ResultModel<LabelParam>> PutBarcodeOutfit(LabelParam labelParam) |
||||
|
{ |
||||
|
ResultModel<LabelParam> result = new ResultModel<LabelParam>(); |
||||
|
_context.Entry(labelParam).State = EntityState.Modified; |
||||
|
//設置容器空間某一個模型的某一個欄位 不提交到資料庫
|
||||
|
_context.Entry<LabelParam>(labelParam).Property("CreateDate").IsModified = false; |
||||
|
_context.Entry<LabelParam>(labelParam).Property("CreateUserID").IsModified = false; |
||||
|
labelParam.UpdateDate = DateTime.Now; |
||||
|
labelParam.UpdateUserID = 0; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增更新Label參數檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="labelParam"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<LabelParam>> PostBarcodeOutfit(LabelParam labelParam) |
||||
|
{ |
||||
|
ResultModel<LabelParam> result = new ResultModel<LabelParam>(); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Helper helper = new Helper(_context); |
||||
|
labelParam.LabelFieldID = helper.GetIDKey("LABEL_FIELD_ID").Result; |
||||
|
_context.LabelParams.Add(labelParam); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// DELETE: api/LabelParam/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<LabelParam>> DeleteLabelParam(int id) |
||||
|
{ |
||||
|
var LabelParam = await _context.LabelParams.FindAsync(id); |
||||
|
if (LabelParam == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.LabelParams.Remove(LabelParam); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return LabelParam; |
||||
|
} |
||||
|
|
||||
|
private bool LabelParamExists(int id) |
||||
|
{ |
||||
|
return _context.LabelParams.Any(e => e.LabelFieldID == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,147 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// FQC檢驗結果ID
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class LabelTemplateDetailController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public LabelTemplateDetailController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
// GET: api/LabelTemplateDetail
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<LabelTemplateDetail>>> GetLabelTemplateDetails() |
||||
|
{ |
||||
|
return await _context.LabelTemplateDetails.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
// GET: api/LabelTemplateDetail/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<LabelTemplateDetail>>> GetLabelTemplateDetail(int id) |
||||
|
{ |
||||
|
var labelTemplateDetail = await _context.LabelTemplateDetails.Where(w=>w.TemplateID == id).ToListAsync(); |
||||
|
|
||||
|
return labelTemplateDetail; |
||||
|
} |
||||
|
|
||||
|
// GET: api/LabelTemplateDetail/5
|
||||
|
[HttpGet("byTemplateIDMulti/{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<dynamic>>> GetLabelTemplateDetailbyTemplateIDMulti(int id) |
||||
|
{ |
||||
|
var q = from p in _context.LabelParams |
||||
|
join d in _context.LabelTemplateDetails |
||||
|
on new { p.LabelFieldID, TemplateID = id } equals new { d.LabelFieldID, d.TemplateID } into d1 |
||||
|
from subd in d1.DefaultIfEmpty() |
||||
|
where p.StatusNo == "Y" |
||||
|
select new |
||||
|
{ |
||||
|
LabelFieldID = p.LabelFieldID, |
||||
|
LabelFieldName = p.LabelFieldName, |
||||
|
ParamName = p.ParamName, |
||||
|
TemplateID = subd != null ? 1 : 0 //有此欄位則顯示為1 沒有就為0
|
||||
|
}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
var query = await q.ToListAsync(); |
||||
|
|
||||
|
return query; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新Label參數檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="LabelTemplateDetail"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPut] |
||||
|
public async Task<ResultModel<LabelTemplateDetail>> PutLabelTemplateDetail(LabelTemplateDetail LabelTemplateDetail) |
||||
|
{ |
||||
|
ResultModel<LabelTemplateDetail> result = new ResultModel<LabelTemplateDetail>(); |
||||
|
_context.Entry(LabelTemplateDetail).State = EntityState.Modified; |
||||
|
//設置容器空間某一個模型的某一個欄位 不提交到資料庫
|
||||
|
_context.Entry<LabelTemplateDetail>(LabelTemplateDetail).Property("CreateDate").IsModified = false; |
||||
|
_context.Entry<LabelTemplateDetail>(LabelTemplateDetail).Property("CreateUserID").IsModified = false; |
||||
|
LabelTemplateDetail.UpdateDate = DateTime.Now; |
||||
|
LabelTemplateDetail.UpdateUserID = 0; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增更新Label參數檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="LabelTemplateDetail"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<LabelTemplateDetail>> PostLabelTemplateDetail(LabelTemplateDetail LabelTemplateDetail) |
||||
|
{ |
||||
|
ResultModel<LabelTemplateDetail> result = new ResultModel<LabelTemplateDetail>(); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Helper helper = new Helper(_context); |
||||
|
LabelTemplateDetail.TemplateID = helper.GetIDKey("TEMPLATE_ID").Result; |
||||
|
_context.LabelTemplateDetails.Add(LabelTemplateDetail); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// DELETE: api/LabelTemplateDetail/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<LabelTemplateDetail>> DeleteLabelTemplateDetail(int id) |
||||
|
{ |
||||
|
var LabelTemplateDetail = await _context.LabelTemplateDetails.FindAsync(id); |
||||
|
if (LabelTemplateDetail == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.LabelTemplateDetails.Remove(LabelTemplateDetail); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return LabelTemplateDetail; |
||||
|
} |
||||
|
|
||||
|
private bool LabelTemplateDetailExists(int id) |
||||
|
{ |
||||
|
return _context.LabelTemplateDetails.Any(e => e.TemplateID == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,165 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using AMESCoreStudio.WebApi.DTO.AMES; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class LabelTemplateMasterController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public LabelTemplateMasterController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
// GET: api/LabelTemplateMaster
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<LabelTemplateMaster>>> GetLabelTemplateMasters() |
||||
|
{ |
||||
|
return await _context.LabelTemplateMasters.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
// GET: api/LabelTemplateMaster/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<LabelTemplateMaster>> GetLabelTemplateMaster(int id) |
||||
|
{ |
||||
|
var LabelTemplateMaster = await _context.LabelTemplateMasters.FindAsync(id); |
||||
|
|
||||
|
if (LabelTemplateMaster == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return LabelTemplateMaster; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新Label參數檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="LabelTemplateMaster"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPut] |
||||
|
public async Task<ResultModel<LabelTemplateMaster>> PutLabelTemplateMaster(LabelTemplateMaster LabelTemplateMaster) |
||||
|
{ |
||||
|
ResultModel<LabelTemplateMaster> result = new ResultModel<LabelTemplateMaster>(); |
||||
|
_context.Entry(LabelTemplateMaster).State = EntityState.Modified; |
||||
|
//設置容器空間某一個模型的某一個欄位 不提交到資料庫
|
||||
|
_context.Entry<LabelTemplateMaster>(LabelTemplateMaster).Property("CreateDate").IsModified = false; |
||||
|
_context.Entry<LabelTemplateMaster>(LabelTemplateMaster).Property("CreateUserID").IsModified = false; |
||||
|
LabelTemplateMaster.UpdateDate = DateTime.Now; |
||||
|
LabelTemplateMaster.UpdateUserID = 0; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增更新Label參數檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="LabelTemplateMaster"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<LabelTemplateMaster>> PostLabelTemplateMaster(LabelTemplateMaster LabelTemplateMaster) |
||||
|
{ |
||||
|
ResultModel<LabelTemplateMaster> result = new ResultModel<LabelTemplateMaster>(); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Helper helper = new Helper(_context); |
||||
|
LabelTemplateMaster.TemplateID = helper.GetIDKey("TEMPLATE_ID").Result; |
||||
|
_context.LabelTemplateMasters.Add(LabelTemplateMaster); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// DELETE: api/LabelTemplateMaster/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<LabelTemplateMaster>> DeleteLabelTemplateMaster(int id) |
||||
|
{ |
||||
|
var LabelTemplateMaster = await _context.LabelTemplateMasters.FindAsync(id); |
||||
|
if (LabelTemplateMaster == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.LabelTemplateMasters.Remove(LabelTemplateMaster); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return LabelTemplateMaster; |
||||
|
} |
||||
|
|
||||
|
// GET: api/LabelTemplateMaster/5
|
||||
|
[HttpGet("LabelTemplatebyMatnr/{LabelMatnr}/{Status}")] |
||||
|
public async Task<ActionResult<IEnumerable<LabelTemplateMaster>>> GetLabelTemplatebyMatnr(string LabelMatnr, string Status, int page = 0, int limit = 10) |
||||
|
{ |
||||
|
|
||||
|
IQueryable<LabelTemplateMaster> q = _context.LabelTemplateMasters; |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(LabelMatnr) && LabelMatnr != "*") |
||||
|
{ |
||||
|
q.Where(w => w.LabelMatnr.Equals(LabelMatnr)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(Status) && Status != "*") |
||||
|
{ |
||||
|
q.Where(w => w.StatusNo.Equals(Status) ); |
||||
|
} |
||||
|
|
||||
|
if (page > 0) |
||||
|
{ |
||||
|
q = q.OrderBy(p => p.LabelMatnr).Skip((page - 1) * limit).Take(limit); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
q = q.OrderBy(p => p.LabelMatnr); |
||||
|
} |
||||
|
|
||||
|
var labelTemplateMasters = await q.ToListAsync(); |
||||
|
|
||||
|
|
||||
|
|
||||
|
return labelTemplateMasters; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
private bool LabelTemplateMasterExists(int id) |
||||
|
{ |
||||
|
return _context.LabelTemplateMasters.Any(e => e.TemplateID == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
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>
|
||||
|
/// Label 參數設定檔
|
||||
|
/// </summary>
|
||||
|
[Table("LABEL_PARAM", Schema = "JHAMES")] |
||||
|
public partial class LabelParam |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 標籤欄位ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("LABEL_FIELD_ID")] |
||||
|
[DataMember] |
||||
|
public int LabelFieldID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 標籤欄位名稱
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "欄位名稱")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Column("LABEL_FIELD_NAME")] |
||||
|
[StringLength(60)] |
||||
|
public string LabelFieldName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 標籤變數名稱
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "變數名稱")] |
||||
|
[Column("PARAM_NAME")] |
||||
|
[StringLength(100)] |
||||
|
public string ParamName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 狀態 P:PASS F:FAIL
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "狀態")] |
||||
|
[Required] |
||||
|
[Column("STATUS_NO")] |
||||
|
[StringLength(1)] |
||||
|
public string StatusNo { get; set; } = "P"; |
||||
|
|
||||
|
/// <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; |
||||
|
} |
||||
|
} |
@ -0,0 +1,75 @@ |
|||||
|
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>
|
||||
|
/// Label 參數設定檔
|
||||
|
/// </summary>
|
||||
|
[Table("LABEL_TEMPLATE_DETAIL", Schema = "JHAMES")] |
||||
|
public partial class LabelTemplateDetail |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 標籤欄位ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("TEMPLATE_ID")] |
||||
|
[DataMember] |
||||
|
public int TemplateID { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 標籤欄位名稱
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "標籤欄位ID")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Column("LABEL_FIELD_ID")] |
||||
|
[StringLength(60)] |
||||
|
public int LabelFieldID { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立UserID
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[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("LabelFieldID")] |
||||
|
[DataMember] |
||||
|
public virtual LabelParam GetLabelParam { get; set; } |
||||
|
} |
||||
|
} |
@ -0,0 +1,109 @@ |
|||||
|
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>
|
||||
|
/// Label 參數設定檔
|
||||
|
/// </summary>
|
||||
|
[Table("LABEL_TEMPLATE_MASTER", Schema = "JHAMES")] |
||||
|
public partial class LabelTemplateMaster |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 標籤欄位ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("TEMPLATE_ID")] |
||||
|
[DataMember] |
||||
|
public int TemplateID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 標籤欄位名稱
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "標籤料號")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Column("LABEL_MATNR")] |
||||
|
[StringLength(20)] |
||||
|
public string LabelMatnr { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 標籤變數名稱
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "標籤檔案")] |
||||
|
[Column("LABEL_FILE")] |
||||
|
[StringLength(100)] |
||||
|
public string LabelFile { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 狀態 P:PASS F:FAIL
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "狀態")] |
||||
|
[Required] |
||||
|
[Column("STATUS_NO")] |
||||
|
[StringLength(1)] |
||||
|
public string StatusNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 圖檔
|
||||
|
/// </summary>
|
||||
|
[Column("IMAGE_NAME")] |
||||
|
[Display(Name = "圖檔")] |
||||
|
[DataMember] |
||||
|
public string ImageName { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立UserID
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[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>
|
||||
|
[DataMember] |
||||
|
[Display(Name = "備註說明")] |
||||
|
[Column("REMARK")] |
||||
|
public string Remark { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 流程站別資料
|
||||
|
/// </summary>
|
||||
|
[ForeignKey("TemplateID")] |
||||
|
[DataMember] |
||||
|
public virtual List<LabelTemplateDetail> GetLabelTemplateDetail { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue