| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.production.dto.ProductProcessRouteItemDto; |
| | | import com.ruoyi.production.dto.ProductionProductMainDto; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.ProductProcessRouteItemService; |
| | | import com.ruoyi.production.service.ProductionProductMainService; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | |
| | | public class ProductProcessRouteItemServiceImpl extends ServiceImpl<ProductProcessRouteItemMapper, ProductProcessRouteItem> implements ProductProcessRouteItemService { |
| | | |
| | | |
| | | private ProductionProductMainService productionProductMainService; |
| | | private ProductProcessRouteItemMapper productProcessRouteItemMapper; |
| | | |
| | | private ProductionProductMainMapper productionProductMainMapper; |
| | |
| | | if (productWorkOrder == null) { |
| | | throw new RuntimeException("删除失败:未找到关联的生产工单"); |
| | | } |
| | | if (BigDecimal.ZERO.compareTo(productWorkOrder.getCompleteQuantity()) < 0) { |
| | | throw new RuntimeException("删除失败:该工单已开始生产,请先删除生产报工"); |
| | | } |
| | | Long workOrderId = productWorkOrder.getId(); |
| | | Long productOrderId = productWorkOrder.getProductOrderId(); |
| | | // 查询生产主表 |
| | |
| | | if (!productionProductMains.isEmpty()) { |
| | | // 批量删除子表 |
| | | for (ProductionProductMain main : productionProductMains) { |
| | | Long mainId = main.getId(); |
| | | // 删除投入 |
| | | productionProductInputMapper.delete(new LambdaQueryWrapper<ProductionProductInput>() |
| | | .eq(ProductionProductInput::getProductMainId, mainId)); |
| | | // 删除产出 |
| | | productionProductOutputMapper.delete(new LambdaQueryWrapper<ProductionProductOutput>() |
| | | .eq(ProductionProductOutput::getProductMainId, mainId)); |
| | | // 删除质检 |
| | | qualityInspectMapper.delete(new LambdaQueryWrapper<QualityInspect>() |
| | | .eq(QualityInspect::getProductMainId, mainId)); |
| | | productionProductMainService.removeProductMain(main.getId()); |
| | | // Long mainId = main.getId(); |
| | | // // 删除投入 |
| | | // productionProductInputMapper.delete(new LambdaQueryWrapper<ProductionProductInput>() |
| | | // .eq(ProductionProductInput::getProductMainId, mainId)); |
| | | // // 删除产出 |
| | | // productionProductOutputMapper.delete(new LambdaQueryWrapper<ProductionProductOutput>() |
| | | // .eq(ProductionProductOutput::getProductMainId, mainId)); |
| | | // // 删除质检 |
| | | // qualityInspectMapper.delete(new LambdaQueryWrapper<QualityInspect>() |
| | | // .eq(QualityInspect::getProductMainId, mainId)); |
| | | } |
| | | } |
| | | // 删除报工(生产主表) |
| | | productionProductMainMapper.delete(new LambdaQueryWrapper<ProductionProductMain>() |
| | | .eq(ProductionProductMain::getWorkOrderId, workOrderId)); |
| | | // 查询订单 + 删除核算 |
| | | ProductOrder productOrder = productOrderMapper.selectById(productOrderId); |
| | | if (productOrder != null && productOrder.getSalesLedgerId() != null) { |