optimize(ebom): 删除时更新last_version_is
This commit is contained in:
parent
fd3c119ac5
commit
70faa04f00
|
|
@ -104,4 +104,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
|
|||
void delEBomHistory(@Param("parentRowIds") List<Long> parentRowIds);
|
||||
|
||||
List<BomNewEbomParentEntity> getLatestByMaterialNo(Collection<String> materialNos);
|
||||
|
||||
void updateLastVersionIs();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2572,10 +2572,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
VUtils.isTure(!StrUtil.equals(root.getCreatedBy(), SessionUtil.getUserCode())).throwMessage("不能删除他人的数据");
|
||||
|
||||
delete(root.getRowId());
|
||||
|
||||
CompletableFuture.runAsync(this::updateLastVersionIs);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void delete(Long bomRowId) {
|
||||
this.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomParentEntity.class)
|
||||
.eq(BomNewEbomParentEntity::getRowId, bomRowId));
|
||||
|
||||
Set<String> materialNos = ebomChildService.lambdaQuery()
|
||||
.select(BomNewEbomChildEntity::getMaterialNo)
|
||||
.eq(BomNewEbomChildEntity::getParentRowId, bomRowId)
|
||||
|
|
@ -2583,6 +2588,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.stream()
|
||||
.map(BomNewEbomChildEntity::getMaterialNo)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
ebomChildService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomChildEntity.class)
|
||||
.eq(BomNewEbomChildEntity::getParentRowId, bomRowId));
|
||||
|
||||
if (CollUtil.isEmpty(materialNos)) return;
|
||||
|
||||
List<BomNewEbomParentEntity> parents = lambdaQuery()
|
||||
|
|
@ -2599,11 +2608,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|| Objects.equals(p.getVirtualPackageIs(), 1))
|
||||
.map(BomNewEbomParentEntity::getRowId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ebomChildService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomChildEntity.class)
|
||||
.eq(BomNewEbomChildEntity::getParentRowId, bomRowId));
|
||||
this.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomParentEntity.class)
|
||||
.eq(BomNewEbomParentEntity::getRowId, bomRowId));
|
||||
//将自己手动创建的bom提为用户顶层
|
||||
List<Long> updateParents = parents.stream()
|
||||
.filter(p -> StrUtil.equals(p.getCreatedBy(), SessionUtil.getUserCode()))
|
||||
|
|
@ -2619,4 +2623,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
deleteParents.forEach(this::delete);
|
||||
}
|
||||
|
||||
private void updateLastVersionIs() {
|
||||
this.getBaseMapper().updateLastVersionIs();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,6 +314,16 @@
|
|||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateLastVersionIs">
|
||||
UPDATE t_bom_new_ebom_parent
|
||||
SET last_version_is=0;
|
||||
UPDATE t_bom_new_ebom_parent p1
|
||||
INNER JOIN (SELECT material_no, MAX(current_version) current_version
|
||||
FROM t_bom_new_ebom_parent
|
||||
GROUP BY material_no) p2 ON p1.material_no = p2.material_no AND
|
||||
p1.current_version = p2.current_version
|
||||
SET p1.last_version_is=1;
|
||||
</update>
|
||||
|
||||
|
||||
<!--检查是否已发布数据的跟节点-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue