Browse Source

完善之前的代码

lwh 1 month ago
parent
commit
fea1f04c48

+ 84 - 26
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/MuseumInfoController.java

@@ -8,11 +8,14 @@ import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
 import cn.iocoder.yudao.module.museum.service.museuminfo.MuseumInfoService;
 import cn.iocoder.yudao.module.museum.service.museuminfo.MuseumInfoService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import javax.validation.Valid;
+import java.time.LocalDate;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -33,14 +36,14 @@ public class MuseumInfoController {
     @Operation(summary = "新增标本")
     @Operation(summary = "新增标本")
     public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
     public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
         String sampleId = saveVO.getSampleId();
         String sampleId = saveVO.getSampleId();
-        MuseumInfoDO result = museumInfoService.getMuseumInfoBySampleId(sampleId);
+        List<MuseumInfoDO> result = museumInfoService.getMuseumInfoBySampleId(sampleId);
         if (result != null) {
         if (result != null) {
             return CommonResult.error(1, "标本编号已存在");
             return CommonResult.error(1, "标本编号已存在");
         } else {
         } else {
             return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
             return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
         }
         }
     }
     }
-
+    @PostMapping("/update")
     @Operation(summary = "更新标本")
     @Operation(summary = "更新标本")
     public CommonResult<Boolean> updateMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO){
     public CommonResult<Boolean> updateMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO){
         museumInfoService.updateMuseumInfo(saveVO);
         museumInfoService.updateMuseumInfo(saveVO);
@@ -67,14 +70,23 @@ public class MuseumInfoController {
       return CommonResult.success(result1);
       return CommonResult.success(result1);
     }
     }
 
 
-    @GetMapping("/selectMuseumInfoList")
-    @Operation(summary = "标本类型查找")
+    @GetMapping("/getSampleId")
+    @Operation(summary = "标本编号查寻")
+    public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@RequestParam("sampleId") String sampleId){
+        List<MuseumInfoDO> result = museumInfoService.getMuseumInfoBySampleId(sampleId);
+        List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
+        return CommonResult.success(result1);
+    }
+
+    @GetMapping("/getSampleType")
+    @Operation(summary = "标本类型查寻")
     public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@RequestParam("sampleType") Integer sampleType){
     public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@RequestParam("sampleType") Integer sampleType){
         List<MuseumInfoDO> result = museumInfoService.selectMuseumInfoListBySampleType(sampleType);
         List<MuseumInfoDO> result = museumInfoService.selectMuseumInfoListBySampleType(sampleType);
         List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
         List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
         return CommonResult.success(result1);
         return CommonResult.success(result1);
     }
     }
 
 
