var billDate = new Array();
var chargeItemName = new Array();
var billYear = new Array();
var billMonth = new Array();
var is_LastMonth = new Array();
var billAmount = new Array();
var shouldChargeDate = new Array();
var now = new Date();
var year = now.getFullYear();
var month1 = now.getMonth()+1;
var month = 0;
if (month1 >= 1 && month1 <= 9) {
month ="0" + month1;
};
year= year.toString();
month = month.toString();
for (var i=0;i<=11;i++){
billDate[i] = msg.payload.data[i].billDate;
chargeItemName[i] = msg.payload.data[i].chargeItemName;
if (chargeItemName[i] === "自用水费") {
billYear[i] = billDate[i].substring(0,4);
billMonth[i] = billDate[i].substring(13,15);
}
else {
billYear[i] = billDate[i].substring(0,4);
billMonth[i] = billDate[i].substring(4,6);
};
is_LastMonth[i] = month - billMonth[i];
billAmount[i] = msg.payload.data[i].billAmount;
shouldChargeDate[i] = msg.payload.data[i].shouldChargeDate;
}
var msg1 = {
cost: {
billYear: billYear[0],
billMonth: billMonth[0],
chargeItemName: chargeItemName[0],
billDate: billDate[0],
billAmount: billAmount[0],
shouldChargeDate: shouldChargeDate[0],
is_LastMonth: is_LastMonth[0],
}
};
var msg2 = {
cost: {
billYear: billYear[1],
billMonth: billMonth[1],
chargeItemName: chargeItemName[1],
billDate: billDate[1],
billAmount: billAmount[1],
shouldChargeDate: shouldChargeDate[1],
is_LastMonth: is_LastMonth[1],
}
};
var msg3 = {
cost: {
billYear: billYear[2],
billMonth: billMonth[2],
chargeItemName: chargeItemName[2],
billDate: billDate[2],
billAmount: billAmount[2],
shouldChargeDate: shouldChargeDate[2],
is_LastMonth: is_LastMonth[2],
}
};
var msg4 = {
cost: {
billYear: billYear[3],
billMonth: billMonth[3],
chargeItemName: chargeItemName[3],
billDate: billDate[3],
billAmount: billAmount[3],
shouldChargeDate: shouldChargeDate[3],
is_LastMonth: is_LastMonth[3],
}
};
var msg5 = {
cost: {
billYear: billYear[4],
billMonth: billMonth[4],
chargeItemName: chargeItemName[4],
billDate: billDate[4],
billAmount: billAmount[4],
shouldChargeDate: shouldChargeDate[4],
is_LastMonth: is_LastMonth[4],
}
};
var msg6 = {
cost: {
billYear: billYear[5],
billMonth: billMonth[5],
chargeItemName: chargeItemName[5],
billDate: billDate[5],
billAmount: billAmount[5],
shouldChargeDate: shouldChargeDate[5],
is_LastMonth: is_LastMonth[5],
}
};
var msg7 = {
cost: {
billYear: billYear[6],
billMonth: billMonth[6],
chargeItemName: chargeItemName[6],
billDate: billDate[6],
billAmount: billAmount[6],
shouldChargeDate: shouldChargeDate[6],
is_LastMonth: is_LastMonth[6],
}
};
var msg8 = {
cost: {
billYear: billYear[7],
billMonth: billMonth[7],
chargeItemName: chargeItemName[7],
billDate: billDate[7],
billAmount: billAmount[7],
shouldChargeDate: shouldChargeDate[7],
is_LastMonth: is_LastMonth[7],
}
};
var msg9 = {
cost: {
billYear: billYear[8],
billMonth: billMonth[8],
chargeItemName: chargeItemName[8],
billDate: billDate[8],
billAmount: billAmount[8],
shouldChargeDate: shouldChargeDate[8],
is_LastMonth: is_LastMonth[8],
}
};
var msg10 = {
cost: {
billYear: billYear[9],
billMonth: billMonth[9],
chargeItemName: chargeItemName[9],
billDate: billDate[9],
billAmount: billAmount[9],
shouldChargeDate: shouldChargeDate[9],
is_LastMonth: is_LastMonth[9],
}
};
var msg11 = {
cost: {
billYear: billYear[10],
billMonth: billMonth[10],
chargeItemName: chargeItemName[10],
billDate: billDate[10],
billAmount: billAmount[10],
shouldChargeDate: shouldChargeDate[10],
is_LastMonth: is_LastMonth[10],
}
};
var msg12 = {
cost: {
billYear: billYear[11],
billMonth: billMonth[11],
chargeItemName: chargeItemName[11],
billDate: billDate[11],
billAmount: billAmount[11],
shouldChargeDate: shouldChargeDate[11],
is_LastMonth: is_LastMonth[11],
}
};
return [msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,msg10,msg11,msg12];
2、以下是“获取上月”switch节点