@@ -123,7 +123,7 @@
@*@Html.ValidationMessage("error") *@
@@ -217,7 +217,7 @@
-
+
@@ -278,7 +278,7 @@
-
@@ -302,7 +302,6 @@
jQuery(function ($) {
$('.element').responsiveEqualHeightGrid();
getUnitLineList($("#unit").val());
- //getRuleStationList($("#unit").val());
});
function getUnitLineList(data)
@@ -330,30 +329,6 @@
});
};
- @*function getRuleStationList(data)
- {
- $.ajax(
- {
- url: "@Url.Action("GetRuleStationByTypeJson", "PCS")",
- dataType: 'json',
- data: { "unit_no": $("#unit").val()},
- type: 'post',
- success: function (result)
- {
- $("#stations").empty();//清空下拉框的值
- $.each(result.data, function (index, item) {
- $("#stations").append($("").text(item.text).val(item.value))
- });
-
- layui.form.render("select");//重新渲染 固定写法
- },
- error: function (result)
- {
- alert(result);
- }
- });
- };*@
-
function SearchNo(e) {
if (e.keyCode == 13) {
$("#GetWipData").click();
@@ -372,7 +347,7 @@
type: "POST",
data: data,
success: function (result) {
- $("#inpputtxt").val('');
+ $("#inputtxt").val('');
if (!result.success) {
parent.hg.msg(result.msg);
}
@@ -383,6 +358,7 @@
}
else {
$("#tblCustomersBody").empty();
+ InputQty();
}
}
}
@@ -407,6 +383,17 @@
});
+ function InputQty() {
+ $.ajax({
+ url: "@Url.Action("getBarcodeStationByInputQty", "PCS")",
+ type: "POST",
+ data: { "wipNo": $("#WipNO").val(), "unitNo": $("#unit").val(), "ststionID": $("#stations").val()},
+ success: function (result) {
+ $("#InputQty").text(result.data);
+ }
+ });
+ };
+
// 新增trRow
function TableAddRow(e) {
//var rowCount = $('.data-contact-person').length + 0;
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs
index 32d373b2..2a779fba 100644
--- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs
@@ -145,6 +145,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return result;
}
+
+ ///
+ /// 查詢 已過站數量
+ ///
+ /// 工單ID
+ /// 站別ID
+ ///
+ [HttpGet("InputQty/{wipID}/{ruleStationID}")]
+ public async Task> GetBarcodeStationByInputQty(int wipID, int ruleStationID)
+ {
+ var barcodeStation = await _context.BarcodeStation
+ .Where(w => wipID == w.WipID && w.RuleStationID == ruleStationID && w.RuleStatus == "P").ToListAsync();
+ return barcodeStation.Count();
+ }
+
///
/// 用工單ID查是否有過站紀錄
///
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
index a8325b67..07d25f60 100644
--- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
@@ -112,7 +112,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
join q2 in _context.WipAtts on q1.WipNO equals q2.WipNO
join q3 in _context.LineInfoes on q1.LineID equals q3.LineID
join q4 in _context.FactoryUnits on q1.UnitNO equals q4.UnitNo
- join q5 in _context.FactoryInfos on q1.Werks equals q5.FactoryID.ToString()
+ join q5 in _context.FactoryInfos on q1.Werks equals q5.FactoryID.ToString()
//join q6 in _context.MaterialItems on q2.ItemNO equals q6.ItemNo
select new
{
@@ -216,15 +216,58 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
public async Task>> GetWipInfoByWipNo(string wipno)
{
IQueryable q = _context.WipInfos.Where(w => w.WipNO == wipno);
-
var WipInfo = await q.ToListAsync();
+ return WipInfo;
+ }
- if (WipInfo == null)
- {
- return NotFound();
- }
+ ///
+ /// 查詢工單是否投入
+ ///
+ /// 工單號碼
+ /// Y:投入N:未投入
+ [HttpGet("CheckStart/{wipno}")]
+ public ActionResult GetWipInfoCheckStart(string wipno)
+ {
+ // 判斷是否有投產紀錄
+ var q = from q1 in _context.WipInfos
+ join q2 in _context.BarcodeInfoes on q1.WipID equals q2.WipID
+ where q1.WipNO == wipno
+ select q2;
+
+ if (q.Count() != 0)
+ return "Y";
+ else
+ return "N";
+ // 判斷是否已經開線
+ var r = from q1 in _context.WipInfos
+ join q2 in _context.LineInfoes on q1.WipID equals q2.WipNo
+ where q1.WipNO == wipno
+ select q2;
+
+ if (r.Count() != 0)
+ return "Y";
+ else
+ return "N";
+ }
- return WipInfo;
+ ///
+ /// 查詢工單是否開線
+ ///
+ /// 工單號碼
+ /// Y:已開線N:未開線
+ [HttpGet("CheckStartLine/{wipno}")]
+ public ActionResult GetWipInfoCheckStartLine(string wipno)
+ {
+ // 判斷是否已經開線
+ var q = from q1 in _context.WipInfos
+ join q2 in _context.LineInfoes on q1.WipID equals q2.WipNo
+ where q1.WipNO == wipno
+ select q2;
+
+ if (q.Count() != 0)
+ return "Y";
+ else
+ return "N";
}
///
@@ -317,5 +360,66 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
return result;
}
+
+ ///
+ /// 删除工單相關資料
+ ///
+ /// 工單號碼
+ ///
+ [HttpDelete("{id}")]
+ public async Task> DeleteWipinfo(string id)
+ {
+ ResultModel result = new ResultModel();
+
+ var wipinfos = await _context.WipInfos.Where(w => w.WipNO == id).ToListAsync();
+ _context.WipInfos.RemoveRange(wipinfos);
+
+ var wipAtt = await _context.WipAtts.Where(w => w.WipNO == id).ToListAsync();
+ _context.WipAtts.RemoveRange(wipAtt);
+
+ var wipKp = await _context.WipKps.Where(w => w.WipNo == id).ToListAsync();
+ _context.WipKps.RemoveRange(wipKp);
+
+ var wipSop = await _context.WipSops.Where(w => w.WipNo == id).ToListAsync();
+ _context.WipSops.RemoveRange(wipSop);
+
+ var wipOutfit = await _context.WipOutfits.Where(w => w.WipNo == id).ToListAsync();
+ _context.WipOutfits.RemoveRange(wipOutfit);
+
+ var wipLabel = await _context.WipLabels.Where(w => w.WipNO == id).ToListAsync();
+ _context.WipLabels.RemoveRange(wipLabel);
+
+ var wipBarcode = await _context.WipBarcodes.Where(w => w.WipNO == id).ToListAsync();
+ _context.WipBarcodes.RemoveRange(wipBarcode);
+
+ var wipBarcodeOther = await _context.WipBarcodeOthers.Where(w => w.WipNO == id).ToListAsync();
+ _context.WipBarcodeOthers.RemoveRange(wipBarcodeOther);
+
+ var wipBoard = await _context.WipBoards.Where(w => w.WipNo == id).ToListAsync();
+ _context.WipBoards.RemoveRange(wipBoard);
+
+ var wipSystem = await _context.WipSystems.Where(w => w.WipNo == id).ToListAsync();
+ _context.WipSystems.RemoveRange(wipSystem);
+
+ var wipChecks = await _context.WipChecks.Where(w => w.WipNo == id).ToListAsync();
+ _context.WipChecks.RemoveRange(wipChecks);
+
+ var wipInfoBlob = await _context.WipInfoBlobs.Where(w => w.WipNo == id).ToListAsync();
+ _context.WipInfoBlobs.RemoveRange(wipInfoBlob);
+
+ try
+ {
+ await _context.SaveChangesAsync();
+ result.Success = true;
+ result.Msg = "OK";
+ }
+ catch (Exception ex)
+ {
+ result.Success = false;
+ result.Msg = ex.InnerException.Message;
+ }
+ return result;
+
+ }
}
}
diff --git a/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs b/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs
index cd4f6b7a..b11db0e9 100644
--- a/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs
@@ -186,25 +186,19 @@ namespace AMESCoreStudio.WebApi.Controllers.BAS
}
///
- /// 根據下一站別ID查詢
+ /// By流程ID 查詢
///
- ///
+ /// 流程ID
///
- // GET: api/Rules/5
- [HttpGet("ByNextStation/{id}")]
- public async Task>> GetRulesByNextStation(int id)
+ [HttpGet("ByFlowRuleID/{id}")]
+ public async Task>> GetRulesByFlowRuleID(int id)
{
- IQueryable q = _context.Ruleses;
-
- q = q.Where(p => p.NextStationID.Equals(id));
+ var q = from q1 in _context.Ruleses
+ join q2 in _context.RuleStations on q1.RuleStationID equals q2.RuleStationID
+ where q2.FlowRuleID == id
+ select q1;
var rules = await q.ToListAsync();
-
- if (rules == null)
- {
- return NotFound();
- }
-
return rules;
}
diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs
index c548bea3..91b884a4 100644
--- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs
@@ -127,9 +127,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
item = q_wipinfo.Value.FirstOrDefault().GetWipAtt.ItemNO;
itemID = ItemNoToItemID(item).Result;
- var q_rulestation = await ruleStationsController.GetRuleStationByFlow(barCodeCheckDto.flowRule, 0, 0);
-
// 抓RulseStationID
+ var q_rulestation = await ruleStationsController.GetRuleStationByFlow(barCodeCheckDto.flowRule, 0, 0);
barCodeCheckDto.ruleStationID = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().RuleStationID;
#region KeyParts 判斷
@@ -209,7 +208,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
#endregion
#region 判斷組件序號是否在製狀態
- if (q_Kp.KpName.ToUpper() == "BOARD")
+ if (q_Kp.KpNo.ToUpper() == "04")
{
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(KPs.inputData);
@@ -221,7 +220,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
#endregion
#region 判斷MAC區間
- if (q_Kp.KpName.ToUpper() == "MAC")
+ if (q_Kp.KpNo.ToUpper() == "94")
{
var wipMAC = await wipMACController.GetWipMAC(barCodeCheckDto.wipNo);
@@ -254,7 +253,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
#region 判斷出貨序號
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
- if (q_Kp.KpName.ToUpper() == "EXT_NO")
+ if (q_Kp.KpNo.ToUpper() == "95")
{
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barCodeCheckDto.wipNo, KPs.inputData);
@@ -367,8 +366,12 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
private void CU_Tables(BarCodeCheckDto barCodeCheckDto)
{
string Msg = string.Empty;
- if (!Table_BarcodeInfo(barCodeCheckDto).Result.Success)
+ var result_BarcodeInfo = Table_BarcodeInfo(barCodeCheckDto).Result;
+ if (result_BarcodeInfo.Success)
{
+ // 將BarCodeID補上
+ if (barCodeCheckDto.barcodeID == 0)
+ barCodeCheckDto.barcodeID = result_BarcodeInfo.Data.FirstOrDefault().BarcodeID;
}
@@ -817,7 +820,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
catch (Exception ex)
{
- resultModel.Msg = ex.InnerException.Message;
+ resultModel.Msg = ex.Message;
}
}
@@ -1071,10 +1074,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return resultModel;
}
+ // 判斷序號目前是否有重複過站
+ BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context);
+ var BarcodeInfos = await barcodeInfoesController.GetBarcodeInfoesByNo(barcode);
+ BarcodeInfos = BarcodeInfos.Value.ToList();
+ if (BarcodeInfos.Value.Where(w => w.RuleStationID == RuleStationID).Any())
+ {
+ resultModel.Msg = "該內部序號【" + barcode + "】已刷過此站";
+ return resultModel;
+ }
+
// 取目前工單ID
int wipID = q1.WipID;
+ int flowRuleID = q1.FlowRuleID;
- resultModel = (ResultModel)await GetBarCodeLastStopRuleStationID(wipID, BarCodeID, station);
+ resultModel = (ResultModel)await GetBarCodeLastStopRuleStationID(wipID, BarCodeID, station, flowRuleID);
if (!resultModel.Success)
return resultModel;
@@ -1295,7 +1309,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
#endregion
#region 判斷組件序號是否在製狀態
- if (wipKps[x + i].KpName.ToUpper() == "BOARD")
+ if (wipKps[x + i].KpNo.ToUpper() == "04")
{
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context);
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(barcodeItemKPDto.inputKP[i]);
@@ -1307,7 +1321,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
#endregion
#region 判斷MAC區間
- if (wipKps[x + i].KpName.ToUpper() == "MAC")
+ if (wipKps[x + i].KpNo.ToUpper() == "94")
{
WipMACController wipMACController = new WipMACController(_context);
var wipMAC = await wipMACController.GetWipMAC(barcodeItemKPDto.WipNo);
@@ -1340,7 +1354,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
#region 判斷出貨序號
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
- if (wipKps[x + i].KpName.ToUpper() == "EXT_NO")
+ if (wipKps[x + i].KpNo.ToUpper() == "95")
{
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context);
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barcodeItemKPDto.WipNo, barcodeItemKPDto.inputKP[i]);
@@ -1491,8 +1505,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
/// 工單ID
/// BarCodeID
/// 目前作業站ID
+ /// 工單流程ID
/// true:false
- private async Task GetBarCodeLastStopRuleStationID(int wipID, int barCodeID, int stationID)
+ private async Task GetBarCodeLastStopRuleStationID(int wipID, int barCodeID, int stationID, int flowRuleID)
{
ResultModel resultModel = new ResultModel { Success = false };
WipInfosController wipInfosController = new WipInfosController(_context);
@@ -1503,13 +1518,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
// 用作業站抓 有設定下一站為該站的資料
RulesController rulesController = new RulesController(_context);
- var rules = await rulesController.GetRulesByNextStation(stationID);
-
+ var rules = await rulesController.GetRulesByFlowRuleID(flowRuleID);
+ rules = rules.Value.Where(w => w.NextStationID == stationID).ToList();
//排除第一站
if (rules.Value.Count() != 0)
{
// 抓有設定下一站=目前作業站的上一站
- var ruleSations = rules.Value.Select(s => new { s.RuleStationID, s.RuleStatus }).ToList();
+ var nowruleSations = rules.Value.Select(s => new { s.RuleStationID, s.RuleStatus }).ToList();
// 取得目前BarCode 最新過站資料
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context);
var barcodeInfo = barcodeInfoesController.GetBarcodeInfoes(barCodeID).Result.Value.FirstOrDefault();
@@ -1520,7 +1535,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return resultModel;
}
- if (ruleSations.Where(w => w.RuleStationID == barcodeInfo.RuleStationID
+ if (nowruleSations.Where(w => w.RuleStationID == barcodeInfo.RuleStationID
&& w.RuleStatus == barcodeInfo.RuleStatus).Count() == 0
)
{
@@ -1552,49 +1567,28 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
var q1 = q.Result.Value.Where(w => w.UnitNO == unitNo).FirstOrDefault();
- int FlowRuleID = q1.FlowRuleID;
-
- // 將工單-生產單位 流程ID取rulestation的作業站排順序
+ // 取得流程
RuleStationsController ruleStationsController = new RuleStationsController(_context);
- List dy = new List();
- int index = 1;
var ruleStations = await ruleStationsController.GetRuleStationByFlow(q1.FlowRuleID, 0);
if (ruleStations.Value.Count() != 0)
{
- // 按照順序塞入判斷資料
- foreach (var item in ruleStations.Value.Where(w => w.StationType == "M").OrderBy(o => o.Sequence))
- {
- var x = new
- {
- index,
- item.StationID
- };
- dy.Add(x);
- index++;
- }
- }
-
- // 在RuleStation 找不到該作業站
- if (dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault() == null)
- return resultModel;
+ // 在RuleStation 找不到該作業站
+ if (!ruleStations.Value.Any(a => a.StationID == stationID))
+ return resultModel;
- // 取得目前該站順序
- int NowIndex = dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault();
+ int rulestationID = ruleStations.Value.Where(w => w.StationID == stationID).FirstOrDefault().RuleStationID;
- // 判斷下一站沒有資料Error
- if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.StationID).FirstOrDefault() == null)
- return resultModel;
+ RulesController rulesController = new RulesController(_context);
+ var rules = await rulesController.GetRulesByFlowRuleID(q1.FlowRuleID);
- // 當下一站SatationID= 1000 代表完工站
- if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.StationID).FirstOrDefault() == 1000)
- {
- resultModel.Success = true;
- return resultModel;
- }
- else
- {
- return resultModel;
+ // 當下一站SatationID= 1000 代表完工站
+ if (rules.Value.Where(w => w.RuleStationID == rulestationID && w.NextStationID == 1000).Any())
+ {
+ resultModel.Success = true;
+ return resultModel;
+ }
}
+ return resultModel;
}
///