diff --git a/AMESCoreStudio.Web/Controllers/JIGController.cs b/AMESCoreStudio.Web/Controllers/JIGController.cs
index 5df08f07..a7e14e1b 100644
--- a/AMESCoreStudio.Web/Controllers/JIGController.cs
+++ b/AMESCoreStudio.Web/Controllers/JIGController.cs
@@ -585,10 +585,22 @@ namespace AMESCoreStudio.Web.Controllers
 
             return View(result[0]);
         }
-        public async Task<IActionResult> JIG004DAsync(int id)
+
+
+        public async Task<IActionResult> JIG004D(int id )
         {
-            var result = await _jigApi.DeleteOutfitInfo(id);
-            return Json(new Result() { success = true, msg = "" });
+            var result = await _jigApi.GetOutfitInfo(id);
+
+            if (result.Count == 0)
+            {
+                return View();
+            }
+            else
+            {
+                return View(result[0]);
+            }
+
+           
         }
         [HttpPost]
         public async Task<IActionResult> JIG004CSaveAsync(OutfitInfo model)
@@ -794,6 +806,43 @@ namespace AMESCoreStudio.Web.Controllers
             //  GetUserID();
             return View();
         }
+
+        public async Task<IActionResult> JIG004DSaveAsync(OutfitInfo model)
+        {
+            var msg = "";
+            if (ModelState.IsValid)
+            {
+                string Status = string.Empty;
+                IResultModel result;
+                if (model.StatusNo == "A")
+                {
+                    model.StatusNo = "S";
+                    Status = "停用";
+                }
+                else
+                {
+                    model.StatusNo = "A";
+                    Status = "啟用";
+                }
+ 
+                result = await _jigApi.PutOutfitInfo(model.OutfitID, JsonConvert.SerializeObject(model));
+
+                if (result.Success)
+                {
+                    var _msg = Status +"成功!";
+                    return RedirectToAction("Refresh", "Home", new { msg = _msg });
+                }
+                else
+                {
+
+                    msg = result.Msg;
+
+                }
+            }
+            if (msg == "") msg = "缺少必填資料";
+            ModelState.AddModelError("error", msg);
+            return View("JIG004D", model);
+        }
         //  YIRU ADD
 
 
@@ -1039,7 +1088,7 @@ namespace AMESCoreStudio.Web.Controllers
                 IResultModel result1;
                 var OutfitInfo = await _jigApi.GetOutfitInfo(model.OutfitID);
                 var modi = OutfitInfo[0];
-                modi.UseStatusNo = "S";
+                modi.UseStatusNo = "C";
                 modi.StatusNo = "S";
                 modi.Custondian = model.StatusUserID;
                 result1 = await _jigApi.PutOutfitInfo(model.OutfitID, JsonConvert.SerializeObject(modi));
@@ -1078,7 +1127,7 @@ namespace AMESCoreStudio.Web.Controllers
                 IResultModel result1;
                 var OutfitInfo = await _jigApi.GetOutfitInfo(model.OutfitID);
                 var modi = OutfitInfo[0];
-                modi.UseStatusNo = "F";
+                modi.UseStatusNo = "S";
                 modi.Custondian = model.StatusUserID;
                 result1 = await _jigApi.PutOutfitInfo(model.OutfitID, JsonConvert.SerializeObject(modi));
                 if (result1.Success)
diff --git a/AMESCoreStudio.Web/Controllers/KCSController.cs b/AMESCoreStudio.Web/Controllers/KCSController.cs
index 446684d6..b48fd946 100644
--- a/AMESCoreStudio.Web/Controllers/KCSController.cs
+++ b/AMESCoreStudio.Web/Controllers/KCSController.cs
@@ -702,7 +702,7 @@ namespace AMESCoreStudio.Web.Controllers
             return View();
         }
         [HttpPost]
-        public async Task<IActionResult> KCS005SaveAsync(InspectionResultBlob model, IFormFile formFile)
+        public async Task<IActionResult> KCS005SaveAsync(KPLink model, IFormFile formFile)
         {
             IResultModel result;
             var tt = await _kcsApi.GetKPLink("");
diff --git a/AMESCoreStudio.Web/Controllers/WHSController.cs b/AMESCoreStudio.Web/Controllers/WHSController.cs
index 90016638..0d639c8c 100644
--- a/AMESCoreStudio.Web/Controllers/WHSController.cs
+++ b/AMESCoreStudio.Web/Controllers/WHSController.cs
@@ -241,7 +241,31 @@ namespace AMESCoreStudio.Web.Controllers
             ViewBag.StationList = StationItems;
         }
 
+        private async Task GetExceptionReasonList()
+        {
+            var result = await _whsApi.GetExceptionReasons();
+
+            var GetExceptionReasons = new List<SelectListItem>();
+            for (int i = 0; i < result.Count; i++)
+            {
+                GetExceptionReasons.Add(new SelectListItem(result[i].ReasonDescCH, result[i].ReasonNo));
+            }
+
+            ViewBag.ExceptionReasons = GetExceptionReasons;
+        }
+
 
+        private async Task GetUserInfo()
+        {
+            var result = await _sysApi.GetUserInfoes();
+
+            var UserItems = new List<SelectListItem>();
+            foreach (var item in result.Data)
+            {
+                UserItems.Add(new SelectListItem(item.UserName, item.UserID.ToString()));
+            }
+            ViewBag.UserList = UserItems;
+        }
         #endregion
 
         #region WHS001工作群組維護相關
@@ -571,8 +595,9 @@ namespace AMESCoreStudio.Web.Controllers
             if (l == 0)  //yiru modify 2022-10-04
                 l = -99;
         //        return Json(new Table() { count = 0, data = null });
-            if (string.IsNullOrEmpty(i))
-                i = "Null";
+            if (string.IsNullOrEmpty(i)) //若沒輸入料號查詢 就不帶出資料
+                return Json(new Table() { count = 0, data = null });
+            //i = "Null";
             if (string.IsNullOrEmpty(u))
                 u = "Null";
             if (u=="0")
