原始BOM列表
This commit is contained in:
parent
171121c609
commit
47eef9d27b
|
|
@ -74,25 +74,17 @@ public class OriginalBomApi extends BaseApi {
|
|||
|
||||
originalParentService.pullFromPlm(SessionUtil.getUserCode());
|
||||
|
||||
//计算树的层级数
|
||||
CompletableFuture.runAsync(()->{
|
||||
try {
|
||||
originalParentService.compucteLevelNum();
|
||||
originalParentService.getBaseMapper().updateRootState();
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
originalParentService.computeLevelNumAndRootState();
|
||||
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
@GetMapping("del")
|
||||
@ApiOperation("删除BOM")
|
||||
public ResultVO<Boolean> del(@RequestParam("parentRowId") Long parentRowId) throws ExecutionException, InterruptedException {
|
||||
return ResultVO.success(originalParentService.del(parentRowId));
|
||||
public ResultVO<Boolean> del(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
originalParentService.del(bomRowId);
|
||||
originalParentService.computeLevelNumAndRootState();
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import java.sql.Struct;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinTask;
|
||||
|
|
@ -240,20 +242,40 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算层级数和根节点状态
|
||||
*/
|
||||
public void computeLevelNumAndRootState() {
|
||||
//计算树的层级数
|
||||
CompletableFuture.runAsync(()->{
|
||||
try {
|
||||
this.compucteLevelNum();
|
||||
this.getBaseMapper().updateRootState();
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除BOM
|
||||
*
|
||||
* @param parentRowId
|
||||
* @param bomRowId
|
||||
*/
|
||||
public Boolean del(Long parentRowId) throws ExecutionException, InterruptedException {
|
||||
public Boolean del(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
|
||||
BomNewOriginalParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
|
||||
VUtils.isTure(Objects.isNull(parentEntity) ).throwMessage("该节点不存在,请检查参数是否正确");
|
||||
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
|
||||
List<BomOriginalListVO> bomTree = getBomTree(bomRowId);
|
||||
|
||||
List<BomOriginalListVO> bomTree = getBomTree(parentRowId);
|
||||
List<Long> parentDel = new ArrayList<>();
|
||||
|
||||
List<Long> delParentRowId = bomTree.stream().filter(u -> u.getCreatedBy().equals(SessionUtil.getUserCode()) && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).map(u -> u.getParentRowId()).collect(Collectors.toList());
|
||||
|
||||
delParentRowId.add(bomRowId);
|
||||
if (CollUtil.isNotEmpty(delParentRowId)) {
|
||||
this.getBaseMapper().delBatch(delParentRowId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@
|
|||
</update>
|
||||
|
||||
<update id="updateRootState">
|
||||
|
||||
update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1;
|
||||
update t_bom_new_original_parent a join (
|
||||
select a.row_id from t_bom_new_original_parent a
|
||||
left join t_bom_new_original_child b
|
||||
|
|
|
|||
Loading…
Reference in New Issue