懒羊羊
2023-11-14 8286c62256f23bc2367a6729c0f46f84215e380b
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
<?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" />
        <result column="beat_time" property="beatTime" />
 
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        beat_time AS "beatTime", 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="snCodeSize" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult" parameterType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam">
        select DISTINCT sfc_code as sfcCode FROM cm_passing_station_collection WHERE sfc_code LIKE CONCAT('%',#{dateLike},'%') GROUP BY sfc_code
    </select>
 
    <select id="getMaxSnCode" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult" parameterType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam">
        SELECT * FROM cm_passing_station_collection ORDER BY create_time DESC LIMIT 1
    </select>
 
    <select id="getBeatTimeList" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult" parameterType="String">
        SELECT * FROM cm_passing_station_collection WHERE sfc_code = #{sfcCode} ORDER BY location_code
    </select>
 
    <select id="bottomLeftChart2" resultType="cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult">
        SELECT COUNT(*) AS num,location_code AS locationCode FROM cm_passing_station_collection GROUP BY location_code
    </select>
 
</mapper>