@@ -851,28 +876,76 @@ namespace AMESCoreStudio.Web.Controllers
         {
             if (ModelState.IsValid)
             {
-                IResultModel result;
+                var Msg = string.Empty;
+                if (model.UnitNoI != "0")
+                {
+                    if (model.StationIDI == -1)
+                    {
+                        Msg += "請選擇援入站別\r\n";
+                    }
+                    if (model.LineIDI == 0)
+                    {
+                        Msg += "請選擇援入線別\r\n";
+                    }
+
+                }
+                else
+                {
+                    if (model.OtherDeptI == "0")
+                    {
+                        Msg += "請選擇援入其他部門\r\n";
+                    }
 
-                result = await _whsApi.PostSupportUser(JsonConvert.SerializeObject(model));
+                }
 
-                
-                if (result.Success)
+                if (model.UnitNoO != "0")
                 {
-                    var _msg = "添加成功!";
-                    return RedirectToAction("Refresh", "Home", new { msg = _msg });
+                    if (model.StationIDO == -1)
+                    {
+                        Msg += "請選擇援出站別\r\n";
+                    }
+                    if (model.LineIDO == 0)
+                    {
+                        Msg += "請選擇援出線別\r\n";
+                    }
+
                 }
                 else
                 {
-                    if (result.Errors.Count > 0)
+                    if (model.OtherDeptO == "0")
                     {
-                        ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg);
+                        Msg += "請選擇援出其他部門\r\n";
+                    }
+                }
+
+                if (Msg != null)
+                {
+                    ModelState.AddModelError("error", Msg);
+                }
+                else
+                { 
+                    IResultModel result;
+                    result = await _whsApi.PostSupportUser(JsonConvert.SerializeObject(model));
+
+
+                    if (result.Success)
+                    {
+                        var _msg = "添加成功!";
+                        return RedirectToAction("Refresh", "Home", new { msg = _msg });
                     }
                     else
                     {
-                        ModelState.AddModelError("error", result.Msg);
+                        if (result.Errors.Count > 0)
+                        {
+                            ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg);
+                        }
+                        else
+                        {
+                            ModelState.AddModelError("error", result.Msg);
+                        }
                     }
-                }
             }
+        }
             return View("WHS008C", model);
         }
         public async Task<IActionResult> WHS008USaveAsync(SupportUser model)
@@ -966,6 +1039,7 @@ namespace AMESCoreStudio.Web.Controllers
             //內部/外部
             //EXCEPTION_Class
             //EXCEPTION_CODE
+            await GetExceptionReasonList();
 
             return View();
         }
@@ -990,6 +1064,11 @@ namespace AMESCoreStudio.Web.Controllers
 
             await GetExceptionCodesList();
 
+            await GetExceptionReasonList();
+
+            await GetUserInfo();
+
+
             var result = await _whsApi.GetExceptionWorktime(id);
             var result2 = await _whsApi.GetExceptionCode(result[0].ExceptionNo);
             ViewBag.ClassNo = result2[0].ExceptionClassNo;
@@ -997,6 +1076,7 @@ namespace AMESCoreStudio.Web.Controllers
             ViewBag.GroupNo = result3[0].ExceptionGroupNo;
 
 
