cl
2024-01-19 e0fac38b26845f25de479783e0c76cf12a5311e0
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?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="cn.stylefeng.guns.modular.cm.passingStationCollection.mapper.PassingStationCollectionMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.cm.passingStationCollection.entity.PassingStationCollection">
        <id column="id" property="id" />
        <result column="work_order_no" property="workOrderNo" />
        <result column="sfc_code" property="sfcCode" />
        <result column="product_code" property="productCode" />
        <result column="production_line" property="productionLine" />
        <result column="location_code" property="locationCode" />
        <result column="equipment_no" property="equipmentNo" />
        <result column="inbound_time" property="inboundTime" />
        <result column="outbound_time" property="outboundTime" />
        <result column="in_rs_sign" property="inRsSign" />
        <result column="in_msg_sign" property="inMsgSign" />
        <result column="out_rs_sign" property="outRsSign" />
        <result column="out_msg_sign" property="outMsgSign" />
        <result column="collection_time" property="collectionTime" />
        <result column="spare_field_1" property="spareField1" />
        <result column="spare_field_2" property="spareField2" />
        <result column="create_user" property="createUser" />
        <result column="create_time" property="createTime" />
        <result column="update_user" property="updateUser" />
        <result column="update_time" property="updateTime" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id AS "id", work_order_no AS "workOrderNo", sfc_code AS "sfcCode", product_code AS "productCode", production_line AS "productionLine", location_code AS "locationCode", equipment_no AS "equipmentNo", inbound_time AS "inboundTime", outbound_time AS "outboundTime", in_rs_sign AS "inRsSign", in_msg_sign AS "inMsgSign", out_rs_sign AS "outRsSign", out_msg_sign AS "outMsgSign", collection_time AS "collectionTime", spare_field_1 AS "spareField1", spare_field_2 AS "spareField2", create_user AS "createUser", create_time AS "createTime", update_user AS "updateUser", update_time AS "updateTime"
    </sql>
 
 
    <select id="customList" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult" parameterType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam">
        select
        <include refid="Base_Column_List"/>
        from cm_passing_station_collection where 1 = 1
        <if test="paramCondition.workOrderNo != null and paramCondition.workOrderNo != ''">
            and work_order_no like CONCAT('%',#{paramCondition.workOrderNo},'%')
        </if>
        <if test="paramCondition.productionLine != null and paramCondition.productionLine != ''">
            and production_line like CONCAT('%',#{paramCondition.productionLine},'%')
        </if>
        <if test="paramCondition.sfcCode != null and paramCondition.sfcCode != ''">
            and sfc_code like CONCAT('%',#{paramCondition.sfcCode},'%')
        </if>
        <if test="paramCondition.locationCode != null and paramCondition.locationCode != ''">
            and location_code like CONCAT('%',#{paramCondition.locationCode},'%')
        </if>
        <if test="paramCondition.startTime != null and paramCondition.startTime != ''">
            and create_time &gt;= #{paramCondition.startTime}
        </if>
        <if test="paramCondition.endTime != null and paramCondition.endTime != ''">
            and create_time &lt;= #{paramCondition.endTime}
        </if>
    </select>
 
    <select id="customMapList" resultType="map" parameterType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam">
        select
        <include refid="Base_Column_List"/>
        from cm_passing_station_collection where 1 = 1
    </select>
 
    <select id="customPageList" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult" parameterType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam">
        select
        <include refid="Base_Column_List"/>
        from cm_passing_station_collection where 1 = 1
        <if test="paramCondition.workOrderNo != null and paramCondition.workOrderNo != ''">
            and work_order_no like CONCAT('%',#{paramCondition.workOrderNo},'%')
        </if>
        <if test="paramCondition.productionLine != null and paramCondition.productionLine != ''">
            and production_line like CONCAT('%',#{paramCondition.productionLine},'%')
        </if>
        <if test="paramCondition.sfcCode != null and paramCondition.sfcCode != ''">
            and sfc_code like CONCAT('%',#{paramCondition.sfcCode},'%')
        </if>
        <if test="paramCondition.locationCode != null and paramCondition.locationCode != ''">
            and location_code like CONCAT('%',#{paramCondition.locationCode},'%')
        </if>
        <if test="paramCondition.startTime != null and paramCondition.startTime != ''">
            and create_time &gt;= #{paramCondition.startTime}
        </if>
        <if test="paramCondition.endTime != null and paramCondition.endTime != ''">
            and create_time &lt;= #{paramCondition.endTime}
        </if>
    </select>
 
    <select id="customPageMapList" resultType="map" parameterType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam">
        select
        <include refid="Base_Column_List"/>
        from cm_passing_station_collection where 1 = 1
    </select>
 
    <select id="getRepairQty" resultType="Integer">
        select COUNT(*) as repairQty from cm_passing_station_collection where DateDiff(dd,create_time,getdate())=0
    </select>
 
    <select id="getRepairQtyWeek" resultType="Integer">
        select COUNT(*) as repairQty from cm_passing_station_collection where DateDiff(week,create_time,getdate())=1
    </select>
 
    <update id="updateSFC">
        update cm_passing_station_collection set sfc_code = #{sfcCode} where sfc_code = #{childSfcCode}
    </update>
 
    <select id="PassRate" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult" parameterType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam">
        SELECT
            location_code as locationCode,
            SUM ( CASE WHEN out_rs_sign = 1 THEN 1 ELSE 0 END ) as 'qualified',
            SUM ( CASE WHEN out_rs_sign = 2 THEN 1 ELSE 0 END ) as 'unqualified',
            FORMAT(CAST(SUM ( CASE WHEN out_rs_sign = 1 THEN 1 ELSE 0 END )*1.00 / COUNT(location_code) AS DECIMAL(8,6)),'P')  as 'passRate'
        FROM
            cm_passing_station_collection
        WHERE
            1 = 1
        <if test="paramCondition.workOrderNo != null and paramCondition.workOrderNo != ''">
            and work_order_no like CONCAT('%',#{paramCondition.workOrderNo},'%')
        </if>
        <if test="paramCondition.productionLine != null and paramCondition.productionLine != ''">
            and production_line like CONCAT('%',#{paramCondition.productionLine},'%')
        </if>
        <if test="paramCondition.sfcCode != null and paramCondition.sfcCode != ''">
            and sfc_code like CONCAT('%',#{paramCondition.sfcCode},'%')
        </if>
        <if test="paramCondition.locationCode != null and paramCondition.locationCode != ''">
            and location_code = #{paramCondition.locationCode}
        </if>
        <if test="paramCondition.startTime != null and paramCondition.startTime != ''">
            and create_time &gt;= #{paramCondition.startTime}
        </if>
        <if test="paramCondition.endTime != null and paramCondition.endTime != ''">
            and create_time &lt;= #{paramCondition.endTime}
        </if>
        GROUP BY
            location_code
    </select>
 
    <select id="bigCenterRightTable" resultType="Integer">
        SELECT COUNT(*) AS sumNumber FROM cm_passing_station_collection
        WHERE 1 = 1
          AND location_code = 'OP170'
          AND work_order_no = #{workOrderNo}
          AND create_time BETWEEN #{startTime} AND #{endTime}
        <if test="qualifiedFlag != null and qualifiedFlag != ''">
            and out_rs_sign = #{qualifiedFlag}
        </if>
    </select>
 
    <select id="centerLeftData" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult">
        SELECT ISNULL(C.num, '0') AS num, L.location_code
        FROM (
                 SELECT 'OP150' AS location_code
                 UNION ALL
                 SELECT 'OP100'
                 UNION ALL
                 SELECT 'OP140'
                 UNION ALL
                 SELECT 'OP070'
                 UNION ALL
                 SELECT 'EOP080'
                 UNION ALL
                 SELECT 'EOP090'
             ) AS L
                 LEFT JOIN (
            SELECT COUNT(*) AS num, location_code
            FROM cm_passing_station_collection
            WHERE work_order_no = #{workOrderNo}
              AND out_rs_sign = '2'
            GROUP BY location_code
 
        ) AS C ON L.location_code = C.location_code
        ORDER BY C.num DESC
    </select>
 
    <select id="getUnqualifiedQuantity" resultType="Integer">
        SELECT
            COUNT(*)
        FROM
            cm_passing_station_collection
        WHERE 1 = 1
          AND location_code IN ( 'OP150', 'OP100', 'OP140', 'OP070', 'EOP080', 'EOP090' )
          AND work_order_no = #{workOrderNo}
          AND out_rs_sign = '2'
    </select>
</mapper>