+
     @GetMapping("/page")
     @GetMapping("/page")
     @Operation(summary = "获取分页")
     @Operation(summary = "获取分页")
     public CommonResult<PageResult<MuseumInfoPageReqVO>> getPage(@Valid MuseumInfoPageReqVO pageReqVO){
     public CommonResult<PageResult<MuseumInfoPageReqVO>> getPage(@Valid MuseumInfoPageReqVO pageReqVO){
@@ -90,10 +102,18 @@ public class MuseumInfoController {
 //
 //
     @GetMapping("/sampleTypeCount")
     @GetMapping("/sampleTypeCount")
     @Operation(summary = "标本类型计数")
     @Operation(summary = "标本类型计数")
-    public CommonResult<List<MuseuminfoTypeVO>> getMap(@RequestParam("sampleType") Integer sampleType) {
-        List<MuseuminfoTypeVO> result = museumInfoService.MuseumInfoBySampleType(sampleType);
+    public CommonResult<Map<String,Integer>> getMap() {
+        Integer count1 = museumInfoService.MuseumInfoBySampleType(1);
+        Integer count2 = museumInfoService.MuseumInfoBySampleType(2);
+        Integer count3 = museumInfoService.MuseumInfoBySampleType(3);
+        Integer count4 = museumInfoService.MuseumInfoBySampleType(4);
 //          标本类型:矿石-1 岩石-2 矿物-3 陨石-4>
 //          标本类型:矿石-1 岩石-2 矿物-3 陨石-4>
-        return CommonResult.success(result);
+        Map<String, Integer> map = new HashMap<>();
+        map.put("矿石", count1);
+        map.put("岩石", count2);
+        map.put("矿物", count3);
+        map.put("陨石", count4);
+        return CommonResult.success(map);
     }
     }
 
 
 
 
@@ -101,36 +121,74 @@ public class MuseumInfoController {
 
 
     @GetMapping("/joinSaveCount")
     @GetMapping("/joinSaveCount")
     @Operation(summary = "标本出入库状态计数(每月)(入库)")
     @Operation(summary = "标本出入库状态计数(每月)(入库)")
-    public CommonResult<List<MuseuminfoMonthSaveVO>> getJoinSave(@RequestParam("save") Integer save) {
-        List<MuseuminfoMonthSaveVO> result1 = museumInfoService.MuseumInfoBySaveJoin(save);
+    public CommonResult<List<MuseuminfoMonthSaveVO>> getJoinSave() {
 //        状态:在库-1 出库-0
 //        状态:在库-1 出库-0
 //          构造 12 个月的数据,确保每个月都有数据(即使为 0)
 //          构造 12 个月的数据,确保每个月都有数据(即使为 0)
-//        List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
-//        for (int month = 1 ; month <= 1 ; month++){
-//            String monthStr = String.format("%d-%2d",save, month);
-//            Optional<MuseuminfoMonthSaveVO> found = MonthSave.stream()
-//            filter(f ->f.getMonth().equals(monthStr))
-//                    .findFirst();
-//            MuseuminfoMonthSaveVO vo = new MuseuminfoMonthSaveVO();
-//            vo.setMonth(monthStr);
-//            vo.setCount(found.map(MuseuminfoMonthSaveVO::getSave).orElse( other: 0)).
-//            result.add(vo);
-        return CommonResult.success(result1);
+        List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
+        LocalDate date = LocalDate.now();
+        int currentYear =date.getYear();
+        for (int month = 1 ; month <= 12 ; month++) {
+
+            Integer number =museumInfoService.MuseumInfoBySaveJoin(month,currentYear);
+            MuseuminfoMonthSaveVO  re = new MuseuminfoMonthSaveVO();
+            re.setMonth(month);
+            if (number == null) {
+                re.setCount(0);
+            }else {
+                re.setCount(number);
+            }
+            result.add(re);
+        }
+        return CommonResult.success(result);
     }
     }
 
 
     @GetMapping("/outSaveCount")
     @GetMapping("/outSaveCount")
     @Operation(summary = "标本出入库状态计数(每月)(出库)")
     @Operation(summary = "标本出入库状态计数(每月)(出库)")
-    public CommonResult<List<MuseuminfoMonthSaveVO>> getOutSave(@RequestParam("save") Integer save) {
-        List<MuseuminfoMonthSaveVO> result1 = museumInfoService.MuseumInfoBySaveOut(save);
-        return CommonResult.success(result1);
+    public CommonResult<List<MuseuminfoMonthSaveVO>> getOutSave() {
+        LocalDate date = LocalDate.now();
+        int currentYear =date.getYear();
+        List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
+        for (int month = 1 ; month <= 12 ; month++) {
+
+            Integer number =museumInfoService.MuseumInfoBySaveOut(month,currentYear);
+            MuseuminfoMonthSaveVO  re = new MuseuminfoMonthSaveVO();
+            re.setMonth(month);
+            if (number == null) {
+                re.setCount(0);
+            }else {
+                re.setCount(number);
+            }
+            result.add(re);
+        }
+        return CommonResult.success(result);
     }
     }
 
 
     @GetMapping("/originCount")
     @GetMapping("/originCount")
     @Operation(summary = "标本来源计数")
     @Operation(summary = "标本来源计数")
-    public CommonResult<List<MuseuminfoOriginVO>> getOrigin(@RequestParam("origin") Integer origin){
-        List<MuseuminfoOriginVO> result1 =museumInfoService.MuseumInfoByOrigin(origin);
+    public CommonResult<List<Map<Integer,Object>>> getOrigin(){
 //        来源:采购-1 捐赠-2 采集-3 其他-4
 //        来源:采购-1 捐赠-2 采集-3 其他-4
-        return CommonResult.success(result1);
+
+        List<Map<Integer,Object>> result = new ArrayList<>();
+        LocalDate date = LocalDate.now();
+        int currentYear =date.getYear();
+        int year1 =currentYear-2;
+        for (int year =currentYear ; year>=year1  ; year--) {
+
+            Integer number1 = museumInfoService.MuseumInfoByOrigin(year,1);
+            Integer number2 = museumInfoService.MuseumInfoByOrigin(year,2);
+            Integer number3 = museumInfoService.MuseumInfoByOrigin(year,3);
+            Integer number4 = museumInfoService.MuseumInfoByOrigin(year,4);
+
+            Map<Integer,Object> map = new HashMap<>();
+            Map<String, Integer> innerMap = new HashMap<>();
+            innerMap.put("采购", number1);
+            innerMap.put("捐赠", number2);
+            innerMap.put("采集", number3);
+            innerMap.put("其他", number4);
+            map.put(year,innerMap);
+            result.add(map);
+        }
+        return CommonResult.success(result);
     }
     }
 
 
 
 

+ 0 - 3
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseumInfoPageReqVO.java

@@ -1,14 +1,11 @@
 package cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo;
 package cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo;
 
 
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.MuseumInfoController;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import lombok.ToString;
 
 
-import java.time.LocalDateTime;
-
 @Schema(description = "博物馆-标本信息-分页 pageReq VO")
 @Schema(description = "博物馆-标本信息-分页 pageReq VO")
 @Data
 @Data
 @EqualsAndHashCode(callSuper = true)
 @EqualsAndHashCode(callSuper = true)

+ 1 - 1
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseuminfoMonthSaveVO.java

@@ -10,5 +10,5 @@ import java.time.LocalDateTime;
 @Data
 @Data
 public class MuseuminfoMonthSaveVO {
 public class MuseuminfoMonthSaveVO {
     private Integer month;
     private Integer month;
-    private Long count;
+    private Integer count;
 }
 }

+ 2 - 2
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseuminfoOriginVO.java

@@ -9,8 +9,8 @@ import java.time.LocalDateTime;
 @Schema(description = "博物馆-标本信息 origin VO")
 @Schema(description = "博物馆-标本信息 origin VO")
 @Data
 @Data
 public class MuseuminfoOriginVO {
 public class MuseuminfoOriginVO {
-    private String year;
+    private Integer year;
     private Integer origin;
     private Integer origin;
-    private Long count;
+    private Integer count;
 
 
 }
 }

+ 1 - 1
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseuminfoTypeVO.java

@@ -10,5 +10,5 @@ import java.time.LocalDateTime;
 @Data
 @Data
 public class MuseuminfoTypeVO {
 public class MuseuminfoTypeVO {
     private Integer sampleType;
     private Integer sampleType;
-    private Long count;
+    private Integer count;
 }
 }

+ 22 - 22
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/dal/mysql/museuminfo/MuseumInfoMapper.java

@@ -40,7 +40,7 @@ public interface MuseumInfoMapper extends BaseMapperX<MuseumInfoDO> {
      * 查询标本编号
      * 查询标本编号
      */
      */
     @Select("SELECT * FROM museum_info WHERE sample_id =#{sampleId} AND deleted =0")
     @Select("SELECT * FROM museum_info WHERE sample_id =#{sampleId} AND deleted =0")
-    MuseumInfoDO getMuseumInfoBySampleId(@Param("sampleId") String sampleId);
+    List<MuseumInfoDO> getMuseumInfoBySampleId(@Param("sampleId") String sampleId);
 
 
     /**
     /**
      * 查询标本类型
      * 查询标本类型
@@ -51,40 +51,40 @@ public interface MuseumInfoMapper extends BaseMapperX<MuseumInfoDO> {
     /**
     /**
      * 标本类型计数1
      * 标本类型计数1
      */
      */
-    @Select("SELECT sample_type ,COUNT(*)AS count FROM museum_info WHERE deleted =0 GROUP BY sample_type")
-    List<MuseuminfoTypeVO> countMuseumInfoBySampleType(@Param("sampleType") Integer sampleType);
-
+    @Select("SELECT COUNT(*) FROM museum_info WHERE deleted =0 AND sample_type =#{sampleType}")
+    Integer countMuseumInfoBySampleType(@Param("sampleType") Integer sampleType);
     /**
     /**
      * 标本入库状态计数
      * 标本入库状态计数
      */
      */
     @Select("SELECT" +
     @Select("SELECT" +
-            " DATE_FORMAT(sample_save_time,'%m')AS month," +
-            " COUNT(*) AS count " +
+            " COUNT(*)"+
             " FROM museum_info " +
             " FROM museum_info " +
-            " WHERE deleted =0 AND save =1" +
-            " GROUP BY DATE_FORMAT(sample_save_time,'%m')" +
-            " ORDER BY month")
-    List<MuseuminfoMonthSaveVO> countMuseumInfoBySaveJoin(@Param("save") Integer save);
-
+            " WHERE deleted =0 AND save =1"+
+            " AND DATE_FORMAT(sample_save_time,'%m') = #{month}"+
+            " AND DATE_FORMAT(sample_save_time,'%Y') = #{currentYear}")
+    Integer countMuseumInfoBySaveJoin(@Param("month") Integer month,@Param("currentYear") Integer currentYear);
     /**
     /**
      * 标本出库状态计数
      * 标本出库状态计数
      */
      */
     @Select("SELECT" +
     @Select("SELECT" +
-            " DATE_FORMAT(sample_save_time,'%m')AS month," +
-            " COUNT(*) AS count " +
-            " FROM museum_info " +
-            " WHERE deleted =0 AND save =1" +
-            " GROUP BY DATE_FORMAT(sample_save_time,'%m')" +
-            " ORDER BY month")
-    List<MuseuminfoMonthSaveVO> countMuseumInfoBySaveOut(@Param("save") Integer save);
+            " COUNT(*)"+
+            " FROM museum_outbound " +
+            " WHERE deleted =0 "+
+            " AND DATE_FORMAT(outbound_time,'%m') = #{month}"+
+            " AND DATE_FORMAT(sample_save_time,'%Y') = #{currentYear}")
+    Integer countMuseumInfoBySaveOut(@Param("month") Integer month,@Param("currentYear") Integer currentYear);
 
 
     /**
     /**
      * 标本来源计数(年)
      * 标本来源计数(年)
      */
      */
-//    @Select("SELECT COUNT(*)  FROM museum_info  WHERE origin =#{origin} AND deleted =0 AND sample_save_time >=2025-02")
-//    Integer countMuseumInfoByOrigin (@Param("origin") Integer origin);
-    @Select("SELECT origin,DATE_FORMAT(sample_save_time,'%Y')AS year ,COUNT(*)AS count  FROM museum_info WHERE deleted =0 AND save =1 GROUP BY origin,DATE_FORMAT(sample_save_time,'%Y')")
-    List<MuseuminfoOriginVO> countMuseumInfoByOrigin(@Param("origin") Integer origin);
+    @Select("SELECT" +
+            " COUNT(*)"+
+            " FROM museum_info " +
+            " WHERE deleted =0 AND save =1"+
+            " AND DATE_FORMAT(sample_save_time,'%Y') = #{year}"+
+            " AND origin = #{origin}")
+    Integer countMuseumInfoByOrigin(@Param("year") Integer year, @Param("origin") Integer origin);
+
 
 
     /**
     /**
      * 分页
      * 分页

+ 8 - 5
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/service/museuminfo/MuseumInfoService.java

@@ -34,7 +34,8 @@ public interface MuseumInfoService {
    /**
    /**
     * 查询标本编号
     * 查询标本编号
     * */
     * */
-   MuseumInfoDO getMuseumInfoBySampleId(String sampleId);
+   List<MuseumInfoDO> getMuseumInfoBySampleId(String sampleId);
+
    /**
    /**
    * 查询标本类型
    * 查询标本类型
    * */
    * */
@@ -49,16 +50,18 @@ public interface MuseumInfoService {
    /**
    /**
     * 标本类型计数
     * 标本类型计数
     * */
     * */
-   List<MuseuminfoTypeVO> MuseumInfoBySampleType(Integer sampleType);
+   Integer MuseumInfoBySampleType(Integer sampleType);
    /**
    /**
     * 标本出入库状态计数
     * 标本出入库状态计数
     * */
     * */
-   List<MuseuminfoMonthSaveVO> MuseumInfoBySaveJoin(Integer save);
+//
+    Integer MuseumInfoBySaveJoin(Integer month,Integer currentYear);
+
 
 
-   List<MuseuminfoMonthSaveVO> MuseumInfoBySaveOut(Integer save);
+   Integer MuseumInfoBySaveOut(Integer month,Integer currentYear);
 
 
    /**
    /**
     * 标本来源计数(年)
     * 标本来源计数(年)
     * */
     * */
-   List<MuseuminfoOriginVO> MuseumInfoByOrigin(Integer origin);
+   Integer MuseumInfoByOrigin(Integer year, Integer origin);
 }
 }

+ 8 - 13
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/service/museuminfo/MuseumInfoServiceImpl.java

@@ -43,12 +43,7 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
    @Override
    @Override
    public void deleteMuseumInfo(Integer id,String reason) {
    public void deleteMuseumInfo(Integer id,String reason) {
       museumInfoMapper.deleteMuseumInfo(id,reason);
       museumInfoMapper.deleteMuseumInfo(id,reason);
-//      museumInfoMapper.deleteById(id);
    }
    }
-   /**
-    * 删除标本
-    */
-
    /**
    /**
     * 查询标本id
     * 查询标本id
     */
     */
@@ -61,7 +56,7 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
     * 查询标本编号
     * 查询标本编号
     */
     */
    @Override
    @Override
-   public MuseumInfoDO getMuseumInfoBySampleId (String sampleId) {
+   public List<MuseumInfoDO> getMuseumInfoBySampleId (String sampleId) {
       return museumInfoMapper.getMuseumInfoBySampleId(sampleId);
       return museumInfoMapper.getMuseumInfoBySampleId(sampleId);
    }
    }
    /**
    /**
@@ -82,27 +77,27 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
     * 标本类型计数
     * 标本类型计数
     * */
     * */
    @Override
    @Override
-   public List<MuseuminfoTypeVO> MuseumInfoBySampleType(Integer sampleType){
+   public Integer MuseumInfoBySampleType(Integer sampleType){
       return museumInfoMapper.countMuseumInfoBySampleType(sampleType);
       return museumInfoMapper.countMuseumInfoBySampleType(sampleType);
    }
    }
    /**
    /**
     * 标本出入库状态计数
     * 标本出入库状态计数
     * */
     * */
    @Override
    @Override
-   public List<MuseuminfoMonthSaveVO> MuseumInfoBySaveJoin(Integer save) {
-      return museumInfoMapper.countMuseumInfoBySaveJoin(save);
+   public Integer MuseumInfoBySaveJoin(Integer month,Integer currentYear) {
+      return museumInfoMapper.countMuseumInfoBySaveJoin(month,currentYear);
    }
    }
 
 
    @Override
    @Override
-   public List<MuseuminfoMonthSaveVO> MuseumInfoBySaveOut(Integer save) {
-      return museumInfoMapper.countMuseumInfoBySaveOut(save);
+   public Integer MuseumInfoBySaveOut(Integer month,Integer currentYear) {
+      return museumInfoMapper.countMuseumInfoBySaveOut(month,currentYear);
    }
    }
    /**
    /**
     * 标本来源计数(年)
     * 标本来源计数(年)
     * */
     * */
    @Override
    @Override
-   public List<MuseuminfoOriginVO> MuseumInfoByOrigin(Integer origin) {
-      return museumInfoMapper.countMuseumInfoByOrigin(origin);
+   public Integer MuseumInfoByOrigin(Integer year, Integer origin) {
+      return museumInfoMapper.countMuseumInfoByOrigin(year,origin);
    }
    }
 }
 }