+
             if (result.Count == 0)
             {
                 return View();
@@ -1014,8 +1094,18 @@ namespace AMESCoreStudio.Web.Controllers
             if (ModelState.IsValid)
             {
                 IResultModel result;
+                if (model.PersonNo != null)
+                {
+                    var Reasons = await _whsApi.GetExceptionReason(model.PersonNo);
+                    model.ReasonNameCh = Reasons[0].ReasonDescCH;
+                }
+                if (model.Measure != null)
+                {
+                    model.MeasureDate = System.DateTime.Now;
+                }
+          
 
-                result = await _whsApi.PostExceptionWorktime(JsonConvert.SerializeObject(model));
+                result = await _whsApi.PostExceptionWorktime(JsonConvert.SerializeObject(model)); //yiru modify 2022-10-04
 
 
                 if (result.Success)
@@ -1074,7 +1164,8 @@ namespace AMESCoreStudio.Web.Controllers
         {
             if (factoryNo == null)
             {
-                factoryNo = "*";
+                //factoryNo = "*";
+                return Json(new Table() { count = 0, data = null });
             }
             if (unitNo == null)
             {
@@ -1202,6 +1293,18 @@ namespace AMESCoreStudio.Web.Controllers
 
         }
 
+
+        public async Task<IActionResult> GetExceptionReasonsByExceptionNoAsync(string id)
+        {
+            var result = await _whsApi.GetExceptionReason(id);
+
+            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
 
         #region WHS011重工標準工時維護相關
diff --git a/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml
index aca3477f..420c6bfb 100644
--- a/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml
+++ b/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml
@@ -154,7 +154,7 @@
                 hg.open('修改設備基本資料', '/JIG/JIG004U/' + obj.data.outfitID, 640,320);
             }
         }
-
+    
         //通过行tool删除,lay-event="del"
         function del(obj) {
             var status;
@@ -165,24 +165,26 @@
                 status = "啟用";
 
             if (obj.data.outfitID) {
-                hg.confirm("設備:" + obj.data.outfitNo + ",确定要" + status +"吗?", function () {
-                    $.ajax({
-                        url: '/JIG/JIG004D',
-                        data: { id: obj.data.outfitID },
-                        type: 'POST',
-                        success: function (data) {
-                            if (data.success) {
-                                obj.del(); //只删本地数据
-                                hg.msghide(status+"成功!");
-                            }
-                            else {
-                                hg.msg(data.msg);
-                            }
-                        },
-                        error: function () {
-                            hg.msg("网络请求失败!");
-                        }
-                    });
+
+                hg.confirm("設備:" + obj.data.outfitNo + ",确定要" + status + "吗?", function () {
+                    hg.open('停用啟用基本設備', '/JIG/JIG004D/' + obj.data.outfitID, 640, 320);
+                  //  $.ajax({
+                   //     url: '/JIG/JIG004D',
+                   //     data: { id: obj.data.outfitID },
+                   //     type: 'POST',
+                   //     success: function (data) {
+                   //         if (data.success) {
+                   //             obj.del(); //只删本地数据
+                   //             hg.msghide(status+"成功!");
+                   //         }
+                   //         else {
+                   //             hg.msg(data.msg);
+                   //         }
+                   //     },
+                   //     error: function () {
+                   //         hg.msg("网络请求失败!");
+                   //     }
+                   // });
                 });
             }
         }
@@ -196,7 +198,7 @@
             }
         }
         ];
-
+  
         ////搜索
         $('#querysubmit').click(function () {
 
diff --git a/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml
index 5a318eb2..584c3109 100644
--- a/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml
+++ b/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml
@@ -129,8 +129,8 @@
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="Master" class="control-label col-sm-3"></label>
                 <select asp-for="Master" class="custom-select col-sm-9">
-                    <option value="Y">是</option>
                     <option value="N">否</option>
+                    <option value="Y">是</option>
                 </select>
                 <span asp-validation-for="Master" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
diff --git a/AMESCoreStudio.Web/Views/JIG/JIG004D.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG004D.cshtml
new file mode 100644
index 00000000..4560266a
--- /dev/null
+++ b/AMESCoreStudio.Web/Views/JIG/JIG004D.cshtml
@@ -0,0 +1,100 @@
+@model AMESCoreStudio.WebApi.Models.AMES.OutfitInfo
+
+
+@{ ViewData["Title"] = "JIG004D";
+    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="JIG004DSave">
+            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
+            <input type="hidden" asp-for="OutfitID" />
+            <input type="hidden" asp-for="CreateUserID" />
+            <input type="hidden" asp-for="UpdateUserID" value="@ViewBag.UserID" />
+            <input type="hidden" asp-for="CreateDate" />
+            <input type="hidden" asp-for="UpdateDate" value="@System.DateTime.Now" />
+            <input type="hidden" asp-for="CommodityID" />
+            <input type="hidden" asp-for="VarietyID" />
+            <input type="hidden" asp-for="StatusNo" />
+            <input type="hidden" asp-for="UseStatusNo" />
+            <input type="hidden" asp-for="Remark" />
+            <input type="hidden" asp-for="BuyDay" />
+            <input type="hidden" asp-for="ScheReturnDay" />
+            <input type="hidden" asp-for="Custondian" />
+            <input type="hidden" asp-for="AreaNo" />
+            <input type="hidden" asp-for="LevelNo" />
+            <input type="hidden" asp-for="SiteNo" />
+            <input type="hidden" asp-for="LocationNo" />
+            <input type="hidden" asp-for="PartNo" />
+            <input type="hidden" asp-for="TypeFlag" />
+            <input type="hidden" asp-for="OutfitFactoryNo" />
+            <input type="hidden" asp-for="PuchaseDate" />
+            <input type="hidden" asp-for="UnitPrice" />
+            <input type="hidden" asp-for="QualityDate" />
+            <input type="hidden" asp-for="VendorID" />
+            <input type="hidden" asp-for="QANo" />
+            <input type="hidden" asp-for="StockQty" />
+            <input type="hidden" asp-for="Unit" />
+            <input type="hidden" asp-for="LotNo" />
+            <input type="hidden" asp-for="Boards" />
+            <input type="hidden" asp-for="UseTimes" />
+            <input type="hidden" asp-for="TotalTimes" />
+            <input type="hidden" asp-for="ModelNo" />
+            <input type="hidden" asp-for="BarcodeNo" />
+            <input type="hidden" asp-for="TypeID" />
+            <input type="hidden" asp-for="CycleID" />
+            <input type="hidden" asp-for="ForeignExpenses" />
+            <input type="hidden" asp-for="CheckDate" />
+            <input type="hidden" asp-for="NextDate" />
+            <input type="hidden" asp-for="Master" />
+            <input type="hidden" asp-for="CustodianName" />
+            <input type="hidden" asp-for="CustodianDept" />
+
+
+
+            <div class=" form-group form-inline my-sm-1">
+                <label asp-for="OutfitNo" class="control-label col-sm-3"></label>
+                <input asp-for="OutfitNo" class="form-control col-sm-9" readonly />
+                <span asp-validation-for="OutfitNo" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="UseStatusRemark" class="control-label col-sm-3"></label>
+                <input asp-for="UseStatusRemark" class="form-control col-sm-9" />
+                <span asp-validation-for="UseStatusRemark" 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>
+
+
+}
+
diff --git a/AMESCoreStudio.Web/Views/JIG/JIG004R.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG004R.cshtml
new file mode 100644
index 00000000..7ac046aa
--- /dev/null
+++ b/AMESCoreStudio.Web/Views/JIG/JIG004R.cshtml
@@ -0,0 +1,161 @@
+@model AMESCoreStudio.WebApi.Models.AMES.OutfitInfoBlob
+
+
+
+@{ ViewData["Title"] = "JIG004R";
+    Layout = "~/Views/Shared/_AMESLayout.cshtml"; }
+
+<style>
+    .control-label {
+        justify-content: flex-end !important;
+    }
+
+    .text-error {
+        color: #dc3545 !important;
+    }
+
+    .my-read-only-class {
+        cursor: not-allowed;
+    }
+</style>
+
+<div class="layui-card">
+    <div class="layui-card-body">
+        <form enctype="multipart/form-data" class="layui-form" method="post" asp-action="JIG004RSave">
+            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
+   
+            <input type="hidden" id="id" asp-for="OutfitID" value="@ViewBag.OutfitID" />
+            <div class="layui-form-item" style="text-align:center">
+                <div class="layui-inline">
+                    <label class="layui-btn">
+                        <input type="file" name="formFile">
+                    </label>
+                    <input type="submit" id="asubmit" value="上傳" class="layui-btn layui-icon " />
+                </div>
+            </div>
+            <div style="text-align:center">
+                <div class="layui-inline">
+                    <span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span>
+                    @* <input type="submit" id="asubmit" value="上傳" class="layui-btn layui-btn-normal layui-btn-xs layui-icon " /> *@
+                </div>
+            </div>
+        </form>
+        @* SOP文件 sheet *@
+        <table class="layui-hide" id="sop" lay-filter="sop"></table>
+
+    </div>
+</div>
+
+@section Scripts {
+    @{ await Html.RenderPartialAsync("_ValidationScriptsPartial");
+        await Html.RenderPartialAsync("_FileinputScriptsPartial"); }
+
+<script type="text/javascript">
+        //layui.use(['form', 'layer', 'laydate'], function () {
+        //    form = layui.form;
+        //
+        //    form.on('select(Type)', function (data) {
+        //        var data = $("#Type").val();
+        //        getInspectionForms(data);
+        //    });
+        //
+        //});
+        hg.form.onsubmit('asubmit', function (data) {
+            tt();
+            //table && table.reload(data);
+        });
+        //通过行tool编辑,lay-event="show"
+        function show(obj) {
+            layui.use('layer', function () {
+                var layer = layui.layer;
+                layer.open({
+                type: 2,
+                title: '預覽文件',
+                shadeClose: true,//点击遮罩关闭层
+                shade: 0.8,
+                area: ['90%', '90%'],
+                content: obj.data.filePath + obj.data.newName, //iframe的url
+                zIndex: 19891014,
+                //iframe: {
+                //    src:obj.data.filePath + obj.data.newName
+                //
+                //}
+                });
+            });
+
+        };
+        //通过行tool删除,lay-event="del"
+         function del(obj) {
+        var id =  @ViewBag.OutfitID;
+        if (obj.data.imageName) {
+            hg.confirm("資料:" + obj.data.imageName + ",确定要删除吗?", function () {
+                $.ajax({
+                    url: '/JIG/JIG004RD' ,
+                    data: { id: id },
+                    type: 'POST',
+                    success: function (data) {
+                        if (data.success) {
+                            obj.del(); //只删本地数据
+                            hg.msghide("删除成功!");
+                        }
+                        else {
+                            hg.msg(data.msg);
+                        }
+                    },
+                    error: function () {
+                        hg.msg("网络请求失败!");
+                    }
+                });
+            });
+        }
+    }
+
+        @* SOP文件 sheet *@
+        var tableCols = [[
+            {
+                field: 'imageName',
+                title: '檔案名稱',
+                sort: true
+            },
+            {
+                field: 'createDate',
+                templet: '<div>{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd") }}</div>'
+            },
+            {
+                field: 'right',
+                width: 150,
+                title: '操作',
+                align: 'center',
+                fixed: 'right',
+                templet: function (d) {
+                    var btn = '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" lay-event="show">預覽</a>';
+                        btn += ' <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del">刪除</a>';
+                   
+                    return btn;
+                }
+            }]
+        ];
+        //基本数据表格
+        var table;
+        $(function () {
+
+            tt();
+        });
+         function tt() {
+
+            //基本数据表格
+            table = hg.table.datatable('sop', '上傳文件', '/JIG/GetOutfitInfoBlobByOutfitID?id=' + @ViewBag.OutfitID , {}, tableCols, false, 'full-100');
+        };
+
+        $(document).ready(function () {
+            var error = '@Html.ValidationMessage("error")';
+            if ($(error).text() != '') {
+                parent.hg.msg(error);
+            }
+        });
+
+</script>
+
+
+}
+
diff --git a/AMESCoreStudio.Web/Views/JIG/JIG005.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG005.cshtml
index 355e0633..7569acdd 100644
--- a/AMESCoreStudio.Web/Views/JIG/JIG005.cshtml
+++ b/AMESCoreStudio.Web/Views/JIG/JIG005.cshtml
@@ -99,7 +99,10 @@
                     else if (d.useStatusNo == "R")
                         str = '歸還';
                     else if (d.useStatusNo == "S")
+                        str = '送修';
+                    else if (d.useStatusNo == "C")
                         str = '報廢';
+                    
                     return str
                     //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>'
                 }
@@ -119,9 +122,9 @@
                 fixed: 'right',
                 templet: function (d) {
                     var btn = '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-edit" lay-event="view">檢視</a>';
-                    if (d.useStatusNo == "B")
+                    if (d.useStatusNo == "B" || d.useStatusNo == "S")
                         btn += ' <a class="layui-btn layui-btn-xs layui-icon layui-icon-edit" lay-event="re">歸還</a>';
-                    else
+                    else if (d.useStatusNo == "N" || d.useStatusNo == "R")
                         btn += ' <a class="layui-btn  layui-btn-xs layui-icon layui-icon-edit" lay-event="edit">領用</a>';
                     return btn
                 }
diff --git a/AMESCoreStudio.Web/Views/JIG/JIG006.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG006.cshtml
index 60687438..efccbf44 100644
--- a/AMESCoreStudio.Web/Views/JIG/JIG006.cshtml
+++ b/AMESCoreStudio.Web/Views/JIG/JIG006.cshtml
@@ -109,9 +109,10 @@
                     else if (d.useStatusNo == "R")
                         str = '歸還';
                     else if (d.useStatusNo == "S")
-                        str = '報廢';
-                    else if (d.useStatusNo == "F")
                         str = '送修';
+                    else if (d.useStatusNo == "C")
+                        str = '報廢';
+                  
                     return str
                 }
             },
