zoukankan      html  css  js  c++  java
  • 【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跳一跳
    OSError: [WinError -2147221003] 找不到应用程序: 'QR.png' 的解决方法
    易知大学 任务25 第一次爬虫与测试
    linux常用命令
    健身日志
    JavaScript JSON
    常用注解 开发SpringBoot项目
    网络基础
    jQuery MINI UI 学习之分页查询
    Springboot集成ActivitiModel提示输入密码
  • 原文地址:https://www.cnblogs.com/mindzone/p/14718291.html
Copyright © 2011-2022 走看看