liyong
17 小时以前 8d230ea993c35ab7a2794bbdca39c819796543b0
refactor(production): 优化产品主表删除逻辑并添加完成状态标识
已修改8个文件
60 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/controller/ProductionProductMainController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductProcessRouteItemDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductWorkOrderDto.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/ProductionProductMainService.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductProcessRouteItemServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductProcessRouteItemMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductWorkOrderMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductionProductMainController.java
@@ -50,7 +50,8 @@
    @DeleteMapping("/delete")
    @Transactional(rollbackFor = Exception.class)
    public R delete(@RequestBody ProductionProductMainDto productionProductMainDto) {
        return R.ok(productionProductMainService.removeProductMain(productionProductMainDto));
        return R.ok(productionProductMainService.removeProductMain(productionProductMainDto.getId()));
    }
src/main/java/com/ruoyi/production/dto/ProductProcessRouteItemDto.java
@@ -24,4 +24,6 @@
    private String productName;
    private String model;
    private Boolean isComplete;
}
src/main/java/com/ruoyi/production/dto/ProductWorkOrderDto.java
@@ -40,4 +40,7 @@
    @ApiModelProperty(value = "报废数量")
    private BigDecimal scrapQty;
    @ApiModelProperty(value = "工单类型 正常 /返工返修")
    private String workOrderType;
}
src/main/java/com/ruoyi/production/service/ProductionProductMainService.java
@@ -3,17 +3,13 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.production.dto.ProcessRouteItemDto;
import com.ruoyi.production.dto.ProductOrderDto;
import com.ruoyi.production.dto.ProductionProductMainDto;
import com.ruoyi.production.pojo.ProductionProductMain;
import java.util.List;
public interface ProductionProductMainService extends IService<ProductionProductMain> {
    IPage<ProductionProductMainDto> listPageProductionProductMainDto(Page page, ProductionProductMainDto productionProductMainDto);
    Boolean addProductMain(ProductionProductMainDto productionProductMainDto);
    Boolean removeProductMain(ProductionProductMainDto productionProductMainDto);
    Boolean removeProductMain(Long id);
}
src/main/java/com/ruoyi/production/service/impl/ProductProcessRouteItemServiceImpl.java
@@ -6,9 +6,11 @@
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;
@@ -20,6 +22,7 @@
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;
@@ -34,6 +37,7 @@
public class ProductProcessRouteItemServiceImpl extends ServiceImpl<ProductProcessRouteItemMapper, ProductProcessRouteItem> implements ProductProcessRouteItemService {
    private ProductionProductMainService productionProductMainService;
    private ProductProcessRouteItemMapper productProcessRouteItemMapper;
    private ProductionProductMainMapper productionProductMainMapper;
@@ -73,6 +77,9 @@
            if (productWorkOrder == null) {
                throw new RuntimeException("删除失败:未找到关联的生产工单");
            }
            if (BigDecimal.ZERO.compareTo(productWorkOrder.getCompleteQuantity()) < 0) {
                throw new RuntimeException("删除失败:该工单已开始生产,请先删除生产报工");
            }
            Long workOrderId = productWorkOrder.getId();
            Long productOrderId = productWorkOrder.getProductOrderId();
            // 查询生产主表
@@ -83,21 +90,19 @@
            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) {
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -248,8 +248,8 @@
    }
    @Override
    public Boolean removeProductMain(ProductionProductMainDto dto) {
        ProductionProductMain productionProductMain = productionProductMainMapper.selectById(dto.getId());
    public Boolean removeProductMain(Long id) {
        ProductionProductMain productionProductMain = productionProductMainMapper.selectById(id);
        //该报工对应的工艺路线详情
        ProductProcessRouteItem productProcessRouteItem = productProcessRouteItemMapper.selectById(productionProductMain.getProductProcessRouteItemId());
        ProductionProductOutput productionProductOutput = productionProductOutputMapper.selectList(Wrappers.<ProductionProductOutput>lambdaQuery().eq(ProductionProductOutput::getProductMainId, productionProductMain.getId())).get(0);
@@ -271,7 +271,6 @@
            productOrder.setEndTime(null);
            productOrderMapper.updateById(productOrder);
        }
        /*删除产出*/
        //删除质检
        qualityInspectMapper.selectList(
                new LambdaQueryWrapper<QualityInspect>()
src/main/resources/mapper/production/ProductProcessRouteItemMapper.xml
@@ -15,11 +15,13 @@
               pp.name as process_name,
               pm.model,
               pm.unit,
               p.product_name
               p.product_name,
               case when pwo.complete_quantity>0 then true else false end as is_complete
        from product_process_route_item ppri
                 left join product_model pm on ppri.product_model_id = pm.id
                 left join product p on pm.product_id = p.id
                 left join product_process pp on pp.id = ppri.process_id
                 left join product_work_order pwo on pwo.product_process_route_item_id = ppri.id
        where ppri.product_order_id = #{orderId}
        order by ppri.drag_sort
    </select>
src/main/resources/mapper/production/ProductWorkOrderMapper.xml
@@ -26,7 +26,11 @@
        pm.unit,
        p.product_name AS productName,
        po.nps_no AS productOrderNpsNo,
        ROUND(pwo.complete_quantity / pwo.plan_quantity * 100, 2) AS completionStatus
        ROUND(pwo.complete_quantity / pwo.plan_quantity * 100, 2) AS completionStatus,
        CASE
        WHEN pwo.work_order_no LIKE 'FG%' THEN '返工返修'
        ELSE '正常'
        END AS work_order_type
        FROM
        product_work_order pwo
        LEFT JOIN product_process_route_item ppri ON ppri.id = pwo.product_process_route_item_id