@@ -134,10 +135,14 @@
                     if (d.statusNo == "A") {
                         if (d.useStatusNo == "N" || d.useStatusNo == "R") {
                             btn += ' <a class="layui-btn layui-btn-xs layui-icon layui-icon-edit" lay-event="fix">送修</a>';
-                            btn += ' <a class="layui-btn  layui-btn-danger  layui-btn-xs layui-icon layui-icon-edit" lay-event="del">報廢</a>';
                         }
-                        else
+                        if (d.useStatusNo == "S" || d.useStatusNo == "B") {
                             btn += ' <a class="layui-btn layui-btn-xs layui-icon layui-icon-edit" lay-event="re">歸還</a>';
+                        }
+                        if (d.useStatusNo == "N" || d.useStatusNo == "R" || d.useStatusNo == "B" || d.useStatusNo == "S")  {
+                             btn += ' <a class="layui-btn  layui-btn-danger  layui-btn-xs layui-icon layui-icon-edit" lay-event="del">報廢</a>';
+                        }
+                        
                     }
 
                     return btn
@@ -234,6 +239,7 @@
         });
         //基本数据表格
         function tt() {
+
             table = hg.table.datatable('test', '設備送修/領用',
                 '/JIG/GetOutfitInfoesByQuery?TypeFlag=' + $("#TypeFlag").val() + '&CommodityID=' + $("#Commodity").val() + '&VarityID=-99&Status=' + $("#Status").val() + '&QANo=' + $("#QANo").val() + '&PartNo=*&UseStatus=*'
                 , {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']);
diff --git a/AMESCoreStudio.Web/Views/KCS/KCS005.cshtml b/AMESCoreStudio.Web/Views/KCS/KCS005.cshtml
index a7d2c048..0b6cb01a 100644
--- a/AMESCoreStudio.Web/Views/KCS/KCS005.cshtml
+++ b/AMESCoreStudio.Web/Views/KCS/KCS005.cshtml
@@ -131,7 +131,7 @@
         });
         function tt() {
             //基本数据表格
-            table = hg.table.datatable('sop', '巡檢上傳文件', '/SPC/GetInspectionResultBlobsByQuery?id=' + @ViewBag.MasterID +'&itemID=' + @ViewBag.ItemID, {}, tableCols, false, 'full-100');
+            table = hg.table.datatable('sop', '組件料號序號文件', '/KCS/GetInspectionResultBlobsByQuery?id=' + @ViewBag.MasterID +'&itemID=' + @ViewBag.ItemID, {}, tableCols, false, 'full-100');
         };
 
         $(document).ready(function () {
diff --git a/AMESCoreStudio.Web/Views/SPC/SPC005.cshtml b/AMESCoreStudio.Web/Views/SPC/SPC005.cshtml
index c939e396..661f62be 100644
--- a/AMESCoreStudio.Web/Views/SPC/SPC005.cshtml
+++ b/AMESCoreStudio.Web/Views/SPC/SPC005.cshtml
@@ -279,7 +279,7 @@
             class: 'layui-btn-normal',
             handler: function () {
                 var form = $("#Form").val();
-                if (form) {
+                if (form != -99) {
                     hg.open('新增巡檢結果', '/SPC/SPC005C/' + form, '', '', true);
                 }
                 else {
diff --git a/AMESCoreStudio.Web/Views/WHS/WHS005.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS005.cshtml
index 9c2e55eb..aaa87b5c 100644
--- a/AMESCoreStudio.Web/Views/WHS/WHS005.cshtml
+++ b/AMESCoreStudio.Web/Views/WHS/WHS005.cshtml
@@ -39,7 +39,7 @@
             </div>
         </div>
         <div class="layui-inline">
-            <button type="button" id="btnAdd" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon">&#xe654;</i>新增</button>
+           
         </div>
         <table class="layui-hide" id="test" lay-filter="test"></table>
     </div>
diff --git a/AMESCoreStudio.Web/Views/WHS/WHS008C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS008C.cshtml
index 504ead40..2ae1bc29 100644
--- a/AMESCoreStudio.Web/Views/WHS/WHS008C.cshtml
+++ b/AMESCoreStudio.Web/Views/WHS/WHS008C.cshtml
@@ -155,7 +155,7 @@
         }
     });
 
-    $("#UserNo").blur(function () {
+    $("#UserNo").change(function () {
         var data = $("#UserNo").val();
         console.log(data);
 
@@ -233,16 +233,19 @@
             success: function (result) {
                 if (result.data) {
                     console.info(result.data);
+                   
                     var name = "";
                     var count = 0;
                     $.each(result.data, function (index, item) {
                         if (item.userNo == data) {
                             name = item.userName;
                             count = count + 1;
+                           
                         }
                     });
                     if (count == 1) {
-                        $("#UserName").val(name);
+                       
+                        $("#UserNane").val(name);
                     }
                     else {
                         alert('請確認工號是否正確!!!');
diff --git a/AMESCoreStudio.Web/Views/WHS/WHS009.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS009.cshtml
index c24e9be8..c8c6bbd1 100644
--- a/AMESCoreStudio.Web/Views/WHS/WHS009.cshtml
+++ b/AMESCoreStudio.Web/Views/WHS/WHS009.cshtml
@@ -182,7 +182,7 @@
                 sort: true
             },
             {
-                field: 'personNameCh',
+                field: 'reasonNameCh',
                 title: '判定描述(中文)',
                 width: 100,
             },
@@ -250,9 +250,9 @@
         //基本数据表格
         //var table = hg.table.datatable('query', '異常工時資料維護', '/WHS/GetExceptionWorktimeByQuery', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']);
         var table;
-        //$(function () {
-        //    tt();
-        //});
+        $(function () {
+            tt();
+        });
         function tt() {           
             //基本数据表格
             var fNO = "", uNO = "", lID = "", dID = "";
diff --git a/AMESCoreStudio.Web/Views/WHS/WHS009C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS009C.cshtml
index 59e130ec..49fb01f7 100644
--- a/AMESCoreStudio.Web/Views/WHS/WHS009C.cshtml
+++ b/AMESCoreStudio.Web/Views/WHS/WHS009C.cshtml
@@ -17,6 +17,7 @@
             <input type="hidden" asp-for="UpdateUserID" value="0" />
             <input type="hidden" asp-for="CreateDate" value="@System.DateTime.Now" />
             <input type="hidden" asp-for="UpdateDate" value="@System.DateTime.Now" />
+
             <label class="control-label col-sm-2">[新增]</label>
             <hr />
             <div class="form-group form-inline my-sm-1">
@@ -96,11 +97,26 @@
                 <select asp-for="DecideDept" asp-items="@ViewBag.DeptList" class="custom-select col-sm-9"></select>
                 <span asp-validation-for="DecideDept" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
+
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="DecideUser" class="control-label col-sm-3"></label>
                 <select asp-for="DecideUser" class="custom-select col-sm-9"></select>
                 <span asp-validation-for="DecideUser" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
+
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyDept" class="control-label col-sm-3"></label>
+                <select asp-for="DutyDept" asp-items="@ViewBag.DeptList" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DutyDept" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyUser" class="control-label col-sm-3"></label>
+                <select asp-for="DutyUser" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DutyUser" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="ExceptionDate" class="control-label col-sm-3"></label>
                 <input asp-for="ExceptionDate" type="date" class="form-control col-sm-9" />
@@ -135,14 +151,40 @@
 
             <label class="control-label col-sm-2">[回復]</label>
             <hr />
+
             <div class="form-group form-inline my-sm-1">
-                <label asp-for="DutyDept" class="control-label col-sm-3"></label>
-                <input asp-for="DutyDept" class="form-control col-sm-9" />
-                <span asp-validation-for="DutyDept" class="text-danger offset-sm-3 my-sm-1"></span>
+                <label asp-for="DecidDeptID" class="control-label col-sm-3"></label>
+                <select asp-for="DecidDeptID" asp-items="@ViewBag.DeptList" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DecidDeptID" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DecidUserID" class="control-label col-sm-3"></label>
+                <select asp-for="DecidUserID" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DecidUserID" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+
+
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyDeptID" class="control-label col-sm-3"></label>
+                <select asp-for="DutyDeptID" asp-items="@ViewBag.DeptList" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DutyDeptID" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyUserID" class="control-label col-sm-3"></label>
+                <select asp-for="DutyUserID" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DutyUserID" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+
+
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="PersonNo" class="control-label col-sm-3"></label>
-                <select id="PersonNo" asp-for="PersonNo" asp-items="@ViewBag.FactoryUnit" class="custom-select col-sm-9"></select>
+                <select id="PersonNo" asp-for="PersonNo" asp-items="@ViewBag.ExceptionReasons" class="custom-select col-sm-9"></select>
                 <span asp-validation-for="PersonNo" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
             <div class="form-group form-inline my-sm-1">
@@ -185,11 +227,7 @@
         //console.info(data);
         getExceptionNo(data);
     });
-    $("#DecideDept").change(function () {
-        var data = $("#DecideDept").val();
-        //console.info(data);
-        getUserInfoes(data);
-    });
+    
     $('#searchItemNo').click(function () {
         var data = $("#WipNo").val();
         if (data) {
@@ -248,8 +286,35 @@
         getLines(data);
         getStations(data);
     });
+    $("#ExceptionNo").change(function () {
+ 
+        var data = $("#ExceptionNo").val();
+        getExceptionReasonNO(data);
+    });
+
+
+    $("#DecideDept").change(function () {
+        var data = $("#DecideDept").val();
+        //console.info(data);
+        getDecideUser(data);
+    });
+    $("#DutyDept").change(function () {
+        var data = $("#DutyDept").val();
+        //console.info(data);
+        getDutyUser(data);
+    });
+    $("#DecidDeptID").change(function () {
+        var data = $("#DecidDeptID").val();
+        //console.info(data);
+        getDecidUserID(data);
+    });
+    $("#DutyDeptID").change(function () {
+        var data = $("#DutyDeptID").val();
+        //console.info(data);
+        getDutyUserID(data);
+    });
 
-    function getUserInfoes(data) {
+    function getDecideUser(data) {
         $.ajax({
             url: "/SYS/GetUserInfoes",
             dataType: 'json',
@@ -279,6 +344,105 @@
             }
         });
     };
+
+
+    function getDutyUser(data) {
+        $.ajax({
+            url: "/SYS/GetUserInfoes",
+            dataType: 'json',
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+                    $("#DutyUser").empty();
+                    $('#DutyUser').append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+                        if (item.deptID == data) {
+                            $('#DutyUser').append(new Option(item.userName, item.userID));
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#DutyUser").empty();
+                        $('#DutyUser').append(new Option("無選項", ""));
+                    }
+                }
+                else {
+                    $("#DutyUser").empty();
+                    $('#DutyUser').append(new Option("無選項", ""));
+                }
+                layui.form.render("select");
+            }
+        });
+    };
+
+
+    function getDecidUserID(data) {
+        $.ajax({
+            url: "/SYS/GetUserInfoes",
+            dataType: 'json',
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+                    $("#DecidUserID").empty();
+                    $('#DecidUserID').append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+                        if (item.deptID == data) {
+                            $('#DecidUserID').append(new Option(item.userName, item.userID));
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#DecidUserID").empty();
+                        $('#DecidUserID').append(new Option("無選項", ""));
+                    }
+                }
+                else {
+                    $("#DecidUserID").empty();
+                    $('#DecidUserID').append(new Option("無選項", ""));
+                }
+                layui.form.render("select");
+            }
+        });
+    };
+
+
+    function getDutyUserID(data) {
+        $.ajax({
+            url: "/SYS/GetUserInfoes",
+            dataType: 'json',
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+                    $("#DutyUserID").empty();
+                    $('#DutyUserID').append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+                        if (item.deptID == data) {
+                            $('#DutyUserID').append(new Option(item.userName, item.userID));
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#DutyUserID").empty();
+                        $('#DutyUserID').append(new Option("無選項", ""));
+                    }
+                }
+                else {
+                    $("#DutyUserID").empty();
+                    $('#DutyUserID').append(new Option("無選項", ""));
+                }
+                layui.form.render("select");
+            }
+        });
+    };
+
+
+
     function getExceptionClass(data) {
         $.ajax({
             url: "/WHS/GetExceptionClasses",
@@ -325,22 +489,23 @@
                 if (result.data) {
 
                     $("#ExceptionNo").empty();
-                    $('#ExceptionNo').append(new Option("請選擇", ""));
+                    $("#ExceptionNo").append(new Option("請選擇", ""));
                     var count = 0;
                     $.each(result.data, function (index, item) {
+                     
                         if (item.exceptionClassNo == data) { //修改等號
-                            $('#ExceptionNo').append(new Option(item.exceptionDescCH, item.exceptionNo));//修改參數
+                            $("#ExceptionNo").append(new Option(item.exceptionDescCH, item.exceptionNo));//修改參數
                             count = count + 1;
                         }
                     });
                     if (count == 0) {
                         $("#ExceptionNo").empty();
-                        $('#ExceptionNo').append(new Option("無選項", ""))
+                        $("#ExceptionNo").append(new Option("無選項", ""))
                     }
                 }
                 else {
                     $("#ExceptionNo").empty();
-                    $('#ExceptionNo').append(new Option("無選項", ""));
+                    $("#ExceptionNo").append(new Option("無選項", ""));
                 }
                 layui.form.render("select");
             }
@@ -406,6 +571,42 @@
             }
         });
     };
+    function getExceptionReasonNO(data) {
+
+        $.ajax({
+            url: "/WHS/GetExceptionReasonsByQuery",
+            dataType: 'json',
+            data: { id: data },
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+
+                    $("#PersonNo").empty();
+                    $("#PersonNo").append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+
+                        if (item.exceptionNo == data) { //修改等號
+                          
+                            $("#PersonNo").append(new Option(item.reasonDescCH, item.reasonNo));//修改參數
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#PersonNo").empty();
+                        $("#PersonNo").append(new Option("無選項", ""))
+                    }
+                }
+                else {
+                    $("#PersonNo").empty();
+                    $("#PersonNo").append(new Option("無選項", ""));
+                }
+
+                layui.form.render("select");
+            }
+        });
+    };
 
     layui.use(['laydate'], function () {
         //form = layui.form;
@@ -432,6 +633,8 @@
         //    getLineInfoes(data);
         //});
 
+      
+
     });
 </script>
 
