|
@@ -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));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|