Browse Source

解决了分页问题

lwh 4 months ago
parent
commit
7d544e296a

+ 5 - 5
yudao-module-museum/yudao-module-museum-biz/pom.xml

@@ -12,11 +12,11 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>9</source>
-                    <target>9</target>
-                    <compilerArgs>--enable-preview</compilerArgs>
-                </configuration>
+<!--                <configuration>-->
+<!--                    <source>9</source>-->
+<!--                    <target>9</target>-->
+<!--                    <compilerArgs>&#45;&#45;enable-preview</compilerArgs>-->
+<!--                </configuration>-->
             </plugin>
         </plugins>
     </build>

+ 2 - 2
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museumflow/MuseumFlowController.java

@@ -135,7 +135,7 @@ public class MuseumFlowController {
                 return CommonResult.error(200, "标本不存在");
             } else {
                 if (event == null) {
-                    int Save = result.getSave();
+                    int Save = result.getStore();
                     if (Save == 1) {
                         LocalDateTime applyTime = LocalDateTime.now();
                         saveVO.setApplyTime(applyTime);
@@ -357,7 +357,7 @@ public class MuseumFlowController {
             if (event == null) {
                 return CommonResult.error(200, "标本未申请出库");
             } else {
-                int Save = result.getSave();
+                int Save = result.getStore();
                 if (Save == 0) {
                     int State = event.getState();
                     if (State == 0) {

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

@@ -173,22 +173,10 @@ public class MuseumInfoController {
         int currentYear =date.getYear();
         List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
         for (int month = 1 ; month <= 12 ; month++) {
-            int sample_number =0;
-            List<String> number =museumInfoService.MuseumInfoBySaveOut(month,currentYear);
-            MuseuminfoMonthSaveVO  re = new MuseuminfoMonthSaveVO();
+            int number = countSampleNumbers(museumInfoService.MuseumInfoBySaveOut(month, currentYear));
+            MuseuminfoMonthSaveVO re = new MuseuminfoMonthSaveVO();
             re.setMonth(month);
-
-            if (number == null) {
-                re.setCount(0);
-            }else {
-                for (String numberStr : number) {
-
-                    String[] groupElements = numberStr.split(",");
-                    // 累加元素数量(每个元素为一组)
-                    sample_number += groupElements.length;
-                }
-                re.setCount(sample_number);
-            }
+            re.setCount(number);
             result.add(re);
         }
         return CommonResult.success(result);
@@ -245,11 +233,10 @@ public class MuseumInfoController {
         }
         int count = 0;
         for (String numberStr : number) {
-
+            //消除空格
             String processedStr = numberStr.replaceAll("\\[|\\]","");
             // 按逗号分割元素
             String[] groupElements = processedStr.split(",");
-
             count += groupElements.length;
         }
         return count;
@@ -261,7 +248,6 @@ public class MuseumInfoController {
     @Operation(summary = "标本来源计数")
     public CommonResult<List<Map<Integer,Object>>> getOrigin(){
 //        来源:采购-1 捐赠-2 采集-3 其他-4
-
         List<Map<Integer,Object>> result = new ArrayList<>();
         LocalDate date = LocalDate.now();
         int currentYear =date.getYear();

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

@@ -62,16 +62,16 @@ public class MuseumInfoRespVO {
     private String origin;
 
     @Schema(description = "描述")
-    private String character;
+    private String bewrite;
 
     @Schema(description = "馆藏状态")
-    private Integer save;
+    private Integer store;
 
     @Schema(description = "入库时间")
-    private LocalDateTime sampleSaveTime;
+    private LocalDateTime storeTime;
 
     @Schema(description = "用途")
-    private String Use;
+    private String way;
 
     @Schema(description = "资产号")
     private String fundId;

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

@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import javax.swing.*;
+
 import java.time.LocalDateTime;
 
 @Schema(description = "博物馆-标本信息 save VO")
@@ -59,16 +59,16 @@ public class MuseumInfoSaveVO {
     private String origin;
 
     @Schema(description = "描述")
-    private String character;
+    private String bewrite;
 
     @Schema(description = "馆藏状态")
-    private Integer save;
+    private Integer store;
 
     @Schema(description = "入库时间")
-    private LocalDateTime sampleSaveTime;
+    private LocalDateTime storeTime;
 
     @Schema(description = "用途")
-    private String Use;
+    private String way;
 
     @Schema(description = "资产号")
     private String fundId;

+ 54 - 56
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseuminfoImportExcelVO.java

@@ -37,63 +37,61 @@ public class MuseuminfoImportExcelVO {
     @Ignore
     private Integer sampleType;
 
+    @ExcelProperty("英文名称")
+    private String englishName;
 
+    @ExcelProperty("国际名称")
+    private String internationName;
 
-//    @Schema(description = "英文名称")
-//    private String englishName;
-//
-//    @Schema(description = "国际名称")
-//    private String internationName;
-//
-//    @Schema(description = "保存类型")
-//    private Integer keepType;
-//
-//    @Schema(description = "成份")
-//    private String element;
-//
-//    @Schema(description = "产地")
-//    private String  local;
-//
-//    @Schema(description = "时代")
-//    private LocalDateTime bronTime ;
-//
-//    @Schema(description = "保存地层")
-//    private String stratum;
-//
-//    @Schema(description = "发现时间")
-//    private LocalDateTime findTime;
-//
-//    @Schema(description = "尺寸")
-//    private String size;
-//
-//    @Schema(description = "重量")
-//    private Long weight;
-//
-//    @Schema(description = "来源")
-//    private String origin;
-//
-//    @Schema(description = "描述")
-//    private String character;
-//
-//    @Schema(description = "馆藏状态")
-//    private Integer save;
-//
-//    @Schema(description = "入库时间")
-//    private LocalDateTime sampleSaveTime;
-//
-//    @Schema(description = "用途")
-//    private String Use;
-//
-//    @Schema(description = "资产号")
-//    private String fundId;
-//
-//    @Schema(description = "删除原因")
-//    private String reason;
-//
-//    @Schema(description = "标本图片")
-//    private List<String> picture;
-//
-//    @Schema(description = "备注")
-//    private String sampleTip;
+    @ExcelProperty("保存类型")
+    private Integer keepType;
+
+    @ExcelProperty("成份")
+    private String element;
+
+    @ExcelProperty("产地")
+    private String  local;
+
+    @ExcelProperty("时代")
+    private LocalDateTime bronTime ;
+
+    @ExcelProperty("保存地层")
+    private String stratum;
+
+    @ExcelProperty("发现时间")
+    private LocalDateTime findTime;
+
+    @ExcelProperty("尺寸")
+    private String size;
+
+    @ExcelProperty("重量")
+    private Long weight;
+
+    @ExcelProperty("来源")
+    private String origin;
+
+    @ExcelProperty("描述")
+    private String bewrite;
+
+    @ExcelProperty("馆藏状态")
+    private Integer store;
+
+    @ExcelProperty("入库时间")
+    private LocalDateTime storeTime;
+
+    @ExcelProperty("用途")
+    private String way;
+
+    @ExcelProperty("资产号")
+    private String fundId;
+
+    @ExcelProperty("删除原因")
+    private String reason;
+
+    @ExcelProperty("标本图片")
+    private List<String> picture;
+
+    @ExcelProperty("备注")
+    private String sampleTip;
 }
 

+ 4 - 4
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/dal/database/museuminfo/MuseumInfoDO.java

@@ -87,19 +87,19 @@ public class MuseumInfoDO extends BaseDO {
     /**
      * 描述
      */
-    private String character;
+    private String bewrite;
     /**
      * 馆藏状态
      */
-    private Integer save;
+    private Integer store;
     /**
      * 入库时间
      */
-    private LocalDateTime sampleSaveTime;
+    private LocalDateTime storeTime;
     /**
      * 用途
      */
-    private String Use;
+    private String way;
     /**
      * 资产号
      */

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

@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo.*;
 import cn.iocoder.yudao.module.museum.dal.database.museumflow.MuseumFlowDO;
 import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -21,17 +22,23 @@ public interface MuseumInfoMapper extends BaseMapperX<MuseumInfoDO> {
     /**
      * 更新标本
      */
-    @Update("UPDATE museum_info SET sample_id=#{sampleId},chinese_name=#{chineseName} WHERE id =#{id}")
+    @Update("UPDATE museum_info SET sample_id=#{sampleId}, sample_type=#{sampleType}, "+
+            " place=#{place}, chinese_name=#{chineseName}, english_name=#{englishName}, "+
+            " internation_name=#{internationName}, keep_type=#{keepType}, element=#{element}, " +
+            " local=#{local}, bron_time=#{bronTime}, stratum=#{stratum}, find_time=#{findTime}, " +
+            " size=#{size}, weight=#{weight}, origin=#{origin}, bewrite=#{bewrite}, " +
+            " store=#{store}, store_time=#{storeTime}, way=#{way}, fund_id=#{fundId}, " +
+            " reason=#{reason}, picture=#{picture}, sample_tip=#{sampleTip} WHERE id =#{id}")
     void updateMuseumInfo(MuseumInfoDO museumInfoDO);
     /**
      * 标本出库
      */
-    @Update("UPDATE museum_info SET save=0  WHERE id =#{id}")
+    @Update("UPDATE museum_info SET store=0  WHERE id =#{id}")
     void outSampleMuseumInfo(@Param("id")Integer id);
     /**
      * 标本回库
      */
-    @Update("UPDATE museum_info SET save=1  WHERE id =#{id}")
+    @Update("UPDATE museum_info SET store=1  WHERE id =#{id}")
     void backSampleMuseumInfo(@Param("id")Integer id);
     /**
      * 删除标本
@@ -76,9 +83,9 @@ public interface MuseumInfoMapper extends BaseMapperX<MuseumInfoDO> {
     @Select("SELECT" +
             " COUNT(*)"+
             " FROM museum_info " +
-            " WHERE deleted =0 AND save =1"+
-            " AND DATE_FORMAT(sample_save_time,'%m') = #{month}"+
-            " AND DATE_FORMAT(sample_save_time,'%Y') = #{currentYear}")
+            " WHERE deleted =0 AND store =1"+
+            " AND DATE_FORMAT(store_time,'%m') = #{month}"+
+            " AND DATE_FORMAT(store_time,'%Y') = #{currentYear}")
     Integer countMuseumInfoBySaveJoin(@Param("month") Integer month,@Param("currentYear") Integer currentYear);
     /**
      * 标本出库状态计数
@@ -108,8 +115,8 @@ public interface MuseumInfoMapper extends BaseMapperX<MuseumInfoDO> {
     @Select("SELECT" +
             " COUNT(*)"+
             " FROM museum_info " +
-            " WHERE deleted =0 AND save =1"+
-            " AND DATE_FORMAT(sample_save_time,'%Y') = #{currentYear}")
+            " WHERE deleted =0 AND store =1"+
+            " AND DATE_FORMAT(store_time,'%Y') = #{currentYear}")
     Integer countMuseumInfoYearJoin(@Param("currentYear") Integer currentYear);
 
     @Select("SELECT" +
@@ -127,8 +134,8 @@ public interface MuseumInfoMapper extends BaseMapperX<MuseumInfoDO> {
     @Select("SELECT" +
             " COUNT(*)"+
             " FROM museum_info " +
-            " WHERE deleted =0 AND save =1"+
-            " AND DATE_FORMAT(sample_save_time,'%Y') = #{year}"+
+            " WHERE deleted =0 AND store =1"+
+            " AND DATE_FORMAT(store_time,'%Y') = #{year}"+
             " AND origin = #{origin}")
     Integer countMuseumInfoByOrigin(@Param("year") Integer year, @Param("origin") Integer origin);
 

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

@@ -37,25 +37,25 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
    @LogRecord(type = MUSEUM_TYPE, subType = CREATE_SUB_TYPE, bizNo = "{{#sampleId.id}}",
            success =  CREATE_SUB_TYPE_SUCCESS)
    public Integer createMuseumInfo(MuseumInfoSaveVO saveVO) {
-      MuseumInfoDO sampleId = BeanUtils.toBean(saveVO, MuseumInfoDO.class);
-      museumInfoMapper.insert(sampleId);
-      LogRecordContext.putVariable("sampleId", sampleId );
-      return sampleId.getId();
+      MuseumInfoDO sample = BeanUtils.toBean(saveVO, MuseumInfoDO.class);
+      museumInfoMapper.insert(sample);
+      LogRecordContext.putVariable("sample", sample );
+      return sample.getId();
    }
    /**
     * 更新标本
     */
-
    @LogRecord(type = MUSEUM_TYPE, subType = UPDATE_SUB_TYPE, bizNo = "{{#sampleId.id}}",
            success = UPDATE_SUB_TYPE_SUCCESS)
    @Override
    public void updateSampleMuseumInfo(MuseumInfoSaveVO saveVO) {
-      MuseumInfoDO sampleId = BeanUtils.toBean(saveVO,MuseumInfoDO.class);
-      museumInfoMapper.updateMuseumInfo(sampleId);
-//      museumInfoMapper.updateById(sampleId);
-      LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(sampleId, MuseumInfoSaveVO.class));
-      LogRecordContext.putVariable("sampleId", sampleId );
+      MuseumInfoDO sample = BeanUtils.toBean(saveVO,MuseumInfoDO.class);
+
+      museumInfoMapper.updateMuseumInfo(sample);
+      LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(sample, MuseumInfoSaveVO.class));
+      LogRecordContext.putVariable("sample", sample );
    }
+
    /**
     * 标本出库
     */
@@ -63,9 +63,9 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
            success = OUT_MUSEUM_SUB_TYPE_SUCCESS)
    @Override
    public void outSampleMuseumInfo(Integer id){
-      MuseumInfoDO sampleId = museumInfoMapper.selectMuseumInfoById(id);
+      MuseumInfoDO sample = museumInfoMapper.selectMuseumInfoById(id);
       museumInfoMapper.outSampleMuseumInfo(id);
-      LogRecordContext.putVariable("sampleId",sampleId);
+      LogRecordContext.putVariable("sample",sample);
    }
    /**
     * 标本回库
@@ -74,9 +74,9 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
            success = BACK_MUSEUM_SUB_TYPE_SUCCESS)
    @Override
    public void backSampleMuseumInfo(Integer id){
-      MuseumInfoDO sampleId = museumInfoMapper.selectMuseumInfoById(id);
+      MuseumInfoDO sample = museumInfoMapper.selectMuseumInfoById(id);
       museumInfoMapper.backSampleMuseumInfo(id);
-      LogRecordContext.putVariable("sampleId",sampleId);
+      LogRecordContext.putVariable("sample",sample);
    }
    /**
     * 删除标本
@@ -85,9 +85,9 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
    @LogRecord(type = MUSEUM_TYPE, subType = DELETE_SUB_TYPE, bizNo = "{{#sampleId.id}}",
            success = DELETE_SUB_TYPE_SUCCESS)
    public void deleteMuseumInfo(Integer id,String reason) {
-      MuseumInfoDO sampleId = museumInfoMapper.selectMuseumInfoById(id);
+      MuseumInfoDO sample = museumInfoMapper.selectMuseumInfoById(id);
       museumInfoMapper.deleteMuseumInfo(id,reason);
-      LogRecordContext.putVariable("sampleId", sampleId );
+      LogRecordContext.putVariable("sample", sample );
    }
    /**
     * 查询标本id
@@ -178,6 +178,20 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
    public Integer MuseumInfoByOrigin(Integer year, Integer origin) {
       return museumInfoMapper.countMuseumInfoByOrigin(year,origin);
    }
+   private Integer  transformSampleType(String sampleType) {
+      if (sampleType==null){
+         return null;
+      }else if (sampleType.equals("矿石")){
+         return 1;
+      }else if (sampleType.equals("岩石")){
+         return 2;
+      }else if (sampleType.equals("矿物")){
+         return 3;
+      }else if (sampleType.equals("陨石")){
+         return 4;
+      }
+      throw new IllegalArgumentException("无效的标本类型: " + sampleType);
+   }
    /**
     * 批量导入用户
     *
@@ -192,8 +206,8 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
       MuseuminfoImportRespVO respVO = MuseuminfoImportRespVO.builder().createSampleIds(new ArrayList<>())
               .updateSampleIds(new ArrayList<>()).failureSampleIds(new LinkedHashMap<>()).build();
       importSamples.forEach(importSample -> {
-
-         try {// 2.1.2 校验,判断是否有不符合的原因
+         // 2.1.2 校验,判断是否有不符合的原因
+         try {
             museumInfoForCreateOrUpdate(null,importSample.getSampleId() );
          } catch (ServiceException ex) {
             respVO.getFailureSampleIds().put(importSample.getSampleId(), ex.getMessage());
@@ -236,30 +250,13 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
    private MuseumInfoDO museumInfoForCreateOrUpdate(Integer id, String sampleId) {
       // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
       return DataPermissionUtils.executeIgnore(() -> {
-         // 校验标本存在
+         // 校验标本
          MuseumInfoDO sample = museumInfoExists(id);
          // 校验标本编号唯一
          museumInfoSampleIdUnique(id, sampleId);
-         // 转换标本类型
          return sample;
       });
    }
-
-   private Integer  transformSampleType(String sampleType) {
-     if (sampleType==null){
-        return null;
-     }else if (sampleType.equals("矿石")){
-        return 1;
-     }else if (sampleType.equals("岩石")){
-        return 2;
-     }else if (sampleType.equals("矿物")){
-        return 3;
-     }else if (sampleType.equals("陨石")){
-      return 4;
-   }
-      throw new IllegalArgumentException("无效的标本类型: " + sampleType);
-   }
-
       MuseumInfoDO museumInfoExists(Integer id) {
          if (id == null) {
             return null;
@@ -281,6 +278,7 @@ public  class  MuseumInfoServiceImpl implements MuseumInfoService {
             return;
          }
          // TODO sample不为空
+         // 如果 id 为空,说明不用比较是否为相同 id 的标本
          if (id == null) {
             throw exception(SAMPLE_ID_EXISTS);
          }