|
@@ -19,6 +19,8 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/api/admin")
|
|
@RequestMapping("/api/admin")
|
|
@@ -521,6 +523,69 @@ public class AdminController {
|
|
|
return Result.success(true);
|
|
return Result.success(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按街道ID列表统计家庭数量(区域匹配用)
|
|
|
|
|
+ */
|
|
|
|
|
+ @Operation(summary = "按街道ID列表统计家庭数量")
|
|
|
|
|
+ @PostMapping("/families/count")
|
|
|
|
|
+ public Result<Long> countFamiliesByStreetIds(@RequestBody Map<String, Object> params) {
|
|
|
|
|
+ List<Long> streetIds = parseStreetIds(params);
|
|
|
|
|
+ if (streetIds.isEmpty()) {
|
|
|
|
|
+ return Result.success(0L);
|
|
|
|
|
+ }
|
|
|
|
|
+ Long count = familyMapper.selectCount(new LambdaQueryWrapper<Family>()
|
|
|
|
|
+ .in(Family::getStreetId, streetIds));
|
|
|
|
|
+ return Result.success(count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按街道ID列表统计成长规划师数量(通过家庭 streetId 归属,teacher_id 去重)
|
|
|
|
|
+ */
|
|
|
|
|
+ @Operation(summary = "按街道ID列表统计成长规划师数量")
|
|
|
|
|
+ @PostMapping("/teachers/count")
|
|
|
|
|
+ public Result<Long> countTeachersByStreetIds(@RequestBody Map<String, Object> params) {
|
|
|
|
|
+ List<Long> streetIds = parseStreetIds(params);
|
|
|
|
|
+ if (streetIds.isEmpty()) {
|
|
|
|
|
+ return Result.success(0L);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 统计这些街道下已绑定成长规划师的家庭,按 teacher_id 去重
|
|
|
|
|
+ List<Family> families = familyMapper.selectList(new LambdaQueryWrapper<Family>()
|
|
|
|
|
+ .in(Family::getStreetId, streetIds)
|
|
|
|
|
+ .isNotNull(Family::getTeacherId));
|
|
|
|
|
+ long count = families.stream()
|
|
|
|
|
+ .map(Family::getTeacherId)
|
|
|
|
|
+ .filter(java.util.Objects::nonNull)
|
|
|
|
|
+ .distinct()
|
|
|
|
|
+ .count();
|
|
|
|
|
+ return Result.success(count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 解析请求中的 streetIds 参数(支持逗号分隔字符串或数组)
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<Long> parseStreetIds(Map<String, Object> params) {
|
|
|
|
|
+ Object raw = params.get("streetIds");
|
|
|
|
|
+ if (raw == null) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ String str = raw.toString();
|
|
|
|
|
+ if (str.isEmpty()) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
|
|
+ for (String part : str.split(",")) {
|
|
|
|
|
+ String trimmed = part.trim();
|
|
|
|
|
+ if (!trimmed.isEmpty()) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ ids.add(Long.parseLong(trimmed));
|
|
|
|
|
+ } catch (NumberFormatException ignored) {
|
|
|
|
|
+ // 忽略非数字片段
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return ids;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 任务模板管理
|
|
// 任务模板管理
|
|
|
@PostMapping("/task-templates")
|
|
@PostMapping("/task-templates")
|
|
|
public Result<Page<TaskTemplate>> getTaskTemplates(@RequestBody Map<String, Object> params) {
|
|
public Result<Page<TaskTemplate>> getTaskTemplates(@RequestBody Map<String, Object> params) {
|