Consolidate PC machinetypeid: all PCs use 33, pctypeid determines type

- Simplified GetMachineTypeIdFromPCType() to always return 33 (PC)
- PC type differentiation now handled entirely by pctypeid
- Updated savedevice.asp: 28 -> 33
- Updated savedevice_direct.asp: 36 -> 33, added pctypeid
- Removed redundant machinetypeid mapping logic (36-43)
- All 317 existing PCs already use machinetypeid=33

Schema simplified:
  machinetypeid=33 (PC) + pctypeid determines specific type
  pctypeid: 1=Standard, 2=Engineer, 3=Shopfloor, 5=CMM, etc.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-09 07:53:27 -05:00
parent adeff46d80
commit 53fd7e2214
3 changed files with 17 additions and 49 deletions

53
api.asp
View File

@@ -833,20 +833,19 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT
Dim pctypeId Dim pctypeId
pctypeId = GetPCTypeIdFromPCType(pcType) pctypeId = GetPCTypeIdFromPCType(pcType)
' Override types based on machinenumber pattern ' Override pctypeid based on machinenumber pattern
' WJPRT* = Wax Trace PC (machinetypeid 42, pctypeid 6) ' WJPRT* = Wax Trace PC (pctypeid 6)
If machinenumber <> "" Then If machinenumber <> "" Then
If UCase(Left(machinenumber, 5)) = "WJPRT" Then If UCase(Left(machinenumber, 5)) = "WJPRT" Then
machineTypeId = 42 ' PC - Wax Trace
pctypeId = 6 ' Wax / Trace pctypeId = 6 ' Wax / Trace
LogToFile "Detected WJPRT pattern in machinenumber, setting machineTypeId to 42, pctypeid to 6" LogToFile "Detected WJPRT pattern in machinenumber, setting pctypeid to 6 (Wax/Trace)"
End If End If
End If End If
' Ensure all IDs are numeric (fallback to safe defaults if empty) ' Ensure all IDs are numeric (fallback to safe defaults if empty)
If Not IsNumeric(vendorId) Or vendorId = "" Then vendorId = 0 If Not IsNumeric(vendorId) Or vendorId = "" Then vendorId = 0
If Not IsNumeric(modelId) Or modelId = "" Then modelId = 1 ' TBD model If Not IsNumeric(modelId) Or modelId = "" Then modelId = 1 ' TBD model
If Not IsNumeric(machineTypeId) Or machineTypeId = "" Then machineTypeId = 36 ' PC - Standard If Not IsNumeric(machineTypeId) Or machineTypeId = "" Then machineTypeId = 33 ' PC
If Not IsNumeric(pctypeId) Or pctypeId = "" Then pctypeId = 1 ' Standard If Not IsNumeric(pctypeId) Or pctypeId = "" Then pctypeId = 1 ' Standard
LogToFile "Vendor ID: " & vendorId & ", Model ID: " & modelId & ", Machine Type ID: " & machineTypeId & ", PC Type ID: " & pctypeId LogToFile "Vendor ID: " & vendorId & ", Model ID: " & modelId & ", Machine Type ID: " & machineTypeId & ", PC Type ID: " & pctypeId
@@ -1627,8 +1626,9 @@ End Function
' ============================================================================ ' ============================================================================
' LEGACY FUNCTION REMOVED: GetOrCreatePCType ' LEGACY FUNCTION REMOVED: GetOrCreatePCType
' This function was replaced by GetMachineTypeIdFromPCType which maps ' All PCs now use machinetypeid=33, with pctypeid determining the specific type
' PC type strings directly to machinetypeid (33=Standard, 34=Engineer, 35=Shopfloor) ' GetMachineTypeIdFromPCType returns 33 for all PCs
' GetPCTypeIdFromPCType maps pcType string to pctypeid (1=Standard, 2=Engineer, etc.)
' Removed: 2025-11-17 during Phase 2 migration from pc/pctype to machines/machinetypes ' Removed: 2025-11-17 during Phase 2 migration from pc/pctype to machines/machinetypes
' ============================================================================ ' ============================================================================
@@ -1853,41 +1853,10 @@ Function GetOrCreateAppVersion(conn, appId, appVersion)
End Function End Function
Function GetMachineTypeIdFromPCType(pcTypeString) Function GetMachineTypeIdFromPCType(pcTypeString)
On Error Resume Next ' All PCs use machinetypeid = 33 (PC)
' The specific PC type is determined by pctypeid, not machinetypeid
' Direct mapping from pcType parameter to machinetypeid (Phase 2 schema) GetMachineTypeIdFromPCType = 33
' Phase 2 PC Machine Types: LogToFile "All PCs use machinetypeid 33, pcType '" & pcTypeString & "' -> pctypeid handles type"
' 36=PC - Standard, 37=PC - Shopfloor, 38=PC - Engineer
' 41=PC - CMM, 42=PC - Wax Trace, 43=PC - Measuring Tool
Dim pcTypeClean
pcTypeClean = Trim(UCase(pcTypeString))
Select Case pcTypeClean
Case "ENGINEER", "ENGINEERING"
GetMachineTypeIdFromPCType = 38 ' PC - Engineer
Case "SHOPFLOOR", "SHOP FLOOR"
GetMachineTypeIdFromPCType = 37 ' PC - Shopfloor
Case "CMM"
GetMachineTypeIdFromPCType = 41 ' PC - CMM (runs PC-DMIS, goCMM, DODA)
Case "WAX TRACE", "WAXTRACE", "WAX"
GetMachineTypeIdFromPCType = 42 ' PC - Wax Trace (runs Formtracepak, FormStatusMonitor)
Case "KEYENCE"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - Keyence (runs Keyence VR Series)
Case "EAS1000", "GENSPECT"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - EAS1000/Genspect (runs GageCal, NI Software)
Case "PART MARKER", "PARTMARKER"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - Part Marker (0615 machines)
Case "MEASURING", "MEASURING TOOL"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool (generic)
Case "STANDARD", ""
GetMachineTypeIdFromPCType = 36 ' PC - Standard
Case Else
LogToFile "Unknown pcType '" & pcTypeString & "', defaulting to PC - Standard (36)"
GetMachineTypeIdFromPCType = 36 ' Default to PC - Standard
End Select
LogToFile "Mapped pcType '" & pcTypeString & "' to machinetypeid: " & GetMachineTypeIdFromPCType
End Function End Function
Function GetPCTypeIdFromPCType(pcTypeString) Function GetPCTypeIdFromPCType(pcTypeString)

