Просмотр исходного кода

Merge branch 'refs/heads/feature-sort-lihb-20250910' into dev

LHB 1 неделя назад
Родитель
Сommit
0f30310c6a

+ 11 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -818,4 +818,15 @@ public class TrialDetectionController extends BladeController {
         });
         return R.data(trailDeviceUseInfoDTOS);
     }
+
+    /**
+     * 根据 设备id 查询 设备信息以及设备使用信息
+     */
+    @PostMapping("/self/updateSort")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "根据类型修改排序", notes = "deviceInfoIds")
+    public R updateSort(@RequestBody TrialSelfInspectionRecordPageDTO dto) {
+        iTrialSelfInspectionRecordService.updateSort(dto);
+        return R.success("成功");
+    }
 }

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java

@@ -47,4 +47,6 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
     R getSamplePdfUrl(String id,String contrctId);
 
     Long saveBaseInfo(TrialSeleInspectionRecordInfoDTO vo);
+
+    void updateSort(TrialSelfInspectionRecordPageDTO dto);
 }

+ 1 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDetectionDataServiceImpl.java

@@ -1,5 +1,6 @@
 package org.springblade.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;

+ 31 - 12
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -145,17 +146,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryStatus())) {
                 queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, dto.getQueryStatus());
             }
-            if (dto.getSortType() != null) {
-                if (dto.getSortType().equals("1")) {
-                    queryWrapper.lambda().orderByAsc(TrialSelfInspectionRecord::getReportNo);
-                } else if (dto.getSortType().equals("2")) {
-                    queryWrapper.lambda().orderByDesc(TrialSelfInspectionRecord::getReportNo);
-                } else if (dto.getSortType().equals("3")) {
-                    queryWrapper.lambda().orderByAsc(Arrays.asList(TrialSelfInspectionRecord::getSpecificationModel, TrialSelfInspectionRecord::getReportNo));
-                } else if (dto.getSortType().equals("4")) {
-                    queryWrapper.lambda().orderByDesc(Arrays.asList(TrialSelfInspectionRecord::getSpecificationModel, TrialSelfInspectionRecord::getReportNo));
-                }
-            }
+            queryWrapper.lambda().orderByAsc(TrialSelfInspectionRecord::getSort);
 
             IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(true, TrialSelfInspectionRecord::getCreateTime));
             IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
@@ -2374,5 +2365,33 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         return record.getId();
     }
 
-
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateSort(TrialSelfInspectionRecordPageDTO dto) {
+        LambdaQueryWrapper<TrialSelfInspectionRecord> queryWrapper = Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
+                .eq(TrialSelfInspectionRecord::getNodeId, dto.getNodeId())
+                .eq(TrialSelfInspectionRecord::getType, dto.getType())
+                .eq(TrialSelfInspectionRecord::getContractId, dto.getContractId())
+                .eq(TrialSelfInspectionRecord::getIsDeleted, 0);
+        if (dto.getSortType() != null) {
+            if (dto.getSortType().equals("1")) {
+                queryWrapper.orderByAsc(TrialSelfInspectionRecord::getReportNo);
+            } else if (dto.getSortType().equals("2")) {
+                queryWrapper.orderByDesc(TrialSelfInspectionRecord::getReportNo);
+            } else if (dto.getSortType().equals("3")) {
+                queryWrapper.orderByAsc(Arrays.asList(TrialSelfInspectionRecord::getSpecificationModel, TrialSelfInspectionRecord::getReportNo));
+            } else if (dto.getSortType().equals("4")) {
+                queryWrapper.orderByDesc(Arrays.asList(TrialSelfInspectionRecord::getSpecificationModel, TrialSelfInspectionRecord::getReportNo));
+            }
+        }
+        List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectList(queryWrapper);
+
+        if (CollectionUtil.isNotEmpty(trialSelfInspectionRecords)) {
+            for (int i = 0; i < trialSelfInspectionRecords.size(); i++) {
+                trialSelfInspectionRecords.get(i).setSort(i + 1);
+            }
+            //修改排序为连续排序
+            updateBatchById(trialSelfInspectionRecords);
+        }
+    }
 }