一个list集合循环进行循环里面的分类操作(比如上下限合并到一起成一个新map)

  /**
     * 查询【查询上下限当前数据】
     *
     * @param psns 【psn数组】主键
     * @return 【集合】
     */
    @Override
    public  List<Map> selectIotDevPropByPsns(String[] psns){
        List<IotDevPropVo> iotDevPropVoList =iotDevPropMapper.selectIotDevPropByPsns(psns);
            //合并值
            //创建list的长度
            List<Map> useSumList = new ArrayList<>(iotDevPropVoList.size());
            //循环第一个list
            for (int i = 0; i < iotDevPropVoList.size(); i++) {
                //拿到下标为0的对象内容
                IotDevPropVo item = iotDevPropVoList.get(i);
                //判断是否等于当前集合的下标 是的话就结束循环   这么做的只要原因是因为下面的对象复制加1了  避免报错
                if (i + 1 == iotDevPropVoList.size()){
                    break;
                }
//                拿到下标为1的对象内容
                IotDevPropVo itemNext = iotDevPropVoList.get(i + 1);
                //新创建一个集合 用来放值
                Map useSum = new HashMap();
                //判断条件  自己定义
                if (item.getPsn().equals(iotDevPropVoList.get(i).getPsn()) && itemNext.getPsn().equals(iotDevPropVoList.get(i).getPsn())
                        &&item.getLabel().equals("1")&&itemNext.getLabel().equals("2")) {
                    //业务逻辑 
                    useSum.put("upperValue",item.getValue());
                    useSum.put("upperLabel",item.getLabel());
                    useSum.put("lowerValue",itemNext.getValue());
                    useSum.put("lowerLabel",itemNext.getLabel());
                    //字段psn
                    useSum.put("psn",item.getPsn());
                    //字段名称
                    useSum.put("name", item.getNname());
                    //字段名称
                    useSum.put("unit", item.getUnit());
                    useSumList.add(useSum);
                }
            }
        return useSumList;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想要一百块

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值