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
187
188
189
190
191
192
193
194
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng 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 yifu4cloud.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: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TStatisticsDeclarerMapper">
<resultMap id="tStatisticsDeclarerMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsDeclarer">
<id property="id" column="ID"/>
<result property="declareUnit" column="DECLARE_UNIT"/>
<result property="declareMonth" column="DECLARE_MONTH"/>
<result property="empName" column="EMP_NAME"/>
<result property="empIdcard" column="EMP_IDCARD"/>
<result property="empPhone" column="EMP_PHONE"/>
<result property="occupationType" column="OCCUPATION_TYPE"/>
<result property="occupationMonth" column="OCCUPATION_MONTH"/>
<result property="isZeroDeclare" column="IS_ZERO_DECLARE"/>
<result property="isDeclare" column="IS_DECLARE"/>
<result property="undeclareReason" column="UNDECLARE_REASON"/>
<result property="isZeroFlag" column="IS_ZERO_FLAG"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.DECLARE_UNIT,
a.DECLARE_MONTH,
a.EMP_NAME,
a.EMP_IDCARD,
a.EMP_PHONE,
a.OCCUPATION_TYPE,
a.OCCUPATION_MONTH,
a.IS_ZERO_DECLARE,
a.IS_DECLARE,
a.UNDECLARE_REASON
</sql>
<sql id="tStatisticsDeclarer_where">
<if test="tStatisticsDeclarer != null">
<if test="tStatisticsDeclarer.id != null and tStatisticsDeclarer.id.trim() != ''">
AND a.ID = #{tStatisticsDeclarer.id}
</if>
<if test="tStatisticsDeclarer.declareUnit != null and tStatisticsDeclarer.declareUnit.trim() != ''">
AND a.DECLARE_UNIT like concat(#{tStatisticsDeclarer.declareUnit},'%')
</if>
<if test="tStatisticsDeclarer.declareMonth != null and tStatisticsDeclarer.declareMonth.trim() != ''">
AND a.DECLARE_MONTH = #{tStatisticsDeclarer.declareMonth}
</if>
<if test="tStatisticsDeclarer.empName != null and tStatisticsDeclarer.empName.trim() != ''">
AND a.EMP_NAME = #{tStatisticsDeclarer.empName}
</if>
<if test="tStatisticsDeclarer.empIdcard != null and tStatisticsDeclarer.empIdcard.trim() != ''">
AND a.EMP_IDCARD = #{tStatisticsDeclarer.empIdcard}
</if>
<if test="tStatisticsDeclarer.empPhone != null and tStatisticsDeclarer.empPhone.trim() != ''">
AND a.EMP_PHONE = #{tStatisticsDeclarer.empPhone}
</if>
<if test="tStatisticsDeclarer.occupationType != null and tStatisticsDeclarer.occupationType.trim() != ''">
AND a.OCCUPATION_TYPE = #{tStatisticsDeclarer.occupationType}
</if>
<if test="tStatisticsDeclarer.occupationMonth != null and tStatisticsDeclarer.occupationMonth.trim() != ''">
AND a.OCCUPATION_MONTH = #{tStatisticsDeclarer.occupationMonth}
</if>
<if test="tStatisticsDeclarer.isZeroDeclare != null and tStatisticsDeclarer.isZeroDeclare.trim() != ''">
AND a.IS_ZERO_DECLARE = #{tStatisticsDeclarer.isZeroDeclare}
</if>
<if test="tStatisticsDeclarer.isDeclare != null and tStatisticsDeclarer.isDeclare.trim() != ''">
AND a.IS_DECLARE = #{tStatisticsDeclarer.isDeclare}
</if>
<if test="tStatisticsDeclarer.undeclareReason != null and tStatisticsDeclarer.undeclareReason.trim() != ''">
AND a.UNDECLARE_REASON = #{tStatisticsDeclarer.undeclareReason}
</if>
</if>
</sql>
<sql id="tStatisticsDeclarer_export_where">
<if test="tStatisticsDeclarer != null">
<if test="tStatisticsDeclarer.idList != null">
AND a.ID in
<foreach item="idStr" index="index" collection="tStatisticsDeclarer.idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tStatisticsDeclarer.id != null and tStatisticsDeclarer.id.trim() != ''">
AND a.ID = #{tStatisticsDeclarer.id}
</if>
<if test="tStatisticsDeclarer.declareUnit != null and tStatisticsDeclarer.declareUnit.trim() != ''">
AND a.DECLARE_UNIT like concat(#{tStatisticsDeclarer.declareUnit},'%')
</if>
<if test="tStatisticsDeclarer.declareMonth != null and tStatisticsDeclarer.declareMonth.trim() != ''">
AND a.DECLARE_MONTH = #{tStatisticsDeclarer.declareMonth}
</if>
<if test="tStatisticsDeclarer.empName != null and tStatisticsDeclarer.empName.trim() != ''">
AND a.EMP_NAME = #{tStatisticsDeclarer.empName}
</if>
<if test="tStatisticsDeclarer.empIdcard != null and tStatisticsDeclarer.empIdcard.trim() != ''">
AND a.EMP_IDCARD = #{tStatisticsDeclarer.empIdcard}
</if>
<if test="tStatisticsDeclarer.isZeroDeclare != null and tStatisticsDeclarer.isZeroDeclare.trim() != ''">
AND a.IS_ZERO_DECLARE = #{tStatisticsDeclarer.isZeroDeclare}
</if>
</if>
</sql>
<!--tStatisticsDeclarer简单分页查询-->
<select id="getTStatisticsDeclarerPage" resultMap="tStatisticsDeclarerMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_statistics_declarer a
<where>
1=1
<include refid="tStatisticsDeclarer_where"/>
</where>
order by a.DECLARE_MONTH desc
</select>
<!--tStatisticsDeclarer简单分页查询-->
<select id="exportDeclarer" resultMap="tStatisticsDeclarerMap">
SELECT
a.DECLARE_UNIT,
a.DECLARE_MONTH,
a.EMP_NAME,
a.EMP_IDCARD,
a.EMP_PHONE,
CASE WHEN a.OCCUPATION_TYPE=0 THEN "雇员"
WHEN a.OCCUPATION_TYPE =1 THEN "其他"
ELSE a.OCCUPATION_TYPE END as "OCCUPATION_TYPE",
CASE WHEN a.IS_ZERO_DECLARE=0 THEN "是"
WHEN a.IS_ZERO_DECLARE =1 THEN "否"
ELSE a.IS_ZERO_DECLARE END as "IS_ZERO_DECLARE",
CASE WHEN a.IS_DECLARE=0 THEN "是"
WHEN a.IS_DECLARE =1 THEN "否"
ELSE a.IS_DECLARE END as "IS_DECLARE",
a.UNDECLARE_REASON
FROM t_statistics_declarer a
<where>
1=1
<include refid="tStatisticsDeclarer_export_where"/>
</where>
order by a.DECLARE_MONTH desc
<if test="tStatisticsDeclarer.limitStart != null">
limit #{tStatisticsDeclarer.limitStart},#{tStatisticsDeclarer.limitEnd}
</if>
</select>
<!--统计-->
<select id="doStatisticsTaxDeclarer" resultMap="tStatisticsDeclarerMap">
SELECT
#{nowMonth} DECLARE_MONTH,c.EMP_NAME,c.EMP_IDCARD,c.EMP_PHONE,c.INVOICE_TITLE DECLARE_UNIT,
if(c.FORM_TYPE=0,'0',if(c.FORM_TYPE=3 or c.FORM_TYPE=4,'1','-')) OCCUPATION_TYPE,
'1' IS_ZERO_DECLARE,
'0' IS_ZERO_FLAG
FROM
(SELECT s.* FROM t_salary_account s,
(SELECT a.EMP_NAME,a.EMP_IDCARD,a.EMP_PHONE,a.INVOICE_TITLE,a.FORM_TYPE,MAX(CREATE_TIME) max_day,a.SETTLEMENT_MONTH,
if(a.FORM_TYPE=0,'0',if(a.FORM_TYPE=3 or a.FORM_TYPE=4,'1','-')) CUPATION_TYPE
FROM t_salary_account a WHERE a.DELETE_FLAG = '0' AND a.SETTLEMENT_MONTH = #{lastMonth}
GROUP BY a.EMP_IDCARD,a.INVOICE_TITLE,CUPATION_TYPE,a.SETTLEMENT_MONTH) b
WHERE s.DELETE_FLAG = '0' AND b.max_day = s.CREATE_TIME
AND s.EMP_IDCARD = b.EMP_IDCARD AND s.INVOICE_TITLE = b.INVOICE_TITLE
AND s.SETTLEMENT_MONTH = b.SETTLEMENT_MONTH) c
GROUP BY c.EMP_IDCARD,c.INVOICE_TITLE,c.SETTLEMENT_MONTH,OCCUPATION_TYPE
</select>
<select id="doStatisticsTaxDeclarerYear" resultMap="tStatisticsDeclarerMap">
select b.DECLARE_MONTH,b.EMP_NAME,b.EMP_IDCARD,b.EMP_PHONE,b.DECLARE_UNIT,
b.OCCUPATION_TYPE,
b.IS_ZERO_DECLARE,
b.IS_ZERO_FLAG from (
SELECT
#{nowMonth} DECLARE_MONTH,c.EMP_NAME,c.EMP_IDCARD,c.EMP_PHONE,c.INVOICE_TITLE DECLARE_UNIT,
if(c.FORM_TYPE=0 or c.FORM_TYPE=1 or c.FORM_TYPE=2,'0',if(c.FORM_TYPE=3 or c.FORM_TYPE=4,'1','-')) OCCUPATION_TYPE,
'2' IS_ZERO_DECLARE,
if(DATE_FORMAT(max(c.CREATE_TIME),"%Y%m")>=DATE_FORMAT(DATE_SUB(CURDATE(),INTERVAL 3 MONTH),"%Y%m"),'1','0') IS_ZERO_FLAG
FROM t_salary_account c WHERE c.DELETE_FLAG = '0' and c.SETTLEMENT_MONTH like concat(DATE_FORMAT(NOW(), '%Y'), '%')
GROUP BY c.EMP_IDCARD
having DATE_FORMAT(DATE_SUB(CURDATE(),INTERVAL 1 MONTH),"%Y%m")
>DATE_FORMAT(max(c.CREATE_TIME),"%Y%m")) b
group by b.EMP_IDCARD,b.DECLARE_UNIT,b.OCCUPATION_TYPE
</select>
</mapper>