Browse Source

1. 過站更新

PTD
Ray 3 years ago
parent
commit
a8958809b8
  1. 24
      AMESCoreStudio.Web/Controllers/PCSController.cs
  2. 184
      AMESCoreStudio.Web/Views/PCS/PCS021.cshtml
  3. 29
      AMESCoreStudio.WebApi/Code/BarcodeContext.cs
  4. 1
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs
  5. 146
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs
  6. 127
      AMESCoreStudio.WebApi/Controllers/BarcodeWipController.cs
  7. 62
      AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs
  8. 12
      AMESCoreStudio.WebApi/Models/AMESContext.cs

24
AMESCoreStudio.Web/Controllers/PCSController.cs

@ -1572,14 +1572,13 @@ namespace AMESCoreStudio.Web.Controllers
//model.WipNO = "WO0001A1";
var q = await _pcsApi.GetWipInfoByWipNO(model.WipNO);
q = q.Where(w => w.UnitNO == model.UnitNO).ToList();
if (q.Count() == 0)
{
ModelState.AddModelError("error", "找不到工單號碼");
ModelState.AddModelError("error", "找不到該生產單位的工單號碼");
}
q = q.Where(w => w.UnitNO == model.UnitNO).ToList();
if (q.Count != 0)
{
model.PlanQTY = q.FirstOrDefault().PlanQTY;
@ -1593,6 +1592,12 @@ namespace AMESCoreStudio.Web.Controllers
{
model.MaterialKps = await _pcsApi.GetMaterialKpByItemID(model.MaterialItem.ItemID);
model.MaterialStationsItems = await _pcsApi.GetMaterialStationsItemByItemID(model.MaterialItem.ItemID);
if (model.MaterialStationsItems.Count() == 0)
{
ModelState.AddModelError("error", "找不到該站別作業工項");
}
var q1 = await _pcsApi.GetMaterialOutfitByItemID(model.MaterialItem.ItemID);
foreach (var item in q1)
{
@ -1624,10 +1629,6 @@ namespace AMESCoreStudio.Web.Controllers
if (model.MaterialOutfits.Where(w => string.IsNullOrWhiteSpace(w.Inputs)).Any())
ModelState.AddModelError("error", "請刷入治具編號");
//model.Inputs = TempData["TmpData"] as List<string>;
var aa = TempData["TmpData"];
model.Inputs.Add(model.Input);
TempData["TmpData"] = model.Inputs;
//var aa = TempData["TmpData"];
//await GetFactoryUnit();
@ -1643,10 +1644,11 @@ namespace AMESCoreStudio.Web.Controllers
// model.materialKpDto = await _pcsApi.GetMaterialKpQuery(model.wipAtt.ItemNO, model.WipInfo.UnitNO);
//}
//if ()
// return View("PCS021");
//else
return Json("Hello");
if (model.Input == "OK")
return Json("OK");
else
return Json(model.Input);
}
#endregion

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

@ -31,22 +31,32 @@
border: none;
}
.element {
float: left;
}
.layui-field-title {
margin: auto;
}
.layui-elem-field {
border-style: groove;
}
.layui-form-item {
margin-bottom: auto;
}
</style>
<div class="layui-card">
<div class="layui-card-header">
<div class="layui-card" style="height:auto;">
@* <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-form-item ">
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div>
</div>
</div>
</div>*@
<form id="PCS021Form" method="post" asp-action="PCS021" class="layui-form">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="layui-card-body">
@ -117,11 +127,23 @@
<label class="layui-form-label">刷讀條碼:</label>
<div class="layui-input-inline">
<input type="text" onkeydown="input(event);" id="inpputtxt" asp-for="Input" class="layui-input" autocomplete="off" />
TmpData:@TempData["TmpData"]
</div>
</div>
</div>
</div>
<fieldset class="layui-elem-field layui-field-title">
<legend style="color: #e18917">刷入資料</legend>
<table id="tblCustomers" class="layui-table" cellpadding="0" cellspacing="0">
<tbody id="tblCustomersBody">
</tbody>
@*<tfoot>
<tr>
<td><input type="text" id="txtInput" /></td>
<td><input type="button" value="Remove" onclick="Remove(this)" /></td>
</tr>
</tfoot>*@
</table>
</fieldset>
<fieldset class="layui-elem-field layui-field-title">
<legend style="color: #e18917">檢查項目</legend>
<table id="MydataTable" class="layui-table">
@ -243,7 +265,7 @@
@index.StationType
</td>
<td>
<input asp-for="@index.Inputs" name="MaterialOutfits[@j].Inputs" />
<input onkeypress="if( event.keyCode == 13 ) { return false; }" asp-for="@index.Inputs" name="MaterialOutfits[@j].Inputs" />
</td>
</tr>
j++;
@ -292,7 +314,6 @@
type: 'post',
success: function (result)
{
console.info(result.data);
$("#line").empty();//清空下拉框的值
$.each(result.data, function (index, item) {
$("#line").append($("<option>").text(item.text).val(item.value))
@ -317,7 +338,6 @@
type: 'post',
success: function (result)
{
console.info(result.data);
$("#stations").empty();//清空下拉框的值
$.each(result.data, function (index, item) {
$("#stations").append($("<option>").text(item.text).val(item.value))
@ -340,15 +360,30 @@
function input(e) {
if (e.keyCode == 13) {
var txt = $("#inpputtxt");
if (txt.val().length <= 0) {
parent.hg.msg("請刷入條碼!");
event.preventDefault();
return false;
}
var Inputs = GetAllEmpData();
//var data = $("#PCS021Form").serialize();
var data = $("#PCS021Form").serialize();
$.each(Inputs, function (i, item) {
data += "&Inputs[" + i + "]=" + item;
});
$.ajax({
url: "@Url.Action("PCS021_Input", "PCS")",
type:"POST",
//data: { "inputtxt": $("#inpputtxt").val() },
data: data,
success: function (result) {
$("#txtNamaPetugas").html(result);
url: "@Url.Action("PCS021_Input", "PCS")",
type: "POST",
data: data,
success: function (result) {
$("#inpputtxt").val('');
if (result != "OK") {
TableAddRow(result);
}
else {
$("#tblCustomersBody").empty();
}
}
});
event.preventDefault();
@ -371,5 +406,114 @@
});
});
function TableAddRow(e) {
//var rowCount = $('.data-contact-person').length + 0;
var contactdiv = '<tr class="data-contact-person">' +
'<td><input type="text" name="f-name" class="form-control f-name01" value='+ e +' /></td>' +
'<td><a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" onclick="Remove(this);">刪除</a></td>' +
'</tr>';
$('#tblCustomers').append(contactdiv);
//rollPage('left');
var txtName = $("#txtInput");
//Get the reference of the Table's TBODY element.
/* var tBody = $("#tblCustomers > TBODY")[0];*/
//Add Row.
/* var row = tBody.insertRow(-1);*/
//Add Name cell.
//var input = $("<input/>");
//input.attr("type", "text");
//input.attr("value", "1111");
//var cell = $(row.insertCell(-1));
//cell.html(e);
//cell.append(input);
//Add Button cell.
//cell = $(row.insertCell(-1));
//var btnRemove = $("<input />");
//btnRemove.attr("type", "button");
//btnRemove.attr("onclick", "Remove(this);");
//btnRemove.val("Remove");
//cell.append(btnRemove);
//Clear the TextBoxes.
//txtName.val(e);
AutoWindowSize();
};
// Table 刪除
function Remove(button) {
//Determine the reference of the Row using the Button.
var row = $(button).closest("TR");
var table = $("#tblCustomers")[0];
table.deleteRow(row[0].rowIndex);
//var name = $("TD", row).eq(0).html();
//if (confirm("Do you want to delete: " + name)) {
// //Get the reference of the Table.
// var table = $("#tblCustomers")[0];
// //Delete the Table row using it's Index.
// table.deleteRow(row[0].rowIndex);
//}
};
function GetAllEmpData() {
var data = [];
$('tr.data-contact-person').each(function () {
var firstName = $(this).find('.f-name01').val();//Bind to the first name with class f-name01
data.push(firstName);
});
return data;
}
function AutoWindowSize() {
$(window).on('resize', function () {
//AdminInit();
//var $content = $('#nav_xbs_tab .layui-tab-content');
//$content.height($(this).height() - 125);
//$content.find('iframe').each(function () {
// $(this).height($content.height());
//});
}).resize();
}
function AdminInit() {
var hgfull = function () {
var layfull = $('[lay-height]');
if (layfull.attr('lay-height')) {
var arr = layfull.attr('lay-height').split('-');
if (arr.length === 2) {
var height = window.innerHeight - arr[1];
layfull.css('height', height + 'px');
layfull.css('overflow-y', 'auto');
}
else if (arr[0] === 'full') {
layfull.css('height', window.innerHeight - 200 + 'px');
layfull.css('overflow-y', 'auto');
}
else if (arr[0] === 'auto') {
var next = layfull.next();
if (next.length > 0) {
setTimeout(function () {
//console.log(next.height());
if (next.height() === 99) {
hgfull();
return false;
}
layfull.children('.layui-card').css('height', next.height() + 'px');
layfull.children('.layui-card').css('overflow-y', 'auto');
}, 5);
}
}
}
}
$(window).resize(function () {
hgfull();
if (!document.fullscreenElement) {
$("body").find('.fa-compress').removeClass('fa-compress').addClass('fa-arrows-alt');
}
});
}
</script>
}

29
AMESCoreStudio.WebApi/Code/BarcodeContext.cs

@ -61,5 +61,34 @@ namespace AMESCoreStudio.WebApi
return "";
}
/// <summary>
/// 是否被鎖定
/// </summary>
/// <param name="WipNo"></param>
/// <param name="BarCode"></param>
/// <returns></returns>
public async Task<string> CheckBarCodeStationAsync(string WipNo, string BarCode)
{
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context);
// 序號與工單相同視為序號
if (BarCode.IndexOf(WipNo) != -1)
{
// 判斷BarCodeInfo 是否有條碼序號資料
var q = await barcodeInfoesController.GetBarcodeInfoesByNo(BarCode);
if (q.Value.Count() != 0)
{
// 判斷條碼序號是否有被鎖定
BarcodeLockController barcodeLockController = new BarcodeLockController(_context);
var q1 = await barcodeLockController.GetBarcodeLockByBarCodeID(q.Value.FirstOrDefault().BarcodeID);
if (q1.Value.Where(w => w.LockStatus == 0).Any())
{
return "條碼編號:" + BarCode + ",已被鎖定,無法過站";
}
}
}
return "";
}
}
}

1
AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs

@ -65,6 +65,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return barcodeInfo;
}
/// <summary>
/// 用No获取该條碼资料
/// </summary>

