地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
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
<?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.javaweb.geo.mapper.CollectStatisticsMapper">
    
    <resultMap type="CollectStatistics" id="CollectStatisticsResult">
        <result property="ids"    column="ids"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyName"    column="company_name"    />
        <result property="projectId"    column="project_id"    />
        <result property="projectNum"    column="project_num"    />
        <result property="holeNum"    column="hole_num"    />
        <result property="exceptionProject"    column="exception_project"    />
        <result property="exceptionNum"    column="exception_num"    />
        <result property="jinchiNum"    column="jinchi_num"    />
        <result property="province"    column="province"    />
        <result property="district"    column="district"    />
        <result property="createTime"    column="create_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="dataResouce"    column="data_resouce"    />
        <result property="isDeleted"    column="is_deleted"    />
    </resultMap>
 
    <sql id="selectCollectStatisticsVo">
        select ids, company_id, company_name, project_num, hole_num, exception_project, exception_num, jinchi_num, province, district, create_time, end_time, data_resouce, is_deleted from js_collect_statistics
    </sql>
 
    <select id="selectCollectStatisticsList" parameterType="CollectStatistics" resultMap="CollectStatisticsResult">
        <include refid="selectCollectStatisticsVo"/>
        <where>  
            <if test="companyId != null  and companyId != ''"> and company_id = #{companyId}</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="projectNum != null "> and project_num = #{projectNum}</if>
            <if test="holeNum != null "> and hole_num = #{holeNum}</if>
            <if test="exceptionProject != null "> and exception_project = #{exceptionProject}</if>
            <if test="exceptionNum != null "> and exception_num = #{exceptionNum}</if>
            <if test="jinchiNum != null "> and jinchi_num = #{jinchiNum}</if>
            <if test="province != null  and province != ''"> and province = #{province}</if>
            <if test="district != null  and district != ''"> and district = #{district}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="dataResouce != null  and dataResouce != ''"> and data_resouce = #{dataResouce}</if>
            <if test="isDeleted != null  and isDeleted != ''"> and is_deleted = #{isDeleted}</if>
 
            <if test="params.beginEndTime != null and params.beginEndTime != ''"><!-- 开始时间检索 -->
                and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginEndTime},'%y%m%d')
            </if>
            <if test="params.endEndTime != null and params.endEndTime != ''"><!-- 结束时间检索 -->
                and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endEndTime},'%y%m%d')
            </if>
 
        </where>
    </select>
    
    <select id="selectCollectStatisticsById" parameterType="String" resultMap="CollectStatisticsResult">
        <include refid="selectCollectStatisticsVo"/>
        where ids = #{ids}
    </select>
 
    <!-- 同步统计汇总数据  -->
    <select id="selectCollectStatistic" resultMap="CollectStatisticsResult">
        SELECT
            a.company_id,
            b.full_name as 'company_name',
            a.ids as 'project_id',
            COUNT(company_id) as 'project_num',
            a.province,
            a.district,
            a.create_time,
            a.end_time
        FROM
            js_project a,
            js_company b
        WHERE
            a.company_id = b.ids and a.create_time &lt;= NOW() and a.create_time >= (SELECT DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY))
        GROUP BY
            a.company_id
    </select>
 
    <insert id="insertCollectStatistics" parameterType="CollectStatistics">
        insert into js_collect_statistics
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ids != null  and ids != ''">ids,</if>
            <if test="companyId != null  and companyId != ''">company_id,</if>
            <if test="companyName != null  and companyName != ''">company_name,</if>
            <if test="projectNum != null ">project_num,</if>
            <if test="holeNum != null ">hole_num,</if>
            <if test="exceptionProject != null ">exception_project,</if>
            <if test="exceptionNum != null ">exception_num,</if>
            <if test="jinchiNum != null ">jinchi_num,</if>
            <if test="province != null  and province != ''">province,</if>
            <if test="district != null  and district != ''">district,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="endTime != null ">end_time,</if>
            <if test="dataResouce != null  and dataResouce != ''">data_resouce,</if>
            <if test="isDeleted != null  and isDeleted != ''">is_deleted,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ids != null  and ids != ''">#{ids},</if>
            <if test="companyId != null  and companyId != ''">#{companyId},</if>
            <if test="companyName != null  and companyName != ''">#{companyName},</if>
            <if test="projectNum != null ">#{projectNum},</if>
            <if test="holeNum != null ">#{holeNum},</if>
            <if test="exceptionProject != null ">#{exceptionProject},</if>
            <if test="exceptionNum != null ">#{exceptionNum},</if>
            <if test="jinchiNum != null ">#{jinchiNum},</if>
            <if test="province != null  and province != ''">#{province},</if>
            <if test="district != null  and district != ''">#{district},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="endTime != null ">#{endTime},</if>
            <if test="dataResouce != null  and dataResouce != ''">#{dataResouce},</if>
            <if test="isDeleted != null  and isDeleted != ''">#{isDeleted},</if>
         </trim>
    </insert>
 
    <update id="updateCollectStatistics" parameterType="CollectStatistics">
        update js_collect_statistics
        <trim prefix="SET" suffixOverrides=",">
            <if test="companyId != null  and companyId != ''">company_id = #{companyId},</if>
            <if test="companyName != null  and companyName != ''">company_name = #{companyName},</if>
            <if test="projectNum != null ">project_num = #{projectNum},</if>
            <if test="holeNum != null ">hole_num = #{holeNum},</if>
            <if test="exceptionProject != null ">exception_project = #{exceptionProject},</if>
            <if test="exceptionNum != null ">exception_num = #{exceptionNum},</if>
            <if test="jinchiNum != null ">jinchi_num = #{jinchiNum},</if>
            <if test="province != null  and province != ''">province = #{province},</if>
            <if test="district != null  and district != ''">district = #{district},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="endTime != null ">end_time = #{endTime},</if>
            <if test="dataResouce != null  and dataResouce != ''">data_resouce = #{dataResouce},</if>
            <if test="isDeleted != null  and isDeleted != ''">is_deleted = #{isDeleted},</if>
        </trim>
        where ids = #{ids}
    </update>
 
    <delete id="deleteCollectStatisticsById" parameterType="String">
        delete from js_collect_statistics where ids = #{ids}
    </delete>
 
    <delete id="deleteCollectStatisticsByIds" parameterType="String">
        delete from js_collect_statistics where ids in 
        <foreach item="ids" collection="array" open="(" separator="," close=")">
            #{ids}
        </foreach>
    </delete>
 
    <delete id="emptyTable">
        delete from js_collect_statistics
    </delete>
 
</mapper>