|
@@ -233,14 +233,21 @@ public class SpecimenInfoController {
|
|
@GetMapping("/statistics/entry/{year}")
|
|
@GetMapping("/statistics/entry/{year}")
|
|
@Operation(summary = "统计本年标本每月入库数量")
|
|
@Operation(summary = "统计本年标本每月入库数量")
|
|
@Parameter(name = "year", description = "年份", required = true, example = "2024")
|
|
@Parameter(name = "year", description = "年份", required = true, example = "2024")
|
|
|
|
+ // TODO 工作台最好有一个独立的权限标识 ,工作台内部的统计可以共用
|
|
@PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
@PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
public CommonResult<Map<String, Object>> getMonthlyEntryStatistics(@PathVariable int year) {
|
|
public CommonResult<Map<String, Object>> getMonthlyEntryStatistics(@PathVariable int year) {
|
|
List<Map<String, Object>> entryStatistics = specimenInfoService.getMonthlyEntryStatistics(year);
|
|
List<Map<String, Object>> entryStatistics = specimenInfoService.getMonthlyEntryStatistics(year);
|
|
|
|
|
|
|
|
+ // TODO 返回格式在CommonResult 里面已经封装了啊,不需要在构建一个
|
|
|
|
+
|
|
// 构造返回格式
|
|
// 构造返回格式
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
result.put("code", 200);
|
|
result.put("code", 200);
|
|
|
|
+ // TODO 统计的就是本年啊?所以这里是不需要的,
|
|
result.put("year", String.valueOf(year));
|
|
result.put("year", String.valueOf(year));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // TODO 直接返回这个就行 Map<String, String> monthData = new HashMap<>();
|
|
result.put("data", entryStatistics.stream()
|
|
result.put("data", entryStatistics.stream()
|
|
.map(stat -> {
|
|
.map(stat -> {
|
|
Map<String, Object> monthData = new HashMap<>();
|
|
Map<String, Object> monthData = new HashMap<>();
|
|
@@ -250,6 +257,12 @@ public class SpecimenInfoController {
|
|
})
|
|
})
|
|
.collect(Collectors.toList())
|
|
.collect(Collectors.toList())
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ // TODO 这个msg完全没必要啊,同样在CommonResult里面封装了
|
|
|
|
+ // result.code = GlobalErrorCodeConstants.SUCCESS.getCode();
|
|
|
|
+ // result.data = data;
|
|
|
|
+ // result.msg = "";
|
|
|
|
+
|
|
result.put("msg", "统计本年标本入库数量");
|
|
result.put("msg", "统计本年标本入库数量");
|
|
|
|
|
|
return success(result);
|
|
return success(result);
|
|
@@ -261,6 +274,7 @@ public class SpecimenInfoController {
|
|
@Parameter(name = "specimen_type", description = "标本类型", required = true, example = "1")
|
|
@Parameter(name = "specimen_type", description = "标本类型", required = true, example = "1")
|
|
@PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
@PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
public CommonResult<List<SpecimenInfoDO>> getSpecimenTypeStatistics(@PathVariable int specimen_type) {
|
|
public CommonResult<List<SpecimenInfoDO>> getSpecimenTypeStatistics(@PathVariable int specimen_type) {
|
|
|
|
+ // TODO 这个接口和我在page中写where有什么不同吗? 白写咯哈哈哈
|
|
List<SpecimenInfoDO> specimenTypeStatistics = specimenInfoService.getSpecimenTypeStatistics(specimen_type);
|
|
List<SpecimenInfoDO> specimenTypeStatistics = specimenInfoService.getSpecimenTypeStatistics(specimen_type);
|
|
return success(specimenTypeStatistics);
|
|
return success(specimenTypeStatistics);
|
|
}
|
|
}
|
|
@@ -269,7 +283,21 @@ public class SpecimenInfoController {
|
|
@Operation(summary = "按标本类别统计库存数")
|
|
@Operation(summary = "按标本类别统计库存数")
|
|
@PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
@PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
public CommonResult<Map<String, Object>> getSpecimenTypeStatistics() {
|
|
public CommonResult<Map<String, Object>> getSpecimenTypeStatistics() {
|
|
|
|
+
|
|
// 从服务层获取标本类别的统计数据
|
|
// 从服务层获取标本类别的统计数据
|
|
|
|
+ // TODO 你第一段代码就已经得出结果了,剩下的其实可以交给前端处理,如果你需要处理,可以使用更简单的方式比如
|
|
|
|
+ // @Select("""
|
|
|
|
+ // SELECT
|
|
|
|
+ // CASE
|
|
|
|
+ // WHEN specimen_type = 0 THEN '矿物'
|
|
|
|
+ // WHEN specimen_type = 1 THEN '岩石矿石'
|
|
|
|
+ // WHEN specimen_type = 2 THEN '化石'
|
|
|
|
+ // WHEN specimen_type = 3 THEN '陨石'
|
|
|
|
+ // ELSE '未知'
|
|
|
|
+ // END as specimen_type,
|
|
|
|
+ // COUNT(*) as count
|
|
|
|
+ // FROM specimen_info
|
|
|
|
+ // GROUP BY specimen_type""") 直接得到结果,填入 return success(result);即可
|
|
List<Map<String, Object>> specimenTypeStatistics = specimenInfoService.getAllSpecimenTypeStatistics();
|
|
List<Map<String, Object>> specimenTypeStatistics = specimenInfoService.getAllSpecimenTypeStatistics();
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
@@ -298,6 +326,8 @@ public class SpecimenInfoController {
|
|
|
|
|
|
// 将总数和样本统计信息放入结果中
|
|
// 将总数和样本统计信息放入结果中
|
|
samples.put("标本总数", totalCount);
|
|
samples.put("标本总数", totalCount);
|
|
|
|
+
|
|
|
|
+ // TODO 结果可以没必要封装这一层,没有实际的意义直接返回samples即可
|
|
result.put("samples", samples); // 将样本统计信息放入结果的 data 中
|
|
result.put("samples", samples); // 将样本统计信息放入结果的 data 中
|
|
|
|
|
|
return success(result);
|
|
return success(result);
|