diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java index b8cead4e..02f677f6 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java @@ -17,6 +17,7 @@ import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.convert.ConversionService; import org.springframework.data.domain.Page; @@ -45,10 +46,25 @@ public class CoalWashingDailyAnalysisService CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request); entity.setOrganizationId(Ctx.currentUser().getOrganizationId()); + validate(entity); this.repository.save(entity); return getById(entity.getId()); } + private void validate(CoalWashingDailyAnalysisEntity entity) { + + + if (CollectionUtils.isNotEmpty(entity.getInputItems())){ + entity.getInputItems().forEach(item -> { + if (item.getTime() == null){ + throw new BizException("时间不能为空"); + } + + }); + } + + } + public CoalWashingDailyAnalysisDto calculate(CreateCoalWashingDailyAnalysisDto request) { CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request); @@ -69,6 +85,10 @@ public class CoalWashingDailyAnalysisService this.mapper.updateEntity(entity, request); entity.setOrganizationId(Ctx.currentUser().getOrganizationId()); + + + validate(entity); + this.repository.save(entity); return getById(entity.getId());