Histórico da Página
...
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "protheus.ch" #include "apcfg021.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.materiais //------------------------------------------------------------------- /*{Protheus.doc} MATR190TReportsBusinessObject Classe para criação do Objeto de Negócio de Prod x Forn para o Smart View @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SA5", name="Produto X Fornecedor", country="ALL", initialRelease="12.1.2210") class MATR190TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getDisplayName() as character public method getDescription() as character public method getData() as object public method getSchema() as object protected data aFields as array protected data aStruct as array protected data cQuery as character protected data cWhere as character protected data jItems as json endclass //------------------------------------------------------------------- /*{Protheus.doc} new Método de instância da classe @return object: self @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method new() class MATR190TReportsBusinessObject _Super:new() self:appendArea("Compras") self:aFields := {"A5_LOJA", "A5_NOMEFOR", "A5_PRODUTO"} return self //------------------------------------------------------------------- /*{Protheus.doc} getDisplayName Retorna o nome de exibição do objeto de negócio @return string @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getDisplayName() as character class MATR190TReportsBusinessObject return "Produtos x Fornecedores - Localizado" //------------------------------------------------------------------- /*{Protheus.doc} getDescription Retorna a descrição do objeto de negócio @return string @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getDescription() as character class MATR190TReportsBusinessObject return "Produtos x Fornecedores" //------------------------------------------------------------------- /*{Protheus.doc} getData Retorna os dados do objeto de negócio @param nPage, numérico, indica a página atual do relatório @param oFilter, objeto, contém o filtro do Smart View @return object: self:oData @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getData(nPage as numeric, oFilter as object) as object class MATR190TReportsBusinessObject local cAlias as character local nSkip as numeric local nCount as numeric local nX as numeric local aPDFields as array local cFieldsQry as character local oExec as object nCount := 0 cFieldsQry := ArrTokStr(self:aFields, ",") self:cQuery := "SELECT " self:cQuery += cFieldsQry self:cQuery += " FROM " + RetSQLName("SA5") if !empty(self:cWhere) self:cQuery += self:cWhere //Where que foi populado no objeto localizado endif //Os filtros serão setados na interface do novo Smart View if oFilter:hasFilter() self:cQuery += " AND " + oFilter:getSQLExpression() endif oExec cAlias := MPSysOpenQueryFwExecStatement(self):New(ChangeQuery(cQuery)) cAlias if nPage == 1 (cAlias)->(dbGoTop()) else:= oExec:OpenAlias() if nPage > 1 //Encontra a quantidade de itens que irá pular de acordo com a página atual nSkip := ((nPage - 1) * self:getPageSize()) (cAlias)->(dbSkip(nSkip)) endif //Verifica se precisa fazer o tratamento para LGPD aPDFields := FwProtectedDataUtil():UsrAccessPDField(__cUserID, self:aFields) lObfuscated := len( aPDFields ) != Len(self:aFields) while !(cAlias)->(Eof()) self:jItems := JsonObject():new() for nX := 1 To Len(self:aStruct) if lObfuscated .and. aScan(aPDFields, self:aStruct[nX][5]) == 0 self:jItems[self:aStruct[nX][1]] := FwProtectedDataUtil():ValueAsteriskToAnonymize((cAlias)->&(self:aStruct[nX][5])) else self:jItems[self:aStruct[nX][1]] := (cAlias)->&(self:aStruct[nX][5]) endif next nX self:processData() self:oData:appendData(self:jItems) (cAlias)->(DBSkip()) nCount++ //Sai do loop quando chegar no tamanho de itens da página if nCount == self:getPageSize() exit endif enddo //Se não for o último registro indica que terá próxima página self:setHasNext(!(cAlias)->(Eof())) (cAlias)->(DBCloseArea()) return self:oData //------------------------------------------------------------------- /*{Protheus.doc} getSchema Retorna a estrutura dos campos @return object: self:oSchema @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getSchema() as object class MATR190TReportsBusinessObject Local nX as numeric self:aStruct := getStruct(self:aFields) for nX := 1 To Len(self:aStruct) self:addProperty(self:aStruct[nX][1], self:aStruct[nX][2], self:aStruct[nX][3], self:aStruct[nX][4], self:aStruct[nX][5]) Next nX return self:oSchema //------------------------------------------------------------------- /*{Protheus.doc} getStruct Prepara a estrutura dos campos @param aCpos array: Array com os campos do relatório @return array: Array com a estrutura dos campos @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- function getStruct(aCpos) Local aDeParaCpo as array Local aCpoTmp as array Local cCampo as character Local cCpoQry as character Local cTipR as character Local nPos as numeric Local nC as numeric aDeParaCpo := {{"C", "string"}, {"D", "date"}, {"N", "number"}, {"L", "boolean"}} aCpoTmp := {} for nC := 1 to Len(aCpos) cCpoQry := aCpos[nC] nPos := AT(".", aCpos[nC]) + 1 if nPos > 0 cCampo := Substr(cCpoQry, nPos) else cCampo := cCpoQry endif cTipo := GetSx3Cache(cCampo, "X3_TIPO") if (nPos := aScan(aDeParaCpo, {|c| c[01] = cTipo})) > 0 cTipR := aDeParaCpo[nPos, 02] else cTipR := "string" endif AAdd(aCpoTmp, {strTran(cCampo, "_", ""), FWSX3Util():GetDescription(cCampo), cTipR, FWSX3Util():GetDescription(cCampo), cCampo}) next nC return (aCpoTmp) |
...
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "protheus.ch" #include "msobject.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.produtos.fornecedores //active virá como .T. pois esse objeto é exclusivo para o Brasil @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SA5", name="Produto X Fornecedor", country="BRA", initialRelease="12.1.2210") //------------------------------------------------------------------- /*{Protheus.doc} ProdFornTReportsBusinessObjectBRA Classe para criação do Objeto de Negócio de Prod x Forn para o Smart View Localizado BRA @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- class ProdFornTReportsBusinessObjectBRA from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getData() as object public method getSchema() as object protected data aFields as array protected data aStruct as array endclass //------------------------------------------------------------------- /*{Protheus.doc} new Método de instância da classe @return object: self @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method new() class ProdFornTReportsBusinessObjectBRA _Super:new() self:appendArea("Compras") self:setDisplayName("Fornecedores x Produtos") self:setDescription("Relatório Fornecedores x Produtos com tratamento LGPD") self:aFields := {"A5_FILIAL", "A5_FORNECE", "A5_LOJA", "A5_NOMEFOR", "A5_PRODUTO", "A5_NOMPROD", "A5_CODPRF"} self:aStruct := getStruct(self:aFields) return self //------------------------------------------------------------------- /*{Protheus.doc} getData Retorna os dados do objeto de negócio @param nPage, numérico, indica a página atual do relatório @param oFilter, objeto, contém o filtro do Smart View @return object: self:oData @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getData(nPage as numeric, oFilter as object) as object class ProdFornTReportsBusinessObjectBRA local cQuery as character local cAlias as character local nSkip as numeric local nCount as numeric local nX as numeric local jItems as json local aPDFields as array local oExec as object nCount := 0 cQuery := "SELECT A5_FILIAL,A5_PRODUTO,A5_NOMPROD,A5_FORNECE,A5_NOMEFOR,A5_LOJA,A5_CODPRF FROM " + RetSQLName("SA5") + " WHERE D_E_L_E_T_ = ' '" //Os filtros serão setados na interface do novo Smart View if oFilter:hasFilter() cQuery += " AND " + oFilter:getSQLExpression() endif oExec := FwExecStatement():New(ChangeQuery(cQuery)) cAlias := MPSysOpenQueryoExec:OpenAlias(cQuery) if nPage ==> 1 (cAlias)->(dbGoTop()) else //Encontra a quantidade de itens que irá pular de acordo com a página atual nSkip := ((nPage - 1) * self:getPageSize()) (cAlias)->(dbSkip(nSkip)) endif //Verifica se precisa fazer o tratamento para LGPD aPDFields := FwProtectedDataUtil():UsrAccessPDField(__cUserID, self:aFields) lObfuscated := len( aPDFields ) != Len(self:aFields) while !(cAlias)->(Eof()) jItems := JsonObject():new() for nX := 1 To Len(self:aStruct) if lObfuscated .and. aScan(aPDFields, self:aStruct[nX][5]) == 0 jItems[self:aStruct[nX][1]] := FwProtectedDataUtil():ValueAsteriskToAnonymize((cAlias)->&(self:aStruct[nX][5])) else jItems[self:aStruct[nX][1]] := (cAlias)->&(self:aStruct[nX][5]) endif next nX self:oData:appendData(jItems) (cAlias)->(DBSkip()) nCount++ //Sai do loop quando chegar no tamanho de itens da página if nCount == self:getPageSize() exit endif enddo //Se não for o último registro indica que terá próxima página self:setHasNext(!(cAlias)->(Eof())) (cAlias)->(DBCloseArea()) return self:oData //------------------------------------------------------------------- /*{Protheus.doc} getSchema Retorna a estrutura dos campos @return object: self:oSchema @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getSchema() as object class ProdFornTReportsBusinessObjectBRA Local nX as numeric for nX := 1 To Len(self:aStruct) self:addProperty(self:aStruct[nX][1], self:aStruct[nX][2], self:aStruct[nX][3], self:aStruct[nX][4], self:aStruct[nX][5]) Next nX return self:oSchema //------------------------------------------------------------------- /*{Protheus.doc} getStruct Prepara a estrutura dos campos @param aFlds array: Array com os campos do relatório @return array: Array com a estrutura dos campos @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- function getStruct(aFlds) Local aConvFld as array Local aFldTmp as array Local cCampo as character Local cFldQry as character Local cTipR as character Local nPos as numeric Local nC as numeric aConvFld := {{"C", "string"}, {"D", "date"}, {"N", "number"}, {"L", "boolean"}, {"M", "memo"}} aFldTmp := {} for nC := 1 to Len(aFlds) cFldQry := aFlds[nC] nPos := AT(".", aFlds[nC]) + 1 if nPos > 0 cCampo := Substr(cFldQry, nPos) else cCampo := cFldQry endif cTipo := GetSx3Cache(cCampo, "X3_TIPO") if (nPos := aScan(aConvFld, {|c| c[01] = cTipo})) > 0 cTipR := aConvFld[nPos, 02] else cTipR := "string" endif AAdd(aFldTmp, {cCampo, FWSX3Util():GetDescription(cCampo), cTipR, FWSX3Util():GetDescription(cCampo), cCampo}) next nC return (aFldTmp) |
...
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas