Jelajahi Sumber

优化sosmapper搜索异常

Simon 1 tahun lalu
induk
melakukan
9debecd459

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFallSolveMapper.java

@@ -25,7 +25,7 @@ public interface TFallSolveMapper {
      * @param aid 跌倒告警主键
      * @return 跌倒告警
      */
-    public TFallSolve selectTFallSolveByAid(Integer aid);
+    public List<TFallSolve> selectTFallSolveByAid(Integer aid);
 
     /**
      * 查询跌倒告警列表

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/ITFallSolveService.java

@@ -25,7 +25,7 @@ public interface ITFallSolveService {
      * @param aid 跌倒告警主键
      * @return 跌倒告警
      */
-    public TFallSolve selectTFallSolveByAid(Integer aid);
+    public List<TFallSolve> selectTFallSolveByAid(Integer aid);
 
     /**
      * 查询跌倒告警列表

+ 8 - 11
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java

@@ -266,18 +266,15 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
      * @return 结果
      */
     @Override
+    @Transactional
     public int deleteTDeviceListByIds(Integer[] ids) {
-        List<TDeviceList> tDeviceLists = tDeviceListMapper.selectTDeviceList();
-        if (StringUtils.isNotEmpty(ids)) {
-            for (Integer id : ids) {
-                for (TDeviceList tDevice : tDeviceLists) {
-                    if (tDevice.getId().equals(id)) {
-                        TFacility tFacility = tFacilityMapper.selectTFacilityByCode(tDevice.getDeviceId());
-                        if (StringUtils.isNotNull(tFacility)) {
-                            tFacilityMapper.deleteTFacilityById(tFacility.getId());
-                        }
-                    }
-                }
+        if (ids == null) {
+            return 0;
+        }
+        for (Integer id : ids) {
+            TDeviceList deviceList = tDeviceListMapper.selectTDeviceListById(id);
+            if (deviceList != null && deviceList.getDeviceId() != null && !StringUtils.isEmpty(deviceList.getDeviceId())) {
+                tFacilityMapper.deleteTFacilityByCode(deviceList.getDeviceId());
             }
         }
         return tDeviceListMapper.deleteTDeviceListByIds(ids);

+ 7 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TFallSolveServiceImpl.java

@@ -33,7 +33,7 @@ public class TFallSolveServiceImpl implements ITFallSolveService {
     }
 
     @Override
-    public TFallSolve selectTFallSolveByAid(Integer aid) {
+    public List<TFallSolve> selectTFallSolveByAid(Integer aid) {
         return tFallSolveMapper.selectTFallSolveByAid(aid);
     }
 
@@ -56,11 +56,14 @@ public class TFallSolveServiceImpl implements ITFallSolveService {
      */
     @Override
     public int insertTFallSolve(TFallSolve tFallSolve) {
-        if (StringUtils.isNull(this.selectTFallSolveByAid(tFallSolve.getAid()))){
+        //TODO 还有问题
+        List<TFallSolve> tFallSolves = this.selectTFallSolveByAid(tFallSolve.getAid());
+        if (tFallSolves != null && !tFallSolves.isEmpty()) {
+            tFallSolve.setUpdateTime(DateUtils.getNowDate());
+            return tFallSolveMapper.updateTFallSolve(tFallSolve);
+        } else {
             tFallSolve.setCreateTime(DateUtils.getNowDate());
             return tFallSolveMapper.insertTFallSolve(tFallSolve);
-        }else{
-            return tFallSolveMapper.updateTFallSolve(tFallSolve);
         }
     }