146
AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs

@ -0,0 +1,146 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using AMESCoreStudio.WebApi.Models.AMES;
namespace AMESCoreStudio.WebApi.Controllers.AMES
{
/// <summary>
/// 條碼鎖定資料表
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class BarcodeLockController : ControllerBase
{
private readonly AMESContext _context;
public BarcodeLockController(AMESContext context)
{
_context = context;
}
// GET: api/BarcodeLock
[HttpGet]
public async Task<ActionResult<IEnumerable<BarcodeLock>>> GetBarcodeLock()
{
return await _context.BarcodeLocks.ToListAsync();
}
// GET: api/BarcodeLock/5
[HttpGet("{id}")]
public async Task<ActionResult<BarcodeLock>> GetBarcodeLock(int id)
{
var barcodeLock = await _context.BarcodeLocks.FindAsync(id);
if (barcodeLock == null)
{
return NotFound();
}
return barcodeLock;
}
/// <summary>
/// 條碼鎖定資料表 by BarCodeID
/// </summary>
/// <param name="id">BarCodeID</param>
/// <returns></returns>
// GET: api/BarcodeLock/5
[HttpGet("BarCodeID/{id}")]
public async Task<ActionResult<IEnumerable<BarcodeLock>>> GetBarcodeLockByBarCodeID(int id)
{
IQueryable<BarcodeLock> q = _context.BarcodeLocks;
q = q.Where(p => p.BarcodeID.Equals(id));
var barcodelock = await q.ToListAsync();
if (barcodelock == null)
{
return NotFound();
}
return barcodelock;
}
// PUT: api/BarcodeLock/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<IActionResult> PutBarcodeLock(decimal id, BarcodeLock barcodeLock)
{
if (id != barcodeLock.BarcodeLockID)
{
return BadRequest();
}
_context.Entry(barcodeLock).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!BarcodeLockExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/BarcodeLock
// 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<ActionResult<BarcodeLock>> PostBarcodeLock(BarcodeLock barcodeLock)
{
_context.BarcodeLocks.Add(barcodeLock);
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateException)
{
if (BarcodeLockExists(barcodeLock.BarcodeLockID))
{
return Conflict();
}
else
{
throw;
}
}
return CreatedAtAction("GetBarcodeLock", new { id = barcodeLock.BarcodeLockID }, barcodeLock);
}
// DELETE: api/BarcodeLock/5
[HttpDelete("{id}")]
public async Task<ActionResult<BarcodeLock>> DeleteBarcodeLock(decimal id)
{
var barcodeLock = await _context.BarcodeLocks.FindAsync(id);
if (barcodeLock == null)
{
return NotFound();
}
_context.BarcodeLocks.Remove(barcodeLock);
await _context.SaveChangesAsync();
return barcodeLock;
}
private bool BarcodeLockExists(decimal id)
{
return _context.BarcodeLocks.Any(e => e.BarcodeLockID == id);
}
}
}

