feat: 新增编辑趋势表权重接口
This commit is contained in:
@@ -155,7 +155,6 @@ public class BudgetController {
|
||||
}
|
||||
|
||||
// todo-1 地图里程数据
|
||||
// todo-2 价格权重调整
|
||||
// todo-2 外省数据上传
|
||||
// todo-2 外省数据价格对比
|
||||
// todo-3 趋势表加入调查表数据
|
||||
|
@@ -1,16 +1,21 @@
|
||||
package mjkf.xinke.main.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.jgy.xxs.core.http.exp.NcHttpException;
|
||||
import com.jgy.xxs.core.http.resp.HttpResponse;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import mjkf.xinke.common.annotation.CommonLog;
|
||||
import mjkf.xinke.main.common.http.FuHttpResponse;
|
||||
import mjkf.xinke.main.constant.HttpErrorResponseEnum;
|
||||
import mjkf.xinke.main.model.db.PriceResult;
|
||||
import mjkf.xinke.main.model.vo.PriceResultEditRequest;
|
||||
import mjkf.xinke.main.model.vo.PriceResultEditWeightRequest;
|
||||
import mjkf.xinke.main.model.vo.PriceResultExport;
|
||||
import mjkf.xinke.main.service.PriceResultService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -93,6 +98,24 @@ public class PriceResultController {
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
@ApiOperation("编辑趋势表权重")
|
||||
@CommonLog("编辑趋势表权重")
|
||||
@PutMapping("/{id}/weight")
|
||||
public HttpResponse editWeight(
|
||||
@PathVariable String id,
|
||||
@ApiParam("参数") @RequestBody PriceResultEditWeightRequest params
|
||||
) throws Exception {
|
||||
var result = priceResultService.getById(id);
|
||||
if (result == null) {
|
||||
throw new NcHttpException(HttpErrorResponseEnum.PRICE_RESULT_NOT_FOUND);
|
||||
}
|
||||
BeanUtil.copyProperties(params, result);
|
||||
result.refreshWeight();
|
||||
priceResultService.updateById(result);
|
||||
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
@ApiOperation("获取趋势表数据趋势")
|
||||
@GetMapping("/{id}/trend")
|
||||
public HttpResponse getTrend(@PathVariable String id) throws Exception {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package mjkf.xinke.main.model.db;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -148,6 +149,12 @@ public class PriceResult extends Model<PriceResult> {
|
||||
@TableField("FLUCTUATING_FUJIAN")
|
||||
private Float fluctuatingFujian;
|
||||
|
||||
private Float weightFtb;
|
||||
private Float weightSs;
|
||||
private Float weightFhb;
|
||||
private Float weightNetwork;
|
||||
private Float weightSurvey;
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
return this.id;
|
||||
@@ -170,4 +177,16 @@ public class PriceResult extends Model<PriceResult> {
|
||||
this.setFluctuatingRecommend(item.getFluctuatingRecommend().floatValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
public void refreshWeight() {
|
||||
var fluctuatingSum = fluctuatingFtb + fluctuatingSs + fluctuatingFhb + fluctuatingNetwork + fluctuatingSurvey;
|
||||
var weight = weightFtb + weightSs + weightFhb + weightNetwork + weightSurvey;
|
||||
var fluctuatingWeightedMean = fluctuatingSum / weight;
|
||||
fluctuatingRecommend = fluctuatingWeightedMean;
|
||||
if (priceLastMonth.equals(0f) || ObjectUtil.isEmpty(priceLastMonth)) {
|
||||
priceRecommend = priceCalculate + fluctuatingRecommend;
|
||||
} else {
|
||||
priceRecommend = priceLastMonth + fluctuatingRecommend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package mjkf.xinke.main.model.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PriceResultEditWeightRequest {
|
||||
@ApiModelProperty("福州交通局权重")
|
||||
private Float weightFtb;
|
||||
@ApiModelProperty("三明钢铁权重")
|
||||
private Float weightSs;
|
||||
@ApiModelProperty("福州公路局权重")
|
||||
private Float weightFhb;
|
||||
@ApiModelProperty("网络权重")
|
||||
private Float weightNetwork;
|
||||
@ApiModelProperty("调查权重")
|
||||
private Float weightSurvey;
|
||||
}
|
@@ -12,3 +12,8 @@ create table LOCATION (
|
||||
UPDATE_USER varchar(20) null comment '更新人'
|
||||
) comment '料场位置';
|
||||
|
||||
ALTER TABLE PRICE_RESULT ADD WEIGHT_FTB decimal(16,4) default 1 comment '福州交通局权重';
|
||||
ALTER TABLE PRICE_RESULT ADD WEIGHT_SS decimal(16,4) default 1 comment '三明钢铁权重';
|
||||
ALTER TABLE PRICE_RESULT ADD WEIGHT_FHB decimal(16,4) default 1 comment '福州公路局权重';
|
||||
ALTER TABLE PRICE_RESULT ADD WEIGHT_NETWORK decimal(16,4) default 1 comment '网络权重';
|
||||
ALTER TABLE PRICE_RESULT ADD WEIGHT_SURVEY decimal(16,4) default 1 comment '调查权重';
|
Reference in New Issue
Block a user