Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -55,10 +55,10 @@ public class EnvironmentIndexConfigController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete/{id}")
|
||||||
@Operation(summary = "删除环境指标配置")
|
@Operation(summary = "删除环境指标配置")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
public CommonResult<Boolean> deleteEnvironmentIndexConfig(@RequestParam("id") String id) {
|
public CommonResult<Boolean> deleteEnvironmentIndexConfig(@PathVariable("id") String id) {
|
||||||
environmentIndexConfigService.deleteEnvironmentIndexConfig(id);
|
environmentIndexConfigService.deleteEnvironmentIndexConfig(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.farm.controller.admin.home;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.BaseNameVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.BaseNameVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.HomeInfo;
|
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.HomeInfo;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.OutlinedInfoVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.service.home.HomeService;
|
import cn.iocoder.yudao.module.farm.service.home.HomeService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -13,7 +12,6 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@@ -31,11 +29,18 @@ public class HomeController {
|
|||||||
@Resource
|
@Resource
|
||||||
private HomeService homeService;
|
private HomeService homeService;
|
||||||
|
|
||||||
|
// @Operation(summary = "农场首页")
|
||||||
|
// @GetMapping("")
|
||||||
|
// @Parameter(name = "baseId", description = "基地ID")
|
||||||
|
// public CommonResult<HomeInfo> getBaseInfo(@RequestParam("baseId") String baseId) {
|
||||||
|
// return success(homeService.getHomeInfo(baseId));
|
||||||
|
// }
|
||||||
|
|
||||||
@Operation(summary = "农场首页")
|
@Operation(summary = "农场首页")
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
@Parameter(name = "baseId", description = "基地ID")
|
@Parameter(name = "baseId", description = "基地ID")
|
||||||
public CommonResult<HomeInfo> getBaseInfo(@RequestParam("baseId") String baseId) {
|
public CommonResult<List<HomeInfo>> getBaseInfo(@RequestParam("baseId") String baseId) {
|
||||||
return success(homeService.getHomeInfo(baseId));
|
return success(homeService.getHomeInfoList(baseId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "农场首页-基地名称列表")
|
@Operation(summary = "农场首页-基地名称列表")
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ public class ProductionPlanController {
|
|||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得种植中心-生产计划-生产计划分页")
|
@Operation(summary = "获得种植中心-生产计划-生产计划分页")
|
||||||
|
|
||||||
public CommonResult<PageResult<ProductionPlanRespVO>> getProductionPlanPage(@Valid ProductionPlanPageReqVO pageReqVO) {
|
public CommonResult<PageResult<ProductionPlanRespVO>> getProductionPlanPage(@Valid ProductionPlanPageReqVO pageReqVO) {
|
||||||
PageResult<ProductionPlanDO> pageResult = productionPlanService.getProductionPlanPage(pageReqVO);
|
PageResult<ProductionPlanDO> pageResult = productionPlanService.getProductionPlanPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, ProductionPlanRespVO.class));
|
return success(BeanUtils.toBean(pageResult, ProductionPlanRespVO.class));
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import cn.idev.excel.annotation.*;
|
import cn.idev.excel.annotation.*;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 物种库维护 Response VO")
|
@Schema(description = "管理后台 - 物种库维护 Response VO")
|
||||||
@@ -17,7 +19,7 @@ public class SpeciesLibraryRespVO {
|
|||||||
|
|
||||||
@Schema(description = "物种类别")
|
@Schema(description = "物种类别")
|
||||||
@ExcelProperty("物种类别")
|
@ExcelProperty("物种类别")
|
||||||
private String category;
|
private Long category;
|
||||||
|
|
||||||
@Schema(description = "物种类别名称", example = "芋艿")
|
@Schema(description = "物种类别名称", example = "芋艿")
|
||||||
@ExcelProperty("物种类别名称")
|
@ExcelProperty("物种类别名称")
|
||||||
@@ -38,6 +40,7 @@ public class SpeciesLibraryRespVO {
|
|||||||
@Schema(description = "图片")
|
@Schema(description = "图片")
|
||||||
@ExcelProperty("图片")
|
@ExcelProperty("图片")
|
||||||
private String image;
|
private String image;
|
||||||
|
private List<String> imageList;
|
||||||
|
|
||||||
@Schema(description = "0=启用,1=停用", example = "1")
|
@Schema(description = "0=启用,1=停用", example = "1")
|
||||||
@ExcelProperty("0=启用,1=停用")
|
@ExcelProperty("0=启用,1=停用")
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.farm.controller.admin.specieslibrary.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 物种库维护新增/修改 Request VO")
|
@Schema(description = "管理后台 - 物种库维护新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class SpeciesLibrarySaveReqVO {
|
public class SpeciesLibrarySaveReqVO {
|
||||||
@@ -27,6 +29,7 @@ public class SpeciesLibrarySaveReqVO {
|
|||||||
|
|
||||||
@Schema(description = "图片")
|
@Schema(description = "图片")
|
||||||
private String image;
|
private String image;
|
||||||
|
private List<String> imageList;
|
||||||
|
|
||||||
@Schema(description = "0=启用,1=停用", example = "1")
|
@Schema(description = "0=启用,1=停用", example = "1")
|
||||||
private Integer useStatus;
|
private Integer useStatus;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TraceabilityCodePageReqVO extends PageParam {
|
|||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
@Schema(description = "采收时间")
|
@Schema(description = "采收时间")
|
||||||
private String harvestDate;
|
private String[] harvestDate;
|
||||||
|
|
||||||
@Schema(description = "采收时间范围查询-开始时间")
|
@Schema(description = "采收时间范围查询-开始时间")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class SpeciesLibraryDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 物种类别
|
* 物种类别
|
||||||
*/
|
*/
|
||||||
private String category;
|
private Long category;
|
||||||
/**
|
/**
|
||||||
* 物种类别名称
|
* 物种类别名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode TWO_DICT_NOT_EXISTS = new ErrorCode(1_050_035_000, "字典不存在");
|
ErrorCode TWO_DICT_NOT_EXISTS = new ErrorCode(1_050_035_000, "字典不存在");
|
||||||
|
|
||||||
ErrorCode PLOT_AREA_ERRORS = new ErrorCode(1_050_036_000, "地块面积总和大于基地面积");
|
ErrorCode PLOT_AREA_ERRORS = new ErrorCode(1_050_036_000, "地块面积总和大于基地面积");
|
||||||
|
ErrorCode PLOT_AREA_EXISTS_ERRORS = new ErrorCode(1_050_036_001, "该基地下存在地块,不可删除");
|
||||||
|
|
||||||
ErrorCode INDICATOR_NAME_NOT_EXISTS = new ErrorCode(1_050_037_000, "指标名称不存在");
|
ErrorCode INDICATOR_NAME_NOT_EXISTS = new ErrorCode(1_050_037_000, "指标名称不存在");
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public interface BaseInfoService {
|
|||||||
*/
|
*/
|
||||||
BaseInfoDO getBaseInfo(String id);
|
BaseInfoDO getBaseInfo(String id);
|
||||||
List<BaseInfoDO> getBaseInfos();
|
List<BaseInfoDO> getBaseInfos();
|
||||||
|
List<BaseInfoDO> getBaseInfosById(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得基地分页
|
* 获得基地分页
|
||||||
@@ -99,4 +100,6 @@ public interface BaseInfoService {
|
|||||||
Integer getBaseTotalCount(String tenantId);
|
Integer getBaseTotalCount(String tenantId);
|
||||||
|
|
||||||
CommonResult<List<FarmBaseInfoRespVO>> getBaseInfoList(FarmBaseInfoReqVO req);
|
CommonResult<List<FarmBaseInfoRespVO>> getBaseInfoList(FarmBaseInfoReqVO req);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,7 @@ import java.util.stream.Collectors;
|
|||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.BASE_INFO_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.BASE_INFO_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.PLOT_AREA_EXISTS_ERRORS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基地 Service 实现类
|
* 基地 Service 实现类
|
||||||
@@ -107,10 +108,13 @@ 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) {
|
boolean flag2 = plotInfoService.validatePlotExistByBaseId(id);
|
||||||
|
if (flag || flag2) {
|
||||||
// 删除
|
// 删除
|
||||||
baseInfoMapper.deleteById(id);
|
baseInfoMapper.deleteById(id);
|
||||||
plotInfoService.deleteByBaseId(id);
|
plotInfoService.deleteByBaseId(id);
|
||||||
|
}else {
|
||||||
|
throw exception(PLOT_AREA_EXISTS_ERRORS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +141,16 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
return baseInfoMapper.selectList("tenant_id", tenantId);
|
return baseInfoMapper.selectList("tenant_id", tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BaseInfoDO> getBaseInfosById(String id) {
|
||||||
|
LambdaQueryWrapperX<BaseInfoDO> wrapperX = new LambdaQueryWrapperX<>();
|
||||||
|
String tenantId = String.valueOf(getLoginUser().getTenantId());
|
||||||
|
wrapperX.eq(BaseInfoDO::getTenantId, tenantId);
|
||||||
|
wrapperX.eq(BaseInfoDO::getDeleted, CommonConstants.NO_CODE);
|
||||||
|
wrapperX.eqIfPresent(BaseInfoDO::getId, id);
|
||||||
|
return baseInfoMapper.selectList(wrapperX);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<BaseInfoDO> getBaseInfoPage(BaseInfoPageReqVO pageReqVO) {
|
public PageResult<BaseInfoDO> getBaseInfoPage(BaseInfoPageReqVO pageReqVO) {
|
||||||
return baseInfoMapper.selectPage(pageReqVO);
|
return baseInfoMapper.selectPage(pageReqVO);
|
||||||
|
|||||||
@@ -41,12 +41,13 @@ public class EnvironmentIndexConfigServiceImpl implements EnvironmentIndexConfig
|
|||||||
public String createEnvironmentIndexConfig(EnvironmentIndexConfigSaveReqVO createReqVO) {
|
public String createEnvironmentIndexConfig(EnvironmentIndexConfigSaveReqVO createReqVO) {
|
||||||
LoginUser user = getLoginUser();
|
LoginUser user = getLoginUser();
|
||||||
// 物种类型
|
// 物种类型
|
||||||
SpeciesLibraryDO speciesLibraryDO = speciesLibraryMapper.selectOne("cultivar_name", createReqVO.getCultivarName());
|
SpeciesLibraryDO speciesLibraryDO = speciesLibraryMapper.selectOne("id", createReqVO.getCultivarName());
|
||||||
// 插入
|
// 插入
|
||||||
EnvironmentIndexConfigDO environmentIndexConfig = BeanUtils.toBean(createReqVO, EnvironmentIndexConfigDO.class);
|
EnvironmentIndexConfigDO environmentIndexConfig = BeanUtils.toBean(createReqVO, EnvironmentIndexConfigDO.class);
|
||||||
environmentIndexConfig.setId(IdUtil.fastUUID());
|
environmentIndexConfig.setId(IdUtil.fastUUID());
|
||||||
environmentIndexConfig.setTenantId(String.valueOf(user.getTenantId()));
|
environmentIndexConfig.setTenantId(String.valueOf(user.getTenantId()));
|
||||||
environmentIndexConfig.setCultivarName(speciesLibraryDO.getSpeciesName());
|
environmentIndexConfig.setCultivarName(speciesLibraryDO.getCultivarName());
|
||||||
|
environmentIndexConfig.setSpeciesName(speciesLibraryDO.getSpeciesName());
|
||||||
environmentIndexConfigMapper.insert(environmentIndexConfig);
|
environmentIndexConfigMapper.insert(environmentIndexConfig);
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
@@ -57,8 +58,11 @@ public class EnvironmentIndexConfigServiceImpl implements EnvironmentIndexConfig
|
|||||||
public void updateEnvironmentIndexConfig(EnvironmentIndexConfigSaveReqVO updateReqVO) {
|
public void updateEnvironmentIndexConfig(EnvironmentIndexConfigSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateEnvironmentIndexConfigExists(updateReqVO.getId());
|
validateEnvironmentIndexConfigExists(updateReqVO.getId());
|
||||||
|
SpeciesLibraryDO speciesLibraryDO = speciesLibraryMapper.selectOne("id", updateReqVO.getCultivarName());
|
||||||
// 更新
|
// 更新
|
||||||
EnvironmentIndexConfigDO updateObj = BeanUtils.toBean(updateReqVO, EnvironmentIndexConfigDO.class);
|
EnvironmentIndexConfigDO updateObj = BeanUtils.toBean(updateReqVO, EnvironmentIndexConfigDO.class);
|
||||||
|
updateObj.setCultivarName(speciesLibraryDO.getCultivarName());
|
||||||
|
updateObj.setSpeciesName(speciesLibraryDO.getSpeciesName());
|
||||||
environmentIndexConfigMapper.updateById(updateObj);
|
environmentIndexConfigMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.farm.service.home;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.BaseNameVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.BaseNameVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.HomeInfo;
|
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.HomeInfo;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.HomeInfo2VO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.OutlinedInfoVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.OutlinedInfoVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -14,6 +13,9 @@ import java.util.Map;
|
|||||||
* @data: 2025/8/14 19:45
|
* @data: 2025/8/14 19:45
|
||||||
*/
|
*/
|
||||||
public interface HomeService {
|
public interface HomeService {
|
||||||
|
|
||||||
|
|
||||||
|
List<HomeInfo> getHomeInfoList(String baseId);
|
||||||
/**
|
/**
|
||||||
* 首页综合信息
|
* 首页综合信息
|
||||||
* @param baseId 基地ID
|
* @param baseId 基地ID
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.*;
|
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.*;
|
||||||
@@ -54,6 +55,12 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
this.modelManagementService = modelManagementService;
|
this.modelManagementService = modelManagementService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HomeInfo> getHomeInfoList(String baseId) {
|
||||||
|
List<BaseInfoDO> baseInfos = baseInfoService.getBaseInfosById(baseId);
|
||||||
|
return baseInfos.stream().map(e -> getHomeInfo(e.getId())).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HomeInfo getHomeInfo(String baseId) {
|
public HomeInfo getHomeInfo(String baseId) {
|
||||||
|
|
||||||
@@ -204,7 +211,6 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
return targetList;
|
return targetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutlinedInfoVO getOutlinedInfo(String baseId) {
|
public OutlinedInfoVO getOutlinedInfo(String baseId) {
|
||||||
OutlinedInfoVO res = new OutlinedInfoVO();
|
OutlinedInfoVO res = new OutlinedInfoVO();
|
||||||
|
|||||||
@@ -104,10 +104,11 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
modelManagement.setSuitablePlantingAreasList(createReqVO.getSuitablePlantingAreas());
|
modelManagement.setSuitablePlantingAreasList(createReqVO.getSuitablePlantingAreas());
|
||||||
}
|
}
|
||||||
// 处理speciesImage字段,优先使用图片集合
|
// 处理speciesImage字段,优先使用图片集合
|
||||||
if (createReqVO.getSpeciesImageList() != null && !createReqVO.getSpeciesImageList().isEmpty()) {
|
SpeciesLibraryDO libraryDO = speciesLibraryService.getSpeciesLibrary(createReqVO.getSpeciesId());
|
||||||
modelManagement.setSpeciesImageList(createReqVO.getSpeciesImageList());
|
if (libraryDO.getImageList() != null && !libraryDO.getImageList().isEmpty()) {
|
||||||
|
modelManagement.setSpeciesImageList(libraryDO.getImageList());
|
||||||
} else if (createReqVO.getSpeciesImage() != null) {
|
} else if (createReqVO.getSpeciesImage() != null) {
|
||||||
modelManagement.setSpeciesImage(createReqVO.getSpeciesImage());
|
modelManagement.setSpeciesImageList(libraryDO.getImageList());
|
||||||
}
|
}
|
||||||
|
|
||||||
modelManagementMapper.insert(modelManagement);
|
modelManagementMapper.insert(modelManagement);
|
||||||
@@ -228,12 +229,12 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 物种图片:支持清空(传空数组)与更新(传非空数组),其次支持单字符串
|
// 物种图片:支持清空(传空数组)与更新(传非空数组),其次支持单字符串
|
||||||
if (updateReqVO.getSpeciesImageList() != null) {
|
SpeciesLibraryDO libraryDO = speciesLibraryService.getSpeciesLibrary(updateReqVO.getSpeciesId());
|
||||||
existing.setSpeciesImageList(updateReqVO.getSpeciesImageList());
|
if (libraryDO.getImageList() != null && !libraryDO.getImageList().isEmpty()) {
|
||||||
|
existing.setSpeciesImageList(libraryDO.getImageList());
|
||||||
} else if (updateReqVO.getSpeciesImage() != null) {
|
} else if (updateReqVO.getSpeciesImage() != null) {
|
||||||
existing.setSpeciesImage(updateReqVO.getSpeciesImage());
|
existing.setSpeciesImageList(libraryDO.getImageList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 允许切换发布状态仅通过专用接口,不在此处处理 isRelease/releaseTime
|
// 允许切换发布状态仅通过专用接口,不在此处处理 isRelease/releaseTime
|
||||||
modelManagementMapper.updateById(existing);
|
modelManagementMapper.updateById(existing);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,4 +76,11 @@ public interface PlotInfoService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer getPlotTotalCount(String tenantId);
|
Integer getPlotTotalCount(String tenantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基地下存在地块,则不可删除
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean validatePlotExistByBaseId(String id);
|
||||||
}
|
}
|
||||||
@@ -150,6 +150,12 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
return count.intValue();
|
return count.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validatePlotExistByBaseId(String id) {
|
||||||
|
Long count = plotInfoMapper.selectCount("base_id", id);
|
||||||
|
return count <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证: 地块总面积不得大于基地面积
|
* 验证: 地块总面积不得大于基地面积
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -70,41 +70,22 @@ public class SpeciesLibraryServiceImpl implements SpeciesLibraryService {
|
|||||||
speciesLibrary.setId(id);
|
speciesLibrary.setId(id);
|
||||||
speciesLibrary.setTenantId(String.valueOf(user.getTenantId()));
|
speciesLibrary.setTenantId(String.valueOf(user.getTenantId()));
|
||||||
speciesLibrary.setCreateTime(LocalDateTime.now());
|
speciesLibrary.setCreateTime(LocalDateTime.now());
|
||||||
TwoDictDO dictDO3 = twoDictService.getTwoDict(Long.valueOf(speciesLibrary.getCategory()));
|
// TwoDictDO dictDO3 = twoDictService.getTwoDict(Long.valueOf(speciesLibrary.getCategory()));
|
||||||
TwoDictDO dictDO2 = twoDictService.getTwoDict(dictDO3.getParentId());
|
// TwoDictDO dictDO2 = twoDictService.getTwoDict(dictDO3.getParentId());
|
||||||
if (dictDO2.getParentId() != null) {
|
// if (dictDO2.getParentId() != null) {
|
||||||
TwoDictDO dictDO1 = twoDictService.getTwoDict(dictDO2.getParentId());
|
// TwoDictDO dictDO1 = twoDictService.getTwoDict(dictDO2.getParentId());
|
||||||
speciesLibrary.setSpeciesName(dictDO1.getName() + "/" + dictDO2.getName() + "/" + dictDO3.getName());
|
// speciesLibrary.setSpeciesName(dictDO1.getName() + "/" + dictDO2.getName() + "/" + dictDO3.getName());
|
||||||
|
// }
|
||||||
|
String speciesName = twoDictService.appendToSpeciesName(String.valueOf(speciesLibrary.getCategory()));
|
||||||
|
speciesLibrary.setSpeciesName(speciesName);
|
||||||
|
for (String image : createReqVO.getImageList()) {
|
||||||
|
speciesLibrary.setImage(image);
|
||||||
}
|
}
|
||||||
speciesLibraryMapper.insert(speciesLibrary);
|
speciesLibraryMapper.insert(speciesLibrary);
|
||||||
// 返回
|
// 返回
|
||||||
return speciesLibrary.getId();
|
return speciesLibrary.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncCreateDict(String id) {
|
|
||||||
SpeciesLibraryDO aDo = speciesLibraryMapper.selectById(id);
|
|
||||||
String category = aDo.getCategory(); // 物种二级编号
|
|
||||||
String cultivarName = aDo.getCultivarName(); // 物种三级名称
|
|
||||||
|
|
||||||
SysDictReqVO query = new SysDictReqVO();
|
|
||||||
query.setDictTypeCode(DICT_TYPE_CODE_3);
|
|
||||||
query.setField2Code(category);
|
|
||||||
SysDictDO obj = sysDictService.selectDictByMaxField2Code(query);
|
|
||||||
|
|
||||||
SysDictDO insertObj = new SysDictDO();
|
|
||||||
insertObj.setDictTypeCode(DICT_TYPE_CODE_3);
|
|
||||||
insertObj.setDictTypeName("物种类别");
|
|
||||||
insertObj.setField1Code(obj.getField1Code());
|
|
||||||
insertObj.setField1Name(obj.getField1Name());
|
|
||||||
insertObj.setField2Code(category);
|
|
||||||
insertObj.setField2Name(obj.getField2Name());
|
|
||||||
insertObj.setField3Code(generate());
|
|
||||||
insertObj.setField3Name(cultivarName);
|
|
||||||
insertObj.setStatus(CommonConstants.YES_CODE);
|
|
||||||
insertObj.setDeleted(false);
|
|
||||||
sysDictService.insertOne(insertObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSpeciesLibrary(SpeciesLibrarySaveReqVO updateReqVO) {
|
public void updateSpeciesLibrary(SpeciesLibrarySaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
@@ -124,38 +105,22 @@ public class SpeciesLibraryServiceImpl implements SpeciesLibraryService {
|
|||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
SpeciesLibraryDO updateObj = BeanUtils.toBean(updateReqVO, SpeciesLibraryDO.class);
|
SpeciesLibraryDO updateObj = BeanUtils.toBean(updateReqVO, SpeciesLibraryDO.class);
|
||||||
TwoDictDO dictDO3 = twoDictService.getTwoDict(Long.valueOf(updateObj.getCategory()));
|
// TwoDictDO dictDO3 = twoDictService.getTwoDict(Long.valueOf(updateObj.getCategory()));
|
||||||
TwoDictDO dictDO2 = twoDictService.getTwoDict(dictDO3.getParentId());
|
// TwoDictDO dictDO2 = twoDictService.getTwoDict(dictDO3.getParentId());
|
||||||
if (dictDO2.getParentId() != null) {
|
// if (dictDO2.getParentId() != null) {
|
||||||
TwoDictDO dictDO1 = twoDictService.getTwoDict(dictDO2.getParentId());
|
// TwoDictDO dictDO1 = twoDictService.getTwoDict(dictDO2.getParentId());
|
||||||
updateObj.setSpeciesName(dictDO1.getName() + "/" + dictDO2.getName() + "/" + dictDO3.getName());
|
// updateObj.setSpeciesName(dictDO1.getName() + "/" + dictDO2.getName() + "/" + dictDO3.getName());
|
||||||
|
// }
|
||||||
|
String speciesName = twoDictService.appendToSpeciesName(String.valueOf(updateObj.getCategory()));
|
||||||
|
updateObj.setSpeciesName(speciesName);
|
||||||
|
for (String image : updateObj.getImageList()) {
|
||||||
|
updateObj.setImage(image);
|
||||||
}
|
}
|
||||||
speciesLibraryMapper.updateById(updateObj);
|
speciesLibraryMapper.updateById(updateObj);
|
||||||
// 同步
|
// 同步
|
||||||
// this.syncUpdateDict(updateObj.getId());
|
// this.syncUpdateDict(updateObj.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncUpdateDict(String id) {
|
|
||||||
SpeciesLibraryDO aDo = speciesLibraryMapper.selectById(id);
|
|
||||||
String category = aDo.getCategory(); // 物种二级编号
|
|
||||||
String cultivarName = aDo.getCultivarName(); // 物种三级名称
|
|
||||||
|
|
||||||
SysDictReqVO query = new SysDictReqVO();
|
|
||||||
query.setDictTypeCode(DICT_TYPE_CODE_3);
|
|
||||||
query.setField2Code(category);
|
|
||||||
SysDictDO obj = sysDictService.selectDictByMaxField2Code(query);
|
|
||||||
|
|
||||||
SysDictDO updateObj = new SysDictDO();
|
|
||||||
updateObj.setId(Integer.valueOf(id));
|
|
||||||
updateObj.setField1Code(obj.getField1Code());
|
|
||||||
updateObj.setField1Name(obj.getField1Name());
|
|
||||||
updateObj.setField2Code(category);
|
|
||||||
updateObj.setField2Name(obj.getField2Name());
|
|
||||||
updateObj.setField3Code(obj.getField3Code());
|
|
||||||
updateObj.setField3Name(cultivarName);
|
|
||||||
sysDictService.updateById(updateObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteSpeciesLibrary(String id) {
|
public void deleteSpeciesLibrary(String id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
@@ -165,23 +130,6 @@ public class SpeciesLibraryServiceImpl implements SpeciesLibraryService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncDeleteDict(String id) {
|
|
||||||
|
|
||||||
SpeciesLibraryDO aDo = speciesLibraryMapper.selectById(id);
|
|
||||||
String category = aDo.getCategory(); // 物种二级编号
|
|
||||||
|
|
||||||
SysDictReqVO query = new SysDictReqVO();
|
|
||||||
query.setDictTypeCode(DICT_TYPE_CODE_3);
|
|
||||||
query.setField2Code(category);
|
|
||||||
SysDictDO obj = sysDictService.selectDictByMaxField2Code(query);
|
|
||||||
|
|
||||||
SysDictDO updateObj = new SysDictDO();
|
|
||||||
updateObj.setId(obj.getId());
|
|
||||||
updateObj.setDeleted(false);
|
|
||||||
sysDictService.updateById(obj);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteSpeciesLibraryListByIds(List<String> ids) {
|
public void deleteSpeciesLibraryListByIds(List<String> ids) {
|
||||||
// 删除
|
// 删除
|
||||||
@@ -309,7 +257,7 @@ public class SpeciesLibraryServiceImpl implements SpeciesLibraryService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 批量查询所有二级分类下的物种,避免 N+1 查询
|
// 批量查询所有二级分类下的物种,避免 N+1 查询
|
||||||
Map<String, List<SpeciesLibraryDO>> categoryToSpeciesMap;
|
Map<Long, List<SpeciesLibraryDO>> categoryToSpeciesMap;
|
||||||
if (level2Ids.isEmpty()) {
|
if (level2Ids.isEmpty()) {
|
||||||
categoryToSpeciesMap = java.util.Collections.emptyMap();
|
categoryToSpeciesMap = java.util.Collections.emptyMap();
|
||||||
} else {
|
} else {
|
||||||
@@ -321,8 +269,7 @@ public class SpeciesLibraryServiceImpl implements SpeciesLibraryService {
|
|||||||
List<SpeciesLibraryDO> allSpecies = speciesLibraryMapper.selectList(queryWrapper);
|
List<SpeciesLibraryDO> allSpecies = speciesLibraryMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
// 按分类ID分组
|
// 按分类ID分组
|
||||||
categoryToSpeciesMap = allSpecies.stream()
|
categoryToSpeciesMap = allSpecies.stream().collect(Collectors.groupingBy(SpeciesLibraryDO::getCategory));
|
||||||
.collect(Collectors.groupingBy(SpeciesLibraryDO::getCategory));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SpeciesThreeLevelTreeRespVO> result = new ArrayList<>();
|
List<SpeciesThreeLevelTreeRespVO> result = new ArrayList<>();
|
||||||
@@ -848,4 +795,5 @@ public class SpeciesLibraryServiceImpl implements SpeciesLibraryService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -66,4 +66,6 @@ public interface TwoDictService {
|
|||||||
*/
|
*/
|
||||||
List<TwoDictTreeRespVO> getTwoDictTree();
|
List<TwoDictTreeRespVO> getTwoDictTree();
|
||||||
|
|
||||||
|
String appendToSpeciesName(String id);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,9 +13,9 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
@@ -124,4 +124,47 @@ public class TwoDictServiceImpl implements TwoDictService {
|
|||||||
return treeList;
|
return treeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物种名称id 反差其父类名称, 并使用/分割返回
|
||||||
|
* @param id 最底层id
|
||||||
|
* @return 自上而下的 name 拼接, 通过"/"分割
|
||||||
|
*/
|
||||||
|
public String appendToSpeciesName(String id) {
|
||||||
|
if (id == null || id.trim().isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存储从底层到顶层的名称(后续会反转)
|
||||||
|
List<String> nameList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取当前节点信息
|
||||||
|
TwoDictDO current = twoDictMapper.selectOne("id", id);
|
||||||
|
if (current == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加当前节点名称
|
||||||
|
nameList.add(current.getName());
|
||||||
|
|
||||||
|
// 递归向上查找父节点
|
||||||
|
Long parentId = current.getParentId();
|
||||||
|
while (parentId != null) {
|
||||||
|
TwoDictDO parent = twoDictMapper.selectOne("id", parentId.toString());
|
||||||
|
if (parent == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
nameList.add(parent.getName());
|
||||||
|
parentId = parent.getParentId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 反转列表,使顺序变为从顶层到底层
|
||||||
|
Collections.reverse(nameList);
|
||||||
|
|
||||||
|
// 使用"/"拼接名称
|
||||||
|
return String.join("/", nameList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user