Parcourir la source

停水公告相关接口优化

王苗苗 il y a 6 jours
Parent
commit
e1f1c042e0

+ 2 - 1
slibra-system/src/main/java/com/slibra/business/service/impl/File2Text.java

@@ -162,7 +162,8 @@ public class File2Text {
         final String appKey = "OKt6jogp6fRjHQVp";
 //        String fileLink = "https://gw.alipayobjects.com/os/bmw-prod/0574ee2e-f494-45a5-820f-63aee583045a.wav";
 //        String fileLink = "https://static.fuxicarbon.com/test/234527-I-0168-15765398611-S.wav";
-        String fileLink = "http://192.168.100.159/voice/005cad2d-3626-477c-8b95-07b68f339630.wav";
+//        String fileLink = "http://192.168.100.159/voice/005cad2d-3626-477c-8b95-07b68f339630.wav";
+        String fileLink = "https://static.fuxicarbon.com/userupload/ttt.wav";
 //        String fileLink = "https://www.w3school.com.cn/i/audio/song.mp3";
         File2Text demo = new File2Text(accessKeyId, accessKeySecret);
         // 第一步:提交录音文件识别请求,获取任务ID用于后续的识别结果轮询。

+ 48 - 11
slibra-system/src/main/java/com/slibra/business/service/impl/TCutOffWaterServiceImpl.java

@@ -50,7 +50,11 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
     @Override
     public TCutOffWater selectTCutOffWaterById(Long id)
     {
-        return tCutOffWaterMapper.selectTCutOffWaterById(id);
+        TCutOffWater tCutOffWater = tCutOffWaterMapper.selectTCutOffWaterById(id);
+        if(!Objects.isNull(tCutOffWater)){
+            this.addExtra(tCutOffWater);
+        }
+        return tCutOffWater;
     }
 
     /**
@@ -125,19 +129,12 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
         tCutOffWater.setCreateTime(DateUtils.getNowDate());
         int i = tCutOffWaterMapper.insertTCutOffWater(tCutOffWater);
         //保存关联表
-        List<CutOffExtraRes> extraResList = tCutOffWater.getExtraResList();
-        if(!CollectionUtils.isEmpty(extraResList)){
-            for (CutOffExtraRes cutOffExtraRes : extraResList) {
-                TCutOffWaterExtra tCutOffWaterExtra = new TCutOffWaterExtra();
-                tCutOffWaterExtra.setCutOffWaterId(tCutOffWater.getId());
-                tCutOffWaterExtra.setPumpingStationId(cutOffExtraRes.getPumpingStationId());
-                tCutOffWaterExtra.setNeighborhoodId(cutOffExtraRes.getNeighbourhoodId());
-                this.tCutOffWaterExtraMapper.insertTCutOffWaterExtra(tCutOffWaterExtra);
-            }
-        }
+        extracted(tCutOffWater);
         return i;
     }
 
+
+
     /**
      * 修改停水信息
      * 
@@ -145,12 +142,19 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
      * @return 结果
      */
     @Override
+    @Transactional
     public int updateTCutOffWater(TCutOffWater tCutOffWater)
     {
         tCutOffWater.setUpdateTime(DateUtils.getNowDate());
+        //删除历史数据
+        deleteHistories(tCutOffWater.getId());
+        //保存关联表
+        extracted(tCutOffWater);
         return tCutOffWaterMapper.updateTCutOffWater(tCutOffWater);
     }
 
+
+
     /**
      * 批量删除停水信息
      * 
@@ -205,4 +209,37 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
         }
         return result;
     }
+
+
+
+
+
+    /**
+     * 保存关联表
+     * @param tCutOffWater
+     */
+    private void extracted(TCutOffWater tCutOffWater) {
+        List<CutOffExtraRes> extraResList = tCutOffWater.getExtraResList();
+        if(!CollectionUtils.isEmpty(extraResList)){
+            for (CutOffExtraRes cutOffExtraRes : extraResList) {
+                TCutOffWaterExtra tCutOffWaterExtra = new TCutOffWaterExtra();
+                tCutOffWaterExtra.setCutOffWaterId(tCutOffWater.getId());
+                tCutOffWaterExtra.setPumpingStationId(cutOffExtraRes.getPumpingStationId());
+                tCutOffWaterExtra.setNeighborhoodId(cutOffExtraRes.getNeighbourhoodId());
+                this.tCutOffWaterExtraMapper.insertTCutOffWaterExtra(tCutOffWaterExtra);
+            }
+        }
+    }
+
+
+    /**
+     * 删除历史数据[停水关联的小区-泵站数据]
+     * @param id
+     */
+    private void deleteHistories(Long id) {
+        List<TCutOffWaterExtra> tCutOffWaterExtras = this.tCutOffWaterExtraMapper.selectTCutOffWaterExtraList(TCutOffWaterExtra.builder().cutOffWaterId(id).build());
+        if(!CollectionUtils.isEmpty(tCutOffWaterExtras)){
+            this.tCutOffWaterExtraMapper.deleteTCutOffWaterExtraByIds(tCutOffWaterExtras.stream().map(TCutOffWaterExtra::getId).toArray(Long[]::new));
+        }
+    }
 }