zouyu
2023-11-15 9bf01a5f04e5e1821d48b42706fb492e1bf21d86
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?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="parentId" column="parent_id"/>
        <result property="dict" column="dict"/>
        <result property="templateParentId" column="templateParentId"/>
        <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>
 
    <select id="getNos" resultType="java.lang.String">
        SELECT parameter_item
        FROM basic_param
        WHERE code=#{code}
    </select>
    <select id="getTemplateParamPlus" resultMap="paramMap">
        SELECT
            bp.id id,
            bpj.parent_id templateParentId,
            bpj.technology_operation_template_id,
            bpj.technology_operation_param_id,
            bpj.default_value,
            bp.code,
            bp.parameter_item,
            bp."type",
            bp.unit
        FROM
            basic_param_join_template bpj
                LEFT JOIN basic_param bp ON bpj.technology_operation_param_id = bp.ID
        WHERE
            bpj.technology_operation_template_id = #{templateId}
    </select>
</mapper>