Browse Source

1.新增组件类别维护PPS015

2.新增组件控管模组KCS
3.新增序号料号维护KCS002
PTD
marvinhong 3 years ago
parent
commit
3ad506074f
  1. 131
      AMESCoreStudio.Web/Controllers/KCSController.cs
  2. 106
      AMESCoreStudio.Web/Controllers/PPSController.cs
  3. 54
      AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs
  4. 39
      AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs
  5. 13
      AMESCoreStudio.Web/Views/Home/Framework.cshtml
  6. 90
      AMESCoreStudio.Web/Views/KCS/KCS002.cshtml
  7. 53
      AMESCoreStudio.Web/Views/KCS/KCS002C.cshtml
  8. 53
      AMESCoreStudio.Web/Views/KCS/KCS002U.cshtml
  9. 2
      AMESCoreStudio.Web/Views/PPS/PPS014U.cshtml
  10. 90
      AMESCoreStudio.Web/Views/PPS/PPS015.cshtml
  11. 53
      AMESCoreStudio.Web/Views/PPS/PPS015C.cshtml
  12. 53
      AMESCoreStudio.Web/Views/PPS/PPS015U.cshtml
  13. 191
      AMESCoreStudio.WebApi/Controllers/AMES/PartMapsController.cs
  14. 189
      AMESCoreStudio.WebApi/Controllers/AMES/RepairItemsController.cs
  15. 72
      AMESCoreStudio.WebApi/Models/AMES/PartMap.cs
  16. 37
      AMESCoreStudio.WebApi/Models/AMES/RepairItem.cs
  17. 11
      AMESCoreStudio.WebApi/Models/AMESContext.cs
  18. 2
      AMESCoreStudio.WebApi/appsettings.json

131
AMESCoreStudio.Web/Controllers/KCSController.cs

