feat: 公众网站数据接口调整
This commit is contained in:
@@ -154,8 +154,6 @@ public class BudgetController {
|
||||
return FuHttpResponse.Builder().dataResponse(budgetItemList).build();
|
||||
}
|
||||
|
||||
// todo-1 发布编码替换
|
||||
// todo-1 公众网站数据
|
||||
// todo-1 公众网站历史数据
|
||||
// todo-1 地图里程数据
|
||||
// todo-1 价格权重调整
|
||||
|
@@ -45,13 +45,12 @@ public class MaterialController {
|
||||
@ApiParam("类型") @RequestParam(value="type") Integer type
|
||||
) {
|
||||
LambdaQueryWrapper<Material> query = new LambdaQueryWrapper<>();
|
||||
query.eq(Material::getIsTree, 1);
|
||||
//query.eq(Material::getIsTree, 1);
|
||||
query.eq(Material::getType, type);
|
||||
List<Map<String, Object>> maps = materialService.listMaps(query);
|
||||
maps = maps.stream().map(map -> convertKeysToLowercase(map)).collect(Collectors.toList());
|
||||
// todo-3 列转树改为泛型对象入参
|
||||
List<Map<String, Object>> result = CommonUtil.listToTree(maps, Material.Fields.id, StrUtil.toUnderlineCase(Material.Fields.parentId), "00.00.00.00");
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
// maps = maps.stream().map(map -> convertKeysToLowercase(map)).collect(Collectors.toList());
|
||||
// List<Map<String, Object>> result = CommonUtil.listToTree(maps, Material.Fields.id, StrUtil.toUnderlineCase(Material.Fields.parentId), "00.00.00.00");
|
||||
return FuHttpResponse.Builder().dataResponse(maps).build();
|
||||
}
|
||||
|
||||
private Map<String, Object> convertKeysToLowercase(Map<String, Object> originalMap) {
|
||||
|
@@ -52,6 +52,7 @@ public class PublicController {
|
||||
@ApiParam(value = "父id") @RequestParam(value="parent_id", required = false) String parentId
|
||||
) throws Exception {
|
||||
LambdaQueryWrapper<PricePublish> query = pricePublishService.getQuery(year, month, null, name, spec, PricePublishType.CURRENT);
|
||||
query.isNotNull(PricePublish::getMaterialId); // 材料编号禁止为空
|
||||
if (keyword != null && ObjectUtil.isNotEmpty(keyword)) {
|
||||
query.and(e -> e
|
||||
.like(PricePublish::getName, keyword).or()
|
||||
@@ -66,6 +67,7 @@ public class PublicController {
|
||||
var currentData = pricePublishService.list(query);
|
||||
|
||||
LambdaQueryWrapper<PricePublish> queryPrevious = pricePublishService.getQuery(year - 1, month, null, name, spec, PricePublishType.CURRENT);
|
||||
queryPrevious.isNotNull(PricePublish::getMaterialId); // 材料编号禁止为空
|
||||
var previousData = pricePublishService.list(queryPrevious);
|
||||
|
||||
// 计算同比, 组合
|
||||
|
@@ -68,7 +68,11 @@ public class PublicResponse {
|
||||
private Float yoy;
|
||||
|
||||
static public List<PublicResponse> list(List<PricePublish> currentData, List<PricePublish> previousData, String region) {
|
||||
var previousPriceMap = previousData.stream().collect(Collectors.toMap(PricePublish::getMaterialId, item -> item.getRegionPrice(region)));
|
||||
var previousPriceMap = previousData.stream().collect(Collectors.toMap(
|
||||
PricePublish::getMaterialId,
|
||||
item -> item.getRegionPrice(region),
|
||||
(v1, v2) -> (BigDecimal)v2
|
||||
));
|
||||
var result = currentData.stream().map(item -> new PublicResponse(item, previousPriceMap, region)).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user