Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -150,6 +150,7 @@ public class CropFarmingCenterController {
|
|||||||
public CommonResult<Boolean> restartPlanning(@RequestBody ProductionPlanUpdateReqVO updateReqVO) {
|
public CommonResult<Boolean> restartPlanning(@RequestBody ProductionPlanUpdateReqVO updateReqVO) {
|
||||||
updateReqVO.setPlanStatus(CommonConstants.PLAN_STATUS_2);
|
updateReqVO.setPlanStatus(CommonConstants.PLAN_STATUS_2);
|
||||||
// TODO: 2025/8/29 这里存在业务逻辑问题 ,等产品确认
|
// TODO: 2025/8/29 这里存在业务逻辑问题 ,等产品确认
|
||||||
|
// 如果地块, 物种 模型 被删除 ,则不可以重启
|
||||||
cropFarmingCenterService.restartProductionPlan(updateReqVO);
|
cropFarmingCenterService.restartProductionPlan(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ public class HomeInfo {
|
|||||||
|
|
||||||
@Schema(description = "基地数量")
|
@Schema(description = "基地数量")
|
||||||
private Integer baseCount;
|
private Integer baseCount;
|
||||||
@Schema(description = "总面积")
|
|
||||||
private Integer cropCount;
|
|
||||||
@Schema(description = "在种作物数量")
|
@Schema(description = "在种作物数量")
|
||||||
|
private Integer cropCount;
|
||||||
|
@Schema(description = "总面积")
|
||||||
private Integer totalArea;
|
private Integer totalArea;
|
||||||
@Schema(description = "在职员工人数")
|
@Schema(description = "在职员工人数")
|
||||||
private Integer personnelCount;
|
private Integer personnelCount;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class ModelCycleRespVO {
|
|||||||
@Schema(description = "阶段图片")
|
@Schema(description = "阶段图片")
|
||||||
@ExcelProperty("阶段图片")
|
@ExcelProperty("阶段图片")
|
||||||
private String stageImage;
|
private String stageImage;
|
||||||
|
private List<String> stageImageList;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.farm.controller.admin.modelcycle.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 ModelCycleSaveReqVO {
|
public class ModelCycleSaveReqVO {
|
||||||
@@ -24,6 +26,7 @@ public class ModelCycleSaveReqVO {
|
|||||||
|
|
||||||
@Schema(description = "阶段图片")
|
@Schema(description = "阶段图片")
|
||||||
private String stageImage;
|
private String stageImage;
|
||||||
|
private List<String> stageImageList;
|
||||||
|
|
||||||
@Schema(description = "基地id", example = "3265")
|
@Schema(description = "基地id", example = "3265")
|
||||||
private String baseId;
|
private String baseId;
|
||||||
|
|||||||
@@ -79,7 +79,9 @@ public class ModelManagementRespVO {
|
|||||||
private String tenantName;
|
private String tenantName;
|
||||||
|
|
||||||
private String userName;
|
private String userName;
|
||||||
|
@Schema(description = "发布状态")
|
||||||
private int isRelease;
|
private int isRelease;
|
||||||
|
@Schema(description = "引用次数")
|
||||||
private int quoteCount;
|
private int quoteCount;
|
||||||
@Schema(description = "物种图片")
|
@Schema(description = "物种图片")
|
||||||
private String speciesImage;
|
private String speciesImage;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.farm.dal.dataobject.modelcycle;
|
package cn.iocoder.yudao.module.farm.dal.dataobject.modelcycle;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
@@ -39,6 +41,14 @@ public class ModelCycleDO extends BaseDO {
|
|||||||
* 阶段天数
|
* 阶段天数
|
||||||
*/
|
*/
|
||||||
private Integer stage;
|
private Integer stage;
|
||||||
|
/**
|
||||||
|
* 周期范围-开始日期 2025年09月10日
|
||||||
|
*/
|
||||||
|
private LocalDate cycleRangeStartDate;
|
||||||
|
/**
|
||||||
|
* 周期范围-结束日期 2025年09月10日
|
||||||
|
*/
|
||||||
|
private LocalDate cycleRangeEndDate;
|
||||||
/**
|
/**
|
||||||
* 物候期描述
|
* 物候期描述
|
||||||
*/
|
*/
|
||||||
@@ -47,6 +57,8 @@ public class ModelCycleDO extends BaseDO {
|
|||||||
* 阶段图片
|
* 阶段图片
|
||||||
*/
|
*/
|
||||||
private String stageImage;
|
private String stageImage;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<String> stageImageList;
|
||||||
/**
|
/**
|
||||||
* 基地id
|
* 基地id
|
||||||
*/
|
*/
|
||||||
@@ -65,4 +77,11 @@ public class ModelCycleDO extends BaseDO {
|
|||||||
private String plotName;
|
private String plotName;
|
||||||
|
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
|
public List<String> getImageList() {
|
||||||
|
if (stageImageList == null) {
|
||||||
|
stageImageList = ImageCollectionUtil.toImageList(this.stageImage);
|
||||||
|
}
|
||||||
|
return stageImageList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@ public class ModelManagementDO extends BaseDO {
|
|||||||
* 生命周期
|
* 生命周期
|
||||||
*/
|
*/
|
||||||
private String cycle;
|
private String cycle;
|
||||||
|
private String cycleName;
|
||||||
/**
|
/**
|
||||||
* 产量参考
|
* 产量参考
|
||||||
*/
|
*/
|
||||||
@@ -91,12 +92,15 @@ public class ModelManagementDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private String taskId;
|
private String taskId;
|
||||||
private int isRelease;
|
private int isRelease;
|
||||||
|
/**
|
||||||
|
* 引用次数
|
||||||
|
*/
|
||||||
private int quoteCount;
|
private int quoteCount;
|
||||||
/**
|
/**
|
||||||
* 物种图片(数据库存储为逗号分隔的字符串)
|
* 物种图片(数据库存储为逗号分隔的字符串)
|
||||||
*/
|
*/
|
||||||
private String speciesImage;
|
private String speciesImage;
|
||||||
private String cycleName;
|
|
||||||
/**
|
/**
|
||||||
* 物种图片集合(业务层使用)
|
* 物种图片集合(业务层使用)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== 地块信息 1-050-003-000 ==========
|
// ========== 地块信息 1-050-003-000 ==========
|
||||||
ErrorCode PLOT_INFO_NOT_EXISTS = new ErrorCode(1_050_003_000, "地块信息不存在");
|
ErrorCode PLOT_INFO_NOT_EXISTS = new ErrorCode(1_050_003_000, "地块信息不存在");
|
||||||
|
ErrorCode PLOT_AREA_ERROR = new ErrorCode(1_050_003_001, "地块面积总和不可大于基地面积");
|
||||||
|
ErrorCode BEGIN_AREA_ERROR = new ErrorCode(1_050_003_002, "在种地块不可删除");
|
||||||
|
|
||||||
// ========== 设备信息 1-050-004-000 ==========
|
// ========== 设备信息 1-050-004-000 ==========
|
||||||
ErrorCode DEVICE_INFO_NOT_EXISTS = new ErrorCode(1_050_004_000, "设备信息不存在");
|
ErrorCode DEVICE_INFO_NOT_EXISTS = new ErrorCode(1_050_004_000, "设备信息不存在");
|
||||||
@@ -120,6 +122,7 @@ public interface ErrorCodeConstants {
|
|||||||
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 PLOT_AREA_EXISTS_ERRORS = new ErrorCode(1_050_036_001, "该基地存在地块,不可删除");
|
||||||
ErrorCode BEING_PLOT_AREA_EXISTS_ERRORS = new ErrorCode(1_050_036_002, "该基地存在在种地块,不可删除");
|
ErrorCode BEING_PLOT_AREA_EXISTS_ERRORS = new ErrorCode(1_050_036_002, "该基地存在在种地块,不可删除");
|
||||||
|
ErrorCode BASE_PLOT_AREA_ERRORS = new ErrorCode(1_050_036_003, "该基地面积小于地块面积总和,不可删除");
|
||||||
|
|
||||||
ErrorCode INDICATOR_NAME_NOT_EXISTS = new ErrorCode(1_050_037_000, "指标名称不存在");
|
ErrorCode INDICATOR_NAME_NOT_EXISTS = new ErrorCode(1_050_037_000, "指标名称不存在");
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManageme
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.LIFE_CYCLE_MAP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模型管理转换工具类
|
* 模型管理转换工具类
|
||||||
* 确保所有接口返回格式统一
|
* 确保所有接口返回格式统一
|
||||||
@@ -30,7 +32,7 @@ public class ModelManagementConvertUtil {
|
|||||||
respVO.setSpeciesId(modelManagementDO.getSpeciesId());
|
respVO.setSpeciesId(modelManagementDO.getSpeciesId());
|
||||||
respVO.setSpeciesName(modelManagementDO.getSpeciesName());
|
respVO.setSpeciesName(modelManagementDO.getSpeciesName());
|
||||||
respVO.setCycle(modelManagementDO.getCycle());
|
respVO.setCycle(modelManagementDO.getCycle());
|
||||||
respVO.setCycleName(modelManagementDO.getCycleName());
|
respVO.setCycleName(LIFE_CYCLE_MAP.get(modelManagementDO.getCycle()));
|
||||||
respVO.setHarvest(modelManagementDO.getHarvest());
|
respVO.setHarvest(modelManagementDO.getHarvest());
|
||||||
respVO.setDescription(modelManagementDO.getDescription());
|
respVO.setDescription(modelManagementDO.getDescription());
|
||||||
respVO.setCreateTime(modelManagementDO.getCreateTime());
|
respVO.setCreateTime(modelManagementDO.getCreateTime());
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
String baseId = updateReqVO.getId();
|
String baseId = updateReqVO.getId();
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateBaseInfoExists(baseId);
|
validateBaseInfoExists(baseId);
|
||||||
|
// 校验基地面积
|
||||||
|
validateBaseArea(baseId, updateReqVO.getArea());
|
||||||
// 更新
|
// 更新
|
||||||
BaseInfoDO updateObj = BeanUtils.toBean(updateReqVO, BaseInfoDO.class);
|
BaseInfoDO updateObj = BeanUtils.toBean(updateReqVO, BaseInfoDO.class);
|
||||||
baseInfoMapper.updateById(updateObj);
|
baseInfoMapper.updateById(updateObj);
|
||||||
@@ -134,6 +136,17 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改后的基地面积 不可小于 其地块面积总和
|
||||||
|
* @param id
|
||||||
|
* @param updateBaseArea
|
||||||
|
*/
|
||||||
|
private void validateBaseArea(String id,BigDecimal updateBaseArea) {
|
||||||
|
if (!plotInfoService.validateTotalPlotArea(id,updateBaseArea)) {
|
||||||
|
throw exception(BASE_PLOT_AREA_ERRORS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseInfoDO getBaseInfo(String id) {
|
public BaseInfoDO getBaseInfo(String id) {
|
||||||
return baseInfoMapper.selectById(id);
|
return baseInfoMapper.selectById(id);
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
|||||||
@Override
|
@Override
|
||||||
public void createProductionPlan(ProductionPlanSaveReqVO reqVO) {
|
public void createProductionPlan(ProductionPlanSaveReqVO reqVO) {
|
||||||
|
|
||||||
|
// 模版类型-模型ID
|
||||||
String speciesModelId = reqVO.getSpeciesModelId();
|
String speciesModelId = reqVO.getSpeciesModelId();
|
||||||
Map<String, String> baseNameMap = baseInfoMapper.selectList().stream().collect(toMap(BaseInfoDO::getId, BaseInfoDO::getName, (v1, v2) -> v1));
|
Map<String, String> baseNameMap = baseInfoMapper.selectList().stream().collect(toMap(BaseInfoDO::getId, BaseInfoDO::getName, (v1, v2) -> v1));
|
||||||
Map<String, String> plotNameMap = plotInfoService.getPlotInfos().stream().collect(toMap(PlotInfoDO::getPlotId, PlotInfoDO::getPlotName, (v1, v2) -> v1));
|
Map<String, String> plotNameMap = plotInfoService.getPlotInfos().stream().collect(toMap(PlotInfoDO::getPlotId, PlotInfoDO::getPlotName, (v1, v2) -> v1));
|
||||||
@@ -91,40 +92,38 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
|||||||
|
|
||||||
List<ProductionPlanDO> list = new ArrayList<>();
|
List<ProductionPlanDO> list = new ArrayList<>();
|
||||||
for (ProductionPlanSaveReqVO.CultivationArea e : cultivationAreaList) {
|
for (ProductionPlanSaveReqVO.CultivationArea e : cultivationAreaList) {
|
||||||
|
if (speciesModelId.equals("")) {
|
||||||
|
continue; // TODO: 2025/9/10 放在外面
|
||||||
|
}
|
||||||
|
// 引用模型-模型ID
|
||||||
|
String taskId = IdUtil.fastUUID();
|
||||||
|
// 随机字符串 + 地块名称
|
||||||
|
String planNumber = StrHelperUtil.generate() + "-" + plotNameMap.getOrDefault(e.getPlotId(), "");
|
||||||
ProductionPlanDO obj = new ProductionPlanDO();
|
ProductionPlanDO obj = new ProductionPlanDO();
|
||||||
|
obj.setId(taskId);
|
||||||
|
obj.setPlanNumber(planNumber);
|
||||||
obj.setPlantSpeciesCode(reqVO.getPlantSpeciesCode());
|
obj.setPlantSpeciesCode(reqVO.getPlantSpeciesCode());
|
||||||
|
|
||||||
obj.setProductionStartDate(reqVO.getProductionStartDate());
|
obj.setProductionStartDate(reqVO.getProductionStartDate());
|
||||||
obj.setProductionEndDate(reqVO.getProductionEndDate());
|
obj.setProductionEndDate(reqVO.getProductionEndDate());
|
||||||
obj.setHarvestStartDate(reqVO.getHarvestStartDate());
|
obj.setHarvestStartDate(reqVO.getHarvestStartDate());
|
||||||
obj.setPlanStatus(CommonConstants.PLAN_STATUS_1);
|
obj.setPlanStatus(CommonConstants.PLAN_STATUS_1);
|
||||||
obj.setPlanSubStatus(CommonConstants.PLAN_STATUS_1);
|
obj.setPlanSubStatus(CommonConstants.PLAN_STATUS_1);
|
||||||
|
|
||||||
obj.setPlantingDate(e.getPlantingDate());
|
obj.setPlantingDate(e.getPlantingDate());
|
||||||
obj.setPlantingQuantity(e.getPlantingQuantity());
|
obj.setPlantingQuantity(e.getPlantingQuantity());
|
||||||
obj.setPredictedYields(e.getPredictedYields());
|
obj.setPredictedYields(e.getPredictedYields());
|
||||||
obj.setTotalArea(e.getTotalArea());
|
obj.setTotalArea(e.getTotalArea());
|
||||||
obj.setPredictedArea(e.getPredictedArea());
|
obj.setPredictedArea(e.getPredictedArea());
|
||||||
// obj.setRemainingArea(e.getRemainingArea());
|
|
||||||
obj.setUsagePercentage(e.getUsagePercentage());
|
obj.setUsagePercentage(e.getUsagePercentage());
|
||||||
obj.setRemark(e.getRemark());
|
obj.setRemark(e.getRemark());
|
||||||
|
|
||||||
obj.setBaseId(e.getBaseId());
|
obj.setBaseId(e.getBaseId());
|
||||||
obj.setBaseName(baseNameMap.getOrDefault(e.getBaseId(), ""));
|
obj.setBaseName(baseNameMap.getOrDefault(e.getBaseId(), ""));
|
||||||
obj.setPlotId(e.getPlotId());
|
obj.setPlotId(e.getPlotId());
|
||||||
obj.setPlotName(plotNameMap.getOrDefault(e.getPlotId(), ""));
|
obj.setPlotName(plotNameMap.getOrDefault(e.getPlotId(), ""));
|
||||||
obj.setTenantId(getLoginUser().getTenantId().toString());
|
obj.setTenantId(getLoginUser().getTenantId().toString());
|
||||||
|
|
||||||
// 随机字符串 + 地块名称
|
// 创建模型案例 (创建引用模版)
|
||||||
obj.setPlanNumber(StrHelperUtil.generate() + "-" + plotNameMap.getOrDefault(e.getPlotId(), ""));
|
String newSpeciesModelId = modelManagementService.createModelManagementCase(speciesModelId, obj);
|
||||||
String taskId = IdUtil.fastUUID();
|
obj.setSpeciesModelId(newSpeciesModelId);
|
||||||
obj.setId(taskId);
|
|
||||||
// 创建模型案例
|
|
||||||
speciesModelId = modelManagementService.createModelManagementCase(speciesModelId, taskId);
|
|
||||||
if (speciesModelId.equals("")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
obj.setSpeciesModelId(speciesModelId);
|
|
||||||
list.add(obj);
|
list.add(obj);
|
||||||
}
|
}
|
||||||
productionPlanMapper.insertBatch(list);
|
productionPlanMapper.insertBatch(list);
|
||||||
@@ -227,6 +226,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
|||||||
String plotId = productionPlanRespVO.getPlotId();
|
String plotId = productionPlanRespVO.getPlotId();
|
||||||
PlotInfoDO plotIObj = plotInfoService.getPlotInfoByPlotId(plotId);
|
PlotInfoDO plotIObj = plotInfoService.getPlotInfoByPlotId(plotId);
|
||||||
productionPlanRespVO.setPlotManger(employeeNameMap.getOrDefault(plotIObj.getEmployeeId(),"系统"));
|
productionPlanRespVO.setPlotManger(employeeNameMap.getOrDefault(plotIObj.getEmployeeId(),"系统"));
|
||||||
|
// 管理周期
|
||||||
return productionPlanRespVO;
|
return productionPlanRespVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,8 +363,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
|||||||
if (baseObj != null) {
|
if (baseObj != null) {
|
||||||
String employeeId = baseObj.getManager();
|
String employeeId = baseObj.getManager();
|
||||||
ModelManagementDO modelManagementDo = modelManagementService.getModelManagement("id", planObj.getSpeciesModelId());
|
ModelManagementDO modelManagementDo = modelManagementService.getModelManagement("id", planObj.getSpeciesModelId());
|
||||||
String managementCycleName = "";
|
String managementCycleName = modelManagementService.getModelCycleName(planObj.getSpeciesModelId());
|
||||||
|
|
||||||
|
|
||||||
ProductionPlanResp2VO.ModelInfo modelInfo = new ProductionPlanResp2VO.ModelInfo();
|
ProductionPlanResp2VO.ModelInfo modelInfo = new ProductionPlanResp2VO.ModelInfo();
|
||||||
modelInfo.setId(modelManagementDo.getId());
|
modelInfo.setId(modelManagementDo.getId());
|
||||||
|
|||||||
@@ -71,16 +71,14 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
// 员工集合 <id,name>
|
// 员工集合 <id,name>
|
||||||
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
||||||
|
|
||||||
BaseOverviewInfo baseOverviewInfo = new BaseOverviewInfo();
|
BaseOverviewInfo baseOverviewInfo = null;
|
||||||
StatisticalInfo statisticalInfo = new StatisticalInfo();
|
|
||||||
if (StringUtils.isEmpty(baseId)) {
|
if (StringUtils.isEmpty(baseId)) {
|
||||||
baseOverviewInfo = this.getCompanyInfo();
|
baseOverviewInfo = this.getCompanyInfo();
|
||||||
statisticalInfo = this.getStatisticalInfo(baseId);
|
|
||||||
} else {
|
} else {
|
||||||
BaseInfoDO baseObj = baseInfoService.getBaseInfo(baseId);
|
BaseInfoDO baseObj = baseInfoService.getBaseInfo(baseId);
|
||||||
baseOverviewInfo = this.getBaseOverviewInfo(baseObj, employeeNameMap);
|
baseOverviewInfo = this.getBaseOverviewInfo(baseObj, employeeNameMap);
|
||||||
statisticalInfo = this.getStatisticalInfo(baseId);
|
|
||||||
}
|
}
|
||||||
|
StatisticalInfo statisticalInfo = this.getStatisticalInfo(baseId);
|
||||||
|
|
||||||
List<HomeInfo.BaseInfo> baseList = new ArrayList<>();
|
List<HomeInfo.BaseInfo> baseList = new ArrayList<>();
|
||||||
for (BaseInfoDO baseInfoDO : baseInfoService.getBaseInfosById(baseId)) {
|
for (BaseInfoDO baseInfoDO : baseInfoService.getBaseInfosById(baseId)) {
|
||||||
@@ -198,13 +196,14 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
PlotInfoDO plotObj = plotInfoService.getPlotInfoByPlotId(plotId);
|
PlotInfoDO plotObj = plotInfoService.getPlotInfoByPlotId(plotId);
|
||||||
List<ProductionPlanDO> plans = productionPlanService.getProductionPlans(baseId,plotId);
|
List<ProductionPlanDO> plans = productionPlanService.getProductionPlans(baseId,plotId);
|
||||||
for (ProductionPlanDO e : plans) {
|
for (ProductionPlanDO e : plans) {
|
||||||
String beingCropName = productionPlanService.getPlantSpeciesCodeForName(e.getPlantSpeciesCode());
|
|
||||||
String cycleName = modelManagementService.getModelCycleName(e.getSpeciesModelId());
|
|
||||||
String beingPlotArea = productionPlanService.getBeingPlotArea(e.getPlotId(), null);
|
|
||||||
SpeciesLibraryDO speciesLibrary = speciesLibraryService.getSpeciesLibrary(e.getPlantSpeciesCode());
|
SpeciesLibraryDO speciesLibrary = speciesLibraryService.getSpeciesLibrary(e.getPlantSpeciesCode());
|
||||||
if (ObjectUtils.isEmpty(speciesLibrary)) {
|
if (ObjectUtils.isEmpty(speciesLibrary)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
String beingCropName = productionPlanService.getPlantSpeciesCodeForName(e.getPlantSpeciesCode());
|
||||||
|
String beingPlotArea = productionPlanService.getBeingPlotArea(e.getPlotId(), null);
|
||||||
|
// 模型管理-管理周期名称
|
||||||
|
String cycleName = modelManagementService.getModelCycleName(e.getSpeciesModelId());
|
||||||
|
|
||||||
PlanInfo target = new PlanInfo();
|
PlanInfo target = new PlanInfo();
|
||||||
target.setBaseId(e.getBaseId());
|
target.setBaseId(e.getBaseId());
|
||||||
@@ -266,9 +265,14 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
private BaseOverviewInfo getCompanyInfo() {
|
private BaseOverviewInfo getCompanyInfo() {
|
||||||
LoginUser user = getLoginUser();
|
LoginUser user = getLoginUser();
|
||||||
int baseCount = baseInfoService.getBaseCount(user.getTenantId()); // 基地数量
|
int baseCount = baseInfoService.getBaseCount(user.getTenantId()); // 基地数量
|
||||||
int cropCount = cropFarmingCenterService.getCropCount(user.getTenantId()); // 作物数量
|
int cropCount = cropFarmingCenterService.getCropCount(user.getTenantId()); // 作物数mong量
|
||||||
Double temp = cropFarmingCenterService.getTotalArea(user.getTenantId()); // 总面积
|
// Double temp = cropFarmingCenterService.getTotalArea(user.getTenantId()); // 总面积
|
||||||
int totalArea = (int) Math.round(temp);
|
Double temp = baseInfoService.getBaseTotalArea(user.getTenantId().toString()); // 总面积
|
||||||
|
int totalArea = 0;
|
||||||
|
if (!ObjectUtils.isEmpty(temp)) {
|
||||||
|
totalArea = (int) Math.round(temp);
|
||||||
|
}
|
||||||
|
|
||||||
int personnelCount = personnelManagementService.personnelCount(user.getTenantId()); // 在职人员
|
int personnelCount = personnelManagementService.personnelCount(user.getTenantId()); // 在职人员
|
||||||
return new BaseOverviewInfo("",baseCount,cropCount,totalArea,personnelCount);
|
return new BaseOverviewInfo("",baseCount,cropCount,totalArea,personnelCount);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,10 @@ public class ModelCycleServiceImpl implements ModelCycleService {
|
|||||||
ModelCycleDO modelCycle = BeanUtils.toBean(createReqVO, ModelCycleDO.class);
|
ModelCycleDO modelCycle = BeanUtils.toBean(createReqVO, ModelCycleDO.class);
|
||||||
modelCycle.setId(IdUtil.fastUUID());
|
modelCycle.setId(IdUtil.fastUUID());
|
||||||
modelCycle.setTenantId(String.valueOf(user.getTenantId()));
|
modelCycle.setTenantId(String.valueOf(user.getTenantId()));
|
||||||
|
for (String image : createReqVO.getStageImageList()) {
|
||||||
|
modelCycle.setStageImage(image);
|
||||||
|
}
|
||||||
modelCycleMapper.insert(modelCycle);
|
modelCycleMapper.insert(modelCycle);
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
return modelCycle.getId();
|
return modelCycle.getId();
|
||||||
}
|
}
|
||||||
@@ -55,6 +57,9 @@ public class ModelCycleServiceImpl implements ModelCycleService {
|
|||||||
// 校验存在
|
// 校验存在
|
||||||
validateModelCycleExists(updateReqVO.getId());
|
validateModelCycleExists(updateReqVO.getId());
|
||||||
// 更新
|
// 更新
|
||||||
|
for (String image : updateReqVO.getStageImageList()) {
|
||||||
|
updateReqVO.setStageImage(image);
|
||||||
|
}
|
||||||
ModelCycleDO updateObj = BeanUtils.toBean(updateReqVO, ModelCycleDO.class);
|
ModelCycleDO updateObj = BeanUtils.toBean(updateReqVO, ModelCycleDO.class);
|
||||||
modelCycleMapper.updateById(updateObj);
|
modelCycleMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelMan
|
|||||||
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementSaveReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.modelfarmingoperation.ModelFarmingOperationDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.modelfarmingoperation.ModelFarmingOperationDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManagementDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManagementDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -26,7 +27,7 @@ public interface ModelManagementService {
|
|||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
String createModelManagement(@Valid ModelManagementSaveReqVO createReqVO);
|
String createModelManagement(@Valid ModelManagementSaveReqVO createReqVO);
|
||||||
String createModelManagementCase(String id,String taskId);
|
String createModelManagementCase(String id, ProductionPlanDO obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新模型管理
|
* 更新模型管理
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManageme
|
|||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.modelpestdiseaseweed.ModelPestDiseaseWeedDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.modelpestdiseaseweed.ModelPestDiseaseWeedDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.modelweatherdisaster.ModelWeatherDisasterDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.modelweatherdisaster.ModelWeatherDisasterDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.personnelmanagement.SystemUserDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.personnelmanagement.SystemUserDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.specieslibrary.SpeciesLibraryDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.specieslibrary.SpeciesLibraryDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.mysql.farmingrecord.FarmingRecordMapper;
|
import cn.iocoder.yudao.module.farm.dal.mysql.farmingrecord.FarmingRecordMapper;
|
||||||
import cn.iocoder.yudao.module.farm.dal.mysql.modelcycle.ModelCycleMapper;
|
import cn.iocoder.yudao.module.farm.dal.mysql.modelcycle.ModelCycleMapper;
|
||||||
@@ -43,6 +44,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -86,29 +88,33 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
@Override
|
@Override
|
||||||
public String createModelManagement(ModelManagementSaveReqVO createReqVO) {
|
public String createModelManagement(ModelManagementSaveReqVO createReqVO) {
|
||||||
LoginUser user = getLoginUser();
|
LoginUser user = getLoginUser();
|
||||||
|
|
||||||
|
SpeciesLibraryDO speciesLibrary = speciesLibraryService.getSpeciesLibrary(createReqVO.getSpeciesId());
|
||||||
|
// 物种类型拼接物种名称
|
||||||
|
String speciesName = speciesLibrary.getSpeciesName() + "/" + speciesLibrary.getCultivarName();
|
||||||
|
// 物种生命周期 -中文
|
||||||
|
String cycleName = LIFE_CYCLE_MAP.getOrDefault(speciesLibrary.getLifeCycle().toString(),"");
|
||||||
|
|
||||||
// 插入
|
// 插入
|
||||||
ModelManagementDO modelManagement = BeanUtils.toBean(createReqVO, ModelManagementDO.class);
|
ModelManagementDO modelManagement = BeanUtils.toBean(createReqVO, ModelManagementDO.class);
|
||||||
modelManagement.setId(IdUtil.fastUUID());
|
modelManagement.setId(IdUtil.fastUUID());
|
||||||
modelManagement.setTenantId(String.valueOf(user.getTenantId()));
|
modelManagement.setTenantId(String.valueOf(user.getTenantId()));
|
||||||
modelManagement.setIsRelease(0);
|
modelManagement.setIsRelease(0);
|
||||||
modelManagement.setType(CommonConstants.MODEL_TYPE_1);
|
modelManagement.setType(CommonConstants.MODEL_TYPE_1);
|
||||||
|
modelManagement.setSpeciesName(speciesName);
|
||||||
SpeciesLibraryDO speciesLibrary = speciesLibraryService.getSpeciesLibrary(createReqVO.getSpeciesId());
|
|
||||||
modelManagement.setSpeciesName(speciesLibrary.getSpeciesName() + "/" + speciesLibrary.getCultivarName());
|
|
||||||
modelManagement.setCycle(speciesLibrary.getLifeCycle().toString());
|
modelManagement.setCycle(speciesLibrary.getLifeCycle().toString());
|
||||||
modelManagement.setCycleName(LIFE_CYCLE_MAP.getOrDefault(speciesLibrary.getLifeCycle().toString(),""));
|
modelManagement.setCycleName(cycleName);
|
||||||
// 处理suitablePlantingAreas字段,优先使用集合
|
// 处理suitablePlantingAreas字段,优先使用集合
|
||||||
if (createReqVO.getSuitablePlantingAreas() != null && !createReqVO.getSuitablePlantingAreas().isEmpty()) {
|
if (createReqVO.getSuitablePlantingAreas() != null && !createReqVO.getSuitablePlantingAreas().isEmpty()) {
|
||||||
modelManagement.setSuitablePlantingAreasList(createReqVO.getSuitablePlantingAreas());
|
modelManagement.setSuitablePlantingAreasList(createReqVO.getSuitablePlantingAreas());
|
||||||
}
|
}
|
||||||
// 处理speciesImage字段,优先使用图片集合
|
// 处理speciesImage字段,优先使用图片集合
|
||||||
SpeciesLibraryDO libraryDO = speciesLibraryService.getSpeciesLibrary(createReqVO.getSpeciesId());
|
if (speciesLibrary.getImageList() != null && !speciesLibrary.getImageList().isEmpty()) {
|
||||||
if (libraryDO.getImageList() != null && !libraryDO.getImageList().isEmpty()) {
|
modelManagement.setSpeciesImageList(speciesLibrary.getImageList());
|
||||||
modelManagement.setSpeciesImageList(libraryDO.getImageList());
|
|
||||||
} else if (createReqVO.getSpeciesImage() != null) {
|
} else if (createReqVO.getSpeciesImage() != null) {
|
||||||
modelManagement.setSpeciesImageList(libraryDO.getImageList());
|
modelManagement.setSpeciesImageList(speciesLibrary.getImageList());
|
||||||
}
|
}
|
||||||
modelManagement.setSpeciesImage(libraryDO.getImage());
|
modelManagement.setSpeciesImage(speciesLibrary.getImage());
|
||||||
modelManagementMapper.insert(modelManagement);
|
modelManagementMapper.insert(modelManagement);
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
@@ -116,16 +122,20 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createModelManagementCase(String id, String taskId) {
|
public String createModelManagementCase(String id, ProductionPlanDO obj) {
|
||||||
|
String taskId = obj.getId();
|
||||||
|
LocalDate productionStartDate = obj.getProductionStartDate();
|
||||||
|
LocalDate productionEndDate = obj.getProductionEndDate();
|
||||||
|
|
||||||
// 1. 查询原模型(类型为模型模板)
|
// 1. 查询原模型(类型为模型模板)
|
||||||
ModelManagementDO modelManagementDO = modelManagementMapper.selectOne(
|
ModelManagementDO modelManagementDO = modelManagementMapper.selectOne(
|
||||||
ModelManagementDO::getId, id,
|
ModelManagementDO::getId, id,
|
||||||
ModelManagementDO::getType, CommonConstants.MODEL_TYPE_1
|
ModelManagementDO::getType, CommonConstants.MODEL_TYPE_1
|
||||||
);
|
);
|
||||||
|
|
||||||
if (modelManagementDO == null) {
|
if (modelManagementDO == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
modelManagementDO.setQuoteCount(modelManagementDO.getQuoteCount() + 1);
|
modelManagementDO.setQuoteCount(modelManagementDO.getQuoteCount() + 1);
|
||||||
modelManagementMapper.updateById(modelManagementDO);
|
modelManagementMapper.updateById(modelManagementDO);
|
||||||
// 2. 创建新的模型引用案例
|
// 2. 创建新的模型引用案例
|
||||||
@@ -141,13 +151,23 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
|
|
||||||
// 4. 复制模型周期及其子集
|
// 4. 复制模型周期及其子集
|
||||||
List<ModelCycleDO> originalCycles = modelCycleMapper.selectListByModelId(id);
|
List<ModelCycleDO> originalCycles = modelCycleMapper.selectListByModelId(id);
|
||||||
|
long originalStageCount_start = 0;
|
||||||
|
long originalStageCount_end = 0;
|
||||||
for (ModelCycleDO originalCycle : originalCycles) {
|
for (ModelCycleDO originalCycle : originalCycles) {
|
||||||
// 复制周期
|
// 复制周期
|
||||||
ModelCycleDO newCycle = BeanUtils.toBean(originalCycle, ModelCycleDO.class);
|
ModelCycleDO newCycle = BeanUtils.toBean(originalCycle, ModelCycleDO.class);
|
||||||
String newCycleId = IdUtil.fastUUID();
|
String newCycleId = IdUtil.fastUUID();
|
||||||
newCycle.setId(newCycleId);
|
newCycle.setId(newCycleId);
|
||||||
newCycle.setModelId(newModelId);
|
newCycle.setModelId(newModelId);
|
||||||
|
// 设置周期范围-开始.结束日期
|
||||||
|
originalStageCount_end += originalCycle.getStage(); // 阶段天数
|
||||||
|
LocalDate cycleRangeStartDate = productionStartDate.plusDays(originalStageCount_start);
|
||||||
|
LocalDate cycleRangeEndDate = productionEndDate.plusDays(originalStageCount_end);
|
||||||
|
newCycle.setCycleRangeStartDate(cycleRangeStartDate);
|
||||||
|
newCycle.setCycleRangeEndDate(cycleRangeEndDate);
|
||||||
modelCycleMapper.insert(newCycle);
|
modelCycleMapper.insert(newCycle);
|
||||||
|
// 推进阶段天数
|
||||||
|
originalStageCount_start = originalStageCount_end;
|
||||||
|
|
||||||
// 复制环境指标
|
// 复制环境指标
|
||||||
List<ModelEnvironmentIndexDO> environmentIndexes = modelEnvironmentIndexMapper.selectByCycleId(originalCycle.getId());
|
List<ModelEnvironmentIndexDO> environmentIndexes = modelEnvironmentIndexMapper.selectByCycleId(originalCycle.getId());
|
||||||
@@ -279,6 +299,7 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
List<ModelCycleDO> list = modelCycleMapper.selectListByModelId(id);
|
List<ModelCycleDO> list = modelCycleMapper.selectListByModelId(id);
|
||||||
list.forEach(cycle -> {
|
list.forEach(cycle -> {
|
||||||
ModelCycleRespVO vo = BeanUtils.toBean(cycle, ModelCycleRespVO.class);
|
ModelCycleRespVO vo = BeanUtils.toBean(cycle, ModelCycleRespVO.class);
|
||||||
|
vo.setStageImageList(cycle.getStageImageList());
|
||||||
//环境指标
|
//环境指标
|
||||||
List<ModelEnvironmentIndexDO> environmentIndexDO = modelEnvironmentIndexMapper.selectByCycleId(cycle.getId());
|
List<ModelEnvironmentIndexDO> environmentIndexDO = modelEnvironmentIndexMapper.selectByCycleId(cycle.getId());
|
||||||
vo.setEnvironmentIndexDOS(environmentIndexDO);
|
vo.setEnvironmentIndexDOS(environmentIndexDO);
|
||||||
@@ -339,7 +360,7 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (modelManagementDO == null) {
|
if (modelManagementDO == null) {
|
||||||
return "";
|
throw exception(MODEL_MANAGEMENT_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 创建新的模型引用案例
|
// 2. 创建新的模型引用案例
|
||||||
@@ -454,9 +475,37 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelCycleName(String modelId) {
|
public String getModelCycleName(String modelId) {
|
||||||
// TODO: 2025/9/9 这里处理当前日期是否在 排查开始日期+持续天数的范围内
|
LambdaQueryWrapperX<ModelCycleDO> wrapperX = new LambdaQueryWrapperX<>();
|
||||||
List<ModelCycleDO> cycleDOS = modelCycleMapper.selectList("model_id", modelId);
|
wrapperX.eq(ModelCycleDO::getModelId, modelId);
|
||||||
return cycleDOS.stream().findFirst().get().getName();
|
wrapperX.orderByAsc(ModelCycleDO::getCreateTime);
|
||||||
|
List<ModelCycleDO> cycleDOS = modelCycleMapper.selectList(wrapperX);
|
||||||
|
|
||||||
|
String managementCycleName = "";
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
for (ModelCycleDO c : cycleDOS) {
|
||||||
|
LocalDate cycleRangeStartDate = c.getCycleRangeStartDate();
|
||||||
|
LocalDate cycleRangeEndDate = c.getCycleRangeEndDate();
|
||||||
|
String name = c.getName();
|
||||||
|
if (cycleRangeStartDate == null ||cycleRangeEndDate == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果今天在 startDate 与 endDate 的范围内
|
||||||
|
if (!currentDate.isBefore(cycleRangeStartDate) && !currentDate.isAfter(cycleRangeEndDate)) {
|
||||||
|
managementCycleName = name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 如果今天在 startDate 之前
|
||||||
|
else if (currentDate.isBefore(cycleRangeStartDate)) {
|
||||||
|
managementCycleName = name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 如果今天在 endDate 之后
|
||||||
|
else if (currentDate.isAfter(cycleRangeEndDate)) {
|
||||||
|
managementCycleName = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return managementCycleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +15,6 @@ import java.util.List;
|
|||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
public interface PlotInfoService {
|
public interface PlotInfoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建地块
|
* 创建地块
|
||||||
*
|
*
|
||||||
@@ -29,21 +29,18 @@ public interface PlotInfoService {
|
|||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updatePlotInfo(@Valid PlotInfoSaveReqVO updateReqVO);
|
void updatePlotInfo(@Valid PlotInfoSaveReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除地块
|
* 删除地块
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
*/
|
*/
|
||||||
void deletePlotInfo(String id);
|
void deletePlotInfo(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除地块
|
* 批量删除地块
|
||||||
*
|
*
|
||||||
* @param ids 编号
|
* @param ids 编号
|
||||||
*/
|
*/
|
||||||
void deletePlotInfoListByIds(List<String> ids);
|
void deletePlotInfoListByIds(List<String> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得地块
|
* 获得地块
|
||||||
*
|
*
|
||||||
@@ -52,7 +49,17 @@ public interface PlotInfoService {
|
|||||||
*/
|
*/
|
||||||
PlotInfoDO getPlotInfo(String id);
|
PlotInfoDO getPlotInfo(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过基地ID获取地块集合
|
||||||
|
* @param baseId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
List<PlotInfoDO> getPlotInfos(String baseId);
|
List<PlotInfoDO> getPlotInfos(String baseId);
|
||||||
|
/**
|
||||||
|
* 地块集合
|
||||||
|
* @param baseId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
List<PlotInfoDO> getPlotInfos();
|
List<PlotInfoDO> getPlotInfos();
|
||||||
/**
|
/**
|
||||||
* 获得地块分页
|
* 获得地块分页
|
||||||
@@ -61,26 +68,29 @@ public interface PlotInfoService {
|
|||||||
* @return 地块分页
|
* @return 地块分页
|
||||||
*/
|
*/
|
||||||
PageResult<PlotInfoDO> getPlotInfoPage(PlotInfoPageReqVO pageReqVO);
|
PageResult<PlotInfoDO> getPlotInfoPage(PlotInfoPageReqVO pageReqVO);
|
||||||
|
/**
|
||||||
|
* 通过基地ID获取地块
|
||||||
|
* @param plotId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
PlotInfoDO getPlotInfoByPlotId(String plotId);
|
PlotInfoDO getPlotInfoByPlotId(String plotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
void deleteByBaseId(String baseId);
|
void deleteByBaseId(String baseId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户-地块总数
|
* 租户-地块总数
|
||||||
* @param tenantId
|
* @param tenantId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer getPlotTotalCount(String tenantId);
|
Integer getPlotTotalCount(String tenantId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基地下存在地块,则不可删除
|
* 基地下存在地块,则不可删除
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean validatePlotExistByBaseId(String id);
|
boolean validatePlotExistByBaseId(String id);
|
||||||
|
|
||||||
|
boolean validateTotalPlotArea(String baseId, BigDecimal baseArea);
|
||||||
}
|
}
|
||||||
@@ -24,8 +24,7 @@ import java.util.List;
|
|||||||
|
|
||||||
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.PLOT_AREA_ERRORS;
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.PLOT_INFO_NOT_EXISTS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地块 Service 实现类
|
* 地块 Service 实现类
|
||||||
@@ -46,12 +45,8 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
@Override
|
@Override
|
||||||
public String createPlotInfo(PlotInfoSaveReqVO createReqVO) {
|
public String createPlotInfo(PlotInfoSaveReqVO createReqVO) {
|
||||||
LoginUser user = getLoginUser();
|
LoginUser user = getLoginUser();
|
||||||
// 验证地块面积总和 需要小于或等于 基地面积
|
// 校验地块面积
|
||||||
boolean flag = this.validateTotalPlotArea(createReqVO.getBaseId());
|
validatePlotArea(createReqVO.getBaseId(),null,createReqVO.getPlotArea());
|
||||||
if (flag) {
|
|
||||||
throw exception(PLOT_AREA_ERRORS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 插入
|
// 插入
|
||||||
PlotInfoDO plotInfo = BeanUtils.toBean(createReqVO, PlotInfoDO.class);
|
PlotInfoDO plotInfo = BeanUtils.toBean(createReqVO, PlotInfoDO.class);
|
||||||
plotInfo.setId(IdUtil.fastUUID());
|
plotInfo.setId(IdUtil.fastUUID());
|
||||||
@@ -67,16 +62,11 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
public void updatePlotInfo(PlotInfoSaveReqVO updateReqVO) {
|
public void updatePlotInfo(PlotInfoSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validatePlotInfoExists(updateReqVO.getId());
|
validatePlotInfoExists(updateReqVO.getId());
|
||||||
// PlotInfoDO sourcePlotInfoDO = plotInfoMapper.selectById(updateReqVO.getId());
|
// 校验地块面积
|
||||||
// String plotId = sourcePlotInfoDO.getPlotId();
|
validatePlotArea(updateReqVO.getBaseId(), updateReqVO.getId(), updateReqVO.getPlotArea());
|
||||||
// BigDecimal oldArea = sourcePlotInfoDO.getPlotArea();
|
|
||||||
// BigDecimal newArea = updateReqVO.getPlotArea();
|
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
PlotInfoDO updateObj = BeanUtils.toBean(updateReqVO, PlotInfoDO.class);
|
PlotInfoDO updateObj = BeanUtils.toBean(updateReqVO, PlotInfoDO.class);
|
||||||
plotInfoMapper.updateById(updateObj);
|
plotInfoMapper.updateById(updateObj);
|
||||||
// 同步
|
|
||||||
// productionPlanService.syncPlotAreaToAllPlansByBaseId(plotId,newArea,oldArea);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,10 +78,11 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
}
|
}
|
||||||
// 校验: 存在在种地块时 不允许删除
|
// 校验: 存在在种地块时 不允许删除
|
||||||
boolean flag = productionPlanService.validateIncompletePlansBId("plot_id", obj.getPlotId());
|
boolean flag = productionPlanService.validateIncompletePlansBId("plot_id", obj.getPlotId());
|
||||||
// 删除
|
if (!flag) {
|
||||||
if (flag) {
|
throw exception(BEGIN_AREA_ERROR);
|
||||||
plotInfoMapper.deleteById(id);
|
|
||||||
}
|
}
|
||||||
|
// 删除
|
||||||
|
plotInfoMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,6 +97,13 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validatePlotArea(String baseId, String plotId, BigDecimal updatePlotArea) {
|
||||||
|
boolean flag = this.validateCurrentPlotArea(baseId, plotId, updatePlotArea);
|
||||||
|
if (flag) {
|
||||||
|
throw exception(PLOT_AREA_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotInfoDO getPlotInfo(String id) {
|
public PlotInfoDO getPlotInfo(String id) {
|
||||||
PlotInfoDO plotInfoDO = plotInfoMapper.selectById(id);
|
PlotInfoDO plotInfoDO = plotInfoMapper.selectById(id);
|
||||||
@@ -156,12 +154,7 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
return count <= 0;
|
return count <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private boolean validateCurrentPlotArea(String baseId, String plotId, BigDecimal currentPlotArea) {
|
||||||
* 验证: 地块总面积不得大于基地面积
|
|
||||||
*
|
|
||||||
* @param baseId 基地面积
|
|
||||||
*/
|
|
||||||
private boolean validateTotalPlotArea(String baseId) {
|
|
||||||
BaseInfoDO baseObj = baseInfoMapper.selectOne("id", baseId);
|
BaseInfoDO baseObj = baseInfoMapper.selectOne("id", baseId);
|
||||||
BigDecimal baseArea = baseObj.getArea();
|
BigDecimal baseArea = baseObj.getArea();
|
||||||
|
|
||||||
@@ -170,6 +163,29 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BigDecimal plotTotalArea = plotInfoDOS.stream()
|
||||||
|
.map(PlotInfoDO::getPlotArea)
|
||||||
|
.filter(area -> area != null) // 重要:过滤null值
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
|
BigDecimal currentTotalArea = null;
|
||||||
|
if (plotId == null) {
|
||||||
|
currentTotalArea = plotTotalArea.add(currentPlotArea);
|
||||||
|
}else{
|
||||||
|
PlotInfoDO one = plotInfoMapper.selectOne("id", plotId);
|
||||||
|
BigDecimal sourcePlotArea = one.getPlotArea();
|
||||||
|
currentTotalArea = plotTotalArea.subtract(sourcePlotArea).add(currentPlotArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentTotalArea.compareTo(baseArea) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean validateTotalPlotArea(String baseId, BigDecimal baseArea) {
|
||||||
|
List<PlotInfoDO> plotInfoDOS = plotInfoMapper.selectList("base_id", baseId);
|
||||||
|
if (plotInfoDOS == null || plotInfoDOS.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BigDecimal plotTotalArea = plotInfoDOS.stream()
|
BigDecimal plotTotalArea = plotInfoDOS.stream()
|
||||||
.map(PlotInfoDO::getPlotArea)
|
.map(PlotInfoDO::getPlotArea)
|
||||||
.filter(area -> area != null) // 重要:过滤null值
|
.filter(area -> area != null) // 重要:过滤null值
|
||||||
|
|||||||
Reference in New Issue
Block a user