fix (farm):
- 农事记录-修改bug
This commit is contained in:
@@ -234,8 +234,8 @@ public class CropFarmingCenterController {
|
|||||||
|
|
||||||
@PutMapping("/farming-record/update")
|
@PutMapping("/farming-record/update")
|
||||||
@Operation(summary = "农事记录-编辑")
|
@Operation(summary = "农事记录-编辑")
|
||||||
public CommonResult<Boolean> updateFarmingRecord(@Valid @RequestBody FarmingRecordSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateFarmingRecord(@Valid @RequestBody FarmingRecordCreateReqVO updateReqVO) {
|
||||||
cropFarmingCenterService.updateFarmingRecord(updateReqVO);
|
cropFarmingCenterService.updateFarmingRecordNew(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class FarmingRecordCreateReqVO {
|
public class FarmingRecordCreateReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "基础id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22116")
|
||||||
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "任务类型", example = "1")
|
@Schema(description = "任务类型", example = "1")
|
||||||
private String taskType;
|
private String taskType;
|
||||||
|
|
||||||
@@ -61,40 +64,40 @@ public class FarmingRecordCreateReqVO {
|
|||||||
@Schema(description = "租户id", example = "23744")
|
@Schema(description = "租户id", example = "23744")
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
@Schema(description = "投入品列表")
|
// @Schema(description = "投入品列表")
|
||||||
private List<InvestGoodsItem> investGoodsList;
|
// private List<InvestGoodsItem> investGoodsList;
|
||||||
|
//
|
||||||
@Schema(description = "投入品项目")
|
// @Schema(description = "投入品项目")
|
||||||
@Data
|
// @Data
|
||||||
public static class InvestGoodsItem {
|
// public static class InvestGoodsItem {
|
||||||
@Schema(description = "投入品ID")
|
// @Schema(description = "投入品ID")
|
||||||
private String inputsId;
|
// private String inputsId;
|
||||||
|
//
|
||||||
@Schema(description = "资产类型")
|
// @Schema(description = "资产类型")
|
||||||
private String assetType;
|
// private String assetType;
|
||||||
|
//
|
||||||
@Schema(description = "用量")
|
// @Schema(description = "用量")
|
||||||
private BigDecimal dose;
|
// private BigDecimal dose;
|
||||||
|
//
|
||||||
@Schema(description = "单位")
|
// @Schema(description = "单位")
|
||||||
private String unit;
|
// private String unit;
|
||||||
|
//
|
||||||
@Schema(description = "包装单位")
|
// @Schema(description = "包装单位")
|
||||||
private String packageUnit;
|
// private String packageUnit;
|
||||||
|
//
|
||||||
@Schema(description = "稀释")
|
// @Schema(description = "稀释")
|
||||||
private String diluted;
|
// private String diluted;
|
||||||
|
//
|
||||||
@Schema(description = "用法")
|
// @Schema(description = "用法")
|
||||||
private String usage;
|
// private String usage;
|
||||||
|
//
|
||||||
@Schema(description = "投入品名称")
|
// @Schema(description = "投入品名称")
|
||||||
private String inputsName;
|
// private String inputsName;
|
||||||
|
//
|
||||||
@Schema(description = "单位名称")
|
// @Schema(description = "单位名称")
|
||||||
private String unitName;
|
// private String unitName;
|
||||||
|
//
|
||||||
@Schema(description = "包装单位名称")
|
// @Schema(description = "包装单位名称")
|
||||||
private String packageUnitName;
|
// private String packageUnitName;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,30 +89,8 @@ public class FarmingRecordRespVO {
|
|||||||
@ExcelProperty("租户id")
|
@ExcelProperty("租户id")
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
@Schema(description = "投入品列表")
|
|
||||||
private List<FarmingRecordInputVO> investGoodsList;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class FarmingRecordInputVO{
|
|
||||||
private String id;
|
|
||||||
@Schema(description = "投入品名称")
|
|
||||||
private String inputsId;
|
|
||||||
@Schema(description = "投入品类型")
|
|
||||||
private String assetType;
|
|
||||||
@Schema(description = "用量")
|
|
||||||
private BigDecimal dose;
|
|
||||||
@Schema(description = "单位")
|
|
||||||
private Integer unit;
|
|
||||||
@Schema(description = "单件")
|
|
||||||
private Integer packageUnit;
|
|
||||||
@Schema(description = "稀释倍液")
|
|
||||||
private Integer diluted;
|
|
||||||
@Schema(description = "用法")
|
|
||||||
private String usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class FarmingRecordSaveReqVO {
|
public class FarmingRecordSaveReqVO {
|
||||||
|
|
||||||
@Schema(description = "基础id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22116")
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "任务类型", example = "1")
|
@Schema(description = "任务类型", example = "1")
|
||||||
@@ -25,15 +25,13 @@ public class FarmingRecordSaveReqVO {
|
|||||||
private String taskScope;
|
private String taskScope;
|
||||||
|
|
||||||
@Schema(description = "任务时间")
|
@Schema(description = "任务时间")
|
||||||
private String taskTime;
|
private List<String> taskTime;
|
||||||
private LocalDate taskStartDate;
|
private LocalDate taskStartDate;
|
||||||
private LocalDate taskEndDate;
|
private LocalDate taskEndDate;
|
||||||
|
|
||||||
@Schema(description = "任务计划 (1: 开始; 2: 结束;)")
|
@Schema(description = "任务计划 (1: 开始; 2: 结束;)")
|
||||||
private Integer taskStatus;
|
private Integer taskStatus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "生产计划ID", example = "24782")
|
@Schema(description = "生产计划ID", example = "24782")
|
||||||
private String productionPlanId;
|
private String productionPlanId;
|
||||||
|
|
||||||
@@ -81,5 +79,4 @@ public class FarmingRecordSaveReqVO {
|
|||||||
@Schema(description = "引用类型投入品id集合 (逗号分隔)")
|
@Schema(description = "引用类型投入品id集合 (逗号分隔)")
|
||||||
private String inputsIds;
|
private String inputsIds;
|
||||||
|
|
||||||
private List<FarmingRecordInputDO> investGoodsList;
|
|
||||||
}
|
}
|
||||||
@@ -51,14 +51,14 @@ public class FarmingRecordJob implements JobHandler {
|
|||||||
public String execute(String param) throws Exception {
|
public String execute(String param) throws Exception {
|
||||||
List<FarmingRecordSaveReqVO> list = this.insertRecordHandler();
|
List<FarmingRecordSaveReqVO> list = this.insertRecordHandler();
|
||||||
for (FarmingRecordSaveReqVO e : list) {
|
for (FarmingRecordSaveReqVO e : list) {
|
||||||
String[] taskTime = e.getTaskTime().split(",");
|
List<String> taskTime = e.getTaskTime();
|
||||||
if (taskTime.length != 2) {
|
if (taskTime.size() != 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
LocalDate startDate = LocalDate.parse(taskTime[0]);
|
LocalDate startDate = LocalDate.parse(taskTime.get(0));
|
||||||
LocalDate endDate = LocalDate.parse(taskTime[1]);
|
LocalDate endDate = LocalDate.parse(taskTime.get(1));
|
||||||
boolean isStartToday = startDate.isEqual(today);
|
boolean isStartToday = startDate.isEqual(today);
|
||||||
boolean isEndToday = endDate.isEqual(today);
|
boolean isEndToday = endDate.isEqual(today);
|
||||||
|
|
||||||
@@ -108,7 +108,8 @@ public class FarmingRecordJob implements JobHandler {
|
|||||||
LocalDate startDate = productionStartDate.plusDays(startingPeriod-1);
|
LocalDate startDate = productionStartDate.plusDays(startingPeriod-1);
|
||||||
// 农事记录结束日期
|
// 农事记录结束日期
|
||||||
LocalDate endDate = startDate.plusDays(used);
|
LocalDate endDate = startDate.plusDays(used);
|
||||||
String taskTime = startDate + "," + endDate;
|
// String taskTime = startDate + "," + endDate;
|
||||||
|
List<String> taskTime = Arrays.asList(startDate.toString(), endDate.toString());
|
||||||
|
|
||||||
FarmingRecordSaveReqVO saveObj = new FarmingRecordSaveReqVO();
|
FarmingRecordSaveReqVO saveObj = new FarmingRecordSaveReqVO();
|
||||||
saveObj.setTaskType(e.getFarmingId());
|
saveObj.setTaskType(e.getFarmingId());
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public interface CropFarmingCenterService {
|
|||||||
FarmingRecordRespVO getFarmingRecord(String id);
|
FarmingRecordRespVO getFarmingRecord(String id);
|
||||||
|
|
||||||
String createFarmingRecordNew(@Valid FarmingRecordCreateReqVO createReqVO);
|
String createFarmingRecordNew(@Valid FarmingRecordCreateReqVO createReqVO);
|
||||||
|
void updateFarmingRecordNew(@Valid FarmingRecordCreateReqVO createReqVO);
|
||||||
|
|
||||||
void updateFarmingRecord(@Valid FarmingRecordSaveReqVO updateReqVO);
|
void updateFarmingRecord(@Valid FarmingRecordSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
|||||||
@@ -613,6 +613,11 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
|||||||
return farmingRecordService.createFarmingRecordNew(createReqVO);
|
return farmingRecordService.createFarmingRecordNew(createReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFarmingRecordNew(FarmingRecordCreateReqVO createReqVO) {
|
||||||
|
farmingRecordService.updateFarmingRecordNew(createReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateFarmingRecord(FarmingRecordSaveReqVO updateReqVO) {
|
public void updateFarmingRecord(FarmingRecordSaveReqVO updateReqVO) {
|
||||||
farmingRecordService.updateFarmingRecord(updateReqVO);
|
farmingRecordService.updateFarmingRecord(updateReqVO);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public interface FarmingRecordService {
|
|||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
String createFarmingRecordNew(@Valid FarmingRecordCreateReqVO createReqVO);
|
String createFarmingRecordNew(@Valid FarmingRecordCreateReqVO createReqVO);
|
||||||
|
void updateFarmingRecordNew(FarmingRecordCreateReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新种植中心-农事基地-农事记录
|
* 更新种植中心-农事基地-农事记录
|
||||||
|
|||||||
@@ -25,14 +25,12 @@ import cn.iocoder.yudao.module.farm.enums.CommonConstants;
|
|||||||
import cn.iocoder.yudao.module.farm.service.inputlibrary.InputUsageRecordsService;
|
import cn.iocoder.yudao.module.farm.service.inputlibrary.InputUsageRecordsService;
|
||||||
import cn.iocoder.yudao.module.farm.service.inputlibrary.InputsService;
|
import cn.iocoder.yudao.module.farm.service.inputlibrary.InputsService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
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.time.LocalDate;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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.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;
|
||||||
@@ -74,14 +72,7 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
|
|||||||
|
|
||||||
// 处理图片集合转换
|
// 处理图片集合转换
|
||||||
handleImageConversion(farmingRecord, createReqVO);
|
handleImageConversion(farmingRecord, createReqVO);
|
||||||
//投入品集合单条保存
|
|
||||||
// if (ObjectUtils.isNotEmpty(createReqVO.getInvestGoodsList())) {
|
|
||||||
// createReqVO.getInvestGoodsList().forEach(e -> {
|
|
||||||
// e.setId(IdUtil.fastUUID());
|
|
||||||
// e.setFarmRecordId(farmingRecord.getId());
|
|
||||||
// farmingRecordInputMapper.insert(e);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
farmingRecordMapper.insert(farmingRecord);
|
farmingRecordMapper.insert(farmingRecord);
|
||||||
// 返回
|
// 返回
|
||||||
@@ -172,12 +163,6 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
|
|||||||
FarmingNameMaintenanceDO farmingNameMaintenanceDO = farmingNameMaintenanceMapper.selectOne(FarmingNameMaintenanceDO::getId, farmingRecord.getTaskName());
|
FarmingNameMaintenanceDO farmingNameMaintenanceDO = farmingNameMaintenanceMapper.selectOne(FarmingNameMaintenanceDO::getId, farmingRecord.getTaskName());
|
||||||
farmingRecord.setTaskName(farmingNameMaintenanceDO.getFarmingName());
|
farmingRecord.setTaskName(farmingNameMaintenanceDO.getFarmingName());
|
||||||
|
|
||||||
// 查询并填充投入品列表
|
|
||||||
// List<FarmingRecordInputDO> inputs = farmingRecordInputMapper.selectList(
|
|
||||||
// new LambdaQueryWrapperX<FarmingRecordInputDO>()
|
|
||||||
// .eq(FarmingRecordInputDO::getFarmRecordId, farmingRecord.getId())
|
|
||||||
// );
|
|
||||||
// farmingRecord.setInvestGoodsList(inputs);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -239,6 +224,15 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
|
|||||||
return createFarmingRecord(saveReqVO);
|
return createFarmingRecord(saveReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFarmingRecordNew(FarmingRecordCreateReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateFarmingRecordExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
FarmingRecordDO updateObj = BeanUtils.toBean(updateReqVO, FarmingRecordDO.class);
|
||||||
|
farmingRecordMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理图片集合转换
|
* 处理图片集合转换
|
||||||
* 优先使用图片集合,如果图片集合为空则使用字符串
|
* 优先使用图片集合,如果图片集合为空则使用字符串
|
||||||
|
|||||||
Reference in New Issue
Block a user