Browse Source

1. Helper 新增 指定Sequence取流水號值

2. 針對過站相關資料取IdKey更改用取Sequence,並更換IdKeyName
   BARCODE_ID => BARCODE_ID_SEQ
   BARCODEITEM_ID => BARCODE_ITEM_ID_SEQ
   BARCODE_OUTFIT_ID => BARCODE_OUTFIT_ID_SEQ
   NG_ID => NG_ID_SEQ
   COMPONENT_ID => NG_COMPONENT_ID_SEQ
master
Sai 1 week ago
parent
commit
c638bd6944
  1. 25
      AMESCoreStudio.WebApi/Code/Helper.cs
  2. 9
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs
  3. 14
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs
  4. 2
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeOutfitController.cs
  5. 4
      AMESCoreStudio.WebApi/Controllers/AMES/NgComponentsController.cs
  6. 2
      AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs
  7. 45
      AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheck2025Controller.cs
  8. 50
      AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckNewController.cs

25
AMESCoreStudio.WebApi/Code/Helper.cs

@ -3,6 +3,11 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using AMESCoreStudio.WebApi.Models.SYS;
using Dapper;
using AMESCoreStudio.WebApi.Extensions;
using AMESCoreStudio.WebApi.Models.AMES;
using Microsoft.EntityFrameworkCore.Storage;
using System.Security.Cryptography;
namespace AMESCoreStudio.WebApi
{
@ -88,6 +93,26 @@ namespace AMESCoreStudio.WebApi
return key = Convert.ToInt32(idkey.CurrentNum);
}
/// <summary>
/// 指定Sequence,流水號值(NEXTVAL)
/// </summary>
/// <param name="sequenceName">Sequence名稱</param>
/// <returns>Sequence取得目前值,例外 -1</returns>
public async Task<int> GetSequenceIDKeyAsync(string sequenceName)
{
try
{
var sql = $" SELECT JHAMES.{sequenceName}.NEXTVAL FROM DUAL ";
var result = await _context.Database.DapperQueryAsync<int>(sql, null);
return result.First();
}
catch (Exception)
{
return -1;
throw;
}
}
/// <summary>
/// 獲取用戶編號
/// </summary>

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

