diff --git a/blade-biz-common/src/main/java/org/springblade/common/jsonserializer/BigDecimalTwoDecimalSerializer.java b/blade-biz-common/src/main/java/org/springblade/common/jsonserializer/BigDecimalTwoDecimalSerializer.java new file mode 100644 index 000000000..98e655357 --- /dev/null +++ b/blade-biz-common/src/main/java/org/springblade/common/jsonserializer/BigDecimalTwoDecimalSerializer.java @@ -0,0 +1,26 @@ +package org.springblade.common.jsonserializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; + +/** + * BigDecimal 序列化器 保留2位小数 四舍五入 + * @Author zqb + * @Date 2024/10/8 + **/ +public class BigDecimalTwoDecimalSerializer extends JsonSerializer { + + @Override + public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + if (value != null) { + gen.writeNumber(value.setScale(2, RoundingMode.HALF_UP)); + } else { + gen.writeNull(); + } + } + } diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/WarehouseLeasingEntity.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/WarehouseLeasingEntity.java index f98f493e9..6e8f08c06 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/WarehouseLeasingEntity.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/WarehouseLeasingEntity.java @@ -1,10 +1,12 @@ package com.logpm.basicdata.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springblade.common.jsonserializer.BigDecimalTwoDecimalSerializer; import org.springblade.core.tenant.mp.TenantEntity; import java.math.BigDecimal; @@ -41,16 +43,19 @@ public class WarehouseLeasingEntity extends TenantEntity { * 租用库位数 */ @ApiModelProperty(value = "租用库位数") + @JsonSerialize(using = BigDecimalTwoDecimalSerializer.class) private BigDecimal storageLocationCount; /** * 租用面积 */ @ApiModelProperty(value = "租用面积") + @JsonSerialize(using = BigDecimalTwoDecimalSerializer.class) private BigDecimal leasedArea; /** * 月租金 */ @ApiModelProperty(value = "月租金") + @JsonSerialize(using = BigDecimalTwoDecimalSerializer.class) private BigDecimal monthlyRent; /** * 租赁合同开始时间 diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/WarehouseLeasingController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/WarehouseLeasingController.java index 658f7396c..3aca01fed 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/WarehouseLeasingController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/WarehouseLeasingController.java @@ -16,6 +16,8 @@ */ package com.logpm.basicdata.controller; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -122,6 +124,19 @@ public class WarehouseLeasingController extends BladeController { @ApiOperation(value = "分页", notes = "传入warehouseLeasing") public R> page(WarehouseLeasingVO warehouseLeasing, Query query) { IPage pages = warehouseLeasingService.selectWarehouseLeasingPage(Condition.getPage(query), warehouseLeasing); + if (ObjectUtil.isNotEmpty(pages)) { + List records = pages.getRecords(); + if (CollUtil.isNotEmpty(records)) { + for (WarehouseLeasingVO record : records) { + if (NumberUtil.equals(record.getType(), 1)) { + record.setTypeName("面积"); + } + if (NumberUtil.equals(record.getType(), 2)) { + record.setTypeName("库位"); + } + } + } + } return R.data(pages); } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/vo/WarehouseLeasingVO.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/vo/WarehouseLeasingVO.java index b5cee1a1f..28d1bd74f 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/vo/WarehouseLeasingVO.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/vo/WarehouseLeasingVO.java @@ -37,6 +37,11 @@ public class WarehouseLeasingVO extends WarehouseLeasingEntity { */ @ApiModelProperty(value = "仓库名称") private String warehouseName; + /** + * 租用类型(名称) + */ + @ApiModelProperty(value = "租用类型(名称)") + private String typeName; /** * 是否过期