feat: 新增按编码查询地材的功能
This commit is contained in:
@@ -6,7 +6,6 @@ import io.swagger.annotations.ApiParam;
|
|||||||
import mjkf.xinke.main.common.http.FuHttpResponse;
|
import mjkf.xinke.main.common.http.FuHttpResponse;
|
||||||
import mjkf.xinke.main.constant.PricePublishType;
|
import mjkf.xinke.main.constant.PricePublishType;
|
||||||
import mjkf.xinke.main.model.db.DataAdjacent;
|
import mjkf.xinke.main.model.db.DataAdjacent;
|
||||||
import mjkf.xinke.main.model.db.LocalMaterial;
|
|
||||||
import mjkf.xinke.main.model.db.PricePublish;
|
import mjkf.xinke.main.model.db.PricePublish;
|
||||||
import mjkf.xinke.main.service.DataAdjacentService;
|
import mjkf.xinke.main.service.DataAdjacentService;
|
||||||
import mjkf.xinke.main.service.LocalMaterialService;
|
import mjkf.xinke.main.service.LocalMaterialService;
|
||||||
|
@@ -50,12 +50,13 @@ public class LocalMaterialController {
|
|||||||
@ApiParam(value = "地市") @RequestParam(value="city", required=false) String city,
|
@ApiParam(value = "地市") @RequestParam(value="city", required=false) String city,
|
||||||
@ApiParam(value = "区县") @RequestParam(value="county", required=false) String county,
|
@ApiParam(value = "区县") @RequestParam(value="county", required=false) String county,
|
||||||
@ApiParam(value = "规格") @RequestParam(value="spec", required=false) String spec,
|
@ApiParam(value = "规格") @RequestParam(value="spec", required=false) String spec,
|
||||||
@ApiParam(value = "名称") @RequestParam(value="name", required=false) String name
|
@ApiParam(value = "名称") @RequestParam(value="name", required=false) String name,
|
||||||
|
@ApiParam(value = "材料id") @RequestParam(value="materialId", required=false) String materialId
|
||||||
) {
|
) {
|
||||||
// 指定月份无数据时选用最新数据
|
// 指定月份无数据时选用最新数据
|
||||||
var date = localMaterialService.checkDate(year, month);
|
var date = localMaterialService.checkDate(year, month);
|
||||||
|
|
||||||
var query = localMaterialService.getQuery(date.getYear(), date.getMonth().getValue(), city, county, spec, name, null);
|
var query = localMaterialService.getQuery(date.getYear(), date.getMonth().getValue(), city, county, spec, name, null, materialId);
|
||||||
query.orderByDesc(LocalMaterial::getName);
|
query.orderByDesc(LocalMaterial::getName);
|
||||||
List<LocalMaterial> data = localMaterialService.list(query);
|
List<LocalMaterial> data = localMaterialService.list(query);
|
||||||
// 按名称分组
|
// 按名称分组
|
||||||
|
@@ -11,8 +11,6 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -33,7 +31,7 @@ import org.apache.poi.ss.usermodel.CellType;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("LOCAL_MATERIAL")
|
@TableName("LOCAL_MATERIAL")
|
||||||
@ApiModel(value = "LocalMaterial对象", description = "地材")
|
@ApiModel(value = "LocalMaterial对象", description = "地材")
|
||||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
//@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||||
public class LocalMaterial extends Model<LocalMaterial> {
|
public class LocalMaterial extends Model<LocalMaterial> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@@ -9,6 +9,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class LocalMaterialSummary {
|
public class LocalMaterialSummary {
|
||||||
|
private String materialId;
|
||||||
private String name;
|
private String name;
|
||||||
private String spec;
|
private String spec;
|
||||||
private String unit;
|
private String unit;
|
||||||
@@ -17,19 +18,20 @@ public class LocalMaterialSummary {
|
|||||||
public LocalMaterialSummary() {}
|
public LocalMaterialSummary() {}
|
||||||
|
|
||||||
public LocalMaterialSummary(List<LocalMaterial> list) {
|
public LocalMaterialSummary(List<LocalMaterial> list) {
|
||||||
|
this.materialId = list.get(0).getMaterialId();
|
||||||
this.name = list.get(0).getName();
|
this.name = list.get(0).getName();
|
||||||
this.spec = list.get(0).getSpec();
|
this.spec = list.get(0).getSpec();
|
||||||
this.unit = list.get(0).getUnit();
|
this.unit = list.get(0).getUnit();
|
||||||
this.data = list;
|
this.data = list;
|
||||||
LocalMaterial avg_item = new LocalMaterial();
|
// LocalMaterial avg_item = new LocalMaterial();
|
||||||
avg_item.setName(list.get(0).getName());
|
// avg_item.setName(list.get(0).getName());
|
||||||
avg_item.setSpec(list.get(0).getSpec());
|
// avg_item.setSpec(list.get(0).getSpec());
|
||||||
avg_item.setUnit(list.get(0).getUnit());
|
// avg_item.setUnit(list.get(0).getUnit());
|
||||||
avg_item.setCity(list.get(0).getCity());
|
// avg_item.setCity(list.get(0).getCity());
|
||||||
Integer id = Math.abs(HashUtil.javaDefaultHash(avg_item.getCity() + avg_item.getName() + avg_item.getSpec()));
|
// Integer id = Math.abs(HashUtil.javaDefaultHash(avg_item.getCity() + avg_item.getName() + avg_item.getSpec()));
|
||||||
avg_item.setId(id);
|
// avg_item.setId(id);
|
||||||
avg_item.setCounty("城区");
|
// avg_item.setCounty("城区");
|
||||||
avg_item.setPrice(BigDecimal.valueOf(list.stream().mapToDouble(item->item.getPrice().doubleValue()).average().orElse(0D)));
|
// avg_item.setPrice(BigDecimal.valueOf(list.stream().mapToDouble(item->item.getPrice().doubleValue()).average().orElse(0D)));
|
||||||
this.data.add(avg_item);
|
// this.data.add(avg_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,7 @@ public class LocalMaterialService extends DataService<BaseMapper<LocalMaterial>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LambdaQueryWrapper<LocalMaterial> getQuery(Integer year, Integer month, String city, String county, String spec, String name, Integer type) {
|
public LambdaQueryWrapper<LocalMaterial> getQuery(Integer year, Integer month, String city, String county, String spec, String name, Integer type, String materialId) {
|
||||||
var query = this.getQuery(null, year, month, null, name, type);
|
var query = this.getQuery(null, year, month, null, name, type);
|
||||||
if (city != null) {
|
if (city != null) {
|
||||||
query.like(LocalMaterial::getCity, city);
|
query.like(LocalMaterial::getCity, city);
|
||||||
@@ -94,6 +94,9 @@ public class LocalMaterialService extends DataService<BaseMapper<LocalMaterial>,
|
|||||||
if(spec!= null) {
|
if(spec!= null) {
|
||||||
query.like(LocalMaterial::getSpec, spec);
|
query.like(LocalMaterial::getSpec, spec);
|
||||||
}
|
}
|
||||||
|
if(materialId!= null) {
|
||||||
|
query.like(LocalMaterial::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user