|
@@ -1,9 +1,11 @@
|
|
|
package cn.iocoder.yudao.module.museums.controller.admin.specimeninfo;
|
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
|
|
import cn.iocoder.yudao.module.museums.enums.common.CollectionStatusEnum;
|
|
|
import cn.iocoder.yudao.module.museums.enums.common.PreservationTypeEnum;
|
|
|
import cn.iocoder.yudao.module.museums.enums.common.SourceEnum;
|
|
|
import cn.iocoder.yudao.module.museums.enums.common.SpecimenTypeEnum;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogRespVO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
|
|
|
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
|
|
@@ -158,37 +160,6 @@ public class SpecimenInfoController {
|
|
|
ExcelUtils.write(response, "标本导入模板.xls", "标本信息", SpecimenImportExcelVO.class, list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping("/import-specimen")
|
|
|
- @Operation(summary = "导入标本")
|
|
|
- @Parameters({
|
|
|
- @Parameter(name = "file", description = "Excel 文件", required = true),
|
|
|
- @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
|
|
- })
|
|
|
- @PreAuthorize("@ss.hasPermission('museums:specimen-info:import')")
|
|
|
- public CommonResult<SpecimenImportRespVO> importSpecimenExcel(@RequestParam("file") MultipartFile file,
|
|
|
- @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
|
|
- List<SpecimenImportExcelVO> list = ExcelUtils.read(file, SpecimenImportExcelVO.class);
|
|
|
- return success(specimenInfoService.importSpecimenList(list, updateSupport));
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/import-specimen-images")
|
|
|
- @Operation(summary = "导入标本图片")
|
|
|
- @Parameters({
|
|
|
- @Parameter(name = "file", description = "压缩包文件", required = true)
|
|
|
- })
|
|
|
- @PreAuthorize("@ss.hasPermission('museums:specimen-info:import-images')")
|
|
|
- public CommonResult<String> importSpecimenImages(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
- // 解压文件并处理图片
|
|
|
- String result = specimenInfoService.importSpecimenImages(file);
|
|
|
- // 确保返回的数据不为 null
|
|
|
- if (result == null) {
|
|
|
- throw exception(INVALID_IMAGE_FORMAT);
|
|
|
- }
|
|
|
- return success(result);
|
|
|
- }
|
|
|
-
|
|
|
@PostMapping("/import-specimen-with-images")
|
|
|
@Operation(summary = "导入标本及其图片")
|
|
|
@Parameters({
|
|
@@ -233,109 +204,28 @@ public class SpecimenInfoController {
|
|
|
@GetMapping("/statistics/entry/{year}")
|
|
|
@Operation(summary = "统计本年标本每月入库数量")
|
|
|
@Parameter(name = "year", description = "年份", required = true, example = "2024")
|
|
|
- // TODO 工作台最好有一个独立的权限标识 ,工作台内部的统计可以共用
|
|
|
- @PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
|
+ @PreAuthorize("@ss.hasPermission('museums:specimen-info:workbench')")
|
|
|
public CommonResult<Map<String, Object>> getMonthlyEntryStatistics(@PathVariable int year) {
|
|
|
- List<Map<String, Object>> entryStatistics = specimenInfoService.getMonthlyEntryStatistics(year);
|
|
|
-
|
|
|
- // TODO 返回格式在CommonResult 里面已经封装了啊,不需要在构建一个
|
|
|
-
|
|
|
- // 构造返回格式
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("code", 200);
|
|
|
- // TODO 统计的就是本年啊?所以这里是不需要的,
|
|
|
- result.put("year", String.valueOf(year));
|
|
|
-
|
|
|
-
|
|
|
- // TODO 直接返回这个就行 Map<String, String> monthData = new HashMap<>();
|
|
|
- result.put("data", entryStatistics.stream()
|
|
|
- .map(stat -> {
|
|
|
- Map<String, Object> monthData = new HashMap<>();
|
|
|
- monthData.put("number", stat.get("entryCount")); // 获取入库数量
|
|
|
- monthData.put("month", stat.get("month") + "月"); // 获取月份并转换格式
|
|
|
- return monthData;
|
|
|
- })
|
|
|
- .collect(Collectors.toList())
|
|
|
- );
|
|
|
-
|
|
|
- // TODO 这个msg完全没必要啊,同样在CommonResult里面封装了
|
|
|
- // result.code = GlobalErrorCodeConstants.SUCCESS.getCode();
|
|
|
- // result.data = data;
|
|
|
- // result.msg = "";
|
|
|
-
|
|
|
- result.put("msg", "统计本年标本入库数量");
|
|
|
-
|
|
|
- return success(result);
|
|
|
- }
|
|
|
-
|
|
|
- //根据标本类别指标统计各类标本库存数,第一个是可查询某个标本类别的所有数据,第二个是可查询各个标本类型的库存数
|
|
|
- @GetMapping("/statistics/{specimen_type}")
|
|
|
- @Operation(summary = "按标本类别统计库存数")
|
|
|
- @Parameter(name = "specimen_type", description = "标本类型", required = true, example = "1")
|
|
|
- @PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
|
- public CommonResult<List<SpecimenInfoDO>> getSpecimenTypeStatistics(@PathVariable int specimen_type) {
|
|
|
- // TODO 这个接口和我在page中写where有什么不同吗? 白写咯哈哈哈
|
|
|
- List<SpecimenInfoDO> specimenTypeStatistics = specimenInfoService.getSpecimenTypeStatistics(specimen_type);
|
|
|
- return success(specimenTypeStatistics);
|
|
|
+ List<Map<String, Object>> monthlyStatistics = specimenInfoService.getMonthlyEntryStatistics(year);
|
|
|
+ Map<String, Object> responseData = new HashMap<>();
|
|
|
+ responseData.put("data", monthlyStatistics);
|
|
|
+ return CommonResult.success(responseData);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/statistics/allType")
|
|
|
@Operation(summary = "按标本类别统计库存数")
|
|
|
- @PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
|
+ @PreAuthorize("@ss.hasPermission('museums:specimen-info:workbench')")
|
|
|
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();
|
|
|
- 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, "陨石");
|
|
|
-
|
|
|
- // 存储统计结果的 Map
|
|
|
- Map<String, Integer> samples = new HashMap<>();
|
|
|
- int totalCount = 0;
|
|
|
-
|
|
|
- // 将统计结果填充到 samples 中
|
|
|
- for (Map<String, Object> specimen : specimenTypeStatistics) {
|
|
|
- Integer type = (Integer) specimen.get("specimen_type");
|
|
|
- Integer count = ((Long) specimen.get("count")).intValue(); // 处理 Long 转换
|
|
|
- String typeName = typeMapping.get(type);
|
|
|
-
|
|
|
- if (typeName != null) {
|
|
|
- samples.put(typeName, count);
|
|
|
- totalCount += count; // 统计总数
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 将总数和样本统计信息放入结果中
|
|
|
- samples.put("标本总数", totalCount);
|
|
|
-
|
|
|
- // TODO 结果可以没必要封装这一层,没有实际的意义直接返回samples即可
|
|
|
- result.put("samples", samples); // 将样本统计信息放入结果的 data 中
|
|
|
-
|
|
|
- return success(result);
|
|
|
+ Map<String, Integer> samples = specimenInfoService.getSpecimenTypeStatistics();
|
|
|
+ Map<String, Object> responseData = new HashMap<>();
|
|
|
+ responseData.put("samples", samples);
|
|
|
+ return success(responseData);
|
|
|
}
|
|
|
|
|
|
//根据出、回、入库的登记信息统计本馆标本历年增减情况。
|
|
|
@GetMapping("/statistics/yearly")
|
|
|
@Operation(summary = "根据出、回、入库登记统计标本历年增减情况")
|
|
|
+ @PreAuthorize("@ss.hasPermission('museums:specimen-info:workbench')")
|
|
|
public CommonResult<Map<String, Object>> getYearlySpecimenStatistics() {
|
|
|
Map<String, Object> yearlyStatistics = specimenInfoService.getYearlySpecimenStatistics();
|
|
|
return CommonResult.success(yearlyStatistics);
|
|
@@ -344,30 +234,23 @@ public class SpecimenInfoController {
|
|
|
//根据入馆凭证中标本来源的登记情况统计
|
|
|
@GetMapping("/statistics/source")
|
|
|
@Operation(summary = "根据标本来源统计历年标本登记情况")
|
|
|
+ @PreAuthorize("@ss.hasPermission('museums:specimen-info:workbench')")
|
|
|
public CommonResult<List<Map<String, Object>>> getYearlySpecimenSourceStatistics() {
|
|
|
List<Map<String, Object>> yearlySourceStatistics = specimenInfoService.getYearlySpecimenSourceStatistics();
|
|
|
return CommonResult.success(yearlySourceStatistics);
|
|
|
}
|
|
|
|
|
|
- //标本库管理
|
|
|
- //实现对标本操作记录进行追溯查看,包括入库记录、编辑记录、出库记录、回库记录等。
|
|
|
- @GetMapping("/records")
|
|
|
- @Operation(summary = "获得标本操作记录")
|
|
|
- @Parameter(name = "id", description = "标本编号", required = true, example = "1024")
|
|
|
- @PreAuthorize("@ss.hasPermission('museums:specimen-info:query')")
|
|
|
- public CommonResult<List<SpecimenInfoDO>> select(@RequestParam("id") Long id) {
|
|
|
- List<SpecimenInfoDO> list = specimenInfoService.getSpecimenRecords(id);
|
|
|
- return success(list); // 返回整个列表
|
|
|
- }
|
|
|
-
|
|
|
@GetMapping("/logs")
|
|
|
@Operation(summary = "获得标本相关的系统日志")
|
|
|
@Parameter(name = "specimenId", description = "标本编号", required = true, example = "1024")
|
|
|
@Parameter(name = "moduleType", description = "操作模块类型", required = true, example = "MUSEUMS 标本")
|
|
|
public CommonResult<List<OperateLogRespVO>> getSpecimenLogs(
|
|
|
- @RequestParam("specimenId") Integer specimenId,
|
|
|
- @RequestParam("moduleType") String moduleType) {
|
|
|
- List<OperateLogDO> logs = operateLogService.getLogsBySpecimenIdAndType(specimenId, moduleType);
|
|
|
+ @RequestParam("specimenId") List<String> extra,
|
|
|
+ @RequestParam("moduleType") String type) {
|
|
|
+ OperateLogPageReqVO pageReqDTO=new OperateLogPageReqVO();
|
|
|
+ pageReqDTO.setType(type);
|
|
|
+ pageReqDTO.setExtra(extra);
|
|
|
+ List<OperateLogDO> logs = operateLogService.getLogsBySpecimenIdAndType(pageReqDTO);
|
|
|
return success(BeanUtils.toBean(logs, OperateLogRespVO.class));
|
|
|
}
|
|
|
}
|