|
@@ -10,10 +10,12 @@ import com.huimv.admin.common.utils.Result;
|
|
|
import com.huimv.admin.common.utils.ResultCode;
|
|
|
import com.huimv.admin.common.utils.ResultUtil;
|
|
|
import com.huimv.admin.entity.BasePigpen;
|
|
|
+import com.huimv.admin.entity.EnergyEnvDevice;
|
|
|
import com.huimv.admin.entity.EnvDevice;
|
|
|
import com.huimv.admin.entity.dto.BasePigpenDto;
|
|
|
import com.huimv.admin.entity.vo.TreeBasePigpen;
|
|
|
import com.huimv.admin.mapper.BasePigpenMapper;
|
|
|
+import com.huimv.admin.mapper.EnergyEnvDeviceMapper;
|
|
|
import com.huimv.admin.mapper.EnvDeviceMapper;
|
|
|
import com.huimv.admin.service.IBasePigpenService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -41,7 +43,8 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
|
private BasePigpenMapper basePigpenMapper;
|
|
|
@Autowired
|
|
|
private EnvDeviceMapper envDeviceMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private EnergyEnvDeviceMapper energyEnvDeviceMapper;
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Result addPigpen(BasePigpenDto basePigpenDto) {
|
|
@@ -99,15 +102,23 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
|
@Transactional
|
|
|
public Result deletePigpen(Map<String, Integer> map) {
|
|
|
Integer integer = map.get("id");
|
|
|
+ Integer count1 = energyEnvDeviceMapper.selectCount(new QueryWrapper<EnergyEnvDevice>().eq("unit_id", integer));
|
|
|
Integer integer1 = envDeviceMapper.selectCount(new QueryWrapper<EnvDevice>().eq("unit_id", integer));
|
|
|
if (integer1 > 0) {
|
|
|
- return new Result(10001, "删除失败,该栋舍下有采集器", false);
|
|
|
+ return new Result(10001, "删除失败,该栋舍下有温湿度采集器", false);
|
|
|
+ }
|
|
|
+ if (count1 > 0) {
|
|
|
+ return new Result(10001, "删除失败,该栋舍下有水电表", false);
|
|
|
}
|
|
|
List<BasePigpen> other2 = basePigpenMapper.selectList(new QueryWrapper<BasePigpen>().like("other2", integer));
|
|
|
for (BasePigpen basePigpen : other2) {
|
|
|
Integer count = envDeviceMapper.selectCount(new QueryWrapper<EnvDevice>().eq("unit_id", basePigpen.getId()));
|
|
|
+ Integer integer2 = envDeviceMapper.selectCount(new QueryWrapper<EnvDevice>().eq("unit_id", integer));
|
|
|
if (count > 0) {
|
|
|
- return new Result(10001, "删除失败,该栋舍下有采集器", false);
|
|
|
+ return new Result(10001, "删除失败,该栋舍下有温湿度采集器", false);
|
|
|
+ }
|
|
|
+ if (integer2 > 0) {
|
|
|
+ return new Result(10001, "删除失败,该栋舍下有水电表", false);
|
|
|
}
|
|
|
basePigpenMapper.deleteById(basePigpen.getId());
|
|
|
}
|