Sai 1 year ago
parent
commit
2c5645166d
  1. 151
      AMESCoreStudio.Web/Controllers/PTDController.cs
  2. 164
      AMESCoreStudio.Web/Views/PTD/PTD002.cshtml
  3. 2
      AMESCoreStudio.WebApi/Controllers/PTD/PTDController.cs
  4. 5
      AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs

151
AMESCoreStudio.Web/Controllers/PTDController.cs

@ -46,7 +46,7 @@ namespace AMESCoreStudio.Web.Controllers
try try
{ {
//組表頭 //組表頭
IResultModel<dynamic> DNDetail = await _pcsApi.GetZDNDetail4PTD001(dnNo, lineNo); IResultModel<dynamic> DNDetail = await _ptdApi.GetZDNDetail4PTD001(dnNo, lineNo);
if (DNDetail.DataTotal > 0) if (DNDetail.DataTotal > 0)
{ {
dataList = "<table id = 'list' border = '0' width='100%' cellspacing='2px' cellpadding='10px'>"; dataList = "<table id = 'list' border = '0' width='100%' cellspacing='2px' cellpadding='10px'>";
@ -104,7 +104,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
//組Detail //組Detail
IResultModel<dynamic> result = await _pcsApi.GetDNInfo4PTD001(dnNo, lineNo); IResultModel<dynamic> result = await _ptdApi.GetDNInfo4PTD001(dnNo, lineNo);
if (result.DataTotal > 0) if (result.DataTotal > 0)
{ {
@ -289,7 +289,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpPost] [HttpPost]
public async Task<JsonResult> GetZDNDetailJson(string recordNumber,string lineNo) public async Task<JsonResult> GetZDNDetailJson(string recordNumber, string lineNo)
{ {
var result = await _ptdApi.GetZDNDetail4PTD001(recordNumber, lineNo); var result = await _ptdApi.GetZDNDetail4PTD001(recordNumber, lineNo);
@ -308,8 +308,147 @@ namespace AMESCoreStudio.Web.Controllers
[HttpPost] [HttpPost]
public async Task<JsonResult> PTD002_CheckInputData(WebApi.Models.AMES.PTDCheckInputData model) public async Task<JsonResult> PTD002_CheckInputData(WebApi.Models.AMES.PTDCheckInputData model)
{ {
var inputCheck = await CheckInputData(model);
if (!string.IsNullOrWhiteSpace(inputCheck))
return Json(new Result() { success = false, msg = inputCheck });
return Json(new { data = "" }); //
var recordType = await _ptdApi.GetRecordTypeInfoById(model.RecordType);
var zsnInfo = await _ptdApi.GetZSNInfoByIntervalNumber(model.FrontSN, model.EndSN);
if (recordType.FirstOrDefault().Status == "WO")
{
}
var datas = new List<dynamic>();
foreach (var item in zsnInfo)
{
var newRowData = new
{
dnNo = model.RecordNumber,
lineNo = model.LineNo,
material = model.ProductId,
sn = item.serialNumber
};
datas.Add(newRowData);
}
return Json(new Result() { success = true, msg = "", data = datas });
return Json(new Result() { success = false, msg = "AAA" });
}
/// <summary>
/// 確認輸入資料是否正確
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<string> CheckInputData(WebApi.Models.AMES.PTDCheckInputData model)
{
// RecordNumber
if (string.IsNullOrWhiteSpace(model.RecordNumber))
{
return "請輸入 RecordNumber";
}
// LineNo
if (string.IsNullOrWhiteSpace(model.LineNo))
{
return "請輸入 LineNo";
}
//var recordType = await _ptdApi.GetRecordTypeInfoById(model.RecordType);
//if (recordType.Any())
//{
// var recordInfoItem = recordType.FirstOrDefault();
// if (model.RecordNumber.Length != int.Parse((string)recordInfoItem.length))
// return "RecordNumber長度與設定的長度不符,請在確認";
// if (!model.RecordNumber.StartsWith((string)recordInfoItem.prefixCode))
// return "RecordNumber單據號碼開頭與設定開頭不符,請在確認";
//}
//else
//{
// return "請維護RecordNumber單投說明表";
//}
// ProductId
if (string.IsNullOrWhiteSpace(model.ProductId))
{
return "請輸入 料號";
}
// 判斷RecordNumber 是601DB or 657 需要填 RMANo
if (model.RecordType == "601DB" || model.RecordType == "657")
{
if (string.IsNullOrWhiteSpace(model.RmaNo))
return "請輸入 RMANo";
}
// 判斷是簍有輸入序號
if (string.IsNullOrWhiteSpace(model.FrontSN) && string.IsNullOrWhiteSpace(model.SNData))
{
return "請輸入 Scanner";
}
// 判斷序號區間格式正確
if (!string.IsNullOrWhiteSpace(model.FrontSN))
{
// 沒有指定單一序號就判斷 備貨量及流水碼
if (model.PcsUnit == "N")
{
var sequential = model.Sequential;
var frontLength = model.FrontSN.Length;
var endLength = model.EndSN?.Length ?? 0;
var frontSequential = 0;
// 流水碼長度不符
if (sequential >= frontLength + 1)
return "請確認 流水碼長度是否正確";
// 流水碼格式不符
if (!int.TryParse(model.FrontSN.Substring(frontLength - sequential, sequential), out _))
{
return "請確認 序號區間流水碼格式是否正確";
}
frontSequential = int.Parse(model.FrontSN.Substring(frontLength - sequential, sequential));
// 當沒有輸入結束序號區間,就判斷備貨量
if (string.IsNullOrWhiteSpace(model.EndSN))
{
if (model.StockQty <= 0)
{
return "請輸入 備貨量";
}
// 判斷備貨量 加總 大於 流水碼數
if ((frontSequential + model.StockQty - 1).ToString().Length > sequential)
{
return "備貨量加總超過設定流水碼長度,請在確認";
}
}
else
{
// 確認開始序號與結束序號是否長度一致
if (frontLength != endLength)
{
return "請確認 起始序號與結束序號區間長度不一致";
}
// 判斷前綴碼是否一致
if (model.FrontSN.Substring(0, frontLength - sequential) != model.EndSN.Substring(0, frontLength - sequential))
{
return "請確認 起始序號與結束序號區間前綴碼不一致";
}
}
}
}
return "";
} }
//public async Task<IActionResult> CheckShipQty(string recordNumber, string lineNo, int addQty) //public async Task<IActionResult> CheckShipQty(string recordNumber, string lineNo, int addQty)
//{ //{
@ -363,7 +502,7 @@ namespace AMESCoreStudio.Web.Controllers
return View(); return View();
} }
public async Task<IActionResult> PTD003QueryAsync(string recordType, string recordNumber, string lineNo, string materialNo, string shippingSN, string dateStart, string dateEnd, int autoLoad = 0 , string RBU = null) public async Task<IActionResult> PTD003QueryAsync(string recordType, string recordNumber, string lineNo, string materialNo, string shippingSN, string dateStart, string dateEnd, int autoLoad = 0, string RBU = null)
{ {
//if (recordNumber == null || recordNumber == "") //if (recordNumber == null || recordNumber == "")
// return Json(new Table() { count = 0, data = null }); // return Json(new Table() { count = 0, data = null });
@ -375,7 +514,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal });
} }
return Json(new Table() { count = 0, data = null, msg =result.Msg }); return Json(new Table() { count = 0, data = null, msg = result.Msg });
} }
[HttpPost] [HttpPost]

164
AMESCoreStudio.Web/Views/PTD/PTD002.cshtml

@ -108,7 +108,7 @@
<div class="layui-inline" style="margin-right: 100px;"> <div class="layui-inline" style="margin-right: 100px;">
<label class="layui-form-label">資料群組:</label> <label class="layui-form-label">資料群組:</label>
<input type="radio" name="StockUnit" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" checked/> <input type="radio" name="StockUnit" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" checked />
<input type="radio" name="StockUnit" value="0" title="PCS" lay-filter="radio-filter" /> <input type="radio" name="StockUnit" value="0" title="PCS" lay-filter="radio-filter" />
</div> </div>
@ -243,6 +243,7 @@
lineNo.focus(); lineNo.focus();
} }
}); });
$('#lineNo').on('keypress', function (event) { $('#lineNo').on('keypress', function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
@ -278,6 +279,7 @@
getItemDesc(document.getElementById('PartNumber').value); getItemDesc(document.getElementById('PartNumber').value);
} }
}); });
$('#frontSN').on('keypress', function (event) { $('#frontSN').on('keypress', function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
checkInputData(); checkInputData();
@ -286,97 +288,33 @@
$('#endSN').on('keypress', function (event) { $('#endSN').on('keypress', function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
var frontSN = document.getElementById('frontSN'); checkInputData();
var endSN = document.getElementById('endSN');
var dnNo = document.getElementById('recordNumber');
var lineNo = document.getElementById('lineNo');
var material = document.getElementById('PartNumber');
var table = layui.table;
var rowAmount = table.cache['query'].length;
var prefixCode = frontSN.value.slice(0, -5);
var currentSN = parseInt(frontSN.value.slice(-5));
while (currentSN <= parseInt(endSN.value.slice(-5))) {
rowAmount++;
var newRowData = {
itemNo: rowAmount,
dnNo: dnNo.value,
lineNo: lineNo.value,
material: material.value,
sn: prefixCode + currentSN.toString().padStart(5, "0")
};
// Add the new row data to the table
hg.table.addRow('query', newRowData);
currentSN++;
}
frontSN.focus(); frontSN.focus();
frontSN.select(); frontSN.select();
} }
}); });
$('#SNData').on('keypress', function (event) { $('#SNData').on('keypress', function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
var SNData = document.getElementById('SNData'); checkInputData();
var dnNo = document.getElementById('recordNumber');
var lineNo = document.getElementById('lineNo');
var material = document.getElementById('PartNumber');
var table = layui.table;
var rowAmount = table.cache['query'].length;
if (SNData.value.trim() == "") {
hg.msg('SN不得為空!');
return;
}
var arr = SNData.value.split('\n');
$.each(arr, function (index, SN) {
rowAmount++;
var newRowData = {
itemNo: rowAmount,
dnNo: dnNo.value,
lineNo: lineNo.value,
material: material.value,
sn: SN
};
// Add the new row data to the table
hg.table.addRow('query', newRowData);
});
SNData.select(); SNData.select();
event.preventDefault(); event.preventDefault();
} }
}); });
$('#StockQty').on('keypress', function (event) { $('#StockQty').on('keypress', function (event) {
if (event.keyCode == 13 && document.getElementById('pcs').checked && !document.getElementById('PCSUnit').checked) { if (event.keyCode == 13) {
var frontSN = document.getElementById('frontSN'); checkInputData();
var StockQty = document.getElementById('StockQty'); frontSN.focus();
var dnNo = document.getElementById('recordNumber'); frontSN.select();
var lineNo = document.getElementById('lineNo');
var material = document.getElementById('PartNumber');
var table = layui.table;
var rowAmount = table.cache['query'].length;
var prefixCode = frontSN.value.slice(0, -5);
var currentSN = parseInt(frontSN.value.slice(-5));
for (var i = 1; i <= parseInt(StockQty.value); i++) {
rowAmount++;
var newRowData = {
itemNo: rowAmount,
dnNo: dnNo.value,
lineNo: lineNo.value,
material: material.value,
sn: prefixCode + currentSN.toString().padStart(5, "0")
};
// Add the new row data to the table
hg.table.addRow('query', newRowData);
currentSN++;
} }
});
$('#sequential').on('keypress', function (event) {
if (event.keyCode == 13) {
checkInputData();
frontSN.focus(); frontSN.focus();
frontSN.select(); frontSN.select();
} }
}); });
@ -390,18 +328,11 @@
var sequential = document.getElementById('sequential').value; var sequential = document.getElementById('sequential').value;
var rMANo = document.getElementById('RMANo').value; var rMANo = document.getElementById('RMANo').value;
var stockUnit = document.querySelector('input[name="StockUnit"]:checked').value; var stockUnit = document.querySelector('input[name="StockUnit"]:checked').value;
var username = getCookie("UserID").value; var pcsUnit = document.getElementById('PCSUnit').checked ? 'Y' : 'N';
var workCenter = document.getElementById('WorkCenter').value; var workCenter = document.getElementById('WorkCenter').value;
var rbu = document.getElementById('RBU').value; var rbu = document.getElementById('RBU').value;
var stockQty = document.getElementById('StockQty').value; var stockQty = document.getElementById('StockQty').value;
var table = layui.table;
var rowAmount = table.cache['query'].length;
var sNData = document.getElementById('SNData').value; var sNData = document.getElementById('SNData').value;
var tableData = layui.table.cache['query'];
//if (isSNAlreadyExist(tableId, rowData.sn)) {
// hg.msg('SN 已存在!');
// return; // Do not add the row
//}
var postData = { var postData = {
RecordType: recordType, RecordType: recordType,
@ -412,6 +343,7 @@
LineNo: lineNo, LineNo: lineNo,
ProductId: material, ProductId: material,
StockUnit: stockUnit, StockUnit: stockUnit,
PcsUnit: pcsUnit,
FrontSN: frontSN, FrontSN: frontSN,
EndSN: endSN, EndSN: endSN,
StockQty: stockQty, StockQty: stockQty,
@ -427,22 +359,29 @@
data: serializedData, data: serializedData,
success: function (res) { success: function (res) {
if (res.success) { if (res.success) {
//// 重新加载表格数据 // 用来统计重复的SN
//layui.table.reload('query', { var duplicateSNs = [];
// data: rowData,
// page: false, res.data.forEach(function (item) {
// limit: 2000 if (isSNAlreadyExist('query', item.sn)) {
//}); // 将重复的SN加入到duplicateSNs数组中
//layer.msg('備貨成功!', { icon: 1 }); duplicateSNs.push(item.sn);
//calculateRowCount(tableData); } else {
hg.table.addRow('query', item);
} }
else { });
hg.msg('備貨失敗,原因:' + res.msg); if (duplicateSNs.length > 0) {
// 将所有重复的SN一次性显示
var duplicateSNsMessage = duplicateSNs.join(', ');
layer.msg(`以下SN已存在: ${duplicateSNsMessage}`, { icon: 2, time: 5000});
} }
} }
, else {
hg.msg('加入失敗:' + res.msg);
}
},
error: function (error) { error: function (error) {
hg.msg('備貨失敗!原因:' + error.msg); hg.msg('加入失敗:' + error.msg);
return; return;
} }
}); });
@ -460,11 +399,6 @@
var tableData = layui.table.cache['query']; var tableData = layui.table.cache['query'];
//if (customer === "") {
// hg.msg('Customer不得為空!');
// return; // Do not add the row
//}
if (material === "") { if (material === "") {
hg.msg('料號不得為空!'); hg.msg('料號不得為空!');
return; // Do not add the row return; // Do not add the row
@ -531,6 +465,7 @@
}); });
}); });
// 取料號DESC
function getItemDesc(itemNo) { function getItemDesc(itemNo) {
$.ajax({ $.ajax({
url: "/BAS/GetMaterialItemByItemNO", url: "/BAS/GetMaterialItemByItemNO",
@ -549,6 +484,7 @@
}); });
}; };
// 判斷Table SN是否有重複
function isSNAlreadyExist(tableId, sn) { function isSNAlreadyExist(tableId, sn) {
var table = layui.table; var table = layui.table;
var currentData = table.cache[tableId]; var currentData = table.cache[tableId];
@ -560,6 +496,8 @@
return isExist; return isExist;
} }
// 刷入數量
function calculateRowCount(table) { function calculateRowCount(table) {
var RowCount = table.length; var RowCount = table.length;
$("#rowCount").html("刷入數量: " + RowCount + " pcs"); $("#rowCount").html("刷入數量: " + RowCount + " pcs");
@ -568,11 +506,12 @@
hg.table.addRow = function (tableId, rowData) { hg.table.addRow = function (tableId, rowData) {
// Get the table instance // Get the table instance
var table = layui.table; var table = layui.table;
if (isSNAlreadyExist(tableId, rowData.sn)) { if (isSNAlreadyExist(tableId, rowData.sn)) {
// Handle the case where SN already exists // 如果SN已经存在,返回,不添加该行
layer.msg('SN 已存在!', { icon: 2 }); return;
return; // Do not add the row
} }
// Add the new row data to the table // Add the new row data to the table
table.reload(tableId, { table.reload(tableId, {
data: [rowData].concat(table.cache[tableId]), data: [rowData].concat(table.cache[tableId]),
@ -585,14 +524,14 @@
}; };
function del(obj) { function del(obj) {
if (obj.data.itemNo) { if (obj.data.sn) {
hg.confirm("SN:" + obj.data.sn + ",確定要刪除嗎?", function () { hg.confirm("SN:" + obj.data.sn + ",確定要刪除嗎?", function () {
// 获取表格数据 // 获取表格数据
var tableData = layui.table.cache['query']; var tableData = layui.table.cache['query'];
// 找到要删除的行的索引 // 找到要删除的行的索引
var rowIndex = tableData.findIndex(function (row) { var rowIndex = tableData.findIndex(function (row) {
return row.itemNo === obj.data.itemNo; return row.sn === obj.data.sn;
}); });
// 从表格数据中删除该行 // 从表格数据中删除该行
@ -669,9 +608,9 @@
var tableCols = [[ var tableCols = [[
{ {
field: 'itemNo', field: 'sn',
width: 100, title: 'SN',
title: 'Item(項次)' width: 150
}, },
{ {
field: 'dnNo', field: 'dnNo',
@ -688,11 +627,6 @@
title: 'Material(料號)', title: 'Material(料號)',
width: 150 width: 150
}, },
{
field: 'sn',
title: 'SN',
width: 150
},
{ {
field: 'delete', field: 'delete',
width: 100, width: 100,

2
AMESCoreStudio.WebApi/Controllers/PTD/PTDController.cs

@ -117,7 +117,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
AND LEN(SerialNumber) = LEN(@strNumber) "; AND LEN(SerialNumber) = LEN(@strNumber) ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
p.Add("strNumber", strNumber); p.Add("strNumber", strNumber);
p.Add("endNuber", endNumber); p.Add("endNumber", endNumber);
var q = await ptdConnection.QueryAsync<dynamic>(query, p); var q = await ptdConnection.QueryAsync<dynamic>(query, p);
return q.ToList(); return q.ToList();
} }

5
AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs

@ -171,6 +171,11 @@ namespace AMESCoreStudio.WebApi.Models.AMES
/// </summary> /// </summary>
public string EndSN { get; set; } public string EndSN { get; set; }
/// <summary>
/// Begin=End 單一序號
/// </summary>
public string PcsUnit { get; set; }
/// <summary> /// <summary>
/// 備貨量 /// 備貨量
/// </summary> /// </summary>

Loading…
Cancel
Save