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="org.jeecg.modules.eam.mapper.EamSecondMaintenanceOrderMapper">
 
    <select id="queryPageList" resultType="org.jeecg.modules.eam.entity.EamSecondMaintenanceOrder">
        SELECT
            wmo.*,
            e.equipment_code,
            e.equipment_name,
            e.equipment_model,
            f.process_instance_id AS 'procInstId',
            f.process_definition_key,
            f.process_definition_id,
            f.process_instance_id
        FROM eam_second_maintenance_order wmo
                 INNER JOIN eam_equipment e ON wmo.equipment_id = e.id
                 LEFT JOIN (
            SELECT
                data_id,
                MAX(id) AS max_id -- 获取最大ID
            FROM flow_my_business
            GROUP BY data_id
        ) latest ON wmo.id = latest.data_id
                 LEFT JOIN flow_my_business f ON f.id = latest.max_id
        ${ew.customSqlSegment}
    </select>
    <select id="queryList" resultType="org.jeecg.modules.eam.dto.EamSecondMaintenanceOrderExport">
        select wmo.*,FORMAT(wmo.maintenance_date, 'yyyy年MM月dd日') AS maintenance_date_formatted, e.equipment_code, e.equipment_name,e.equipment_model,f.factory_name
        from eam_second_maintenance_order wmo
        inner join eam_equipment e
        on wmo.equipment_id = e.id
        LEFT JOIN eam_base_factory f ON f.org_code = SUBSTRING ( e.factory_org_code , 1, 6 )
            ${ew.customSqlSegment}
    </select>
</mapper>