Browse Source

年龄计算调整

dev
yinzuomei 2 years ago
parent
commit
e1204cf30b
  1. 33
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

33
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -1558,17 +1558,20 @@
temp.CODE, temp.CODE,
count(temp.ID) as totalResi count(temp.ID) as totalResi
from ( from (
SELECT select
u.ID, temp1.id,
YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) as age,
( (
case when u.BIRTHDAY > DATE_SUB(CURDATE(),INTERVAL 50 year) then '0' case when temp1.age < 50 then '0'
when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 59 year) AND DATE_SUB(CURDATE(),INTERVAL 50 year) then '1' when temp1.age >= 50 and temp1.age <= 59 then '1'
when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 69 year) AND DATE_SUB(CURDATE(),INTERVAL 60 year) then '2' when temp1.age >= 60 and temp1.age <= 69 then '2'
when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 79 year) AND DATE_SUB(CURDATE(),INTERVAL 70 year) then '3' when temp1.age >= 70 and temp1.age <= 79 then '3'
when u.BIRTHDAY <= DATE_SUB(CURDATE(),INTERVAL 80 year) then '4' when temp1.age >= 80 then '4'
end end
) as `code` ) as `code`
from (
SELECT
u.ID,
YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) as age
FROM FROM
ic_resi_user u ic_resi_user u
WHERE WHERE
@ -1583,6 +1586,7 @@
<if test='orgType == "grid" '> <if test='orgType == "grid" '>
and u.GRID_ID = #{orgId} and u.GRID_ID = #{orgId}
</if> </if>
)temp1
)temp )temp
group by temp.`code` group by temp.`code`
</select> </select>
@ -1601,8 +1605,7 @@
u.ID_CARD AS idCard, u.ID_CARD AS idCard,
u.GENDER AS gender, u.GENDER AS gender,
( CASE WHEN u.GENDER = '1' THEN '男' WHEN u.GENDER = '2' THEN '女' ELSE '未知' END ) AS genderName, ( CASE WHEN u.GENDER = '1' THEN '男' WHEN u.GENDER = '2' THEN '女' ELSE '未知' END ) AS genderName,
YEAR ( YEAR (NOW())- SUBSTR( u.BIRTHDAY, 1, 4 ) AS age,
NOW())- SUBSTR( u.BIRTHDAY, 1, 4 ) AS age,
u.CULTURE AS educationCode, u.CULTURE AS educationCode,
'' AS educationName, '' AS educationName,
IFNULL(u.CULTURE,'')AS educationCode, IFNULL(u.CULTURE,'')AS educationCode,
@ -1626,19 +1629,19 @@
</if> </if>
<if test='codeType == "age" '> <if test='codeType == "age" '>
<if test=" 0 == code"> <if test=" 0 == code">
and u.BIRTHDAY > DATE_SUB(CURDATE(),INTERVAL 50 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt; 50
</if> </if>
<if test=" 1 == code"> <if test=" 1 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 59 year) AND DATE_SUB(CURDATE(),INTERVAL 50 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;=50 and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt;=59
</if> </if>
<if test=" 2 == code"> <if test=" 2 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 69 year) AND DATE_SUB(CURDATE(),INTERVAL 60 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;= 60 and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt;= 69
</if> </if>
<if test=" 3 == code"> <if test=" 3 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 79 year) AND DATE_SUB(CURDATE(),INTERVAL 70 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;=70 and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt;=79
</if> </if>
<if test=" 4 == code"> <if test=" 4 == code">
and u.BIRTHDAY &lt;= DATE_SUB(CURDATE(),INTERVAL 80 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;=80
</if> </if>
</if> </if>
order by u.ID asc order by u.ID asc

Loading…
Cancel
Save