李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
<?xml version="1.0" encoding="UTF-8"?>
 
<!--
  ~
  ~      Copyright (c) 2018-2025, ztt All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the pig4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: ztt
  ~
  -->
 
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="com.chinaztt.mes.basic.mapper.ParamMapper">
 
    <resultMap id="paramMap" type="com.chinaztt.mes.basic.dto.ParamDTO">
        <id property="id" column="id"/>
        <result property="code" column="code"/>
        <result property="parameterItem" column="parameter_item"/>
        <result property="parameterFormat" column="parameter_format"/>
        <result property="type" column="type"/>
        <result property="unit" column="unit"/>
        <result property="createUser" column="create_user"/>
        <result property="updateUser" column="update_user"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="technologyOperationTemplateId" column="technology_operation_template_id"/>
        <result property="index" column="index"/>
        <result property="paramValue" column="param_value"/>
        <result property="defaultValue" column="default_value"/>
        <result property="dict" column="dict"/>
        <collection property="sysDictItemList" ofType="com.chinaztt.ztt.admin.api.entity.SysDictItem"
                    column="dict" select="com.chinaztt.mes.basic.mapper.ParamMapper.getDict">
        </collection>
    </resultMap>
 
    <select id="getDict" resultType="com.chinaztt.ztt.admin.api.entity.SysDictItem">
        SELECT *
        FROM sys_dict_item
        WHERE type = #{dict}
    </select>
 
    <select id="getTechnologyParamPage" resultMap="paramMap">
        SELECT A.*
        FROM basic_param A
        LEFT JOIN technology_join_operation_param B ON B.technology_param_id = A."id"
        LEFT JOIN technology_operation C ON C."id" = B.technology_operation_id
        WHERE C."id" = #{id}
        <if test="ew.emptyOfWhere == false">
            and ${ew.SqlSegment}
        </if>
    </select>
    <select id="getParamById" resultMap="paramMap">
        SELECT D.*,B.technology_operation_template_id,B.sort as index,B.default_value
        FROM basic_template A
        LEFT JOIN basic_param_join_template B ON B.technology_operation_template_id = A."id"
        LEFT JOIN basic_param D ON D."id" = B.technology_operation_param_id
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
        ORDER BY B.sort
    </select>
    <select id="getParam" resultMap="paramMap">
        SELECT D.*,B.default_value
        FROM basic_param D
                 LEFT JOIN basic_param_join_template B ON B.technology_operation_param_id = D."id"
        WHERE B.technology_operation_template_id = #{id}
        order by B.sort
    </select>
    <select id="getTemplateParam" resultMap="paramMap">
        SELECT D.*,B.sort as index,B.default_value,B.technology_operation_template_id
        FROM basic_param D
                 LEFT JOIN basic_param_join_template B ON B.technology_operation_param_id = D."id"
        WHERE B.technology_operation_template_id = #{id}
        order by B.sort
    </select>
 
    <select id="getLastParamById" resultMap="paramMap">
        SELECT
            D.*,
            B.technology_operation_template_id,
            B.sort AS index,
            B.default_value,
            tempA.param_value
        FROM basic_template A
                 LEFT JOIN basic_param_join_template B ON B.technology_operation_template_id = A."id"
                 LEFT JOIN basic_param D ON D."id" = B.technology_operation_param_id
                 LEFT JOIN (SELECT *
                            FROM production_operation_task_param potp
                            WHERE potp.operation_task_record_id =
                                  (SELECT potr."id"
                                   FROM production_operation_task_record potr
                                            LEFT JOIN production_operation_task pot ON pot."id" = potr.operation_task_id
                                   WHERE pot.workstation_id = #{paramDTO.workstationId}
                                     AND potr.operation_template_id = #{paramDTO.technologyOperationTemplateId}
                                   ORDER BY potr.create_time DESC
                                LIMIT 1)
             )
             tempA
        ON tempA
           .
           code =
           D
           .
           code
        WHERE A."id" = #{paramDTO.technologyOperationTemplateId}
        ORDER BY B.sort
    </select>
</mapper>