瀏覽代碼

feat(blind-structures): 修改文件上传为可选并优化数据导入逻辑- 将 `BlindStructuresController` 中的文件参数设为非必需,避免无文件时校验失败
- 在 `BlindStructuresServiceImpl` 中增加对文件是否为空的判断,仅在文件存在时解析和导入数据
- 调整了数据校验与等级插入逻辑的执行条件,确保只在有文件上传时处理相关业务fix(schedule-config): 更新

fugui001 3 月之前
父節點
當前提交
7f7b022acb

+ 7 - 7
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/BlindStructuresController.java

@@ -105,19 +105,19 @@ public class BlindStructuresController extends BaseController {
     @PostMapping(value = "/edit")
      public R<Boolean> edit(
         @RequestPart(name = "BlindStructuresBo") BlindStructuresBo bo,
-        @RequestPart(name = "file") MultipartFile file
+        @RequestPart(name = "file", required = false) MultipartFile file
     ) {
-        if (file == null || file.isEmpty()) {
+      /*  if (file == null || file.isEmpty()) {
             return R.fail("文件为空");
         }
-
+*/
         // 处理文件上传逻辑
-        if (file == null && file.isEmpty()) {
+       /* if (file == null && file.isEmpty()) {
             // TODO: 文件处理逻辑,比如保存到服务器或存储路径
-        /*    String filePath = uploadService.saveFile(file); // 示例方法
-            bo.setFilePath(filePath); // 假设 BO 中有字段记录文件路径*/
+        *//*    String filePath = uploadService.saveFile(file); // 示例方法
+            bo.setFilePath(filePath); // 假设 BO 中有字段记录文件路径*//*
             return R.fail();
-        }
+        }*/
 
         return blindStructuresService.updateByBo(bo,file);
     }

+ 13 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/TournamentsTemplate.java

@@ -104,4 +104,17 @@ public class TournamentsTemplate extends BaseEntity {
 
     private int robotCount;
 
+    /**
+     * 延迟卡时间
+     */
+    private Integer delayCardTime;
+    /**
+     * 延迟卡数量
+     */
+    private Integer delayCardNum;
+    /**
+     * 行动时间(使用卡延时)
+     */
+    private Integer actionTime;
+
 }

+ 38 - 35
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/BlindStructuresServiceImpl.java

@@ -238,54 +238,57 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
             Long userId = LoginHelper.getUserId();
             update.setUpdateUserId(userId);
 
-
             // 1. 解析 Excel 文件
-            List<BlindLevelsImportVo> dataList;
-            try (InputStream inputStream = file.getInputStream()) {
-                dataList = parseExcel(inputStream);
-            } catch (IOException e) {
-                log.error("读取文件失败", e);
-                return R.fail("读取文件失败");
-            }
+            List<BlindLevelsImportVo> dataList = List.of();
+            if (file != null) {
+                try (InputStream inputStream = file.getInputStream()) {
+                    dataList = parseExcel(inputStream);
+                } catch (IOException e) {
+                    log.error("读取文件失败", e);
+                    return R.fail("读取文件失败");
+                }
 
-            if (CollectionUtils.isEmpty(dataList)) {
-                return R.fail("导入数据为空");
+                if (CollectionUtils.isEmpty(dataList)) {
+                    return R.fail("导入数据为空");
+                }
+
+                // 校验数据逻辑(可选)
+                BlindLevelsValidatorUtils.ValidationResult validationResult = BlindLevelsValidatorUtils.validateBlindLevels(dataList);
+                if (validationResult.isValid()) {
+                    System.out.println("数据校验通过");
+                } else {
+                    return R.fail(validationResult.getErrorMessage());
+                }
             }
 
 
-            // 校验数据逻辑(可选)
-            BlindLevelsValidatorUtils.ValidationResult validationResult = BlindLevelsValidatorUtils.validateBlindLevels(dataList);
-            if (validationResult.isValid()) {
-                System.out.println("数据校验通过");
-            } else {
-                return R.fail(validationResult.getErrorMessage());
-            }
 
             // 2. 更新主表
             int i = baseMapper.updateBlindStructuresById(update);
             if (i <= 0) {
                 return R.fail("更新失败");
             }
+            if (file != null) {
+                // 3. 删除原有等级数据
+                Boolean b = blindLevelsService.deleteBlindLevelByBlindStructureId(update.getId());
+                   /* if (!b) {
+                        return R.fail("删除历史等级失败");
+                    }*/
+
+                // 5. 插入新等级数据
+                for (BlindLevelsImportVo vo : dataList) {
+                    BlindLevelsBo levelBo = new BlindLevelsBo();
+                    levelBo.setBlindStructureId(update.getId());
+                    levelBo.setLevelNumber(vo.getLevelNumber());
+                    levelBo.setSmallBlind(vo.getSmallBlind());
+                    levelBo.setBigBlind(vo.getBigBlind());
+                    levelBo.setAnte(vo.getAnte());
+                    levelBo.setDurationMinutes(vo.getDurationMinutes());
+                    levelBo.setCreateUserId(userId);
+                    blindLevelsService.insertByBo(levelBo);
+                }
 
-            // 3. 删除原有等级数据
-            Boolean b = blindLevelsService.deleteBlindLevelByBlindStructureId(update.getId());
-           /* if (!b) {
-                return R.fail("删除历史等级失败");
-            }*/
-
-            // 5. 插入新等级数据
-            for (BlindLevelsImportVo vo : dataList) {
-                BlindLevelsBo levelBo = new BlindLevelsBo();
-                levelBo.setBlindStructureId(update.getId());
-                levelBo.setLevelNumber(vo.getLevelNumber());
-                levelBo.setSmallBlind(vo.getSmallBlind());
-                levelBo.setBigBlind(vo.getBigBlind());
-                levelBo.setAnte(vo.getAnte());
-                levelBo.setDurationMinutes(vo.getDurationMinutes());
-                levelBo.setCreateUserId(userId);
-                blindLevelsService.insertByBo(levelBo);
             }
-
             return R.ok(true); // 成功返回 true
 
         } catch (Exception e) {

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/ScheduleConfigServiceImpl.java

@@ -245,7 +245,7 @@ public class ScheduleConfigServiceImpl implements IScheduleConfigService {
         switch (schemeCode.toUpperCase()) {
             case "DAILY":
                 // 初始化为特定日期
-                endDate = LocalDate.of(2025, 8, 30);
+                endDate = LocalDate.of(2028, 12, 30);
                 generateDailyPlan(configId, startDate, endDate, repeatTypes, execTimes);
                 break;
             case "WEEKLY":

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/TournamentsTemplateServiceImpl.java

@@ -423,9 +423,9 @@ public class TournamentsTemplateServiceImpl implements ITournamentsTemplateServi
     public Boolean updateByBo(TournamentsDto bo) {
         try {
 
-            if(scheduleConfigMapper.selExitConfigByTemplateId(bo.getId())>0){
+          /*  if(scheduleConfigMapper.selExitConfigByTemplateId(bo.getId())>0){
                 throw new RuntimeException("该模版已经被自动化配置了");
-            }
+            }*/
 
             // 转换 BO -> Entity
             TournamentsTemplate update = new TournamentsTemplate();

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentsMapper.xml

@@ -10,11 +10,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectTournamentsVoList" resultType="org.dromara.business.domain.vo.TournamentsVo">
-        SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete FROM tournaments  ${ew.customSqlSegment}
+        SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete,delay_card_time,delay_card_num,action_time FROM tournaments  ${ew.customSqlSegment}
     </select>
 
     <select id="selectVoByIdInfo" resultType="org.dromara.business.domain.vo.TournamentsVo">
-       SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete FROM tournaments WHERE id =  #{id}
+       SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete,delay_card_time,delay_card_num,action_time FROM tournaments WHERE id =  #{id}
     </select>