fix(aihr): keep old daily drills out of today
This commit is contained in:
+2
-2
@@ -925,7 +925,7 @@ public class AihrPracticeSeedService {
|
|||||||
FROM aihr_practice_assignment
|
FROM aihr_practice_assignment
|
||||||
WHERE tenant_id = ?
|
WHERE tenant_id = ?
|
||||||
AND (? = '' OR ext_party_id = ?)
|
AND (? = '' OR ext_party_id = ?)
|
||||||
AND (status = '待训练' OR (source = 'daily' AND DATE(create_time) = CURRENT_DATE()))
|
AND ((source <> 'daily' AND status = '待训练') OR (source = 'daily' AND DATE(create_time) = CURRENT_DATE()))
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE WHEN source = 'daily' THEN 1 ELSE 0 END,
|
CASE WHEN source = 'daily' THEN 1 ELSE 0 END,
|
||||||
CASE WHEN source = 'daily' THEN id ELSE NULL END ASC,
|
CASE WHEN source = 'daily' THEN id ELSE NULL END ASC,
|
||||||
@@ -958,7 +958,7 @@ public class AihrPracticeSeedService {
|
|||||||
FROM aihr_practice_assignment
|
FROM aihr_practice_assignment
|
||||||
WHERE tenant_id = ?
|
WHERE tenant_id = ?
|
||||||
AND ext_party_id IN (%s)
|
AND ext_party_id IN (%s)
|
||||||
AND (status = '待训练' OR (source = 'daily' AND DATE(create_time) = CURRENT_DATE()))
|
AND ((source <> 'daily' AND status = '待训练') OR (source = 'daily' AND DATE(create_time) = CURRENT_DATE()))
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE WHEN source = 'daily' THEN 1 ELSE 0 END,
|
CASE WHEN source = 'daily' THEN 1 ELSE 0 END,
|
||||||
CASE WHEN source = 'daily' THEN id ELSE NULL END ASC,
|
CASE WHEN source = 'daily' THEN id ELSE NULL END ASC,
|
||||||
|
|||||||
+66
@@ -118,6 +118,22 @@ public class AihrPracticeSeedServiceTest {
|
|||||||
assertEquals(List.of(), jdbcTemplate.reviewArgs);
|
assertEquals(List.of(), jdbcTemplate.reviewArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void assignmentsOnlyCarriesTodayDailyDrills() {
|
||||||
|
AssignmentJdbcTemplate jdbcTemplate = new AssignmentJdbcTemplate("主管", List.of("13900001111", "EMP-1"));
|
||||||
|
AihrPracticeSeedService service = new AihrPracticeSeedService(new ObjectMapper(), jdbcTemplate, null, null);
|
||||||
|
|
||||||
|
service.assignments("13900001111", 10);
|
||||||
|
String ownSql = jdbcTemplate.assignmentSql;
|
||||||
|
|
||||||
|
service.assignments("", "13900001111", 10);
|
||||||
|
String scopedSql = jdbcTemplate.assignmentSql;
|
||||||
|
|
||||||
|
String condition = "(source <> 'daily' AND status = '待训练') OR (source = 'daily' AND DATE(create_time) = CURRENT_DATE())";
|
||||||
|
assertTrue(ownSql.contains(condition));
|
||||||
|
assertTrue(scopedSql.contains(condition));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void competencyDoesNotSeedScoreForEmptyEmployee() {
|
public void competencyDoesNotSeedScoreForEmptyEmployee() {
|
||||||
JdbcTemplate jdbcTemplate = mock(JdbcTemplate.class);
|
JdbcTemplate jdbcTemplate = mock(JdbcTemplate.class);
|
||||||
@@ -201,6 +217,56 @@ public class AihrPracticeSeedServiceTest {
|
|||||||
return mapped;
|
return mapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class AssignmentJdbcTemplate extends JdbcTemplate {
|
||||||
|
private final String ownerLevel;
|
||||||
|
private final List<String> scopeIds;
|
||||||
|
private String assignmentSql = "";
|
||||||
|
|
||||||
|
private AssignmentJdbcTemplate(String ownerLevel, List<String> scopeIds) {
|
||||||
|
this.ownerLevel = ownerLevel;
|
||||||
|
this.scopeIds = scopeIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T queryForObject(String sql, Class<T> requiredType) {
|
||||||
|
return requiredType.cast(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T queryForObject(String sql, Class<T> requiredType, Object... args) {
|
||||||
|
return requiredType.cast(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String sql) {
|
||||||
|
// Table creation is irrelevant for query assembly tests.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> List<T> query(String sql, RowMapper<T> rowMapper, Object... args) {
|
||||||
|
try {
|
||||||
|
if (sql.contains("SELECT id, ext_party_id")) {
|
||||||
|
assignmentSql = sql;
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
if (sql.contains("SELECT project_code") && sql.contains("LIMIT 1")) {
|
||||||
|
return mapRows(rowMapper, List.of(Map.of(
|
||||||
|
"project_code", "P1",
|
||||||
|
"position_level", ownerLevel
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
if (sql.contains("SELECT ext_party_id") && sql.contains("ORDER BY position_level")) {
|
||||||
|
return mapRows(rowMapper, scopeIds.stream()
|
||||||
|
.map(id -> Map.of("ext_party_id", id))
|
||||||
|
.toList());
|
||||||
|
}
|
||||||
|
return List.of();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final class PracticeReviewJdbcTemplate extends JdbcTemplate {
|
private static final class PracticeReviewJdbcTemplate extends JdbcTemplate {
|
||||||
private final String ownerLevel;
|
private final String ownerLevel;
|
||||||
private final List<String> scopeIds;
|
private final List<String> scopeIds;
|
||||||
|
|||||||
Reference in New Issue
Block a user