java 不同维度算出对应红绿个数

{
code: "0",
desc: "查询成功",
data: {
valuelist: [
{
CARCODE: "A39-III-IV049",
ECODE: "A39-Ⅲ",
MANAGER: "高乐红",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A39-III-IV050",
ECODE: "A39-Ⅲ",
MANAGER: "高乐红",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A39-III-IV051",
ECODE: "A39-Ⅲ",
MANAGER: "高乐红",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A39-III-IV052",
ECODE: "A39-Ⅲ",
MANAGER: "高乐红",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A39-III-IV053",
ECODE: "A39-Ⅲ",
MANAGER: "高乐红",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "总拼焊接"
}
],
progress: ""
},
{
CARCODE: "A39-III-IV064",
ECODE: "A39-Ⅲ",
MANAGER: "高乐红",
listValue: [
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV141",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "裸车改制"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "前处理"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "密封胶"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "烘干1"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "烘干2"
}
],
progress: ""
},
{
CARCODE: "A90-IV142",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV144",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "白车身改制"
}
],
progress: ""
},
{
CARCODE: "A90-IV152",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV153",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV154",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV155",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV156",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV157",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV158",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
},
{
CARCODE: "A90-IV210",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "绿",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "绿",
ISCAR: "是",
PNAME: "总拼焊接"
}
],
progress: ""
},
{
CARCODE: "A90-S019",
ECODE: "A90-ET2-2",
MANAGER: "汤立尧",
listValue: [
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "下车体焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "总拼焊接"
},
{
COLORCODE: "红",
ISCAR: "否",
PNAME: "白车身改制"
},
{
COLORCODE: "红",
ISCAR: "是",
PNAME: "装调"
}
],
progress: ""
}
]
}
}
  String str = JSONObject.parseObject(boardstr).getJSONObject("Body").getString("listValue");
                String head = JSONObject.parseObject(boardstr).getJSONObject("Head").getString("listValue");
                List<Valuelist> valuelist = JSONObject.parseArray(str, Valuelist.class);
                Map<String, Map<String, Integer>> resultMap = new HashMap<>();
                for (Valuelist vlist : valuelist) {
                    if(!resultMap.containsKey(vlist.getECODE())){
                        resultMap.put(vlist.getECODE(),new HashMap<>());
                    }
                    for (PnameList lvalue : vlist.getListValue()) {
                        Map<String,Integer> chilsReaultMap = resultMap.get(vlist.getECODE());
                        if(chilsReaultMap.containsKey(lvalue.getCOLORCODE())){
                            chilsReaultMap.put(lvalue.getCOLORCODE(),chilsReaultMap.get(lvalue.getCOLORCODE())+1);
                        }else{
                            chilsReaultMap.put(lvalue.getCOLORCODE(),1);
                        }
                    }
                }
                for (Valuelist vlist : valuelist) {
                    red=   resultMap.get(vlist.getECODE()).get("红");
                    green=  resultMap.get(vlist.getECODE()).get("绿");
                    //获取格式化对象
                    NumberFormat nt = NumberFormat.getPercentInstance();
                    //设置百分数精确度2即保留两位小数
                    nt.setMinimumFractionDigits(2);
                    vlist.setProgress(nt.format(green/(red+green)));
                }
                addJsonObj("valuelist", valuelist);
                addJsonObj("head", head);

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值