|
|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
|
* Copyright 2019 DH
|
|
|
* All right reserved.
|
|
|
- * 项目名称: 大恒泰山系统
|
|
|
+ * 项目名称: 运维系统
|
|
|
* 创建日期:2023/10/19
|
|
|
*/
|
|
|
package org.springblade.modules.baseinfo.monitorsite.controller;
|
|
|
@@ -18,8 +18,9 @@ import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.modules.baseinfo.monitorpoint.entity.MonitorPointInfoEntity;
|
|
|
-import org.springblade.modules.baseinfo.monitorpoint.vo.MonitorPointInfoVO;
|
|
|
-import org.springblade.modules.baseinfo.monitorpoint.wrapper.MonitorPointWrapper;
|
|
|
+import org.springblade.modules.baseinfo.monitorpoint.entity.MonitorPointRelEntity;
|
|
|
+import org.springblade.modules.baseinfo.monitorpoint.service.IMonitorPointRelService;
|
|
|
+import org.springblade.modules.baseinfo.monitorpoint.service.IMonitorPointService;
|
|
|
import org.springblade.modules.baseinfo.monitorsite.dto.MonitorSiteInfoDTO;
|
|
|
import org.springblade.modules.baseinfo.monitorsite.entity.MonitorSiteInfoEntity;
|
|
|
import org.springblade.modules.baseinfo.monitorsite.entity.MonitorSiteRelEntity;
|
|
|
@@ -31,7 +32,8 @@ import org.springblade.modules.baseinfo.rtu.entity.RtuInfoEntity;
|
|
|
import org.springblade.modules.baseinfo.rtu.service.IRtuBaseInfoService;
|
|
|
import org.springblade.modules.baseinfo.wateruseconsumer.entity.WaterUseConsumerInfoEntity;
|
|
|
import org.springblade.modules.baseinfo.wateruseconsumer.service.IWaterUseConsumerService;
|
|
|
-import org.springblade.modules.system.entity.Dept;
|
|
|
+import org.springblade.modules.business.rtumanage.entity.RtuStatusEntity;
|
|
|
+import org.springblade.modules.business.rtumanage.service.IRtuManageService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
@@ -54,6 +56,10 @@ public class MonitorSiteController extends BladeController {
|
|
|
private final IMonitorSiteRelService monitorSiteRelService;
|
|
|
private final IRtuBaseInfoService rtuBaseInfoService;
|
|
|
private final IWaterUseConsumerService waterUseConsumerService;
|
|
|
+ private final IMonitorPointRelService monitorPointRelService;
|
|
|
+ private final IMonitorPointService monitorPointService;
|
|
|
+ private final IRtuManageService rtuManageService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 多表联合查询自定义分页
|
|
|
@@ -89,7 +95,6 @@ public class MonitorSiteController extends BladeController {
|
|
|
return R.data(MonitorSiteWrapper.build().listVO(list));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
@@ -101,7 +106,6 @@ public class MonitorSiteController extends BladeController {
|
|
|
return R.data(MonitorSiteWrapper.build().entityVO(detail));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 新增
|
|
|
*/
|
|
|
@@ -109,28 +113,38 @@ public class MonitorSiteController extends BladeController {
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "新增", notes = "")
|
|
|
public R save(@RequestBody MonitorSiteInfoDTO dto) {
|
|
|
- if (monitorSiteService.save(dto)) {
|
|
|
-
|
|
|
- RtuInfoEntity rtuInfoEntity = new RtuInfoEntity();
|
|
|
- rtuInfoEntity.setRtuCode(dto.getWiustCd());
|
|
|
- rtuInfoEntity.setRtuName(dto.getWiustNm());
|
|
|
-// LambdaQueryWrapper<MonitorSiteRelEntity> wrapper = Wrappers.<MonitorSiteRelEntity>query().lambda();
|
|
|
-// wrapper.eq(MonitorSiteRelEntity::getWiustCd, dto.getWiustCd());
|
|
|
-// wrapper.last("limit 1");
|
|
|
-// MonitorSiteRelEntity relEntity = monitorSiteRelService.getOne(wrapper);
|
|
|
- LambdaQueryWrapper<WaterUseConsumerInfoEntity> wrapper2 = Wrappers.<WaterUseConsumerInfoEntity>query().lambda();
|
|
|
- wrapper2.eq(WaterUseConsumerInfoEntity::getWiuCd, dto.getWiuCd());
|
|
|
- wrapper2.last("limit 1");
|
|
|
- WaterUseConsumerInfoEntity waterUseConsumerInfoEntity = waterUseConsumerService.getOne(wrapper2);
|
|
|
+ if (Func.isNull(dto.getWiustCd()) || Func.isNull(dto.getWiuCd())) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<MonitorSiteInfoEntity> wrapper = Wrappers.<MonitorSiteInfoEntity>query().lambda();
|
|
|
+ wrapper.eq(MonitorSiteInfoEntity::getIsDeleted, 0);
|
|
|
+ wrapper.eq(MonitorSiteInfoEntity::getWiustCd, dto.getWiustCd());
|
|
|
+ long count = monitorSiteService.count(wrapper);
|
|
|
+ if (count > 0) {
|
|
|
+ return R.fail("测站已经存在");
|
|
|
+ }
|
|
|
+ //添加RTU
|
|
|
+ RtuInfoEntity rtuInfoEntity = rtuBaseInfoService.rtuInfoByRtuCode(dto.getWiustCd());
|
|
|
+ if (Func.isNull(rtuInfoEntity)) {
|
|
|
+ rtuInfoEntity = new RtuInfoEntity();
|
|
|
+ }
|
|
|
+ rtuInfoEntity.setRtuCode(dto.getWiustCd());
|
|
|
+ rtuInfoEntity.setRtuName(dto.getWiustNm());
|
|
|
+ LambdaQueryWrapper<WaterUseConsumerInfoEntity> wrapper2 = Wrappers.<WaterUseConsumerInfoEntity>query().lambda();
|
|
|
+ wrapper2.eq(WaterUseConsumerInfoEntity::getIsDeleted, 0);
|
|
|
+ wrapper2.eq(WaterUseConsumerInfoEntity::getWiuCd, dto.getWiuCd());
|
|
|
+ WaterUseConsumerInfoEntity waterUseConsumerInfoEntity = waterUseConsumerService.getOne(wrapper2);
|
|
|
+ if (Func.notNull(waterUseConsumerInfoEntity)) {
|
|
|
rtuInfoEntity.setOrgId(waterUseConsumerInfoEntity.getOrgId());
|
|
|
- rtuBaseInfoService.save(rtuInfoEntity);
|
|
|
-
|
|
|
- MonitorSiteRelEntity relEntity = new MonitorSiteRelEntity();
|
|
|
- relEntity.setWiustCd(dto.getWiustCd());
|
|
|
- relEntity.setWiuCd(dto.getWiuCd());
|
|
|
- return R.status(monitorSiteRelService.save(relEntity));
|
|
|
}
|
|
|
- return R.status(false);
|
|
|
+ rtuBaseInfoService.saveOrUpdate(rtuInfoEntity);
|
|
|
+ //测站和用水户关联表
|
|
|
+ monitorSiteRelService.removeRel(dto.getWiustCd());
|
|
|
+ MonitorSiteRelEntity relEntity = new MonitorSiteRelEntity();
|
|
|
+ relEntity.setWiustCd(dto.getWiustCd());
|
|
|
+ relEntity.setWiuCd(dto.getWiuCd());
|
|
|
+ monitorSiteRelService.save(relEntity);
|
|
|
+ return R.status(monitorSiteService.save(dto));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -140,33 +154,17 @@ public class MonitorSiteController extends BladeController {
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
@ApiOperation(value = "修改", notes = "")
|
|
|
public R update(@RequestBody MonitorSiteInfoDTO dto) {
|
|
|
-// LambdaQueryWrapper<MonitorSiteRelEntity> wrapper = Wrappers.<MonitorSiteRelEntity>query().lambda();
|
|
|
-// wrapper.eq(MonitorSiteRelEntity::getWiustCd, dto.getWiustCd());
|
|
|
-// wrapper.last("limit 1");
|
|
|
-// MonitorSiteRelEntity relEntity = monitorSiteRelService.getOne(wrapper);
|
|
|
-// relEntity.setWiuCd(dto.getWiuCd());
|
|
|
-// monitorSiteRelService.updateById(relEntity);
|
|
|
- return R.status(monitorSiteService.updateById(dto));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增或修改
|
|
|
- */
|
|
|
- @PostMapping("/submit")
|
|
|
- @ApiOperationSupport(order = 6)
|
|
|
- @ApiOperation(value = "新增或修改", notes = "")
|
|
|
- public R submit(@RequestBody MonitorSiteInfoDTO dto) {
|
|
|
- if (dto.getId() != null) {
|
|
|
- return R.status(monitorSiteService.updateById(dto));
|
|
|
- } else {
|
|
|
- if (monitorSiteService.save(dto)) {
|
|
|
- MonitorSiteRelEntity relEntity = new MonitorSiteRelEntity();
|
|
|
- relEntity.setWiustCd(dto.getWiustCd());
|
|
|
- relEntity.setWiuCd(dto.getWiuCd());
|
|
|
- return R.status(monitorSiteRelService.save(relEntity));
|
|
|
+ if (Func.isNull(dto.getId())) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ if (monitorSiteService.updateById(dto)) {
|
|
|
+ RtuInfoEntity rtuInfoEntity = rtuBaseInfoService.rtuInfoByRtuCode(dto.getWiustCd());
|
|
|
+ if (Func.notNull(rtuInfoEntity)) {
|
|
|
+ rtuInfoEntity.setRtuName(dto.getWiustNm());
|
|
|
+ rtuBaseInfoService.updateById(rtuInfoEntity);
|
|
|
}
|
|
|
}
|
|
|
- return R.status(false);
|
|
|
+ return R.status(true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -176,7 +174,29 @@ public class MonitorSiteController extends BladeController {
|
|
|
@ApiOperationSupport(order = 7)
|
|
|
@ApiOperation(value = "逻辑删除", notes = "")
|
|
|
public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
|
|
|
+ List<Long> idArr = Func.toLongList(ids);
|
|
|
+ for (Long id : idArr) {
|
|
|
+ MonitorSiteInfoEntity entity = monitorSiteService.getById(id);
|
|
|
+ //删除RTU
|
|
|
+ RtuInfoEntity rtuInfoEntity = rtuBaseInfoService.rtuInfoByRtuCode(entity.getWiustCd());
|
|
|
+ if (Func.notNull(rtuInfoEntity)) {
|
|
|
+ rtuBaseInfoService.deleteLogic(Func.toLongList(Func.toStr(rtuInfoEntity.getId())));
|
|
|
+ }
|
|
|
+ //删除RTU状态
|
|
|
+// LambdaQueryWrapper<RtuStatusEntity> wrapper = Wrappers.<RtuStatusEntity>query().lambda();
|
|
|
+// wrapper.eq(RtuStatusEntity::getIsDeleted, 0);
|
|
|
+// wrapper.eq(RtuStatusEntity::getRtuCode, entity.getWiustCd());
|
|
|
+// RtuStatusEntity rtuStatusEntity = rtuManageService.getOne(wrapper);
|
|
|
+// if (Func.notNull(rtuStatusEntity)) {
|
|
|
+// rtuManageService.deleteLogic(Func.toLongList(Func.toStr(rtuStatusEntity.getId())));
|
|
|
+// }
|
|
|
+ //删除站点下点位
|
|
|
+ monitorSiteService.removeRelPoints(entity.getWiustCd());
|
|
|
+ //删除测站和用水户关联表
|
|
|
+ monitorSiteRelService.removeRel(entity.getWiustCd());
|
|
|
+ }
|
|
|
+ //删除站点
|
|
|
boolean temp = monitorSiteService.deleteLogic(Func.toLongList(ids));
|
|
|
- return R.status(temp);
|
|
|
+ return R.status(true);
|
|
|
}
|
|
|
}
|