feat (farm): 地块管理
- 添加地块种植类型
This commit is contained in:
@@ -153,7 +153,7 @@ public class HomeInfo {
|
||||
@Schema(description = "种植状态 (1: 在种; 2: 未种;)")
|
||||
private String growFlag;
|
||||
@Schema(description = "种植面积") // 2025/10/15 种植面积 修改为 地块面积 , 字段名为修改!! 只是修改了取值!!!
|
||||
private Double growArea;
|
||||
private Integer growArea;
|
||||
@Schema(description = "在种作物数量") // 2025/10/15 在种作物数量 修改为 物种数量 , 字段名未修改!! 只是修改了取值!!!
|
||||
private Integer beingCrop;
|
||||
@Schema(description = "生产计划任务数量")
|
||||
|
||||
@@ -25,6 +25,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.PLOT_TYPE_NAME_MAP;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
@@ -83,7 +84,12 @@ public class PlotInfoController {
|
||||
@Operation(summary = "获得地块分页")
|
||||
public CommonResult<PageResult<PlotInfoRespVO>> getPlotInfoPage(@Valid PlotInfoPageReqVO pageReqVO) {
|
||||
PageResult<PlotInfoDO> pageResult = plotInfoService.getPlotInfoPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PlotInfoRespVO.class));
|
||||
PageResult<PlotInfoRespVO> result = BeanUtils.toBean(pageResult, PlotInfoRespVO.class);
|
||||
for (PlotInfoRespVO p : result.getList()) {
|
||||
p.setTypeName(PLOT_TYPE_NAME_MAP.get(p.getType()));
|
||||
}
|
||||
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@@ -98,4 +104,6 @@ public class PlotInfoController {
|
||||
BeanUtils.toBean(list, PlotInfoRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -72,6 +72,9 @@ public class BaseInfoRespVO {
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class PlotInfo{
|
||||
@Schema(description = "地块类型")
|
||||
private Integer type;
|
||||
private String typeName;
|
||||
@Schema(description = "地块ID")
|
||||
private String plotId;
|
||||
@Schema(description = "地块名称")
|
||||
|
||||
@@ -54,7 +54,8 @@ public class PlotInfoRespVO {
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "种植类型")
|
||||
private String type;
|
||||
private Integer type;
|
||||
private String typeName;
|
||||
|
||||
@Schema(description = " 租赁状态 (1: 已租; 0: 未租;)")
|
||||
private Integer plotLeaseStatus;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -17,18 +18,31 @@ import lombok.NoArgsConstructor;
|
||||
public class PlotLesseeDetailsRespVO {
|
||||
@Schema(description = "ID")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "姓名")
|
||||
@ExcelProperty("姓名")
|
||||
private String leaseName;
|
||||
|
||||
@Schema(description = "身份证号码")
|
||||
@ExcelProperty("身份证号码")
|
||||
private String leaseIdCard;
|
||||
|
||||
@Schema(description = "手机号码")
|
||||
@ExcelProperty("手机号码")
|
||||
private String leasePhone;
|
||||
|
||||
@Schema(description = "租赁开始日期")
|
||||
@ExcelProperty("租赁开始日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private String leaseStartDate;
|
||||
|
||||
@Schema(description = "租赁接口日期")
|
||||
@ExcelProperty("租赁接口日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private String leaseEndDate;
|
||||
|
||||
@Schema(description = "租赁状态 (1: 当前租赁人; 2: 历史租赁人)")
|
||||
private String leaseStatus;
|
||||
@ExcelProperty("租赁状态")
|
||||
private String leaseStatusName;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ public class PlotLesseeInfoRespVO {
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "种植类型")
|
||||
private String type;
|
||||
private Integer type;
|
||||
private String typeName;
|
||||
|
||||
@Schema(description = " 租赁状态 (1: 已租; 0: 未租;)")
|
||||
private Integer plotLeaseStatus;
|
||||
|
||||
@@ -137,7 +137,7 @@ public class InputLibraryController {
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/usage-records/create")
|
||||
@PostMapping("/usage-records/create")
|
||||
@Operation(summary = "投入品使用日志-新增)")
|
||||
public CommonResult<String> createInputUsageRecords(InputUsageRecordsSaveReqVO req) {
|
||||
inputsManager.createInputUsageRecords(req);
|
||||
|
||||
@@ -104,9 +104,13 @@ public class CommonConstants {
|
||||
public static Map<Integer,String> USAGE_STATUS_MAP = new HashMap<>();
|
||||
public static Map<Integer,String> INPUT_CATEGORY_MAP = new HashMap<>();
|
||||
public static Map<Integer,String> FARMING_RECORD_TASK_STATUS_MAP = new HashMap<>();
|
||||
public static Map<Integer,String> PLOT_TYPE_NAME_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
|
||||
PLOT_TYPE_NAME_MAP.put(1, "种植地块");
|
||||
PLOT_TYPE_NAME_MAP.put(2, "养殖地块");
|
||||
|
||||
FARMING_RECORD_TASK_STATUS_MAP.put(FARMING_RECORD_STATUS_0, "未开始");
|
||||
FARMING_RECORD_TASK_STATUS_MAP.put(FARMING_RECORD_STATUS_1, "开始");
|
||||
FARMING_RECORD_TASK_STATUS_MAP.put(FARMING_RECORD_STATUS_2, "结束");
|
||||
|
||||
@@ -50,6 +50,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
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.module.farm.enums.CommonConstants.PLOT_TYPE_NAME_MAP;
|
||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@@ -308,7 +309,8 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
||||
for (PlotInfoDO aDo : plotList) {
|
||||
String plotManager = employeeMap.getOrDefault(aDo.getEmployeeId(), "系统");
|
||||
List<BaseInfoRespVO.GridInfo> gridInfos = this.packageGridInfo(aDo.getId());
|
||||
BaseInfoRespVO.PlotInfo target = new BaseInfoRespVO.PlotInfo(aDo.getId(), aDo.getPlotName(), aDo.getPlotColor(), BigDecimalUtil.roundedViaMath( aDo.getPlotArea()), plotManager, aDo.getPoint(), gridInfos);
|
||||
String typeName = PLOT_TYPE_NAME_MAP.get(Integer.valueOf(aDo.getType()));
|
||||
BaseInfoRespVO.PlotInfo target = new BaseInfoRespVO.PlotInfo(Integer.valueOf(aDo.getType()),typeName,aDo.getId(), aDo.getPlotName(), aDo.getPlotColor(), BigDecimalUtil.roundedViaMath( aDo.getPlotArea()), plotManager, aDo.getPoint(), gridInfos);
|
||||
targetList.add(target);
|
||||
}
|
||||
return targetList;
|
||||
|
||||
@@ -201,7 +201,7 @@ public class HomeServiceImpl implements HomeService {
|
||||
t.setPlotId(e.getPlotId());
|
||||
t.setPlotName(e.getPlotName());
|
||||
t.setGrowFlag(growFlag);
|
||||
t.setGrowArea(e.getPlotArea().doubleValue());
|
||||
t.setGrowArea(e.getPlotArea().intValue());
|
||||
t.setBeingCrop(growingCropCount);
|
||||
t.setTaskCount(taskCount);
|
||||
t.setLotCount(iotCount);
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.stream.Collectors;
|
||||
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.module.farm.enums.CommonConstants.LEASE_STATUS_MAP;
|
||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.PLOT_TYPE_NAME_MAP;
|
||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@@ -71,9 +72,11 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
||||
plotInfo.setTenantId(String.valueOf(user.getTenantId()));
|
||||
plotInfoMapper.insert(plotInfo);
|
||||
|
||||
PlotLesseeSaveReqVO plotLesseeSaveReqVO = createReqVO.getPlotLessee();
|
||||
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
||||
insertLessee(plotLesseeDO, createReqVO.getBaseId(), plotInfo.getId(), plotInfo.getPlotName());
|
||||
if (createReqVO.getPlotLeaseStatus() == 1) {
|
||||
PlotLesseeSaveReqVO plotLesseeSaveReqVO = createReqVO.getPlotLessee();
|
||||
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
||||
insertLessee(plotLesseeDO, createReqVO.getBaseId(), plotInfo.getId(), plotInfo.getPlotName());
|
||||
}
|
||||
|
||||
// 返回
|
||||
return plotInfo.getId();
|
||||
@@ -102,6 +105,10 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
||||
PlotInfoDO plotInfo = BeanUtils.toBean(updateReqVO, PlotInfoDO.class);
|
||||
plotInfoMapper.updateById(plotInfo);
|
||||
|
||||
if (updateReqVO.getPlotLeaseStatus() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 重置所有租赁状态为: 未租
|
||||
List<PlotLesseeDO> doList = plotLesseeMapper.selectList("plot_id", updateReqVO.getId());
|
||||
doList.forEach(e -> e.setLeaseStatus(CommonConstants.NO_CODE));
|
||||
@@ -180,6 +187,7 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
||||
|
||||
PlotInfoDO plotInfoDO = this.getPlotInfo(id);
|
||||
PlotLesseeInfoRespVO plotLesseeDetailsRespVO = BeanUtils.toBean(plotInfoDO, PlotLesseeInfoRespVO.class);
|
||||
plotLesseeDetailsRespVO.setTypeName(PLOT_TYPE_NAME_MAP.get(plotLesseeDetailsRespVO.getType()));
|
||||
plotLesseeDetailsRespVO.setPlotLessee(subLesseeInfo);
|
||||
plotLesseeDetailsRespVO.setPlotLeaseStatusName(LEASE_STATUS_MAP.get(plotLesseeDetailsRespVO.getPlotLeaseStatus()));
|
||||
return plotLesseeDetailsRespVO;
|
||||
|
||||
@@ -129,6 +129,11 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
||||
LambdaQueryWrapperX<ProductionPlanDO> qw = new LambdaQueryWrapperX<>();
|
||||
qw.eqIfPresent(ProductionPlanDO::getBaseId, baseId);
|
||||
qw.eqIfPresent(ProductionPlanDO::getPlotId, plotId);
|
||||
// 获取当年的开始和结束日期
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate startOfYear = LocalDate.of(now.getYear(), 1, 1); // 当年1月1日
|
||||
LocalDate endOfYear = LocalDate.of(now.getYear(), 12, 31); // 当年12月31日
|
||||
qw.between(ProductionPlanDO::getProductionStartDate, startOfYear, endOfYear);
|
||||
return productionPlanMapper.selectList(qw);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user