zss
15 小时以前 d8adaddf1886dfeb28599ef2e047da905883e42d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.ruoyi.productionPlan.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.production.dto.ProductOrderDto;
import com.ruoyi.production.mapper.ProductOrderMapper;
import com.ruoyi.production.mapper.ProductionOrderRouteMapper;
import com.ruoyi.production.mapper.ProductionProductMainMapper;
import com.ruoyi.production.pojo.ProductionProductMain;
import com.ruoyi.productionPlan.dto.OrderDto;
import com.ruoyi.productionPlan.dto.ProductionPlanDto;
import com.ruoyi.productionPlan.dto.TrackDto;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.productionPlan.mapper.ProductionPlanMapper;
import com.ruoyi.productionPlan.pojo.ProductOrderPlan;
import com.ruoyi.productionPlan.mapper.ProductOrderPlanMapper;
import com.ruoyi.productionPlan.service.ProductOrderPlanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 芯导软件(江苏)有限公司
 * @since 2026-03-11 03:02:58
 */
@Service
public class ProductOrderPlanServiceImpl extends ServiceImpl<ProductOrderPlanMapper, ProductOrderPlan> implements ProductOrderPlanService {
 
    @Autowired
    private ProductOrderPlanMapper productOrderPlanMapper;
 
    @Autowired
    private ProductionPlanMapper productionPlanMapper;
 
    @Autowired
    private ProductOrderMapper productOrderMapper;
 
    @Autowired
    private ProductionProductMainMapper productionProductMainMapper;
 
    @Override
    public TrackDto trackProgressByNo(String applyNo) {
        TrackDto trackDto = new TrackDto();
        //生产计划数据
        ProductionPlanDto planDto = new ProductionPlanDto();
        planDto.setApplyNo(applyNo);
        ProductionPlanDto productionPlanDto = productionPlanMapper.listPage(new Page(1, -1), planDto).getRecords().get(0);
        trackDto.setProductionPlanDto(productionPlanDto);
        //生产订单数据
        List<OrderDto> orderDtos = listByApplyNo(productionPlanDto);
        trackDto.setOrderDtoList(orderDtos);
        return trackDto;
    }
 
    private List<OrderDto> listByApplyNo(ProductionPlanDto productionPlanDto) {
        List<OrderDto> orderDtos = new ArrayList<>();
        //1.先查询该生产计划下所有关联的生产订单
        List<ProductOrderPlan> productOrderPlans = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery()
                .eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId()));
        if (CollectionUtils.isEmpty(productOrderPlans)){
            return null;
        }
        productOrderPlans.forEach(productOrderPlan -> {
            OrderDto orderDto = new OrderDto();
            //生产订单信息
            ProductOrderDto productOrderDto=productOrderMapper.getProductOrderDto(productOrderPlan.getProductOrderId());
            orderDto.setProductOrderDto(productOrderDto);
            //报工详情
            List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(Wrappers.<ProductionProductMain>lambdaQuery()
                    .eq(ProductionProductMain::getProductOrderId, productOrderPlan.getProductOrderId())
                    .orderByAsc(ProductionProductMain::getReportingTime));
            orderDto.setProductionProductMains(productionProductMains);
            orderDtos.add(orderDto);
        });
        return orderDtos;
    }
}