411 lines
19 KiB
Plaintext
411 lines
19 KiB
Plaintext
Compile function React_Item_Services(@Service, @Params)
|
|
/***********************************************************************************************************************
|
|
|
|
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
|
|
permission from SRP Computer Solutions, Inc.
|
|
|
|
Name : React_Item_Services
|
|
|
|
Description : Handler program for all module related services.
|
|
|
|
Notes : The generic parameters should contain all the necessary information to process the services. Often
|
|
this will be information like the data Record and Key ID.
|
|
|
|
Parameters :
|
|
Service [in] -- Name of the service being requested
|
|
Param1-10 [in/out] -- Additional request parameter holders
|
|
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
|
|
|
|
History : (Date, Initials, Notes)
|
|
08/02/22 djs Original programmer.
|
|
|
|
***********************************************************************************************************************/
|
|
|
|
#pragma precomp SRP_PreCompiler
|
|
|
|
$Insert LOGICAL
|
|
$Insert APP_INSERTS
|
|
$Insert RLIST_EQUATES
|
|
$Insert REACT_ITEM_EQUATES
|
|
|
|
Declare function Database_Services, Error_Services, SRP_JSON, NextKey
|
|
Declare subroutine SRP_JSON, Error_Services, Btree.Extract, Database_Services
|
|
GoToService
|
|
|
|
Return Response or ""
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// SERVICES
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
Service GetReactItems(RIType, CurrStatus)
|
|
|
|
ErrorMsg = ''
|
|
Response = ''
|
|
Swap ',' with @VM in RIType
|
|
Swap ',' with @VM in CurrStatus
|
|
|
|
Open 'DICT.REACT_ITEM' to DictReactItem then
|
|
|
|
SearchString = ''
|
|
If RIType NE '' then SearchString := 'RI_TYPE':@VM:RIType:@FM
|
|
If CurrStatus NE '' then SearchString := 'CURR_STATUS':@VM:CurrStatus:@FM
|
|
RIKeys = ''
|
|
Btree.Extract(SearchString, 'REACT_ITEM', DictReactItem, RIKeys, '', '')
|
|
ErrCode = ''
|
|
IF Get_Status(ErrCode) then
|
|
ErrorMsg = 'Error in ':Service:' service. Error calling Btree.Extract. Error code ':ErrCode:'.'
|
|
end else
|
|
Response = RIKeys
|
|
end
|
|
|
|
end else
|
|
ErrorMsg = 'Error in ':Service:' service. Error opening REACT_ITEM dictionary.'
|
|
end
|
|
|
|
If ErrorMsg NE '' then
|
|
Error_Services('Add', ErrorMsg)
|
|
end
|
|
|
|
End Service
|
|
|
|
|
|
Service ConvertRecordToJSON(KeyID, Record, ItemURL)
|
|
|
|
jsonRecord = ''
|
|
|
|
If KeyID NE '' then
|
|
|
|
If Record EQ '' then Record = Database_Services('ReadDataRow', 'REACT_ITEM', KeyID)
|
|
If Error_Services('NoError') then
|
|
@DICT = Database_Services('GetTableHandle', 'DICT.REACT_ITEM')
|
|
@ID = KeyID
|
|
@RECORD = Record
|
|
If SRP_JSON(objJSON, 'New', 'Object') then
|
|
|
|
If SRP_JSON(objReactItem, 'New', 'Object') then
|
|
SRP_JSON(objReactItem, 'SetValue', 'keyId', @ID)
|
|
SRP_JSON(objReactItem, 'SetValue', 'description', {DESC})
|
|
SRP_JSON(objReactItem, 'SetValue', 'retireDt', OConv({RETIRE_DT}, 'D4/'))
|
|
SRP_JSON(objReactItem, 'SetValue', 'partType', {PART_TYPE})
|
|
SRP_JSON(objReactItem, 'SetValue', 'mfrCd', {MFR_CD})
|
|
SRP_JSON(objReactItem, 'SetValue', 'mfrPartNo', {MFR_PART_NO})
|
|
SRP_JSON(objReactItem, 'SetValue', 'mfrPartNoRev', {MFR_PART_NO_REV})
|
|
SRP_JSON(objReactItem, 'SetValue', 'serialNo', {SERIAL_NO})
|
|
SRP_JSON(objReactItem, 'SetValue', 'riType', {RI_TYPE})
|
|
// Add available disposition codes
|
|
DispCodes = Xlate('SYSREPOSPOPUPS', 'LSL2**REACT_ITEM_DISP', 'DISPLAY', 'X')
|
|
If SRP_JSON(objReactItemDispArray, 'New', 'Array') then
|
|
For each DispCode in DispCodes using @VM setting vPos
|
|
If SRP_JSON(objDisp, 'New', 'Object') then
|
|
SRP_JSON(objDisp, 'SetValue', 'dispCode', DispCode<0, 0, 1>)
|
|
SRP_JSON(objDisp, 'SetValue', 'dispDesc', DispCode<0, 0, 2>)
|
|
end
|
|
SRP_JSON(objReactItemDispArray, 'Add', objDisp)
|
|
SRP_JSON(objDisp, 'Release')
|
|
Next DispCode
|
|
SRP_JSON(objReactItem, 'Set', 'dispCodes', objReactItemDispArray)
|
|
SRP_JSON(objReactItemDispArray, 'Release')
|
|
end
|
|
SRP_JSON(objJSON, 'Set', 'reactItem', objReactItem)
|
|
SRP_JSON(objReactItem, 'Release')
|
|
end
|
|
|
|
If itemURL NE '' then
|
|
// The itemURL was passed in so add HAL+JSON properties.
|
|
// Create the _links property and then all link objects needed for this resource.
|
|
If SRP_JSON(objLinks, 'New', 'Object') then
|
|
// Create a self link.
|
|
If SRP_JSON(objLink, 'New', 'Object') then
|
|
SRP_JSON(objLink, 'SetValue', 'href', ItemURL, 'String')
|
|
SRP_JSON(objLink, 'SetValue', 'title', 'Self', 'String')
|
|
SRP_JSON(objLinks, 'Set', 'self', objLink)
|
|
SRP_JSON(objLink, 'Release')
|
|
end
|
|
SRP_JSON(objJSON, 'Set', '_links', objLinks)
|
|
SRP_JSON(objLinks, 'Release')
|
|
end
|
|
|
|
// Create the _class property for this resource.
|
|
SRP_JSON(objJSON, 'SetValue', '_class', 'resource')
|
|
end
|
|
jsonRecord = SRP_JSON(objJSON, 'Stringify', 'Styled')
|
|
SRP_JSON(objJSON, 'Release')
|
|
end else
|
|
Error_Services('Add', 'Unable to create JSON representation in the ' : Service : ' service.')
|
|
end
|
|
end
|
|
end else
|
|
Error_Services('Add', 'KeyID argument was missing in the ' : Service : ' service.')
|
|
end
|
|
|
|
Response = jsonRecord
|
|
|
|
|
|
end service
|
|
|
|
|
|
Service ConvertJSONToRecord(JSON)
|
|
|
|
Record = ''
|
|
If JSON NE '' then
|
|
If SRP_JSON(objJSON, 'Parse', JSON) EQ '' then
|
|
objReactItem = SRP_JSON(objJSON, 'Get', 'reactItem')
|
|
KeyID = SRP_JSON(objReactItem, 'GetValue', 'keyId', '')
|
|
Record<REACT_ITEM_DESC$> = SRP_JSON(objReactItem, 'GetValue', 'description', '')
|
|
Record<REACT_ITEM_ENTER_BY$> = SRP_JSON(objReactItem, 'GetValue', 'enterBy', '')
|
|
Record<REACT_ITEM_ENTER_DTM$> = IConv(SRP_JSON(objReactItem, 'GetValue', 'enterDtm', ''), 'DT')
|
|
Record<REACT_ITEM_RETIRE_BY$> = SRP_JSON(objReactItem, 'GetValue', 'retireBy', '')
|
|
Record<REACT_ITEM_RETIRE_DT$> = IConv(SRP_JSON(objReactItem, 'GetValue', 'retireDt', ''), 'D')
|
|
Record<REACT_ITEM_PART_TYPE$> = SRP_JSON(objReactItem, 'GetValue', 'partType', '')
|
|
Record<REACT_ITEM_MFR_CD$> = SRP_JSON(objReactItem, 'GetValue', 'mfrCd', '')
|
|
Record<REACT_ITEM_MFR_PART_NO$> = SRP_JSON(objReactItem, 'GetValue', 'mfrPartNo', '')
|
|
Record<REACT_ITEM_MFR_PART_NO_REV$> = SRP_JSON(objReactItem, 'GetValue', 'mfrPartNoRev', '')
|
|
Record<REACT_ITEM_SERIAL_NO$> = SRP_JSON(objReactItem, 'GetValue', 'serialNo', '')
|
|
Record<REACT_ITEM_RI_TYPE$> = SRP_JSON(objReactItem, 'GetValue', 'riType', '')
|
|
Record<REACT_ITEM_SUSC_SIZE$> = SRP_JSON(objReactItem, 'GetValue', 'suscSize', '')
|
|
Record<REACT_ITEM_PKT_QTY$> = SRP_JSON(objReactItem, 'GetValue', 'pktQty', '')
|
|
Record<REACT_ITEM_PKT_SIZE$> = SRP_JSON(objReactItem, 'GetValue', 'pktSize', '')
|
|
Record<REACT_ITEM_NOTES$> = SRP_JSON(objReactItem, 'GetValue', 'notes', '')
|
|
Record<REACT_ITEM_PPLUS_RDS_NO$> = SRP_JSON(objReactItem, 'GetValue', 'pPlusRdsNo', '')
|
|
Record<REACT_ITEM_SERIAL$> = SRP_JSON(objReactItem, 'GetValue', 'serial', '')
|
|
Record<REACT_ITEM_TUBE_GRADE$> = SRP_JSON(objReactItem, 'GetValue', 'tubeGrade', '')
|
|
Record<REACT_ITEM_TUBE_PRESS$> = SRP_JSON(objReactItem, 'GetValue', 'tubePress', '')
|
|
Record<REACT_ITEM_TUBE_STYLE$> = SRP_JSON(objReactItem, 'GetValue', 'tubeStyle', '')
|
|
SRP_JSON(objReactItem, 'Release')
|
|
SRP_JSON(objJSON, 'Release')
|
|
end else
|
|
Error_Services('Add', 'Error in ':Service:' service. Unable to parse JSON payload.')
|
|
end
|
|
end else
|
|
Error_Services('Add', 'Error in ':Service:' service. Null JSON passed in.')
|
|
end
|
|
|
|
Response = Record
|
|
|
|
end service
|
|
|
|
|
|
Service GetReactItemTemplateJSON()
|
|
|
|
jsonRecord = ''
|
|
|
|
If SRP_JSON(objJSON, 'New', 'Object') then
|
|
|
|
If SRP_JSON(objReactItem, 'New', 'Object') then
|
|
SRP_JSON(objReactItem, 'SetValue', 'description', '')
|
|
SRP_JSON(objReactItem, 'SetValue', 'retireDt', '')
|
|
|
|
PartTypes = Xlate('SYSREPOSPOPUPS', 'LSL2**RI_PART_TYPE', 'DISPLAY', 'X')
|
|
If SRP_JSON(objPartTypeArray, 'New', 'Array') then
|
|
For each PartType in PartTypes using @VM
|
|
If SRP_JSON(objPartType, 'New', 'Object') then
|
|
SRP_JSON(objPartType, 'SetValue', 'code', PartType<0, 0, 1>)
|
|
SRP_JSON(objPartType, 'SetValue', 'description', PartType<0, 0, 2>)
|
|
SRP_JSON(objPartTypeArray, 'Add', objPartType)
|
|
SRP_JSON(objPartType, 'Release')
|
|
end
|
|
Next RIType
|
|
SRP_JSON(objReactItem, 'Set', 'partTypeOptions', objPartTypeArray)
|
|
SRP_JSON(objPartTypeArray, 'Release')
|
|
end
|
|
|
|
SRP_JSON(objReactItem, 'SetValue', 'mfrCd', '')
|
|
SRP_JSON(objReactItem, 'SetValue', 'mfrPartNo', '')
|
|
SRP_JSON(objReactItem, 'SetValue', 'mfrPartNoRev', '')
|
|
SRP_JSON(objReactItem, 'SetValue', 'serialNo', '')
|
|
|
|
SuscPockets = Xlate('SYSREPOSPOPUPS', 'LSL2**SUSCEPTOR_POCKETS', 'DISPLAY', 'X')
|
|
If SRP_JSON(objSuscPocketsArray, 'New', 'Array') then
|
|
For each SuscPocket in SuscPockets using @VM
|
|
If SRP_JSON(objSuscPocket, 'New', 'Object') then
|
|
SRP_JSON(objSuscPocket, 'SetValue', 'numPockets', SuscPocket<0, 0, 1>)
|
|
SRP_JSON(objSuscPocket, 'SetValue', 'reactTypeCode', SuscPocket<0, 0, 2>)
|
|
SRP_JSON(objSuscPocket, 'SetValue', 'reactTypeDesc', SuscPocket<0, 0, 3>)
|
|
SRP_JSON(objSuscPocketsArray, 'Add', objSuscPocket)
|
|
SRP_JSON(objSuscPocket, 'Release')
|
|
end
|
|
Next SuscPocket
|
|
SRP_JSON(objReactItem, 'Set', 'pktQtyOptions', objSuscPocketsArray)
|
|
SRP_JSON(objSuscPocketsArray, 'Release')
|
|
end
|
|
|
|
RITypes = Xlate('SYSREPOSPOPUPS', 'LSL2**REACT_ITEM_TYPE', 'DISPLAY', 'X')
|
|
If SRP_JSON(objRITypeArray, 'New', 'Array') then
|
|
For each RIType in RITypes using @VM
|
|
If SRP_JSON(objRIType, 'New', 'Object') then
|
|
SRP_JSON(objRIType, 'SetValue', 'code', RIType<0, 0, 1>)
|
|
SRP_JSON(objRIType, 'SetValue', 'description', RIType<0, 0, 2>)
|
|
SRP_JSON(objRITypeArray, 'Add', objRIType)
|
|
SRP_JSON(objRIType, 'Release')
|
|
end
|
|
Next RIType
|
|
SRP_JSON(objReactItem, 'Set', 'riTypeOptions', objRITypeArray)
|
|
SRP_JSON(objRITypeArray, 'Release')
|
|
end
|
|
|
|
TubeStyles = Xlate('SYSREPOSPOPUPS', 'LSL2**TUBE_STYLE', 'DISPLAY', 'X')
|
|
If SRP_JSON(objTubeStylesArray, 'New', 'Array') then
|
|
For each TubeStyle in TubeStyles using @VM
|
|
If SRP_JSON(objTubeStyle, 'New', 'Object') then
|
|
SRP_JSON(objTubeStyle, 'SetValue', 'code', TubeStyle<0, 0, 1>)
|
|
SRP_JSON(objTubeStyle, 'SetValue', 'description', TubeStyle<0, 0, 2>)
|
|
SRP_JSON(objTubeStylesArray, 'Add', objTubeStyle)
|
|
SRP_JSON(objTubeStyle, 'Release')
|
|
end
|
|
Next TubeStyle
|
|
SRP_JSON(objReactItem, 'Set', 'tubeStyleOptions', objTubeStylesArray)
|
|
SRP_JSON(objTubeStylesArray, 'Release')
|
|
end
|
|
|
|
Vendors = Xlate('SYSREPOSPOPUPS', 'LSL2**REACT_VENDOR', 'DISPLAY', 'X')
|
|
If SRP_JSON(objVendorsArray, 'New', 'Array') then
|
|
For each Vendor in Vendors using @VM
|
|
If SRP_JSON(objVendor, 'New', 'Object') then
|
|
SRP_JSON(objVendor, 'SetValue', 'code', Vendor<0, 0, 1>)
|
|
SRP_JSON(objVendor, 'SetValue', 'description', Vendor<0, 0, 2>)
|
|
SRP_JSON(objVendorsArray, 'Add', objVendor)
|
|
SRP_JSON(objVendor, 'Release')
|
|
end
|
|
Next Vendor
|
|
SRP_JSON(objReactItem, 'Set', 'mfrCdOptions', objVendorsArray)
|
|
SRP_JSON(objVendorsArray, 'Release')
|
|
end
|
|
|
|
WaferSizes = Xlate('SYSREPOSPOPUPS', 'LSL2**WAFER_SIZES', 'DISPLAY', 'X')
|
|
If SRP_JSON(objWaferSizesArray, 'New', 'Array') then
|
|
For each WaferSize in WaferSizes using @VM
|
|
If SRP_JSON(objWaferSize, 'New', 'Object') then
|
|
SRP_JSON(objWaferSize, 'SetValue', 'code', WaferSize<0, 0, 1>)
|
|
SRP_JSON(objWaferSize, 'SetValue', 'description', WaferSize<0, 0, 2>)
|
|
SRP_JSON(objWaferSizesArray, 'Add', objWaferSize)
|
|
SRP_JSON(objWaferSize, 'Release')
|
|
end
|
|
Next WaferSize
|
|
SRP_JSON(objReactItem, 'Set', 'ptySizeOptions', objWaferSizesArray)
|
|
SRP_JSON(objWaferSizesArray, 'Release')
|
|
end
|
|
|
|
WaferSizes = Xlate('SYSREPOSPOPUPS', 'LSL2**WAFER_SIZES', 'DISPLAY', 'X')
|
|
If SRP_JSON(objWaferSizesArray, 'New', 'Array') then
|
|
For each WaferSize in WaferSizes using @VM
|
|
If SRP_JSON(objWaferSize, 'New', 'Object') then
|
|
SRP_JSON(objWaferSize, 'SetValue', 'code', WaferSize<0, 0, 1>)
|
|
SRP_JSON(objWaferSize, 'SetValue', 'description', WaferSize<0, 0, 2>)
|
|
SRP_JSON(objWaferSizesArray, 'Add', objWaferSize)
|
|
SRP_JSON(objWaferSize, 'Release')
|
|
end
|
|
Next WaferSize
|
|
SRP_JSON(objReactItem, 'Set', 'suscSizeOptions', objWaferSizesArray)
|
|
SRP_JSON(objWaferSizesArray, 'Release')
|
|
end
|
|
|
|
SRP_JSON(objJSON, 'Set', 'reactItem', objReactItem)
|
|
SRP_JSON(objReactItem, 'Release')
|
|
end
|
|
|
|
jsonRecord = SRP_JSON(objJSON, 'Stringify', 'Styled')
|
|
SRP_JSON(objJSON, 'Release')
|
|
end else
|
|
Error_Services('Add', 'Unable to create JSON representation in the ' : Service : ' service.')
|
|
end
|
|
|
|
Response = jsonRecord
|
|
|
|
|
|
end service
|
|
|
|
|
|
Service CreateReactItem(Record)
|
|
ErrMsg = ''
|
|
KeyID = ''
|
|
If Record NE '' then
|
|
//Need to do some parameter checks here
|
|
ReactItemType = Record<REACT_ITEM_RI_TYPE$>
|
|
If ReactItemType EQ '' then
|
|
ErrMsg := 'React Item Type was blank!' : CRLF$
|
|
end
|
|
If ErrMsg EQ '' then
|
|
KeyID = NextKey('REACT_ITEM')
|
|
If Error_Services('NoError') and KeyID NE '' then
|
|
Database_Services('WriteDataRow', 'REACT_ITEM', KeyID, Record)
|
|
end else
|
|
ErrMsg := 'Failed to generate a key for a new react item. ' : CRLF$
|
|
end
|
|
end
|
|
end
|
|
If ErrMsg NE '' then
|
|
Error_Services('Add', Errmsg)
|
|
end
|
|
Response = KeyID
|
|
|
|
end service
|
|
|
|
Service ConvertRecordToJSONQuick(KeyID, Record, ItemURL)
|
|
|
|
jsonRecord = ''
|
|
|
|
If KeyID NE '' then
|
|
|
|
If Record EQ '' then Record = Database_Services('ReadDataRow', 'REACT_ITEM', KeyID)
|
|
If Error_Services('NoError') then
|
|
@DICT = Database_Services('GetTableHandle', 'DICT.REACT_ITEM')
|
|
@ID = KeyID
|
|
@RECORD = Record
|
|
If SRP_JSON(objJSON, 'New', 'Object') then
|
|
|
|
If SRP_JSON(objReactItem, 'New', 'Object') then
|
|
SRP_JSON(objReactItem, 'SetValue', 'keyId', @ID)
|
|
SRP_JSON(objReactItem, 'SetValue', 'description', {DESC})
|
|
SRP_JSON(objReactItem, 'SetValue', 'serialNo', {SERIAL_NO})
|
|
SRP_JSON(objJSON, 'Set', 'reactItem', objReactItem)
|
|
SRP_JSON(objReactItem, 'Release')
|
|
end
|
|
|
|
If itemURL NE '' then
|
|
// The itemURL was passed in so add HAL+JSON properties.
|
|
// Create the _links property and then all link objects needed for this resource.
|
|
If SRP_JSON(objLinks, 'New', 'Object') then
|
|
// Create a self link.
|
|
If SRP_JSON(objLink, 'New', 'Object') then
|
|
SRP_JSON(objLink, 'SetValue', 'href', ItemURL, 'String')
|
|
SRP_JSON(objLink, 'SetValue', 'title', 'Self', 'String')
|
|
SRP_JSON(objLinks, 'Set', 'self', objLink)
|
|
SRP_JSON(objLink, 'Release')
|
|
end
|
|
SRP_JSON(objJSON, 'Set', '_links', objLinks)
|
|
SRP_JSON(objLinks, 'Release')
|
|
end
|
|
|
|
// Create the _class property for this resource.
|
|
SRP_JSON(objJSON, 'SetValue', '_class', 'resource')
|
|
end
|
|
jsonRecord = SRP_JSON(objJSON, 'Stringify', 'Styled')
|
|
SRP_JSON(objJSON, 'Release')
|
|
end else
|
|
Error_Services('Add', 'Unable to create JSON representation in the ' : Service : ' service.')
|
|
end
|
|
end
|
|
end else
|
|
Error_Services('Add', 'KeyID argument was missing in the ' : Service : ' service.')
|
|
end
|
|
|
|
Response = jsonRecord
|
|
|
|
end service
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Internal GoSubs
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
ClearCursors:
|
|
|
|
For counter = 0 to 8
|
|
ClearSelect counter
|
|
Next counter
|
|
|
|
return
|
|
|
|
|
|
|