127
AMESCoreStudio.WebApi/Controllers/BarcodeWipController.cs

@ -0,0 +1,127 @@
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;
namespace AMESCoreStudio.WebApi.Controllers
{
/// <summary>
/// 檔案用途 條碼工單資料檔
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class BarcodeWipController : ControllerBase
{
private readonly AMESContext _context;
public BarcodeWipController(AMESContext context)
{
_context = context;
}
// GET: api/BarcodeWip
[HttpGet]
public async Task<ActionResult<IEnumerable<BarcodeWip>>> GetBarcodeWips()
{
return await _context.BarcodeWips.ToListAsync();
}
// GET: api/BarcodeWip/5
[HttpGet("{id}/{wipid}")]
public async Task<ActionResult<BarcodeWip>> GetBarcodeWipByTwoKey(decimal id, decimal wipid)
{
var barcodeWip = await _context.BarcodeWips.Where(w => w.BarcodeID == id && w.WipID == wipid).FirstOrDefaultAsync();
if (barcodeWip == null)
{
return NotFound();
}
return barcodeWip;
}
// PUT: api/BarcodeWip/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<IActionResult> PutBarcodeWip(decimal id, BarcodeWip barcodeWip)
{
if (id != barcodeWip.WipID)
{
return BadRequest();
}
_context.Entry(barcodeWip).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!BarcodeWipExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/BarcodeWip
// 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<ActionResult<BarcodeWip>> PostBarcodeWip(BarcodeWip barcodeWip)
{
_context.BarcodeWips.Add(barcodeWip);
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateException)
{
if (BarcodeWipExists(barcodeWip.WipID))
{
return Conflict();
}
else
{
throw;
}
}
return CreatedAtAction("GetBarcodeWip", new { id = barcodeWip.WipID }, barcodeWip);
}
// DELETE: api/BarcodeWip/5
[HttpDelete("{id}")]
public async Task<ActionResult<BarcodeWip>> DeleteBarcodeWip(decimal id)
{
var barcodeWip = await _context.BarcodeWips.FindAsync(id);
if (barcodeWip == null)
{
return NotFound();
}
_context.BarcodeWips.Remove(barcodeWip);
await _context.SaveChangesAsync();
return barcodeWip;
}
private bool BarcodeWipExists(decimal id)
{
return _context.BarcodeWips.Any(e => e.WipID == id);
}
}
}

