fix(price-publish): 新增状态信息
This commit is contained in:
@@ -97,10 +97,15 @@ public class PricePublishController {
|
|||||||
@ApiParam("年份") @RequestParam("year") Integer year,
|
@ApiParam("年份") @RequestParam("year") Integer year,
|
||||||
@ApiParam("月份") @RequestParam(value = "month") Integer month
|
@ApiParam("月份") @RequestParam(value = "month") Integer month
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
var data = new PricePublish();
|
var query = pricePublishService.getQuery(year, month, null, null, null, null);
|
||||||
data.setCreateTime(LocalDateTime.of(year, month, 1, 0, 0));
|
List<PricePublish> items = pricePublishService.list(query);
|
||||||
|
PublicController.PublicUpdateInfo result;
|
||||||
var result = new PublicController.PublicUpdateInfo(data);
|
if (items.size() == 0) {
|
||||||
|
result = new PublicController.PublicUpdateInfo(year, month);
|
||||||
|
} else {
|
||||||
|
var data = items.get(0);
|
||||||
|
result = new PublicController.PublicUpdateInfo(data);
|
||||||
|
}
|
||||||
|
|
||||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import lombok.Data;
|
|||||||
import mjkf.xinke.dev.modular.file.entity.DevFile;
|
import mjkf.xinke.dev.modular.file.entity.DevFile;
|
||||||
import mjkf.xinke.dev.modular.file.service.DevFileService;
|
import mjkf.xinke.dev.modular.file.service.DevFileService;
|
||||||
import mjkf.xinke.main.common.http.FuHttpResponse;
|
import mjkf.xinke.main.common.http.FuHttpResponse;
|
||||||
|
import mjkf.xinke.main.constant.PricePublishStatus;
|
||||||
import mjkf.xinke.main.constant.PricePublishType;
|
import mjkf.xinke.main.constant.PricePublishType;
|
||||||
import mjkf.xinke.main.model.db.PricePublish;
|
import mjkf.xinke.main.model.db.PricePublish;
|
||||||
import mjkf.xinke.main.model.vo.PublicResponse;
|
import mjkf.xinke.main.model.vo.PublicResponse;
|
||||||
@@ -114,24 +115,39 @@ public class PublicController {
|
|||||||
@ApiModelProperty("月份")
|
@ApiModelProperty("月份")
|
||||||
private Integer month;
|
private Integer month;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
public PublicUpdateInfo () {}
|
public PublicUpdateInfo () {}
|
||||||
|
|
||||||
public PublicUpdateInfo (PricePublish lastData) {
|
public PublicUpdateInfo (Integer year, Integer month) {
|
||||||
|
this.date = LocalDate.of(year, month, 1);
|
||||||
|
this.period = getPeriod(this.date.getYear(), this.date.getMonth().getValue());
|
||||||
|
this.year = date.getYear();
|
||||||
|
this.month = date.getMonth().getValue();
|
||||||
|
this.status = PricePublishStatus.WAITING;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getPeriod(Integer year, Integer month) {
|
||||||
Integer initialPeriod = 0;
|
Integer initialPeriod = 0;
|
||||||
var initialDate = LocalDate.of(2000,1,1);
|
var initialDate = LocalDate.of(2000,1,1);
|
||||||
|
|
||||||
this.date = lastData.getCreateTime().toLocalDate();
|
|
||||||
Integer months = 0;
|
Integer months = 0;
|
||||||
for (var i = 0; i < 1000;i++) {
|
for (var i = 0; i < 1000;i++) {
|
||||||
var date = initialDate.plusMonths(i);
|
var date = initialDate.plusMonths(i);
|
||||||
if (date.getYear() == this.date.getYear() && date.getMonth() == this.date.getMonth()) {
|
if (date.getYear() == year && date.getMonth().getValue() == month) {
|
||||||
months = i;
|
months = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.period = initialPeriod + months;
|
return initialPeriod + months;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicUpdateInfo (PricePublish lastData) {
|
||||||
|
this.date = lastData.getCreateTime().toLocalDate();
|
||||||
|
this.period = getPeriod(this.date.getYear(), this.date.getMonth().getValue());
|
||||||
this.year = date.getYear();
|
this.year = date.getYear();
|
||||||
this.month = date.getMonth().getValue();
|
this.month = date.getMonth().getValue();
|
||||||
|
this.status = lastData.getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user