2026-04-22 30587170535f5a850c59b4a2323b1a311a22aa6a
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.production.mapper.ProductionOrderMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.production.pojo.ProductionOrder">
        <id column="id" property="id" />
        <result column="sales_ledger_id" property="salesLedgerId" />
        <result column="production_plan_ids" property="productionPlanIds" />
        <result column="product_model_id" property="productModelId" />
        <result column="nps_no" property="npsNo" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="technology_routing_id" property="technologyRoutingId" />
        <result column="quantity" property="quantity" />
        <result column="complete_quantity" property="completeQuantity" />
        <result column="start_time" property="startTime" />
        <result column="end_time" property="endTime" />
        <result column="sale_ledger_product_id" property="saleLedgerProductId" />
        <result column="create_user" property="createUser" />
        <result column="dept_id" property="deptId" />
    </resultMap>
 
    <select id="selectProgressOrders" resultType="com.ruoyi.home.dto.ProductionProgressOrderDto">
        select po.nps_no,
               sl.sales_contract_no,
               sl.project_name,
               sl.customer_name,
               p.product_name as productCategory,
               pm.model as specificationModel,
               tr.process_route_code as processRouteCode,
               po.quantity,
               ifnull(po.complete_quantity, 0) as completeQuantity,
               round(ifnull(po.complete_quantity, 0) / nullif(po.quantity, 0) * 100, 2) as completionStatus,
               tb.bom_no,
               datediff(sl.delivery_date, curdate()) as deliveryDaysDiff,
               sl.delivery_date,
               false as isFh
        from production_order po
                 left join sales_ledger sl on po.sales_ledger_id = sl.id
                 left join product_model pm on po.product_model_id = pm.id
                 left join product p on pm.product_id = p.id
                 left join technology_routing tr on po.technology_routing_id = tr.id
                 left join technology_bom tb on tr.bom_id = tb.id
        where po.create_time between #{startTime} and #{endTime}
        order by po.create_time desc
    </select>
 
    <select id="countCreated" resultType="java.lang.Integer">
        select count(1)
        from production_order
        where create_time &gt;= #{startDate}
          and create_time &lt;= #{endDate}
    </select>
 
    <select id="countCompleted" resultType="java.lang.Integer">
        select count(1)
        from production_order
        where end_time &gt;= #{startDate}
          and end_time &lt;= #{endDate}
          and ifnull(complete_quantity, 0) &gt;= quantity
    </select>
 
    <select id="countPending" resultType="java.lang.Integer">
        select count(1)
        from production_order
        where create_time &gt;= #{startDate}
          and create_time &lt;= #{endDate}
          and ifnull(complete_quantity, 0) &lt; quantity
    </select>
 
</mapper>