feat: 新增材料预算结果新增预算月份

This commit is contained in:
han0
2024-07-09 11:33:06 +08:00
parent 2be2c7be59
commit e7ad0fe717
8 changed files with 51 additions and 28 deletions

View File

@@ -291,8 +291,6 @@ public class MaterialTaskType {
/** /**
* todo-1 数据展示模块 地市暂不切换 * todo-1 数据展示模块 地市暂不切换
* todo-1 趋势图一年每月打点 * todo-1 趋势图一年每月打点
* todo-1 项目材料价格预算“最高(低)总金额”携带上价格的月份
* todo-1 项目材料价格预算计算数值没有小数点
*/ */
} }

View File

@@ -43,17 +43,27 @@ public class Budget extends Model<Budget> {
@ApiModelProperty("总数") @ApiModelProperty("总数")
@TableField("AMOUNT") @TableField("AMOUNT")
private Integer amount; private Double amount;
@ApiModelProperty("最小值") @ApiModelProperty("最小值")
@TableField("MIN_AMOUNT") @TableField("MIN_AMOUNT")
@JsonProperty(value = "min_amount") @JsonProperty(value = "min_amount")
private Integer minAmount; private Double minAmount;
@ApiModelProperty("最大值") @ApiModelProperty("最大值")
@TableField("MAX_AMOUNT") @TableField("MAX_AMOUNT")
@JsonProperty(value = "max_amount") @JsonProperty(value = "max_amount")
private Integer maxAmount; private Double maxAmount;
@ApiModelProperty("最小值月份")
@TableField("MIN_MONTH")
@JsonProperty(value = "min_month")
private String minMonth;
@ApiModelProperty("最大值月份")
@TableField("MAX_MONTH")
@JsonProperty(value = "max_month")
private String maxMonth;
@ApiModelProperty("日期") @ApiModelProperty("日期")
@TableField("`DATE`") @TableField("`DATE`")
@@ -74,19 +84,21 @@ public class Budget extends Model<Budget> {
public Budget() {} public Budget() {}
public Budget(BudgetCreateRequest params, SaBaseLoginUser user, Map<String, Integer> totalMap) { public Budget(BudgetCreateRequest params, SaBaseLoginUser user, Map<String, Double> totalMap) {
this.update(params, user, totalMap); this.update(params, user, totalMap);
} }
public void update(BudgetCreateRequest params, SaBaseLoginUser user, Map<String, Integer> totalMap) { public void update(BudgetCreateRequest params, SaBaseLoginUser user, Map<String, Double> totalMap) {
this.name = params.getName(); this.name = params.getName();
this.amount = params.getItems().stream().mapToInt(item -> item.getTotalPrice()).sum(); this.amount = params.getItems().stream().mapToDouble(item -> item.getTotalPrice()).sum();
List<Map.Entry<String,Integer>> list = new ArrayList(totalMap.entrySet()); List<Map.Entry<String, Double>> list = new ArrayList(totalMap.entrySet());
Collections.sort(list, (o1, o2) -> (o1.getValue() - o2.getValue())); Collections.sort(list, (o1, o2) -> (o1.getValue().compareTo(o2.getValue())));
this.minAmount = list.get(0).getValue(); this.minAmount = list.get(0).getValue();
this.maxAmount = list.get(list.size() -1).getValue(); this.maxAmount = list.get(list.size() -1).getValue();
this.minMonth = list.get(0).getKey();
this.maxMonth = list.get(list.size() -1).getKey();
// list.get(0).getKey(); // list.get(0).getKey();
// list.get(list.size() -1 ).getKey(); // list.get(list.size() -1 ).getKey();
this.date = LocalDate.now(); this.date = LocalDate.now();

View File

@@ -63,11 +63,11 @@ public class BudgetItem extends Model<BudgetItem> {
@ApiModelProperty("单价") @ApiModelProperty("单价")
@TableField("UNIT_PRICE") @TableField("UNIT_PRICE")
private Integer unitPrice; private Double unitPrice;
@ApiModelProperty("总价") @ApiModelProperty("总价")
@TableField("TOTAL_PRICE") @TableField("TOTAL_PRICE")
private Integer totalPrice; private Double totalPrice;
@Override @Override
public Serializable pkVal() { public Serializable pkVal() {

View File

@@ -134,7 +134,7 @@ public class PricePublish extends Model<PricePublish> {
@TableField("PRICE_PINTAN") @TableField("PRICE_PINTAN")
private BigDecimal pricePintan; private BigDecimal pricePintan;
@ApiModelProperty("平潭价格") @ApiModelProperty("漳州开发区价格")
@TableField("PRICE_ZHANGZHOUKFQ") @TableField("PRICE_ZHANGZHOUKFQ")
private BigDecimal priceZhangzhouKfq; private BigDecimal priceZhangzhouKfq;

View File

@@ -42,38 +42,38 @@ public class BudgetCreateRequest {
@ApiModelProperty("单价") @ApiModelProperty("单价")
@JsonProperty(value = "unit_price") @JsonProperty(value = "unit_price")
private Integer unitPrice; private Double unitPrice;
@ApiModelProperty("数量") @ApiModelProperty("数量")
private Integer quantity; private Integer quantity;
@ApiModelProperty("总价") @ApiModelProperty("总价")
@JsonProperty(value = "total_price") @JsonProperty(value = "total_price")
private Integer totalPrice; private Double totalPrice;
} }
public Map<String, Integer> getTotalMap(Map<String, Integer> priceMap) { public Map<String, Double> getTotalMap(Map<String, Double> priceMap) {
var params = this; var params = this;
var totalMap = new HashMap<String, Integer>(); var totalMap = new HashMap<String, Double>();
for (var item: params.getItems()) { for (var item: params.getItems()) {
for (var month: params.getMonths()) { for (var month: params.getMonths()) {
var key = item.getName() + month.toString(); var key = item.getName() + month.toString();
var price = priceMap.getOrDefault(key, 0); var price = priceMap.getOrDefault(key, 0.0);
var total = totalMap.getOrDefault(month.toString(), 0); var total = totalMap.getOrDefault(month.toString(), 0.0);
totalMap.put(month.toString(), total + price * item.getQuantity()); totalMap.put(month.toString(), total + price * item.getQuantity());
} }
} }
return totalMap; return totalMap;
} }
public List<BudgetItem> getBudgetItemList(Map<String, Integer> priceMap) { public List<BudgetItem> getBudgetItemList(Map<String, Double> priceMap) {
var params = this; var params = this;
var budgetItemList = new ArrayList<BudgetItem>(); var budgetItemList = new ArrayList<BudgetItem>();
for (var item: params.getItems()) { for (var item: params.getItems()) {
var meta = new ArrayList<Map<String, Object>>(); var meta = new ArrayList<Map<String, Object>>();
for (var month: params.getMonths()) { for (var month: params.getMonths()) {
var key = item.getName() + month.toString(); var key = item.getName() + month.toString();
var price = priceMap.getOrDefault(key, 0); var price = priceMap.getOrDefault(key, 0.0);
meta.add(Map.of( meta.add(Map.of(
"month", month, "month", month,
"total", price * item.getQuantity(), "total", price * item.getQuantity(),

View File

@@ -16,13 +16,13 @@ public class BudgetDetail{
private String name; private String name;
private Integer amount; private Double amount;
@JsonProperty(value = "min_amount") @JsonProperty(value = "min_amount")
private Integer minAmount; private Double minAmount;
@JsonProperty(value = "max_amount") @JsonProperty(value = "max_amount")
private Integer maxAmount; private Double maxAmount;
private LocalDate date; private LocalDate date;

View File

@@ -46,12 +46,12 @@ public class PricePublishService extends ServiceImpl<BaseMapper<PricePublish>, P
return query; return query;
} }
public Map<String, Integer> getPriceMapEntryByMaterialIdAndMonth(LambdaQueryWrapper<PricePublish> query) { public Map<String, Double> getPriceMapEntryByMaterialIdAndMonth(LambdaQueryWrapper<PricePublish> query) {
var result = new HashMap<String, Integer>(); var result = new HashMap<String, Double>();
var items = this.list(query); var items = this.list(query);
for (PricePublish item: items) { for (PricePublish item: items) {
var key = item.getName() + item.getMonth().toString(); var key = item.getName() + item.getMonth().toString();
result.put(key, item.getPrice().intValue()); result.put(key, item.getPrice().doubleValue());
} }
return result; return result;
} }

View File

@@ -26,4 +26,17 @@ CREATE UNIQUE INDEX Idx_key ON FUJIAN_SURVEY (NAME, SPEC, DATE, REGION);
DROP INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU; DROP INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU;
CREATE UNIQUE INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU (NAME, SPEC, DATE, REGION); CREATE UNIQUE INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU (NAME, SPEC, DATE, REGION);
DROP INDEX Idx_key ON FUZHOU_TRANSPORTATION_BUREAU; DROP INDEX Idx_key ON FUZHOU_TRANSPORTATION_BUREAU;
CREATE UNIQUE INDEX Idx_key ON FUZHOU_TRANSPORTATION_BUREAU (NAME, SPEC, DATE, REGION); CREATE UNIQUE INDEX Idx_key ON FUZHOU_TRANSPORTATION_BUREAU (NAME, SPEC, DATE, REGION);
ALTER TABLE BUDGET_ITEM MODIFY UNIT_PRICE decimal(16,4) COMMENT '单价';
ALTER TABLE BUDGET_ITEM MODIFY TOTAL_PRICE decimal(16,4) COMMENT '总价';
ALTER TABLE BUDGET MODIFY AMOUNT decimal(16,4) COMMENT '总数';
ALTER TABLE BUDGET MODIFY MIN_AMOUNT decimal(16,4) COMMENT '最小值';
ALTER TABLE BUDGET MODIFY MAX_AMOUNT decimal(16,4) COMMENT '最大值';
ALTER TABLE PRICE_PUBLISH ADD PRICE_ZHANGZHOUKFQ decimal(16,4) NULL COMMENT '漳州开发区价格';
ALTER TABLE PRICE_PUBLISH
MODIFY COLUMN PRICE_ZHANGZHOUKFQ decimal(16,4) COMMENT '漳州开发区价格' AFTER PRICE_PINTAN;
ALTER TABLE BUDGET ADD MIN_MONTH varchar(16) NULL COMMENT '最小值月份';
ALTER TABLE BUDGET ADD MAX_MONTH varchar(16) NULL COMMENT '最大值月份';