SOURCE

var str ="[{\"company\":\"两湖街道办\",\"classes\":\"县处级\"}]"

ResultData = function (id, company, proviceTimes, proviceMoney, cityTimes,
    cityMoney, areaTimes, areaMoney) {
    this.id = id;
    this.company = company;
    this.proviceTimes = proviceTimes;
    this.proviceMoney = proviceMoney;
    this.cityTimes = cityTimes;
    this.cityMoney = cityMoney;
    this.areaTimes = areaTimes;
    this.areaMoney = areaMoney;
}

var resultDatas = new Array;
var admirDatas = JSON.parse(str);
var itemId = 0, provicetime = 0, citytime = 0, areatime = 0;
for (var i = 0; i < admirDatas.length; i++) {
    if (i == 0) {
        itemId++;
        if (admirDatas[i].classes == "省部级" || admirDatas[i].classes == "省级") {
            provicetime++;
        } else if (admirDatas[i].classes == "市厅级"  || admirDatas[i].classes == "市级") {
            citytime++;
        } else if (admirDatas[i].classes == "县处级"  || admirDatas[i].classes == "县级") {
            areatime++;
        }
        var resultdata = {
            id: itemId,
            company: admirDatas[i].company,
            proviceTimes: provicetime,
            proviceMoney: provicetime * 1,
            cityTimes: citytime,
            cityMoney: citytime * 0.5,
            areaTimes: areatime,
            areaMoney: areatime * 0.3
        };
        resultDatas.push(resultdata)
        provicetime = 0
        citytime = 0
        areatime = 0
    }
    if (i > 0) {
        if (admirDatas[i].company == admirDatas[i - 1].company) {            
            if (admirDatas[i].classes == "省部级") {
                resultDatas[resultDatas.length - 1].proviceTimes++;
                resultDatas[resultDatas.length - 1].proviceMoney = resultDatas[resultDatas.length - 1].proviceTimes * 1;
            } else if (admirDatas[i].classes == "市厅级") {
                resultDatas[resultDatas.length - 1].cityTimes++;
                resultDatas[resultDatas.length - 1].cityMoney = resultDatas[resultDatas.length - 1].cityTimes * 0.5;

            } else if (admirDatas[i].classes == "县处级") {
                resultDatas[resultDatas.length - 1].areaTimes++;
                resultDatas[resultDatas.length - 1].areaMoney = resultDatas[resultDatas.length - 1].areaTimes * 0.3;

            }
        }else{
   
        itemId++;
        if (admirDatas[i].classes == "省部级") {
            provicetime++;
        } else if (admirDatas[i].classes == "市厅级") {
            citytime++;
        } else if (admirDatas[i].classes == "县处级") {
            areatime++;
        }
         var resultdata = {
            id: itemId,
            company: admirDatas[i].company,
            proviceTimes: provicetime,
            proviceMoney: provicetime * 1,
            cityTimes: citytime,
            cityMoney: citytime * 0.5,
            areaTimes: areatime,
            areaMoney: areatime * 0.3
        };
        resultDatas.push(resultdata)
        provicetime = 0
        citytime = 0
        areatime = 0
        }
    }

}

   


    document.write(
        JSON.stringify(resultDatas))
console 命令行工具 X clear

                    
>
console