susee
This commit is contained in:
parent
b03096711f
commit
a020148fe8
@ -17,111 +17,3 @@ exports.Welcome = (req, res) =>
|
||||
}); } //end of try catch
|
||||
|
||||
};
|
||||
|
||||
|
||||
exports.json = (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
PolicyParameterMaster.findAll({ where : { id : 48}})
|
||||
.then(data=>
|
||||
{
|
||||
const resP = JSON.parse(data[0].rules)
|
||||
pro_type = 'Residential';
|
||||
pro_val = 'Rented';
|
||||
const { Engine } = require('json-rules-engine')
|
||||
let engine = new Engine()
|
||||
engine.addRule({
|
||||
conditions: {
|
||||
any: [{
|
||||
all: [{
|
||||
fact: 'prop_type' ,
|
||||
operator: 'in',
|
||||
value : Object.keys(resP)
|
||||
}, {
|
||||
fact: 'prop_val' ,
|
||||
operator: 'in',
|
||||
value: Object.keys(resP[pro_type])
|
||||
}]
|
||||
}]
|
||||
},
|
||||
event: {
|
||||
type: 'Norms',
|
||||
params: {
|
||||
message: resP.Residential.Rented
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
let facts = { prop_type: pro_type , prop_val: pro_val }
|
||||
// Run the engine to evaluate
|
||||
engine.run(facts)
|
||||
.then(({ events }) =>
|
||||
{
|
||||
events.map(event => console.log(event.params.message))
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
.catch(err=> { res.send(err)})
|
||||
} catch(err) {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||
}); } //end of try catch
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exports.excel = async ( req , res ) => {
|
||||
// Requiring the module
|
||||
const reader = require('xlsx')
|
||||
|
||||
// Reading our test file
|
||||
const file = reader.readFile('./cr_policy.xlsx')
|
||||
|
||||
let data = [ ]
|
||||
var obj = { };
|
||||
|
||||
const sheets = file.SheetNames[3]
|
||||
console.log(sheets);
|
||||
for(let i = 0; i < sheets.length; i++)
|
||||
{
|
||||
const temp = reader.utils.sheet_to_json(file.Sheets[file.SheetNames[3]])
|
||||
|
||||
temp.forEach((res) => {
|
||||
// var key = Object.values(res);
|
||||
// var obj = {}
|
||||
// obj = {
|
||||
// property_ownership_document_available : key[0],
|
||||
// type_of_property : key[1],
|
||||
// property_used_in_business : key[2],
|
||||
// property_free_loan_taken : key[3],
|
||||
// property_in_the_name_of_applicant : key[4],
|
||||
// loan_obligated_in_cet : key[5],
|
||||
// property_created_in_last_eight_yr : key[6],
|
||||
// value_to_be_considered : key[7],
|
||||
// mv_to_be_added_to_atnw : key[8] * 100,
|
||||
// final_value_considered : key[9]
|
||||
// }
|
||||
data.push(res)
|
||||
})
|
||||
}
|
||||
|
||||
res.send(data)
|
||||
// AdjustableTang.bulkCreate(data).then(data=> {res.send(data)}).catch(err=>{res.send(err)})
|
||||
|
||||
}
|
||||
@ -22,8 +22,6 @@ module.exports = app => {
|
||||
*/
|
||||
router.get("/demo", Mycontroller.Welcome);
|
||||
|
||||
router.get("/json", Mycontroller.json);
|
||||
|
||||
|
||||
// Parameter Maste rData select api
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user