62
AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs

@ -0,0 +1,62 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
#nullable disable
namespace AMESCoreStudio.WebApi.Models.AMES
{
/// <summary>
/// 檔案用途 條碼工單資料檔
/// </summary>
[Table("BARCODE_WIP", Schema = "JHAMES")]
public partial class BarcodeWip
{
/// <summary>
/// 內部條碼ID
/// </summary>
[Key]
[Column("BARCODE_ID", TypeName = "NUMBER")]
[DataMember]
[Display(Name = "內部條碼ID")]
public decimal BarcodeID { get; set; }
/// <summary>
/// 工單ID
/// </summary>
[Key]
[Column("WIP_ID", TypeName = "NUMBER")]
[DataMember]
[Display(Name = "工單ID")]
public decimal WipID { get; set; }
/// <summary>
/// 建立者
/// </summary>
[Column("CREATE_USERID")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
[Display(Name = "建立者")]
public decimal CreateUserID { get; set; } = -1;
/// <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;
}
}

12
AMESCoreStudio.WebApi/Models/AMESContext.cs

@ -41,6 +41,7 @@ namespace AMESCoreStudio.WebApi
modelBuilder.Entity<WipLog>().HasKey(c => new { c.WipID, c.CreateDate });
modelBuilder.Entity<PartMap>().HasKey(c => new { c.CorpSN });
modelBuilder.Entity<WipSopLog>().HasKey(c => new { c.WipID, c.WipSopID });
modelBuilder.Entity<BarcodeWip>().HasKey(c => new { c.WipID, c.BarcodeID });
modelBuilder.Entity<WipRule>().HasKey(c => new { c.WipNO, c.RuleStationID, c.KeyNo });
modelBuilder.Entity<WipMAC>().HasKey(c => new { c.WipNO, c.StartNO, c.EndNO });
@ -396,6 +397,7 @@ namespace AMESCoreStudio.WebApi
/// </summary>
public DbSet<BarcodeItem> BarcodeItems { get; set; }
/// <summary>
///工時群組資料
/// </summary>
@ -463,6 +465,16 @@ namespace AMESCoreStudio.WebApi
/// </summary>
public virtual DbSet<MaterialOutfit> MaterialOutfits { get; set; }
/// <summary>
/// 條碼鎖定資料表
/// </summary>
public DbSet<BarcodeLock> BarcodeLocks { get; set; }
/// <summary>
/// 檔案用途 條碼工單資料檔
/// </summary>
public virtual DbSet<BarcodeWip> BarcodeWips { get; set; }
}
}

Loading…
Cancel
Save