View File

@@ -42,11 +42,10 @@
' modelnumberid = 1 (default model) ' modelnumberid = 1 (default model)
' requires_manual_machine_config = 0 (no manual config needed) ' requires_manual_machine_config = 0 (no manual config needed)
' osid = 1 (default OS) ' osid = 1 (default OS)
' machinetypeid = 28 (PC - Standard default) ' machinetypeid = 33 (PC), pctypeid = 1 (Standard)
' pctypeid = 1 (Standard PC type)
Dim insertSQL, recordsAffected Dim insertSQL, recordsAffected
insertSQL = "INSERT INTO machines (serialnumber, machinestatusid, isactive, modelnumberid, requires_manual_machine_config, osid, machinetypeid, pctypeid, lastupdated) " & _ insertSQL = "INSERT INTO machines (serialnumber, machinestatusid, isactive, modelnumberid, requires_manual_machine_config, osid, machinetypeid, pctypeid, lastupdated) " & _
"VALUES (?, 2, 1, 1, 0, 1, 28, 1, NOW())" "VALUES (?, 2, 1, 1, 0, 1, 33, 1, NOW())"
recordsAffected = ExecuteParameterizedInsert(objConn, insertSQL, Array(serialnumber)) recordsAffected = ExecuteParameterizedInsert(objConn, insertSQL, Array(serialnumber))

View File

@@ -3,7 +3,7 @@
' FILE: savedevice_direct.asp ' FILE: savedevice_direct.asp
' PURPOSE: Create new PC with minimal required fields (PC-only scanner) ' PURPOSE: Create new PC with minimal required fields (PC-only scanner)
' SECURITY: Parameterized queries, HTML encoding, input validation ' SECURITY: Parameterized queries, HTML encoding, input validation
' UPDATED: 2025-12-04 - Changed to PC-only (machinetypeid 36 = PC - Standard) ' UPDATED: 2025-12-09 - All PCs use machinetypeid 33, pctypeid determines type
'============================================================================= '=============================================================================
%> %>
<!--#include file="./includes/sql.asp"--> <!--#include file="./includes/sql.asp"-->
@@ -55,15 +55,15 @@
Set cmdCheck = Nothing Set cmdCheck = Nothing
' Insert new PC with minimal required fields - PHASE 2: Use machines table ' Insert new PC with minimal required fields - PHASE 2: Use machines table
' machinetypeid = 36 (PC - Standard) ' machinetypeid = 33 (PC), pctypeid = 1 (Standard)
' machinestatusid = 2 (Inventory) ' machinestatusid = 2 (Inventory)
' modelnumberid = 1 (default model) ' modelnumberid = 1 (default model)
' maptop = 1519, mapleft = 1896 (default map location) ' maptop = 1519, mapleft = 1896 (default map location)
' hostname = serialnumber (default) ' hostname = serialnumber (default)
' isactive = 1 ' isactive = 1
Dim insertSQL, cmdInsert Dim insertSQL, cmdInsert
insertSQL = "INSERT INTO machines (serialnumber, hostname, machinetypeid, machinestatusid, modelnumberid, maptop, mapleft, isactive, lastupdated) " & _ insertSQL = "INSERT INTO machines (serialnumber, hostname, machinetypeid, pctypeid, machinestatusid, modelnumberid, maptop, mapleft, isactive, lastupdated) " & _
"VALUES (?, ?, 36, 2, 1, 1519, 1896, 1, NOW())" "VALUES (?, ?, 33, 1, 2, 1, 1519, 1896, 1, NOW())"
Set cmdInsert = Server.CreateObject("ADODB.Command") Set cmdInsert = Server.CreateObject("ADODB.Command")
cmdInsert.ActiveConnection = objConn cmdInsert.ActiveConnection = objConn
cmdInsert.CommandText = insertSQL cmdInsert.CommandText = insertSQL