feat: 新增材料预算结果新增预算月份
This commit is contained in:
@@ -291,8 +291,6 @@ public class MaterialTaskType {
|
||||
/**
|
||||
* todo-1 数据展示模块 地市暂不切换
|
||||
* todo-1 趋势图一年每月打点
|
||||
* todo-1 项目材料价格预算“最高(低)总金额”携带上价格的月份
|
||||
* todo-1 项目材料价格预算计算数值没有小数点
|
||||
*/
|
||||
}
|
||||
|
||||
|
@@ -43,17 +43,27 @@ public class Budget extends Model<Budget> {
|
||||
|
||||
@ApiModelProperty("总数")
|
||||
@TableField("AMOUNT")
|
||||
private Integer amount;
|
||||
private Double amount;
|
||||
|
||||
@ApiModelProperty("最小值")
|
||||
@TableField("MIN_AMOUNT")
|
||||
@JsonProperty(value = "min_amount")
|
||||
private Integer minAmount;
|
||||
private Double minAmount;
|
||||
|
||||
@ApiModelProperty("最大值")
|
||||
@TableField("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("日期")
|
||||
@TableField("`DATE`")
|
||||
@@ -74,19 +84,21 @@ public class Budget extends Model<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);
|
||||
}
|
||||
|
||||
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.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());
|
||||
Collections.sort(list, (o1, o2) -> (o1.getValue() - o2.getValue()));
|
||||
List<Map.Entry<String, Double>> list = new ArrayList(totalMap.entrySet());
|
||||
Collections.sort(list, (o1, o2) -> (o1.getValue().compareTo(o2.getValue())));
|
||||
|
||||
this.minAmount = list.get(0).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(list.size() -1 ).getKey();
|
||||
this.date = LocalDate.now();
|
||||
|
@@ -63,11 +63,11 @@ public class BudgetItem extends Model<BudgetItem> {
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
@TableField("UNIT_PRICE")
|
||||
private Integer unitPrice;
|
||||
private Double unitPrice;
|
||||
|
||||
@ApiModelProperty("总价")
|
||||
@TableField("TOTAL_PRICE")
|
||||
private Integer totalPrice;
|
||||
private Double totalPrice;
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
|
@@ -134,7 +134,7 @@ public class PricePublish extends Model<PricePublish> {
|
||||
@TableField("PRICE_PINTAN")
|
||||
private BigDecimal pricePintan;
|
||||
|
||||
@ApiModelProperty("平潭价格")
|
||||
@ApiModelProperty("漳州开发区价格")
|
||||
@TableField("PRICE_ZHANGZHOUKFQ")
|
||||
private BigDecimal priceZhangzhouKfq;
|
||||
|
||||
|
@@ -42,38 +42,38 @@ public class BudgetCreateRequest {
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
@JsonProperty(value = "unit_price")
|
||||
private Integer unitPrice;
|
||||
private Double unitPrice;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty("总价")
|
||||
@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 totalMap = new HashMap<String, Integer>();
|
||||
var totalMap = new HashMap<String, Double>();
|
||||
for (var item: params.getItems()) {
|
||||
for (var month: params.getMonths()) {
|
||||
var key = item.getName() + month.toString();
|
||||
var price = priceMap.getOrDefault(key, 0);
|
||||
var total = totalMap.getOrDefault(month.toString(), 0);
|
||||
var price = priceMap.getOrDefault(key, 0.0);
|
||||
var total = totalMap.getOrDefault(month.toString(), 0.0);
|
||||
totalMap.put(month.toString(), total + price * item.getQuantity());
|
||||
}
|
||||
}
|
||||
return totalMap;
|
||||
}
|
||||
|
||||
public List<BudgetItem> getBudgetItemList(Map<String, Integer> priceMap) {
|
||||
public List<BudgetItem> getBudgetItemList(Map<String, Double> priceMap) {
|
||||
var params = this;
|
||||
var budgetItemList = new ArrayList<BudgetItem>();
|
||||
for (var item: params.getItems()) {
|
||||
var meta = new ArrayList<Map<String, Object>>();
|
||||
for (var month: params.getMonths()) {
|
||||
var key = item.getName() + month.toString();
|
||||
var price = priceMap.getOrDefault(key, 0);
|
||||
var price = priceMap.getOrDefault(key, 0.0);
|
||||
meta.add(Map.of(
|
||||
"month", month,
|
||||
"total", price * item.getQuantity(),
|
||||
|
@@ -16,13 +16,13 @@ public class BudgetDetail{
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer amount;
|
||||
private Double amount;
|
||||
|
||||
@JsonProperty(value = "min_amount")
|
||||
private Integer minAmount;
|
||||
private Double minAmount;
|
||||
|
||||
@JsonProperty(value = "max_amount")
|
||||
private Integer maxAmount;
|
||||
private Double maxAmount;
|
||||
|
||||
private LocalDate date;
|
||||
|
||||
|
@@ -46,12 +46,12 @@ public class PricePublishService extends ServiceImpl<BaseMapper<PricePublish>, P
|
||||
return query;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getPriceMapEntryByMaterialIdAndMonth(LambdaQueryWrapper<PricePublish> query) {
|
||||
var result = new HashMap<String, Integer>();
|
||||
public Map<String, Double> getPriceMapEntryByMaterialIdAndMonth(LambdaQueryWrapper<PricePublish> query) {
|
||||
var result = new HashMap<String, Double>();
|
||||
var items = this.list(query);
|
||||
for (PricePublish item: items) {
|
||||
var key = item.getName() + item.getMonth().toString();
|
||||
result.put(key, item.getPrice().intValue());
|
||||
result.put(key, item.getPrice().doubleValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -27,3 +27,16 @@ DROP INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU;
|
||||
CREATE UNIQUE INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU (NAME, SPEC, DATE, REGION);
|
||||
DROP INDEX Idx_key ON FUZHOU_TRANSPORTATION_BUREAU;
|
||||
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 '最大值月份';
|
Reference in New Issue
Block a user