huminmin
昨天 e28990c8626f115fccad6fd5f47a6e98b85dacb7
src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -166,6 +166,7 @@
            if (assignedVolume.add(remainingVolume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) {
                // 最后一个计划,分配剩余方数
                BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume);
                plan.setStatus(1);
                plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume));
                productOrderPlan.setAssignedQuantity(lastRemainingVolume);
                productionPlanMapper.updateById(plan);
@@ -174,6 +175,7 @@
            }
            // 分配当前计划方数
            plan.setStatus(1);
            plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume));
            productOrderPlan.setAssignedQuantity(remainingVolume);
            // 更新生产计划
@@ -196,6 +198,10 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean update(ProductionPlanDto productionPlanDto) {
        // 已下发状态,不能编辑
        if (productionPlanDto.getStatus() == 1) {
            throw new BaseException("已下发状态,不能编辑");
        }
        // 查询是否有关联订单
        boolean hasProductOrderPlan = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId())).stream().anyMatch(p -> p.getProductOrderId() != null);
        if (hasProductOrderPlan) {
@@ -212,6 +218,10 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> ids) {
        // 如果存在已下发的计划,则不能删除
        if (productionPlanMapper.selectList(Wrappers.<ProductionPlan>lambdaQuery().in(ProductionPlan::getId, ids).eq(ProductionPlan::getStatus, 1)).stream().anyMatch(p -> p.getStatus() == 1)) {
            throw new BaseException("删除失败,存在已下发的计划");
        }
        // 如果有关联订单,则不能删除
        if (productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductionPlanId, ids)).stream().anyMatch(p -> p.getProductOrderId() != null)) {
            throw new BaseException("删除失败,存在关联订单");