From 48c2e5ffb3f9ad3509006e50f3142ea4d0e7f619 Mon Sep 17 00:00:00 2001
From: Jay <csj123456>
Date: 星期三, 16 十月 2024 09:32:16 +0800
Subject: [PATCH] 修改拼接sql逻辑以及返回逻辑

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java |   51 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
index b410b7f..4f28365 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -1,7 +1,9 @@
 package com.iailab.module.data.point.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.iailab.framework.common.pojo.PageResult;
 import com.iailab.framework.common.util.object.ConvertUtils;
@@ -18,9 +20,8 @@
 import com.iailab.module.data.point.service.DaPointService;
 import com.iailab.module.data.point.service.DaSequenceNumService;
 import com.iailab.module.data.point.vo.DaPointPageReqVO;
-import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
@@ -48,8 +49,9 @@
 
 
     @Override
-    public PageResult<DaPointEntity> queryPage(DaPointPageReqVO reqVO) {
-        return daPointDao.selectPage(reqVO);
+    public PageResult<DaPointDTO> queryPage(DaPointPageReqVO reqVO) {
+        IPage<DaPointDTO> page = daPointDao.selectPage(reqVO);
+        return new PageResult<DaPointDTO>(page.getRecords(), page.getTotal());
     }
 
     @Override
@@ -71,26 +73,35 @@
     }
 
     @Override
+    public DaPointDTO getSimpleInfoById(String id) {
+        return ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class);
+    }
+
+    @Override
+    public DaPointDTO getSimpleInfoByNo(String no) {
+        QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("pointNo", no);
+        return ConvertUtils.sourceToTarget(daPointDao.selectOne(queryWrapper), DaPointDTO.class);
+    }
+
+    @Override
     public List<DaPointDTO> list(Map<String, Object> params) {
-        String page = (String) params.get("page");
-        String limit = (String) params.get("limit");
-        String pointType = (String)params.get("pointType");
+        Object pointType = params.get("pointType");
         List<String> pointNos = new ArrayList<>();
         if (params.get("pointNos") != null) {
             pointNos = JSONArray.parseArray(JSONArray.toJSONString(params.get("pointNos")), String.class);
         }
-        String pointNoLike = (String)params.get("pointNoLike");
+        Object pointNoLike = params.get("pointNoLike");
         QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper();
-        queryWrapper.eq(StringUtils.isNotBlank(pointType), "point_type", pointType)
-        .in(!CollectionUtils.isEmpty(pointNos),"point_no", pointNos)
-        .like(StringUtils.isNotBlank(pointNoLike), "point_no", pointNoLike)
-                .last("limit 1, 10");
+        queryWrapper.eq(!ObjectUtils.isEmpty(pointType), "point_type", pointType);
+        queryWrapper.in(pointNos.size() != 0,"point_no", pointNos);
+        queryWrapper.like(!ObjectUtils.isEmpty(pointNoLike), "point_no", pointNoLike);
         List<DaPointEntity> list = daPointDao.selectList(queryWrapper);
         return ConvertUtils.sourceToTarget(list, DaPointDTO.class);
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    @DSTransactional(rollbackFor = Exception.class)
     public void add(DaPointDTO dataPoint) {
         DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class);
         daPointEntity.setId(UUID.randomUUID().toString());
@@ -113,7 +124,7 @@
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    @DSTransactional(rollbackFor = Exception.class)
     public void update(DaPointDTO dataPoint) {
         DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class);
         daPointEntity.setUpdateTime(new Date());
@@ -124,17 +135,17 @@
             measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
             measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
             daMeasurePointService.update(measurePoint);
-        } else if (PointTypeEnum.CALCULATE_POINT.equals(dataPoint.getPointType())) {
+        } else if (PointTypeEnum.CALCULATE_POINT.getName().equals(dataPoint.getPointType())) {
             daMathPointService.update(dataPoint.getMathPoint());
         }
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void delete(String[] ids) {
-        daPointDao.deleteBatchIds(Arrays.asList(ids));
-        daMeasurePointService.deleteByPoint(ids);
-        daMathPointService.deleteByPoint(ids);
+    @DSTransactional(rollbackFor = Exception.class)
+    public void delete(String[] id) {
+        daPointDao.deleteBatchIds(Arrays.asList(id));
+        daMeasurePointService.deleteByPoint(id);
+        daMathPointService.deleteByPoint(id);
     }
 
     @Override

--
Gitblit v1.9.3