private String newStaffId(String position) { if (position.equals("管理员")) { List<Staff> list = staffDao.findByPosition(position); int num = list.size() + 1; String id = ""; if (num < 10) { id = "S" + "000" + num; } else if (100 > num && num >= 10) { id = "S" + "00" + num; } else if (1000 > num && num >= 100) { id = "S" + "0" + num; } else { id = "S" + num; } return id; } else if (position.equals("经理")) { List<Staff> list = staffDao.findByPosition(position); int num = list.size() + 1; String id = ""; if (num < 10) { id = "A" + "000" + num; } else if (100 > num && num >= 10) { id = "A" + "00" + num; } else if (1000 > num && num >= 100) { id = "A" + "0" + num; } else { id = "A" + num; } return id; } else { List<Staff> list = staffDao.findByPosition(position); int num = list.size() + 1; String id = ""; if (num < 10) { id = "C" + "000" + num; } else if (100 > num && num >= 10) { id = "C" + "00" + num; } else if (1000 > num && num >= 100) { id = "C" + "0" + num; } else { id = "C" + num; } return id; } }
@Override public List<StaffInfo> searchStaffByProposition(String position) { List<StaffInfo> stafflist = new ArrayList<StaffInfo>(); List<Staff> entitylist = staffDao.findByPosition(position); if (entitylist != null) { for (int i = 0; i < entitylist.size(); i++) { StaffInfo temp = convertEntity(entitylist.get(i)); stafflist.add(temp); } } return stafflist; }