@ -561,7 +561,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
if (barcodeInfo.Count == 0)
{
BarcodeInfo barcode_info = new BarcodeInfo();
barcode_info.BarcodeID = helper.GetIDKey("BARCODE_ID").Result;
//barcode_info.BarcodeID = helper.GetIDKey("BARCODE_ID").Result;
barcode_info.BarcodeID = helper.GetSequenceIDKeyAsync("BARCODE_ID_SEQ").Result;
barcode_info.BarcodeNo = barcodeNo;
barcode_info.WipID = wipID;
barcode_info.StationID = stationID;
@ -691,7 +692,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
if (barcodeInfo.Count == 0)
{
BarcodeInfo barcode_info = new BarcodeInfo();
barcode_info.BarcodeID = helper.GetIDKey("BARCODE_ID").Result;
//barcode_info.BarcodeID = helper.GetIDKey("BARCODE_ID").Result;
barcode_info.BarcodeID = helper.GetSequenceIDKeyAsync("BARCODE_ID_SEQ").Result;
barcode_info.BarcodeNo = barcodeNo;
barcode_info.WipID = wipID;
barcode_info.StationID = stationID;
@ -870,7 +872,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
{
ResultModel<BarcodeInfo> result = new ResultModel<BarcodeInfo>();
Helper helper = new Helper(_context);
barcodeInfo.BarcodeID = helper.GetIDKey("BARCODE_ID").Result;
//barcodeInfo.BarcodeID = helper.GetIDKey("BARCODE_ID").Result;
barcodeInfo.BarcodeID = helper.GetSequenceIDKeyAsync("BARCODE_ID_SEQ").Result;
_context.BarcodeInfoes.Add(barcodeInfo);
List<BarcodeInfo> barcodeInfos = new List<BarcodeInfo>();

14
AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs

@ -541,7 +541,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
BarcodeItem barcode_item = new BarcodeItem();
barcode_item.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result;
barcode_item.BarcodeItemID = helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result;
barcode_item.BarcodeID = barcodeID;
barcode_item.WipID = wipID;
barcode_item.StationID = stationID;
@ -605,7 +605,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
BarcodeItem barcode_item = new BarcodeItem();
barcode_item.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result;
barcode_item.BarcodeItemID = helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result;
barcode_item.BarcodeID = barcodeID;
barcode_item.WipID = wipID;
barcode_item.StationID = stationID;
@ -686,7 +686,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
BarcodeItem barcode_item = new BarcodeItem();
barcode_item.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result;
barcode_item.BarcodeItemID = helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result;
barcode_item.BarcodeID = barcodeID;
barcode_item.WipID = wipID;
barcode_item.StationID = stationID;
@ -765,7 +765,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
BarcodeItem barcode_item = new BarcodeItem();
barcode_item.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result;
barcode_item.BarcodeItemID = helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result;
barcode_item.BarcodeID = barcodeID;
barcode_item.WipID = wipID;
barcode_item.StationID = stationID;
@ -833,7 +833,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
kpDateTime = jo["kpDateTime"].ToString();
BarcodeItem barcode_item = new BarcodeItem();
barcode_item.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result;
barcode_item.BarcodeItemID = helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result;
barcode_item.BarcodeID = barcodeID;
barcode_item.WipID = wipID;
barcode_item.StationID = stationID;
@ -872,7 +872,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
{
ResultModel<BarcodeItem> result = new ResultModel<BarcodeItem>();
Helper helper = new Helper(_context);
barcodeItem.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result;
barcodeItem.BarcodeItemID = helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result;
if (PartNoExists(barcodeItem.PartNo))
{
@ -912,7 +912,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
{
ResultModel<BarcodeItem> result = new ResultModel<BarcodeItem>();
Helper helper = new Helper(_context);
barcodeItem.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result;
barcodeItem.BarcodeItemID = helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result;
barcodeItem.B.BarcodeID = barcodeItem.BarcodeID;
if (PartNoExists(barcodeItem.PartNo))

2
AMESCoreStudio.WebApi/Controllers/AMES/BarcodeOutfitController.cs

@ -102,7 +102,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
try
{
Helper helper = new Helper(_context);
barcodeOutfit.BarcodeOutfitID = helper.GetIDKey("BARCODE_OUTFIT_ID").Result;
barcodeOutfit.BarcodeOutfitID = helper.GetSequenceIDKeyAsync("BARCODE_OUTFIT_ID_SEQ").Result;
_context.BarcodeOutfits.Add(barcodeOutfit);
await _context.SaveChangesAsync();
result.Success = true;

4
AMESCoreStudio.WebApi/Controllers/AMES/NgComponentsController.cs

@ -174,8 +174,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
{
ResultModel<NgComponent> result = new ResultModel<NgComponent>();
Helper helper = new Helper(_context);
ngComponent.ComponentID = helper.GetIDKey("COMPONENT_ID").Result;
ngComponent.ComponentID = helper.GetSequenceIDKeyAsync("NG_COMPONENT_ID_SEQ").Result;
_context.NgComponents.Add(ngComponent);
try
{

2
AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs

@ -320,7 +320,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
{
ResultModel<NgInfo> result = new ResultModel<NgInfo>();
Helper helper = new Helper(_context);
ngInfo.NgID = helper.GetIDKey("NG_ID").Result;
ngInfo.NgID = helper.GetSequenceIDKeyAsync("NG_ID_SEQ").Result;
_context.NgInfos.Add(ngInfo);
List<NgInfo> ngInfos = new List<NgInfo> { ngInfo };

45
AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheck2025Controller.cs

@ -492,32 +492,65 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
int NgId = 0;
List<int> ComponentId = new List<int>();
#region 舊取號方式
//// BarCodeInfo ID
//if (data.barcodeID == 0)
//{
// BarCodeId = helper.GetIDKey("BARCODE_ID").Result;
// data.barcodeID = BarCodeId;
//}
//// 組件料號
//foreach (var item in data.inputItems.Where(w => !w.inputData.Contains("$")))
//{
// BarCodeItemId.Add(helper.GetIDKey("BARCODEITEM_ID").Result);
//}
//// 治具編號
//foreach (var item in data.outfits)
//{
// BarCodeOutfitId.Add(helper.GetIDKey("BARCODE_OUTFIT_ID").Result);
//}
//// 不良代碼
//if (data.inputItems.Where(w => w.inputData.Contains("$")).Any())
//{
// NgId = helper.GetIDKey("NG_ID").Result;
// foreach (var item in data.inputItems.Where(w => w.inputData.Contains("$")))
// {
// ComponentId.Add(helper.GetIDKey("COMPONENT_ID").Result);
// }
//}
#endregion
// BarCodeInfo ID
if (data.barcodeID == 0)
{
BarCodeId = helper.GetIDKey("BARCODE_ID").Result;
BarCodeId = helper.GetSequenceIDKeyAsync("BARCODE_ID_SEQ").Result;
data.barcodeID = BarCodeId;
}
// 組件料號
foreach (var item in data.inputItems.Where(w => !w.inputData.Contains("$")))
{
BarCodeItemId.Add(helper.GetIDKey("BARCODEITEM_ID").Result);
BarCodeItemId.Add(helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result);
}
// 治具編號
foreach (var item in data.outfits)
{
BarCodeOutfitId.Add(helper.GetIDKey("BARCODE_OUTFIT_ID").Result);
BarCodeOutfitId.Add(helper.GetSequenceIDKeyAsync("BARCODE_OUTFIT_ID_SEQ").Result);
}
// 不良代碼
if (data.inputItems.Where(w => w.inputData.Contains("$")).Any())
{
NgId = helper.GetIDKey("NG_ID").Result;
NgId = helper.GetSequenceIDKeyAsync("NG_ID_SEQ").Result;
foreach (var item in data.inputItems.Where(w => w.inputData.Contains("$")))
{
ComponentId.Add(helper.GetIDKey("COMPONENT_ID").Result);
ComponentId.Add(helper.GetSequenceIDKeyAsync("NG_COMPONENT_ID_SEQ").Result);
}
}
@ -2550,7 +2583,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
data.extNo = "";
data.flowRule = wipinfo.FlowRuleID;
data.wipNo = wipinfo.WipNO;
var Msg = Table_BarcodeInfo(data, await helper.GetIDKey("BARCODE_ID"));
var Msg = Table_BarcodeInfo(data, await helper.GetSequenceIDKeyAsync("BARCODE_ID_SEQ"));
if (string.IsNullOrWhiteSpace(Msg))
{

50
AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckNewController.cs

@ -14,6 +14,9 @@ using System.Net.Http;
using System.Threading.Tasks;
using Dapper;
using AMESCoreStudio.WebApi.Extensions;
using AMESCoreStudio.WebApi.Models.SYS;
using System.Diagnostics;
using System.DirectoryServices.Protocols;
namespace AMESCoreStudio.WebApi.Controllers.AMES
{
@ -475,7 +478,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
#endregion
#region 判斷過站完成新增or更新 Table
#region -- 判斷過站完成新增or更新 Table --
/// <summary>
/// 判斷過站完成新增or更新 Table
/// </summary>
@ -492,32 +495,65 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
int NgId = 0;
List<int> ComponentId = new List<int>();
#region 舊取號方式
//// BarCodeInfo ID
//if (data.barcodeID == 0)
//{
// BarCodeId = helper.GetIDKey("BARCODE_ID").Result;
// data.barcodeID = BarCodeId;
//}
//// 組件料號
//foreach (var item in data.inputItems.Where(w => !w.inputData.Contains("$")))
//{
// BarCodeItemId.Add(helper.GetIDKey("BARCODEITEM_ID").Result);
//}
//// 治具編號
//foreach (var item in data.outfits)
//{
// BarCodeOutfitId.Add(helper.GetIDKey("BARCODE_OUTFIT_ID").Result);
//}
//// 不良代碼
//if (data.inputItems.Where(w => w.inputData.Contains("$")).Any())
//{
// NgId = helper.GetIDKey("NG_ID").Result;
// foreach (var item in data.inputItems.Where(w => w.inputData.Contains("$")))
// {
// ComponentId.Add(helper.GetIDKey("COMPONENT_ID").Result);
// }
//}
#endregion
// BarCodeInfo ID
if (data.barcodeID == 0)
{
BarCodeId = helper.GetIDKey("BARCODE_ID").Result;
BarCodeId = helper.GetSequenceIDKeyAsync("BARCODE_ID_SEQ").Result;
data.barcodeID = BarCodeId;
}
// 組件料號
foreach (var item in data.inputItems.Where(w => !w.inputData.Contains("$")))
{
BarCodeItemId.Add(helper.GetIDKey("BARCODEITEM_ID").Result);
BarCodeItemId.Add(helper.GetSequenceIDKeyAsync("BARCODE_ITEM_ID_SEQ").Result);
}
// 治具編號
foreach (var item in data.outfits)
{
BarCodeOutfitId.Add(helper.GetIDKey("BARCODE_OUTFIT_ID").Result);
BarCodeOutfitId.Add(helper.GetSequenceIDKeyAsync("BARCODE_OUTFIT_ID_SEQ").Result);
}
// 不良代碼
if (data.inputItems.Where(w => w.inputData.Contains("$")).Any())
{
NgId = helper.GetIDKey("NG_ID").Result;
NgId = helper.GetSequenceIDKeyAsync("NG_ID_SEQ").Result;
foreach (var item in data.inputItems.Where(w => w.inputData.Contains("$")))
{
ComponentId.Add(helper.GetIDKey("COMPONENT_ID").Result);
ComponentId.Add(helper.GetSequenceIDKeyAsync("NG_COMPONENT_ID_SEQ").Result);
}
}
@ -2552,7 +2588,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
data.extNo = "";
data.flowRule = wipinfo.FlowRuleID;
data.wipNo = wipinfo.WipNO;
var Msg = Table_BarcodeInfo(data, await helper.GetIDKey("BARCODE_ID"));
var Msg = Table_BarcodeInfo(data, await helper.GetSequenceIDKeyAsync("BARCODE_ID_SEQ"));
if (string.IsNullOrWhiteSpace(Msg))
{

Loading…
Cancel
Save