@ -0,0 +1,131 @@
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using AMESCoreStudio.Web.Models;
using Newtonsoft.Json;
using AMESCoreStudio.WebApi.Models.AMES;
using AMESCoreStudio.CommonTools.Result;
namespace AMESCoreStudio.Web.Controllers
{
public class KCSController : Controller
{
private readonly ILogger<KCSController> _logger;
public readonly IKCS _kcsApi;
public KCSController(ILogger<KCSController> logger, IKCS kcsApi)
{
_logger = logger;
_kcsApi = kcsApi;
}
#region KCS002序號料號維護相關
public IActionResult KCS002()
{
return View();
}
//新增頁面
public IActionResult KCS002C()
{
return View();
}
//修改页面
[HttpGet]
public async Task<IActionResult> KCS002UAsync(string id)
{
var result = await _kcsApi.GetPartMap(id);
if (result.Count == 0)
{
return View();
}
return View(result[0]);
}
public async Task<IActionResult> KCS002DAsync(string id)
{
var result = await _kcsApi.DeletePartMap(id);
return Json(new Result() { success = true, msg = "" });
}
//頁面提交,id=0 添加,id>0 修改
[HttpPost]
public async Task<IActionResult> KCS002CSaveAsync(PartMap model)
{
if (ModelState.IsValid)
{
IResultModel result;
result = await _kcsApi.PostPartMap(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("KCS002C", model);
}
public async Task<IActionResult> KCS002USaveAsync(PartMap model)
{
if (ModelState.IsValid)
{
IResultModel result;
result = await _kcsApi.PutPartMap(model.CorpSN, 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("PPS002U", model);
}
[ResponseCache(Duration = 0)]
[HttpGet]
public async Task<IActionResult> GetPartMapsAsync(int page = 1, int limit = 10)
{
var result_total = await _kcsApi.GetPartMaps(0, limit);
var result = await _kcsApi.GetPartMaps(page, limit);
if (result.Count > 0)
{
return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count });
}
return Json(new Table() { count = 0, data = null });
}
#endregion
}
}

106
AMESCoreStudio.Web/Controllers/PPSController.cs

@ -1771,6 +1771,112 @@ namespace AMESCoreStudio.Web.Controllers
#endregion
#region PPS015組件類別維護相關
public IActionResult PPS015()
{
return View();
}
//新增頁面
public IActionResult PPS015C()
{
return View();
}
//修改页面
[HttpGet]
public async Task<IActionResult> PPS015UAsync(string id)
{
var result = await _ppsApi.GetRepairItem(id);
if (result.Count == 0)
{
return View();
}
return View(result[0]);
}
public async Task<IActionResult> PPS015DAsync(string id)
{
var result = await _ppsApi.DeleteRepairItem(id);
return Json(new Result() { success = true, msg = "" });
}
//頁面提交,id=0 添加,id>0 修改
[HttpPost]
public async Task<IActionResult> PPS015CSaveAsync(RepairItem model)
{
if (ModelState.IsValid)
{
IResultModel result;
result = await _ppsApi.PostRepairItem(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("PPS015C", model);
}
public async Task<IActionResult> PPS015USaveAsync(RepairItem model)
{
if (ModelState.IsValid)
{
IResultModel result;
result = await _ppsApi.PutRepairItem(model.ItemNo, 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("PPS015U", model);
}
[ResponseCache(Duration = 0)]
[HttpGet]
public async Task<IActionResult> GetRepairItemsAsync(int page = 1, int limit = 10)
{
var result_total = await _ppsApi.GetRepairItems(0, limit);
var result = await _ppsApi.GetRepairItems(page, limit);
if (result.Count > 0)
{
return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count });
}
return Json(new Table() { count = 0, data = null });
}
#endregion
#region PPS016 問題類別維護相關

54
AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs

@ -0,0 +1,54 @@
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;
namespace AMESCoreStudio.Web
{
[JsonReturn]
public interface IKCS:IHttpApi
{
#region KCS002 序號料號維護
/// <summary>
/// 新增序號料號
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpPost("api/PartMaps")]
ITask<ResultModel<PartMap>> PostPartMap([FromBody, RawJsonContent] string model);
/// <summary>
/// 更新序號料號
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpPut("api/PartMaps/{id}")]
ITask<ResultModel<PartMap>> PutPartMap(string id, [FromBody, RawJsonContent] string model);
/// <summary>
/// 刪除序號料號
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpDelete("api/PartMaps/{id}")]
ITask<ResultModel<PartMap>> DeletePartMap(string id);
/// <summary>
/// 根據ID獲取指定序號料號資料
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/PartMaps/{id}")]
ITask<List<PartMap>> GetPartMap(string id);
/// <summary>
/// 獲取序號料號資料
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/PartMaps")]
ITask<List<PartMap>> GetPartMaps(int page = 1, int limit = 10);
#endregion
}
}

39
AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs

@ -561,6 +561,45 @@ namespace AMESCoreStudio.Web
#endregion
#region PPS015 組件類別維護
/// <summary>
/// 新增組件類別
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpPost("api/RepairItems")]
ITask<ResultModel<RepairItem>> PostRepairItem([FromBody, RawJsonContent] string model);
/// <summary>
/// 更新組件類別
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpPut("api/RepairItems/{id}")]
ITask<ResultModel<RepairItem>> PutRepairItem(string id, [FromBody, RawJsonContent] string model);
/// <summary>
/// 刪除組件類別
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpDelete("api/RepairItems/{id}")]
ITask<ResultModel<RepairItem>> DeleteRepairItem(string id);
/// <summary>
/// 根據ID獲取指定組件類別資料
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/RepairItems/{id}")]
ITask<List<RepairItem>> GetRepairItem(string id);
/// <summary>
/// 獲取組件類別資料
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/RepairItems")]
ITask<List<RepairItem>> GetRepairItems(int page = 1, int limit = 10);
#endregion
#region PPS016 問題類別維護
/// <summary>

13
AMESCoreStudio.Web/Views/Home/Framework.cshtml

@ -204,11 +204,24 @@
<li class="sub-tab" hg-title="維修方式維護" hg-nav="/PPS/PPS014">
<a><i class="fa fa-comment-o fa-fw"></i><cite>維修方式維護</cite></a>
</li>
<li class="sub-tab" hg-title="組件類別維護" hg-nav="/PPS/PPS015">
<a><i class="fa fa-comment-o fa-fw"></i><cite>組件類別維護</cite></a>
</li>
<li class="sub-tab" hg-title="問題類別維護" hg-nav="/PPS/PPS016">
<a><i class="fa fa-comment-o fa-fw"></i><cite>問題類別維護</cite></a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-cog fa-fw" style="color:#77B272;"></i><cite style="color:#77B272;">組件控管模組</cite><i class="fa fa-angle-up fa-fw nav_right"></i>
</a>
<ul class="sub-menu">
<li class="sub-tab" hg-title="序號-料號維護" hg-nav="/KCS/KCS002">
<a><i class="fa fa-comment-o fa-fw"></i><cite>序號-料號維護</cite></a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-folder-o fa-fw" style="color:#77B272;"></i><cite style="color:#77B272;">製程控管模組</cite><i class="fa fa-angle-up fa-fw nav_right"></i>

