farm模块-农事记录新增
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.Produc
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordCreateReqVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecord.FarmingRecordDO;
|
||||
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
|
||||
import cn.iocoder.yudao.module.farm.service.cropFarmingCenter.CropFarmingCenterService;
|
||||
@@ -152,8 +153,8 @@ public class CropFarmingCenterController {
|
||||
|
||||
@PostMapping("/farming-record/create")
|
||||
@Operation(summary = "农事记录-新增")
|
||||
public CommonResult<String> createFarmingRecord(@Valid @RequestBody FarmingRecordSaveReqVO createReqVO) {
|
||||
return success(farmingRecordService.createFarmingRecord(createReqVO));
|
||||
public CommonResult<String> createFarmingRecord(@Valid @RequestBody FarmingRecordCreateReqVO createReqVO) {
|
||||
return success(farmingRecordService.createFarmingRecordNew(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/farming-record/update")
|
||||
|
||||
@@ -27,6 +27,7 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPOR
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordCreateReqVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecord.FarmingRecordDO;
|
||||
import cn.iocoder.yudao.module.farm.service.farmingrecord.FarmingRecordService;
|
||||
|
||||
@@ -46,6 +47,13 @@ public class FarmingRecordController {
|
||||
return success(farmingRecordService.createFarmingRecord(createReqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/create-new")
|
||||
@Operation(summary = "创建种植中心-农事基地-农事记录(新格式)")
|
||||
|
||||
public CommonResult<String> createFarmingRecordNew(@Valid @RequestBody FarmingRecordCreateReqVO createReqVO) {
|
||||
return success(farmingRecordService.createFarmingRecordNew(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新种植中心-农事基地-农事记录")
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 种植中心-农事基地-农事记录创建 Request VO")
|
||||
@Data
|
||||
public class FarmingRecordCreateReqVO {
|
||||
|
||||
@Schema(description = "任务类型", example = "1")
|
||||
private String taskType;
|
||||
|
||||
@Schema(description = "任务名称", example = "芋艿")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "任务范围")
|
||||
private String taskScope;
|
||||
|
||||
@Schema(description = "任务时间范围", example = "['2025-08-31', '2025-09-30']")
|
||||
private List<String> taskTime;
|
||||
|
||||
@Schema(description = "所属地块", example = "10480")
|
||||
private String plotId;
|
||||
|
||||
@Schema(description = "生产计划ID", example = "24782")
|
||||
private String productionPlanId;
|
||||
|
||||
@Schema(description = "执行人ID列表")
|
||||
private List<String> executor;
|
||||
|
||||
@Schema(description = "实际用工")
|
||||
private Integer actualLaborCost;
|
||||
|
||||
@Schema(description = "日工", example = "111,111,111")
|
||||
private String dayLaborer;
|
||||
|
||||
@Schema(description = "实际投入品ID", example = "5691")
|
||||
private String actualInputId;
|
||||
|
||||
@Schema(description = "执行反馈-备注")
|
||||
private String feedbackNotes;
|
||||
|
||||
@Schema(description = "执行反馈-图片URL集合")
|
||||
private List<String> feedbackImageUrlList;
|
||||
|
||||
@Schema(description = "逻辑删除标识符", example = "1")
|
||||
private Boolean delStatus;
|
||||
|
||||
@Schema(description = "基地id", example = "28798")
|
||||
private String baseId;
|
||||
|
||||
@Schema(description = "基地", example = "李四")
|
||||
private String baseName;
|
||||
|
||||
@Schema(description = "地块", example = "赵六")
|
||||
private String plotName;
|
||||
|
||||
@Schema(description = "租户id", example = "23744")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "投入品列表")
|
||||
private List<InvestGoodsItem> investGoodsList;
|
||||
|
||||
@Schema(description = "投入品项目")
|
||||
@Data
|
||||
public static class InvestGoodsItem {
|
||||
@Schema(description = "投入品ID")
|
||||
private String inputsId;
|
||||
|
||||
@Schema(description = "资产类型")
|
||||
private String assetType;
|
||||
|
||||
@Schema(description = "用量")
|
||||
private BigDecimal dose;
|
||||
|
||||
@Schema(description = "单位")
|
||||
private String unit;
|
||||
|
||||
@Schema(description = "包装单位")
|
||||
private String packageUnit;
|
||||
|
||||
@Schema(description = "稀释")
|
||||
private String diluted;
|
||||
|
||||
@Schema(description = "用法")
|
||||
private String usage;
|
||||
|
||||
@Schema(description = "投入品名称")
|
||||
private String inputsName;
|
||||
|
||||
@Schema(description = "单位名称")
|
||||
private String unitName;
|
||||
|
||||
@Schema(description = "包装单位名称")
|
||||
private String packageUnitName;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@@ -23,8 +24,7 @@ public class FarmingRecordPageReqVO extends PageParam {
|
||||
private String taskScope;
|
||||
|
||||
@Schema(description = "任务时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] taskTime;
|
||||
private String taskTime;
|
||||
|
||||
@Schema(description = "所属地块", example = "10480")
|
||||
private String plotId;
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import cn.idev.excel.annotation.*;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecordinput.FarmingRecordInputDO;
|
||||
|
||||
@Schema(description = "管理后台 - 种植中心-农事基地-农事记录 Response VO")
|
||||
@Data
|
||||
@@ -31,7 +32,7 @@ public class FarmingRecordRespVO {
|
||||
|
||||
@Schema(description = "任务时间")
|
||||
@ExcelProperty("任务时间")
|
||||
private LocalDateTime taskTime;
|
||||
private List<String> taskTime;
|
||||
|
||||
@Schema(description = "所属地块", example = "10480")
|
||||
@ExcelProperty("所属地块")
|
||||
@@ -43,7 +44,7 @@ public class FarmingRecordRespVO {
|
||||
|
||||
@Schema(description = "执行人")
|
||||
@ExcelProperty("执行人")
|
||||
private String executor;
|
||||
private List<String> executor;
|
||||
|
||||
@Schema(description = "实际用工")
|
||||
@ExcelProperty("实际用工")
|
||||
@@ -84,6 +85,9 @@ public class FarmingRecordRespVO {
|
||||
@ExcelProperty("租户id")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "投入品列表")
|
||||
private List<FarmingRecordInputDO> investGoodsList;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class FarmingRecordSaveReqVO {
|
||||
private String taskScope;
|
||||
|
||||
@Schema(description = "任务时间")
|
||||
private LocalDateTime taskTime;
|
||||
private String taskTime;
|
||||
|
||||
@Schema(description = "所属地块", example = "10480")
|
||||
private String plotId;
|
||||
|
||||
@@ -8,7 +8,9 @@ import jakarta.validation.Valid;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -24,6 +26,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
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 cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
@@ -44,14 +47,12 @@ public class FarmingRecordInputController {
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建种植中心-农事基地-农事记录-投入品")
|
||||
|
||||
public CommonResult<String> createFarmingRecordInput(@Valid @RequestBody FarmingRecordInputSaveReqVO createReqVO) {
|
||||
return success(farmingRecordInputService.createFarmingRecordInput(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新种植中心-农事基地-农事记录-投入品")
|
||||
|
||||
public CommonResult<Boolean> updateFarmingRecordInput(@Valid @RequestBody FarmingRecordInputSaveReqVO updateReqVO) {
|
||||
farmingRecordInputService.updateFarmingRecordInput(updateReqVO);
|
||||
return success(true);
|
||||
@@ -60,7 +61,6 @@ public class FarmingRecordInputController {
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除种植中心-农事基地-农事记录-投入品")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
|
||||
public CommonResult<Boolean> deleteFarmingRecordInput(@RequestParam("id") String id) {
|
||||
farmingRecordInputService.deleteFarmingRecordInput(id);
|
||||
return success(true);
|
||||
@@ -69,7 +69,6 @@ public class FarmingRecordInputController {
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除种植中心-农事基地-农事记录-投入品")
|
||||
|
||||
public CommonResult<Boolean> deleteFarmingRecordInputList(@RequestParam("ids") List<String> ids) {
|
||||
farmingRecordInputService.deleteFarmingRecordInputListByIds(ids);
|
||||
return success(true);
|
||||
@@ -78,7 +77,6 @@ public class FarmingRecordInputController {
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得种植中心-农事基地-农事记录-投入品")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
|
||||
public CommonResult<FarmingRecordInputRespVO> getFarmingRecordInput(@RequestParam("id") String id) {
|
||||
FarmingRecordInputDO farmingRecordInput = farmingRecordInputService.getFarmingRecordInput(id);
|
||||
return success(BeanUtils.toBean(farmingRecordInput, FarmingRecordInputRespVO.class));
|
||||
@@ -86,7 +84,6 @@ public class FarmingRecordInputController {
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得种植中心-农事基地-农事记录-投入品分页")
|
||||
|
||||
public CommonResult<PageResult<FarmingRecordInputRespVO>> getFarmingRecordInputPage(@Valid FarmingRecordInputPageReqVO pageReqVO) {
|
||||
PageResult<FarmingRecordInputDO> pageResult = farmingRecordInputService.getFarmingRecordInputPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, FarmingRecordInputRespVO.class));
|
||||
@@ -94,15 +91,14 @@ public class FarmingRecordInputController {
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出种植中心-农事基地-农事记录-投入品 Excel")
|
||||
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportFarmingRecordInputExcel(@Valid FarmingRecordInputPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<FarmingRecordInputDO> list = farmingRecordInputService.getFarmingRecordInputPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "种植中心-农事基地-农事记录-投入品.xls", "数据", FarmingRecordInputRespVO.class,
|
||||
BeanUtils.toBean(list, FarmingRecordInputRespVO.class));
|
||||
BeanUtils.toBean(list, FarmingRecordInputRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ public class FarmingRecordDO extends BaseDO {
|
||||
/**
|
||||
* 任务时间
|
||||
*/
|
||||
private LocalDateTime taskTime;
|
||||
private String taskTime;
|
||||
/**
|
||||
* 所属地块
|
||||
*/
|
||||
@@ -81,6 +82,18 @@ public class FarmingRecordDO extends BaseDO {
|
||||
@TableField(exist = false)
|
||||
private List<String> feedbackImageUrlList;
|
||||
|
||||
/**
|
||||
* 任务时间集合
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<String> taskTimeList;
|
||||
|
||||
/**
|
||||
* 执行人集合
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<String> executorList;
|
||||
|
||||
/**
|
||||
* 逻辑删除标识符
|
||||
*/
|
||||
@@ -119,4 +132,45 @@ public class FarmingRecordDO extends BaseDO {
|
||||
this.feedbackImageUrlList = feedbackImageUrlList;
|
||||
this.feedbackImageUrl = ImageCollectionUtil.toDatabaseString(feedbackImageUrlList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务时间集合
|
||||
*/
|
||||
public List<String> getTaskTimeList() {
|
||||
if (taskTimeList == null && taskTime != null) {
|
||||
taskTimeList = new ArrayList<>();
|
||||
taskTimeList.add(taskTime);
|
||||
}
|
||||
return taskTimeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务时间集合
|
||||
*/
|
||||
public void setTaskTimeList(List<String> taskTimeList) {
|
||||
this.taskTimeList = taskTimeList;
|
||||
if (taskTimeList != null && !taskTimeList.isEmpty()) {
|
||||
this.taskTime = taskTimeList.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取执行人集合
|
||||
*/
|
||||
public List<String> getExecutorList() {
|
||||
if (executorList == null && executor != null) {
|
||||
executorList = Arrays.asList(executor.split(","));
|
||||
}
|
||||
return executorList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置执行人集合
|
||||
*/
|
||||
public void setExecutorList(List<String> executorList) {
|
||||
this.executorList = executorList;
|
||||
if (executorList != null && !executorList.isEmpty()) {
|
||||
this.executor = String.join(",", executorList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public interface FarmingRecordMapper extends BaseMapperX<FarmingRecordDO> {
|
||||
.eqIfPresent(FarmingRecordDO::getTaskType, reqVO.getTaskType())
|
||||
.likeIfPresent(FarmingRecordDO::getTaskName, reqVO.getTaskName())
|
||||
.eqIfPresent(FarmingRecordDO::getTaskScope, reqVO.getTaskScope())
|
||||
.betweenIfPresent(FarmingRecordDO::getTaskTime, reqVO.getTaskTime())
|
||||
.eqIfPresent(FarmingRecordDO::getTaskTime, reqVO.getTaskTime())
|
||||
.eqIfPresent(FarmingRecordDO::getPlotId, reqVO.getPlotId())
|
||||
.eqIfPresent(FarmingRecordDO::getProductionPlanId, reqVO.getProductionPlanId())
|
||||
.eqIfPresent(FarmingRecordDO::getExecutor, reqVO.getExecutor())
|
||||
|
||||
@@ -44,7 +44,8 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
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.ErrorCodeConstants.PRODUCTION_PLAN_NOT_EXISTS;
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
/**
|
||||
* @description: 种植中心
|
||||
@@ -109,11 +110,11 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
obj.setBaseId(e.getBaseId());
|
||||
obj.setBaseName(baseNameMap.getOrDefault(e.getBaseId(), ""));
|
||||
obj.setPlotId(e.getPlotId());
|
||||
obj.setPlotName(plotNameMap.getOrDefault(e.getPlotId(),""));
|
||||
obj.setPlotName(plotNameMap.getOrDefault(e.getPlotId(), ""));
|
||||
obj.setTenantId(getLoginUser().getTenantId().toString());
|
||||
|
||||
// 随机字符串 + 地块名称
|
||||
obj.setPlanNumber(StrHelperUtil.generate() + "-" + plotNameMap.getOrDefault(e.getPlotId(),""));
|
||||
obj.setPlanNumber(StrHelperUtil.generate() + "-" + plotNameMap.getOrDefault(e.getPlotId(), ""));
|
||||
String taskId = IdUtil.fastUUID();
|
||||
obj.setId(taskId);
|
||||
// 创建模型案例
|
||||
@@ -166,7 +167,6 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
farmingRecordReq.setTaskType("农事操作");
|
||||
farmingRecordReq.setTaskName(operation.getFarmingName());
|
||||
farmingRecordReq.setTaskScope(cycle.getName());
|
||||
farmingRecordReq.setTaskTime(operationDate.atStartOfDay());
|
||||
farmingRecordReq.setPlotId(plotId);
|
||||
farmingRecordReq.setProductionPlanId(productionPlanId);
|
||||
farmingRecordReq.setExecutor("系统生成");
|
||||
@@ -321,7 +321,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
subNode.setPlanId(subPlan.getId());
|
||||
subNode.setPlanNumber(subPlan.getPlanNumber());
|
||||
subNode.setPlanStatus(subPlan.getPlanStatus());
|
||||
subNode.setPlanStatusName(PLAN_MAP.getOrDefault(subPlan.getPlanStatus(),""));
|
||||
subNode.setPlanStatusName(PLAN_MAP.getOrDefault(subPlan.getPlanStatus(), ""));
|
||||
subNode.setProductionStartDate(subPlan.getProductionStartDate());
|
||||
subNode.setProductionEndDate(subPlan.getProductionEndDate());
|
||||
subNode.setHarvestStartDate(subPlan.getHarvestStartDate());
|
||||
@@ -329,7 +329,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
subNode.setOverdueDays(this.countOverdueDays(subPlan));
|
||||
subNode.setIntervalDays(this.countIntervalDays(subPlan));
|
||||
subNode.setPlanOverview(this.getPlanOverview(subPlan));
|
||||
subNode.setModelInfo(this.getModelManagement(subPlan,employeeNameMap));
|
||||
subNode.setModelInfo(this.getModelManagement(subPlan, employeeNameMap));
|
||||
nodes.add(subNode);
|
||||
|
||||
id++;
|
||||
@@ -344,7 +344,8 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
source.setTotalArea(baseObj.getArea());
|
||||
return BeanUtils.toBean(source, ProductionPlanResp2VO.PlanOverview.class);
|
||||
}
|
||||
public ProductionPlanResp2VO.ModelInfo getModelManagement(ProductionPlanDO planObj,Map<String, String> employeeNameMap) {
|
||||
|
||||
public ProductionPlanResp2VO.ModelInfo getModelManagement(ProductionPlanDO planObj, Map<String, String> employeeNameMap) {
|
||||
|
||||
BaseInfoDO baseObj = baseInfoMapper.selectOne("id", planObj.getBaseId());
|
||||
String employeeId = baseObj.getManager();
|
||||
@@ -451,11 +452,11 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
return;
|
||||
}
|
||||
// 只有逾期状态 才需要状态回退
|
||||
if (ObjectUtils.notEqual(currentPlanStatus,PLAN_STATUS_4)) {
|
||||
if (ObjectUtils.notEqual(currentPlanStatus, PLAN_STATUS_4)) {
|
||||
return;
|
||||
}
|
||||
// 状态回退 逾期未开始 -> 未开始
|
||||
if (ObjectUtils.notEqual(currentPlanSubStatus,PLAN_STATUS_5)) {
|
||||
if (ObjectUtils.notEqual(currentPlanSubStatus, PLAN_STATUS_5)) {
|
||||
if (today.isBefore(newProductionEndDate) || today.isEqual(newProductionEndDate)) { // eg: 8.1 - 8.21(today) - 8.30(newProductionEndDate)
|
||||
updateObj.setPlanStatus(PLAN_STATUS_1);
|
||||
updateObj.setPlanSubStatus(PLAN_STATUS_1);
|
||||
@@ -467,7 +468,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
}
|
||||
|
||||
// 状态还原 逾期未结束 -> 进行中
|
||||
if (ObjectUtils.notEqual(currentPlanSubStatus,PLAN_STATUS_6)) {
|
||||
if (ObjectUtils.notEqual(currentPlanSubStatus, PLAN_STATUS_6)) {
|
||||
if (today.isBefore(newProductionEndDate) || today.isEqual(newProductionEndDate)) {
|
||||
updateObj.setPlanStatus(PLAN_STATUS_2);
|
||||
updateObj.setPlanSubStatus(PLAN_STATUS_2);
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.farm.service.farmingrecord;
|
||||
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordCreateReqVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecord.FarmingRecordDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@@ -24,6 +25,14 @@ public interface FarmingRecordService {
|
||||
*/
|
||||
String createFarmingRecord(@Valid FarmingRecordSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 创建种植中心-农事基地-农事记录(新格式)
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
String createFarmingRecordNew(@Valid FarmingRecordCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新种植中心-农事基地-农事记录
|
||||
*
|
||||
|
||||
@@ -6,19 +6,27 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordCreateReqVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecord.FarmingRecordDO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecordinput.FarmingRecordInputDO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingtypemaintenance.FarmingTypeMaintenanceDO;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.farmingrecord.FarmingRecordMapper;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.farmingrecordinput.FarmingRecordInputMapper;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.farmingtypemaintenance.FarmingTypeMaintenanceMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
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.ErrorCodeConstants.FARMING_RECORD_NOT_EXISTS;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
|
||||
/**
|
||||
* 种植中心-农事基地-农事记录 Service 实现类
|
||||
*
|
||||
@@ -32,6 +40,8 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
|
||||
private FarmingRecordMapper farmingRecordMapper;
|
||||
@Resource
|
||||
private FarmingRecordInputMapper farmingRecordInputMapper;
|
||||
@Resource
|
||||
private FarmingTypeMaintenanceMapper farmingTypeMaintenanceMapper;
|
||||
|
||||
@Override
|
||||
public String createFarmingRecord(FarmingRecordSaveReqVO createReqVO) {
|
||||
@@ -94,6 +104,17 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
|
||||
if (farmingRecord != null) {
|
||||
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
|
||||
farmingRecord.getFeedbackImageUrlList();
|
||||
|
||||
// 触发任务时间和执行人集合转换,确保返回格式一致
|
||||
farmingRecord.getTaskTimeList();
|
||||
farmingRecord.getExecutorList();
|
||||
|
||||
// 查询并填充投入品列表,确保返回格式一致
|
||||
List<FarmingRecordInputDO> inputs = farmingRecordInputMapper.selectList(
|
||||
new LambdaQueryWrapperX<FarmingRecordInputDO>()
|
||||
.eq(FarmingRecordInputDO::getFarmRecordId, farmingRecord.getId())
|
||||
);
|
||||
farmingRecord.setInvestGoodsList(inputs);
|
||||
}
|
||||
return farmingRecord;
|
||||
}
|
||||
@@ -102,16 +123,88 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
|
||||
public PageResult<FarmingRecordDO> getFarmingRecordPage(FarmingRecordPageReqVO pageReqVO) {
|
||||
PageResult<FarmingRecordDO> pageResult = farmingRecordMapper.selectPage(pageReqVO);
|
||||
if (pageResult.getList() != null) {
|
||||
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
|
||||
// 同时填充投入品列表,确保返回格式一致
|
||||
pageResult.getList().forEach(farmingRecord -> {
|
||||
if (farmingRecord != null) {
|
||||
// 触发图片集合转换
|
||||
farmingRecord.getFeedbackImageUrlList();
|
||||
|
||||
// 触发任务时间和执行人集合转换,确保返回格式一致
|
||||
farmingRecord.getTaskTimeList();
|
||||
farmingRecord.getExecutorList();
|
||||
FarmingTypeMaintenanceDO farmingTypeMaintenanceDO = farmingTypeMaintenanceMapper.selectOne(FarmingTypeMaintenanceDO::getFarmingCode, farmingRecord.getTaskType());
|
||||
farmingRecord.setTaskType(farmingTypeMaintenanceDO.getFarmingName());
|
||||
// 查询并填充投入品列表
|
||||
List<FarmingRecordInputDO> inputs = farmingRecordInputMapper.selectList(
|
||||
new LambdaQueryWrapperX<FarmingRecordInputDO>()
|
||||
.eq(FarmingRecordInputDO::getFarmRecordId, farmingRecord.getId())
|
||||
);
|
||||
farmingRecord.setInvestGoodsList(inputs);
|
||||
}
|
||||
});
|
||||
}
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFarmingRecordNew(FarmingRecordCreateReqVO createReqVO) {
|
||||
LoginUser user = getLoginUser();
|
||||
|
||||
// 转换时间格式:取第一个时间作为任务时间
|
||||
String taskTime = null;
|
||||
if (createReqVO.getTaskTime() != null && !createReqVO.getTaskTime().isEmpty()) {
|
||||
try {
|
||||
taskTime = String.join(",", createReqVO.getTaskTime());
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("任务时间格式错误,应为 yyyy-MM-dd 格式");
|
||||
}
|
||||
}
|
||||
|
||||
// 转换执行人:将数组转换为逗号分隔的字符串
|
||||
String executor = null;
|
||||
if (createReqVO.getExecutor() != null && !createReqVO.getExecutor().isEmpty()) {
|
||||
executor = String.join(",", createReqVO.getExecutor());
|
||||
}
|
||||
|
||||
// 创建FarmingRecordSaveReqVO对象
|
||||
FarmingRecordSaveReqVO saveReqVO = new FarmingRecordSaveReqVO();
|
||||
saveReqVO.setTaskType(createReqVO.getTaskType());
|
||||
saveReqVO.setTaskName(createReqVO.getTaskName());
|
||||
saveReqVO.setTaskScope(createReqVO.getTaskScope());
|
||||
saveReqVO.setTaskTime(taskTime);
|
||||
saveReqVO.setPlotId(createReqVO.getPlotId());
|
||||
saveReqVO.setProductionPlanId(createReqVO.getProductionPlanId());
|
||||
saveReqVO.setExecutor(executor);
|
||||
saveReqVO.setActualLaborCost(createReqVO.getActualLaborCost());
|
||||
saveReqVO.setFeedbackNotes(createReqVO.getFeedbackNotes());
|
||||
saveReqVO.setFeedbackImageUrlList(createReqVO.getFeedbackImageUrlList());
|
||||
saveReqVO.setBaseId(createReqVO.getBaseId());
|
||||
saveReqVO.setBaseName(createReqVO.getBaseName());
|
||||
saveReqVO.setPlotName(createReqVO.getPlotName());
|
||||
saveReqVO.setTenantId(createReqVO.getTenantId());
|
||||
|
||||
// 转换投入品列表
|
||||
if (createReqVO.getInvestGoodsList() != null && !createReqVO.getInvestGoodsList().isEmpty()) {
|
||||
List<FarmingRecordInputDO> inputList = createReqVO.getInvestGoodsList().stream()
|
||||
.map(item -> {
|
||||
FarmingRecordInputDO input = new FarmingRecordInputDO();
|
||||
input.setId(IdUtil.fastUUID());
|
||||
input.setDosage(item.getDose());
|
||||
input.setUsage(item.getUsage());
|
||||
input.setBaseId(createReqVO.getBaseId());
|
||||
input.setBaseName(createReqVO.getBaseName());
|
||||
input.setPlotId(createReqVO.getPlotId());
|
||||
input.setPlotName(createReqVO.getPlotName());
|
||||
input.setTenantId(createReqVO.getTenantId());
|
||||
return input;
|
||||
}).collect(Collectors.toList());
|
||||
saveReqVO.setInvestGoodsList(inputList);
|
||||
}
|
||||
|
||||
// 调用原有的创建方法
|
||||
return createFarmingRecord(saveReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理图片集合转换
|
||||
* 优先使用图片集合,如果图片集合为空则使用字符串
|
||||
|
||||
@@ -2,16 +2,16 @@ package cn.iocoder.yudao.module.farm.service.mqtt;
|
||||
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceinfo.DeviceInfoDO;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.deviceinfo.DeviceInfoMapper;
|
||||
import cn.iocoder.yudao.module.farm.service.telemetry.DeviceTelemetryService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import cn.iocoder.yudao.module.farm.service.telemetry.DeviceTelemetryService;
|
||||
|
||||
@Service
|
||||
public class DeviceMqttService {
|
||||
|
||||
Reference in New Issue
Block a user