/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/mm/whkitting.aspx.vb
279 строк
10 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports System.Net Imports System.Data Imports System.IO Imports Newtonsoft.Json Partial Class mm_whkitting Inherits System.Web.UI.Page #Region "Page life cycle" Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load 'For Each c As Control In form1.Controls ' If TypeOf (c) Is Label Then ' CType(c, Label).Text = c.ID ' End If 'Next Dim line As String = Request.QueryString("l") If Not IsNothing(line) Then line = line.ToUpper Else line = "A" End If Title = "Line: " & line & ". WH Kitting" lblLine.Text = line curClock.Text = TimeOfDay.ToString("HH:mm:ss") 'GMES Data BindData(GetData(line)) Dim CurPo As TB_CATV_MAIN_LINE_DETAIL = GetCurPoDetailData(line) Dim NextPo As TB_CATV_MAIN_LINE_DETAIL = GetNextPoDetailData(CurPo) BindDetailData(CurPo, NextPo) ' WMS data Dim ltsReq As DataTable = Nothing Dim toList As DataTable = Nothing Dim f As Boolean = True 'Current PO If Not IsNothing(CurPo) Then ltsReq = GetLTSRequest(CurPo.Po, "R24") If Not IsNothing(ltsReq) Then For Each dr As DataRow In ltsReq.Rows lblCurMaterial.Text &= IIf(lblCurMaterial.Text = "", "", " / ") & dr("MATNR") Dim tempTOList As DataTable = GetTO(CurPo.Po, dr("MATNR")) If Not IsNothing(tempTOList) Then If f Then toList = tempTOList.Copy f = False Else For Each ddr As DataRow In tempTOList.Rows toList.ImportRow(ddr) Next End If End If Next Dim curPoGiQty As Integer = 0 If Not IsNothing(toList) Then If toList.Rows.Count > 0 Then Dim curPoGITo() As DataRow = toList.Select("LZNUM='" & CurPo.Po & "' AND KQUIT='X'") For Each dr In curPoGITo curPoGiQty += Convert.ToInt32(dr("VSOLA")) Next lblGi.Text = curPoGiQty lblRemain.Text = CurPo.Plan - curPoGiQty End If End If If Request.QueryString("details") = "c" Then GridView1.DataSource = ltsReq GridView2.DataSource = toList GridView1.DataBind() GridView2.DataBind() End If End If End If 'Next PO If Not IsNothing(NextPo) Then f = True toList = Nothing ltsReq = Nothing ltsReq = GetLTSRequest(NextPo.Po, "R24") If Not IsNothing(ltsReq) Then For Each dr As DataRow In ltsReq.Rows lblNextMaterial.Text &= IIf(lblNextMaterial.Text = "", "", " / ") & dr("MATNR") Dim tempTOList As DataTable = GetTO(NextPo.Po, dr("MATNR")) If Not IsNothing(tempTOList) Then If f Then toList = tempTOList.Copy f = False Else For Each ddr As DataRow In tempTOList.Rows toList.ImportRow(ddr) Next End If End If Next Dim nextPoGiQty As Integer = 0 Dim nextPoKittingQty As Integer = 0 If Not IsNothing(toList) Then If toList.Rows.Count > 0 Then Dim nextPoGITo() As DataRow = toList.Select("LZNUM='" & NextPo.Po & "' AND KQUIT='X'") For Each dr In nextPoGITo nextPoGiQty += Convert.ToInt32(dr("VSOLA")) Next lblNextLotGi.Text = nextPoGiQty Dim kittingZone() As DataRow = toList.Select("LZNUM='" & NextPo.Po & "' AND KQUIT=''") For Each dr In kittingZone nextPoKittingQty += Convert.ToInt32(dr("VSOLA")) Next lblKitting.Text = nextPoKittingQty End If End If If Request.QueryString("details") = "n" Then GridView1.DataSource = ltsReq GridView2.DataSource = toList GridView1.DataBind() GridView2.DataBind() End If End If End If End Sub Protected Sub Page_PreRenderComplete(sender As Object, e As System.EventArgs) Handles Me.PreRenderComplete End Sub #End Region #Region "Data" Dim catv As New catvDataContext Private Function GetData(line As String) As TB_COM_MAIN_LINE Try Dim q = From l In catv.TB_COM_MAIN_LINEs Where l.LINE = line Select l Return q.First Catch ex As Exception Return Nothing End Try End Function Private Function GetCurPoDetailData(line As String) As TB_CATV_MAIN_LINE_DETAIL Try Dim nowTime As String = TimeOfDay.ToString("HHmm") '"0730" ' Dim q = From l In catv.TB_CATV_MAIN_LINE_DETAILs Where l.Line = line And l.CURRENT_PROD = "X" Select l Try Return q.First Catch ex As Exception Dim qq = From ll In catv.TB_CATV_MAIN_LINE_DETAILs Where ll.Line = line And ll.Plan_start >= nowTime Select ll Return qq.First End Try Catch ex As Exception Return Nothing End Try End Function Private Function GetNextPoDetailData(curPo As TB_CATV_MAIN_LINE_DETAIL) As TB_CATV_MAIN_LINE_DETAIL Try Dim q = From l In catv.TB_CATV_MAIN_LINE_DETAILs Where l.Line = curPo.Line And l.Plan_start >= curPo.Plan_end Select l Return q.First Catch ex As Exception Return Nothing End Try End Function Private Function GetWorkingStatus(line As String) As TB_CATV_WORKING_STATUS_MAIN Dim q = From l In catv.TB_CATV_WORKING_STATUS_MAINs Where l.LINE = line Select l If q.Count > 0 Then Return q.First Else Return Nothing End If End Function Private Sub BindData(lineInfo As TB_COM_MAIN_LINE) If Not IsNothing(lineInfo) Then End If End Sub Private Sub BindDetailData(CurPo As TB_CATV_MAIN_LINE_DETAIL, NextPo As TB_CATV_MAIN_LINE_DETAIL) If Not IsNothing(CurPo) Then With CurPo lblStartTime.Text = formatTime(.Actual_start) lblEndTime.Text = formatTime(.Plan_end) lblPoNumber.Text = .Po lblModel.Text = .Model lblPLan.Text = .Plan lblResult.Text = .Prod End With If Not IsNothing(NextPo) Then With NextPo lblNextPo.Text = .Po & " / " & .Model & " / " & formatTime(.Plan_start) lblNextPlan.Text = .Plan End With Else lblNextPo.Text = "-" lblNextPlan.Text = "-" lblNextLotGi.Text = "-" lblNextMaterial.Text = "-" End If Else lblCurMaterial.Text = "-" lblGi.Text = "-" lblStartTime.Text = "-" lblEndTime.Text = "-" lblPoNumber.Text = "-" lblModel.Text = "-" lblPLan.Text = "-" lblResult.Text = "-" lblNextPo.Text = "-" lblNextPlan.Text = "-" lblNextLotGi.Text = "-" lblNextMaterial.Text = "-" End If End Sub #End Region #Region "WMS" Private Function GetLTSRequest(po As String, mrpc As String) As DataTable Try Dim url As String = "http://serkweb.serk.lan:8080/tools/Handlers/getwmsdata.ashx?fname=Z_RFC_LTS_REQ&format=json&po=" & _ po & "&mrp=" & mrpc Dim o As DataTable = Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(GetWMSData(url)) Return o Catch ex As Exception Return Nothing End Try End Function Private Function GetTO(po As String, material As String, Optional mvt As String = "261") As DataTable Try Dim url As String = "http://serkweb.serk.lan:8080/tools/Handlers/getwmsdata.ashx?fname=Z_RFC_TO_HEADER_ITEM&format=json&lznum=" & _ po & "&mvt=" & mvt & "&material=" & material Dim o As DataTable = Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(GetWMSData(url)) Return o Catch ex As Exception Return Nothing End Try End Function Private Function GetWMSData(url As String) As String Try Dim wb As WebRequest wb = WebRequest.Create(url) Dim res As WebResponse = wb.GetResponse Dim sr As New StreamReader(res.GetResponseStream) Return sr.ReadToEnd() Catch ex As Exception Return "" End Try End Function #End Region #Region "Etc" Private Function formatTime(t As String) As String If t.Length = 4 Then Return t.Substring(0, 2) & ":" & t.Substring(2, 2) Else Return t End If End Function #End Region End Class