feat(dict): 新增字典注解删除标记字段支持并修复库存计算空指针异常

- 在Dict注解中新增deleteFlag字段用于指定删除标记字段名
- 修改DictAspect切面逻辑支持删除标记字段的过滤查询
- 更新ProductDetailAppMapper.xml中的关联查询条件排序
- 修复ProductDetailAppServiceImpl中partPercent为空时的空指针异常
- 为ReceiptPageDto中的字典字段添加删除标记过滤配置
- 新增药物统计管理门户页面提供各类统计报表入口
This commit is contained in:
2026-02-24 17:30:23 +08:00
parent 8b993d5ddd
commit ff41aa9c04
6 changed files with 306 additions and 105 deletions

View File

@@ -173,29 +173,47 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
productDetailPageDto.setInventoryStatusEnum_enumText(
EnumUtils.getInfoByValue(PublicationStatus.class, productDetailPageDto.getInventoryStatusEnum()));
// 计算包装单位数量
BigDecimal[] results
= productDetailPageDto.getQuantity().divideAndRemainder(productDetailPageDto.getPartPercent());
// 整数
productDetailPageDto.setNumber(results[0]);
// 余数
productDetailPageDto.setRemainder(results[1]);
// 计算包装单位数量 - 防止partPercent为null导致的空指针异常
BigDecimal partPercent = productDetailPageDto.getPartPercent();
if (partPercent != null && partPercent.compareTo(BigDecimal.ZERO) != 0) {
BigDecimal[] results = productDetailPageDto.getQuantity().divideAndRemainder(partPercent);
// 整数
productDetailPageDto.setNumber(results[0]);
// 余数
productDetailPageDto.setRemainder(results[1]);
// 计算采购总额
if (productDetailPageDto.getPurchasePrice() != null) {
productDetailPageDto
.setTotalPurchasePrice(productDetailPageDto.getPurchasePrice().multiply(results[0])
.add(productDetailPageDto.getPurchasePrice()
.divide(productDetailPageDto.getPartPercent(), 6, RoundingMode.HALF_UP)
.multiply(results[1])));
}
// 计算采购总额
if (productDetailPageDto.getPurchasePrice() != null) {
productDetailPageDto
.setTotalPurchasePrice(productDetailPageDto.getPurchasePrice().multiply(results[0])
.add(productDetailPageDto.getPurchasePrice()
.divide(partPercent, 6, RoundingMode.HALF_UP)
.multiply(results[1])));
}
// 计算售价总额
if (productDetailPageDto.getSalePrice() != null) {
productDetailPageDto.setTotalSalePrice(productDetailPageDto.getSalePrice().multiply(results[0])
.add(productDetailPageDto.getSalePrice()
.divide(productDetailPageDto.getPartPercent(), 6, RoundingMode.HALF_UP)
.multiply(results[1])));
// 计算售价总额
if (productDetailPageDto.getSalePrice() != null) {
productDetailPageDto.setTotalSalePrice(productDetailPageDto.getSalePrice().multiply(results[0])
.add(productDetailPageDto.getSalePrice()
.divide(partPercent, 6, RoundingMode.HALF_UP)
.multiply(results[1])));
}
} else {
// 如果partPercent为空或为0则直接设置数量避免计算
productDetailPageDto.setNumber(productDetailPageDto.getQuantity());
productDetailPageDto.setRemainder(BigDecimal.ZERO);
// 计算采购总额
if (productDetailPageDto.getPurchasePrice() != null) {
productDetailPageDto.setTotalPurchasePrice(
productDetailPageDto.getPurchasePrice().multiply(productDetailPageDto.getQuantity()));
}
// 计算售价总额
if (productDetailPageDto.getSalePrice() != null) {
productDetailPageDto.setTotalSalePrice(
productDetailPageDto.getSalePrice().multiply(productDetailPageDto.getQuantity()));
}
}
}
}
@@ -552,29 +570,47 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
productDetailPageDto.setInventoryStatusEnum_enumText(
EnumUtils.getInfoByValue(PublicationStatus.class, productDetailPageDto.getInventoryStatusEnum()));
// 计算包装单位数量
BigDecimal[] results
= productDetailPageDto.getQuantity().divideAndRemainder(productDetailPageDto.getPartPercent());
// 整数
productDetailPageDto.setNumber(results[0]);
// 余数
productDetailPageDto.setRemainder(results[1]);
// 计算包装单位数量 - 防止partPercent为null导致的空指针异常
BigDecimal partPercent = productDetailPageDto.getPartPercent();
if (partPercent != null && partPercent.compareTo(BigDecimal.ZERO) != 0) {
BigDecimal[] results = productDetailPageDto.getQuantity().divideAndRemainder(partPercent);
// 整数
productDetailPageDto.setNumber(results[0]);
// 余数
productDetailPageDto.setRemainder(results[1]);
// 计算采购总额
if (productDetailPageDto.getPurchasePrice() != null) {
productDetailPageDto
.setTotalPurchasePrice(productDetailPageDto.getPurchasePrice().multiply(results[0])
.add(productDetailPageDto.getPurchasePrice()
.divide(productDetailPageDto.getPartPercent(), 6, RoundingMode.HALF_UP)
.multiply(results[1])));
}
// 计算采购总额
if (productDetailPageDto.getPurchasePrice() != null) {
productDetailPageDto
.setTotalPurchasePrice(productDetailPageDto.getPurchasePrice().multiply(results[0])
.add(productDetailPageDto.getPurchasePrice()
.divide(partPercent, 6, RoundingMode.HALF_UP)
.multiply(results[1])));
}
// 计算售价总额
if (productDetailPageDto.getSalePrice() != null) {
productDetailPageDto.setTotalSalePrice(productDetailPageDto.getSalePrice().multiply(results[0])
.add(productDetailPageDto.getSalePrice()
.divide(productDetailPageDto.getPartPercent(), 6, RoundingMode.HALF_UP)
.multiply(results[1])));
// 计算售价总额
if (productDetailPageDto.getSalePrice() != null) {
productDetailPageDto.setTotalSalePrice(productDetailPageDto.getSalePrice().multiply(results[0])
.add(productDetailPageDto.getSalePrice()
.divide(partPercent, 6, RoundingMode.HALF_UP)
.multiply(results[1])));
}
} else {
// 如果partPercent为空或为0则直接设置数量避免计算
productDetailPageDto.setNumber(productDetailPageDto.getQuantity());
productDetailPageDto.setRemainder(BigDecimal.ZERO);
// 计算采购总额
if (productDetailPageDto.getPurchasePrice() != null) {
productDetailPageDto.setTotalPurchasePrice(
productDetailPageDto.getPurchasePrice().multiply(productDetailPageDto.getQuantity()));
}
// 计算售价总额
if (productDetailPageDto.getSalePrice() != null) {
productDetailPageDto.setTotalSalePrice(
productDetailPageDto.getSalePrice().multiply(productDetailPageDto.getQuantity()));
}
}
}
}

