Compare commits
1 Commits
master
...
lowProdGen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac76e44b2e |
16
Authentication Register Program/OliveYoungRelateDTO.vb
Normal file
16
Authentication Register Program/OliveYoungRelateDTO.vb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Public Class OliveYoungRelateDTO
|
||||||
|
Public Property Serial_Number As String
|
||||||
|
Public Property itemCode As String
|
||||||
|
Public Property item_name As String
|
||||||
|
Public Property colorFlag As String
|
||||||
|
|
||||||
|
Public Property invoice As String
|
||||||
|
|
||||||
|
Public Property Shipment_Date As String
|
||||||
|
Public Property Account_Name As String
|
||||||
|
|
||||||
|
Public Sub New(pk As String)
|
||||||
|
Me.Serial_Number = pk
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
End Class
|
||||||
@ -5,7 +5,8 @@ Imports MySql.Data.MySqlClient
|
|||||||
|
|
||||||
Public Class mainform
|
Public Class mainform
|
||||||
Private Sub mainform_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub mainform_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
Me.Text = "DUALSONIC Authentication Register Program Ver 1.1.0"
|
Me.Text = "DUALSONIC Authentication Register Program Ver 1.1.5"
|
||||||
|
lowProdListLoad()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private PackOk As Boolean = False
|
Private PackOk As Boolean = False
|
||||||
@ -13,6 +14,11 @@ Public Class mainform
|
|||||||
|
|
||||||
Private Const COL_COUNT As Byte = 19
|
Private Const COL_COUNT As Byte = 19
|
||||||
|
|
||||||
|
Private lowProdflag As Boolean = False ''언제 초기화 해줄지 결정해야함
|
||||||
|
|
||||||
|
Private lowProd88List As New Dictionary(Of String, String) ''key : 88코드 value: 모델코드&컬러
|
||||||
|
|
||||||
|
|
||||||
Private Sub BtnOrderSearch_Click(sender As Object, e As EventArgs) Handles btnOrderSearch.Click
|
Private Sub BtnOrderSearch_Click(sender As Object, e As EventArgs) Handles btnOrderSearch.Click
|
||||||
lbWait.Visible = True
|
lbWait.Visible = True
|
||||||
lbWait.Refresh()
|
lbWait.Refresh()
|
||||||
@ -55,11 +61,13 @@ Public Class mainform
|
|||||||
mcDate.Enabled = True
|
mcDate.Enabled = True
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
lowProdflag = False
|
||||||
lbWait.Visible = False
|
lbWait.Visible = False
|
||||||
lbWait.Refresh()
|
lbWait.Refresh()
|
||||||
End Sub
|
End Sub
|
||||||
|
Private Sub lowProdListLoad()
|
||||||
|
lowProdList(lowProd88List)
|
||||||
|
End Sub
|
||||||
Private Function GetGenuineDatasByDate(targetDate As Date) As List(Of GenuineProductDto)
|
Private Function GetGenuineDatasByDate(targetDate As Date) As List(Of GenuineProductDto)
|
||||||
Dim results = FindSerialsByDate(targetDate)
|
Dim results = FindSerialsByDate(targetDate)
|
||||||
|
|
||||||
@ -69,6 +77,19 @@ Public Class mainform
|
|||||||
Dim genuineProductDtoMap As New Dictionary(Of String, GenuineProductDto)
|
Dim genuineProductDtoMap As New Dictionary(Of String, GenuineProductDto)
|
||||||
|
|
||||||
For Each serial In individualSerials
|
For Each serial In individualSerials
|
||||||
|
If lowProd88List.Count <> 0 Then
|
||||||
|
If lowProd88List.ContainsKey(serial) Then
|
||||||
|
|
||||||
|
If lowProdflag = False Then
|
||||||
|
For Each dt In getOyList(lowProd88List)
|
||||||
|
genuineProductDtoMap.Add(dt.Key, dt.Value)
|
||||||
|
Next
|
||||||
|
lowProdflag = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
Continue For
|
||||||
|
End If
|
||||||
|
End If
|
||||||
Dim genuineProductDto As New GenuineProductDto(serial)
|
Dim genuineProductDto As New GenuineProductDto(serial)
|
||||||
genuineProductDtoMap(serial) = genuineProductDto
|
genuineProductDtoMap(serial) = genuineProductDto
|
||||||
Next
|
Next
|
||||||
@ -239,10 +260,15 @@ Public Class mainform
|
|||||||
UpdateData = "INSERT INTO fm_genuine" & ColName & " VALUES " & UpdateData
|
UpdateData = "INSERT INTO fm_genuine" & ColName & " VALUES " & UpdateData
|
||||||
|
|
||||||
If SSHCommand(UpdateData) Then
|
If SSHCommand(UpdateData) Then
|
||||||
MsgBox("저장 완료 !", vbInformation)
|
If updateOliveYoungGenuineDate(lowProd88List) Then
|
||||||
|
dgvNormal.Rows.Clear()
|
||||||
|
MsgBox("저장 완료 !", vbInformation)
|
||||||
|
Else
|
||||||
|
MsgBox("저장 실패 !", vbCritical)
|
||||||
|
End If
|
||||||
Else
|
Else
|
||||||
MsgBox("저장 실패 !", vbCritical)
|
MsgBox("저장 실패 !", vbCritical)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
lbsave.Visible = False
|
lbsave.Visible = False
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
Imports MySql.Data.MySqlClient
|
Imports MySql.Data.MySqlClient
|
||||||
Imports Renci.SshNet
|
Imports Renci.SshNet
|
||||||
|
|
||||||
Module mySQLModule
|
Module mySQLModule
|
||||||
@ -21,6 +21,8 @@ Module mySQLModule
|
|||||||
Public Const CartTDDB As String = "jomtTesterDB.jomtCartridgeTbl"
|
Public Const CartTDDB As String = "jomtTesterDB.jomtCartridgeTbl"
|
||||||
Public Const OrderDB As String = "jomtOrderDB.jomtOrderTbl"
|
Public Const OrderDB As String = "jomtOrderDB.jomtOrderTbl"
|
||||||
Public Const PlistDB As String = "jomtTesterDB.jomtProdList"
|
Public Const PlistDB As String = "jomtTesterDB.jomtProdList"
|
||||||
|
Dim genuineProductDtoMap As Dictionary(Of String, GenuineProductDto)
|
||||||
|
Private orderCodeList As HashSet(Of String)
|
||||||
|
|
||||||
Public Function GetDBConn() As MySqlConnection
|
Public Function GetDBConn() As MySqlConnection
|
||||||
Try
|
Try
|
||||||
@ -33,23 +35,36 @@ Module mySQLModule
|
|||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
Public Sub lowProdList(dic As Dictionary(Of String, String))
|
||||||
|
Using Conn As MySqlConnection = GetDBConn()
|
||||||
|
Dim cmd As New MySqlCommand("SELECT 88_Code, ModelNum, ColorNum FROM jomtTesterDB.jomtProdList WHERE 88_Code IS NOT NULL", Conn)
|
||||||
|
|
||||||
|
Using reader As MySqlDataReader = cmd.ExecuteReader()
|
||||||
|
While reader.Read
|
||||||
|
Dim key = reader("88_Code").ToString.Trim
|
||||||
|
Dim value = reader("ModelNum").ToString.Trim + reader("ColorNum").ToString.Trim
|
||||||
|
dic.Add(key, value)
|
||||||
|
End While
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
End Sub
|
||||||
Public Function FindSerialsByDate(targetDate As Date) As ValueTuple(Of List(Of String), List(Of String))
|
Public Function FindSerialsByDate(targetDate As Date) As ValueTuple(Of List(Of String), List(Of String))
|
||||||
Using conn As MySqlConnection = GetDBConn()
|
Using conn As MySqlConnection = GetDBConn()
|
||||||
Dim getSerialCmd As New MySqlCommand("SELECT Serial_Number FROM jomtOrderDB.jomtOrderTbl
|
Dim getSerialCmd As New MySqlCommand("SELECT Serial_Number,Order_Code FROM jomtOrderDB.jomtOrderTbl
|
||||||
WHERE Invoice_Number IS NOT NULL
|
WHERE Invoice_Number IS NOT NULL
|
||||||
AND Serial_Number IS NOT NULL
|
AND Serial_Number IS NOT NULL
|
||||||
AND LENGTH(Serial_Number) > 11
|
AND ((LEFT(Serial_Number,1) < '8' AND LENGTH(Serial_Number) > 11 ) OR Serial_Number in (SELECT 88_Code FROM jomtTesterDB.jomtProdList WHERE 88_Code IS NOT NULL))
|
||||||
AND LEFT(Serial_Number, 1) < '8'
|
AND genuine_date is null
|
||||||
AND Shipment_Date = @date", conn)
|
AND Shipment_Date = @date", conn)
|
||||||
|
|
||||||
getSerialCmd.Parameters.AddWithValue("@date", targetDate)
|
getSerialCmd.Parameters.AddWithValue("@date", targetDate)
|
||||||
|
|
||||||
Dim serials As New List(Of String)
|
Dim serials As New List(Of String)
|
||||||
Dim unmatchedSerials As New List(Of String)
|
Dim unmatchedSerials As New List(Of String)
|
||||||
|
orderCodeList = New HashSet(Of String)
|
||||||
Using reader As MySqlDataReader = getSerialCmd.ExecuteReader()
|
Using reader As MySqlDataReader = getSerialCmd.ExecuteReader()
|
||||||
While reader.Read()
|
While reader.Read()
|
||||||
|
orderCodeList.Add(reader("Order_Code").ToString().Trim())
|
||||||
Dim raw = reader("Serial_Number").ToString().Trim()
|
Dim raw = reader("Serial_Number").ToString().Trim()
|
||||||
If raw.Contains("/") Then
|
If raw.Contains("/") Then
|
||||||
serials.AddRange(raw.Split("/"c).Select(Function(s) s.Trim()).Where(Function(s) s.Length > 0))
|
serials.AddRange(raw.Split("/"c).Select(Function(s) s.Trim()).Where(Function(s) s.Length > 0))
|
||||||
@ -199,4 +214,157 @@ Module mySQLModule
|
|||||||
Next
|
Next
|
||||||
End Using
|
End Using
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Function getOyList(dic As Dictionary(Of String, String)) As Dictionary(Of String, GenuineProductDto)
|
||||||
|
Dim TdTableList As New List(Of String) From {"jomtTesterDB.jomtCartridgeTbl", "jomtTesterDB.jomtLDMTbl", "jomtTesterDB.jomtNonTDTbl"}
|
||||||
|
genuineProductDtoMap = New Dictionary(Of String, GenuineProductDto)
|
||||||
|
Dim OliveYoungRelateDTOList As New List(Of OliveYoungRelateDTO)
|
||||||
|
Dim Serial_NumberFilterList As New List(Of String)()
|
||||||
|
For Each sn In dic.Keys
|
||||||
|
If Not String.IsNullOrWhiteSpace(sn) Then
|
||||||
|
Serial_NumberFilterList.Add(sn.Trim())
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
Using conn As MySqlConnection = GetDBConn()
|
||||||
|
'' 첫 번째 쿼리: Serial_Number IN (파라미터)
|
||||||
|
If Serial_NumberFilterList.Count > 0 Then
|
||||||
|
Dim inParams As New List(Of String)
|
||||||
|
For i As Integer = 0 To Serial_NumberFilterList.Count - 1
|
||||||
|
inParams.Add("@sno" & i)
|
||||||
|
Next
|
||||||
|
Dim inClause As String = String.Join(", ", inParams)
|
||||||
|
Dim query As String = "SELECT DISTINCT item_code, item_name, Serial_Number, Invoice_Number, DATE_FORMAT(Shipment_Date, '%Y-%m-%d') AS Shipment_Date, Account_Name FROM jomtOrderDB.jomtOrderTbl WHERE Serial_Number IN (" & inClause & ") AND genuine_date IS NULL"
|
||||||
|
Using cmd As New MySqlCommand(query, conn)
|
||||||
|
For i As Integer = 0 To Serial_NumberFilterList.Count - 1
|
||||||
|
cmd.Parameters.AddWithValue("@sno" & i, Serial_NumberFilterList(i))
|
||||||
|
Next
|
||||||
|
Using reader = cmd.ExecuteReader()
|
||||||
|
While reader.Read()
|
||||||
|
Dim oy_object As New OliveYoungRelateDTO(reader("Serial_Number").ToString().Trim())
|
||||||
|
oy_object.colorFlag = dic(oy_object.Serial_Number)
|
||||||
|
oy_object.itemCode = reader("item_code").ToString().Trim()
|
||||||
|
oy_object.item_name = reader("item_name").ToString().Trim()
|
||||||
|
oy_object.invoice = reader("Invoice_Number").ToString().Trim()
|
||||||
|
oy_object.Shipment_Date = reader("Shipment_Date").ToString().Trim()
|
||||||
|
oy_object.Account_Name = reader("Account_Name").ToString().Trim()
|
||||||
|
OliveYoungRelateDTOList.Add(oy_object)
|
||||||
|
End While
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
End If
|
||||||
|
|
||||||
|
'' 두 번째 쿼리: Product_SN LIKE (파라미터) - TdTableList 각 테이블 조회 (동일 스키마: Product_SN, Ct_Abroad, P3_DateTime, LastQC_Date, TestStep, genuine_date)
|
||||||
|
For Each obj In OliveYoungRelateDTOList
|
||||||
|
Dim likeValue As String = obj.colorFlag & "%"
|
||||||
|
|
||||||
|
For Each tableName As String In TdTableList
|
||||||
|
If String.IsNullOrWhiteSpace(tableName) Then Continue For
|
||||||
|
Dim query2 As String = "SELECT Product_SN, Ct_Abroad AS Country, DATE_FORMAT(P3_DateTime, '%Y-%m-%d') AS MfgDate FROM " & tableName & " WHERE Product_SN LIKE @colorPrefix AND LastQC_Date IS NOT NULL AND TestStep = 31 AND genuine_date IS NULL"
|
||||||
|
Try
|
||||||
|
Using sec_cmd As New MySqlCommand(query2, conn)
|
||||||
|
sec_cmd.Parameters.AddWithValue("@colorPrefix", likeValue)
|
||||||
|
Using sec_reader = sec_cmd.ExecuteReader()
|
||||||
|
While sec_reader.Read()
|
||||||
|
Dim productSn As String = sec_reader("Product_SN").ToString()
|
||||||
|
If genuineProductDtoMap.ContainsKey(productSn) Then Continue While
|
||||||
|
Dim dto As New GenuineProductDto(productSn)
|
||||||
|
dto.ModelCode = obj.itemCode
|
||||||
|
dto.Model = obj.item_name
|
||||||
|
dto.PackingSn = obj.Serial_Number
|
||||||
|
dto.SalesStore = obj.Account_Name
|
||||||
|
dto.ManufactureDate = sec_reader("MfgDate").ToString()
|
||||||
|
dto.InvoiceNumber = obj.invoice
|
||||||
|
dto.BuyDate = obj.Shipment_Date
|
||||||
|
genuineProductDtoMap.Add(productSn, dto)
|
||||||
|
End While
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
Catch ex As MySqlException
|
||||||
|
'' 테이블/컬럼 스키마가 다르면 해당 테이블만 스킵 (예: jomtLDMTbl이 Abroad/DateTime 사용 시)
|
||||||
|
'' 필요 시 로그: MsgBox("테이블 조회 제외: " & tableName & " - " & ex.Message)
|
||||||
|
End Try
|
||||||
|
Next
|
||||||
|
Next
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Return genuineProductDtoMap
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function updateOliveYoungGenuineDate(dic As Dictionary(Of String, String)) As Boolean
|
||||||
|
'' Product_SN, genuine_date 컬럼이 있는 테이블만 포함 (스키마 동일한 테이블만)
|
||||||
|
Dim TdTableList As New List(Of String) From {"jomtTesterDB.jomtCartridgeTbl", "jomtTesterDB.jomtLDMTbl", "jomtTesterDB.jomtNonTDTbl"}
|
||||||
|
Try
|
||||||
|
Dim productSnList As New List(Of String)()
|
||||||
|
If genuineProductDtoMap IsNot Nothing Then
|
||||||
|
productSnList.AddRange(genuineProductDtoMap.Keys)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim serialFilterList As New List(Of String)() ''88코드
|
||||||
|
For Each sn In dic.Keys
|
||||||
|
If Not String.IsNullOrWhiteSpace(sn) Then serialFilterList.Add(sn.Trim())
|
||||||
|
Next
|
||||||
|
|
||||||
|
Dim orderList As New List(Of String)()
|
||||||
|
If orderCodeList IsNot Nothing Then
|
||||||
|
orderList.AddRange(orderCodeList)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Using conn As MySqlConnection = GetDBConn()
|
||||||
|
'' TD 테이블들: Product_SN IN (파라미터)
|
||||||
|
If productSnList.Count > 0 Then
|
||||||
|
Dim inParams As New List(Of String)
|
||||||
|
For i As Integer = 0 To productSnList.Count - 1
|
||||||
|
inParams.Add("@psn" & i)
|
||||||
|
Next
|
||||||
|
Dim inClause As String = String.Join(", ", inParams)
|
||||||
|
For Each tableName As String In TdTableList
|
||||||
|
Dim query As String = "UPDATE " & tableName & " SET genuine_date = NOW() WHERE Product_SN IN (" & inClause & ")"
|
||||||
|
Using cmd As New MySqlCommand(query, conn)
|
||||||
|
For i As Integer = 0 To productSnList.Count - 1
|
||||||
|
cmd.Parameters.AddWithValue("@psn" & i, productSnList(i))
|
||||||
|
Next
|
||||||
|
cmd.ExecuteNonQuery()
|
||||||
|
End Using
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
'' 주문 테이블: Order_Code IN, Serial_Number IN (파라미터)
|
||||||
|
If orderList.Count = 0 Then Return True
|
||||||
|
Dim orderParams As New List(Of String)
|
||||||
|
For i As Integer = 0 To orderList.Count - 1
|
||||||
|
orderParams.Add("@ord" & i)
|
||||||
|
Next
|
||||||
|
Dim orderInClause As String = String.Join(", ", orderParams)
|
||||||
|
Dim serialInClause As String
|
||||||
|
Dim queryOrder As String
|
||||||
|
If serialFilterList.Count > 0 Then
|
||||||
|
Dim serialParams As New List(Of String)
|
||||||
|
For i As Integer = 0 To serialFilterList.Count - 1
|
||||||
|
serialParams.Add("@sno" & i)
|
||||||
|
Next
|
||||||
|
serialInClause = String.Join(", ", serialParams)
|
||||||
|
queryOrder = "UPDATE jomtOrderDB.jomtOrderTbl SET genuine_date = NOW() WHERE Order_Code IN (" & orderInClause & ") AND ((LEFT(Serial_Number,1) < '8' AND LENGTH(Serial_Number) > 11) OR Serial_Number IN (" & serialInClause & "))"
|
||||||
|
Else
|
||||||
|
queryOrder = "UPDATE jomtOrderDB.jomtOrderTbl SET genuine_date = NOW() WHERE Order_Code IN (" & orderInClause & ") AND (LEFT(Serial_Number,1) < '8' AND LENGTH(Serial_Number) > 11)"
|
||||||
|
End If
|
||||||
|
|
||||||
|
Using cmd As New MySqlCommand(queryOrder, conn)
|
||||||
|
For i As Integer = 0 To orderList.Count - 1
|
||||||
|
cmd.Parameters.AddWithValue("@ord" & i, orderList(i))
|
||||||
|
Next
|
||||||
|
If serialFilterList.Count > 0 Then
|
||||||
|
For i As Integer = 0 To serialFilterList.Count - 1
|
||||||
|
cmd.Parameters.AddWithValue("@sno" & i, serialFilterList(i))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
cmd.ExecuteNonQuery()
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
Return True
|
||||||
|
Catch ex As Exception
|
||||||
|
MsgBox("정품 등록 중 NAS 오류 발생!" & vbCrLf & ex.Message)
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
End Module
|
End Module
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user