Browse Source

增加PCS038無序號工單批次過站功能

master
Yiru 2 years ago
parent
commit
2f68afe3cb
  1. 169
      AMESCoreStudio.Web/Controllers/PCSController.cs
  2. 38
      AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs
  3. 3
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs
  4. 113
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs
  5. 82
      AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
  6. 90
      AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs
  7. 2
      AMESCoreStudio.WebApi/DTO/AMES/BarcodeInfoDto.cs

169
AMESCoreStudio.Web/Controllers/PCSController.cs

@ -8694,6 +8694,175 @@ namespace AMESCoreStudio.Web.Controllers
return _msg;
}
#endregion
#region PCS038 條碼輸入整批作業
public async Task<IActionResult> PCS038()
{
await GetLineInfo();
await GetFactoryUnit();
return View();
}
/// <summary>
/// PCS038 Query
/// </summary>
/// <param name="wipNo">工單號碼/param>
/// <param name="productNo">料號</param>
/// <param name="unit">生產單位/param>
/// <param name="lineID">LineID</param>
/// <param name="type">選擇查詢類型</param>
/// <returns></returns>
public async Task<IActionResult> PCS038QueryAsync(string wipNo, string productNo, string unit, string type, int lineID = 0, int page = 0, int limit = 10)
{
if (type == "W")
productNo = string.Empty;
else
wipNo = string.Empty;
var wipInfo = await _pcsApi.GetWipInfoByWipNO(wipNo);
wipInfo = wipInfo.Where(w => w.WipType == "N").ToList();
if (wipInfo.Count() > 0)
{
IResultModel<BarcodeInfoDto> result = await _pcsApi.GetBarcodeInfoesByPCS022Query(wipNo: wipNo,
itemNo: productNo, unit: unit, lineID, page: page, limit: limit);
if (result.Data.Count() != 0)
{
return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.Data.Count() });
}
else
{
IResultModel<BarcodeInfoDto> result1 = await _pcsApi.GetWipInfosByPCS038Query(wipNo: wipNo,
unit: unit, lineID, page: page, limit: limit);
if (result1.Data.Count() != 0)
{
return Json(new Table() { code = 0, msg = "", data = result1.Data, count = result1.DataTotal });
}
else
{
return Json(new Table() { count = 0, data = null });
}
}
}
else
{
return Json(new Table() { count = 0, data = null });
}
}
[HttpGet]
public IActionResult PCS038V(int wipID, int stationID)
{
ViewBag.WIP_ID = wipID;
ViewBag.STATION_ID = stationID;
return View();
}
[HttpGet]
public async Task<IActionResult> PCS038VQuery(int wipID, int stationID, int page = 0, int limit = 10)
{
var result = await _pcsApi.GetWipStationBarcodeByPCS038(wipID, stationID, page, limit);
if (result.DataTotal > 0)
{
return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal });
}
return Json(new Table() { count = 0, data = null });
}
[HttpPost]
public async Task<IActionResult> PCS038U(int wipID, int StationID, int PassQty)
{
var result = await _pcsApi.GetBarcodeInfoesByWipID(wipID);
result = result.Where(w => w.StationID == StationID && w.RuleStatus == "P").OrderBy(o =>o.BarcodeID).Take(PassQty).ToList();
var FlowRule = result.FirstOrDefault().GetWipInfo.FlowRuleID;
var result_RuleStation = await _basApi.GetRuleStationsByFlow(FlowRule, 0);
// 只抓標準站 & 排除完工站
result_RuleStation = result_RuleStation.Where(w => w.StationType == "M" && w.StationID != 1000).OrderBy(o => o.Sequence).ToList();
// 當站
var NowSequence = 0;
if (StationID != 0)
NowSequence = result_RuleStation.Where(w => w.StationID == StationID && w.FlowRuleID == FlowRule).FirstOrDefault().Sequence;
var NextStationID = 0;
// 排除當站為最後一站
if (result_RuleStation.Count != NowSequence + 1)
NextStationID = result_RuleStation.Where(w => w.Sequence == NowSequence + 1).FirstOrDefault().StationID;
if (NextStationID != 0)
{
var resultMsg = string.Empty;
foreach (var item in result)
{
//自動過站
var barCode = new BarCodeCheckDto
{
wipNo = item.GetWipInfo.WipNO,
barcode = item.BarcodeNo,
barcodeType = "M",
stationID = NextStationID,
line = item.GetWipInfo.LineID ?? 0,
unitNo = item.GetWipInfo.UnitNO,
inputItems = null,
userID = GetLogInUserID()
};
try
{
if (StationID == 0)
{
await _pcsApi.DeleteBarcodeInfo(item.BarcodeID);
}
var barcode_result = await _pcsApi.PassIngByCheck(JsonConvert.SerializeObject(barCode));
if (barcode_result.Success)
{
resultMsg += $"{item.BarcodeNo} 內部條碼:資料過站成功!!!" + "</br>";
}
else
{
resultMsg += $"{item.BarcodeNo} 內部條碼:資料過站失敗!!!原因:" + barcode_result.Msg + "</br>";
}
//return Json(new Result() { success = true, msg = resultMsg });
}
catch (Exception ex)
{
return Json(new Result() { success = false, msg = ex.Message });
}
}
return Json(new Result() { success = true, msg = resultMsg });
}
return Json(new Result() { success = true, msg = "該站為最後一站,無法執行過站" });
}
public async Task<IActionResult> PCS038CreateBarcodeAsync(int wipID)
{
var wipbarcode = await _pcsApi.CreateBarcodeInfobyPCS038(wipID);
return Json(new Result() { success = wipbarcode.Success, msg = wipbarcode.Msg });
}
#endregion
}

