fix (farm): 基地管理
- 删除基地同时删除其所属地块
This commit is contained in:
@@ -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.plotinfo.PlotInfoMapper;
|
||||||
import cn.iocoder.yudao.module.farm.dal.mysql.specieslibrary.SpeciesLibraryMapper;
|
import cn.iocoder.yudao.module.farm.dal.mysql.specieslibrary.SpeciesLibraryMapper;
|
||||||
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
|
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 cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
@@ -46,8 +47,6 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
@Resource
|
@Resource
|
||||||
private BaseInfoMapper baseInfoMapper;
|
private BaseInfoMapper baseInfoMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PlotInfoMapper plotInfoMapper;
|
|
||||||
@Resource
|
|
||||||
private SpeciesLibraryMapper speciesLibraryMapper;
|
private SpeciesLibraryMapper speciesLibraryMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PersonnelManagementMapper personnelManagementMapper;
|
private PersonnelManagementMapper personnelManagementMapper;
|
||||||
@@ -55,6 +54,8 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
private GridInfoMapper gridInfoMapper;
|
private GridInfoMapper gridInfoMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProductionPlanService productionPlanService;
|
private ProductionPlanService productionPlanService;
|
||||||
|
@Resource
|
||||||
|
private PlotInfoService plotInfoService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createBaseInfo(BaseInfoSaveReqVO createReqVO) {
|
public String createBaseInfo(BaseInfoSaveReqVO createReqVO) {
|
||||||
@@ -89,12 +90,12 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
// 校验存在
|
// 校验存在
|
||||||
validateBaseInfoExists(id);
|
validateBaseInfoExists(id);
|
||||||
// 校验: 存在在种地块时 不允许删除
|
// 校验: 存在在种地块时 不允许删除
|
||||||
boolean flag = productionPlanService.validateIncompletePlansBId("base_id",id);
|
boolean flag = productionPlanService.validateIncompletePlansBId("base_id", id);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
// 删除
|
// 删除
|
||||||
baseInfoMapper.deleteById(id);
|
baseInfoMapper.deleteById(id);
|
||||||
|
plotInfoService.deleteByBaseId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -130,7 +131,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
List<BaseNameRespVO> res = new ArrayList<>();
|
List<BaseNameRespVO> res = new ArrayList<>();
|
||||||
|
|
||||||
// 地块
|
// 地块
|
||||||
List<PlotInfoDO> plotInfoDOS = plotInfoMapper.selectList();
|
List<PlotInfoDO> plotInfoDOS = plotInfoService.getPlotInfos();
|
||||||
// 基地
|
// 基地
|
||||||
List<BaseInfoDO> baseInfoDOS = baseInfoMapper.selectList();
|
List<BaseInfoDO> baseInfoDOS = baseInfoMapper.selectList();
|
||||||
Map<String, String> baseNameMap = baseInfoDOS.stream().collect(Collectors.toMap(BaseInfoDO::getId, BaseInfoDO::getName, (v1, v2) -> v1));
|
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 baseId = obj.getId();
|
||||||
String baseName = obj.getName();
|
String baseName = obj.getName();
|
||||||
BigDecimal baseArea = obj.getArea();
|
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);
|
BaseInfoRespVO.BaseInfo baseOverview = this.packageBaseOverview(tenantId, baseId, baseName, baseArea, plotList);
|
||||||
|
|||||||
@@ -63,4 +63,10 @@ public interface PlotInfoService {
|
|||||||
PageResult<PlotInfoDO> getPlotInfoPage(PlotInfoPageReqVO pageReqVO);
|
PageResult<PlotInfoDO> getPlotInfoPage(PlotInfoPageReqVO pageReqVO);
|
||||||
|
|
||||||
PlotInfoDO getPlotInfoByPlotId(String plotId);
|
PlotInfoDO getPlotInfoByPlotId(String plotId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void deleteByBaseId(String baseId);
|
||||||
}
|
}
|
||||||
@@ -131,6 +131,11 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
return plotInfoMapper.selectOne(queryWrapper);
|
return plotInfoMapper.selectOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByBaseId(String baseId) {
|
||||||
|
plotInfoMapper.delete("base_id", baseId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证: 地块总面积不得大于基地面积
|
* 验证: 地块总面积不得大于基地面积
|
||||||
* @param baseId 基地面积
|
* @param baseId 基地面积
|
||||||
|
|||||||
Reference in New Issue
Block a user