90
AMESCoreStudio.Web/Views/KCS/KCS002.cshtml

@ -0,0 +1,90 @@
@{
ViewData["Title"] = "序號料號維護";
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: 'corpSN',
width: 200,
title: '序號'
},
{
field: 'corpPN',
title: '料號'
},
{
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> <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del">删除</a>'
}
}]
];
//通过行tool编辑,lay-event="edit"
function edit(obj) {
if (obj.data.corpSN) {
hg.open('修改序號料號', '/KCS/KCS002U/' + obj.data.corpSN, 640,320);
}
}
//通过行tool删除,lay-event="del"
function del(obj) {
if (obj.data.corpSN) {
hg.confirm("序號料號:" + obj.data.corpSN + "," + obj.data.corpPN + ",确定要删除吗?", function () {
$.ajax({
url: '/KCS/KCS002D',
data: { id: obj.data.corpSN },
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: '&#xe608;',
class: 'layui-btn-normal',
handler: function () {
hg.open('新增序號料號', '/KCS/KCS002C', 640, 320);
}
}
];
//基本数据表格
var table = hg.table.datatable('test', '序號料號維護', '/KCS/GetPartMaps', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']);
</script>
}

53
AMESCoreStudio.Web/Views/KCS/KCS002C.cshtml

@ -0,0 +1,53 @@
@model AMESCoreStudio.WebApi.Models.AMES.PartMap
@{ ViewData["Title"] = "KCS002C";
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="KCS002CSave">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group form-inline my-sm-1">
<label asp-for="CorpSN" class="control-label col-sm-3"></label>
<input asp-for="CorpSN" class="form-control col-sm-9" placeholder="請輸入序號" />
<span asp-validation-for="CorpSN" class="text-danger offset-sm-3 my-sm-1"></span>
</div>
<div class="form-group form-inline my-sm-1">
<label asp-for="CorpPN" class="control-label col-sm-3"></label>
<input asp-for="CorpPN" class="form-control col-sm-9" placeholder="請輸入料號" />
<span asp-validation-for="CorpPN" class="text-danger offset-sm-3 my-sm-1"></span>
</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>
}

53
AMESCoreStudio.Web/Views/KCS/KCS002U.cshtml

@ -0,0 +1,53 @@
@model AMESCoreStudio.WebApi.Models.AMES.PartMap
@{ ViewData["Title"] = "KCS002U";
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="KCS002USave">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group form-inline my-sm-1">
<label asp-for="CorpSN" class="control-label col-sm-3"></label>
<input asp-for="CorpSN" class="form-control col-sm-9" placeholder="請輸入序號" readonly="readonly" />
<span asp-validation-for="CorpSN" class="text-danger offset-sm-3 my-sm-1"></span>
</div>
<div class="form-group form-inline my-sm-1">
<label asp-for="CorpPN" class="control-label col-sm-3"></label>
<input asp-for="CorpPN" class="form-control col-sm-9" placeholder="請輸入料號" />
<span asp-validation-for="CorpPN" class="text-danger offset-sm-3 my-sm-1"></span>
</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>
}

2
AMESCoreStudio.Web/Views/PPS/PPS014U.cshtml

@ -18,7 +18,7 @@
<div class="form-group form-inline my-sm-1">
<label asp-for="RepairTypeNo" class="control-label col-sm-3"></label>
<input asp-for="RepairTypeNo" class="form-control col-sm-9" placeholder="請輸入維修項目代碼" />
<input asp-for="RepairTypeNo" class="form-control col-sm-9" placeholder="請輸入維修項目代碼" readonly="readonly" />
<span asp-validation-for="RepairTypeNo" class="text-danger offset-sm-3 my-sm-1"></span>
</div>
<div class="form-group form-inline my-sm-1">

90
AMESCoreStudio.Web/Views/PPS/PPS015.cshtml

@ -0,0 +1,90 @@
@{
ViewData["Title"] = "組件類別維護";
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: 'itemNo',
width: 200,
title: '組件類別代碼'
},
{
field: 'itemName',
title: '組件類別名稱'
},
{
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> <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del">删除</a>'
}
}]
];
//通过行tool编辑,lay-event="edit"
function edit(obj) {
if (obj.data.itemNo) {
hg.open('修改組件類別', '/PPS/PPS015U/' + obj.data.itemNo, 640,320);
}
}
//通过行tool删除,lay-event="del"
function del(obj) {
if (obj.data.itemNo) {
hg.confirm("組件類別:" + obj.data.itemName + ",确定要删除吗?", function () {
$.ajax({
url: '/PPS/PPS015D',
data: { id: obj.data.itemNo },
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: '&#xe608;',
class: 'layui-btn-normal',
handler: function () {
hg.open('新增組件類別', '/PPS/PPS015C', 640, 320);
}
}
];
//基本数据表格
var table = hg.table.datatable('test', '組件類別維護', '/PPS/GetRepairItems', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']);
</script>
}

53
AMESCoreStudio.Web/Views/PPS/PPS015C.cshtml

@ -0,0 +1,53 @@
@model AMESCoreStudio.WebApi.Models.AMES.RepairItem
@{ ViewData["Title"] = "PPS015C";
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="PPS015CSave">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group form-inline my-sm-1">
<label asp-for="ItemNo" class="control-label col-sm-3"></label>
<input asp-for="ItemNo" class="form-control col-sm-9" placeholder="請輸入組件類別代碼" />
<span asp-validation-for="ItemNo" class="text-danger offset-sm-3 my-sm-1"></span>
</div>
<div class="form-group form-inline my-sm-1">
<label asp-for="ItemName" class="control-label col-sm-3"></label>
<input asp-for="ItemName" class="form-control col-sm-9" placeholder="請輸入組件類別名稱" />
<span asp-validation-for="ItemName" class="text-danger offset-sm-3 my-sm-1"></span>
</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>
}

53
AMESCoreStudio.Web/Views/PPS/PPS015U.cshtml

@ -0,0 +1,53 @@
@model AMESCoreStudio.WebApi.Models.AMES.RepairItem
@{ ViewData["Title"] = "PPS015U";
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="PPS015USave">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group form-inline my-sm-1">
<label asp-for="ItemNo" class="control-label col-sm-3"></label>
<input asp-for="ItemNo" class="form-control col-sm-9" placeholder="請輸入組件類別代碼" readonly="readonly" />
<span asp-validation-for="ItemNo" class="text-danger offset-sm-3 my-sm-1"></span>
</div>
<div class="form-group form-inline my-sm-1">
<label asp-for="ItemName" class="control-label col-sm-3"></label>
<input asp-for="ItemName" class="form-control col-sm-9" placeholder="請輸入組件類別名稱" />
<span asp-validation-for="ItemName" class="text-danger offset-sm-3 my-sm-1"></span>
</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>
}

191
AMESCoreStudio.WebApi/Controllers/AMES/PartMapsController.cs

@ -0,0 +1,191 @@
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 PartMapsController : ControllerBase
{
private readonly AMESContext _context;
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public PartMapsController(AMESContext context)
{
_context = context;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
// GET: api/PartMaps
[HttpGet]
public async Task<ActionResult<IEnumerable<PartMap>>> GetPartMap(int page = 1, int limit = 10)
{
IQueryable<PartMap> q = _context.PartMaps;
if (page > 0)
{
q = q.OrderBy(p => p.CorpSN).Skip((page - 1) * limit).Take(limit);
}
else
{
q = q.OrderBy(p => p.CorpSN);
}
var partMap = await q.ToListAsync();
return partMap;
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// GET: api/PartMaps/5
[HttpGet("{id}")]
public async Task<ActionResult<IEnumerable<PartMap>>> GetPartMap(string id)
{
IQueryable<PartMap> q = _context.PartMaps;
q = q.Where(p => p.CorpSN == id);
var partMap = await q.ToListAsync();
if (partMap == null)
{
return NotFound();
}
return partMap;
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="partMap"></param>
/// <returns></returns>
// PUT: api/PartMaps/5
// To protect from overposting attacks, enable the specific properties you want to bind to, for
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
[HttpPut("{id}")]
public async Task<ResultModel<PartMap>> PutPartMap(string id, [FromBody] PartMap partMap)
{
ResultModel<PartMap> result = new ResultModel<PartMap>();
if (id != partMap.CorpSN)
{
result.Success = false;
result.Msg = "序號錯誤";
return result;
}
_context.Entry(partMap).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!PartMapExists(id))
{
result.Success = false;
result.Msg = "序號不存在";
return result;
}
else
{
throw;
}
}
result.Success = true;
result.Msg = "OK";
return result;
}
/// <summary>
///
/// </summary>
/// <param name="partMap"></param>
/// <returns></returns>
// POST: api/PartMaps
// To protect from overposting attacks, enable the specific properties you want to bind to, for
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
[HttpPost]
public async Task<ResultModel<PartMap>> PostPartMap([FromBody]PartMap partMap)
{
ResultModel<PartMap> result = new ResultModel<PartMap>();
_context.PartMaps.Add(partMap);
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateException)
{
if (PartMapExists(partMap.CorpSN))
{
result.Success = false;
result.Msg = "序號重複";
return result;
}
else
{
throw;
}
}
result.Success = true;
result.Msg = "OK";
return result;
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/PartMaps/5
[HttpDelete("{id}")]
public async Task<ResultModel<PartMap>> DeletePartMap(string id)
{
ResultModel<PartMap> result = new ResultModel<PartMap>();
var partMap = await _context.PartMaps.FindAsync(id);
if (partMap == null)
{
result.Success = false;
result.Msg = "序號不存在";
return result;
}
_context.PartMaps.Remove(partMap);
await _context.SaveChangesAsync();
result.Success = true;
result.Msg = "OK";
return result;
}
private bool PartMapExists(string id)
{
return _context.PartMaps.Any(e => e.CorpSN == id);
}
}
}

189
AMESCoreStudio.WebApi/Controllers/AMES/RepairItemsController.cs

@ -0,0 +1,189 @@
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 RepairItemsController : ControllerBase
{
private readonly AMESContext _context;
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public RepairItemsController(AMESContext context)
{
_context = context;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
// GET: api/RepairItems
[HttpGet]
public async Task<ActionResult<IEnumerable<RepairItem>>> GetRepairItem(int page = 1, int limit = 10)
{
IQueryable<RepairItem> q = _context.RepairItems;
if (page > 0)
{
q = q.OrderBy(p => p.ItemNo).Skip((page - 1) * limit).Take(limit);
}
else
{
q = q.OrderBy(p => p.ItemNo);
}
var repairItem = await q.ToListAsync();
return repairItem;
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// GET: api/RepairItems/5
[HttpGet("{id}")]
public async Task<ActionResult<IEnumerable<RepairItem>>> GetRepairItem(string id)
{
IQueryable<RepairItem> q = _context.RepairItems;
q = q.Where(p => p.ItemNo.Equals(id));
var repairItem = await q.ToListAsync();
if (repairItem == null)
{
return NotFound();
}
return repairItem;
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="repairItem"></param>
/// <returns></returns>
// PUT: api/RepairItems/5
// To protect from overposting attacks, enable the specific properties you want to bind to, for
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
[HttpPut("{id}")]
public async Task<ResultModel<RepairItem>> PutRepairItem(string id, [FromBody] RepairItem repairItem)
{
ResultModel<RepairItem> result = new ResultModel<RepairItem>();
if (id != repairItem.ItemNo)
{
result.Success = false;
result.Msg = "組件類別代碼錯誤";
return result;
}
_context.Entry(repairItem).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!RepairItemExists(id))
{
result.Success = false;
result.Msg = "組件類別代碼不存在";
return result;
}
else
{
throw;
}
}
result.Success = true;
result.Msg = "OK";
return result;
}
/// <summary>
///
/// </summary>
/// <param name="repairItem"></param>
/// <returns></returns>
// POST: api/RepairItems
// To protect from overposting attacks, enable the specific properties you want to bind to, for
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
[HttpPost]
public async Task<ResultModel<RepairItem>> PostRepairItem([FromBody] RepairItem repairItem)
{
ResultModel<RepairItem> result = new ResultModel<RepairItem>();
_context.RepairItems.Add(repairItem);
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateException)
{
if (RepairItemExists(repairItem.ItemNo))
{
result.Success = false;
result.Msg = "組件類別代碼重複";
return result;
}
else
{
throw;
}
}
result.Success = true;
result.Msg = "OK";
return result;
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/RepairItems/5
[HttpDelete("{id}")]
public async Task<ResultModel<RepairItem>> DeleteRepairItem(string id)
{
ResultModel<RepairItem> result = new ResultModel<RepairItem>();
var repairItem = await _context.RepairItems.FindAsync(id);
if (repairItem == null)
{
result.Success = false;
result.Msg = "組件類別不存在";
return result;
}
_context.RepairItems.Remove(repairItem);
await _context.SaveChangesAsync();
result.Success = true;
result.Msg = "OK";
return result;
}
private bool RepairItemExists(string id)
{
return _context.RepairItems.Any(e => e.ItemNo == id);
}
}
}

72
AMESCoreStudio.WebApi/Models/AMES/PartMap.cs

@ -0,0 +1,72 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace AMESCoreStudio.WebApi.Models.AMES
{
/// <summary>
/// 序號料號資料表
/// </summary>
[Table("PART_MAP", Schema = "JHAMES")]
public class PartMap
{
/// <summary>
/// 序號
/// </summary>
[Key]
[Column("CORP_SN")]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "序號")]
[StringLength(40, ErrorMessage = "{0},不能大于{1}")]
[DataMember]
public string CorpSN { get; set; }
/// <summary>
/// 料號
/// </summary>
[Column("CORP_PN")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "料號")]
[StringLength(30, ErrorMessage = "{0},不能大于{1}")]
public string CorpPN { get; set; }
/// <summary>
/// 序號狀態
/// </summary>
[Column("SN_STATUS")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "序號狀態")]
public int SNStatus { get; set; } = 0;
/// <summary>
/// 建立者
/// </summary>
[Column("CREATE_USERID")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "建立者")]
public decimal CreateUserID { get; set; } = 0;
/// <summary>
/// 建立時間
/// </summary>
[Column("CREATE_DATE")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "建立時間")]
public DateTime CreateDate { get; set; } = DateTime.Now;
/// <summary>
/// 修改時間
/// </summary>
[Column("UPDATE_DATE")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "修改時間")]
public DateTime UpdateDate { get; set; } = DateTime.Now;
}
}

