sfd
2025-05-26 2a64b537e8e3bce9ce030585a3da17d48379c0ad
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?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.aps.core.mapper.ApsStandardProcessRouteHeaderMapper">
    
    <resultMap type="com.aps.core.domain.ApsStandardProcessRouteHeader" id="ApsStandardProcessRouteHeaderResult">
        <result property="id"    column="id"    />
        <result property="itemCode"    column="item_code"    />
        <result property="drawingNumber"    column="drawing_number"    />
        <result property="routeId"    column="route_id"    />
        <result property="version"    column="version"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="orgCode"    column="org_code"    />
        <result property="processAllTime"    column="process_all_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>
 
    <sql id="selectApsStandardProcessRouteHeaderVo">
        select id, route_id, version, start_date, end_date, org_code, del_flag, create_by,
               create_time, update_by, update_time, item_code, drawing_number, process_all_time
        from aps_standard_process_route_header
    </sql>
 
    <select id="selectApsStandardProcessRouteHeaderList" parameterType="com.aps.core.domain.ApsStandardProcessRouteHeader" resultMap="ApsStandardProcessRouteHeaderResult">
        <include refid="selectApsStandardProcessRouteHeaderVo"/>
        <where>  
            <if test="routeId != null  and routeId != ''"> and route_id = #{routeId}</if>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="startDate != null  and startDate != ''"> and start_date = #{startDate}</if>
            <if test="endDate != null  and endDate != ''"> and end_date = #{endDate}</if>
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            <if test="itemCode != null  and itemCode != ''"> and item_code like '%' || #{itemCode} || '%'</if>
            and del_flag = '0'
        </where>
        ORDER BY version desc
    </select>
    
    <select id="selectApsStandardProcessRouteHeaderById" parameterType="Long" resultMap="ApsStandardProcessRouteHeaderResult">
        <include refid="selectApsStandardProcessRouteHeaderVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertApsStandardProcessRouteHeader" parameterType="com.aps.core.domain.ApsStandardProcessRouteHeader">
        insert into aps_standard_process_route_header
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="routeId != null">route_id,</if>
            <if test="version != null">version,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="orgCode != null">org_code,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="routeId != null">#{routeId},</if>
            <if test="version != null">#{version},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="orgCode != null">#{orgCode},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>
 
    <update id="updateApsStandardProcessRouteHeader" parameterType="com.aps.core.domain.ApsStandardProcessRouteHeader">
        update aps_standard_process_route_header
        <trim prefix="SET" suffixOverrides=",">
            <if test="routeId != null">route_id = #{routeId},</if>
            <if test="version != null">version = #{version},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="orgCode != null">org_code = #{orgCode},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteApsStandardProcessRouteHeaderById" parameterType="Long">
        delete from aps_standard_process_route_header where id = #{id}
    </delete>
 
    <delete id="deleteApsStandardProcessRouteHeaderByIds" parameterType="String">
        delete from aps_standard_process_route_header where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="queryStandardProcessRouteHeaderByPlantAndItemCode" parameterType="String" resultMap="ApsStandardProcessRouteHeaderResult">
        <include refid="selectApsStandardProcessRouteHeaderVo"/>
         where del_flag = '0'
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            <if test="itemCode != null  and itemCode != ''"> and item_code = #{itemCode} </if>
    </select>
    
    <select id="selectProcessRouteStandardTimeData" parameterType="String" resultType="com.alibaba.fastjson2.JSONObject">
        select  hd.item_code,sum(standard_time) as standardTime,hd.org_code
        from aps_standard_process_route_line as ln
                 left join aps_standard_process_route_header as hd on ln.route_id=hd.route_id
        where ln.del_flag='0' and hd.del_flag='0'
        <if test="orgCode != null  and orgCode != ''">
          and hd.org_code = #{orgCode}
        </if>
        group by hd.item_code,hd.org_code
    </select>
</mapper>