..
This commit is contained in:
644
Handler/Project/Util/BarcodeDataProcessing.cs
Normal file
644
Handler/Project/Util/BarcodeDataProcessing.cs
Normal file
@@ -0,0 +1,644 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using AR;
|
||||
using Project.Class;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class FMain
|
||||
{
|
||||
|
||||
EResultKeyence BCDProcess_ALL(Class.JobData itemC, string Src, bool CompleteCheck)
|
||||
{
|
||||
var mainJob = Src.Equals("SPS") == false;
|
||||
|
||||
//assign customer code - fixed data
|
||||
if (itemC.VisionData.CUSTCODE.isEmpty() && VAR.STR[eVarString.JOB_CUSTOMER_CODE].isEmpty() == false)
|
||||
{
|
||||
itemC.VisionData.CUSTCODE = VAR.STR[eVarString.JOB_CUSTOMER_CODE];
|
||||
PUB.log.Add($"Cutomer Code 고정값 사용 : {itemC.VisionData.CUSTCODE}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//커스터머 이름 확인
|
||||
if (mainJob && PUB.OPT_BYPASS() == false)
|
||||
BCDProcess_GetCustomerName(itemC);
|
||||
|
||||
//Ignore Value
|
||||
BCDProcess_IgnoreValue(itemC);
|
||||
|
||||
//기본 벤더이름
|
||||
BCDProcess_DefVenderName(itemC);
|
||||
|
||||
//기본 MFG
|
||||
BCDProcess_DefMFGDate(itemC);
|
||||
|
||||
//바코드가 변경된 경우이다, 자동채우기 기능이 있다면 사용한다
|
||||
bool NewBarcodeUpdated = false;
|
||||
|
||||
//[WMS] SID정보테이블에서 정보 추출(프린트정보는 없음)
|
||||
//[WMS] 에서 중복검색되면 팝업을 해야하므로 이것을 먼저 처리한다.
|
||||
if (VAR.BOOL[eVarBool.Opt_ApplyWMSInfo] && itemC.VisionData.BarcodeTouched == true)
|
||||
{
|
||||
var rlt_FindWMD = BCDProcess_FindWMSInfo(itemC);
|
||||
if (rlt_FindWMD.NewBarcodeUpdated) NewBarcodeUpdated = true;
|
||||
if (rlt_FindWMD.retval == EResultKeyence.MultiSID) return rlt_FindWMD.retval;
|
||||
}
|
||||
|
||||
//SID정보테이블에서 정보 추출
|
||||
if (VAR.BOOL[eVarBool.Opt_ApplySIDInfo] && itemC.VisionData.BarcodeTouched == true)
|
||||
{
|
||||
if (BCDProcess_FindSIDInfo(itemC) == true) NewBarcodeUpdated = true;
|
||||
}
|
||||
|
||||
//시드변환정보에서 정보 추출
|
||||
if (VAR.BOOL[eVarBool.Opt_ApplySIDConv] && itemC.VisionData.BarcodeTouched == true)
|
||||
{
|
||||
if (BCDProcess_FindSIDConv(itemC) == true) NewBarcodeUpdated = true;
|
||||
}
|
||||
|
||||
//기존 작업에서 데이터를 찾아서 쓴다
|
||||
if (VAR.BOOL[eVarBool.Opt_ApplyJobInfo] && itemC.VisionData.BarcodeTouched == true)
|
||||
{
|
||||
if (BCDProcess_FindJobData(itemC) == true) NewBarcodeUpdated = true;
|
||||
}
|
||||
|
||||
//릴ID 신규발행
|
||||
if (mainJob && PUB.OPT_BYPASS() == false && VAR.BOOL[eVarBool.Opt_NewReelID])
|
||||
BCDProcess_MakeReelID(itemC);
|
||||
|
||||
//SiD CONVERT
|
||||
if (PUB.OPT_BYPASS() == false &&
|
||||
VAR.BOOL[eVarBool.Opt_SIDConvert] &&
|
||||
PUB.flag.get(eVarBool.FG_WAIT_LOADERINFO) == false &&
|
||||
VAR.BOOL[eVarBool.JOB_Empty_SIDConvertInfo] == false)
|
||||
{
|
||||
//원본시드(sid0)가 비어있는데 sid과 확정되었다면 변환작업을 진행한다
|
||||
BCDProcess_SIDConvert(itemC);
|
||||
}
|
||||
|
||||
//Print Position
|
||||
BCDProcess_BCDPrint(itemC);
|
||||
|
||||
|
||||
|
||||
//해당 바코드작업이 완료되었는지 확인한다. 신규 바코드값이 업데이트되면 한번더 동작하도록 한다
|
||||
if (itemC.VisionData.BarcodeTouched == true && NewBarcodeUpdated == false)
|
||||
{
|
||||
itemC.VisionData.BarcodeTouched = false;
|
||||
}
|
||||
|
||||
bool BatchValueOK = false;
|
||||
if (PUB.Result.vModel.IgnoreBatch) BatchValueOK = true;
|
||||
else BatchValueOK = itemC.VisionData.BATCH.isEmpty() == false;
|
||||
|
||||
bool partnoValueOK = false;
|
||||
if (PUB.Result.vModel.IgnorePartNo) partnoValueOK = true;
|
||||
else partnoValueOK = itemC.VisionData.PARTNO.isEmpty() == false;
|
||||
|
||||
|
||||
//수량임의 입력의 경우
|
||||
bool vQtyOK = false;
|
||||
if (VAR.BOOL[eVarBool.Opt_UserQtyRQ])
|
||||
{
|
||||
if (itemC.VisionData.QTYRQ) vQtyOK = true; ////RQ의 값이 들어있으면 성공
|
||||
else vQtyOK = false; //수량임의모드인데 RQ값이 들어있지않으면 자동진행하지 않는다
|
||||
}
|
||||
else
|
||||
{
|
||||
//자동에서는 수량값이 들어있으면 바로 넘어가게한다.
|
||||
vQtyOK = itemC.VisionData.QTY.isEmpty() == false;
|
||||
}
|
||||
|
||||
//데이터확정 및 완료처리
|
||||
if (CompleteCheck)
|
||||
{
|
||||
|
||||
if (itemC.VisionData.Confirm)
|
||||
{
|
||||
//이미 완료된 데이터
|
||||
if (mainJob)
|
||||
{
|
||||
if (itemC.VisionData.ConfirmAuto)
|
||||
PUB.log.AddI($"Proceeding due to data confirmation completion (automatic)");
|
||||
else if (itemC.VisionData.ConfirmUser)
|
||||
PUB.log.AddI($"Proceeding due to data confirmation completion (manual)");
|
||||
else
|
||||
PUB.log.AddI($"Proceeding due to data confirmation completion (BYPASS)");
|
||||
}
|
||||
}
|
||||
else if (vQtyOK &&
|
||||
(itemC.VisionData.VNAME.isEmpty() == false) &&
|
||||
itemC.VisionData.VLOT.isEmpty() == false &&
|
||||
itemC.VisionData.SID.Length == 9 &&
|
||||
itemC.VisionData.MFGDATE.isEmpty() == false &&
|
||||
partnoValueOK &&
|
||||
BatchValueOK &&
|
||||
itemC.VisionData.RID.isEmpty() == false)
|
||||
{
|
||||
//모든값이 입력되어 있다면 조건 체크후 진행할 수 있도록 한다
|
||||
//2206211400
|
||||
CheckDataComplte(itemC, Src, mainJob);
|
||||
return EResultKeyence.Wait;
|
||||
}
|
||||
else
|
||||
{
|
||||
//아직데이터가 완료되지 않았다면
|
||||
//대기시간이 지나면 사용자 확인창을 띄운다
|
||||
return EResultKeyence.Wait;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return EResultKeyence.Nothing;
|
||||
}
|
||||
|
||||
//커스터머 이름 확인
|
||||
void BCDProcess_GetCustomerName(Class.JobData itemC)
|
||||
{
|
||||
if (itemC.VisionData.CUSTNAME.isEmpty() && itemC.VisionData.CUSTCODE.isEmpty() == false)
|
||||
{
|
||||
var qta = new DataSet1TableAdapters.QueriesTableAdapter();
|
||||
var custname = qta.GetCustName(itemC.VisionData.CUSTCODE);
|
||||
if ((custname ?? string.Empty).isEmpty() == false)
|
||||
{
|
||||
PUB.log.Add($"New CustName => {custname}");
|
||||
itemC.VisionData.CUSTNAME = custname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BCDProcess_BCDPrint(Class.JobData itemC)
|
||||
{
|
||||
var OPT_BYPASS = PUB.OPT_BYPASS();
|
||||
bool NeedConfirm = false;
|
||||
if (itemC.VisionData.PrintPositionData.isEmpty() == true || itemC.VisionData.PrintPositionCheck == false)
|
||||
{
|
||||
if (OPT_BYPASS)
|
||||
{
|
||||
//바이패스해야하는 경우라면 프린트위치를 임의로 한다
|
||||
itemC.VisionData.PrintPositionData = "1";
|
||||
itemC.VisionData.PrintPositionCheck = true;
|
||||
PUB.log.AddI($"Print position arbitrarily set due to bypass SID ({itemC.VisionData.SID})");
|
||||
}
|
||||
else if (itemC.VisionData.SID.isEmpty())
|
||||
{
|
||||
//no sid need confirm
|
||||
NeedConfirm = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//기록된 현재작업의 인쇄위치 정보에서 찾는다 231005
|
||||
if (PUB.Result.PrintPostionList.ContainsKey(itemC.VisionData.SID))
|
||||
{
|
||||
var preprnpos = PUB.Result.PrintPostionList[itemC.VisionData.SID];
|
||||
itemC.VisionData.PrintPositionData = preprnpos;
|
||||
itemC.VisionData.PrintPositionCheck = true;
|
||||
PUB.log.AddI($"Print position found in current job info SID:{itemC.VisionData.SID}, Value={preprnpos}");
|
||||
}
|
||||
else if (NeedConfirm == false)
|
||||
{
|
||||
//현작업내에서의 정보를 찾아서 적용한다 231005
|
||||
NeedConfirm = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NeedConfirm;
|
||||
}
|
||||
|
||||
void BCDProcess_IgnoreValue(Class.JobData itemC)
|
||||
{
|
||||
if (PUB.Result.vModel.IgnorePartNo == true && itemC.VisionData.PARTNO_Trust == false)
|
||||
{
|
||||
PUB.log.Add("PartNo Trust by Ignore PartNo Setting(opmodel)");
|
||||
itemC.VisionData.PARTNO_Trust = true;
|
||||
}
|
||||
|
||||
//ignore batch value
|
||||
if (PUB.Result.vModel.IgnoreBatch == true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//기본 벤더이름
|
||||
void BCDProcess_DefVenderName(Class.JobData itemC)
|
||||
{
|
||||
//기본 벤더이름
|
||||
var defname = PUB.Result.vModel.Def_Vname ?? string.Empty;
|
||||
if (PUB.Result.isSetvModel && defname.isEmpty() == false)
|
||||
{
|
||||
if (itemC.VisionData.VNAME.Equals(defname) == false)
|
||||
{
|
||||
itemC.VisionData.VNAME = defname.Trim();
|
||||
itemC.VisionData.VNAME_Trust = true;
|
||||
PUB.log.Add($"Defaul V.Name Set to {defname}");
|
||||
}
|
||||
}
|
||||
else if (PUB.OPT_BYPASS() == true)
|
||||
{
|
||||
if (itemC.VisionData.VNAME_Trust == false)
|
||||
{
|
||||
itemC.VisionData.VNAME = "BYPASS";
|
||||
itemC.VisionData.VNAME_Trust = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//기본 MFG
|
||||
void BCDProcess_DefMFGDate(Class.JobData itemC)
|
||||
{
|
||||
var defname = PUB.Result.vModel.Def_MFG ?? string.Empty;
|
||||
if (PUB.Result.isSetvModel && defname.isEmpty() == false && itemC.VisionData.MFGDATE.Equals(defname) == false)
|
||||
{
|
||||
itemC.VisionData.MFGDATE = defname.Trim();
|
||||
itemC.VisionData.MFGDATE_Trust = true;
|
||||
PUB.log.Add($"Defaul MFGDATE Set to {defname}");
|
||||
}
|
||||
}
|
||||
|
||||
//[WMS] SID정보테이블에서 정보 추출(프린트정보는 없음)
|
||||
//[WMS] 에서 중복검색되면 팝업을 해야하므로 이것을 먼저 처리한다.
|
||||
(bool NewBarcodeUpdated, EResultKeyence retval) BCDProcess_FindWMSInfo(Class.JobData itemC)
|
||||
{
|
||||
Boolean Apply = true;
|
||||
var vdata = itemC.VisionData;
|
||||
bool NewBarcodeUpdated = false;
|
||||
EResultKeyence rlt = EResultKeyence.Wait;
|
||||
|
||||
//select columns
|
||||
List<string> fields = new List<string>();
|
||||
if (VAR.BOOL[eVarBool.Opt_WMS_Apply_CustCode] && vdata.CUSTCODE.isEmpty()) fields.Add("CUST_CODE");
|
||||
if (VAR.BOOL[eVarBool.Opt_WMS_Apply_PartNo] && (vdata.PARTNO.isEmpty() || vdata.PARTNO_Trust == false)) fields.Add("PART_NO");
|
||||
if (VAR.BOOL[eVarBool.Opt_WMS_Apply_VenderName] && (vdata.VNAME_Trust == false || vdata.VNAME.isEmpty())) fields.Add("VENDOR_NM");
|
||||
if (VAR.BOOL[eVarBool.Opt_WMS_Apply_SID] && (vdata.SID_Trust == false || vdata.SID.isEmpty())) fields.Add("SID");
|
||||
if (VAR.BOOL[eVarBool.Opt_WMS_Apply_batch] && (vdata.SID_Trust == false || vdata.BATCH.isEmpty())) fields.Add("BATCH_NO"); //220921
|
||||
|
||||
//where coluns
|
||||
List<string> wheres = new List<string>();
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_WMS_Where_CustCode])
|
||||
{
|
||||
if (vdata.CUSTCODE.isEmpty() == false) wheres.Add($"CUST_CODE='{vdata.CUSTCODE.PadLeft(10, '0')}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_WMS_Where_PartNo])
|
||||
{
|
||||
if (vdata.PARTNO_Trust && vdata.PARTNO.isEmpty() == false) wheres.Add($"PART_NO='{vdata.PARTNO}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_WMS_Where_SID])
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.Opt_SIDConvert]) //if sid convert logic
|
||||
{
|
||||
if (vdata.SID_Trust && vdata.SID0.isEmpty() == false && vdata.SID.isEmpty() == false) wheres.Add($"SID='{vdata.SID}'");
|
||||
else Apply = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vdata.SID_Trust && vdata.SID.isEmpty() == false) wheres.Add($"SID='{vdata.SID}'");
|
||||
else Apply = false;
|
||||
}
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_WMS_Where_VLOT]) //221013
|
||||
{
|
||||
if (vdata.VLOT_Trust && vdata.VLOT.isEmpty() == false) wheres.Add($"VENDOR_LOT = '{vdata.VLOT}'");
|
||||
else Apply = false;
|
||||
}
|
||||
|
||||
//if query data . no error
|
||||
if (Apply && fields.Count > 0 && wheres.Count > 0)
|
||||
{
|
||||
var TableName = "VW_GET_MAX_QTY_VENDOR_LOT";
|
||||
var whereState = " where " + string.Join(" and ", wheres);
|
||||
var selectFields = string.Join(",", fields);
|
||||
|
||||
var SQL = $"select top 1 {selectFields} from {TableName} WITH(NOLOCK) {whereState}";
|
||||
var SQLC = $"select count(*) from {TableName} WITH(NOLOCK) {whereState}";
|
||||
|
||||
//정보가 여러개 존재하면 선택화면으로 처리해야한다
|
||||
var cntvalue = (DBHelper.ExecuteScalar(SQLC)?.ToString() ?? "0").toInt();
|
||||
if (cntvalue > 1)
|
||||
{
|
||||
VAR.STR[eVarString.MULTISID_QUERY] = $"select {selectFields} from {TableName} WITH(NOLOCK) {whereState}";
|
||||
VAR.STR[eVarString.MULTISID_FIELDS] = selectFields;
|
||||
rlt = EResultKeyence.MultiSID;
|
||||
}
|
||||
|
||||
if (PUB.Result.ItemDataC.VisionData.LastQueryStringWMS.Equals(SQL) == false) //같은 쿼리는 처리하지 않는다
|
||||
{
|
||||
if (PUB.GetSIDInfo_And_SetData(fields, ref vdata, SQL, SQLC))
|
||||
NewBarcodeUpdated = true;
|
||||
|
||||
PUB.Result.ItemDataC.VisionData.LastQueryStringWMS = SQL;
|
||||
}
|
||||
|
||||
}
|
||||
return (NewBarcodeUpdated, rlt);
|
||||
}
|
||||
|
||||
//SID정보테이블에서 정보 추출
|
||||
bool BCDProcess_FindSIDInfo(Class.JobData itemC)
|
||||
{
|
||||
Boolean Apply = true;
|
||||
bool NewBarcodeUpdated = false;
|
||||
var vdata = itemC.VisionData;
|
||||
|
||||
//select columns
|
||||
List<string> fields = new List<string>();
|
||||
if (VAR.BOOL[eVarBool.Opt_SID_Apply_CustCode] && vdata.CUSTCODE.isEmpty()) fields.Add("CustCode");
|
||||
if (VAR.BOOL[eVarBool.Opt_SID_Apply_PartNo] && (vdata.PARTNO.isEmpty() || vdata.PARTNO_Trust == false)) fields.Add("PartNo");
|
||||
if (VAR.BOOL[eVarBool.Opt_SID_Apply_PrintPos] && vdata.PrintPositionData.isEmpty()) fields.Add("PrintPosition");
|
||||
if (VAR.BOOL[eVarBool.Opt_SID_Apply_VenderName] && (vdata.VNAME_Trust == false || vdata.VNAME.isEmpty())) fields.Add("VenderName");
|
||||
if (VAR.BOOL[eVarBool.Opt_SID_Apply_SID] && (vdata.SID_Trust == false || vdata.SID.isEmpty())) fields.Add("SID");
|
||||
if (VAR.BOOL[eVarBool.Opt_SID_Apply_batch] && (vdata.SID_Trust == false || vdata.BATCH.isEmpty())) fields.Add("batch"); //220921
|
||||
if (VAR.BOOL[eVarBool.Opt_SID_Apply_qty] && (vdata.SID_Trust == false || vdata.QTYMAX.isEmpty())) fields.Add("qtymax"); //220921
|
||||
fields.Add("attach"); //231026
|
||||
|
||||
//where coluns
|
||||
List<string> wheres = new List<string>();
|
||||
//wheres.Add($"MC='{COMM.SETTING.Data.McName}");
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_SID_Where_CustCode])
|
||||
{
|
||||
if (vdata.CUSTCODE.isEmpty() == false) wheres.Add($"CustCode='{vdata.CUSTCODE.PadLeft(10, '0')}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_SID_Where_PartNo])
|
||||
{
|
||||
if (vdata.PARTNO_Trust && vdata.PARTNO.isEmpty() == false) wheres.Add($"PartNo='{vdata.PARTNO}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_SID_Where_SID])
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.Opt_SIDConvert]) //if sid convert logic
|
||||
{
|
||||
if (vdata.SID_Trust && vdata.SID0.isEmpty() == false && vdata.SID.isEmpty() == false)
|
||||
wheres.Add($"SID='{vdata.SID}'");
|
||||
else Apply = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vdata.SID_Trust && vdata.SID.isEmpty() == false) wheres.Add($"SID='{vdata.SID}'");
|
||||
else Apply = false;
|
||||
}
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_SID_Where_VLOT]) //221013
|
||||
{
|
||||
if (vdata.VLOT_Trust && vdata.VLOT.isEmpty() == false)
|
||||
wheres.Add($"(VenderLot like '{vdata.VLOT}' or VenderLot like '%,{vdata.VLOT}' or VenderLot like '{vdata.VLOT},%' or VenderLot like '%,{vdata.VLOT},%')");
|
||||
else Apply = false;
|
||||
}
|
||||
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_SID_Where_MC]) //231006
|
||||
{
|
||||
if (AR.SETTING.Data.McName.isEmpty() == false)
|
||||
wheres.Add($"attach='{AR.SETTING.Data.McName}'");
|
||||
else Apply = false;
|
||||
}
|
||||
|
||||
//if query data . no error
|
||||
if (Apply && fields.Count > 0 && wheres.Count > 0)
|
||||
{
|
||||
|
||||
var mcname = SETTING.Data.McName;
|
||||
if (VAR.BOOL[eVarBool.Use_Conveyor]) mcname = PUB.MCCode;
|
||||
|
||||
var SQL = "select top 1 " + string.Join(",", fields) +
|
||||
" from K4EE_Component_Reel_SID_Information WITH(NOLOCK)" +
|
||||
" where mc='" + mcname + "' and " + string.Join(" and ", wheres) +
|
||||
" order by wdate desc";
|
||||
|
||||
var SQLC = "select count(*)" +
|
||||
" from K4EE_Component_Reel_SID_Information WITH(NOLOCK)" +
|
||||
" where mc='" + mcname + "' and " + string.Join(" and ", wheres);
|
||||
|
||||
if (PUB.Result.ItemDataC.VisionData.LastQueryStringSID.Equals(SQL) == false)
|
||||
{
|
||||
if (PUB.GetSIDInfo_And_SetData(fields, ref vdata, SQL, SQLC) == true)
|
||||
NewBarcodeUpdated = true;
|
||||
|
||||
PUB.Result.ItemDataC.VisionData.LastQueryStringSID = SQL;
|
||||
}
|
||||
}
|
||||
return NewBarcodeUpdated;
|
||||
}
|
||||
|
||||
//시드변환정보에서 정보 추출
|
||||
bool BCDProcess_FindSIDConv(Class.JobData itemC)
|
||||
{
|
||||
Boolean Apply = true;
|
||||
bool NewBarcodeUpdated = false;
|
||||
var vdata = itemC.VisionData;
|
||||
|
||||
//select columns
|
||||
List<string> fields = new List<string>();
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Apply_CustCode] && vdata.CUSTCODE.isEmpty()) fields.Add("CustCode");
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Apply_PartNo] && (vdata.PARTNO.isEmpty() || vdata.PARTNO_Trust == false)) fields.Add("PartNo");
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Apply_PrintPos] && vdata.PrintPositionData.isEmpty()) fields.Add("PrintPosition");
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Apply_VenderName] && (vdata.VNAME_Trust == false || vdata.VNAME.isEmpty())) fields.Add("VenderName");
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Apply_SID] && (vdata.SID_Trust == false || vdata.SID.isEmpty())) fields.Add("SID");
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Apply_Batch] && (vdata.SID_Trust == false || vdata.BATCH.isEmpty())) fields.Add("batch"); //220921
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Apply_QtyMax] && (vdata.SID_Trust == false || vdata.QTYMAX.isEmpty())) fields.Add("qtymax"); //220921
|
||||
|
||||
|
||||
//where coluns
|
||||
List<string> wheres = new List<string>();
|
||||
//wheres.Add($"MC='{COMM.SETTING.Data.McName}");
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_Conv_Where_CustCode])
|
||||
{
|
||||
if (vdata.CUSTCODE.isEmpty() == false) wheres.Add($"CustCode='{vdata.CUSTCODE.PadLeft(10, '0')}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_Conv_Where_PartNo])
|
||||
{
|
||||
if (vdata.PARTNO_Trust && vdata.PARTNO.isEmpty() == false) wheres.Add($"PartNo='{vdata.PARTNO}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (Apply && VAR.BOOL[eVarBool.Opt_Conv_Where_SID])
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.Opt_SIDConvert]) //if sid convert logic
|
||||
{
|
||||
if (vdata.SID_Trust && vdata.SID0.isEmpty() == false && vdata.SID.isEmpty() == false)
|
||||
wheres.Add($"SIDTo='{vdata.SID}'");
|
||||
else Apply = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vdata.SID_Trust && vdata.SID.isEmpty() == false) wheres.Add($"SIDTo='{vdata.SID}'");
|
||||
else Apply = false;
|
||||
}
|
||||
}
|
||||
if (VAR.BOOL[eVarBool.Opt_Conv_Where_VLOT]) //221013
|
||||
{
|
||||
if (vdata.VLOT_Trust && vdata.VLOT.isEmpty() == false)
|
||||
wheres.Add($"(VenderLot like '{vdata.VLOT}' or VenderLot like '%,{vdata.VLOT}' or VenderLot like '{vdata.VLOT},%' or VenderLot like '%,{vdata.VLOT},%')");
|
||||
else Apply = false;
|
||||
}
|
||||
|
||||
|
||||
//if query data . no error
|
||||
if (Apply && fields.Count > 0 && wheres.Count > 0)
|
||||
{
|
||||
|
||||
var mcname = SETTING.Data.McName;
|
||||
if (VAR.BOOL[eVarBool.Use_Conveyor]) mcname = PUB.MCCode;
|
||||
|
||||
var SQL = "select top 1 " + string.Join(",", fields) +
|
||||
" from K4EE_Component_Reel_SID_Convert WITH(NOLOCK)" +
|
||||
" where " + string.Join(" and ", wheres) +
|
||||
" order by wdate desc";
|
||||
|
||||
var SQLC = "select count(*)" +
|
||||
" from K4EE_Component_Reel_SID_Convert WITH(NOLOCK)" +
|
||||
" where " + string.Join(" and ", wheres);
|
||||
|
||||
if (PUB.Result.ItemDataC.VisionData.LastQueryStringCNV.Equals(SQL) == false)
|
||||
{
|
||||
if (PUB.GetSIDInfo_And_SetData(fields, ref vdata, SQL, SQLC) == true)
|
||||
NewBarcodeUpdated = true;
|
||||
|
||||
PUB.Result.ItemDataC.VisionData.LastQueryStringCNV = SQL;
|
||||
}
|
||||
}
|
||||
return NewBarcodeUpdated;
|
||||
}
|
||||
|
||||
//기존 작업에서 데이터를 찾아서 쓴다
|
||||
bool BCDProcess_FindJobData(Class.JobData itemC)
|
||||
{
|
||||
bool NewBarcodeUpdated = false;
|
||||
Boolean Apply = true;
|
||||
var vdata = itemC.VisionData;
|
||||
|
||||
//select columns
|
||||
List<string> fields = new List<string>();
|
||||
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Apply_CustCode] && vdata.CUSTCODE.isEmpty()) fields.Add("CUSTCODE");
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Apply_PartNo] && (vdata.PARTNO.isEmpty() || vdata.PARTNO_Trust == false)) fields.Add("PARTNO");
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Apply_PrintPos] && vdata.PrintPositionData.isEmpty()) fields.Add("POS");
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Apply_VenderName] && (vdata.VNAME_Trust == false || vdata.VNAME.isEmpty())) fields.Add("VNAME");
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Apply_SID] && (vdata.SID_Trust == false || vdata.SID.isEmpty())) fields.Add("SID");
|
||||
|
||||
//where coluns
|
||||
List<string> wheres = new List<string>();
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Where_CustCode])
|
||||
{
|
||||
if (vdata.CUSTCODE.isEmpty() == false) wheres.Add($"CUSTCODE='{vdata.CUSTCODE.PadLeft(10, '0')}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Where_PartNo])
|
||||
{
|
||||
if (vdata.PARTNO_Trust && vdata.PARTNO.isEmpty() == false) wheres.Add($"PARTNO='{vdata.PARTNO}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Where_SID])
|
||||
{
|
||||
if (vdata.SID_Trust && vdata.SID.isEmpty() == false) wheres.Add($"SID='{vdata.SID}'");
|
||||
else Apply = false;
|
||||
}
|
||||
if (VAR.BOOL[eVarBool.Opt_Job_Where_VLOT])
|
||||
{
|
||||
if (vdata.VLOT_Trust && vdata.VLOT.isEmpty() == false) wheres.Add($"VenderLot='{vdata.VLOT}'");
|
||||
else Apply = false;
|
||||
}
|
||||
|
||||
//if query data . no error
|
||||
if (Apply && fields.Count > 0 && wheres.Count > 0)
|
||||
{
|
||||
PUB.log.Add($"DATABAES : RESULT QUERY");
|
||||
|
||||
var SQL = "select top 1 " + string.Join(",", fields) +
|
||||
" from K4EE_Component_Reel_Result WITH(NOLOCK) " +
|
||||
$" where mc = '{AR.SETTING.Data.McName}'" +
|
||||
$" and prnattach = 1 and stime >= '{DateTime.Now.AddHours(-3).ToString("yyyy-MM-dd HH:mm:ss")}'" +
|
||||
$" and " + string.Join(" and ", wheres) +
|
||||
$" order by wdate desc";
|
||||
|
||||
if (PUB.Result.ItemDataC.VisionData.LastQueryStringJOB.Equals(SQL) == false)
|
||||
{
|
||||
if (PUB.GetSIDInfo_And_SetData(fields, ref vdata, SQL, ""))
|
||||
NewBarcodeUpdated = true;
|
||||
|
||||
PUB.Result.ItemDataC.VisionData.LastQueryStringJOB = SQL;
|
||||
}
|
||||
}
|
||||
return NewBarcodeUpdated;
|
||||
}
|
||||
|
||||
void BCDProcess_SIDConvert(Class.JobData itemC)
|
||||
{
|
||||
var vdata = itemC.VisionData;
|
||||
//원본시드(sid0)가 비어있는데 sid과 확정되었다면 변환작업을 진행한다
|
||||
if (vdata.SID0.isEmpty() && vdata.SID.isEmpty() == false && vdata.SID_Trust)
|
||||
{
|
||||
//이 sid가 존재여부확인 후 없는 sid라면 더이상 처리하지 않는다 230510
|
||||
if (PUB.Result.DTSidConvertEmptyList.Contains(vdata.SID))
|
||||
{
|
||||
//존재하지 않는 SID로 이미 확인되었다
|
||||
}
|
||||
else if (PUB.Result.DTSidConvertMultiList.Contains(vdata.SID))
|
||||
{
|
||||
//다중sid로 인해 처리하지 않는다
|
||||
}
|
||||
else
|
||||
{
|
||||
var newsid = PUB.SIDCovert(vdata.SID, "SPS_BarcodeProcess", out bool converr);
|
||||
if (converr)
|
||||
{
|
||||
if (PUB.sm.Step == eSMStep.RUN)
|
||||
PUB.log.AddE(newsid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vdata.SID0 = vdata.SID;
|
||||
vdata.SID = newsid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Generate Reel ID
|
||||
void BCDProcess_MakeReelID(Class.JobData itemC)
|
||||
{
|
||||
if (itemC.VisionData.RIDNew == false && itemC.VisionData.SID.isEmpty() == false)
|
||||
{
|
||||
var newid = PUB.MakeNewREELID(itemC.VisionData.SID);// Amkor.RestfulService.Allocation_Unique_ReelID_AmkorSTD(itemC.VisionData.CUSTCODE, "4", "A", out string errmsg);
|
||||
if (newid.success == true)
|
||||
{
|
||||
//backup origin reel id
|
||||
itemC.VisionData.RID0 = itemC.VisionData.RID;
|
||||
|
||||
//set new reel id
|
||||
PUB.log.Add("new reelid bacodeprecess");
|
||||
itemC.VisionData.SetRID(newid.newid, "SPS:CHKDATACOMPLETE");// = newid;
|
||||
itemC.VisionData.RIDNew = true; //applied new reel id
|
||||
|
||||
//서버의수량업데이트기능이 켜져있다면 해당 값을 제거해준다. (다시 조회되도록 함)
|
||||
if (VAR.BOOL[eVarBool.Opt_ServerQty])
|
||||
{
|
||||
//이미 수량업데이트된 경우이므로 복원시켜준다
|
||||
if (itemC.VisionData.QTY0.isEmpty() == false)
|
||||
{
|
||||
PUB.log.AddAT($"릴아이디 변경으로 인해 수량을 복원합니다({itemC.VisionData.QTY}->{itemC.VisionData.QTY0})");
|
||||
itemC.VisionData.QTY = itemC.VisionData.QTY0;
|
||||
itemC.VisionData.QTY0 = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var logtime = VAR.TIME.RUN((int)eVarTime.LOG_NEWIDERROR);
|
||||
if (logtime.TotalSeconds >= 3000)
|
||||
{
|
||||
PUB.log.AddAT($"Reel_ID 생성실패 : {newid.message}");
|
||||
VAR.TIME.Update(eVarTime.LOG_NEWIDERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Data;
|
||||
//using System.Diagnostics;
|
||||
//using System.Drawing;
|
||||
//using System.IO;
|
||||
//using System.Linq;
|
||||
//using System.Management;
|
||||
//using System.Net;
|
||||
//using System.Net.NetworkInformation;
|
||||
//using System.Runtime.Serialization.Formatters.Binary;
|
||||
//using System.Text;
|
||||
//using System.Windows.Forms;
|
||||
|
||||
//namespace Project
|
||||
//{
|
||||
|
||||
// public static partial class UTIL
|
||||
// {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //public static Boolean SendMail(string title, string body, string from, string[] tolist, string file = "")
|
||||
// //{
|
||||
// // //메일을 전송하고 나간다
|
||||
// // Chilkat.MailMan mailman = new Chilkat.MailMan();
|
||||
// // bool success = mailman.UnlockComponent("BLUPRT.CBX012020_rzDFf7pQAsCS");
|
||||
// // if (success != true)
|
||||
// // {
|
||||
// // UTIL.MsgE("메일 전송이 실패되었습니다\n잠시 후 다시 시도하세요", true);
|
||||
// // return false;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // mailman.SmtpHost = "10.101.10.6";
|
||||
// // mailman.SmtpPort = 25;
|
||||
// // Chilkat.Email email = new Chilkat.Email();
|
||||
// // email.Subject = title;
|
||||
// // //email.Body = this.textBox1.Text;
|
||||
// // email.SetHtmlBody(body.Replace("\r", "").Replace("\n", "<br/>"));
|
||||
// // email.From = from;
|
||||
|
||||
// // foreach (var to in tolist)
|
||||
// // email.AddTo(to.Substring(0, to.IndexOf('@')), to);
|
||||
|
||||
// // if (System.IO.File.Exists(file))
|
||||
// // email.AddFileAttachment(file);
|
||||
|
||||
// // success = mailman.SendEmail(email);
|
||||
// // if (success != true)
|
||||
// // {
|
||||
// // UTIL.MsgE("발송 실패", true);
|
||||
// // return false;
|
||||
// // }
|
||||
|
||||
// // success = mailman.CloseSmtpConnection();
|
||||
// // if (success != true)
|
||||
// // {
|
||||
// // UTIL.MsgE("Connection to SMTP server not closed cleanly.", true);
|
||||
// // return false;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // return true;
|
||||
// //}
|
||||
|
||||
|
||||
// //public static string JobListToFile(Class.CHistoryJOB data, string jobdate, string jobseq, out int cnt)
|
||||
// //{
|
||||
// // cnt = 0;
|
||||
// // if (string.IsNullOrEmpty(jobdate)) return string.Empty;
|
||||
// // //이미저장된 목록을 가져오고 중복된것은 피한다
|
||||
// // var preSavedFile = System.IO.Path.Combine(COMM.SETTING.Data.Path_Data, "JobData", jobdate.Substring(0, 6), jobdate + "-" + jobseq + ".txt");
|
||||
// // List<string> preList = new List<string>();
|
||||
// // if (System.IO.File.Exists(preSavedFile)) preList.AddRange(System.IO.File.ReadAllLines(preSavedFile, System.Text.Encoding.UTF8));
|
||||
|
||||
// // //Temp
|
||||
// // var fiName = System.IO.Path.Combine(COMM.SETTING.Data.Path_Data, "UploadTemp", jobdate + "_" + jobseq + ".tab");
|
||||
// // var fi = new System.IO.FileInfo(fiName);
|
||||
// // if (fi.Directory.Exists == false) fi.Directory.Create();
|
||||
// // var sb = new System.Text.StringBuilder();
|
||||
|
||||
// // sb.AppendLine("#Time\tSID\tRID\tRAW");
|
||||
// // var oklist = data.Items.Where(t => t.VisionData.RID.isEmpty() == false).ToArray();
|
||||
// // foreach (var item in oklist)
|
||||
// // {
|
||||
// // //기존에 전송한 목록에 없어야 한다
|
||||
// // if (item.error == Class.JobData.ErrorCode.None && item.VisionData.RID.isEmpty() == false)
|
||||
// // {
|
||||
// // sb.AppendLine(string.Format("{0}\t{1}\t{2}\t{3}",
|
||||
// // item.JobStart.ToString("yyyy-MM-dd HH:mm:sss"), item.VisionData.SID, item.VisionData.RID, item.VisionData.QROutRaw));
|
||||
// // cnt += 1;
|
||||
// // }
|
||||
// // }
|
||||
// // try
|
||||
// // {
|
||||
// // System.IO.File.WriteAllText(fi.FullName, sb.ToString(), System.Text.Encoding.UTF8);
|
||||
// // return fi.FullName;
|
||||
// // }
|
||||
// // catch (Exception ex)
|
||||
// // {
|
||||
// // PUB.log.AddE("JobListToFile:" + ex.Message);
|
||||
// // return string.Empty;
|
||||
// // }
|
||||
// //}
|
||||
|
||||
// //public static bool SendMail(string seqdate, string seqno)
|
||||
// //{
|
||||
// // Chilkat.MailMan mailman = new Chilkat.MailMan();
|
||||
// // bool success = mailman.UnlockComponent("BLUPRT.CBX012020_rzDFf7pQAsCS");
|
||||
// // if (success != true)
|
||||
// // {
|
||||
// // Debug.WriteLine(mailman.LastErrorText);
|
||||
// // return false;
|
||||
// // }
|
||||
|
||||
// // mailman.SmtpHost = "10.101.10.6";
|
||||
|
||||
// // mailman.SmtpPort = 25;
|
||||
|
||||
// // // Create a new email object
|
||||
// // Chilkat.Email email = new Chilkat.Email();
|
||||
|
||||
// // var mailform = PUB.mailForm.FirstOrDefault();
|
||||
// // if (mailform == null)
|
||||
// // return false;
|
||||
|
||||
|
||||
|
||||
// // var subject = mailform.subject.Trim();
|
||||
// // subject = subject.Replace("{seqdate}", seqdate);
|
||||
// // subject = subject.Replace("{seqno}", seqno);
|
||||
|
||||
|
||||
// // var buffer = System.IO.File.ReadAllText(UTIL.CurrentPath + "\\Mailform.html");
|
||||
|
||||
// // //시드별집계데이터생성
|
||||
// // System.Text.StringBuilder sbFileSID = new StringBuilder();
|
||||
// // System.Text.StringBuilder sbFileREEL = new StringBuilder();
|
||||
// // sbFileSID.AppendLine(string.Format("NO,SID,작업수량,예정수량,UNIT"));
|
||||
// // sbFileREEL.AppendLine(string.Format("NO,SID,REEL,QTY,TIME"));
|
||||
|
||||
// // // int cntrid = 1;
|
||||
|
||||
// // System.IO.File.WriteAllText(UTIL.CurrentPath + "\\result_sidsummary.csv", sbFileSID.ToString(), System.Text.Encoding.Default);
|
||||
// // System.IO.File.WriteAllText(UTIL.CurrentPath + "\\result_reelist.csv", sbFileREEL.ToString(), System.Text.Encoding.Default);
|
||||
|
||||
// // //메일본문의 내용 치환
|
||||
// // var contents = buffer.Trim();
|
||||
// // contents = contents.Replace("{seqdate}", seqdate);
|
||||
// // contents = contents.Replace("{seqno}", seqno);
|
||||
|
||||
// // email.Subject = subject;
|
||||
// // email.SetHtmlBody(contents);
|
||||
// // email.From = "ReelSorter";
|
||||
// // email.AddFileAttachment(UTIL.CurrentPath + "\\result_sidsummary.csv");
|
||||
// // email.AddFileAttachment(UTIL.CurrentPath + "\\result_reelist.csv");
|
||||
|
||||
|
||||
// // System.Text.StringBuilder maillist = new StringBuilder();
|
||||
// // foreach (DataSet1.MailRecipientRow r in PUB.mailList.Rows)
|
||||
// // {
|
||||
// // success = email.AddTo(r.Name, r.Address);
|
||||
// // maillist.Append(string.Format("{0}({1})", r.Name, r.Address));
|
||||
// // }
|
||||
|
||||
|
||||
// // success = mailman.SendEmail(email);
|
||||
// // if (success != true)
|
||||
// // {
|
||||
// // Debug.WriteLine(mailman.LastErrorText);
|
||||
// // return false;
|
||||
// // }
|
||||
|
||||
// // success = mailman.CloseSmtpConnection();
|
||||
// // if (success != true)
|
||||
// // {
|
||||
// // Debug.WriteLine("Connection to SMTP server not closed cleanly.");
|
||||
// // PUB.log.AddE("메일 발송 실패(" + maillist.ToString() + ")");
|
||||
// // }
|
||||
|
||||
// // PUB.log.AddI("메일 발송 완료(" + maillist.ToString() + ")");
|
||||
// // return true;
|
||||
// //}
|
||||
|
||||
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user