zhoushihao
2025-07-07 9018bdb6ede7bccd16d78dd2de51bf88754012df
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
<?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.mes.order.mapper.OrdersMapper">
    <resultMap id="baseMap" type="com.mes.order.entity.dto.OrderDTO">
        <result column="order_id" property="orderId"/>
        <result column="customer_name" property="customerName"/>
        <result column="project" property="project"/>
        <result column="area" property="area"/>
        <result column="quantity" property="quantity"/>
        <result column="create_time" property="createTime"/>
        <result column="percent" property="percent"/>
    </resultMap>
    <select id="selectOrderPercent" resultMap="baseMap">
        SELECT a.order_id,
               a.customer_name,
               a.project,
               a.area,
               a.quantity,
               a.create_time,
               round(ifnull(d.finishNum, 0) / a.quantity * 100) as 'percent',
                ifnull(d.finishNum, 0)
        from sd.`order` as a
                 LEFT JOIN (
            SELECT sum(c.reporting_work_num) as 'finishNum',order_id
            from sd.order_process_detail as c
            where c.id in (
                SELECT max(id) from sd.order_process_detail as b GROUP BY b.process_id, order_number
            )
            GROUP BY c.order_id
        ) as d
                           on a.order_id = d.order_id
        where a.warehousing != 2 and a.warehousing >= 0
        ORDER BY  a.order_id desc
    </select>
</mapper>