38
AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs

@ -1563,6 +1563,44 @@ namespace AMESCoreStudio.Web
#endregion
/// <summary>
/// 無序號條碼批次作業查詢Query
/// </summary>
/// <param name="wipNo">工單號碼</param>
/// <param name="itemNo">料號</param>
/// <param name="unit">生產單位</param>
/// <param name="lineID">線別</param>
/// <param name="page">頁數</param>
/// <param name="limit">筆數</param>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/WipInfos/WipInfoByPCS038")]
ITask<ResultModel<BarcodeInfoDto>> GetWipInfosByPCS038Query(string wipNo = null,
string unit = null, int lineID = 0, int page = 0, int limit = 10);
/// <summary>
///
/// </summary>
/// <param name="WipID">工單</param>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/BarCodeCheck/CreateBarcodeInfobyPCS038")]
ITask<ResultModel<BarcodeInfo>> CreateBarcodeInfobyPCS038(int WipID);
/// <summary>
/// 條碼批次查詢
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/BarcodeStation/GetWipStationBarcodeByPCS038")]
ITask<ResultModel<dynamic>> GetWipStationBarcodeByPCS038(int wipID, int stationID, int page, int limit);
/// <summary>
/// 刪除Barcodeinfo
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpDelete("api/BarcodeInfoes/{id}")]
ITask<ResultModel<string>> DeleteBarcodeInfo(int id);
}
}

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

@ -264,7 +264,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
LineName = q4.LineDesc,
LineID = q4.LineID,
Unit = q5.UnitNo,
UnitName = q5.UnitName
UnitName = q5.UnitName,
WipType = q3.WipType
};
// 查詢生產單位

113
AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs

@ -291,6 +291,119 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return result;
}
/// <summary>
/// 查詢工單站別條碼資料 By 條碼批次查詢
/// </summary>
/// <returns></returns>
[Route("[action]")]
[HttpGet]
public async Task<ResultModel<dynamic>> GetWipStationBarcodeByPCS038(int wipID, int stationID, int page = 0, int limit = 10)
{
ResultModel<dynamic> result = new ResultModel<dynamic>();
var q = from q1 in _context.BarcodeStation
join q2 in _context.BarcodeInfoes on q1.BarcodeID equals q2.BarcodeID
join q3 in _context.LineInfoes on q1.LineId equals q3.LineID
join q4 in _context.UserInfoes on q1.CreateUserID equals q4.UserID
select new
{
q1.BarcodeID,
q1.WipID,
q1.StationID,
q2.BarcodeNo,
q3.LineDesc,
q1.RuleStatus,
q1.Systype,
q1.InputDate,
q4.UserName
};
if (stationID == 0)
q = q.Where(w => w.WipID == wipID && w.RuleStatus != "F");
q = q.Where(w => w.WipID == wipID && w.StationID == stationID && w.RuleStatus != "F").OrderBy(o=>o.BarcodeNo);
if (q.Count() == 0)
{
var q1 = _context.BarcodeInfoes.Where(w => w.WipID == wipID).Select(s => new
{
s.WipID,
s.StationID,
s.BarcodeNo,
s.RuleStatus,
s.SysType,
s.CreateDate
});
if (q1.Count() > 0)
{
q1 = q1.Where(w => w.RuleStatus != "F").OrderBy(o=>o.BarcodeNo);
//紀錄筆數
result.DataTotal = q1.Count();
//Table 頁數
if (page > 0)
{
q1 = q1.Skip((page - 1) * limit).Take(limit);
}
result.Data = await q1.ToListAsync();
if (result == null)
{
result.Msg = "查無資料";
result.Success = false;
return result;
}
result.Success = true;
result.Msg = "OK";
return result;
}
else
{
result.Msg = "查無資料";
result.Success = false;
return result;
}
}
else
{
//紀錄筆數
result.DataTotal = q.Count();
//Table 頁數
if (page > 0)
{
q = q.Skip((page - 1) * limit).Take(limit);
}
result.Data = await q.ToListAsync();
if (result == null)
{
result.Msg = "查無資料";
result.Success = false;
return result;
}
result.Success = true;
result.Msg = "OK";
return result;
}
}
// PUT: api/BarcodeStation/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.

82
AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs

