燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-29 9a8c8a90c7c01b6bc770d4be5baeff72c058468c
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
<?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.yssh.mapper.FeedbackMapper">
    <resultMap id="FeedbackDetailResult" type="com.yssh.entity.FeedbackDetail">
        <id property="id"    column="id"    />
        <result property="tableName"    column="table_name"    />
        <result property="locationName"    column="location_name"    />
        <result property="detectionId"    column="detection_id"    />
        <result property="detectionVocsName"    column="detection_vocs_name"    />
        <result property="detectionValue"    column="detection_value"    />
        <result property="practicalId"    column="practical_id"    />
        <result property="practicalVocsName"    column="practical_vocs_name"    />
        <result property="practicalValue"    column="practical_value"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>
    
    <sql id="feedbackDetailSql">
        SELECT id, table_name, location_name, detection_id, detection_vocs_name, format(detection_value, 2) detection_value,
             practical_id, practical_vocs_name, format(practical_value, 2) practical_value, create_time
        FROM feedback
    </sql>
    
    <select id="selectById" parameterType="java.lang.Long" resultMap="FeedbackDetailResult">
        <include refid="feedbackDetailSql"></include>
        WHERE id = #{id}
    </select>
    
    <select id="selectSevenDayAccuracyAvg" parameterType="java.lang.Long" resultType="java.lang.Double">
        SELECT COUNT(id)/(SELECT COUNT(id) FROM feedback 
        WHERE CONVERT(date_format(create_time, '%Y%m%d%H%'), SIGNED) &gt;= #{beginTime}) FROM feedback 
        WHERE CONVERT(date_format(create_time, '%Y%m%d%H%'), SIGNED) &gt;= #{beginTime}
        AND practical_id IS NULL
    </select>
    
    <insert id="insert" parameterType="com.yssh.entity.FeedbackDetail" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO feedback 
            (table_name, location_name, detection_id, 
            detection_vocs_name, detection_value, practical_id, 
            practical_vocs_name, practical_value, create_time)
        VALUES 
            (#{tableName}, #{locationName}, #{detectionId}, 
            #{detectionVocsName}, #{detectionValue}, #{practicalId}, 
            #{practicalVocsName}, #{practicalValue}, #{createTime})
    </insert>
 
    <update id="update" parameterType="com.yssh.entity.FeedbackDetail">
        UPDATE feedback SET 
        practical_id = #{practicalId}, practical_vocs_name = #{practicalVocsName}, practical_value = #{practicalValue}
        WHERE id = #{id}
    </update>
</mapper>