• 【Java】逗号拼接的取巧处理


    需求如图:

    这是表的关键处理数据,页面上的输入框要做分开展示,也就是要写业务逻辑来处理

    逗号拼接的取巧处理,使用了List集合toString方法来实现,然后移除括号

    final String employeeSql = "SELECT TYPE, `NAME`, PHONE FROM tt_foresee_maintain_order_employee WHERE ORDER_ID = ? ";
    List<TtForeseeMaintainOrderEmployeePO> employeeList = TtForeseeMaintainOrderEmployeePO.findBySQL(employeeSql, id); // id 1353
    if (employeeSql != null && employeeList.size() > 0) {
        List<String> ctos = new LinkedList<String>();
        List<String> ctoPhones = new LinkedList<String>();
        List<String> claimants =  new LinkedList();
        List<String> claimantPhones =  new LinkedList();
        for (int i = 0; i < employeeList.size(); ++i) {
            TtForeseeMaintainOrderEmployeePO employee = employeeList.get(i);
            if ( "1".equals(employee.get("TYPE").toString())) {
                ctos.add(employee.get("NAME").toString() );
                ctoPhones.add(employee.get("PHONE").toString());
            } else {
                claimants.add(employee.get("NAME").toString());
                claimantPhones.add(employee.get("PHONE").toString());
            }
        }
        map.put("cto_name", ctos.toString().replaceAll("\[|\]", ""));
        map.put("cto_phone", ctoPhones.toString().replaceAll("\[|\]", ""));
        map.put("claimant_name", claimants.toString().replaceAll("\[|\]", ""));
        map.put("claimant_phone", claimantPhones.toString().replaceAll("\[|\]", ""));
    }
  • 相关阅读:
    python 模块特点
    python 对象类型有哪些?
    python 异常处理
    python urllib2查询数据
    哈希表之词频统计
    泛型 队列
    大小端存储
    收藏 去掉 html 标签的perl 小函数
    好玩 多线程 显示
    服务器客户端 之 文件下载
  • 原文地址:https://www.cnblogs.com/mindzone/p/14718291.html
Copyright © 2020-2023  润新知