parent
c0f3efb8dd
commit
876d2ff6ac
@ -37,40 +37,8 @@ public class EmployeeDAO {
|
|||||||
table.close();
|
table.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queryByPerformance() throws IOException {
|
// 其他查询方法实现(与原HBaseEmpManager逻辑相同)
|
||||||
Table table = HBaseConnectionManager.getConnection().getTable(TableName.valueOf("emp1520"));
|
// ... existing query methods ...
|
||||||
Scan scan = new Scan();
|
|
||||||
scan.addFamily(Bytes.toBytes(CF_PERFORMANCE));
|
|
||||||
ResultScanner scanner = table.getScanner(scan);
|
|
||||||
for (Result result : scanner) {
|
|
||||||
String perf = Bytes.toString(result.getValue(
|
|
||||||
Bytes.toBytes(CF_PERFORMANCE), Bytes.toBytes("performance_score")));
|
|
||||||
if (perf != null && Integer.parseInt(perf) >= 90) {
|
|
||||||
System.out.println("高绩效员工: " +
|
|
||||||
Bytes.toString(result.getValue(Bytes.toBytes(CF_EMPNUM), Bytes.toBytes("empno"))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
table.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void queryRecentPromotion() throws IOException {
|
|
||||||
Table table = HBaseConnectionManager.getConnection().getTable(TableName.valueOf("emp1520"));
|
|
||||||
Scan scan = new Scan();
|
|
||||||
scan.addColumn(Bytes.toBytes(CF_PERFORMANCE), Bytes.toBytes("promotion_date"));
|
|
||||||
ResultScanner scanner = table.getScanner(scan);
|
|
||||||
for (Result result : scanner) {
|
|
||||||
String dateStr = Bytes.toString(result.getValue(
|
|
||||||
Bytes.toBytes(CF_PERFORMANCE), Bytes.toBytes("promotion_date")));
|
|
||||||
if (dateStr != null && !dateStr.isEmpty()) {
|
|
||||||
LocalDate date = LocalDate.parse(dateStr);
|
|
||||||
if (date.isAfter(LocalDate.now().minusYears(1))) {
|
|
||||||
System.out.println("近一年晋升员工: " +
|
|
||||||
Bytes.toString(result.getValue(Bytes.toBytes(CF_EMPNUM), Bytes.toBytes("empno"))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
table.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String generateRowKey(String empno) throws NoSuchAlgorithmException {
|
private static String generateRowKey(String empno) throws NoSuchAlgorithmException {
|
||||||
String prefix = empno.substring(0, 3);
|
String prefix = empno.substring(0, 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user