mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-25 07:07:37 +08:00
feat(CoalWashingDailyAnalysisKFItem): add archiving checks to create, update, and delete operations
This commit is contained in:
@@ -16,4 +16,10 @@ public interface CoalWashingDailyAnalysisKFItemRepository
|
||||
boolean isLinked(List<String> ids);
|
||||
|
||||
void deleteAllByCoalWashingDailyAnalysis(CoalWashingDailyAnalysisEntity entity);
|
||||
|
||||
@Query("select case when count(e) > 0 then true else false end from CoalWashingDailyAnalysisKFItemEntity e where e.id in :ids and e.coalWashingDailyAnalysis.archiveStatus = '1'")
|
||||
boolean isMainArchived(List<String> ids);
|
||||
|
||||
@Query("select case when c.archiveStatus = '1' then true else false end from CoalWashingDailyAnalysisEntity c where c.id = :mainId")
|
||||
boolean isMainArchivedByMainId(String mainId);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
@@ -38,6 +40,10 @@ public class CoalWashingDailyAnalysisKFItemService
|
||||
|
||||
public CoalWashingDailyAnalysisKFItemDto create(
|
||||
CreateCoalWashingDailyAnalysisKFItemDto request) {
|
||||
if (request.getCoalWashingDailyAnalysis() != null
|
||||
&& this.repository.isMainArchivedByMainId(request.getCoalWashingDailyAnalysis())) {
|
||||
throw new BizException("主单已归档,无法新增");
|
||||
}
|
||||
CoalWashingDailyAnalysisKFItemEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
@@ -46,6 +52,9 @@ public class CoalWashingDailyAnalysisKFItemService
|
||||
|
||||
public CoalWashingDailyAnalysisKFItemDto update(
|
||||
UpdateCoalWashingDailyAnalysisKFItemDto request) {
|
||||
if (this.repository.isMainArchived(List.of(request.getId()))) {
|
||||
throw new BizException("主单已归档,无法编辑");
|
||||
}
|
||||
CoalWashingDailyAnalysisKFItemEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
@@ -55,6 +64,9 @@ public class CoalWashingDailyAnalysisKFItemService
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
if (this.repository.isMainArchived(request.getIds())) {
|
||||
throw new BizException("主单已归档,无法删除");
|
||||
}
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class DeviceWorkOrderEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "workOrder", cascade = {CascadeType.ALL})
|
||||
@OneToMany(mappedBy = "workOrder", cascade = {CascadeType.ALL}, orphanRemoval = true)
|
||||
private List<DeviceWorkOrderDetailEntity> details;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user