var flowfile = session.get();
if(flowfile!=null){
var data = flowfile.getAttribute("data");
var data_obj = JSON.parse(data);
var kw_response_ = flowfile.getAttribute("kw_response");
var kw_response = JSON.parse(kw_response_);
if(kw_response){
var illegalActivities_k = []; // 违法行为
var damageConsequence_k = []; // 损害后果
var damage_k = []; //损害对象
try{
var response = kw_response["data"][0]["attributes"];
if (kw_response["code"] == 200){
for(var i = 0; i < response.length; i++){
var ins = response[i]['type'];
if(ins=="违法事实"){
illegalActivities_k.push(response[i]['entity'])
}
if(ins=="损害后果"){
damageConsequence_k.push(response[i]['entity'])
}
if(ins=="损害对象"){
damage_k.push(response[i]['entity'])
}
}
data_obj['illegalActivities_k'] = illegalActivities_k;
data_obj['damageConsequence'] = damageConsequence_k;
data_obj['damage'] = damage_k;
}else{
data_obj['illegalActivities_k'] = illegalActivities_k;
data_obj['damageConsequence'] = damageConsequence_k;
data_obj['damage'] = damage_k;
}
}
catch(e){
data_obj['illegalActivities_k'] = illegalActivities_k;
data_obj['damageConsequence'] = damageConsequence_k;
data_obj['damage'] = damage_k;
}
}
var data = JSON.stringify(data_obj);
session.putAttribute(flowfile, "data", data);
session.putAttribute(flowfile, "illegalActivities_k", illegalActivities_k.toString());
session.transfer(flowfile, REL_SUCCESS);
} else {
session.transfer(flowfile, REL_SUCCESS);
}
console