From 096296cd7485c5583c8194d88cca700e3c4d84a0 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期一, 01 十二月 2025 16:50:42 +0800
Subject: [PATCH] 调整基础配置信息查询方式,取消jpa

---
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DeviceIotService.java |   72 +++++++++++++++++++++++++++---------
 1 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DeviceIotService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DeviceIotService.java
index b147541..197d39c 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DeviceIotService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DeviceIotService.java
@@ -1,15 +1,16 @@
 package com.fzzy.igds.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.fzzy.igds.constant.RedisConst;
+import com.fzzy.igds.data.DeviceIotParam;
 import com.fzzy.igds.domain.DeviceIot;
-import com.fzzy.igds.repository.DeviceIotRepository;
+import com.fzzy.igds.mapper.DeviceIotMapper;
 import com.fzzy.igds.utils.ContextUtil;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.domain.Specification;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.*;
@@ -27,17 +28,46 @@
     @Resource
     private RedisCache redisCache;
     @Resource
-    private DeviceIotRepository deviceIotRepository;
+    private DeviceIotMapper deviceIotMapper;
 
     /**
-     * JPA鍒嗛〉鏌ヨ鏁版嵁
-     *
-     * @param specification
-     * @param pageable
-     * @return
+     * 鍒嗛〉鏌ヨ鏁版嵁
+     * @param page
+     * @param param
      */
-    public Page<DeviceIot> findAll(Specification<DeviceIot> specification, Pageable pageable) {
-        return deviceIotRepository.findAll(specification, pageable);
+    public void listPageData(Page<DeviceIot> page, DeviceIotParam param) {
+        QueryWrapper<DeviceIot> queryWrapper = new QueryWrapper<>();
+
+        param.setCompanyId(ContextUtil.getCompanyId());
+        param.setDeptId(ContextUtil.subDeptId(null));
+        queryWrapper.eq("company_id", param.getCompanyId());
+        queryWrapper.eq("dept_id", param.getDeptId());
+
+        if (StringUtils.isNotBlank(param.getDepotId())) {
+            queryWrapper.eq("depot_id", param.getDepotId());
+        }
+        if (StringUtils.isNotBlank(param.getType())) {
+            queryWrapper.eq("type", param.getType());
+        }
+        if (StringUtils.isNotBlank(param.getSerId())) {
+            queryWrapper.eq("ser_id", param.getSerId());
+        }
+
+        deviceIotMapper.selectPage(page, queryWrapper);
+    }
+
+    /**
+     * 鏍规嵁鏉′欢鏌ヨ
+     * @param companyId
+     */
+    public List<DeviceIot> listData(String companyId) {
+        QueryWrapper<DeviceIot> queryWrapper = new QueryWrapper<>();
+        if (StringUtils.isEmpty(companyId)) {
+            companyId = ContextUtil.getCompanyId();
+        }
+        queryWrapper.eq("company_id", companyId);
+
+        return deviceIotMapper.selectList(queryWrapper);
     }
 
     /**
@@ -55,10 +85,14 @@
             deviceIot.setId(ContextUtil.generateId());
             deviceIot.setCreateBy(ContextUtil.getLoginUserName());
             deviceIot.setCreateTime(new Date());
+            deviceIot.setUpdateBy(ContextUtil.getLoginUserName());
+            deviceIot.setUpdateTime(new Date());
+            deviceIotMapper.insert(deviceIot);
+        }else {
+            deviceIot.setUpdateBy(ContextUtil.getLoginUserName());
+            deviceIot.setUpdateTime(new Date());
+            deviceIotMapper.updateById(deviceIot);
         }
-        deviceIot.setUpdateBy(ContextUtil.getLoginUserName());
-        deviceIot.setUpdateTime(new Date());
-        deviceIotRepository.save(deviceIot);
     }
 
     /**
@@ -66,7 +100,7 @@
      * @param deviceIot
      */
     public void delDepotDeviceIot(DeviceIot deviceIot) {
-        deviceIotRepository.delete(deviceIot);
+        deviceIotMapper.deleteById(deviceIot);
     }
 
     /**
@@ -77,7 +111,9 @@
      * @param posY
      */
     public void updatePos(String deviceId, Double posX, Double posY) {
-        deviceIotRepository.updatePos(deviceId, posX, posY);
+        UpdateWrapper<DeviceIot> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.eq("id", deviceId).set("pos_x", posX).set("pos_y", posY);
+        deviceIotMapper.update(null, updateWrapper);
     }
 
     /**
@@ -89,7 +125,7 @@
             companyId = ContextUtil.getCompanyId();
         }
         // 鑾峰彇鎵�鏈夌殑璁惧淇℃伅
-        List<DeviceIot> listAll =deviceIotRepository.getDeviceIotByCompanyId(companyId);
+        List<DeviceIot> listAll =this.listData(companyId);
 
         if (null != listAll) {
             this.setCacheAllDeviceIot(listAll, companyId);

--
Gitblit v1.9.3