|
@@ -25,6 +25,7 @@ import org.apache.commons.lang.time.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -138,7 +139,7 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @Transactional
|
|
|
|
|
|
+ @Transactional(rollbackFor = RuntimeException.class)
|
|
public Result deletePigpen(Map<String, Integer> map) {
|
|
public Result deletePigpen(Map<String, Integer> map) {
|
|
Integer integer = map.get("id");
|
|
Integer integer = map.get("id");
|
|
Integer integer1 = envDeviceMapper.selectCount(new QueryWrapper<EnvDevice>().eq("unit_id", integer));
|
|
Integer integer1 = envDeviceMapper.selectCount(new QueryWrapper<EnvDevice>().eq("unit_id", integer));
|
|
@@ -149,6 +150,7 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
for (BasePigpen basePigpen : other2) {
|
|
for (BasePigpen basePigpen : other2) {
|
|
Integer count = envDeviceMapper.selectCount(new QueryWrapper<EnvDevice>().eq("unit_id", basePigpen.getId()));
|
|
Integer count = envDeviceMapper.selectCount(new QueryWrapper<EnvDevice>().eq("unit_id", basePigpen.getId()));
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
return new Result(10001, "删除失败,该栋舍下有采集器", false);
|
|
return new Result(10001, "删除失败,该栋舍下有采集器", false);
|
|
}
|
|
}
|
|
basePigpenMapper.deleteById(basePigpen);
|
|
basePigpenMapper.deleteById(basePigpen);
|