fix: 修复获取最新数据的异常

This commit is contained in:
han0
2025-01-08 16:47:15 +08:00
parent e057ff13c1
commit 77d0ff37a8
2 changed files with 4 additions and 4 deletions

View File

@@ -52,7 +52,7 @@ public class PricePublishController {
if (month < 0 || year < 0) {
var date = pricePublishService.getLatestDate();
year = date.getYear();
month = date.getMonth();
month = date.getMonthValue();
}
var query = pricePublishService.getQuery(year, month, materialId, name, spec, type);

View File

@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import mjkf.xinke.main.model.vo.BudgetCreateRequest;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -58,12 +58,12 @@ public class PricePublishService extends ServiceImpl<BaseMapper<PricePublish>, P
return result;
}
public Date getLatestDate() {
public LocalDate getLatestDate() {
var query = new LambdaQueryWrapper<PricePublish>();
query.orderByDesc(PricePublish::getYear);
query.orderByDesc(PricePublish::getMonth);
var data = this.getOne(query, false);
var result = new Date(data.getYear(), data.getMonth(), 1);
var result = LocalDate.of(data.getYear(), data.getMonth(), 1);
return result;
}
}