Sub LoadJobs
Sleep(1)
Dim Li As List
Li.Initialize2(Array(Main.SetUpUnitDivisor, Main.RunUnitDivisor, Main.ActiveWC, Main.ActiveWC))
Dim SQLStr As String
SQLStr = $"Select SchedMachines.SchM_Machine, [SchO_ID], ScheduledOps.SchO_Order, FORMAT(Os_StartbyDate, 'MM/dd', 'en-US') AS Os_StartbyDate,Opstatus.Os_JobNum,Opstatus.Os_ReleaseNum,Opstatus.Os_SeqNum, SchedMachines.SchM_ID, SchedMachines.SchM_HrsPerWk,
ScheduledOps.SchO_SchMTID,Opstatus.Os_WCCode,Opstatus.Os_FinishbyDate,Opstatus.Os_ID, Jobs.Jb_Part_Num, Jobs.Jb_Part_Rev, Jobs.Jb_Part_Desc, JobRelease.Jr_StartQty, SchedMachines.SchM_WCCode,
SchedMachines.SchM_Group,Opstatus.Os_RunTime,Opstatus.Os_SetupTime,Opstatus.Os_HoursTodate, FORMAT((COALESCE(Os_SetupTime, 0) / ?) + ((COALESCE(Jr_StartQty, 1) * COALESCE(Os_RunTime, 0)) / ?), '0.0', 'en-us') BalHrs,Opstatus.Os_QtyToMake,Opstatus.Os_QtyTodate, SchedFirstDueDateQry.MinOfSh_Due_Date As FirstDueDate,
JobShip.Sh_Note, SchedMachines.SchM_EmpAssignDayShift, SchedMachines.SchM_EmpAssignShift2, SchedMachines.SchM_EmpAssignShift3, SchedMachines.SchM_Cell, ScheduledOps.SchO_OSId,Opstatus.Os_Status,
Opstatus.Os_Description, FORMAT(Jr_FirstDueDate, 'MM/dd', 'en-US') AS Jr_FirstDueDate, --OpsByMachStatusCheckScheduleTemp.NewSchedStartDate, OpsByMachStatusCheckScheduleTemp.NewSchedFinishDate, OpsByMachStatusCheckScheduleTemp.OriginalStartbyDate,
JobRelease.Jr_Released, Jobs.Jb_PO_Num
FROM (((SchedMachines LEFT JOIN (ScheduledOps LEFT JOIN ((Opstatus LEFT JOIN Jobs ON Opstatus.Os_JobNum = Jobs.Jb_Job_Num)
LEFT JOIN JobRelease ON (Opstatus.Os_ReleaseNum = JobRelease.Jr_ReleaseNum) And (Opstatus.Os_JobNum = JobRelease.Jr_JobNum)) ON ScheduledOps.SchO_OSId =Opstatus.Os_ID) ON SchedMachines.SchM_ID = ScheduledOps.SchO_SchMTID)
LEFT JOIN (
Select JobShip.Sh_Job_Num, CAST([Sh_Release_Num] As Int) As Rel, Min(JobShip.Sh_Due_Date) As MinOfSh_Due_Date, Max(JobShip.Sh_ID) As MaxOfSh_ID FROM JobShip WHERE (((JobShip.Sh_Qty_Shipped)=0 Or (JobShip.Sh_Qty_Shipped) Is Null))
GROUP BY JobShip.Sh_Job_Num, Cast([Sh_Release_Num] As Int)
) SchedFirstDueDateQry ON (JobRelease.Jr_JobNum = SchedFirstDueDateQry.Sh_Job_Num) And (JobRelease.Jr_ReleaseNum = SchedFirstDueDateQry.Rel))
LEFT JOIN JobShip ON SchedFirstDueDateQry.MaxOfSh_ID = JobShip.Sh_ID) --LEFT JOIN OpsByMachStatusCheckScheduleTemp ON (ScheduledOps.SchO_SchMTID = OpsByMachStatusCheckScheduleTemp.SchM_ID) And (ScheduledOps.SchO_Order = OpsByMachStatusCheckScheduleTemp.SchO_Order)
WHERE (((SchedMachines.SchM_WCCode) Like ?) AND ((SchedMachines.SchM_Group) Like '%') AND ((SchedMachines.SchM_Cell)=0)
And ((Opstatus.Os_Status)<>'C')) OR (((SchedMachines.SchM_WCCode) Like ?) AND ((SchedMachines.SchM_Group) Like '%') AND ((SchedMachines.SchM_Cell)=0) AND ((Opstatus.Os_Status) Is Null) AND ([SchO_ID] IS Not Null))
ORDER BY SchedMachines.SchM_Machine, ScheduledOps.SchO_Order,Opstatus.Os_StartbyDate,Opstatus.Os_JobNum,Opstatus.Os_ReleaseNum,Opstatus.Os_SeqNum;"$
Try
Dim SenderFilter As Object = Main.sql1.ExecQueryAsync("WCMachinesJobs", SQLStr, Li) '1/30/19 - Added SW57
'Log(SQLStr)
Wait For (SenderFilter) WCMachinesJobs_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
Dim zx As Int, TTTTT As Long = DateTime.Now 'for testing
If Success Then
Sleep(1)
Dim LV As ListView, P As B4XView
LV.Initialize("")
Dim TM As TextMetric
TM.Initialize
Do While Crsr.NextRow = True
P = MachinesMap.Get(Crsr.GetString("SchM_Machine"))
Dim T As TextArea, M As Map
DADMod.FillJobMap(Crsr, M, False)
T.Initialize("JobsTA")
T.Editable = False
LoadOpData(T, M)
TM = ScheduleMod.MeasureText(T.Text, fx.DefaultFont(15))
T.PrefWidth = TM.Width + 3dip ' add dips for the vert scrollbar so we don't get a vert scrollbar
T.PrefHeight = 50
LV = P.GetView(1)
LV.Items.Add(T)
M.Put("ListView", LV)
T.Tag = M
T.TooltipText = Crsr.GetInt("SchO_ID")
MoveMachine2.MakeDragSource(T, "MToMMoveS")
MoveMachine2.MakeDragTarget(T, "MToMMoveT")
zx=zx+1 'for testing
Loop
Log("Ops: " & ((DateTime.Now - TTTTT) / 1000) & " Seconds " & zx & " Records")
Sleep(1)
ResizeLists(MachinesFrm.RootPane.Width)
Loading = False
Else
Main.Msgbox.Show(LastException & CRLF & CRLF & SQLStr, "LoadJobs")
Log(SQLStr)
End If
Catch
Main.Msgbox.Show(LastException, "LoadJobs")
End Try
End Sub
Sub FillJobMap(Crsr As JdbcResultSet, M As Map, Update As Boolean)
If Not(M.IsInitialized) Then M.Initialize
M.Put("Type", "JobData")
M.Put("SchO_Order", Crsr.GetString("SchO_Order"))
M.Put("SchO_OSId", Crsr.GetString("SchO_OSId"))
M.Put("SchO_SchMTID", Crsr.GetString("SchM_ID"))
M.Put("SchO_ID", Crsr.GetString("SchO_ID"))
M.Put("SchM_Machine", Crsr.GetString("SchM_Machine"))
M.Put("SchM_HrsPerWk", Crsr.GetString("SchM_HrsPerWk"))
M.Put("SchM_ID", Crsr.GetLong("SchM_ID"))
If Update Then Return
M.Put("Os_JobNum", Crsr.GetString("Os_JobNum"))
M.Put("Os_ReleaseNum", Crsr.GetString("Os_ReleaseNum"))
M.Put("Os_SeqNum", Crsr.GetString("Os_SeqNum"))
M.Put("Os_StartbyDate", Crsr.GetString("Os_StartbyDate"))
M.Put("Os_FinishbyDate", Crsr.GetString("Os_FinishbyDate"))
M.Put("Os_WCCode", Crsr.GetString("Os_WCCode"))
M.Put("Os_ID", Crsr.GetLong("Os_ID"))
M.Put("Os_RunTime", Crsr.GetString("Os_RunTime"))
M.Put("Os_SetupTime", Crsr.GetString("Os_SetupTime"))
M.Put("Os_HoursTodate", Crsr.GetString("Os_HoursTodate"))
M.Put("Os_QtyToMake", Crsr.GetString("Os_QtyToMake"))
M.Put("Os_QtyTodate", Crsr.GetString("Os_QtyTodate"))
M.Put("Jb_Part_Num", Crsr.GetString("Jb_Part_Num"))
M.Put("Jb_Part_Rev", Crsr.GetString("Jb_Part_Rev"))
M.Put("Jb_Part_Desc", Crsr.GetString("Jb_Part_Desc"))
M.Put("Jr_FirstDueDate", Crsr.GetString("Jr_FirstDueDate"))
M.Put("BalHrs", Crsr.GetString("BalHrs"))
M.Put("Os_Description", Crsr.GetString("Os_Description"))
M.Put("Jr_Released", Crsr.GetInt("Jr_Released"))
M.Put("Jb_PO_Num", Crsr.GetString("Jb_PO_Num"))
End Sub
Sub LoadOpData(T As TextArea, M As Map)
T.Style = ";-fx-control-inner-background:rgba(95,158,160,.2)"
SB.Initialize
SB.Append(M.Get("Jb_Part_Num")).Append(CRLF).Append(M.Get("Os_JobNum")).Append(" Rel ").Append(M.Get("Os_ReleaseNum"))
SB.Append("Seq ").Append(M.Get("Os_SeqNum")).Append(CRLF).Append(M.Get("Os_StartbyDate")).Append(" Qty:").Append(M.Get("Os_QtyToMake"))
SB.Append(" Hr:").Append(M.Get("BalHrs")).Append(CRLF).Append(M.Get("Os_Description")).Append(CRLF).Append("NextDue:")
SB.Append(M.Get("Jr_FirstDueDate")).Append(CRLF)
If 1 = M.Get("Jr_Released") Then
'Log("Inside True")
SB.Append("HOT")
T.Style = ";-fx-control-inner-background:rgba(255,93,84,1)"
Else
'Log("Inside False")
SB.Append("PO:").Append(M.Get("Jb_PO_Num"))
End If
T.Text = SB.ToString
'Log("Jr_Released = " & M.Get("Jr_Released"))
End Sub