fix:修复字典切面响应单个空对象没有判空;物料实例加检索条件。

This commit is contained in:
shusir
2026-02-26 09:08:11 +08:00
parent 4312630da6
commit 61ca2cc52e
4 changed files with 17 additions and 2 deletions

View File

@@ -407,6 +407,11 @@ public class DictAspect {
*/ */
private Boolean checkHasDict(List<Object> records){ private Boolean checkHasDict(List<Object> records){
if(LegendConvertUtils.isNotEmpty(records) && records.size()>0){ if(LegendConvertUtils.isNotEmpty(records) && records.size()>0){
// 添加对第一个元素的空值检查
Object firstRecord = records.get(0);
if (firstRecord == null) {
return false;
}
for (Field field : LegendConvertUtils.getAllFields(records.get(0))) { for (Field field : LegendConvertUtils.getAllFields(records.get(0))) {
if (LegendConvertUtils.isNotEmpty(field.getAnnotation(Dict.class))) { if (LegendConvertUtils.isNotEmpty(field.getAnnotation(Dict.class))) {
return true; return true;

View File

@@ -604,6 +604,10 @@ public class LegendConvertUtils {
* @return * @return
*/ */
public static Field[] getAllFields(Object object) { public static Field[] getAllFields(Object object) {
// 添加空值检查
if (object == null) {
return new Field[0];
}
Class<?> clazz = object.getClass(); Class<?> clazz = object.getClass();
List<Field> fieldList = new ArrayList<>(); List<Field> fieldList = new ArrayList<>();
while (clazz != null) { while (clazz != null) {

View File

@@ -121,14 +121,17 @@ public class MaterialInfomationRespVO {
@Schema(description = "是否危险品,1-是0-否") @Schema(description = "是否危险品,1-是0-否")
@ExcelProperty("是否危险品,1-是0-否") @ExcelProperty("是否危险品,1-是0-否")
@Dict(dicCode = "yes_or_no")
private Integer hazardous; private Integer hazardous;
@Schema(description = "是否标准溶液,1-是0-否") @Schema(description = "是否标准溶液,1-是0-否")
@ExcelProperty("是否标准溶液,1-是0-否") @ExcelProperty("是否标准溶液,1-是0-否")
@Dict(dicCode = "yes_or_no")
private Integer standardSolutionFlag; private Integer standardSolutionFlag;
@Schema(description = "是否标准物质,1-是0-否") @Schema(description = "是否标准物质,1-是0-否")
@ExcelProperty("是否标准物质,1-是0-否") @ExcelProperty("是否标准物质,1-是0-否")
@Dict(dicCode = "yes_or_no")
private Integer standardMaterialFlag; private Integer standardMaterialFlag;
@Schema(description = "配置人") @Schema(description = "配置人")

View File

@@ -106,7 +106,10 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
MPJLambdaWrapper<MaterialInfomationDO> wrapper = getInfomationDOMPJLambdaWrapper(); MPJLambdaWrapper<MaterialInfomationDO> wrapper = getInfomationDOMPJLambdaWrapper();
wrapper.eqIfExists(MaterialInfomationDO::getCode, queryVO.getCode()) wrapper.eqIfExists(MaterialInfomationDO::getCode, queryVO.getCode())
.eqIfExists(MaterialInfomationDO::getUsageStatus, queryVO.getUsageStatus()) .eqIfExists(MaterialInfomationDO::getUsageStatus, queryVO.getUsageStatus())
.eqIfExists(MaterialInfomationDO::getUseEndFlag, queryVO.getUseEndFlag()); .eqIfExists(MaterialInfomationDO::getUseEndFlag, queryVO.getUseEndFlag())
.eqIfExists(MaterialProductDO::getHazardous, queryVO.getHazardous())
.eqIfExists(MaterialProductDO::getStandardMaterialFlag, queryVO.getStandardMaterialFlag())
.eqIfExists(MaterialProductDO::getStandardSolutionFlag, queryVO.getStandardSolutionFlag());
return selectJoinOne(MaterialInfomationRespVO.class, wrapper); return selectJoinOne(MaterialInfomationRespVO.class, wrapper);
} }
@@ -132,7 +135,7 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
.selectAs("batch.BAT_NO", MaterialInfomationRespVO::getBatchNo) .selectAs("batch.BAT_NO", MaterialInfomationRespVO::getBatchNo)
.selectAs("gongduan.ASN_DEPT_NAME", MaterialInfomationRespVO::getAssignDepartmentName) .selectAs("gongduan.ASN_DEPT_NAME", MaterialInfomationRespVO::getAssignDepartmentName)
.selectAs(ConfigWarehouseLocationDO::getCode, MaterialInfomationRespVO::getLocationCode) .selectAs(ConfigWarehouseLocationDO::getCode, MaterialInfomationRespVO::getLocationCode)
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId) .innerJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId)
.leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialInfomationDO::getBatchId) .leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialInfomationDO::getBatchId)
.leftJoin(MaterialBatchDO.class, "gongduan", MaterialBatchDO::getId, MaterialInfomationDO::getGongduanId) .leftJoin(MaterialBatchDO.class, "gongduan", MaterialBatchDO::getId, MaterialInfomationDO::getGongduanId)
.leftJoin(ConfigWarehouseLocationDO.class, ConfigWarehouseLocationDO::getId, MaterialInfomationDO::getLocationId) .leftJoin(ConfigWarehouseLocationDO.class, ConfigWarehouseLocationDO::getId, MaterialInfomationDO::getLocationId)