View File

@@ -53,7 +53,7 @@ public class ReceiptPageDto {
/**
* 供应商
*/
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_supplier")
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_supplier", deleteFlag = "delete_flag")
@JsonSerialize(using = ToStringSerializer.class)
private Long supplierId;
private String supplierId_dictText;
@@ -63,7 +63,7 @@ public class ReceiptPageDto {
/**
* 目的仓库
*/
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_location")
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_location", deleteFlag = "delete_flag")
@JsonSerialize(using = ToStringSerializer.class)
private Long purposeLocationId;
private String purposeLocationId_dictText;
@@ -73,7 +73,7 @@ public class ReceiptPageDto {
/**
* 目的仓位
*/
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_location")
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_location", deleteFlag = "delete_flag")
@JsonSerialize(using = ToStringSerializer.class)
private Long purposeLocationStoreId;
private String purposeLocationStoreId_dictText;
@@ -86,7 +86,7 @@ public class ReceiptPageDto {
/**
* 经手人
*/
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_practitioner")
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_practitioner", deleteFlag = "delete_flag")
@JsonSerialize(using = ToStringSerializer.class)
private Long practitionerId;
private String practitionerId_dictText;
@@ -96,7 +96,7 @@ public class ReceiptPageDto {
/**
* 审批人
*/
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_practitioner")
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_practitioner", deleteFlag = "delete_flag")
private Long approverId;
private String approverId_dictText;
@Excel(name = "审批人", sort = 10)
@@ -111,7 +111,7 @@ public class ReceiptPageDto {
/**
* 申请人
*/
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_practitioner")
@Dict(dictCode = "id", dictText = "name", dictTable = "adm_practitioner", deleteFlag = "delete_flag")
@JsonSerialize(using = ToStringSerializer.class)
private Long applicantId;
private String applicantId_dictText;