|
@@ -206,23 +206,59 @@ public class SpecimenInfoController {
|
|
|
List<SpecimenInfoDO> specimenTypeStatistics = specimenInfoService.getSpecimenTypeStatistics(specimen_type);
|
|
|
return success(specimenTypeStatistics);
|
|
|
}
|
|
|
+// @GetMapping("/statistics/allType")
|
|
|
+// @Operation(summary = "按标本类别统计库存数")
|
|
|
+// @PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
|
+// public CommonResult<Map<Integer, Integer>> getSpecimenTypeStatistics() {
|
|
|
+// List<Map<String, Object>> specimenTypeStatistics = specimenInfoService.getAllSpecimenTypeStatistics();
|
|
|
+// Map<Integer, Integer> result = new HashMap<>();
|
|
|
+//
|
|
|
+// // 将统计结果填充到 Map 中
|
|
|
+// for (Map<String, Object> specimen : specimenTypeStatistics) {
|
|
|
+// Integer type = (Integer) specimen.get("specimen_type");
|
|
|
+// Integer count = ((Long) specimen.get("count")).intValue(); // 处理 Long 转换
|
|
|
+// result.put(type, count);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return success(result);
|
|
|
+// }
|
|
|
+
|
|
|
@GetMapping("/statistics/allType")
|
|
|
@Operation(summary = "按标本类别统计库存数")
|
|
|
@PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
|
- public CommonResult<Map<Integer, Integer>> getSpecimenTypeStatistics() {
|
|
|
+ public CommonResult<Map<String, Object>> getSpecimenTypeStatistics() {
|
|
|
List<Map<String, Object>> specimenTypeStatistics = specimenInfoService.getAllSpecimenTypeStatistics();
|
|
|
- Map<Integer, Integer> result = new HashMap<>();
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+
|
|
|
+ // 使用 HashMap 而不是 Map.of
|
|
|
+ Map<Integer, String> typeMapping = new HashMap<>();
|
|
|
+ typeMapping.put(0, "矿物");
|
|
|
+ typeMapping.put(1, "岩石矿石");
|
|
|
+ typeMapping.put(2, "化石");
|
|
|
+ typeMapping.put(3, "陨石");
|
|
|
+
|
|
|
+ int totalCount = 0;
|
|
|
|
|
|
// 将统计结果填充到 Map 中
|
|
|
for (Map<String, Object> specimen : specimenTypeStatistics) {
|
|
|
Integer type = (Integer) specimen.get("specimen_type");
|
|
|
Integer count = ((Long) specimen.get("count")).intValue(); // 处理 Long 转换
|
|
|
- result.put(type, count);
|
|
|
+ String typeName = typeMapping.get(type);
|
|
|
+
|
|
|
+ if (typeName != null) {
|
|
|
+ result.put(typeName, count);
|
|
|
+ totalCount += count; // 统计总数
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // 将总数放入结果中
|
|
|
+ result.put("标本总数", totalCount);
|
|
|
+
|
|
|
return success(result);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//根据出、回、入库的登记信息统计本馆标本历年增减情况。
|
|
|
@GetMapping("/statistics/yearly")
|
|
|
@Operation(summary = "根据出、回、入库登记统计标本历年增减情况")
|