需求如图:
这是表的关键处理数据,页面上的输入框要做分开展示,也就是要写业务逻辑来处理
逗号拼接的取巧处理,使用了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("\[|\]", "")); }