@ -1884,6 +1884,88 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
return "N";
}
/// <summary>
/// 條碼批次查詢
/// </summary>
/// <param name="wipNO"></param>
/// <param name="unit"></param>
/// <param name="lineID"></param>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <param name="wipNo">工單號碼</param>
/// <returns></returns>
[HttpGet("WipInfoByPCS038")]
public async Task<ResultModel<dynamic>> GetWipInfoByPCS038(string wipNO,
string unit, int lineID, int page = 0, int limit = 10)
{
ResultModel<dynamic> result = new ResultModel<dynamic>();
try
{
var q = from q1 in _context.WipInfos
join q2 in _context.WipAtts on q1.WipNO equals q2.WipNO into wip_att
from x in wip_att.DefaultIfEmpty()
join q3 in _context.LineInfoes on q1.LineID equals q3.LineID
join q4 in _context.FactoryUnits on q1.UnitNO equals q4.UnitNo
select new
{
q1.WipID,
q1.WipNO,
WipQty = q1.PlanQTY,
q1.CompleteQTY,
q1.UnitNO,
q1.LineID,
q1.FlowRuleID,
q1.StatusNO,
q1.CreateDate,
x.ItemNO,
LineName = q3.LineDesc,
q4.UnitName,
q1.WipType
};
if (wipNO != null && wipNO != "")
{
q = q.Where(w => w.WipNO == wipNO);
}
if (unit != null && unit != "")
{
q = q.Where(w => w.UnitNO == unit);
}
if (lineID != 0)
{
q = q.Where(w => w.LineID == lineID);
}
//紀錄筆數
result.DataTotal = q.Count();
result.Data = await q.ToListAsync();
result.DataTotal = q.Count();
// Table 頁數
if (page > 0)
{
q = q.Skip((page - 1) * limit).Take(limit);
}
result.Data = q.ToList();
result.Success = true;
return result;
}
catch (Exception ex)
{
result.Success = false;
result.Msg = ex.Message;
return result;
}
}
/// <summary>
/// 查詢工單是否開線
/// </summary>

90
AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs

@ -2374,5 +2374,95 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
return resultModel;
}
/// <summary>
///
/// </summary>
/// <param name="WipID"></param>
/// <returns></returns>
[HttpGet("CreateBarcodeInfobyPCS038")]
public async Task<IResultModel> CreateBarcodeInfobyPCS038(int WipID)
{
ResultModel<string> resultModel = new ResultModel<string> { Success = true };
WipInfosController wipinfoConteroller = new WipInfosController(_context);
var wipinfo = wipinfoConteroller.GetWipInfo(WipID).Result.Value;
if (wipinfo != null)
{
string wipNO = wipinfo.Select(s=>s.WipNO).FirstOrDefault();
WipBarcodeController BarcodeConteroller = new WipBarcodeController(_context);
var wipbarcode = BarcodeConteroller.GetWipBarcode(wipNO);
string resultMsg = "";
if (wipbarcode != null)
{
foreach (var item in wipbarcode.Result.Value)
{
string start = item.StartNO;
string end = item.EndNO;
// 取得流水號的長度
int serialLength = start.Length - 4;
// 將起始跟結束序號的流水號轉換為數字
int startSerial = int.Parse(start.Substring(start.Length - 4));
int endSerial = int.Parse(end.Substring(end.Length - 4));
// 進行序號展開
for (int i = startSerial; i <= endSerial; i++)
{
string serial = i.ToString().PadLeft(4, '0');
string code = start.Substring(0, start.Length - 4);
string barcode = code + serial;
BarCodeCheckDto barCodeCheckDto = new BarCodeCheckDto();
barCodeCheckDto.unitNo = wipinfo.FirstOrDefault().UnitNO;
barCodeCheckDto.wipID = WipID;
barCodeCheckDto.barcode = barcode;
barCodeCheckDto.barcodeID = 0;
barCodeCheckDto.extNo = "";
barCodeCheckDto.flowRule = wipinfo.FirstOrDefault().FlowRuleID;
barCodeCheckDto.wipNo = wipNO;
var result_BarcodeInfo = Table_BarcodeInfo(barCodeCheckDto).Result;
if (result_BarcodeInfo.Success)
{
resultMsg += $"{code + serial} 內部條碼:產生成功!!!" + "</br>";
}
else
{
resultMsg += $"{code + serial} 內部條碼:產生失敗!!!原因:" + result_BarcodeInfo.Msg + "</br>";
}
}
resultModel.Success = true;
}
}
else
{
resultModel.Success = false;
resultModel.Msg = "工單資料沒有設定生產序號區間";
}
}
else
{
resultModel.Success = false;
resultModel.Msg = "查無工單";
}
return resultModel;
}
}
}

2
AMESCoreStudio.WebApi/DTO/AMES/BarcodeInfoDto.cs

@ -100,5 +100,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
/// </summary>
public DateTime UpdateDate { get; set; }
public string WipType { get; set; }
}
}

Loading…
Cancel
Save