fix (farm): 基地管理

- 删除基地同时删除其所属地块
This commit is contained in:
达富斌
2025-08-30 14:02:48 +08:00
parent 517e709661
commit 809eabce10
3 changed files with 18 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.farm.dal.mysql.personnelmanagement.PersonnelManag
import cn.iocoder.yudao.module.farm.dal.mysql.plotinfo.PlotInfoMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.specieslibrary.SpeciesLibraryMapper;
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
import cn.iocoder.yudao.module.farm.service.plotinfo.PlotInfoService;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -46,8 +47,6 @@ public class BaseInfoServiceImpl implements BaseInfoService {
@Resource
private BaseInfoMapper baseInfoMapper;
@Resource
private PlotInfoMapper plotInfoMapper;
@Resource
private SpeciesLibraryMapper speciesLibraryMapper;
@Resource
private PersonnelManagementMapper personnelManagementMapper;
@@ -55,6 +54,8 @@ public class BaseInfoServiceImpl implements BaseInfoService {
private GridInfoMapper gridInfoMapper;
@Resource
private ProductionPlanService productionPlanService;
@Resource
private PlotInfoService plotInfoService;
@Override
public String createBaseInfo(BaseInfoSaveReqVO createReqVO) {
@@ -89,12 +90,12 @@ public class BaseInfoServiceImpl implements BaseInfoService {
// 校验存在
validateBaseInfoExists(id);
// 校验: 存在在种地块时 不允许删除
boolean flag = productionPlanService.validateIncompletePlansBId("base_id",id);
boolean flag = productionPlanService.validateIncompletePlansBId("base_id", id);
if (flag) {
// 删除
baseInfoMapper.deleteById(id);
plotInfoService.deleteByBaseId(id);
}
}
@Override
@@ -130,7 +131,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
List<BaseNameRespVO> res = new ArrayList<>();
// 地块
List<PlotInfoDO> plotInfoDOS = plotInfoMapper.selectList();
List<PlotInfoDO> plotInfoDOS = plotInfoService.getPlotInfos();
// 基地
List<BaseInfoDO> baseInfoDOS = baseInfoMapper.selectList();
Map<String, String> baseNameMap = baseInfoDOS.stream().collect(Collectors.toMap(BaseInfoDO::getId, BaseInfoDO::getName, (v1, v2) -> v1));
@@ -198,7 +199,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
String baseId = obj.getId();
String baseName = obj.getName();
BigDecimal baseArea = obj.getArea();
List<PlotInfoDO> plotList = plotInfoMapper.selectList("base_id", baseId);
List<PlotInfoDO> plotList = plotInfoService.getPlotInfos( baseId);
// 基地概述
BaseInfoRespVO.BaseInfo baseOverview = this.packageBaseOverview(tenantId, baseId, baseName, baseArea, plotList);

View File

@@ -63,4 +63,10 @@ public interface PlotInfoService {
PageResult<PlotInfoDO> getPlotInfoPage(PlotInfoPageReqVO pageReqVO);
PlotInfoDO getPlotInfoByPlotId(String plotId);
/**
* 批量删除
* @param id
*/
void deleteByBaseId(String baseId);
}

View File

@@ -131,6 +131,11 @@ public class PlotInfoServiceImpl implements PlotInfoService {
return plotInfoMapper.selectOne(queryWrapper);
}
@Override
public void deleteByBaseId(String baseId) {
plotInfoMapper.delete("base_id", baseId);
}
/**
* 验证: 地块总面积不得大于基地面积
* @param baseId 基地面积