diff --git a/AMESCoreStudio.Web/Views/WHS/WHS009U.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS009U.cshtml
index 9c3b7760..f33a6297 100644
--- a/AMESCoreStudio.Web/Views/WHS/WHS009U.cshtml
+++ b/AMESCoreStudio.Web/Views/WHS/WHS009U.cshtml
@@ -10,7 +10,7 @@
 </style>
 <div class="row">
     <div class="col-sm-12">
-        <form enctype="multipart/form-data" method="post" asp-action="WHS009CSave">
+        <form enctype="multipart/form-data" method="post" asp-action="WHS009USave">
             <div asp-validation-summary="ModelOnly" class="text-danger"></div>
             <input type="hidden" asp-for="ExceptionID" />
             <input type="hidden" asp-for="CreateUserID" />
@@ -60,7 +60,7 @@
                 <span asp-validation-for="DeptID" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
             <div class="form-group form-inline my-sm-1">
-                <label class="control-label col-sm-3" >歸屬類別</label>
+                <label class="control-label col-sm-3">歸屬類別</label>
                 <select id="ExceptionType" class="custom-select col-sm-9" readonly>
                     <option value="I">內部</option>
                     <option value="O">外部</option>
@@ -68,13 +68,13 @@
             </div>
             <div class="form-group form-inline my-sm-1">
                 <label class="control-label col-sm-3">類別編號</label>