37
AMESCoreStudio.WebApi/Models/AMES/RepairItem.cs

@ -0,0 +1,37 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace AMESCoreStudio.WebApi.Models.AMES
{
/// <summary>
/// 組件類別資料表
/// </summary>
[Table("REPAIR_ITEM", Schema = "JHAMES")]
[DataContract]
public class RepairItem
{
/// <summary>
/// 組件類別代碼
/// </summary>
[Key]
[Column("ITEM_NO")]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "組件類別代碼")]
[StringLength(6, ErrorMessage = "{0},不能大于{1}")]
[DataMember]
public string ItemNo { get; set; }
/// <summary>
/// 組件類別名稱
/// </summary>
[Column("ITEM_NAME")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "組件類別名稱")]
[StringLength(50, ErrorMessage = "{0},不能大于{1}")]
public string ItemName { get; set; }
}
}

11
AMESCoreStudio.WebApi/Models/AMESContext.cs

@ -84,6 +84,7 @@ namespace AMESCoreStudio.WebApi
modelBuilder.Entity<Rules>().HasKey(c => new { c.RuleStationID, c.RuleStatus });
modelBuilder.Entity<WipBarcode>().HasKey(c => new { c.WipNO, c.StartNO, c.EndNO });
modelBuilder.Entity<WipLog>().HasKey(c => new { c.WipID, c.CreateDate});
modelBuilder.Entity<PartMap>().HasKey(c => new { c.CorpSN });
modelBuilder.Entity<CycleTime>().HasKey(c => new { c.ItemNo, c.LineID });
modelBuilder.Entity<CycleTime>().HasOne(r => r.Unit).WithMany().HasForeignKey(r => r.SectionNo).IsRequired();
@ -292,6 +293,16 @@ namespace AMESCoreStudio.WebApi
/// 維修方式資料
/// </summary>
public DbSet<RepairType> RepairTypes { get; set; }
/// <summary>
/// 組件類別資料
/// </summary>
public DbSet<RepairItem> RepairItems { get; set; }
/// <summary>
/// 序號料號資料
/// </summary>
public DbSet<PartMap> PartMaps { get; set; }
}
}

2
AMESCoreStudio.WebApi/appsettings.json

@ -8,7 +8,7 @@
},
"ConnectionStrings": {
"AMESContext2": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.5)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=gdb)));User Id=JHSYS;Password=12345;",
"AMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=cpadb)));User Id=JHSYS;Password=ASYS666;"
"AMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=jhdb)));User Id=JHSYS;Password=ASYS666;"
},
"AllowedHosts": "*"
}

Loading…
Cancel
Save