diff --git a/process/AISalesproject_lib/AISalesproject_lib.aod b/process/AISalesproject_lib/AISalesproject_lib.aod index c109e9524b9ff27dffb007486cdb1091ef22e50c..13b8a275db57d71b190f905695f39072a7756756 100644 --- a/process/AISalesproject_lib/AISalesproject_lib.aod +++ b/process/AISalesproject_lib/AISalesproject_lib.aod @@ -3,6 +3,7 @@ <name>AISalesproject_lib</name> <majorModelMode>DISTRIBUTED</majorModelMode> <process>%aditoprj%/process/AISalesproject_lib/process.js</process> + <alias>Data_alias</alias> <variants> <element>LIBRARY</element> </variants> diff --git a/process/AISalesproject_lib/process.js b/process/AISalesproject_lib/process.js index 0521bd2d9eb7229a5ded416377bd708fb15145dc..c1a63392f2bfc2786c2e3e79c4f38146e11f990d 100644 --- a/process/AISalesproject_lib/process.js +++ b/process/AISalesproject_lib/process.js @@ -48,12 +48,30 @@ AISalesprojectUtil.train = function () attributes.push(spRow["PHASE"]) //PHASE if(spRow["VOLUME"] != null && parseFloat(spRow["VOLUME"]) > 0) attributes.push(AISalesprojectUtil.getVolumeClassification(parseFloat(spRow["VOLUME"]))); //VOLUME - if(spRow["PROBABILITY"] != null) + if(spRow["PROBABILITY"] != null) attributes.push(AISalesprojectUtil.getProbabilityValue(spRow["PROBABILITY"])); //PROBABILITY var sectorSP = new AttributeRelationQuery(spRow["CONTACT_ID"], $AttributeRegistry.industry()).getSingleAttributeValue(); if(sectorSP != null) attributes.push(sectorSP); //Sector var doc = new NBDocument(spRow["#UID"], attributes); + + //Classification + + //Department + var department = AISalesprojectUtil.getClassificationValues("SALESPROJ", "Salesproject", spRow["#UID"], "ScoreDepartment"); + if(department) + attributes.push(department); + + //Standard + var standard = AISalesprojectUtil.getClassificationValues("SALESPROJ", "Salesproject", spRow["#UID"], "ScoreStandard"); + if(standard) + attributes.push(standard); + + //Users + var users = AISalesprojectUtil.getClassificationValues("SALESPROJ", "Salesproject", spRow["#UID"], "ScoreUsers"); + if(users) + attributes.push(users); + var loadCompConfig = entities.createConfigForLoadingRows() .entity("Competition_entity") @@ -67,7 +85,9 @@ AISalesprojectUtil.train = function () doc.add(compRow["ORGANISATION_NAME"]); //competitors }); - data.add(spRow["STATUS"], [doc]); // train model with lost and order salesprojects + data.add(spRow["STATUS"], [doc]); // train model with lost and order salesprojects + //logging.log("data:"); + //logging.log(JSON.stringify(doc)); } }); @@ -105,7 +125,25 @@ AISalesprojectUtil.classify = function (pSalesprojectId, pContactId, pPhase, pSt var sectorSP = new AttributeRelationQuery(pContactId, $AttributeRegistry.industry()).getSingleAttributeValue(); if(sectorSP != null) testAttributes.push(sectorSP); //Sector - } + } + + //Classification + + //Department + var department = AISalesprojectUtil.getClassificationValues("SALESPROJ", "Salesproject", pSalesprojectId, "ScoreDepartment"); + if(department) + testAttributes.push(department); + + //Standard + var standard = AISalesprojectUtil.getClassificationValues("SALESPROJ", "Salesproject", pSalesprojectId, "ScoreStandard"); + if(standard) + testAttributes.push(standard); + + //Users + var users = AISalesprojectUtil.getClassificationValues("SALESPROJ", "Salesproject", pSalesprojectId, "ScoreUsers"); + if(users) + testAttributes.push(users); + var loadCompConfig = entities.createConfigForLoadingRows() .entity("Competition_entity") .provider("Links") @@ -154,4 +192,19 @@ AISalesprojectUtil.getProbabilityValue = function (pProbId) else if(pProbId == "SALPROJPROB75" || pProbId == "SALPROJPROB100") return "positive"; return ""; -}; \ No newline at end of file +}; + +AISalesprojectUtil.getClassificationValues = function (pClassificationType, pObjectType, pObjectRowid, pScoreType) +{ + var value = newSelect("TITLE") + .from("CLASSIFICATIONTYPE") + .leftJoin("CLASSIFICATION", newWhere("CLASSIFICATIONTYPEID = CLASSIFICATIONTYPE_ID") + .and("CLASSIFICATION.OBJECT_TYPE", pObjectType) + .and("CLASSIFICATION.OBJECT_ROWID", pObjectRowid)) + .leftJoin("CLASSIFICATIONSCORE", "CLASSIFICATIONSCORE_ID = CLASSIFICATIONSCOREID") + .where("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", pClassificationType) + .andIfSet("CLASSIFICATIONTYPE.SCORETYPE", pScoreType) + .cell() + + return value; +};