-                <select id="ExceptionClass"  asp-items="@ViewBag.ExceptionClasses" class="custom-select col-sm-9" readonly>
+                <select id="ExceptionClass" asp-items="@ViewBag.ExceptionClasses" class="custom-select col-sm-9" readonly>
                     <option value="">請選擇</option>
                 </select>
             </div>
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="ExceptionNo" class="control-label col-sm-3"></label>
-                <select asp-for="ExceptionNo"   asp-items="@ViewBag.ExceptionCodes"  class="custom-select col-sm-9" readonly>
+                <select asp-for="ExceptionNo" asp-items="@ViewBag.ExceptionCodes" class="custom-select col-sm-9" readonly>
                     <option value="">N/A</option>
                 </select>
                 <span asp-validation-for="ExceptionNo" class="text-danger offset-sm-3 my-sm-1"></span>
@@ -97,9 +97,23 @@
             </div>
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="DecideUser" class="control-label col-sm-3"></label>
-                <select asp-for="DecideUser" class="custom-select col-sm-9" readonly></select>
+                <select asp-for="DecideUser"  asp-items="@ViewBag.UserList" class="custom-select col-sm-9" readonly></select>
                 <span asp-validation-for="DecideUser" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyDept" class="control-label col-sm-3"></label>
+                <select asp-for="DutyDept" asp-items="@ViewBag.DeptList" class="custom-select col-sm-9" readonly></select>
+                <span asp-validation-for="DutyDept" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyUser" class="control-label col-sm-3"></label>
+                <select asp-for="DutyUser"  asp-items="@ViewBag.UserList" class="custom-select col-sm-9" readonly></select>
+                <span asp-validation-for="DutyUser" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="ExceptionDate" class="control-label col-sm-3"></label>
                 <input asp-for="ExceptionDate" type="date" class="form-control col-sm-9" readonly />
@@ -132,16 +146,40 @@
                 <span asp-validation-for="Memo" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
 
-            <label  class="control-label col-sm-2">[回復]</label>
+            <label class="control-label col-sm-2">[回復]</label>
             <hr />
+
+
             <div class="form-group form-inline my-sm-1">
-                <label asp-for="DutyDept" class="control-label col-sm-3"></label>
-                <input asp-for="DutyDept" class="form-control col-sm-9" />
-                <span asp-validation-for="DutyDept" class="text-danger offset-sm-3 my-sm-1"></span>
+                <label asp-for="DecidDeptID" class="control-label col-sm-3"></label>
+                <select asp-for="DecidDeptID" asp-items="@ViewBag.DeptList" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DecidDeptID" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DecidUserID" class="control-label col-sm-3"></label>
+                <select asp-for="DecidUserID"  asp-items="@ViewBag.UserList" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DecidUserID" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
+
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyDeptID" class="control-label col-sm-3"></label>
+                <select asp-for="DutyDeptID" asp-items="@ViewBag.DeptList" class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DutyDeptID" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
+
+
+            <div class="form-group form-inline my-sm-1">
+                <label asp-for="DutyUserID" class="control-label col-sm-3"></label>
+                <select asp-for="DutyUserID" asp-items="@ViewBag.UserList"  class="custom-select col-sm-9"></select>
+                <span asp-validation-for="DutyUserID" class="text-danger offset-sm-3 my-sm-1"></span>
+            </div>
+
             <div class="form-group form-inline my-sm-1">
                 <label asp-for="PersonNo" class="control-label col-sm-3"></label>
-                <select id="PersonNo" asp-for="PersonNo" asp-items="@ViewBag.FactoryUnit" class="custom-select col-sm-9"></select>
+                <select id="PersonNo" asp-for="PersonNo" asp-items="@ViewBag.ExceptionReasons" class="custom-select col-sm-9"></select>
                 <span asp-validation-for="PersonNo" class="text-danger offset-sm-3 my-sm-1"></span>
             </div>
             <div class="form-group form-inline my-sm-1">
@@ -189,11 +227,7 @@
         //console.info(data);
         getExceptionNo(data);
     });
-    $("#DecideDept").change(function () {
-        var data = $("#DecideDept").val();
-        //console.info(data);
-        getUserInfoes(data);
-    });
+  
     $('#searchItemNo').click(function () {
         var data = $("#WipNo").val();
         if (data) {
@@ -246,7 +280,35 @@
 
     });
 
-    function getUserInfoes(data) {
+    $("#ExceptionNo").change(function () {
+        var data = $("#ExceptionNo").val();
+        //console.info(data);
+        getExceptionReasonNO(data);
+    });
+
+
+    $("#DecideDept").change(function () {
+        var data = $("#DecideDept").val();
+        //console.info(data);
+        getDecideUser(data);
+    });
+    $("#DutyDept").change(function () {
+        var data = $("#DutyDept").val();
+        //console.info(data);
+        getDutyUser(data);
+    });
+    $("#DecidDeptID").change(function () {
+        var data = $("#DecidDeptID").val();
+        //console.info(data);
+        getDecidUserID(data);
+    });
+    $("#DutyDeptID").change(function () {
+        var data = $("#DutyDeptID").val();
+        //console.info(data);
+        getDutyUserID(data);
+    });
+
+    function getDecideUser(data) {
         $.ajax({
             url: "/SYS/GetUserInfoes",
             dataType: 'json',
@@ -275,7 +337,105 @@
                 layui.form.render("select");
             }
         });
-        };
+    };
+
+
+    function getDutyUser(data) {
+        $.ajax({
+            url: "/SYS/GetUserInfoes",
+            dataType: 'json',
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+                    $("#DutyUser").empty();
+                    $('#DutyUser').append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+                        if (item.deptID == data) {
+                            $('#DutyUser').append(new Option(item.userName, item.userID));
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#DutyUser").empty();
+                        $('#DutyUser').append(new Option("無選項", ""));
+                    }
+                }
+                else {
+                    $("#DutyUser").empty();
+                    $('#DutyUser').append(new Option("無選項", ""));
+                }
+                layui.form.render("select");
+            }
+        });
+    };
+
+
+    function getDecidUserID(data) {
+        $.ajax({
+            url: "/SYS/GetUserInfoes",
+            dataType: 'json',
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+                    $("#DecidUserID").empty();
+                    $('#DecidUserID').append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+                        if (item.deptID == data) {
+                            $('#DecidUserID').append(new Option(item.userName, item.userID));
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#DecidUserID").empty();
+                        $('#DecidUserID').append(new Option("無選項", ""));
+                    }
+                }
+                else {
+                    $("#DecidUserID").empty();
+                    $('#DecidUserID').append(new Option("無選項", ""));
+                }
+                layui.form.render("select");
+            }
+        });
+    };
+
+
+    function getDutyUserID(data) {
+        $.ajax({
+            url: "/SYS/GetUserInfoes",
+            dataType: 'json',
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+                    $("#DutyUserID").empty();
+                    $('#DutyUserID').append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+                        if (item.deptID == data) {
+                            $('#DutyUserID').append(new Option(item.userName, item.userID));
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#DutyUserID").empty();
+                        $('#DutyUserID').append(new Option("無選項", ""));
+                    }
+                }
+                else {
+                    $("#DutyUserID").empty();
+                    $('#DutyUserID').append(new Option("無選項", ""));
+                }
+                layui.form.render("select");
+            }
+        });
+    };
+
+  
     function getExceptionClass(data) {
         $.ajax({
             url: "/WHS/GetExceptionClasses",
@@ -343,7 +503,41 @@
             }
         });
     };
+    function getExceptionReasonNO(data) {
 
+        $.ajax({
+            url: "/WHS/GetExceptionReasonsByQuery",
+            dataType: 'json',
+            data: { id: data },
+            contentType: "application/json",
+            type: 'get',
+            success: function (result) {
+                if (result.data) {
+
+                    $("#PersonNo").empty();
+                    $("#PersonNo").append(new Option("請選擇", ""));
+                    var count = 0;
+                    $.each(result.data, function (index, item) {
+
+                        if (item.exceptionNo == data) { //修改等號
+                            $("#PersonNo").append(new Option(item.reasonDescCH, item.reasonNo));//修改參數
+                            count = count + 1;
+                        }
+                    });
+                    if (count == 0) {
+                        $("#PersonNo").empty();
+                        $("#PersonNo").append(new Option("無選項", ""))
+                    }
+                }
+                else {
+                    $("#PersonNo").empty();
+                    $("#PersonNo").append(new Option("無選項", ""));
+                }
+
+                layui.form.render("select");
+            }
+        });
+    };
 </script>
 
 
diff --git a/AMESCoreStudio.WebApi/Models/AMES/ExceptionWorktime.cs b/AMESCoreStudio.WebApi/Models/AMES/ExceptionWorktime.cs
index 4ef6791c..bb027af2 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/ExceptionWorktime.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/ExceptionWorktime.cs
@@ -9,7 +9,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
     /// 異常工時資料
     /// </summary>
     [Table("EXCEPTION_WORKTIME", Schema = "JHAMES")]
-    [DataContract]
+
     public class ExceptionWorktime
     {
         /// <summary>
@@ -179,7 +179,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("REASON_NAME_CH")]
         [Display(Name = "回覆: 判定描述")]
-        public string PersonNameCh { get; set; }
+        public string ReasonNameCh { get; set; }
 
         /// <summary>
         ///回覆: 判定類別
@@ -213,6 +213,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// 判定負責人ID
         /// </summary>
         [Column("DECIDE_USER_ID")]
+        [Display(Name = "判定負責人ID")]
         public int DecidUserID { get; set; }
 
         /// <summary>
diff --git a/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs b/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs
index 8ba66d53..befeac89 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs
@@ -385,5 +385,14 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         [Column("UPDATE_DATE", TypeName = "DATE")]
         [DataMember]
         public DateTime UpdateDate { get; set; } = System.DateTime.Now;
+
+        /// <summary>
+        /// 變更狀態備註(啟用/停用)
+        /// </summary>
+        [Column("USE_STATUS_REMARK")]
+        [StringLength(200)]
+        [Display(Name = "變更狀態備註(啟用/停用)")]
+        public string UseStatusRemark { get; set; }
+
     }
 }
diff --git a/AMESCoreStudio.WebApi/Models/AMES/SupportUser.cs b/AMESCoreStudio.WebApi/Models/AMES/SupportUser.cs
index 91685879..0092dd4e 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/SupportUser.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/SupportUser.cs
@@ -53,6 +53,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("UNIT_NO_I")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "援入單位")]
         public string UnitNoI { get; set; }
 
@@ -69,6 +70,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("UNIT_NO_O")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "援出單位")]
         public string UnitNoO { get; set; }
 
@@ -93,6 +95,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("LINE_ID_I")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "援入線別")]
         public int LineIDI { get; set; }
 
@@ -101,6 +104,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("STATION_ID_I")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "援入站別")]
         public int StationIDI { get; set; }
 
@@ -109,6 +113,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("LINE_ID_O")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "援出線別")]
         public int LineIDO { get; set; }
 
@@ -117,6 +122,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("STATION_ID_O")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "援出站別")]
         public int StationIDO { get; set; }
 
@@ -141,6 +147,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("CLASS_NO")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "班別")]
         public string ClassNo { get; set; }
 
diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkGroup.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkGroup.cs
index d06bab4b..cf91bf4e 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/WorkGroup.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/WorkGroup.cs
@@ -27,7 +27,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         [DataMember]
         [Display(Name = "工作群組名稱")]
         [Required(ErrorMessage = "{0},不能空白")]
-        [StringLength(5, ErrorMessage = "{0},不能大于{1}")]
+        [StringLength(20, ErrorMessage = "{0},不能大于{1}")]
         public string GroupName { get; set; }
 
         /// <summary>
diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkManPower.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkManPower.cs
index 23fad5bf..dda4f5d7 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/WorkManPower.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/WorkManPower.cs
@@ -53,6 +53,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("UNIT_NO")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "制程代碼")]
         public string UnitNo { get; set; }
 
@@ -125,6 +126,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
         /// </summary>
         [Column("WERKS")]
         [DataMember]
+        [Required(ErrorMessage = "{0},不能空白")]
         [Display(Name = "廠別")]
         public string Werks { get; set; }